diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / Telegram / SourceFiles / data / data_search_controller . cpp <nl> ppp b / Telegram / SourceFiles / data / data_search_controller . cpp <nl> SearchController : : CacheEntry : : CacheEntry ( const Query & query ) <nl> } <nl> <nl> SearchController : : SearchController ( not_null < Main : : Session * > session ) <nl> - : _session ( session ) <nl> - , _api ( session - > api ( ) . instance ( ) ) { <nl> + : _session ( session ) { <nl> } <nl> <nl> bool SearchController : : hasInCache ( const Query & query ) const { <nl> void SearchController : : requestMore ( <nl> const auto type = : : Data : : Histories : : RequestType : : History ; <nl> const auto history = _session - > data ( ) . history ( listData - > peer ) ; <nl> auto requestId = histories . sendRequest ( history , type , [ = ] ( Fn < void ( ) > finish ) { <nl> - return _api . request ( <nl> + return _session - > api ( ) . request ( <nl> std : : move ( * prepared ) <nl> ) . done ( [ = ] ( const MTPmessages_Messages & result ) { <nl> listData - > requests . remove ( key ) ; <nl> mmm a / Telegram / SourceFiles / data / data_search_controller . h <nl> ppp b / Telegram / SourceFiles / data / data_search_controller . h <nl> class SearchController final { <nl> Data * listData ) ; <nl> <nl> const not_null < Main : : Session * > _session ; <nl> - MTP : : Sender _api ; <nl> Cache _cache ; <nl> Cache : : iterator _current = _cache . end ( ) ; <nl> <nl>
|
Fix crash in SearchController .
|
telegramdesktop/tdesktop
|
844e9b60ddf01712082e7ff87cfe74bb20d97297
|
2020-02-25T12:13:07Z
|
mmm a / src / Common / MemoryTracker . cpp <nl> ppp b / src / Common / MemoryTracker . cpp <nl> void MemoryTracker : : alloc ( Int64 size ) <nl> Int64 current_hard_limit = hard_limit . load ( std : : memory_order_relaxed ) ; <nl> Int64 current_profiler_limit = profiler_limit . load ( std : : memory_order_relaxed ) ; <nl> <nl> + / / / Cap the limit to the total_memory_tracker , since it may include some drift . <nl> + / / / <nl> + / / / And since total_memory_tracker is reseted to the process resident <nl> + / / / memory peridically ( in AsynchronousMetrics : : update ( ) ) , any limit can be <nl> + / / / capped to it , to avoid possible drift . <nl> + if ( unlikely ( current_hard_limit & & will_be > current_hard_limit ) ) <nl> + { <nl> + Int64 total_amount = total_memory_tracker . get ( ) ; <nl> + if ( amount > total_amount ) <nl> + { <nl> + set ( total_amount ) ; <nl> + will_be = size + total_amount ; <nl> + } <nl> + } <nl> + <nl> std : : bernoulli_distribution fault ( fault_probability ) ; <nl> if ( unlikely ( fault_probability & & fault ( thread_local_rng ) ) ) <nl> { <nl>
|
Merge pull request from azat / fix - user - memory - tracking - drift
|
ClickHouse/ClickHouse
|
072a8e0e40f79c23a28db217d66d20e59f98d769
|
2020-07-09T01:25:55Z
|
mmm a / packaging / msi / FDBInstaller . wxs <nl> ppp b / packaging / msi / FDBInstaller . wxs <nl> <nl> <nl> < Wix xmlns = ' http : / / schemas . microsoft . com / wix / 2006 / wi ' > <nl> < Product Name = ' $ ( var . Title ) ' <nl> - Id = ' { BF0D29C1 - 636A - 41F1 - B2A5 - 872EAC57C15F } ' <nl> + Id = ' { E0036E6A - 8287 - 4BAD - A709 - FBE032AF5415 } ' <nl> UpgradeCode = ' { A95EA002 - 686E - 4164 - 8356 - C715B7F8B1C8 } ' <nl> Version = ' $ ( var . Version ) ' <nl> Manufacturer = ' $ ( var . Manufacturer ) ' <nl> mmm a / versions . target <nl> ppp b / versions . target <nl> <nl> < ? xml version = " 1 . 0 " ? > <nl> < Project xmlns = " http : / / schemas . microsoft . com / developer / msbuild / 2003 " > <nl> < PropertyGroup > <nl> - < Version > 5 . 1 . 6 < / Version > <nl> + < Version > 5 . 1 . 7 < / Version > <nl> < PackageName > 5 . 1 < / PackageName > <nl> < / PropertyGroup > <nl> < / Project > <nl>
|
updated msi installer and versions . target
|
apple/foundationdb
|
318a48c4206d29f97e0f12bb173e6b02214f8019
|
2018-04-18T01:34:20Z
|
mmm a / scene / main / http_request . cpp <nl> ppp b / scene / main / http_request . cpp <nl> void HTTPRequest : : _bind_methods ( ) { <nl> BIND_CONSTANT ( RESULT_NO_RESPONSE ) ; <nl> BIND_CONSTANT ( RESULT_BODY_SIZE_LIMIT_EXCEEDED ) ; <nl> BIND_CONSTANT ( RESULT_REQUEST_FAILED ) ; <nl> - BIND_CONSTANT ( RESULT_REDIRECT_LIMIT_REACHED ) ; <nl> + BIND_CONSTANT ( RESULT_DOWNLOAD_FILE_CANT_OPEN ) ; <nl> BIND_CONSTANT ( RESULT_DOWNLOAD_FILE_WRITE_ERROR ) ; <nl> + BIND_CONSTANT ( RESULT_REDIRECT_LIMIT_REACHED ) ; <nl> <nl> } <nl> <nl>
|
Exposed a RESULT_DOWNLOAD_FILE_CANT_OPEN constant to docs and GDScript .
|
godotengine/godot
|
dd4eaa10051407034bf854a7f876fbb6d1027f01
|
2016-06-03T16:03:12Z
|
mmm a / src / library_html5 . js <nl> ppp b / src / library_html5 . js <nl> var LibraryJSEvents = { <nl> } , <nl> <nl> emscripten_get_pointerlock_status : function ( pointerlockStatus ) { <nl> + if ( pointerlockStatus ) JSEvents . fillPointerlockChangeEventData ( pointerlockStatus ) ; <nl> if ( ! document . body . requestPointerLock & & ! document . body . mozRequestPointerLock & & ! document . body . webkitRequestPointerLock & & ! document . body . msRequestPointerLock ) { <nl> return { { { cDefine ( ' EMSCRIPTEN_RESULT_NOT_SUPPORTED ' ) } } } ; <nl> } <nl> - JSEvents . fillPointerlockChangeEventData ( pointerlockStatus ) ; <nl> return { { { cDefine ( ' EMSCRIPTEN_RESULT_SUCCESS ' ) } } } ; <nl> } , <nl> <nl>
|
Make emscripten_get_pointerlock_status ( ) always fill the output structure even when pointer lock is not supported .
|
emscripten-core/emscripten
|
eaf25d77e31b28d352dd651e1c754c26c694cca5
|
2015-01-22T10:43:24Z
|
mmm a / include / rapidjson / document . h <nl> ppp b / include / rapidjson / document . h <nl> RAPIDJSON_DIAG_OFF ( terminate ) / / ignore throwing RAPIDJSON_ASSERT in RAPIDJSON_N <nl> # endif / / __GNUC__ <nl> <nl> # ifndef RAPIDJSON_NOMEMBERITERATORCLASS <nl> - # include < iterator > / / std : : iterator , std : : random_access_iterator_tag <nl> + # include < iterator > / / std : : random_access_iterator_tag <nl> # endif <nl> <nl> # if RAPIDJSON_HAS_CXX11_RVALUE_REFS <nl> struct GenericMember { <nl> \ see GenericMember , GenericValue : : MemberIterator , GenericValue : : ConstMemberIterator <nl> * / <nl> template < bool Const , typename Encoding , typename Allocator > <nl> - class GenericMemberIterator <nl> - : public std : : iterator < std : : random_access_iterator_tag <nl> - , typename internal : : MaybeAddConst < Const , GenericMember < Encoding , Allocator > > : : Type > { <nl> + class GenericMemberIterator { <nl> <nl> friend class GenericValue < Encoding , Allocator > ; <nl> template < bool , typename , typename > friend class GenericMemberIterator ; <nl> <nl> typedef GenericMember < Encoding , Allocator > PlainType ; <nl> typedef typename internal : : MaybeAddConst < Const , PlainType > : : Type ValueType ; <nl> - typedef std : : iterator < std : : random_access_iterator_tag , ValueType > BaseType ; <nl> <nl> public : <nl> / / ! Iterator type itself <nl> class GenericMemberIterator <nl> / / ! Non - constant iterator type <nl> typedef GenericMemberIterator < false , Encoding , Allocator > NonConstIterator ; <nl> <nl> + / * * \ name std : : iterator_traits support * / <nl> + / / @ { <nl> + typedef ValueType value_type ; <nl> + typedef ValueType * pointer ; <nl> + typedef ValueType & reference ; <nl> + typedef std : : ptrdiff_t difference_type ; <nl> + typedef std : : random_access_iterator_tag iterator_category ; <nl> + / / @ } <nl> + <nl> / / ! Pointer to ( const ) GenericMember <nl> - typedef typename BaseType : : pointer Pointer ; <nl> + typedef pointer Pointer ; <nl> / / ! Reference to ( const ) GenericMember <nl> - typedef typename BaseType : : reference Reference ; <nl> + typedef reference Reference ; <nl> / / ! Signed integer type ( e . g . \ c ptrdiff_t ) <nl> - typedef typename BaseType : : difference_type DifferenceType ; <nl> + typedef difference_type DifferenceType ; <nl> <nl> / / ! Default constructor ( singular value ) <nl> / * ! Creates an iterator pointing to no element . <nl>
|
Merge pull request from pah / fixes / 1131 - iterator - deprecation
|
Tencent/rapidjson
|
87d4e07ffd0fb2603661243b43bdcb647a070aa0
|
2017-12-13T02:52:20Z
|
mmm a / imgui . cpp <nl> ppp b / imgui . cpp <nl> using namespace IMGUI_STB_NAMESPACE ; <nl> <nl> struct ImGuiAabb ; <nl> <nl> - static bool ButtonBehaviour ( const ImGuiAabb & bb , const ImGuiID & id , bool * out_hovered , bool * out_held , bool allow_key_modifiers , bool repeat = false ) ; <nl> + static bool ButtonBehaviour ( const ImGuiAabb & bb , const ImGuiID & id , bool * out_hovered , bool * out_held , bool allow_key_modifiers , bool repeat = false , bool pressed_on_click = false ) ; <nl> static void LogText ( const ImVec2 & ref_pos , const char * text , const char * text_end = NULL ) ; <nl> <nl> static void RenderText ( ImVec2 pos , const char * text , const char * text_end = NULL , bool hide_text_after_hash = true ) ; <nl> static bool IsHovered ( const ImGuiAabb & bb , const ImGuiID & id ) <nl> return false ; <nl> } <nl> <nl> - static bool ButtonBehaviour ( const ImGuiAabb & bb , const ImGuiID & id , bool * out_hovered , bool * out_held , bool allow_key_modifiers , bool repeat ) <nl> + static bool ButtonBehaviour ( const ImGuiAabb & bb , const ImGuiID & id , bool * out_hovered , bool * out_held , bool allow_key_modifiers , bool repeat , bool pressed_on_click ) <nl> { <nl> ImGuiState & g = * GImGui ; <nl> ImGuiWindow * window = GetCurrentWindow ( ) ; <nl> static bool ButtonBehaviour ( const ImGuiAabb & bb , const ImGuiID & id , bool * out_ho <nl> { <nl> if ( g . IO . MouseClicked [ 0 ] ) <nl> { <nl> - SetActiveId ( id ) ; <nl> + if ( pressed_on_click ) <nl> + { <nl> + pressed = true ; <nl> + SetActiveId ( 0 ) ; <nl> + } <nl> + else <nl> + { <nl> + SetActiveId ( id ) ; <nl> + } <nl> FocusWindow ( window ) ; <nl> } <nl> else if ( repeat & & g . ActiveId & & ImGui : : IsMouseClicked ( 0 , true ) ) <nl> bool ImGui : : InputFloat4 ( const char * label , float v [ 4 ] , int decimal_precision ) <nl> return InputFloatN ( label , v , 4 , decimal_precision ) ; <nl> } <nl> <nl> - static bool Combo_ArrayGetter ( void * data , int idx , const char * * out_text ) <nl> + static bool Items_ArrayGetter ( void * data , int idx , const char * * out_text ) <nl> { <nl> const char * * items = ( const char * * ) data ; <nl> if ( out_text ) <nl> static bool Combo_ArrayGetter ( void * data , int idx , const char * * out_text ) <nl> return true ; <nl> } <nl> <nl> - / / Combo box helper allowing to pass an array of strings . <nl> - bool ImGui : : Combo ( const char * label , int * current_item , const char * * items , int items_count , int popup_height_items ) <nl> + static bool Items_SingleStringGetter ( void * data , int idx , const char * * out_text ) <nl> { <nl> - const bool value_changed = Combo ( label , current_item , Combo_ArrayGetter , ( void * ) items , items_count , popup_height_items ) ; <nl> - return value_changed ; <nl> - } <nl> - <nl> - static bool Combo_StringListGetter ( void * data , int idx , const char * * out_text ) <nl> - { <nl> - / / FIXME - OPT : we could precompute the indices to fasten this . But only 1 active combo means the waste is limited . <nl> + / / FIXME - OPT : we could pre - compute the indices to fasten this . But only 1 active combo means the waste is limited . <nl> const char * items_separated_by_zeros = ( const char * ) data ; <nl> int items_count = 0 ; <nl> const char * p = items_separated_by_zeros ; <nl> static bool Combo_StringListGetter ( void * data , int idx , const char * * out_text ) <nl> return true ; <nl> } <nl> <nl> + / / Combo box helper allowing to pass an array of strings . <nl> + bool ImGui : : Combo ( const char * label , int * current_item , const char * * items , int items_count , int popup_height_items ) <nl> + { <nl> + const bool value_changed = Combo ( label , current_item , Items_ArrayGetter , ( void * ) items , items_count , popup_height_items ) ; <nl> + return value_changed ; <nl> + } <nl> + <nl> / / Combo box helper allowing to pass all items in a single string . <nl> bool ImGui : : Combo ( const char * label , int * current_item , const char * items_separated_by_zeros , int popup_height_items ) <nl> { <nl> int items_count = 0 ; <nl> - const char * p = items_separated_by_zeros ; <nl> + const char * p = items_separated_by_zeros ; / / FIXME - OPT : Avoid computing this <nl> while ( * p ) <nl> { <nl> p + = strlen ( p ) + 1 ; <nl> items_count + + ; <nl> } <nl> - bool value_changed = Combo ( label , current_item , Combo_StringListGetter , ( void * ) items_separated_by_zeros , items_count , popup_height_items ) ; <nl> + bool value_changed = Combo ( label , current_item , Items_SingleStringGetter , ( void * ) items_separated_by_zeros , items_count , popup_height_items ) ; <nl> return value_changed ; <nl> } <nl> <nl>
|
Internal ButtonBehaviour ( ) supports a pressed_on_click mode ( unused yet ) + Renamed internal Combo * getters to Items * getters
|
ocornut/imgui
|
220d9205819dffac08a64acd504ebc0075605d94
|
2015-02-10T17:45:45Z
|
mmm a / arangod / Cluster / HeartbeatThread . cpp <nl> ppp b / arangod / Cluster / HeartbeatThread . cpp <nl> static std : : chrono : : system_clock : : time_point deadThreadsPosted ; / / defaults to <nl> <nl> static arangodb : : Mutex deadThreadsMutex ; <nl> <nl> + namespace arangodb { <nl> + <nl> + <nl> + class HeartbeatBackgroundJobThread : public Thread { <nl> + <nl> + public : <nl> + HeartbeatBackgroundJobThread ( HeartbeatThread * heartbeatThread ) : <nl> + Thread ( " Maintenance " ) , <nl> + _heartbeatThread ( heartbeatThread ) , <nl> + _stop ( false ) , <nl> + _sleeping ( false ) , <nl> + _backgroundJobsLaunched ( 0 ) <nl> + { } <nl> + <nl> + ~ HeartbeatBackgroundJobThread ( ) { shutdown ( ) ; } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief asks the thread to stop , but does not wait . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void stop ( ) { <nl> + std : : unique_lock < std : : mutex > guard ( _mutex ) ; <nl> + _stop = true ; <nl> + _condition . notify_one ( ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief notifies the background thread : when the thread is sleeping , wakes <nl> + / / / it up . Otherwise sets a flag to start another round . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void notify ( ) { <nl> + std : : unique_lock < std : : mutex > guard ( _mutex ) ; <nl> + _anotherRun . store ( true , std : : memory_order_release ) ; <nl> + if ( _sleeping . load ( std : : memory_order_acquire ) ) { <nl> + _condition . notify_one ( ) ; <nl> + } <nl> + } <nl> + <nl> + protected : <nl> + void run ( ) override { <nl> + <nl> + while ( ! _stop ) { <nl> + <nl> + { <nl> + std : : unique_lock < std : : mutex > guard ( _mutex ) ; <nl> + <nl> + if ( ! _anotherRun . load ( std : : memory_order_acquire ) ) { <nl> + _sleeping . store ( true , std : : memory_order_release ) ; <nl> + <nl> + while ( true ) { <nl> + _condition . wait ( guard ) ; <nl> + <nl> + if ( _stop ) { <nl> + return ; <nl> + } else if ( _anotherRun ) { <nl> + break ; <nl> + } / / otherwise spurious wakeup <nl> + } <nl> + <nl> + _sleeping . store ( false , std : : memory_order_release ) ; <nl> + } <nl> + <nl> + _anotherRun . store ( false , std : : memory_order_release ) ; <nl> + } <nl> + <nl> + / / execute schmutz here <nl> + uint64_t jobNr = + + _backgroundJobsLaunched ; <nl> + LOG_TOPIC ( DEBUG , Logger : : HEARTBEAT ) < < " sync callback started " < < jobNr ; <nl> + { <nl> + DBServerAgencySync job ( _heartbeatThread ) ; <nl> + job . work ( ) ; <nl> + } <nl> + LOG_TOPIC ( DEBUG , Logger : : HEARTBEAT ) < < " sync callback ended " < < jobNr ; <nl> + <nl> + } <nl> + } <nl> + <nl> + private : <nl> + HeartbeatThread * _heartbeatThread ; <nl> + <nl> + std : : mutex _mutex ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief used to wake up the background thread <nl> + / / / guarded via _mutex . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + std : : condition_variable _condition ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Set by the HeartbeatThread when the BackgroundThread should stop <nl> + / / / guarded via _mutex . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + std : : atomic < bool > _stop ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief wether the background thread sleeps or not <nl> + / / / guarded via _mutex . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + std : : atomic < bool > _sleeping ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief when awake , the background thread will execute another round of <nl> + / / / phase 1 and phase 2 , after resetting this to false <nl> + / / / guarded via _mutex . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + std : : atomic < bool > _anotherRun ; <nl> + <nl> + uint64_t _backgroundJobsLaunched ; <nl> + } ; <nl> + } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief constructs a heartbeat thread <nl> HeartbeatThread : : HeartbeatThread ( AgencyCallbackRegistry * agencyCallbackRegistry , <nl> _desiredVersions ( std : : make_shared < AgencyVersions > ( 0 , 0 ) ) , <nl> _wasNotified ( false ) , <nl> _backgroundJobsPosted ( 0 ) , <nl> - _backgroundJobsLaunched ( 0 ) , <nl> - _backgroundJobScheduledOrRunning ( false ) , <nl> - _launchAnotherBackgroundJob ( false ) , <nl> - _lastSyncTime ( 0 ) { <nl> + _lastSyncTime ( 0 ) , <nl> + _maintenanceThread ( nullptr ) { <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief destroys a heartbeat thread <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - HeartbeatThread : : ~ HeartbeatThread ( ) { shutdown ( ) ; } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief running of heartbeat background jobs ( in JavaScript ) , we run <nl> - / / / these by instantiating an object in class HeartbeatBackgroundJob , <nl> - / / / which is a std : : function < void ( ) > and holds a shared_ptr to the <nl> - / / / HeartbeatThread singleton itself . This instance is then posted to <nl> - / / / the io_service for execution in the thread pool . Should the heartbeat <nl> - / / / thread itself terminate during shutdown , then the HeartbeatThread <nl> - / / / singleton itself is still kept alive by the shared_ptr in the instance <nl> - / / / of HeartbeatBackgroundJob . The operator ( ) method simply calls the <nl> - / / / runBackgroundJob ( ) method of the heartbeat thread . Should this have <nl> - / / / to schedule another background job , then it can simply create a new <nl> - / / / HeartbeatBackgroundJob instance , again using shared_from_this ( ) to <nl> - / / / create a new shared_ptr keeping the HeartbeatThread object alive . <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - class HeartbeatBackgroundJob { <nl> - std : : shared_ptr < HeartbeatThread > _heartbeatThread ; <nl> - double _startTime ; <nl> - std : : string _schedulerInfo ; <nl> - public : <nl> - explicit HeartbeatBackgroundJob ( std : : shared_ptr < HeartbeatThread > hbt , <nl> - double startTime ) <nl> - : _heartbeatThread ( hbt ) , _startTime ( startTime ) , _schedulerInfo ( SchedulerFeature : : SCHEDULER - > infoStatus ( ) ) { <nl> - } <nl> - <nl> - void operator ( ) ( ) { <nl> - / / first tell the scheduler that this thread is working : <nl> - JobGuard guard ( SchedulerFeature : : SCHEDULER ) ; <nl> - guard . work ( ) ; <nl> - <nl> - double now = TRI_microtime ( ) ; <nl> - if ( now > _startTime + 5 . 0 ) { <nl> - LOG_TOPIC ( ERR , Logger : : HEARTBEAT ) < < " ALARM : Scheduling background job " <nl> - " took " < < now - _startTime <nl> - < < " seconds , scheduler info at schedule time : " < < _schedulerInfo <nl> - < < " , scheduler info now : " <nl> - < < SchedulerFeature : : SCHEDULER - > infoStatus ( ) ; <nl> - } <nl> - _heartbeatThread - > runBackgroundJob ( ) ; <nl> - } <nl> - } ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief method runBackgroundJob ( ) <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void HeartbeatThread : : runBackgroundJob ( ) { <nl> - uint64_t jobNr = + + _backgroundJobsLaunched ; <nl> - LOG_TOPIC ( DEBUG , Logger : : HEARTBEAT ) < < " sync callback started " < < jobNr ; <nl> - { <nl> - DBServerAgencySync job ( this ) ; <nl> - job . work ( ) ; <nl> - } <nl> - LOG_TOPIC ( DEBUG , Logger : : HEARTBEAT ) < < " sync callback ended " < < jobNr ; <nl> - <nl> - { <nl> - MUTEX_LOCKER ( mutexLocker , * _statusLock ) ; <nl> - TRI_ASSERT ( _backgroundJobScheduledOrRunning ) ; <nl> - <nl> - if ( _launchAnotherBackgroundJob ) { <nl> - jobNr = + + _backgroundJobsPosted ; <nl> - LOG_TOPIC ( DEBUG , Logger : : HEARTBEAT ) < < " dispatching sync tail " < < jobNr ; <nl> - _launchAnotherBackgroundJob = false ; <nl> - <nl> - / / the JobGuard is in the operator ( ) of HeartbeatBackgroundJob <nl> - _lastSyncTime = TRI_microtime ( ) ; <nl> - SchedulerFeature : : SCHEDULER - > post ( <nl> - HeartbeatBackgroundJob ( shared_from_this ( ) , _lastSyncTime ) , false ) ; <nl> - } else { <nl> - _backgroundJobScheduledOrRunning = false ; <nl> - _launchAnotherBackgroundJob = false ; <nl> - } <nl> + HeartbeatThread : : ~ HeartbeatThread ( ) { <nl> + if ( _maintenanceThread ) { <nl> + _maintenanceThread - > stop ( ) ; <nl> } <nl> + shutdown ( ) ; <nl> } <nl> <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief heartbeat main loop <nl> / / / the heartbeat thread constantly reports the current server status to the <nl> void HeartbeatThread : : runBackgroundJob ( ) { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> void HeartbeatThread : : run ( ) { <nl> + <nl> ServerState : : RoleEnum role = ServerState : : instance ( ) - > getRole ( ) ; <nl> <nl> / / mop : the heartbeat thread itself is now ready <nl> void HeartbeatThread : : run ( ) { <nl> <nl> void HeartbeatThread : : runDBServer ( ) { <nl> <nl> + _maintenanceThread = std : : make_unique < HeartbeatBackgroundJobThread > ( this ) ; <nl> + if ( ! _maintenanceThread - > start ( ) ) { <nl> + / / WHAT TO DO NOW ? <nl> + LOG_TOPIC ( ERR , Logger : : HEARTBEAT ) < < " Failed to start dedicated thread for maintenance " ; <nl> + } <nl> + <nl> std : : function < bool ( VPackSlice const & result ) > updatePlan = <nl> [ = ] ( VPackSlice const & result ) { <nl> <nl> void HeartbeatThread : : runSingleServer ( ) { <nl> continue ; / / try again next time <nl> } <nl> } <nl> - <nl> + <nl> TRI_voc_tick_t lastTick = 0 ; / / we always want to set lastTick <nl> auto sendTransient = [ & ] ( ) { <nl> VPackBuilder builder ; <nl> void HeartbeatThread : : runSingleServer ( ) { <nl> applier - > stopAndJoin ( ) ; <nl> } <nl> lastTick = EngineSelectorFeature : : ENGINE - > currentTick ( ) ; <nl> - <nl> + <nl> / / put the leader in optional read - only mode <nl> auto readOnlySlice = response . get ( std : : vector < std : : string > ( <nl> { AgencyCommManager : : path ( ) , " Readonly " } ) ) ; <nl> void HeartbeatThread : : runSingleServer ( ) { <nl> <nl> ServerState : : instance ( ) - > setFoxxmaster ( leaderStr ) ; / / leader is foxxmater <nl> ServerState : : instance ( ) - > setReadOnly ( true ) ; / / Disable writes with dirty - read header <nl> - <nl> + <nl> std : : string endpoint = ci - > getServerEndpoint ( leaderStr ) ; <nl> if ( endpoint . empty ( ) ) { <nl> LOG_TOPIC ( ERR , Logger : : HEARTBEAT ) < < " Failed to resolve leader endpoint " ; <nl> void HeartbeatThread : : updateServerMode ( VPackSlice const & readOnlySlice ) { <nl> if ( readOnlySlice . isBoolean ( ) ) { <nl> readOnly = readOnlySlice . getBool ( ) ; <nl> } <nl> - <nl> + <nl> ServerState : : instance ( ) - > setReadOnly ( readOnly ) ; <nl> } <nl> <nl> bool HeartbeatThread : : handlePlanChangeCoordinator ( uint64_t currentPlanVersion ) { <nl> } <nl> std : : string const name = options . value . get ( " name " ) . copyString ( ) ; <nl> TRI_ASSERT ( ! name . empty ( ) ) ; <nl> - <nl> + <nl> VPackSlice const idSlice = options . value . get ( " id " ) ; <nl> if ( ! idSlice . isString ( ) ) { <nl> LOG_TOPIC ( ERR , Logger : : HEARTBEAT ) < < " Missing id in agency database plan " ; <nl> void HeartbeatThread : : syncDBServerStatusQuo ( bool asyncPush ) { <nl> <nl> MUTEX_LOCKER ( mutexLocker , * _statusLock ) ; <nl> bool shouldUpdate = false ; <nl> - <nl> + <nl> if ( _desiredVersions - > plan > _currentVersions . plan ) { <nl> LOG_TOPIC ( DEBUG , Logger : : HEARTBEAT ) <nl> < < " Plan version " < < _currentVersions . plan <nl> void HeartbeatThread : : syncDBServerStatusQuo ( bool asyncPush ) { <nl> < < " is lower than desired version " < < _desiredVersions - > current ; <nl> shouldUpdate = true ; <nl> } <nl> - <nl> + <nl> / / 7 . 4 seconds is just less than half the 15 seconds agency uses to declare dead server , <nl> / / perform a safety execution of job in case other plan changes somehow incomplete or undetected <nl> double now = TRI_microtime ( ) ; <nl> if ( now > _lastSyncTime + 7 . 4 | | asyncPush ) { <nl> shouldUpdate = true ; <nl> } <nl> - <nl> + <nl> if ( ! shouldUpdate ) { <nl> return ; <nl> } <nl> - <nl> + <nl> / / First invalidate the caches in ClusterInfo : <nl> auto ci = ClusterInfo : : instance ( ) ; <nl> if ( _desiredVersions - > plan > ci - > getPlanVersion ( ) ) { <nl> void HeartbeatThread : : syncDBServerStatusQuo ( bool asyncPush ) { <nl> if ( _desiredVersions - > current > ci - > getCurrentVersion ( ) ) { <nl> ci - > invalidateCurrent ( ) ; <nl> } <nl> - <nl> - if ( _backgroundJobScheduledOrRunning ) { <nl> - _launchAnotherBackgroundJob = true ; <nl> - return ; <nl> - } <nl> - <nl> + <nl> / / schedule a job for the change : <nl> uint64_t jobNr = + + _backgroundJobsPosted ; <nl> LOG_TOPIC ( DEBUG , Logger : : HEARTBEAT ) < < " dispatching sync " < < jobNr ; <nl> - _backgroundJobScheduledOrRunning = true ; <nl> - <nl> - / / the JobGuard is in the operator ( ) of HeartbeatBackgroundJob <nl> + <nl> _lastSyncTime = TRI_microtime ( ) ; <nl> - SchedulerFeature : : SCHEDULER - > post ( <nl> - HeartbeatBackgroundJob ( shared_from_this ( ) , _lastSyncTime ) , false ) ; <nl> - <nl> + TRI_ASSERT ( _maintenanceThread ! = nullptr ) ; <nl> + _maintenanceThread - > notify ( ) ; <nl> + <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void HeartbeatThread : : logThreadDeaths ( bool force ) { <nl> LOG_TOPIC ( DEBUG , Logger : : HEARTBEAT ) < < " HeartbeatThread ok . " ; <nl> std : : string buffer ; <nl> buffer . reserve ( 40 ) ; <nl> - <nl> + <nl> for ( auto const & it : deadThreads ) { <nl> buffer = date : : format ( " % FT % TZ " , date : : floor < std : : chrono : : milliseconds > ( it . first ) ) ; <nl> <nl> mmm a / arangod / Cluster / HeartbeatThread . h <nl> ppp b / arangod / Cluster / HeartbeatThread . h <nl> struct AgencyVersions { <nl> } ; <nl> <nl> class AgencyCallbackRegistry ; <nl> + class HeartbeatBackgroundJobThread ; <nl> <nl> class HeartbeatThread : public CriticalThread , <nl> public std : : enable_shared_from_this < HeartbeatThread > { <nl> class HeartbeatThread : public CriticalThread , <nl> <nl> void setReady ( ) { _ready . store ( true ) ; } <nl> <nl> - void runBackgroundJob ( ) ; <nl> + / / void runBackgroundJob ( ) ; <nl> <nl> void dispatchedJobResult ( DBServerAgencySyncResult ) ; <nl> <nl> class HeartbeatThread : public CriticalThread , <nl> <nl> std : : atomic < uint64_t > _backgroundJobsPosted ; <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief number of background jobs that have been launched by the scheduler <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - std : : atomic < uint64_t > _backgroundJobsLaunched ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief flag indicates whether or not a background job is either <nl> - / / / scheduled with boost : : asio or is already running , this and the <nl> - / / / next one about having to start another background job when the <nl> - / / / current one is finished are protected by the statusLock . <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool _backgroundJobScheduledOrRunning ; <nl> + / / when was the sync routine last run ? <nl> + double _lastSyncTime ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief flag indicates whether or not a new background job needs <nl> - / / / to be started when the current one has terminated . This and the <nl> - / / / previous one are protected by the statusLock . <nl> + / / / @ brief handle of the dedicated thread to execute the phase 1 and phase 2 <nl> + / / / code . Only created on dbservers . <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool _launchAnotherBackgroundJob ; <nl> - <nl> - / / when was the javascript sync routine last run ? <nl> - double _lastSyncTime ; <nl> + std : : unique_ptr < HeartbeatBackgroundJobThread > _maintenanceThread ; <nl> } ; <nl> } <nl> <nl> mmm a / arangod / Cluster / UpdateCollection . cpp <nl> ppp b / arangod / Cluster / UpdateCollection . cpp <nl> UpdateCollection : : UpdateCollection ( <nl> ActionBase ( feature , desc ) { <nl> <nl> std : : stringstream error ; <nl> - <nl> + <nl> _labels . emplace ( FAST_TRACK ) ; <nl> <nl> if ( ! desc . has ( COLLECTION ) ) { <nl> bool UpdateCollection : : first ( ) { <nl> if ( ! _result . ok ( ) ) { <nl> LOG_TOPIC ( ERR , Logger : : MAINTENANCE ) < < " failed to update properties " <nl> " of collection " < < shard < < " : " < < _result . errorMessage ( ) ; <nl> - _feature . storeShardError ( database , collection , shard , <nl> - _description . get ( SERVER_ID ) , _result ) ; <nl> } <nl> } ) ; <nl> <nl> bool UpdateCollection : : first ( ) { <nl> < < " in database " + database ; <nl> LOG_TOPIC ( ERR , Logger : : MAINTENANCE ) < < error . str ( ) ; <nl> _result = actionError ( TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND , error . str ( ) ) ; <nl> - <nl> - return false ; <nl> } <nl> } catch ( std : : exception const & e ) { <nl> std : : stringstream error ; <nl> bool UpdateCollection : : first ( ) { <nl> error < < " action " < < _description < < " failed with exception " < < e . what ( ) ; <nl> LOG_TOPIC ( WARN , Logger : : MAINTENANCE ) < < " UpdateCollection : " < < error . str ( ) ; <nl> _result . reset ( TRI_ERROR_INTERNAL , error . str ( ) ) ; <nl> + } <nl> <nl> - return false ; <nl> + if ( _result . fail ( ) ) { <nl> + _feature . storeShardError ( database , collection , shard , <nl> + _description . get ( SERVER_ID ) , _result ) ; <nl> } <nl> <nl> notify ( ) ; <nl>
|
Dedicated thread for Phase 1 & 2 - devel ( )
|
arangodb/arangodb
|
95345fff8feba91fd639a6edc4f532d07a26886b
|
2018-09-07T12:46:01Z
|
mmm a / CMake / CMakeLibs . cmake <nl> ppp b / CMake / CMakeLibs . cmake <nl> macro ( GET_GENERATION_DEPS BASE_PATH ) <nl> file ( GLOB TABLE_FILES_TEMPLATES " $ { BASE_PATH } / osquery / tables / templates / * . in " ) <nl> set ( GENERATION_DEPENDENCIES <nl> " $ { BASE_PATH } / tools / codegen / * . py " <nl> - " $ { BASE_PATH } / osquery / tables / specs / blacklist " <nl> + " $ { BASE_PATH } / specs / blacklist " <nl> ) <nl> list ( APPEND GENERATION_DEPENDENCIES $ { TABLE_FILES_TEMPLATES } ) <nl> endmacro ( ) <nl> macro ( AMALGAMATE BASE_PATH NAME OUTPUT ) <nl> add_custom_command ( <nl> OUTPUT " $ { CMAKE_BINARY_DIR } / generated / $ { NAME } _amalgamation . cpp " <nl> COMMAND $ { PYTHON_EXECUTABLE } " $ { BASE_PATH } / tools / codegen / amalgamate . py " <nl> - " $ { BASE_PATH } / osquery / tables / " " $ { CMAKE_BINARY_DIR } / generated " " $ { NAME } " <nl> + " $ { BASE_PATH } / tools / codegen / " " $ { CMAKE_BINARY_DIR } / generated " " $ { NAME } " <nl> DEPENDS $ { GENERATED_TARGETS } $ { GENERATION_DEPENDENCIES } <nl> WORKING_DIRECTORY " $ { CMAKE_SOURCE_DIR } " <nl> ) <nl> mmm a / CMake / FindCppNetlib . cmake <nl> ppp b / CMake / FindCppNetlib . cmake <nl> set ( CPP - NETLIB_LINK_DIR " $ { CPP - NETLIB_BUILD_DIR } / libs / network / src " ) <nl> set ( CPP - NETLIB_LIBRARY <nl> " $ { CPP - NETLIB_LINK_DIR } / libcppnetlib - uri . a " <nl> " $ { CPP - NETLIB_LINK_DIR } / libcppnetlib - client - connections . a " <nl> - " $ { CPP - NETLIB_LINK_DIR } / libcppnetlib - server - parsers . a " <nl> ) <nl> <nl> - # LOG ( " Found library dependency $ { CPP - NETLIB_LINK_DIR } / libcppnetlib - uri . a " ) <nl> - LOG_LIBRARY ( cpp - netlib " $ { CPP - NETLIB_LINK_DIR } / libcppnetlib - client - connections . a " ) <nl> - LOG_LIBRARY ( cpp - netlib " $ { CPP - NETLIB_LINK_DIR } / libcppnetlib - server - parsers . a " ) <nl> LOG_LIBRARY ( cpp - netlib " $ { CPP - NETLIB_LINK_DIR } / libcppnetlib - uri . a " ) <nl> + LOG_LIBRARY ( cpp - netlib " $ { CPP - NETLIB_LINK_DIR } / libcppnetlib - client - connections . a " ) <nl> mmm a / docs / wiki / deployment / performance - safety . md <nl> ppp b / docs / wiki / deployment / performance - safety . md <nl> The build will run each of the support operating system platform / versions and in <nl> <nl> Performance impacting virtual tables are most likely the result of missing features / tooling in osquery . Because of their dependencies on core optimizations there ' s no hard including the table generation code in master as long as the table is blacklisted when a non - developer builds the tool suite . <nl> <nl> - If you are developing latent tables that would be blacklisted please make sure you are relying on a feature with a clear issue and traction . Then add your table name ( as it appears in the ` . table ` spec ) to ` osquery / tables / specs / blacklist ` and adopt : <nl> + If you are developing latent tables that would be blacklisted please make sure you are relying on a feature with a clear issue and traction . Then add your table name ( as it appears in the ` . table ` spec ) to [ ` specs / blacklist ` ] ( https : / / github . com / facebook / osquery / blob / master / specs / blacklist ) and adopt : <nl> <nl> ` ` ` <nl> $ DISABLE_BLACKLIST = 1 make <nl> mmm a / docs / wiki / development / creating - tables . md <nl> ppp b / docs / wiki / development / creating - tables . md <nl> <nl> - SQL tables are used to represent abstract operating system concepts , such as running processes . <nl> - <nl> - A table can be used in conjunction with other tables via operations like sub - queries and joins . This allows for a rich data exploration experience . While osquery ships with a default set of tables , osquery provides an API that allows you to create new tables . <nl> - <nl> - You can explore current tables : [ https : / / osquery . io / tables ] ( https : / / osquery . io / tables ) . Tables that are up for grabs in terms of development can be found on Github issues using the " virtual tables " + " [ up for grabs tag ] ( https : / / github . com / facebook / osquery / issues ? q = is % 3Aopen + is % 3Aissue + label % 3A % 22virtual + tables % 22 ) " . <nl> - <nl> - # # New Table Walkthrough <nl> - <nl> - Let ' s walk through an exercise where we build a ' time ' table . The table will have one row , and that row will have three columns : hour , minute , and second . <nl> - <nl> - Column values ( a single row ) will be dynamically computed at query time . <nl> - <nl> - * * Table specifications * * <nl> - <nl> - Under the hood , osquery uses libraries from SQLite core to create " virtual tables " . The default API for creating virtual tables is relatively complex . osquery has abstracted this complexity away , allowing you to write a simple table declaration . <nl> - <nl> - To make table - creation simple osquery uses a * table spec * file . <nl> - The current specs are organized by operating system in the [ osquery / tables / specs ] ( https : / / github . com / facebook / osquery / tree / master / osquery / tables / specs ) source folder . <nl> - For our time exercise , a spec file would look like the following : <nl> - <nl> - ` ` ` python <nl> - # Use the table_name function to define a virtual table name . <nl> - table_name ( " time " ) <nl> - <nl> - # Provide a short " one line " description . <nl> - description ( " Returns the current hour , minutes , and seconds . " ) <nl> - <nl> - # Define your schema , which accepts a list of Column instances at minimum . <nl> - # You may also describe foreign keys and " action " columns ( more later ) . <nl> - schema ( [ <nl> - # Declare the name , type , and documentation description for each column . <nl> - # The supported types are INTEGER , BIGINT , TEXT , DATE , and DATETIME . <nl> - Column ( " hour " , INTEGER , " The current hour " ) , <nl> - Column ( " minutes " , INTEGER , " The current minutes past the hour " ) , <nl> - Column ( " seconds " , INTEGER , " The current seconds past the minute " ) , <nl> - ] ) <nl> - <nl> - # Name of the C + + function that implements the table : " gen { TableName } " <nl> - implementation ( " genTime " ) <nl> - ` ` ` <nl> - <nl> - You can leave the comments out in your production spec . Shoot for simplicity , do NOT go " hard in the paint " and do things like inheritance for Column objects , loops in your table spec , etc . <nl> - <nl> - You might wonder " this syntax looks similar to Python ? " . Well , it is ! The build process actually parses the spec files as Python code and meta - programs necessary C / C + + implementation files . <nl> - <nl> - * * Where do I put the spec ? * * <nl> - <nl> - You may be wondering how osquery handles cross - platform support while still allowing operating - system specific tables . The osquery build process takes care of this by only generating the relevant code based on a directory structure convention . <nl> - <nl> - - Cross - platform : [ osquery / tables / specs / ] ( https : / / github . com / facebook / osquery / tree / master / osquery / tables / specs / ) <nl> - - Mac OS X : [ osquery / tables / specs / darwin / ] ( https : / / github . com / facebook / osquery / tree / master / osquery / tables / specs / darwin ) <nl> - - General Linux : [ osquery / tables / specs / linux / ] ( https : / / github . com / facebook / osquery / tree / master / osquery / tables / specs / linux ) <nl> - - Ubuntu : [ osquery / tables / specs / ubuntu / ] ( https : / / github . com / facebook / osquery / tree / master / osquery / tables / specs / ubuntu ) <nl> - - CentOS : [ osquery / tables / specs / centos / ] ( https : / / github . com / facebook / osquery / tree / master / osquery / tables / specs / centos ) <nl> - <nl> - Note : the CMake build provides custom defines for each platform and platform version . <nl> - <nl> - * * Creating your implementation * * <nl> - <nl> - As indicated in the spec file , our implementation will be in a function called ` genTime ` . Since this is a very general table and should compile on all supported operating systems we can place it in * osquery / tables / utility / time . cpp * . The directory * osquery / table / * contains the set of * specs * and implementation categories . Place implementations in the corresponding category using your best judgement . <nl> - <nl> - Here is that code for * osquery / tables / utility / time . cpp * : <nl> - <nl> - ` ` ` cpp <nl> - / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> - <nl> - # include < ctime > <nl> - # include < osquery / tables . h > <nl> - <nl> - namespace osquery { <nl> - namespace tables { <nl> - <nl> - QueryData genTime ( QueryContext & context ) { <nl> - Row r ; <nl> - QueryData results ; <nl> - <nl> - time_t _time = time ( 0 ) ; <nl> - struct tm * now = localtime ( & _time ) ; <nl> - <nl> - r [ " hour " ] = INTEGER ( now - > tm_hour ) ; <nl> - r [ " minutes " ] = INTEGER ( now - > tm_min ) ; <nl> - r [ " seconds " ] = INTEGER ( now - > tm_sec ) ; <nl> - <nl> - results . push_back ( r ) ; <nl> - return results ; <nl> - } <nl> - } <nl> - } <nl> - ` ` ` <nl> - <nl> - Key points to remember : <nl> - <nl> - - Your implementation function should be in the ` osquery : : tables ` namespace . <nl> - - Your implementation function should accept on ` QueryContext & ` parameter and return an instance of ` QueryData ` <nl> - <nl> - # # Using where clauses <nl> - <nl> - The ` QueryContext ` data type is osquery ' s abstraction of the underlying SQL engine ' s query parsing . It is defined in [ include / osquery / tables . h ] ( https : / / github . com / facebook / osquery / blob / master / include / osquery / tables . h ) . <nl> - <nl> - The most important use of the context is query predicate constraints ( e . g . , ` WHERE col = ' value ' ` ) . Some tables MUST have a predicate constraint , others may optionally use the constraints to increase performance . <nl> - <nl> - Examples : <nl> - <nl> - ` hash ` requires a predicate , since the resultant rows are the hashes of the EQUALS constraint operators ( ` = ` ) . The table implementation includes : <nl> - ` ` ` cpp <nl> - auto paths = context . constraints [ " path " ] . getAll ( EQUALS ) ; <nl> - for ( const auto & path_string : paths ) { <nl> - boost : : filesystem : : path path = path_string ; <nl> - [ . . . ] <nl> - } <nl> - ` ` ` <nl> - <nl> - ` processes ` optionally uses a predicate . A syscall to list process pids requires few resources . Enumerating " / proc " information and parsing environment / argument uses MANY resources . The table implementation includes : <nl> - ` ` ` cpp <nl> - for ( auto & pid : pidlist ) { <nl> - if ( ! context . constraints [ " pid " ] . matches < int > ( pid ) ) { <nl> - / / Optimize by not searching when a pid is a constraint . <nl> - continue ; <nl> - } <nl> - [ . . . ] <nl> - } <nl> - ` ` ` <nl> - <nl> - # # SQL data types <nl> - <nl> - Data types like ` QueryData ` , ` Row ` , ` DiffResults ` , etc . are osquery ' s built - in data result types . They ' re all defined in [ include / osquery / database / results . h ] ( https : / / github . com / facebook / osquery / blob / master / include / osquery / database / results . h ) . <nl> - <nl> - ` Row ` is just a ` typedef ` for a ` std : : map < std : : string , std : : string > ` . That ' s it . A row of data is just a mapping of strings that represent column names to strings that represent column values . Note that , currently , even if your SQL table type is an ` int ` and not a ` std : : string ` , we need to cast the ints as strings to comply with the type definition of the ` Row ` object . They ' ll be casted back to ` int ` ' s later . This is all handled transparently by osquery ' s supporting infrastructure as long as you use the macros like ` TEXT ` , ` INTEGER ` , ` BIGINT ` , etc when inserting columns into your row . <nl> - <nl> - ` QueryData ` is just a ` typedef ` for a ` std : : vector < Row > ` . Query data is just a list of rows . Simple enough . <nl> - <nl> - To populate the data that will be returned to the user at runtime , your implementation function must generate the data that you ' d like to display and populate a ` QueryData ` map with the appropriate ` Rows ` . Then , just return the ` QueryData ` . <nl> - <nl> - In our case , we used system APIs to create a struct of type ` tm ` which has fields such as ` tm_hour ` , ` tm_min ` and ` tm_sec ` which represent the current time . We can then create our three entries in our ` Row ` variable : hour , minutes and seconds . Then we push that single row onto the ` QueryData ` variable and return it . Note that if we wanted our table to have many rows ( a more common use - case ) , we would just push back more ` Row ` maps onto ` results ` . <nl> - <nl> - # # Building new tables <nl> - <nl> - If you ' ve created a new file , you ' ll need to make sure that CMake properly builds your code . Open [ osquery / tables / CMakeLists . txt ] ( https : / / github . com / facebook / osquery / blob / master / osquery / tables / CMakeLists . txt ) . Find the line that defines the library ` osquery_tables ` and add your file , " utility / time . cpp " to the sources which are compiled by that library . <nl> - <nl> - If your table only works on OS X , find the target called ` osquery_tables_darwin ` and add your file to that list of sources instead . If your table only works on Linux , find the target called ` osquery_tables_linux ` and add your implementation file to that list of sources . <nl> - <nl> - Return to the root of the repository and execute ` make ` . This will generate the appropriate code and link everything properly . <nl> - <nl> - # # # Testing your table <nl> - <nl> - If your code compiled properly , launch the interactive query console by executing ` . / build / [ darwin | linux ] / osquery / osqueryi ` and try issuing your new table a command : ` SELECT * FROM time ; ` . <nl> - <nl> - # # # Getting your query ready for use in osqueryd <nl> - <nl> - You don ' t have to do anything to make your query work in the osqueryd daemon . All osquery queries work in osqueryd . It ' s worth noting , however , that osqueryd is a long - running process . If your table leaks memory or uses a lot of systems resources , you will notice poor performance from osqueryd . For more information on ensuring a performant table , see [ performance overview ] ( . . / deployment / performance - safety . md ) . <nl> - <nl> - When in doubt , use existing open source tables to guide your development . <nl> + SQL tables are used to represent abstract operating system concepts , such as running processes . <nl> + <nl> + A table can be used in conjunction with other tables via operations like sub - queries and joins . This allows for a rich data exploration experience . While osquery ships with a default set of tables , osquery provides an API that allows you to create new tables . <nl> + <nl> + You can explore current tables : [ https : / / osquery . io / tables ] ( https : / / osquery . io / tables ) . Tables that are up for grabs in terms of development can be found on Github issues using the " virtual tables " + " [ up for grabs tag ] ( https : / / github . com / facebook / osquery / issues ? q = is % 3Aopen + is % 3Aissue + label % 3A % 22virtual + tables % 22 ) " . <nl> + <nl> + # # New Table Walkthrough <nl> + <nl> + Let ' s walk through an exercise where we build a ' time ' table . The table will have one row , and that row will have three columns : hour , minute , and second . <nl> + <nl> + Column values ( a single row ) will be dynamically computed at query time . <nl> + <nl> + * * Table specifications * * <nl> + <nl> + Under the hood , osquery uses libraries from SQLite core to create " virtual tables " . The default API for creating virtual tables is relatively complex . osquery has abstracted this complexity away , allowing you to write a simple table declaration . <nl> + <nl> + To make table - creation simple osquery uses a * table spec * file . <nl> + The current specs are organized by operating system in the [ specs ] ( https : / / github . com / facebook / osquery / tree / master / specs ) source folder . <nl> + For our time exercise , a spec file would look like the following : <nl> + <nl> + ` ` ` python <nl> + # This . table file is called a " spec " and is written in Python <nl> + # This syntax ( several definitions ) is defined in / tools / codegen / gentable / py . <nl> + table_name ( " time " ) <nl> + <nl> + # Provide a short " one line " description , please use punctuation ! <nl> + description ( " Returns the current hour , minutes , and seconds . " ) <nl> + <nl> + # Define your schema , which accepts a list of Column instances at minimum . <nl> + # You may also describe foreign keys and " action " columns . <nl> + schema ( [ <nl> + # Declare the name , type , and documentation description for each column . <nl> + # The supported types are INTEGER , BIGINT , TEXT , DATE , and DATETIME . <nl> + Column ( " hour " , INTEGER , " The current hour " ) , <nl> + Column ( " minutes " , INTEGER , " The current minutes past the hour " ) , <nl> + Column ( " seconds " , INTEGER , " The current seconds past the minute " ) , <nl> + ] ) <nl> + <nl> + # Use the " @ gen { TableName } " to communicate the C + + symbol name . <nl> + implementation ( " genTime " ) <nl> + ` ` ` <nl> + <nl> + You can leave the comments out in your production spec . Shoot for simplicity , do NOT go " hard in the paint " and do things like inheritance for Column objects , loops in your table spec , etc . <nl> + <nl> + You might wonder " this syntax looks similar to Python ? " . Well , it is ! The build process actually parses the spec files as Python code and meta - programs necessary C / C + + implementation files . <nl> + <nl> + * * Where do I put the spec ? * * <nl> + <nl> + You may be wondering how osquery handles cross - platform support while still allowing operating - system specific tables . The osquery build process takes care of this by only generating the relevant code based on a directory structure convention . <nl> + <nl> + - Cross - platform : [ specs / ] ( https : / / github . com / facebook / osquery / tree / master / specs / ) <nl> + - Mac OS X : [ specs / darwin / ] ( https : / / github . com / facebook / osquery / tree / master / specs / darwin ) <nl> + - General Linux : [ specs / linux / ] ( https : / / github . com / facebook / osquery / tree / master / specs / linux ) <nl> + - Ubuntu : [ specs / ubuntu / ] ( https : / / github . com / facebook / osquery / tree / master / specs / ubuntu ) <nl> + - CentOS : [ specs / centos / ] ( https : / / github . com / facebook / osquery / tree / master / specs / centos ) <nl> + <nl> + Note : the CMake build provides custom defines for each platform and platform version . <nl> + <nl> + * * Creating your implementation * * <nl> + <nl> + As indicated in the spec file , our implementation will be in a function called ` genTime ` . Since this is a very general table and should compile on all supported operating systems we can place it in * osquery / tables / utility / time . cpp * . The directory * osquery / table / * contains the set of * specs * and implementation categories . Place implementations in the corresponding category using your best judgement . <nl> + <nl> + Here is that code for * osquery / tables / utility / time . cpp * : <nl> + <nl> + ` ` ` cpp <nl> + / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> + <nl> + # include < ctime > <nl> + # include < osquery / tables . h > <nl> + <nl> + namespace osquery { <nl> + namespace tables { <nl> + <nl> + QueryData genTime ( QueryContext & context ) { <nl> + Row r ; <nl> + QueryData results ; <nl> + <nl> + time_t _time = time ( 0 ) ; <nl> + struct tm * now = localtime ( & _time ) ; <nl> + <nl> + r [ " hour " ] = INTEGER ( now - > tm_hour ) ; <nl> + r [ " minutes " ] = INTEGER ( now - > tm_min ) ; <nl> + r [ " seconds " ] = INTEGER ( now - > tm_sec ) ; <nl> + <nl> + results . push_back ( r ) ; <nl> + return results ; <nl> + } <nl> + } <nl> + } <nl> + ` ` ` <nl> + <nl> + Key points to remember : <nl> + <nl> + - Your implementation function should be in the ` osquery : : tables ` namespace . <nl> + - Your implementation function should accept on ` QueryContext & ` parameter and return an instance of ` QueryData ` <nl> + <nl> + # # Using where clauses <nl> + <nl> + The ` QueryContext ` data type is osquery ' s abstraction of the underlying SQL engine ' s query parsing . It is defined in [ include / osquery / tables . h ] ( https : / / github . com / facebook / osquery / blob / master / include / osquery / tables . h ) . <nl> + <nl> + The most important use of the context is query predicate constraints ( e . g . , ` WHERE col = ' value ' ` ) . Some tables MUST have a predicate constraint , others may optionally use the constraints to increase performance . <nl> + <nl> + Examples : <nl> + <nl> + ` hash ` requires a predicate , since the resultant rows are the hashes of the EQUALS constraint operators ( ` = ` ) . The table implementation includes : <nl> + ` ` ` cpp <nl> + auto paths = context . constraints [ " path " ] . getAll ( EQUALS ) ; <nl> + for ( const auto & path_string : paths ) { <nl> + boost : : filesystem : : path path = path_string ; <nl> + [ . . . ] <nl> + } <nl> + ` ` ` <nl> + <nl> + ` processes ` optionally uses a predicate . A syscall to list process pids requires few resources . Enumerating " / proc " information and parsing environment / argument uses MANY resources . The table implementation includes : <nl> + ` ` ` cpp <nl> + for ( auto & pid : pidlist ) { <nl> + if ( ! context . constraints [ " pid " ] . matches < int > ( pid ) ) { <nl> + / / Optimize by not searching when a pid is a constraint . <nl> + continue ; <nl> + } <nl> + [ . . . ] <nl> + } <nl> + ` ` ` <nl> + <nl> + # # SQL data types <nl> + <nl> + Data types like ` QueryData ` , ` Row ` , ` DiffResults ` , etc . are osquery ' s built - in data result types . They ' re all defined in [ include / osquery / database / results . h ] ( https : / / github . com / facebook / osquery / blob / master / include / osquery / database / results . h ) . <nl> + <nl> + ` Row ` is just a ` typedef ` for a ` std : : map < std : : string , std : : string > ` . That ' s it . A row of data is just a mapping of strings that represent column names to strings that represent column values . Note that , currently , even if your SQL table type is an ` int ` and not a ` std : : string ` , we need to cast the ints as strings to comply with the type definition of the ` Row ` object . They ' ll be casted back to ` int ` ' s later . This is all handled transparently by osquery ' s supporting infrastructure as long as you use the macros like ` TEXT ` , ` INTEGER ` , ` BIGINT ` , etc when inserting columns into your row . <nl> + <nl> + ` QueryData ` is just a ` typedef ` for a ` std : : vector < Row > ` . Query data is just a list of rows . Simple enough . <nl> + <nl> + To populate the data that will be returned to the user at runtime , your implementation function must generate the data that you ' d like to display and populate a ` QueryData ` map with the appropriate ` Rows ` . Then , just return the ` QueryData ` . <nl> + <nl> + In our case , we used system APIs to create a struct of type ` tm ` which has fields such as ` tm_hour ` , ` tm_min ` and ` tm_sec ` which represent the current time . We can then create our three entries in our ` Row ` variable : hour , minutes and seconds . Then we push that single row onto the ` QueryData ` variable and return it . Note that if we wanted our table to have many rows ( a more common use - case ) , we would just push back more ` Row ` maps onto ` results ` . <nl> + <nl> + # # Building new tables <nl> + <nl> + If you ' ve created a new file , you ' ll need to make sure that CMake properly builds your code . Open [ osquery / tables / CMakeLists . txt ] ( https : / / github . com / facebook / osquery / blob / master / osquery / tables / CMakeLists . txt ) . Find the line that defines the library ` osquery_tables ` and add your file , " utility / time . cpp " to the sources which are compiled by that library . <nl> + <nl> + If your table only works on OS X , find the target called ` osquery_tables_darwin ` and add your file to that list of sources instead . If your table only works on Linux , find the target called ` osquery_tables_linux ` and add your implementation file to that list of sources . <nl> + <nl> + Return to the root of the repository and execute ` make ` . This will generate the appropriate code and link everything properly . <nl> + <nl> + # # # Testing your table <nl> + <nl> + If your code compiled properly , launch the interactive query console by executing ` . / build / [ darwin | linux ] / osquery / osqueryi ` and try issuing your new table a command : ` SELECT * FROM time ; ` . <nl> + <nl> + # # # Getting your query ready for use in osqueryd <nl> + <nl> + You don ' t have to do anything to make your query work in the osqueryd daemon . All osquery queries work in osqueryd . It ' s worth noting , however , that osqueryd is a long - running process . If your table leaks memory or uses a lot of systems resources , you will notice poor performance from osqueryd . For more information on ensuring a performant table , see [ performance overview ] ( . . / deployment / performance - safety . md ) . <nl> + <nl> + When in doubt , use existing open source tables to guide your development . <nl> mmm a / osquery / CMakeLists . txt <nl> ppp b / osquery / CMakeLists . txt <nl> if ( NOT ENV { SKIP_TABLES } ) <nl> endif ( ) <nl> <nl> # Amalgamate the utility tables needed to compile . <nl> - GENERATE_UTILITIES ( " $ { CMAKE_SOURCE_DIR } / osquery / tables " ) <nl> + GENERATE_UTILITIES ( " $ { CMAKE_SOURCE_DIR } " ) <nl> AMALGAMATE ( " $ { CMAKE_SOURCE_DIR } " " utils " AMALGAMATION_UTILS ) <nl> ADD_OSQUERY_LIBRARY_CORE ( osquery_amalgamation $ { AMALGAMATION_UTILS } ) <nl> <nl> add_dependencies ( devel libosquery ) <nl> <nl> if ( NOT OSQUERY_BUILD_SDK_ONLY ) <nl> # Generate the osquery additional tables ( the non - util ) . <nl> - GENERATE_TABLES ( " $ { CMAKE_SOURCE_DIR } / osquery / tables " ) <nl> + GENERATE_TABLES ( " $ { CMAKE_SOURCE_DIR } " ) <nl> AMALGAMATE ( " $ { CMAKE_SOURCE_DIR } " " additional " AMALGAMATION ) <nl> ADD_OSQUERY_LIBRARY_ADDITIONAL ( osquery_additional_amalgamation $ { AMALGAMATION } ) <nl> <nl> mmm a / osquery / config / CMakeLists . txt <nl> ppp b / osquery / config / CMakeLists . txt <nl> ADD_OSQUERY_LIBRARY ( FALSE osquery_config_plugins <nl> $ { OSQUERY_CONFIG_PLUGINS } <nl> ) <nl> <nl> - ADD_OSQUERY_LIBRARY ( FALSE osquery_config_parsers <nl> + ADD_OSQUERY_LIBRARY ( TRUE osquery_config_parsers <nl> $ { OSQUERY_CONFIG_PARSERS } <nl> ) <nl> <nl> mmm a / osquery / config / parsers / query_packs . cpp <nl> ppp b / osquery / config / parsers / query_packs . cpp <nl> Status QueryPackConfigParserPlugin : : update ( const ConfigTreeMap & config ) { <nl> } <nl> <nl> / / / Call the simple Query Packs ConfigParserPlugin " packs " . <nl> - REGISTER ( QueryPackConfigParserPlugin , " config_parser " , " packs " ) ; <nl> + REGISTER_INTERNAL ( QueryPackConfigParserPlugin , " config_parser " , " packs " ) ; <nl> } <nl> mmm a / osquery / tables / CMakeLists . txt <nl> ppp b / osquery / tables / CMakeLists . txt <nl> else ( ) <nl> ADD_OSQUERY_LINK_ADDITIONAL ( " ip4tc " ) <nl> endif ( ) <nl> <nl> - file ( GLOB OSQUERY_CROSS_TABLES " [ ! ue ] * / * . cpp " ) <nl> + file ( GLOB OSQUERY_CROSS_TABLES " [ ! ueo ] * / * . cpp " ) <nl> ADD_OSQUERY_LIBRARY_ADDITIONAL ( osquery_tables <nl> $ { OSQUERY_CROSS_TABLES } <nl> ) <nl> <nl> - file ( GLOB OSQUERY_CROSS_TABLES_TESTS " [ ! u ] * / tests / * . cpp " ) <nl> + file ( GLOB OSQUERY_CROSS_TABLES_TESTS " [ ! uo ] * / tests / * . cpp " ) <nl> ADD_OSQUERY_TABLE_TEST ( $ { OSQUERY_CROSS_TABLES_TESTS } ) <nl> <nl> file ( GLOB OSQUERY_UTILITY_TABLES " utility / * . cpp " ) <nl> ADD_OSQUERY_LIBRARY_CORE ( osquery_tables_utility <nl> ) <nl> <nl> if ( NOT FREEBSD ) <nl> - file ( GLOB OSQUERY_UTILS " utils / * . cpp " ) <nl> + file ( GLOB OSQUERY_UTILS " other / * . cpp " ) <nl> ADD_OSQUERY_LIBRARY_ADDITIONAL ( osquery_utils <nl> $ { OSQUERY_UTILS } <nl> ) <nl> <nl> - file ( GLOB OSQUERY_UTILS_TESTS " utils / tests / * . cpp " ) <nl> + file ( GLOB OSQUERY_UTILS_TESTS " other / tests / * . cpp " ) <nl> ADD_OSQUERY_TEST_ADDITIONAL ( $ { OSQUERY_UTILS_TESTS } ) <nl> endif ( ) <nl> deleted file mode 100644 <nl> index d8b4eb9e98 . . 0000000000 <nl> mmm a / osquery / tables / other / osquery . cpp <nl> ppp / dev / null <nl> <nl> - / * <nl> - * Copyright ( c ) 2014 , Facebook , Inc . <nl> - * All rights reserved . <nl> - * <nl> - * This source code is licensed under the BSD - style license found in the <nl> - * LICENSE file in the root directory of this source tree . An additional grant <nl> - * of patent rights can be found in the PATENTS file in the same directory . <nl> - * <nl> - * / <nl> - <nl> - # include < osquery / config . h > <nl> - # include < osquery / core . h > <nl> - # include < osquery / registry . h > <nl> - # include < osquery / tables . h > <nl> - # include < osquery / filesystem . h > <nl> - <nl> - # include " osquery / config / parsers / query_packs . h " <nl> - <nl> - namespace osquery { <nl> - namespace tables { <nl> - <nl> - typedef pt : : ptree : : value_type tree_node ; <nl> - <nl> - void genQueryPack ( const tree_node & pack , QueryData & results ) { <nl> - Row r ; <nl> - / / Packs are stored by name and contain configuration data . <nl> - r [ " name " ] = pack . first ; <nl> - r [ " path " ] = pack . second . get ( " path " , " " ) ; <nl> - <nl> - / / There are optional restrictions on the set of queries applied pack - wide . <nl> - auto pack_wide_version = pack . second . get ( " version " , " " ) ; <nl> - auto pack_wide_platform = pack . second . get ( " platform " , " " ) ; <nl> - <nl> - / / Iterate through each query in the pack . <nl> - for ( auto const & query : pack . second . get_child ( " queries " ) ) { <nl> - r [ " query_name " ] = query . first ; <nl> - r [ " query " ] = query . second . get ( " query " , " " ) ; <nl> - r [ " interval " ] = INTEGER ( query . second . get ( " interval " , 0 ) ) ; <nl> - r [ " description " ] = query . second . get ( " description " , " " ) ; <nl> - r [ " value " ] = query . second . get ( " value " , " " ) ; <nl> - <nl> - / / Set the version requirement based on the query - specific or pack - wide . <nl> - if ( query . second . count ( " version " ) > 0 ) { <nl> - r [ " version " ] = query . second . get ( " version " , " " ) ; <nl> - } else { <nl> - r [ " version " ] = pack_wide_platform ; <nl> - } <nl> - <nl> - / / Set the platform requirement based on the query - specific or pack - wide . <nl> - if ( query . second . count ( " platform " ) > 0 ) { <nl> - r [ " platform " ] = query . second . get ( " platform " , " " ) ; <nl> - } else { <nl> - r [ " platform " ] = pack_wide_platform ; <nl> - } <nl> - <nl> - / / Adding a prefix to the pack queries to differentiate packs from schedule . <nl> - r [ " scheduled_name " ] = " pack_ " + r . at ( " name " ) + " _ " + r . at ( " query_name " ) ; <nl> - if ( Config : : checkScheduledQueryName ( r . at ( " scheduled_name " ) ) ) { <nl> - r [ " scheduled " ] = INTEGER ( 1 ) ; <nl> - } else { <nl> - r [ " scheduled " ] = INTEGER ( 0 ) ; <nl> - } <nl> - <nl> - results . push_back ( r ) ; <nl> - } <nl> - } <nl> - <nl> - QueryData genOsqueryPacks ( QueryContext & context ) { <nl> - QueryData results ; <nl> - <nl> - / / Get a lock on the config instance . <nl> - ConfigDataInstance config ; <nl> - <nl> - / / Get the loaded data tree from global JSON configuration . <nl> - const auto & packs_parsed_data = config . getParsedData ( " packs " ) ; <nl> - <nl> - / / Iterate through all the packs to get each configuration and set of queries . <nl> - for ( auto const & pack : packs_parsed_data ) { <nl> - / / Make sure the pack data contains queries . <nl> - if ( pack . second . count ( " queries " ) = = 0 ) { <nl> - continue ; <nl> - } <nl> - genQueryPack ( pack , results ) ; <nl> - } <nl> - <nl> - return results ; <nl> - } <nl> - } <nl> - } <nl> similarity index 97 % <nl> rename from osquery / tables / utils / tests / yara_tests . cpp <nl> rename to osquery / tables / other / tests / yara_tests . cpp <nl> mmm a / osquery / tables / utils / tests / yara_tests . cpp <nl> ppp b / osquery / tables / other / tests / yara_tests . cpp <nl> <nl> <nl> # include < osquery / filesystem . h > <nl> <nl> - # include " osquery / tables / utils / yara_utils . h " <nl> + # include " osquery / tables / other / yara_utils . h " <nl> <nl> namespace osquery { <nl> <nl> similarity index 99 % <nl> rename from osquery / tables / utils / yara . cpp <nl> rename to osquery / tables / other / yara . cpp <nl> mmm a / osquery / tables / utils / yara . cpp <nl> ppp b / osquery / tables / other / yara . cpp <nl> <nl> # include < osquery / tables . h > <nl> # include < osquery / status . h > <nl> <nl> - # include " osquery / tables / utils / yara_utils . h " <nl> + # include " osquery / tables / other / yara_utils . h " <nl> <nl> # ifdef CONCAT <nl> # undef CONCAT <nl> similarity index 99 % <nl> rename from osquery / tables / utils / yara_utils . cpp <nl> rename to osquery / tables / other / yara_utils . cpp <nl> mmm a / osquery / tables / utils / yara_utils . cpp <nl> ppp b / osquery / tables / other / yara_utils . cpp <nl> <nl> # include < osquery / config . h > <nl> # include < osquery / logger . h > <nl> <nl> - # include " osquery / tables / utils / yara_utils . h " <nl> + # include " osquery / tables / other / yara_utils . h " <nl> <nl> namespace osquery { <nl> <nl> similarity index 100 % <nl> rename from osquery / tables / utils / yara_utils . h <nl> rename to osquery / tables / other / yara_utils . h <nl> mmm a / osquery / tables / system / darwin / packages . cpp <nl> ppp b / osquery / tables / system / darwin / packages . cpp <nl> const char * BOM : : getPointer ( int index , size_t * length ) const { <nl> } <nl> <nl> const BOMVar * BOM : : getVariable ( size_t * offset ) const { <nl> + if ( offset = = nullptr ) { <nl> + return nullptr ; <nl> + } <nl> + <nl> if ( size_ < vars_offset_ + * offset + sizeof ( BOMVar ) ) { <nl> / / Offset overflows the variable list . <nl> * offset = 0 ; <nl> const BOMVar * BOM : : getVariable ( size_t * offset ) const { <nl> } <nl> <nl> const BOMVar * var = ( BOMVar * ) ( ( char * ) Vars - > list + * offset ) ; <nl> + if ( var = = nullptr ) { <nl> + * offset = 0 ; <nl> + return nullptr ; <nl> + } <nl> + <nl> * offset + = sizeof ( BOMVar ) + var - > length ; <nl> return var ; <nl> } <nl> void genPackageBOM ( const std : : string & path , QueryData & results ) { <nl> for ( unsigned i = 0 ; i < ntohl ( bom . Vars - > count ) ; i + + ) { <nl> / / Iterate through each BOM variable , a packed set of structures . <nl> auto var = bom . getVariable ( & var_offset ) ; <nl> - if ( var = = nullptr | | var - > name = = nullptr ) { <nl> + if ( var = = nullptr | | ( char * ) var - > name = = nullptr ) { <nl> break ; <nl> } <nl> <nl> void genPackageBOM ( const std : : string & path , QueryData & results ) { <nl> const BOMTree * tree = ( const BOMTree * ) var_data ; <nl> auto paths = bom . getPaths ( tree - > child ) ; <nl> while ( paths ! = nullptr & & paths - > isLeaf = = htons ( 0 ) ) { <nl> - if ( paths - > indices = = nullptr ) { <nl> + if ( ( BOMPathIndices * ) paths - > indices = = nullptr ) { <nl> break ; <nl> } <nl> paths = bom . getPaths ( paths - > indices [ 0 ] . index0 ) ; <nl> mmm a / osquery / tables / system / darwin / packages . h <nl> ppp b / osquery / tables / system / darwin / packages . h <nl> struct BOMBlockTable { <nl> / / See header for number of non - null blocks <nl> uint32_t count ; <nl> / / First entry must always be a null entry <nl> - BOMPointer * blockPointers ; <nl> + BOMPointer blockPointers [ ] ; <nl> } __attribute__ ( ( packed ) ) ; <nl> <nl> struct BOMTree { <nl> struct BOMTree { <nl> struct BOMVar { <nl> uint32_t index ; <nl> uint8_t length ; <nl> - char * name ; <nl> + char name [ ] ; <nl> } __attribute__ ( ( packed ) ) ; <nl> <nl> struct BOMVars { <nl> uint32_t count ; <nl> - BOMVar * list ; <nl> + BOMVar list [ ] ; <nl> } __attribute__ ( ( packed ) ) ; <nl> <nl> struct BOMPathIndices { <nl> struct BOMPaths { <nl> uint16_t count ; <nl> uint32_t forward ; <nl> uint32_t backward ; <nl> - BOMPathIndices * indices ; <nl> + BOMPathIndices indices [ ] ; <nl> } __attribute__ ( ( packed ) ) ; <nl> <nl> struct BOMPathInfo2 { <nl> struct BOMPathInfo2 { <nl> uint32_t devType ; <nl> } ; <nl> uint32_t linkNameLength ; <nl> - char * linkName ; <nl> + char linkName [ ] ; <nl> } __attribute__ ( ( packed ) ) ; <nl> <nl> struct BOMPathInfo1 { <nl> struct BOMPathInfo1 { <nl> struct BOMFile { <nl> / / Parent BOMPathInfo1 - > id <nl> uint32_t parent ; <nl> - char * name ; <nl> + char name [ ] ; <nl> } __attribute__ ( ( packed ) ) ; <nl> <nl> class BOM { <nl> mmm a / osquery / tables / utility / osquery . cpp <nl> ppp b / osquery / tables / utility / osquery . cpp <nl> <nl> # include < osquery / tables . h > <nl> # include < osquery / filesystem . h > <nl> <nl> + # include " osquery / config / parsers / query_packs . h " <nl> + <nl> namespace osquery { <nl> namespace tables { <nl> <nl> + typedef pt : : ptree : : value_type tree_node ; <nl> + <nl> + void genQueryPack ( const tree_node & pack , QueryData & results ) { <nl> + Row r ; <nl> + / / Packs are stored by name and contain configuration data . <nl> + r [ " name " ] = pack . first ; <nl> + r [ " path " ] = pack . second . get ( " path " , " " ) ; <nl> + <nl> + / / There are optional restrictions on the set of queries applied pack - wide . <nl> + auto pack_wide_version = pack . second . get ( " version " , " " ) ; <nl> + auto pack_wide_platform = pack . second . get ( " platform " , " " ) ; <nl> + <nl> + / / Iterate through each query in the pack . <nl> + for ( auto const & query : pack . second . get_child ( " queries " ) ) { <nl> + r [ " query_name " ] = query . first ; <nl> + r [ " query " ] = query . second . get ( " query " , " " ) ; <nl> + r [ " interval " ] = INTEGER ( query . second . get ( " interval " , 0 ) ) ; <nl> + r [ " description " ] = query . second . get ( " description " , " " ) ; <nl> + r [ " value " ] = query . second . get ( " value " , " " ) ; <nl> + <nl> + / / Set the version requirement based on the query - specific or pack - wide . <nl> + if ( query . second . count ( " version " ) > 0 ) { <nl> + r [ " version " ] = query . second . get ( " version " , " " ) ; <nl> + } else { <nl> + r [ " version " ] = pack_wide_platform ; <nl> + } <nl> + <nl> + / / Set the platform requirement based on the query - specific or pack - wide . <nl> + if ( query . second . count ( " platform " ) > 0 ) { <nl> + r [ " platform " ] = query . second . get ( " platform " , " " ) ; <nl> + } else { <nl> + r [ " platform " ] = pack_wide_platform ; <nl> + } <nl> + <nl> + / / Adding a prefix to the pack queries to differentiate packs from schedule . <nl> + r [ " scheduled_name " ] = " pack_ " + r . at ( " name " ) + " _ " + r . at ( " query_name " ) ; <nl> + if ( Config : : checkScheduledQueryName ( r . at ( " scheduled_name " ) ) ) { <nl> + r [ " scheduled " ] = INTEGER ( 1 ) ; <nl> + } else { <nl> + r [ " scheduled " ] = INTEGER ( 0 ) ; <nl> + } <nl> + <nl> + results . push_back ( r ) ; <nl> + } <nl> + } <nl> + <nl> + QueryData genOsqueryPacks ( QueryContext & context ) { <nl> + QueryData results ; <nl> + <nl> + / / Get a lock on the config instance . <nl> + ConfigDataInstance config ; <nl> + <nl> + / / Get the loaded data tree from global JSON configuration . <nl> + const auto & packs_parsed_data = config . getParsedData ( " packs " ) ; <nl> + <nl> + / / Iterate through all the packs to get each configuration and set of queries . <nl> + for ( auto const & pack : packs_parsed_data ) { <nl> + / / Make sure the pack data contains queries . <nl> + if ( pack . second . count ( " queries " ) = = 0 ) { <nl> + continue ; <nl> + } <nl> + genQueryPack ( pack , results ) ; <nl> + } <nl> + <nl> + return results ; <nl> + } <nl> + <nl> void genFlag ( const std : : string & name , <nl> const FlagInfo & flag , <nl> QueryData & results ) { <nl> similarity index 100 % <nl> rename from osquery / tables / specs / acpi_tables . table <nl> rename to specs / acpi_tables . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / arp_cache . table <nl> rename to specs / arp_cache . table <nl> similarity index 98 % <nl> rename from osquery / tables / specs / blacklist <nl> rename to specs / blacklist <nl> mmm a / osquery / tables / specs / blacklist <nl> ppp b / specs / blacklist <nl> freebsd : yara_events <nl> freebsd : yara <nl> freebsd : system_controls <nl> freebsd : smbios_tables <nl> + example <nl> similarity index 100 % <nl> rename from osquery / tables / specs / block_devices . table <nl> rename to specs / block_devices . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / centos / rpm_package_files . table <nl> rename to specs / centos / rpm_package_files . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / centos / rpm_packages . table <nl> rename to specs / centos / rpm_packages . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / chrome_extensions . table <nl> rename to specs / chrome_extensions . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / cpuid . table <nl> rename to specs / cpuid . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / crontab . table <nl> rename to specs / crontab . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / ad_config . table <nl> rename to specs / darwin / ad_config . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / alf . table <nl> rename to specs / darwin / alf . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / alf_exceptions . table <nl> rename to specs / darwin / alf_exceptions . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / alf_explicit_auths . table <nl> rename to specs / darwin / alf_explicit_auths . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / alf_services . table <nl> rename to specs / darwin / alf_services . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / apps . table <nl> rename to specs / darwin / apps . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / browser_plugins . table <nl> rename to specs / darwin / browser_plugins . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / certificates . table <nl> rename to specs / darwin / certificates . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / extended_attributes . table <nl> rename to specs / darwin / extended_attributes . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / homebrew_packages . table <nl> rename to specs / darwin / homebrew_packages . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / iokit_devicetree . table <nl> rename to specs / darwin / iokit_devicetree . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / iokit_registry . table <nl> rename to specs / darwin / iokit_registry . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / kernel_extensions . table <nl> rename to specs / darwin / kernel_extensions . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / keychain_items . table <nl> rename to specs / darwin / keychain_items . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / launchd . table <nl> rename to specs / darwin / launchd . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / launchd_overrides . table <nl> rename to specs / darwin / launchd_overrides . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / managed_policies . table <nl> rename to specs / darwin / managed_policies . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / nfs_shares . table <nl> rename to specs / darwin / nfs_shares . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / nvram . table <nl> rename to specs / darwin / nvram . table <nl> similarity index 84 % <nl> rename from osquery / tables / specs / darwin / package_bom . table <nl> rename to specs / darwin / package_bom . table <nl> mmm a / osquery / tables / specs / darwin / package_bom . table <nl> ppp b / specs / darwin / package_bom . table <nl> schema ( [ <nl> Column ( " path " , TEXT , " Path of package bom " , required = True ) , <nl> ] ) <nl> implementation ( " packages @ genPackageBOM " ) <nl> + examples ( [ <nl> + " select * from package_bom where path = ' / var / db / receipts / com . apple . pkg . MobileDevice . bom ' " <nl> + ] ) <nl> similarity index 80 % <nl> rename from osquery / tables / specs / darwin / package_receipts . table <nl> rename to specs / darwin / package_receipts . table <nl> mmm a / osquery / tables / specs / darwin / package_receipts . table <nl> ppp b / specs / darwin / package_receipts . table <nl> schema ( [ <nl> Column ( " install_time " , INTEGER , " Timestamp of install time " ) , <nl> Column ( " installer_name " , TEXT , " Name of installer process " ) , <nl> Column ( " path " , TEXT , " Path of receipt plist " , <nl> - additional = True ) , <nl> + index = True , additional = True ) , <nl> ] ) <nl> implementation ( " packages @ genPackageReceipts " ) <nl> + examples ( [ <nl> + " select * from package_bom where path = ' / var / db / receipts / com . apple . pkg . MobileDevice . bom ' " <nl> + ] ) <nl> similarity index 71 % <nl> rename from osquery / tables / specs / darwin / preferences . table <nl> rename to specs / darwin / preferences . table <nl> mmm a / osquery / tables / specs / darwin / preferences . table <nl> ppp b / specs / darwin / preferences . table <nl> <nl> table_name ( " preferences " ) <nl> description ( " OS X defaults and managed preferences . " ) <nl> schema ( [ <nl> - Column ( " domain " , TEXT , " Application ID usually in com . name . product format " ) , <nl> + Column ( " domain " , TEXT , " Application ID usually in com . name . product format " , <nl> + index = True ) , <nl> Column ( " key " , TEXT , " Preference top - level key " ) , <nl> Column ( " subkey " , TEXT , " Intemediate key path , includes lists / dicts " ) , <nl> Column ( " value " , TEXT , " String value of most CF types " ) , <nl> Column ( " forced " , INTEGER , " 1 if the value is forced / managed , else 0 " ) , <nl> - Column ( " path " , TEXT , " ( optional ) read preferences from a plist " ) , <nl> + Column ( " path " , TEXT , " ( optional ) read preferences from a plist " , <nl> + additional = True ) , <nl> ] ) <nl> implementation ( " system / darwin / preferences @ genOSXPreferences " ) <nl> + examples ( [ <nl> + " select * from preferences where domain = ' loginwindow ' " , <nl> + " select * from preferences where path = ' / Library / Preferences / loginwindow . plist ' " <nl> + ] ) <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / safari_extensions . table <nl> rename to specs / darwin / safari_extensions . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / startup_items . table <nl> rename to specs / darwin / startup_items . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / darwin / xprotect_entries . table <nl> rename to specs / darwin / xprotect_entries . table <nl> similarity index 87 % <nl> rename from osquery / tables / specs / darwin / xprotect_reports . table <nl> rename to specs / darwin / xprotect_reports . table <nl> mmm a / osquery / tables / specs / darwin / xprotect_reports . table <nl> ppp b / specs / darwin / xprotect_reports . table <nl> schema ( [ <nl> Column ( " user_action " , TEXT , " Action taken by user after prompted " ) , <nl> Column ( " time " , TEXT , " Quarantine alert time " ) , <nl> ] ) <nl> - implementation ( " xprotect @ genXProtectReports " ) <nl> \ No newline at end of file <nl> + implementation ( " xprotect @ genXProtectReports " ) <nl> similarity index 100 % <nl> rename from osquery / tables / specs / disk_encryption . table <nl> rename to specs / disk_encryption . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / etc_hosts . table <nl> rename to specs / etc_hosts . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / etc_protocols . table <nl> rename to specs / etc_protocols . table <nl> similarity index 99 % <nl> rename from osquery / tables / specs / etc_services . table <nl> rename to specs / etc_services . table <nl> mmm a / osquery / tables / specs / etc_services . table <nl> ppp b / specs / etc_services . table <nl> schema ( [ <nl> Column ( " comment " , TEXT , " Optional comment for a service . " ) , <nl> ] ) <nl> implementation ( " etc_services @ genEtcServices " ) <nl> - <nl> new file mode 100644 <nl> index 0000000000 . . 9e8f5bd5f0 <nl> mmm / dev / null <nl> ppp b / specs / example . table <nl> <nl> + # This . table file is called a " spec " and is written in Python <nl> + # This syntax ( several definitions ) is defined in / tools / codegen / gentable / py . <nl> + table_name ( " example " ) <nl> + <nl> + # Provide a short " one line " description , please use punctuation ! <nl> + description ( " This is an example table spec . " ) <nl> + <nl> + # Define your schema , which accepts a list of Column instances at minimum . <nl> + # You may also describe foreign keys and " action " columns . <nl> + schema ( [ <nl> + # Declare the name , type , and documentation description for each column . <nl> + # The supported types are INTEGER , BIGINT , TEXT , DATE , and DATETIME . <nl> + Column ( " name " , TEXT , " Description for name column " ) , <nl> + Column ( " points " , INTEGER , " This is a signed SQLite int column " ) , <nl> + Column ( " size " , BIGINT , " This is a signed SQLite bigint column " ) , <nl> + <nl> + # More complex tables include columns denoted as " required " . <nl> + # A required column MUST be present in a query predicate ( WHERE clause ) . <nl> + Column ( " action " , TEXT , " Action performed in generation " , required = True ) , <nl> + <nl> + # Tables may optimize there selection using " index " columns . <nl> + # The optimization is undefined , but this is a hint to table users that <nl> + # JOINing on this column will improve performance . <nl> + Column ( " id " , INTEGER , " An index of some sort " , index = True ) , <nl> + <nl> + # Some tables operate using default configurations or OS settings . <nl> + # OS X has default paths for . app executions , but . apps exist otherwise . <nl> + # Tables may generate additional or different data when using some columns . <nl> + # Set the " additional " argument if searching a non - default path . <nl> + Column ( " path " , TEXT , " Path of example " , additional = True ) , <nl> + # When paths are involved they are usually both additional and an index . <nl> + ] ) <nl> + <nl> + # Use the " @ gen { TableName } " to communicate the C + + symbol name . <nl> + # Event subscriber tables and other more - complex implementations may use <nl> + # class - static methods for generation ; they use " @ ClassName : : genTable " syntax . <nl> + implementation ( " @ genExample " ) <nl> + <nl> + # Provide some example queries that stress table use . <nl> + # If using actions or indexing , it will be best to include those predicates . <nl> + examples ( [ <nl> + " select * from example where id = 1 " , <nl> + " select name from example where action = ' new ' " , <nl> + <nl> + # Examples may be used in documentation and in stress / fuzz testing . <nl> + # Including example JOINs on indexes is preferred . <nl> + " select e . * from example e , example_environments ee where e . id = ee . id " <nl> + ] ) <nl> + <nl> + # Attributes provide help to documentation / API generation tools . <nl> + # If an attribute is false , or no attributes apply , do no include ' attributes ' . <nl> + attributes ( <nl> + # Set event_subscriber if this table is generated using an EventSubscriber . <nl> + event_subscriber = False , <nl> + # Set utility if this table should be built into the osquery - SDK ( core ) . <nl> + # Utility tables are mostly reserved for osquery meta - information . <nl> + utility = False , <nl> + # Set kernel_required if an osquery kernel extension / module / driver is needed . <nl> + kernel_required = False <nl> + ) <nl> similarity index 100 % <nl> rename from osquery / tables / specs / file_events . table <nl> rename to specs / file_events . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / firefox_addons . table <nl> rename to specs / firefox_addons . table <nl> similarity index 61 % <nl> rename from osquery / tables / specs / groups . table <nl> rename to specs / groups . table <nl> mmm a / osquery / tables / specs / groups . table <nl> ppp b / specs / groups . table <nl> schema ( [ <nl> Column ( " groupname " , TEXT , " Canonical local group name " ) , <nl> ] ) <nl> implementation ( " groups @ genGroups " ) <nl> + examples ( [ <nl> + " select * from groups where gid = 0 " , <nl> + # Group / user_groups is not JOIN optimized <nl> + # " select g . groupname , ug . uid from groups g , user_groups ug where g . gid = ug . gid " , <nl> + ] ) <nl> similarity index 100 % <nl> rename from osquery / tables / specs / hardware_events . table <nl> rename to specs / hardware_events . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / interface_addresses . table <nl> rename to specs / interface_addresses . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / interface_details . table <nl> rename to specs / interface_details . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / kernel_info . table <nl> rename to specs / kernel_info . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / last . table <nl> rename to specs / last . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / linux / iptables . table <nl> rename to specs / linux / iptables . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / linux / kernel_integrity . table <nl> rename to specs / linux / kernel_integrity . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / linux / kernel_modules . table <nl> rename to specs / linux / kernel_modules . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / linux / memory_map . table <nl> rename to specs / linux / memory_map . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / linux / shared_memory . table <nl> rename to specs / linux / shared_memory . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / listening_ports . table <nl> rename to specs / listening_ports . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / logged_in_users . table <nl> rename to specs / logged_in_users . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / mounts . table <nl> rename to specs / mounts . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / opera_extensions . table <nl> rename to specs / opera_extensions . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / os_version . table <nl> rename to specs / os_version . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / passwd_changes . table <nl> rename to specs / passwd_changes . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / pci_devices . table <nl> rename to specs / pci_devices . table <nl> similarity index 53 % <nl> rename from osquery / tables / specs / process_envs . table <nl> rename to specs / process_envs . table <nl> mmm a / osquery / tables / specs / process_envs . table <nl> ppp b / specs / process_envs . table <nl> <nl> table_name ( " process_envs " ) <nl> description ( " A key / value table of environment variables for each process . " ) <nl> schema ( [ <nl> - Column ( " pid " , INTEGER , " Process ( or thread ) ID " ) , <nl> + Column ( " pid " , INTEGER , " Process ( or thread ) ID " , index = True ) , <nl> Column ( " key " , TEXT , " Environment variable name " ) , <nl> Column ( " value " , TEXT , " Environment variable value " ) , <nl> - ForeignKey ( column = " pid " , table = " processes " ) , <nl> - ForeignKey ( column = " pid " , table = " process_open_files " ) , <nl> ] ) <nl> implementation ( " system / processes @ genProcessEnvs " ) <nl> + examples ( [ <nl> + " select * from process_envs where pid = 1 " , <nl> + ' ' ' select pe . * <nl> + from process_envs pe , ( select * from processes limit 10 ) p <nl> + where p . pid = pe . pid ; ' ' ' <nl> + ] ) <nl> similarity index 83 % <nl> rename from osquery / tables / specs / process_memory_map . table <nl> rename to specs / process_memory_map . table <nl> mmm a / osquery / tables / specs / process_memory_map . table <nl> ppp b / specs / process_memory_map . table <nl> <nl> table_name ( " process_memory_map " ) <nl> description ( " Process memory mapped files and pseudo device / regions . " ) <nl> schema ( [ <nl> - Column ( " pid " , INTEGER , " Process ( or thread ) ID " ) , <nl> + Column ( " pid " , INTEGER , " Process ( or thread ) ID " , index = True ) , <nl> Column ( " start " , TEXT , " Virtual start address ( hex ) " ) , <nl> Column ( " end " , TEXT , " Virtual end address ( hex ) " ) , <nl> Column ( " permissions " , TEXT , " r = read , w = write , x = execute , p = private ( cow ) " ) , <nl> schema ( [ <nl> Column ( " pseudo " , INTEGER , " 1 if path is a pseudo path , else 0 " ) , <nl> ] ) <nl> implementation ( " processes @ genProcessMemoryMap " ) <nl> + examples ( [ <nl> + " select * from process_memory_map where pid = 1 " , <nl> + ] ) <nl> similarity index 68 % <nl> rename from osquery / tables / specs / process_open_files . table <nl> rename to specs / process_open_files . table <nl> mmm a / osquery / tables / specs / process_open_files . table <nl> ppp b / specs / process_open_files . table <nl> <nl> table_name ( " process_open_files " ) <nl> description ( " File descriptors for each process . " ) <nl> schema ( [ <nl> - Column ( " pid " , BIGINT , " Process ( or thread ) ID " ) , <nl> + Column ( " pid " , BIGINT , " Process ( or thread ) ID " , index = True ) , <nl> Column ( " fd " , BIGINT , " Process - specific file descriptor number " ) , <nl> Column ( " path " , TEXT , " Filesystem path of descriptor " ) , <nl> ] ) <nl> implementation ( " system / process_open_files @ genOpenFiles " ) <nl> + examples ( [ <nl> + " select * from process_open_files where pid = 1 " , <nl> + ] ) <nl> similarity index 81 % <nl> rename from osquery / tables / specs / process_open_sockets . table <nl> rename to specs / process_open_sockets . table <nl> mmm a / osquery / tables / specs / process_open_sockets . table <nl> ppp b / specs / process_open_sockets . table <nl> <nl> table_name ( " process_open_sockets " ) <nl> description ( " Processes which have open network sockets on the system . " ) <nl> schema ( [ <nl> - Column ( " pid " , INTEGER , " Process ( or thread ) ID " ) , <nl> + Column ( " pid " , INTEGER , " Process ( or thread ) ID " , index = True ) , <nl> Column ( " socket " , INTEGER , " Socket descriptor number " ) , <nl> Column ( " family " , INTEGER , " Network protocol ( IPv4 , IPv6 ) " ) , <nl> Column ( " protocol " , INTEGER , " Transport protocol ( TCP / UDP ) " ) , <nl> schema ( [ <nl> Column ( " remote_port " , INTEGER , " Socket remote port " ) , <nl> ] ) <nl> implementation ( " system / process_open_sockets @ genOpenSockets " ) <nl> - <nl> + examples ( [ <nl> + " select * from process_open_sockets where pid = 1 " , <nl> + ] ) <nl> similarity index 90 % <nl> rename from osquery / tables / specs / processes . table <nl> rename to specs / processes . table <nl> mmm a / osquery / tables / specs / processes . table <nl> ppp b / specs / processes . table <nl> <nl> table_name ( " processes " ) <nl> description ( " All running processes on the host system . " ) <nl> schema ( [ <nl> - Column ( " pid " , INTEGER , " Process ( or thread ) ID " ) , <nl> + Column ( " pid " , INTEGER , " Process ( or thread ) ID " , index = True ) , <nl> Column ( " name " , TEXT , " The process path or shorthand argv [ 0 ] " ) , <nl> Column ( " path " , TEXT , " Path to executed binary " ) , <nl> Column ( " cmdline " , TEXT , " Complete argv " ) , <nl> schema ( [ <nl> Column ( " parent " , INTEGER , " Process parent ' s PID " ) , <nl> ] ) <nl> implementation ( " system / processes @ genProcesses " ) <nl> + examples ( [ <nl> + " select * from processes where pid = 1 " , <nl> + ] ) <nl> similarity index 100 % <nl> rename from osquery / tables / specs / routes . table <nl> rename to specs / routes . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / shell_history . table <nl> rename to specs / shell_history . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / smbios_tables . table <nl> rename to specs / smbios_tables . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / suid_bin . table <nl> rename to specs / suid_bin . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / system_controls . table <nl> rename to specs / system_controls . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / ubuntu / apt_sources . table <nl> rename to specs / ubuntu / apt_sources . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / ubuntu / deb_packages . table <nl> rename to specs / ubuntu / deb_packages . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / usb_devices . table <nl> rename to specs / usb_devices . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / user_groups . table <nl> rename to specs / user_groups . table <nl> similarity index 64 % <nl> rename from osquery / tables / specs / users . table <nl> rename to specs / users . table <nl> mmm a / osquery / tables / specs / users . table <nl> ppp b / specs / users . table <nl> schema ( [ <nl> Column ( " uid " , BIGINT , " User ID " ) , <nl> Column ( " gid " , BIGINT , " Group ID ( unsigned ) " ) , <nl> Column ( " uid_signed " , BIGINT , " User ID as int64 signed ( Apple ) " ) , <nl> - Column ( " gid_signed " , BIGINT , " Group ID as int64 signed ( Apple ) " ) , <nl> + Column ( " gid_signed " , BIGINT , " Default group ID as int64 signed ( Apple ) " ) , <nl> Column ( " username " , TEXT ) , <nl> Column ( " description " , TEXT , " Optional user description " ) , <nl> Column ( " directory " , TEXT , " User ' s home directory " ) , <nl> Column ( " shell " , TEXT , " User ' s configured default shell " ) , <nl> ] ) <nl> implementation ( " users @ genUsers " ) <nl> + examples ( [ <nl> + " select * from users where uid = 1000 " , <nl> + " select * from users where username = ' root ' " , <nl> + " select count ( * ) from users u , user_groups ug where u . uid = ug . uid " , <nl> + ] ) <nl> similarity index 89 % <nl> rename from osquery / tables / specs / utility / file . table <nl> rename to specs / utility / file . table <nl> mmm a / osquery / tables / specs / utility / file . table <nl> ppp b / specs / utility / file . table <nl> schema ( [ <nl> ] ) <nl> attributes ( utility = True ) <nl> implementation ( " utility / file @ genFile " ) <nl> + examples ( [ <nl> + " select * from file where path = ' / etc / passwd ' " , <nl> + " select * from file where directory = ' / etc / ' " , <nl> + " select * from file where pattern = ' / etc / % ' " , <nl> + ] ) <nl> \ No newline at end of file <nl> similarity index 81 % <nl> rename from osquery / tables / specs / utility / hash . table <nl> rename to specs / utility / hash . table <nl> mmm a / osquery / tables / specs / utility / hash . table <nl> ppp b / specs / utility / hash . table <nl> schema ( [ <nl> ] ) <nl> attributes ( utility = True ) <nl> implementation ( " utility / hash @ genHash " ) <nl> + examples ( [ <nl> + " select * from hash where path = ' / etc / passwd ' " , <nl> + " select * from hash where directory = ' / etc / ' " , <nl> + ] ) <nl> similarity index 100 % <nl> rename from osquery / tables / specs / utility / osquery_extensions . table <nl> rename to specs / utility / osquery_extensions . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / utility / osquery_flags . table <nl> rename to specs / utility / osquery_flags . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / utility / osquery_info . table <nl> rename to specs / utility / osquery_info . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / osquery_packs . table <nl> rename to specs / utility / osquery_packs . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / utility / osquery_registry . table <nl> rename to specs / utility / osquery_registry . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / utility / osquery_schedule . table <nl> rename to specs / utility / osquery_schedule . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / utility / time . table <nl> rename to specs / utility / time . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / yara . table <nl> rename to specs / yara . table <nl> similarity index 100 % <nl> rename from osquery / tables / specs / yara_events . table <nl> rename to specs / yara_events . table <nl> mmm a / tools / codegen / genapi . py <nl> ppp b / tools / codegen / genapi . py <nl> <nl> import sys <nl> import uuid <nl> <nl> - from gentable import Column , ForeignKey , \ <nl> - table_name , schema , implementation , description , table , attributes , \ <nl> - DataType , BIGINT , DATE , DATETIME , INTEGER , TEXT , \ <nl> - is_blacklisted <nl> + from gentable import * <nl> + <nl> + SCRIPT_DIR = os . path . dirname ( os . path . realpath ( __file__ ) ) <nl> + sys . path . append ( SCRIPT_DIR + " / . . / tests " ) <nl> + from utils import platform <nl> <nl> # the log format for the logging module <nl> LOG_FORMAT = " % ( levelname ) s [ Line % ( lineno ) d ] : % ( message ) s " <nl> def encode ( self , o ) : <nl> return result <nl> <nl> <nl> - def gen_api ( api ) : <nl> + def gen_api_json ( api ) : <nl> " " " Apply the api literal object to the template . " " " <nl> api = json . dumps ( <nl> api , cls = Encoder , sort_keys = True , indent = 1 , separators = ( ' , ' , ' : ' ) <nl> def gen_spec ( tree ) : <nl> " function " : table . function , <nl> " description " : table . description , <nl> " attributes " : table . attributes , <nl> + " examples " : table . examples , <nl> } <nl> <nl> <nl> def gen_diff ( api_old_path , api_new_path ) : <nl> column [ 3 ] , column [ 1 ] ) ) <nl> <nl> <nl> + def gen_api ( tables_path , profile = { } ) : <nl> + blacklist = None <nl> + blacklist_path = os . path . join ( tables_path , " blacklist " ) <nl> + if os . path . exists ( blacklist_path ) : <nl> + with open ( blacklist_path , " r " ) as fh : <nl> + blacklist = fh . read ( ) <nl> + <nl> + categories = { } <nl> + for base , _ , files in os . walk ( tables_path ) : <nl> + for spec_file in files : <nl> + if spec_file [ 0 ] = = ' . ' or spec_file . find ( " example " ) = = 0 : <nl> + continue <nl> + # Exclude blacklist specific file <nl> + if spec_file = = ' blacklist ' : <nl> + continue <nl> + platform = os . path . basename ( base ) <nl> + platform_name = CANONICAL_PLATFORMS [ platform ] <nl> + name = spec_file . split ( " . table " , 1 ) [ 0 ] <nl> + if platform not in categories . keys ( ) : <nl> + categories [ platform ] = { " name " : platform_name , " tables " : [ ] } <nl> + with open ( os . path . join ( base , spec_file ) , " rU " ) as fh : <nl> + tree = ast . parse ( fh . read ( ) ) <nl> + table_spec = gen_spec ( tree ) <nl> + table_profile = profile . get ( " % s . % s " % ( platform , name ) , { } ) <nl> + table_spec [ " profile " ] = NoIndent ( table_profile ) <nl> + table_spec [ " blacklisted " ] = is_blacklisted ( table_spec [ " name " ] , <nl> + blacklist = blacklist ) <nl> + categories [ platform ] [ " tables " ] . append ( table_spec ) <nl> + categories = [ { " key " : k , " name " : v [ " name " ] , " tables " : v [ " tables " ] } <nl> + for k , v in categories . iteritems ( ) ] <nl> + return categories <nl> + <nl> def main ( argc , argv ) : <nl> parser = argparse . ArgumentParser ( " Generate API documentation . " ) <nl> parser . add_argument ( <nl> - " - - tables " , default = " osquery / tables / specs " , <nl> + " - - debug " , default = False , action = " store_true " , <nl> + help = " Output debug messages ( when developing ) " <nl> + ) <nl> + parser . add_argument ( <nl> + " - - tables " , default = " specs " , <nl> help = " Path to osquery table specs " <nl> ) <nl> parser . add_argument ( <nl> def main ( argc , argv ) : <nl> help = " Compare API changes API_PREVIOUS API_CURRENT " <nl> ) <nl> parser . add_argument ( " vars " , nargs = " * " ) <nl> - args = parser . parse_args ( ) <nl> + args = parser . parse_args ( argv ) <nl> <nl> - logging . basicConfig ( format = LOG_FORMAT , level = logging . INFO ) <nl> + if args . debug : <nl> + logging . basicConfig ( format = LOG_FORMAT , level = logging . DEBUG ) <nl> + else : <nl> + logging . basicConfig ( format = LOG_FORMAT , level = logging . INFO ) <nl> <nl> if args . diff : <nl> if len ( args . vars ) < 2 : <nl> def main ( argc , argv ) : <nl> logging . error ( " Cannot parse profile data : % s " % ( str ( e ) ) ) <nl> exit ( 2 ) <nl> <nl> - # Read in the optional list of blacklisted tables <nl> - blacklist = None <nl> - blacklist_path = os . path . join ( args . tables , " blacklist " ) <nl> - if os . path . exists ( blacklist_path ) : <nl> - with open ( blacklist_path , " r " ) as fh : <nl> - blacklist = fh . read ( ) <nl> - <nl> - categories = { } <nl> - for base , _ , files in os . walk ( args . tables ) : <nl> - for spec_file in files : <nl> - if spec_file [ 0 ] = = ' . ' : <nl> - continue <nl> - # Exclude blacklist specific file <nl> - if spec_file = = ' blacklist ' : <nl> - continue <nl> - platform = os . path . basename ( base ) <nl> - platform_name = CANONICAL_PLATFORMS [ platform ] <nl> - name = spec_file . split ( " . table " , 1 ) [ 0 ] <nl> - if platform not in categories . keys ( ) : <nl> - categories [ platform ] = { " name " : platform_name , " tables " : [ ] } <nl> - with open ( os . path . join ( base , spec_file ) , " rU " ) as fh : <nl> - tree = ast . parse ( fh . read ( ) ) <nl> - table_spec = gen_spec ( tree ) <nl> - table_profile = profile . get ( " % s . % s " % ( platform , name ) , { } ) <nl> - table_spec [ " profile " ] = NoIndent ( table_profile ) <nl> - table_spec [ " blacklisted " ] = is_blacklisted ( table_spec [ " name " ] , <nl> - blacklist = blacklist ) <nl> - categories [ platform ] [ " tables " ] . append ( table_spec ) <nl> - categories = [ { " key " : k , " name " : v [ " name " ] , " tables " : v [ " tables " ] } <nl> - for k , v in categories . iteritems ( ) ] <nl> - print ( gen_api ( categories ) ) <nl> + # Read in the optional list of blacklisted tables , then generate categories . <nl> + api = gen_api ( args . tables , profile ) <nl> + print ( gen_api_json ( api ) ) <nl> <nl> <nl> if __name__ = = " __main__ " : <nl> + SCRIPT_DIR = os . path . dirname ( os . path . realpath ( __file__ ) ) <nl> main ( len ( sys . argv ) , sys . argv ) <nl> mmm a / tools / codegen / gentable . py <nl> ppp b / tools / codegen / gentable . py <nl> <nl> from __future__ import print_function <nl> from __future__ import unicode_literals <nl> <nl> + import argparse <nl> import ast <nl> import jinja2 <nl> import logging <nl> import os <nl> import sys <nl> <nl> - # set DEVELOPING to True for debug statements <nl> - DEVELOPING = False <nl> + SCRIPT_DIR = os . path . dirname ( os . path . realpath ( __file__ ) ) <nl> + sys . path . append ( SCRIPT_DIR + " / . . / tests " ) <nl> + from utils import platform <nl> <nl> # the log format for the logging module <nl> LOG_FORMAT = " % ( levelname ) s [ Line % ( lineno ) d ] : % ( message ) s " <nl> <nl> RESERVED = [ " n " , " index " ] <nl> <nl> # Set the platform in osquery - language <nl> - if sys . platform . find ( " freebsd " ) = = 0 : <nl> - PLATFORM = " freebsd " <nl> - elif sys . platform . find ( " linux " ) = = 0 : <nl> - PLATFORM = " linux " <nl> - else : <nl> - PLATFORM = sys . platform <nl> + PLATFORM = platform ( ) <nl> <nl> # Supported SQL types for spec <nl> class DataType ( object ) : <nl> def lightred ( msg ) : <nl> def is_blacklisted ( table_name , path = None , blacklist = None ) : <nl> " " " Allow blacklisting by tablename . " " " <nl> if blacklist is None : <nl> - specs_path = os . path . dirname ( os . path . dirname ( path ) ) <nl> - if os . path . basename ( specs_path ) = = " tables " : <nl> - specs_path + = " / specs " <nl> + specs_path = os . path . dirname ( path ) <nl> + if os . path . basename ( specs_path ) ! = " specs " : <nl> + specs_path = os . path . basename ( specs_path ) <nl> blacklist_path = os . path . join ( specs_path , " blacklist " ) <nl> if not os . path . exists ( blacklist_path ) : <nl> return False <nl> def is_blacklisted ( table_name , path = None , blacklist = None ) : <nl> return True <nl> return False <nl> <nl> - def setup_templates ( path ) : <nl> - tables_path = os . path . dirname ( os . path . dirname ( path ) ) <nl> - templates_path = os . path . join ( tables_path , " templates " ) <nl> + def setup_templates ( templates_path ) : <nl> if not os . path . exists ( templates_path ) : <nl> templates_path = os . path . join ( os . path . dirname ( tables_path ) , " templates " ) <nl> if not os . path . exists ( templates_path ) : <nl> def __init__ ( self ) : <nl> self . class_name = " " <nl> self . description = " " <nl> self . attributes = { } <nl> + self . examples = [ ] <nl> <nl> def columns ( self ) : <nl> return [ i for i in self . schema if isinstance ( i , Column ) ] <nl> def generate ( self , path , template = " default " ) : <nl> function = self . function , <nl> class_name = self . class_name , <nl> attributes = self . attributes , <nl> + examples = self . examples , <nl> ) <nl> <nl> if self . table_name = = " " or self . function = = " " : <nl> def table_name ( name ) : <nl> table . table_name = name <nl> table . description = " " <nl> table . attributes = { } <nl> + table . examples = [ ] <nl> <nl> <nl> def schema ( schema_list ) : <nl> def description ( text ) : <nl> table . description = text <nl> <nl> <nl> + def select_all ( name = None ) : <nl> + if name = = None : <nl> + name = table . table_name <nl> + return " select count ( * ) from % s ; " % ( name ) <nl> + <nl> + <nl> + def examples ( example_queries ) : <nl> + table . examples = example_queries <nl> + <nl> + <nl> def attributes ( * * kwargs ) : <nl> for attr in kwargs : <nl> table . attributes [ attr ] = kwargs [ attr ] <nl> def implementation ( impl_string ) : <nl> <nl> <nl> def main ( argc , argv ) : <nl> - if DEVELOPING : <nl> + parser = argparse . ArgumentParser ( " Generate C + + Table Plugin from specfile . " ) <nl> + parser . add_argument ( <nl> + " - - debug " , default = False , action = " store_true " , <nl> + help = " Output debug messages ( when developing ) " <nl> + ) <nl> + parser . add_argument ( " - - templates " , default = SCRIPT_DIR + " / templates " , <nl> + help = " Path to codegen output . cpp . in templates " ) <nl> + parser . add_argument ( " spec_file " , help = " Path to input . table spec file " ) <nl> + parser . add_argument ( " output " , help = " Path to output . cpp file " ) <nl> + args = parser . parse_args ( ) <nl> + <nl> + if args . debug : <nl> logging . basicConfig ( format = LOG_FORMAT , level = logging . DEBUG ) <nl> else : <nl> logging . basicConfig ( format = LOG_FORMAT , level = logging . INFO ) <nl> def main ( argc , argv ) : <nl> if argc < 3 : <nl> usage ( ) <nl> sys . exit ( 1 ) <nl> - filename = argv [ 1 ] <nl> - output = argv [ 2 ] <nl> + filename = args . spec_file <nl> + output = args . output <nl> <nl> if filename . endswith ( " . table " ) : <nl> # Adding a 3rd parameter will enable the blacklist <nl> disable_blacklist = argc > 3 <nl> <nl> - setup_templates ( filename ) <nl> + setup_templates ( args . templates ) <nl> with open ( filename , " rU " ) as file_handle : <nl> tree = ast . parse ( file_handle . read ( ) ) <nl> exec ( compile ( tree , " < string > " , " exec " ) ) <nl> def main ( argc , argv ) : <nl> table . generate ( output ) <nl> <nl> if __name__ = = " __main__ " : <nl> + SCRIPT_DIR = os . path . dirname ( os . path . realpath ( __file__ ) ) <nl> main ( len ( sys . argv ) , sys . argv ) <nl> similarity index 100 % <nl> rename from osquery / tables / templates / amalgamation . cpp . in <nl> rename to tools / codegen / templates / amalgamation . cpp . in <nl> similarity index 100 % <nl> rename from osquery / tables / templates / blacklist . cpp . in <nl> rename to tools / codegen / templates / blacklist . cpp . in <nl> similarity index 100 % <nl> rename from osquery / tables / templates / default . cpp . in <nl> rename to tools / codegen / templates / default . cpp . in <nl> mmm a / tools / profile . py <nl> ppp b / tools / profile . py <nl> def get_stats ( p , interval = 1 ) : <nl> utilization = p . cpu_percent ( interval = interval ) <nl> return { <nl> " utilization " : utilization , <nl> - " counters " : p . io_counters ( ) if sys . platform ! = " darwin " else None , <nl> + " counters " : p . io_counters ( ) if platform ( ) ! = " darwin " else None , <nl> " fds " : p . num_fds ( ) , <nl> " cpu_times " : p . cpu_times ( ) , <nl> " memory " : p . memory_info_ex ( ) , <nl> def check_leaks_darwin ( shell , query , count = 1 ) : <nl> <nl> <nl> def check_leaks ( shell , query , count = 1 , supp_file = None ) : <nl> - if sys . platform = = " darwin " : <nl> + if platform ( ) = = " darwin " : <nl> return check_leaks_darwin ( shell , query , count = count ) <nl> else : <nl> return check_leaks_linux ( shell , query , count = count , supp_file = supp_file ) <nl> def regress_check ( profile1 , profile2 ) : <nl> return 1 <nl> <nl> if __name__ = = " __main__ " : <nl> - platform = sys . platform <nl> - if platform = = " linux2 " : <nl> - platform = " linux " <nl> parser = argparse . ArgumentParser ( description = ( <nl> " Profile osquery , individual tables , " <nl> " or a set of osqueryd config queries . " <nl> def regress_check ( profile1 , profile2 ) : <nl> ) <nl> group . add_argument ( <nl> " - - shell " , metavar = " PATH " , default = " . / build / % s / osquery / run " % ( <nl> - platform ) , <nl> + platform ( ) ) , <nl> help = " Path to osquery run wrapper ( . / build / < sys > / osquery / run ) . " <nl> ) <nl> <nl> mmm a / tools / tests / CMakeLists . txt <nl> ppp b / tools / tests / CMakeLists . txt <nl> ADD_OSQUERY_PYTHON_TEST ( test_osqueryd test_osqueryd . py ) <nl> ADD_OSQUERY_PYTHON_TEST ( test_modules test_modules . py ) <nl> ADD_OSQUERY_PYTHON_TEST ( test_extensions test_extensions . py ) <nl> ADD_OSQUERY_PYTHON_TEST ( test_additional test_additional . py ) <nl> + ADD_OSQUERY_PYTHON_TEST ( test_example_queries test_example_queries . py ) <nl> \ No newline at end of file <nl> new file mode 100755 <nl> index 0000000000 . . 60f6a3830d <nl> mmm / dev / null <nl> ppp b / tools / tests / test_example_queries . py <nl> <nl> + # ! / usr / bin / env python <nl> + <nl> + # Copyright ( c ) 2014 , Facebook , Inc . <nl> + # All rights reserved . <nl> + # <nl> + # This source code is licensed under the BSD - style license found in the <nl> + # LICENSE file in the root directory of this source tree . An additional grant <nl> + # of patent rights can be found in the PATENTS file in the same directory . <nl> + <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + from __future__ import unicode_literals <nl> + <nl> + import os <nl> + import shutil <nl> + import time <nl> + import unittest <nl> + import sys <nl> + <nl> + # osquery - specific testing utils <nl> + import test_base <nl> + import utils <nl> + <nl> + class ExampleQueryTests ( test_base . ProcessGenerator , unittest . TestCase ) : <nl> + def setUp ( self ) : <nl> + self . daemon = self . _run_daemon ( { <nl> + # The set of queries will hammer the daemon process . <nl> + " disable_watchdog " : True , <nl> + } ) <nl> + self . assertTrue ( self . daemon . isAlive ( ) ) <nl> + <nl> + # The sets of example tests will use the extensions API . s <nl> + self . client = test_base . EXClient ( self . daemon . options [ " extensions_socket " ] ) <nl> + test_base . expectTrue ( self . client . open ) <nl> + self . assertTrue ( self . client . open ( ) ) <nl> + self . em = self . client . getEM ( ) <nl> + <nl> + def tearDown ( self ) : <nl> + self . client . close ( ) <nl> + self . daemon . kill ( ) <nl> + <nl> + def _execute ( self , query ) : <nl> + try : <nl> + result = self . em . query ( query ) <nl> + self . assertEqual ( result . status . code , 0 ) <nl> + return result . response <nl> + except Exception as e : <nl> + print ( " General exception executing query : % s " % ( <nl> + utils . lightred ( query ) ) ) <nl> + raise e <nl> + <nl> + def _execute_set ( self , queries ) : <nl> + for example in queries : <nl> + start_time = time . time ( ) <nl> + result = self . _execute ( example ) <nl> + end_time = time . time ( ) <nl> + duration_ms = int ( ( end_time - start_time ) * 1000 ) <nl> + if duration_ms > 2000 : <nl> + # Query took longer than 2 seconds . <nl> + duration_ms = utils . lightred ( duration_ms ) <nl> + print ( " Query ( % sms ) : % s , rows : % d " % ( <nl> + duration_ms , example , len ( result ) ) ) <nl> + <nl> + <nl> + def test_cross_platform_queries ( self ) : <nl> + self . _execute_set ( PLATFORM_EXAMPLES [ " specs " ] ) <nl> + <nl> + def test_platform_specific_queries ( self ) : <nl> + self . _execute_set ( PLATFORM_EXAMPLES [ utils . platform ( ) ] ) <nl> + <nl> + def test_utility_queries ( self ) : <nl> + self . _execute_set ( PLATFORM_EXAMPLES [ " utility " ] ) <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + # Import the API generation code for example query introspection . <nl> + SCRIPT_DIR = os . path . dirname ( os . path . realpath ( __file__ ) ) <nl> + SOURCE_DIR = os . path . abspath ( SCRIPT_DIR + " / . . / . . / " ) <nl> + sys . path . append ( SOURCE_DIR + " / tools / codegen " ) <nl> + from genapi import gen_api <nl> + API = gen_api ( SOURCE_DIR + " / specs " ) <nl> + <nl> + # Organize example queries by platform <nl> + PLATFORM_EXAMPLES = { } <nl> + for category in API : <nl> + PLATFORM_EXAMPLES [ category [ " key " ] ] = [ ] <nl> + for table in category [ " tables " ] : <nl> + PLATFORM_EXAMPLES [ category [ " key " ] ] + = table [ " examples " ] <nl> + <nl> + module = test_base . Tester ( ) <nl> + <nl> + # Find and import the thrift - generated python interface <nl> + test_base . loadThriftFromBuild ( test_base . ARGS . build ) <nl> + <nl> + module . run ( ) <nl> mmm a / tools / tests / utils . py <nl> ppp b / tools / tests / utils . py <nl> def red ( msg ) : <nl> <nl> <nl> def lightred ( msg ) : <nl> - return " \ 033 [ 1 ; 31m % s \ 033 [ 0m " % str ( msg ) <nl> + return " \ 033 [ 1 ; 31m % s \ 033 [ 0m " % str ( msg ) <nl> <nl> <nl> def yellow ( msg ) : <nl> def write_config ( data = { } , path = None ) : <nl> with open ( path , " w " ) as fh : <nl> fh . write ( json . dumps ( data ) ) <nl> <nl> + <nl> + def platform ( ) : <nl> + platform = sys . platform <nl> + if platform . find ( " linux " ) = = 0 : <nl> + platform = " linux " <nl> + if platform . find ( " freebsd " ) = = 0 : <nl> + platform = " freebsd " <nl> + return platform <nl> + <nl> + <nl> def queries_from_config ( config_path ) : <nl> config = { } <nl> try : <nl> def queries_from_tables ( path , restrict ) : <nl> " " " Construct select all queries from all tables . " " " <nl> # Let the caller limit the tables <nl> restrict_tables = [ t . strip ( ) for t in restrict . split ( " , " ) ] <nl> - platform = sys . platform if sys . platform is not " linux2 " else " linux " <nl> + platform = platform ( ) <nl> tables = [ ] <nl> for base , _ , files in os . walk ( path ) : <nl> for spec in files : <nl>
|
Move specs to a top - level path , add query examples
|
osquery/osquery
|
a1059248042e5a6a0f0d43be22d320815548458a
|
2015-06-03T17:39:05Z
|
mmm a / src / addrman . h <nl> ppp b / src / addrman . h <nl> class CAddrInfo : public CAddress <nl> # define ADDRMAN_GETADDR_MAX_PCT 23 <nl> <nl> / / ! the maximum number of nodes to return in a getaddr call <nl> - # define ADDRMAN_GETADDR_MAX 2500 <nl> + # define ADDRMAN_GETADDR_MAX 1000 <nl> <nl> / / ! Convenience <nl> # define ADDRMAN_TRIED_BUCKET_COUNT ( 1 < < ADDRMAN_TRIED_BUCKET_COUNT_LOG2 ) <nl> mmm a / src / net . cpp <nl> ppp b / src / net . cpp <nl> void CConnman : : AddNewAddresses ( const std : : vector < CAddress > & vAddr , const CAddres <nl> <nl> std : : vector < CAddress > CConnman : : GetAddresses ( ) <nl> { <nl> - return addrman . GetAddr ( ) ; <nl> + std : : vector < CAddress > addresses = addrman . GetAddr ( ) ; <nl> + if ( m_banman ) { <nl> + addresses . erase ( std : : remove_if ( addresses . begin ( ) , addresses . end ( ) , <nl> + [ this ] ( const CAddress & addr ) { return m_banman - > IsDiscouraged ( addr ) | | m_banman - > IsBanned ( addr ) ; } ) , <nl> + addresses . end ( ) ) ; <nl> + } <nl> + return addresses ; <nl> + } <nl> + <nl> + std : : vector < CAddress > CConnman : : GetAddresses ( Network requestor_network ) <nl> + { <nl> + const auto current_time = GetTime < std : : chrono : : microseconds > ( ) ; <nl> + if ( m_addr_response_caches . find ( requestor_network ) = = m_addr_response_caches . end ( ) | | <nl> + m_addr_response_caches [ requestor_network ] . m_update_addr_response < current_time ) { <nl> + m_addr_response_caches [ requestor_network ] . m_addrs_response_cache = GetAddresses ( ) ; <nl> + m_addr_response_caches [ requestor_network ] . m_update_addr_response = current_time + std : : chrono : : hours ( 21 ) + GetRandMillis ( std : : chrono : : hours ( 6 ) ) ; <nl> + } <nl> + return m_addr_response_caches [ requestor_network ] . m_addrs_response_cache ; <nl> } <nl> <nl> bool CConnman : : AddNode ( const std : : string & strNode ) <nl> mmm a / src / net . h <nl> ppp b / src / net . h <nl> <nl> # include < atomic > <nl> # include < cstdint > <nl> # include < deque > <nl> + # include < map > <nl> # include < thread > <nl> # include < memory > <nl> # include < condition_variable > <nl> static const int TIMEOUT_INTERVAL = 20 * 60 ; <nl> static const int FEELER_INTERVAL = 120 ; <nl> / * * The maximum number of new addresses to accumulate before announcing . * / <nl> static const unsigned int MAX_ADDR_TO_SEND = 1000 ; <nl> + / / TODO : remove ADDRMAN_GETADDR_MAX and let the caller specify this limit with MAX_ADDR_TO_SEND . <nl> + static_assert ( MAX_ADDR_TO_SEND = = ADDRMAN_GETADDR_MAX , <nl> + " Max allowed ADDR message size should be equal to the max number of records returned from AddrMan . " ) ; <nl> / * * Maximum length of incoming protocol messages ( no message over 4 MB is currently acceptable ) . * / <nl> static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1000 * 1000 ; <nl> / * * Maximum length of the user agent string in ` version ` message * / <nl> class CConnman <nl> void MarkAddressGood ( const CAddress & addr ) ; <nl> void AddNewAddresses ( const std : : vector < CAddress > & vAddr , const CAddress & addrFrom , int64_t nTimePenalty = 0 ) ; <nl> std : : vector < CAddress > GetAddresses ( ) ; <nl> + / * * <nl> + * Cache is used to minimize topology leaks , so it should <nl> + * be used for all non - trusted calls , for example , p2p . <nl> + * A non - malicious call ( from RPC or a peer with addr permission ) should <nl> + * call the function without a parameter to avoid using the cache . <nl> + * / <nl> + std : : vector < CAddress > GetAddresses ( Network requestor_network ) ; <nl> <nl> / / This allows temporarily exceeding m_max_outbound_full_relay , with the goal of finding <nl> / / a peer that is better than all our current peers . <nl> class CConnman <nl> std : : atomic < NodeId > nLastNodeId { 0 } ; <nl> unsigned int nPrevNodeCount { 0 } ; <nl> <nl> + / * * <nl> + * Cache responses to addr requests to minimize privacy leak . <nl> + * Attack example : scraping addrs in real - time may allow an attacker <nl> + * to infer new connections of the victim by detecting new records <nl> + * with fresh timestamps ( per self - announcement ) . <nl> + * / <nl> + struct CachedAddrResponse { <nl> + std : : vector < CAddress > m_addrs_response_cache ; <nl> + std : : chrono : : microseconds m_update_addr_response { 0 } ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Addr responses stored in different caches <nl> + * per network prevent cross - network node identification . <nl> + * If a node for example is multi - homed under Tor and IPv6 , <nl> + * a single cache ( or no cache at all ) would let an attacker <nl> + * to easily detect that it is the same node by comparing responses . <nl> + * The used memory equals to 1000 CAddress records ( or around 32 bytes ) per <nl> + * distinct Network ( up to 5 ) we have / had an inbound peer from , <nl> + * resulting in at most ~ 160 KB . <nl> + * / <nl> + std : : map < Network , CachedAddrResponse > m_addr_response_caches ; <nl> + <nl> / * * <nl> * Services this instance offers . <nl> * <nl> mmm a / src / net_permissions . cpp <nl> ppp b / src / net_permissions . cpp <nl> const std : : vector < std : : string > NET_PERMISSIONS_DOC { <nl> " relay ( relay even in - blocksonly mode ) " , <nl> " mempool ( allow requesting BIP35 mempool contents ) " , <nl> " download ( allow getheaders during IBD , no disconnect after maxuploadtarget limit ) " , <nl> + " addr ( responses to GETADDR avoid hitting the cache and contain random records with the most up - to - date info ) " <nl> } ; <nl> <nl> namespace { <nl> bool TryParsePermissionFlags ( const std : : string str , NetPermissionFlags & output , <nl> else if ( permission = = " download " ) NetPermissions : : AddFlag ( flags , PF_DOWNLOAD ) ; <nl> else if ( permission = = " all " ) NetPermissions : : AddFlag ( flags , PF_ALL ) ; <nl> else if ( permission = = " relay " ) NetPermissions : : AddFlag ( flags , PF_RELAY ) ; <nl> + else if ( permission = = " addr " ) NetPermissions : : AddFlag ( flags , PF_ADDR ) ; <nl> else if ( permission . length ( ) = = 0 ) ; / / Allow empty entries <nl> else { <nl> error = strprintf ( _ ( " Invalid P2P permission : ' % s ' " ) , permission ) ; <nl> std : : vector < std : : string > NetPermissions : : ToStrings ( NetPermissionFlags flags ) <nl> if ( NetPermissions : : HasFlag ( flags , PF_RELAY ) ) strings . push_back ( " relay " ) ; <nl> if ( NetPermissions : : HasFlag ( flags , PF_MEMPOOL ) ) strings . push_back ( " mempool " ) ; <nl> if ( NetPermissions : : HasFlag ( flags , PF_DOWNLOAD ) ) strings . push_back ( " download " ) ; <nl> + if ( NetPermissions : : HasFlag ( flags , PF_ADDR ) ) strings . push_back ( " addr " ) ; <nl> return strings ; <nl> } <nl> <nl> mmm a / src / net_permissions . h <nl> ppp b / src / net_permissions . h <nl> enum NetPermissionFlags { <nl> PF_NOBAN = ( 1U < < 4 ) | PF_DOWNLOAD , <nl> / / Can query the mempool <nl> PF_MEMPOOL = ( 1U < < 5 ) , <nl> + / / Can request addrs without hitting a privacy - preserving cache <nl> + PF_ADDR = ( 1U < < 7 ) , <nl> <nl> / / True if the user did not specifically set fine grained permissions <nl> PF_ISIMPLICIT = ( 1U < < 31 ) , <nl> - PF_ALL = PF_BLOOMFILTER | PF_FORCERELAY | PF_RELAY | PF_NOBAN | PF_MEMPOOL | PF_DOWNLOAD , <nl> + PF_ALL = PF_BLOOMFILTER | PF_FORCERELAY | PF_RELAY | PF_NOBAN | PF_MEMPOOL | PF_DOWNLOAD | PF_ADDR , <nl> } ; <nl> <nl> class NetPermissions <nl> mmm a / src / net_processing . cpp <nl> ppp b / src / net_processing . cpp <nl> void ProcessMessage ( <nl> if ( ! pfrom . IsAddrRelayPeer ( ) ) { <nl> return ; <nl> } <nl> - if ( vAddr . size ( ) > 1000 ) <nl> + if ( vAddr . size ( ) > MAX_ADDR_TO_SEND ) <nl> { <nl> LOCK ( cs_main ) ; <nl> Misbehaving ( pfrom . GetId ( ) , 20 , strprintf ( " addr message size = % u " , vAddr . size ( ) ) ) ; <nl> void ProcessMessage ( <nl> pfrom . fSentAddr = true ; <nl> <nl> pfrom . vAddrToSend . clear ( ) ; <nl> - std : : vector < CAddress > vAddr = connman . GetAddresses ( ) ; <nl> + std : : vector < CAddress > vAddr ; <nl> + if ( pfrom . HasPermission ( PF_ADDR ) ) { <nl> + vAddr = connman . GetAddresses ( ) ; <nl> + } else { <nl> + vAddr = connman . GetAddresses ( pfrom . addr . GetNetwork ( ) ) ; <nl> + } <nl> FastRandomContext insecure_rand ; <nl> for ( const CAddress & addr : vAddr ) { <nl> - bool banned_or_discouraged = banman & & ( banman - > IsDiscouraged ( addr ) | | banman - > IsBanned ( addr ) ) ; <nl> - if ( ! banned_or_discouraged ) { <nl> - pfrom . PushAddress ( addr , insecure_rand ) ; <nl> - } <nl> + pfrom . PushAddress ( addr , insecure_rand ) ; <nl> } <nl> return ; <nl> } <nl> bool PeerLogicValidation : : SendMessages ( CNode * pto ) <nl> { <nl> pto - > m_addr_known - > insert ( addr . GetKey ( ) ) ; <nl> vAddr . push_back ( addr ) ; <nl> - / / receiver rejects addr messages larger than 1000 <nl> - if ( vAddr . size ( ) > = 1000 ) <nl> + / / receiver rejects addr messages larger than MAX_ADDR_TO_SEND <nl> + if ( vAddr . size ( ) > = MAX_ADDR_TO_SEND ) <nl> { <nl> connman - > PushMessage ( pto , msgMaker . Make ( NetMsgType : : ADDR , vAddr ) ) ; <nl> vAddr . clear ( ) ; <nl> mmm a / src / test / fuzz / net_permissions . cpp <nl> ppp b / src / test / fuzz / net_permissions . cpp <nl> void test_one_input ( const std : : vector < uint8_t > & buffer ) <nl> NetPermissionFlags : : PF_FORCERELAY , <nl> NetPermissionFlags : : PF_NOBAN , <nl> NetPermissionFlags : : PF_MEMPOOL , <nl> + NetPermissionFlags : : PF_ADDR , <nl> NetPermissionFlags : : PF_ISIMPLICIT , <nl> NetPermissionFlags : : PF_ALL , <nl> } ) : <nl> mmm a / src / test / netbase_tests . cpp <nl> ppp b / src / test / netbase_tests . cpp <nl> BOOST_AUTO_TEST_CASE ( netpermissions_test ) <nl> BOOST_CHECK ( NetWhitelistPermissions : : TryParse ( " bloom , forcerelay , noban , relay , mempool @ 1 . 2 . 3 . 4 / 32 " , whitelistPermissions , error ) ) ; <nl> <nl> const auto strings = NetPermissions : : ToStrings ( PF_ALL ) ; <nl> - BOOST_CHECK_EQUAL ( strings . size ( ) , 6U ) ; <nl> + BOOST_CHECK_EQUAL ( strings . size ( ) , 7U ) ; <nl> BOOST_CHECK ( std : : find ( strings . begin ( ) , strings . end ( ) , " bloomfilter " ) ! = strings . end ( ) ) ; <nl> BOOST_CHECK ( std : : find ( strings . begin ( ) , strings . end ( ) , " forcerelay " ) ! = strings . end ( ) ) ; <nl> BOOST_CHECK ( std : : find ( strings . begin ( ) , strings . end ( ) , " relay " ) ! = strings . end ( ) ) ; <nl> BOOST_CHECK ( std : : find ( strings . begin ( ) , strings . end ( ) , " noban " ) ! = strings . end ( ) ) ; <nl> BOOST_CHECK ( std : : find ( strings . begin ( ) , strings . end ( ) , " mempool " ) ! = strings . end ( ) ) ; <nl> BOOST_CHECK ( std : : find ( strings . begin ( ) , strings . end ( ) , " download " ) ! = strings . end ( ) ) ; <nl> + BOOST_CHECK ( std : : find ( strings . begin ( ) , strings . end ( ) , " addr " ) ! = strings . end ( ) ) ; <nl> } <nl> <nl> BOOST_AUTO_TEST_CASE ( netbase_dont_resolve_strings_with_embedded_nul_characters ) <nl> new file mode 100755 <nl> index 000000000000 . . c9278eab922c <nl> mmm / dev / null <nl> ppp b / test / functional / p2p_getaddr_caching . py <nl> <nl> + # ! / usr / bin / env python3 <nl> + # Copyright ( c ) 2020 The Bitcoin Core developers <nl> + # Distributed under the MIT software license , see the accompanying <nl> + # file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> + " " " Test addr response caching " " " <nl> + <nl> + import time <nl> + from test_framework . messages import ( <nl> + CAddress , <nl> + NODE_NETWORK , <nl> + NODE_WITNESS , <nl> + msg_addr , <nl> + msg_getaddr , <nl> + ) <nl> + from test_framework . mininode import ( <nl> + P2PInterface , <nl> + mininode_lock <nl> + ) <nl> + from test_framework . test_framework import BitcoinTestFramework <nl> + from test_framework . util import ( <nl> + assert_equal , <nl> + ) <nl> + <nl> + MAX_ADDR_TO_SEND = 1000 <nl> + <nl> + def gen_addrs ( n ) : <nl> + addrs = [ ] <nl> + for i in range ( n ) : <nl> + addr = CAddress ( ) <nl> + addr . time = int ( time . time ( ) ) <nl> + addr . nServices = NODE_NETWORK | NODE_WITNESS <nl> + # Use first octets to occupy different AddrMan buckets <nl> + first_octet = i > > 8 <nl> + second_octet = i % 256 <nl> + addr . ip = " { } . { } . 1 . 1 " . format ( first_octet , second_octet ) <nl> + addr . port = 8333 <nl> + addrs . append ( addr ) <nl> + return addrs <nl> + <nl> + class AddrReceiver ( P2PInterface ) : <nl> + <nl> + def __init__ ( self ) : <nl> + super ( ) . __init__ ( ) <nl> + self . received_addrs = None <nl> + <nl> + def get_received_addrs ( self ) : <nl> + with mininode_lock : <nl> + return self . received_addrs <nl> + <nl> + def on_addr ( self , message ) : <nl> + self . received_addrs = [ ] <nl> + for addr in message . addrs : <nl> + self . received_addrs . append ( addr . ip ) <nl> + <nl> + def addr_received ( self ) : <nl> + return self . received_addrs is not None <nl> + <nl> + <nl> + class AddrTest ( BitcoinTestFramework ) : <nl> + def set_test_params ( self ) : <nl> + self . setup_clean_chain = False <nl> + self . num_nodes = 1 <nl> + <nl> + def run_test ( self ) : <nl> + self . log . info ( ' Create connection that sends and requests addr messages ' ) <nl> + addr_source = self . nodes [ 0 ] . add_p2p_connection ( P2PInterface ( ) ) <nl> + <nl> + msg_send_addrs = msg_addr ( ) <nl> + self . log . info ( ' Fill peer AddrMan with a lot of records ' ) <nl> + # Since these addrs are sent from the same source , not all of them will be stored , <nl> + # because we allocate a limited number of AddrMan buckets per addr source . <nl> + total_addrs = 10000 <nl> + addrs = gen_addrs ( total_addrs ) <nl> + for i in range ( int ( total_addrs / MAX_ADDR_TO_SEND ) ) : <nl> + msg_send_addrs . addrs = addrs [ i * MAX_ADDR_TO_SEND : ( i + 1 ) * MAX_ADDR_TO_SEND ] <nl> + addr_source . send_and_ping ( msg_send_addrs ) <nl> + <nl> + responses = [ ] <nl> + self . log . info ( ' Send many addr requests within short time to receive same response ' ) <nl> + N = 5 <nl> + cur_mock_time = int ( time . time ( ) ) <nl> + for i in range ( N ) : <nl> + addr_receiver = self . nodes [ 0 ] . add_p2p_connection ( AddrReceiver ( ) ) <nl> + addr_receiver . send_and_ping ( msg_getaddr ( ) ) <nl> + # Trigger response <nl> + cur_mock_time + = 5 * 60 <nl> + self . nodes [ 0 ] . setmocktime ( cur_mock_time ) <nl> + addr_receiver . wait_until ( addr_receiver . addr_received ) <nl> + responses . append ( addr_receiver . get_received_addrs ( ) ) <nl> + for response in responses [ 1 : ] : <nl> + assert_equal ( response , responses [ 0 ] ) <nl> + assert ( len ( response ) < MAX_ADDR_TO_SEND ) <nl> + <nl> + cur_mock_time + = 3 * 24 * 60 * 60 <nl> + self . nodes [ 0 ] . setmocktime ( cur_mock_time ) <nl> + <nl> + self . log . info ( ' After time passed , see a new response to addr request ' ) <nl> + last_addr_receiver = self . nodes [ 0 ] . add_p2p_connection ( AddrReceiver ( ) ) <nl> + last_addr_receiver . send_and_ping ( msg_getaddr ( ) ) <nl> + # Trigger response <nl> + cur_mock_time + = 5 * 60 <nl> + self . nodes [ 0 ] . setmocktime ( cur_mock_time ) <nl> + last_addr_receiver . wait_until ( last_addr_receiver . addr_received ) <nl> + # new response is different <nl> + assert ( set ( responses [ 0 ] ) ! = set ( last_addr_receiver . get_received_addrs ( ) ) ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + AddrTest ( ) . main ( ) <nl> mmm a / test / functional / p2p_permissions . py <nl> ppp b / test / functional / p2p_permissions . py <nl> def run_test ( self ) : <nl> self . checkpermission ( <nl> # all permission added <nl> [ " - whitelist = all @ 127 . 0 . 0 . 1 " ] , <nl> - [ " forcerelay " , " noban " , " mempool " , " bloomfilter " , " relay " , " download " ] , <nl> + [ " forcerelay " , " noban " , " mempool " , " bloomfilter " , " relay " , " download " , " addr " ] , <nl> False ) <nl> <nl> self . stop_node ( 1 ) <nl> mmm a / test / functional / test_runner . py <nl> ppp b / test / functional / test_runner . py <nl> <nl> ' rpc_deprecated . py ' , <nl> ' wallet_disable . py ' , <nl> ' p2p_addr_relay . py ' , <nl> + ' p2p_getaddr_caching . py ' , <nl> ' p2p_getdata . py ' , <nl> ' rpc_net . py ' , <nl> ' wallet_keypool . py ' , <nl>
|
Merge : Cache responses to GETADDR to prevent topology leaks
|
bitcoin/bitcoin
|
14ceddd29085b6cd9327892de4cd22ae2f3e0095
|
2020-08-03T12:48:52Z
|
mmm a / code / mathematical - algorithms / armstrong_numbers / armstrong_numbers . cpp <nl> ppp b / code / mathematical - algorithms / armstrong_numbers / armstrong_numbers . cpp <nl> <nl> # include < iostream > <nl> # include < cmath > <nl> using namespace std ; <nl> - <nl> + / / Part of Cosmos by OpenGenus Foundation <nl> int main ( ) <nl> { <nl> int initialNumber ; <nl>
|
header comment added
|
OpenGenus/cosmos
|
b36dd561d7166514a2606478223a0692ed7e9919
|
2017-10-07T16:16:11Z
|
mmm a / src / util . h <nl> ppp b / src / util . h <nl> typedef boost : : interprocess : : interprocess_condition CConditionVariable ; <nl> } <nl> <nl> <nl> - / / This is exactly like std : : string , but with a custom allocator . <nl> - / / ( secure_allocator < > is defined in serialize . h ) <nl> - typedef std : : basic_string < char , std : : char_traits < char > , secure_allocator < char > > SecureString ; <nl> - <nl> - <nl> - <nl> - <nl> - <nl> inline std : : string i64tostr ( int64 n ) <nl> { <nl> return strprintf ( " % " PRI64d , n ) ; <nl>
|
remove duplicate definition of SecureString in util . h
|
bitcoin/bitcoin
|
3ee5f8aac3541604c94594b2f4b9cc7d4453a51b
|
2012-05-01T16:49:50Z
|
mmm a / tools / swift / Immediate . cpp <nl> ppp b / tools / swift / Immediate . cpp <nl> struct EditLineWrapper { <nl> el_set ( e , EL_CLIENTDATA , ( void * ) this ) ; <nl> el_set ( e , EL_HIST , history , h ) ; <nl> el_set ( e , EL_SIGNAL , 1 ) ; <nl> + <nl> + / / Provide special outdenting behavior for ' } ' . <nl> el_set ( e , EL_ADDFN , " swift - close - brace " , " Reduce { } indentation level " , <nl> - CloseBraceFn ) ; <nl> + BindingFn < & EditLineWrapper : : onCloseBrace > ) ; <nl> el_set ( e , EL_BIND , " } " , " swift - close - brace " , NULL ) ; <nl> + / / Provide special indent / completion behavior for tab . <nl> + el_set ( e , EL_ADDFN , " swift - indent - or - complete " , <nl> + " Indent line or trigger completion " , <nl> + BindingFn < & EditLineWrapper : : onIndentOrComplete > ) ; <nl> + el_set ( e , EL_BIND , " \ t " , " swift - indent - or - complete " , NULL ) ; <nl> + <nl> HistEvent ev ; <nl> history ( h , & ev , H_SETSIZE , 800 ) ; <nl> } <nl> struct EditLineWrapper { <nl> return PromptString . c_str ( ) ; <nl> } <nl> <nl> - static unsigned char CloseBraceFn ( EditLine * e , int ch ) { <nl> + template < unsigned char ( EditLineWrapper : : * method ) ( int ) > <nl> + static unsigned char BindingFn ( EditLine * e , int ch ) { <nl> void * clientdata ; <nl> el_get ( e , EL_CLIENTDATA , & clientdata ) ; <nl> - return ( ( EditLineWrapper * ) clientdata ) - > onCloseBrace ( ch ) ; <nl> + return ( ( ( EditLineWrapper * ) clientdata ) - > * method ) ( ch ) ; <nl> } <nl> <nl> unsigned char onCloseBrace ( int ch ) { <nl> struct EditLineWrapper { <nl> } <nl> return CC_REFRESH ; <nl> } <nl> + <nl> + unsigned char onIndentOrComplete ( int ch ) { <nl> + / / If there ' s nothing but whitespace before the cursor , indent to the next <nl> + / / 2 - character tab stop . <nl> + LineInfo const * line = el_line ( e ) ; <nl> + <nl> + bool shouldIndent = true ; <nl> + / / FIXME : UTF - 8 ? What ' s that ? <nl> + size_t cursorPos = line - > cursor - line - > buffer ; <nl> + for ( char c : StringRef ( line - > buffer , cursorPos ) ) { <nl> + if ( ! isspace ( c ) ) { <nl> + shouldIndent = false ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + if ( shouldIndent ) { <nl> + char const * indent = cursorPos & 1 ? " " : " " ; <nl> + el_insertstr ( e , indent ) ; <nl> + return CC_REFRESH ; <nl> + } <nl> + <nl> + / / TODO : Otherwise , look for completions . <nl> + return CC_REFRESH_BEEP ; <nl> + } <nl> <nl> ~ EditLineWrapper ( ) { <nl> el_end ( e ) ; <nl>
|
REPL : Indent when tab is pressed at start of line .
|
apple/swift
|
189bda045094cab5a985212910d286b96981c408
|
2013-02-06T23:50:14Z
|
mmm a / docker / packager / binary / build . sh <nl> ppp b / docker / packager / binary / build . sh <nl> cd build / build_docker <nl> ccache - - show - stats | | : <nl> ccache - - zero - stats | | : <nl> rm - f CMakeCache . txt <nl> - cmake . . - DCMAKE_BUILD_TYPE = $ BUILD_TYPE - DSANITIZE = $ SANITIZER $ CMAKE_FLAGS <nl> + cmake . . - LA - DCMAKE_BUILD_TYPE = $ BUILD_TYPE - DSANITIZE = $ SANITIZER $ CMAKE_FLAGS <nl> ninja <nl> ccache - - show - stats | | : <nl> mv . / dbms / programs / clickhouse * / output <nl>
|
Merge pull request from ClickHouse / aku / dump - cmake - options
|
ClickHouse/ClickHouse
|
3d909d9c05eeb180780344e41c2b28ddaa431028
|
2019-12-18T20:06:36Z
|
mmm a / db / client . cpp <nl> ppp b / db / client . cpp <nl> namespace mongo { <nl> BSONObj CachedBSONObj : : _tooBig = fromjson ( " { \ " $ msg \ " : \ " query not recording ( too large ) \ " } " ) ; <nl> AtomicUInt CurOp : : _nextOpNum ; <nl> <nl> - / * * true if this is " under " the parent collection . indexes are that way . i . e . for a db foo , <nl> - foo . mycoll can be thought of as a parent of foo . mycoll . $ someindex collection . <nl> - * / <nl> - bool subcollectionOf ( const string & parent , const char * child ) { <nl> - return parent = = child | | <nl> - ( strlen ( child ) > parent . size ( ) & & child [ parent . size ( ) ] = = ' . ' ) ; <nl> - } <nl> - <nl> - # if defined ( CLC ) <nl> - void Client : : checkLocks ( ) const { <nl> - if ( lockStatus . collLockCount ) { <nl> - assert ( ns ( ) = = 0 | | subcollectionOf ( lockStatus . whichCollection , ns ( ) ) ) ; <nl> - } <nl> - else if ( lockStatus . dbLockCount ) { <nl> - assert ( lockStatus . whichDB = = database ( ) | | database ( ) = = 0 ) ; <nl> - } <nl> - } <nl> - # endif <nl> - <nl> Client : : Context : : Context ( string ns , Database * db , bool doauth ) : <nl> _client ( currentClient . get ( ) ) , <nl> _oldContext ( _client - > _context ) , <nl> namespace mongo { <nl> * / <nl> Client : : ReadContext : : ReadContext ( const string & ns , string path , bool doauth ) { <nl> { <nl> - lk . reset ( new readlock ( ) ) ; <nl> + lk . reset ( new _LockCollectionForReading ( ns ) ) ; <nl> Database * db = dbHolder ( ) . get ( ns , path ) ; <nl> if ( db ) { <nl> c . reset ( new Context ( path , ns , db , doauth ) ) ; <nl> namespace mongo { <nl> Context c ( ns , path , doauth ) ; <nl> } <nl> / / db could be closed at this interim point - - that is ok , we will throw , and don ' t mind throwing . <nl> - lk . reset ( new readlock ( ) ) ; <nl> + lk . reset ( new _LockCollectionForReading ( ns ) ) ; <nl> c . reset ( new Context ( ns , path , doauth ) ) ; <nl> } <nl> else { <nl> mmm a / db / client . h <nl> ppp b / db / client . h <nl> <nl> - / * @ file client . h <nl> + / * @ file db / client . h <nl> <nl> " Client " represents a connection to the database ( the server - side ) and corresponds <nl> to an open socket ( or logical connection if pooling on sockets ) from a client . <nl> namespace mongo { <nl> class Command ; <nl> class Client ; <nl> class AbstractMessagingPort ; <nl> + class LockCollectionForReading ; <nl> + <nl> + # if defined ( CLC ) <nl> + typedef LockCollectionForReading _LockCollectionForReading ; <nl> + # else <nl> + typedef readlock _LockCollectionForReading ; <nl> + # endif <nl> <nl> TSP_DECLARE ( Client , currentClient ) <nl> <nl> namespace mongo { <nl> ReadContext ( const string & ns , string path = dbpath , bool doauth = true ) ; <nl> Context & ctx ( ) { return * c . get ( ) ; } <nl> private : <nl> - scoped_ptr < readlock > lk ; <nl> + scoped_ptr < _LockCollectionForReading > lk ; <nl> scoped_ptr < Context > c ; <nl> } ; <nl> <nl> namespace mongo { <nl> Database * _db ; <nl> } ; / / class Client : : Context <nl> <nl> - HLock : : TLS hlockInfo ; <nl> - <nl> - # if defined ( CLC ) <nl> - struct LockStatus { <nl> - LockStatus ( ) : dbLockCount ( 0 ) , whichDB ( 0 ) , collLockCount ( 0 ) { } <nl> - SimpleRWLock collLock ; <nl> - const Database * whichDB ; <nl> + struct LockStatus { <nl> + LockStatus ( ) ; <nl> string whichCollection ; <nl> - int dbLockCount ; <nl> - int collLockCount ; <nl> - bool collLocked ( ) ; <nl> + int coll ; <nl> } lockStatus ; <nl> - # endif <nl> + <nl> void checkLocks ( ) const { } <nl> <nl> } ; / / class Client <nl> namespace mongo { <nl> _prev = cc ( ) . _god ; <nl> cc ( ) . _god = true ; <nl> } <nl> - <nl> inline Client : : GodScope : : ~ GodScope ( ) { cc ( ) . _god = _prev ; } <nl> <nl> / * this unreadlocks and then writelocks ; i . e . it does NOT upgrade inside the <nl> mmm a / db / d_concurrency . cpp <nl> ppp b / db / d_concurrency . cpp <nl> <nl> # include " d_concurrency . h " <nl> # include " . . / util / concurrency / threadlocal . h " <nl> # include " . . / util / concurrency / rwlock . h " <nl> + # include " . . / util / concurrency / value . h " <nl> # include " . . / util / assert_util . h " <nl> # include " client . h " <nl> <nl> - namespace mongo { <nl> - <nl> - SimpleRWLock writeExcluder ; <nl> - <nl> - / / kept in cc ( ) . . . <nl> - HLock : : TLS : : TLS ( ) { <nl> - x = 0 ; <nl> - } <nl> - HLock : : TLS : : ~ TLS ( ) { <nl> - wassert ( x = = 0 ) ; <nl> - } <nl> - <nl> - HLock : : HLock ( int l , HLock * p ) : <nl> - level ( l ) , parent ( p ) , r ( 0 ) <nl> - { <nl> - dassert ( level > 0 ) ; <nl> - } <nl> - void HLock : : hlockShared ( int n ) { <nl> - if ( - - n > 0 ) { <nl> - assert ( parent ) ; <nl> - parent - > hlockShared ( n ) ; <nl> - } <nl> - r . lock_shared ( ) ; <nl> - } <nl> - void HLock : : hunlockShared ( int n ) { <nl> - r . unlock_shared ( ) ; <nl> - if ( - - n > 0 ) { <nl> - assert ( parent ) ; <nl> - parent - > hunlockShared ( n ) ; <nl> - } <nl> - } <nl> - <nl> - HLock : : readlock : : readlock ( HLock & _h ) : h ( _h ) { <nl> - int & x = cc ( ) . hlockInfo . x ; <nl> - nToLock = h . level - x ; <nl> - if ( nToLock < = 0 ) <nl> - return ; <nl> - x + = nToLock ; <nl> - dassert ( x = = h . level ) ; <nl> - h . hlockShared ( nToLock ) ; <nl> - } <nl> - HLock : : readlock : : ~ readlock ( ) { <nl> - if ( nToLock > 0 ) <nl> - h . hunlockShared ( nToLock ) ; <nl> - } <nl> - <nl> - # if defined ( CLC ) <nl> - <nl> - HLock : : readlocktry : : readlocktry ( int ms ) { <nl> - already = cc ( ) . readLocked | | cc ( ) . writeLocked ; <nl> - if ( ! already ) { <nl> - ok = h . hlockSharedTry ( ) ; <nl> - } <nl> - } <nl> + / / we will use the global write lock for writing to system . * collections for simplicity <nl> + / / for now ; this has some advantages in speed as we don ' t need to latch just for that then ; <nl> + / / also there are cases to be handled carefully otherwise such as namespacedetails methods <nl> + / / reaching into system . indexes implicitly <nl> + / / <nl> + / / exception : system . profile <nl> <nl> - HLock : : writelock : : writelock ( HLock & _h ) : h ( _h ) { <nl> - assert ( ! cc ( ) . readLocked ) ; <nl> - already = cc ( ) . writeLocked ; <nl> - if ( ! already ) { <nl> - h . lock ( ) ; <nl> - cc ( ) . writeLocked = true ; <nl> - } <nl> - } <nl> - HLock : : writelock : : ~ writelock ( ) { <nl> - if ( ! already ) { <nl> - cc ( ) . writeLocked = false ; <nl> - h . hunlock ( ) ; <nl> - } <nl> - } <nl> + / / oplog locking <nl> + / / . . . <nl> <nl> - void HLock : : hlockShared ( ) { <nl> - if ( parent ) <nl> - parent - > hlockShared ( ) ; <nl> - r . lock_shared ( ) ; <nl> - } <nl> - void HLock : : hunlockShared ( ) { <nl> - r . unlock_shared ( ) ; <nl> - if ( parent ) <nl> - parent - > hunlockShared ( ) ; <nl> - } <nl> + namespace mongo { <nl> <nl> - / * <nl> - bool HLock : : hlockSharedTry ( int ms ) { <nl> - if ( parent & & ! parent - > hlockSharedTry ( ms ) ) { <nl> - return false ; <nl> - } <nl> - bool ok = r . lock_shared_try ( ms ) ; <nl> - if ( ! ok ) { <nl> - parent - > hunlockShared ( ) ; <nl> - } <nl> - return ok ; <nl> - } <nl> + / * * we want to be able to block any attempted write while allowing reads ; additionally <nl> + force non - greedy acquisition so that reads can continue - - <nl> + that is , disallow greediness of write lock acquisitions . This is for that purpose . The <nl> + # 1 need is by groupCommitWithLimitedLocks ( ) but useful elsewhere such as for lock and fsync . <nl> * / <nl> + SimpleRWLock writeExcluder ; <nl> <nl> - void HLock : : hlock ( ) { <nl> - writeExcluder . lock_shared ( ) ; <nl> - if ( parent ) <nl> - parent - > hlockShared ( ) ; <nl> - r . lock ( ) ; <nl> - } <nl> - void HLock : : hunlock ( ) { <nl> - r . unlock ( ) ; <nl> - if ( parent ) <nl> - parent - > hunlockShared ( ) ; <nl> - writeExcluder . unlock_shared ( ) ; <nl> + Client : : LockStatus : : LockStatus ( ) { <nl> + coll = 0 ; <nl> } <nl> <nl> - # if 0 <nl> - LockDatabaseSharable : : LockDatabaseSharable ( ) { <nl> - Client & c = cc ( ) ; <nl> - Client : : LockStatus & s = c . lockStatus ; <nl> - already = false ; <nl> - if ( dbMutex . isWriteLocked ( ) ) { <nl> - already = true ; <nl> - assert ( s . dbLockCount = = 0 ) ; <nl> - return ; <nl> - } <nl> - Database * db = c . database ( ) ; <nl> - assert ( db ) ; <nl> - if ( s . dbLockCount = = 0 ) { <nl> - s . whichDB = db ; <nl> - db - > dbLock . lock_shared ( ) ; <nl> - } <nl> - else { <nl> - / / recursed <nl> - massert ( 15919 , " wrong database while locking " , db = = s . whichDB ) ; <nl> + bool subcollectionOf ( const string & parent , const char * child ) { <nl> + if ( parent = = child ) <nl> + return true ; <nl> + if ( ! str : : startsWith ( child , parent ) ) <nl> + return false ; <nl> + const char * p = child + parent . size ( ) ; <nl> + return * p = = ' . ' & & p [ 1 ] = = ' $ ' ; <nl> + } <nl> + <nl> + / / we don ' t keep these locks in the namespacedetailstransient and Database <nl> + / / objects - - that makes things safer as we need not prove to ourselves that they <nl> + / / are always in scope when we need them . <nl> + / / todo : we don ' t clean these locks up yet . <nl> + / / todo : avoiding the mutex here might be nice . <nl> + class TheLocks { <nl> + / / mapsf < string , RWLock * > dblocks ; <nl> + mapsf < string , RWLock * > nslocks ; <nl> + public : <nl> + / * RWLock & fordb ( string db ) { <nl> + mapsf < string , RWLock * > : : ref r ( dblocks ) ; <nl> + RWLock * & rw = r [ db ] ; <nl> + if ( rw = = 0 ) <nl> + rw = new RWLock ( 0 ) ; <nl> + return * rw ; <nl> + } * / <nl> + RWLock & forns ( string ns ) { <nl> + mapsf < string , RWLock * > : : ref r ( nslocks ) ; <nl> + RWLock * & rw = r [ ns ] ; <nl> + if ( rw = = 0 ) { <nl> + rw = new RWLock ( 0 ) ; <nl> + } <nl> + return * rw ; <nl> } <nl> - s . dbLockCount - - ; / / < 0 means sharable <nl> - } <nl> + } theLocks ; <nl> <nl> - LockDatabaseSharable : : ~ LockDatabaseSharable ( ) { <nl> - if ( already ) <nl> - return ; <nl> - Client & c = cc ( ) ; <nl> - Client : : LockStatus & s = c . lockStatus ; <nl> - if ( c . database ( ) = = 0 ) { <nl> - wassert ( false ) ; <nl> - return ; <nl> - } <nl> - if ( c . database ( ) ! = s . whichDB ) { <nl> - DEV error ( ) < < " ~ LockDatabaseSharable wrong db context " < < c . database ( ) < < ' ' < < s . whichDB < < endl ; <nl> - wassert ( false ) ; <nl> - } <nl> - wassert ( s . dbLockCount < 0 ) ; <nl> - if ( + + s . dbLockCount = = 0 ) { <nl> - c . database ( ) - > dbLock . unlock_shared ( ) ; <nl> + LockCollectionForWriting : : Locks : : Locks ( string ns ) : <nl> + excluder ( writeExcluder ) , <nl> + gslk ( ) , <nl> + clk ( theLocks . forns ( ns ) , true ) <nl> + { } <nl> + LockCollectionForWriting : : ~ LockCollectionForWriting ( ) { <nl> + if ( locks . get ( ) ) { <nl> + Client : : LockStatus & s = cc ( ) . lockStatus ; <nl> + s . whichCollection . clear ( ) ; <nl> + s . coll - - ; <nl> } <nl> } <nl> - <nl> - bool subcollectionOf ( const string & parent , const char * child ) ; <nl> - <nl> - / * * notes <nl> - note if we r and w lock arbitarily with nested rwlocks we can deadlock . so we avoid this . <nl> - also have to be careful about any throws in things like this <nl> - * / <nl> - LockCollectionForReading : : LockCollectionForReading ( const char * ns ) <nl> + LockCollectionForWriting : : LockCollectionForWriting ( string coll ) <nl> { <nl> - Client & c = cc ( ) ; <nl> - Client : : LockStatus & s = c . lockStatus ; <nl> - assert ( c . ns ( ) & & ns & & str : : equals ( c . ns ( ) , ns ) ) ; <nl> - already = false ; <nl> - if ( dbMutex . isWriteLocked ( ) | | s . dbLockCount > 0 ) { <nl> - / / already locked exclusively at a higher level in the hierarchy <nl> - already = true ; <nl> - assert ( s . collLockCount = = 0 ) ; <nl> + Client : : LockStatus & s = cc ( ) . lockStatus ; <nl> + if ( ! s . whichCollection . empty ( ) ) { <nl> + if ( ! subcollectionOf ( s . whichCollection , coll . c_str ( ) ) ) { <nl> + massert ( 0 , str : : stream ( ) < < " can ' t nest lock of " < < coll < < " beneath " < < s . whichCollection , false ) ; <nl> + } <nl> + massert ( 0 , " want collection write lock but it is already read locked " , s . coll > 0 ) ; <nl> return ; <nl> } <nl> - <nl> - if ( s . collLockCount = = 0 ) { <nl> - s . whichCollection = ns ; <nl> - s . collLock . lock_shared ( ) ; <nl> - } <nl> - else { <nl> - / / must be the same ns or a child ns <nl> - assert ( subcollectionOf ( s . whichCollection , ns ) ) ; <nl> - if ( s . whichCollection ! = ns ) { <nl> - DEV log ( ) < < " info lock on nested ns : " < < ns < < endl ; <nl> + s . whichCollection = coll ; <nl> + dassert ( s . coll = = 0 ) ; <nl> + s . coll + + ; <nl> + locks . reset ( new Locks ( coll ) ) ; <nl> + } <nl> + <nl> + LockCollectionForReading : : Locks : : Locks ( string ns ) : <nl> + gslk ( ) , <nl> + clk ( theLocks . forns ( ns ) ) <nl> + { } <nl> + LockCollectionForReading : : ~ LockCollectionForReading ( ) { <nl> + Client : : LockStatus & s = cc ( ) . lockStatus ; <nl> + dassert ( ! s . whichCollection . empty ( ) ) ; <nl> + if ( locks . get ( ) ) { <nl> + s . whichCollection . clear ( ) ; <nl> + s . coll + + ; <nl> + wassert ( s . coll = = 0 ) ; <nl> + } <nl> + } <nl> + LockCollectionForReading : : LockCollectionForReading ( string coll ) <nl> + { <nl> + Client : : LockStatus & s = cc ( ) . lockStatus ; <nl> + if ( ! s . whichCollection . empty ( ) ) { <nl> + if ( ! subcollectionOf ( s . whichCollection , coll . c_str ( ) ) ) { <nl> + massert ( 0 , str : : stream ( ) < < " can ' t nest lock of " < < coll < < " beneath " < < s . whichCollection , false ) ; <nl> } <nl> - } <nl> - s . collLockCount - - ; / / < 0 means sharable state <nl> - } <nl> - <nl> - LockCollectionForReading : : ~ LockCollectionForReading ( ) { <nl> - if ( already ) <nl> + / / already locked , so done ; might have been a write lock . <nl> return ; <nl> - Client & c = cc ( ) ; <nl> - Client : : LockStatus & s = c . lockStatus ; <nl> - wassert ( c . ns ( ) & & s . whichCollection = = c . ns ( ) ) ; <nl> - wassert ( s . collLockCount < 0 ) ; <nl> - if ( + + s . collLockCount = = 0 ) { <nl> - s . collLock . unlock_shared ( ) ; <nl> } <nl> + s . whichCollection = coll ; <nl> + dassert ( s . coll = = 0 ) ; <nl> + s . coll - - ; <nl> + locks . reset ( new Locks ( coll ) ) ; <nl> } <nl> <nl> - # endif <nl> - <nl> - # endif <nl> - <nl> } <nl> mmm a / db / d_concurrency . h <nl> ppp b / db / d_concurrency . h <nl> <nl> # pragma once <nl> <nl> # include " . . / util / concurrency / rwlock . h " <nl> + # include " db / mongomutex . h " <nl> <nl> namespace mongo { <nl> <nl> - class HLock { <nl> - public : <nl> - HLock ( int level , HLock * parent ) ; <nl> - struct writelock { <nl> - writelock ( HLock & ) ; <nl> - ~ writelock ( ) ; <nl> - private : <nl> - HLock & h ; <nl> - bool already ; <nl> - } ; <nl> - struct readlock { <nl> - readlock ( HLock & ) ; <nl> - ~ readlock ( ) ; <nl> - private : <nl> - HLock & h ; int nToLock ; <nl> + class LockCollectionForReading { <nl> + struct Locks { <nl> + Locks ( string ns ) ; <nl> + GlobalSharedLock gslk ; <nl> + rwlock_shared clk ; <nl> } ; <nl> - struct TLS { <nl> - TLS ( ) ; ~ TLS ( ) ; int x ; <nl> + scoped_ptr < Locks > locks ; <nl> + public : <nl> + LockCollectionForReading ( string coll ) ; <nl> + ~ LockCollectionForReading ( ) ; <nl> + } ; <nl> + <nl> + class LockCollectionForWriting { <nl> + struct Locks { <nl> + Locks ( string ns ) ; <nl> + SimpleRWLock : : Shared excluder ; <nl> + GlobalSharedLock gslk ; <nl> + rwlock clk ; <nl> } ; <nl> - private : <nl> - void hlock ( ) ; <nl> - void hunlock ( ) ; <nl> - void hlockShared ( int n ) ; <nl> - void hunlockShared ( int n ) ; <nl> - HLock * const parent ; <nl> - RWLock r ; <nl> - const int level ; / / 1 = global , 2 = db , 3 = collection <nl> + scoped_ptr < Locks > locks ; <nl> + public : <nl> + LockCollectionForWriting ( string db ) ; <nl> + ~ LockCollectionForWriting ( ) ; <nl> } ; <nl> <nl> / / CLC turns on the " collection level concurrency " code which is under development <nl> mmm a / db / database . cpp <nl> ppp b / db / database . cpp <nl> namespace mongo { <nl> } <nl> } <nl> <nl> - HLock theGlobalLock ( 1 , 0 ) ; <nl> - <nl> Database : : Database ( const char * nm , bool & newDb , const string & _path ) <nl> : name ( nm ) , path ( _path ) , namespaceIndex ( path , name ) , <nl> - profileName ( name + " . system . profile " ) , <nl> - h ( 2 , & theGlobalLock ) <nl> + profileName ( name + " . system . profile " ) <nl> { <nl> try { <nl> { <nl> mmm a / db / database . h <nl> ppp b / db / database . h <nl> namespace mongo { <nl> int profile ; / / 0 = off . <nl> const string profileName ; / / " alleyinsider . system . profile " <nl> CCByLoc ccByLoc ; <nl> - HLock h ; <nl> int magic ; / / used for making sure the object is still loaded in memory <nl> } ; <nl> <nl> mmm a / db / db . vcxproj <nl> ppp b / db / db . vcxproj <nl> <nl> < ClCompile Include = " dur_preplogbuffer . cpp " / > <nl> < ClCompile Include = " dur_recover . cpp " / > <nl> < ClCompile Include = " dur_writetodatafiles . cpp " / > <nl> + < ClCompile Include = " d_concurrency . cpp " / > <nl> < ClCompile Include = " geo \ 2d . cpp " / > <nl> < ClCompile Include = " geo \ haystack . cpp " / > <nl> < ClCompile Include = " key . cpp " / > <nl> mmm a / db / db . vcxproj . filters <nl> ppp b / db / db . vcxproj . filters <nl> <nl> < ClCompile Include = " . . \ util \ intrusive_counter . cpp " / > <nl> < ClCompile Include = " . . \ util \ systeminfo_win32 . cpp " / > <nl> < ClCompile Include = " commands \ document_source_cursor . cpp " / > <nl> + < ClCompile Include = " d_concurrency . cpp " / > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < ClInclude Include = " . . \ client \ dbclientcursor . h " / > <nl> mmm a / db / mongomutex . h <nl> ppp b / db / mongomutex . h <nl> namespace mongo { <nl> void unlock_shared ( ) { <nl> int s = _state . get ( ) ; <nl> if ( s > 0 ) { <nl> - assert ( s > 1 ) ; / * we must have done a lock write first to have s > 1 * / <nl> + wassert ( s > 1 ) ; / * we must have done a lock write first to have s > 1 * / <nl> _state . set ( s - 1 ) ; <nl> return ; <nl> } <nl> namespace mongo { <nl> _state . set ( s + 1 ) ; <nl> return ; <nl> } <nl> - assert ( s = = - 1 ) ; <nl> + wassert ( s = = - 1 ) ; <nl> _state . set ( 0 ) ; <nl> _m . unlock_shared ( ) ; <nl> } <nl> namespace mongo { <nl> ) ; <nl> } <nl> } ; <nl> + / / eventually rename fully <nl> + typedef readlock GlobalSharedLock ; <nl> <nl> struct readlocktry { <nl> readlocktry ( const string & ns , int tryms ) { <nl> mmm a / db / namespace . cpp <nl> ppp b / db / namespace . cpp <nl> namespace mongo { <nl> / / that is NOT handled here yet ! TODO <nl> / / repair may not use nsdt though not sure . anyway , requires work . <nl> NamespaceDetailsTransient : : NamespaceDetailsTransient ( Database * db , const char * ns ) : <nl> - database ( db ) , <nl> - h ( 3 , & db - > h ) , _ns ( ns ) , _keysComputed ( false ) , _qcWriteCount ( ) <nl> + _ns ( ns ) , _keysComputed ( false ) , _qcWriteCount ( ) <nl> { <nl> dassert ( db ) ; <nl> } <nl> <nl> NamespaceDetailsTransient : : ~ NamespaceDetailsTransient ( ) { <nl> - DEV wassert ( database - > isOk ( ) ) ; <nl> } <nl> <nl> void NamespaceDetailsTransient : : clearForPrefix ( const char * prefix ) { <nl> mmm a / db / namespace . h <nl> ppp b / db / namespace . h <nl> namespace mongo { <nl> <nl> todo : cleanup code , need abstractions and separation <nl> * / <nl> + / / todo : multiple db ' s with the same name ( repairDatbase ) is not handled herein . that may be <nl> + / / the way to go , if not used by repair , but need some sort of enforcement / asserts . <nl> class NamespaceDetailsTransient : boost : : noncopyable { <nl> BOOST_STATIC_ASSERT ( sizeof ( NamespaceDetails ) = = 496 ) ; <nl> <nl> - Database * database ; <nl> - HLock h ; <nl> + / / Database * database ; <nl> const string _ns ; <nl> void reset ( ) ; <nl> static std : : map < string , shared_ptr < NamespaceDetailsTransient > > _nsdMap ; <nl> mmm a / dbtests / threadedtests . cpp <nl> ppp b / dbtests / threadedtests . cpp <nl> <nl> # include " . . / util / timer . h " <nl> # include < boost / thread . hpp > <nl> # include < boost / bind . hpp > <nl> + # include " . . / db / d_concurrency . h " <nl> <nl> # include " dbtests . h " <nl> <nl> namespace ThreadedTests { <nl> } <nl> } ; <nl> <nl> + class Hierarchical1 { <nl> + public : <nl> + void run ( ) { <nl> + { <nl> + LockCollectionForReading x ( " bar " ) ; <nl> + } <nl> + { <nl> + LockCollectionForReading x ( " foo " ) ; <nl> + LockCollectionForReading y ( " foo " ) ; / / recursion is ok <nl> + } <nl> + { <nl> + LockCollectionForReading x ( " foo " ) ; <nl> + LockCollectionForReading y ( " foo . $ bar " ) ; <nl> + } <nl> + { <nl> + LockCollectionForWriting x ( " foo " ) ; <nl> + LockCollectionForWriting y ( " foo " ) ; <nl> + } <nl> + { <nl> + LockCollectionForReading x ( " foo " ) ; <nl> + ASSERT_THROWS ( LockCollectionForWriting y ( " foo " ) , DBException ) <nl> + } <nl> + { <nl> + LockCollectionForReading x ( " foo " ) ; <nl> + ASSERT_THROWS ( LockCollectionForReading y ( " bar " ) , DBException ) <nl> + } <nl> + <nl> + cout < < " temp ok " < < endl ; <nl> + } <nl> + } ; <nl> + <nl> # if 1 <nl> class UpgradableTest : public ThreadedTest < 7 > { <nl> RWLock m ; <nl> namespace ThreadedTests { <nl> All ( ) : Suite ( " threading " ) { } <nl> <nl> void setupTests ( ) { <nl> + add < Hierarchical1 > ( ) ; <nl> + <nl> add < WriteLocksAreGreedy > ( ) ; <nl> add < UpgradableTest > ( ) ; <nl> add < List1Test > ( ) ; <nl> namespace ThreadedTests { <nl> add < ThreadPoolTest > ( ) ; <nl> add < LockTest > ( ) ; <nl> <nl> + <nl> add < RWLockTest1 > ( ) ; <nl> / / add < RWLockTest2 > ( ) ; / / SERVER - 2996 <nl> add < RWLockTest3 > ( ) ; <nl> mmm a / s / client . h <nl> ppp b / s / client . h <nl> <nl> - / / client . h <nl> + / / @ file s / client . h <nl> <nl> / * <nl> * Copyright ( C ) 2010 10gen Inc . <nl> <nl> * You should have received a copy of the GNU Affero General Public License <nl> * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> * / <nl> - <nl> # pragma once <nl> <nl> # include " . . / pch . h " <nl> mmm a / s / s_only . cpp <nl> ppp b / s / s_only . cpp <nl> namespace mongo { <nl> <nl> TSP_DEFINE ( Client , currentClient ) <nl> <nl> + Client : : LockStatus : : LockStatus ( ) { <nl> + dassert ( false ) ; <nl> + } <nl> + <nl> Client : : Client ( const char * desc , AbstractMessagingPort * p ) : <nl> _context ( 0 ) , <nl> _shutdown ( false ) , <nl> mmm a / util / concurrency / mutexdebugger . h <nl> ppp b / util / concurrency / mutexdebugger . h <nl> namespace mongo { <nl> } <nl> <nl> void entering ( mid m ) { <nl> - if ( this = = 0 ) return ; <nl> + if ( this = = 0 | | m = = 0 ) return ; <nl> assert ( magic = = 0x12345678 ) ; <nl> <nl> Preceeding * _preceeding = us . get ( ) ; <nl> namespace mongo { <nl> } <nl> } <nl> void leaving ( mid m ) { <nl> - if ( this = = 0 ) return ; / / still in startup pre - main ( ) <nl> + if ( this = = 0 | | m = = 0 ) return ; / / still in startup pre - main ( ) <nl> Preceeding & preceeding = * us . get ( ) ; <nl> preceeding [ m ] - - ; <nl> if ( preceeding [ m ] < 0 ) { <nl> mmm a / util / concurrency / rwlock . h <nl> ppp b / util / concurrency / rwlock . h <nl> namespace mongo { <nl> void unlock ( ) { RWLockBase : : unlock ( ) ; } <nl> void lock_shared ( ) { RWLockBase : : lock_shared ( ) ; } <nl> void unlock_shared ( ) { RWLockBase : : unlock_shared ( ) ; } <nl> + class Shared : boost : : noncopyable { <nl> + SimpleRWLock & _r ; <nl> + public : <nl> + Shared ( SimpleRWLock & rwlock ) : _r ( rwlock ) { _r . lock_shared ( ) ; } <nl> + ~ Shared ( ) { _r . unlock_shared ( ) ; } <nl> + } ; <nl> + class Exclusive : boost : : noncopyable { <nl> + SimpleRWLock & _r ; <nl> + public : <nl> + Exclusive ( SimpleRWLock & rwlock ) : _r ( rwlock ) { _r . lock ( ) ; } <nl> + ~ Exclusive ( ) { _r . unlock ( ) ; } <nl> + } ; <nl> } ; <nl> <nl> class RWLock : public RWLockBase { <nl> namespace mongo { <nl> _r . unlockFromUpgradable ( ) ; <nl> } <nl> else { <nl> - / / TEMP assert ( _r . x = = Exclusive ) ; / / has been upgraded <nl> + / / TEMP assert ( _r . x = = Exclusive ) ; / / has been upgraded <nl> _r . x = NilState ; <nl> _r . unlock ( ) ; <nl> } <nl> mmm a / util / concurrency / value . h <nl> ppp b / util / concurrency / value . h <nl> namespace mongo { <nl> struct ref { <nl> SimpleMutex : : scoped_lock lk ; <nl> public : <nl> - map < K , V > const & r ; <nl> + map < K , V > & r ; <nl> ref ( mapsf < K , V > & m ) : lk ( m . m ) , r ( m . val ) { } <nl> V & operator [ ] ( const K & k ) { return r [ k ] ; } <nl> } ; <nl>
|
clc
|
mongodb/mongo
|
5f7c8109db658fd786726b0868dbdf2a0c45ddd2
|
2011-12-11T16:01:23Z
|
mmm a / tools / turbolizer / src / graphmultiview . ts <nl> ppp b / tools / turbolizer / src / graphmultiview . ts <nl> export class GraphMultiView extends View { <nl> view . selectMenu . innerHTML = ' ' ; <nl> view . sourceResolver . forEachPhase ( ( phase ) = > { <nl> const optionElement = document . createElement ( " option " ) ; <nl> - optionElement . text = phase . name ; <nl> + const maxNodeId = phase . highestNodeId = = 0 ? " " : ` $ { phase . highestNodeId } ` ; <nl> + optionElement . text = ` $ { phase . name } $ { maxNodeId } ` ; <nl> view . selectMenu . add ( optionElement ) ; <nl> } ) ; <nl> this . selectMenu . onchange = function ( this : HTMLSelectElement ) { <nl> mmm a / tools / turbolizer / src / source - resolver . ts <nl> ppp b / tools / turbolizer / src / source - resolver . ts <nl> export class SourceResolver { <nl> recordOrigins ( phase ) { <nl> if ( phase . type ! = " graph " ) return ; <nl> for ( const node of phase . data . nodes ) { <nl> + phase . highestNodeId = Math . max ( phase . highestNodeId , node . id ) <nl> if ( node . origin ! = undefined & & <nl> node . origin . bytecodePosition ! = undefined ) { <nl> const position = { bytecodePosition : node . origin . bytecodePosition } ; <nl> export class SourceResolver { <nl> <nl> parsePhases ( phases ) { <nl> for ( const [ phaseId , phase ] of Object . entries < Phase > ( phases ) ) { <nl> + phase . highestNodeId = 0 ; <nl> if ( phase . type = = ' disassembly ' ) { <nl> this . disassemblyPhase = phase ; <nl> } else if ( phase . type = = ' schedule ' ) { <nl>
|
[ turbolizer ] Display highest node id in phase selection drop - down
|
v8/v8
|
949dffc9edc8c24794e1c88fecde4fa00c071ff9
|
2018-10-31T10:59:14Z
|
mmm a / addons / skin . estouchy / xml / Includes . xml <nl> ppp b / addons / skin . estouchy / xml / Includes . xml <nl> <nl> < posy > 0 < / posy > <nl> < include > ScreenWidth < / include > <nl> < height > 960 < / height > <nl> - < visible > ! Skin . HasSetting ( HideVideoBackground ) + Player . HasVideo + ! Window . IsVisible ( TVChannels ) + ! Window . IsVisible ( RadioChannels ) + ! Window . IsVisible ( TVGuide ) + ! Window . IsVisible ( RadioGuide ) + ! Window . IsVisible ( TVSearch ) + ! Window . IsVisible ( RadioSearch ) + ! Window . IsVisible ( TVTimers ) + ! Window . IsVisible ( RadioTimers ) + ! Window . IsVisible ( TVTimerRules ) + ! Window . IsVisible ( RadioTimerRules ) + ! Window . IsVisible ( TVRecordings ) + ! Window . IsVisible ( RadioRecordings ) < / visible > <nl> + < visible > ! Skin . HasSetting ( HideVideoBackground ) + Player . HasVideo + ! Window . IsVisible ( TVChannels ) + ! Window . IsVisible ( RadioChannels ) + ! Window . IsVisible ( TVGuide ) + ! Window . IsVisible ( RadioGuide ) + ! Window . IsVisible ( TVSearch ) + ! Window . IsVisible ( RadioSearch ) + ! Window . IsVisible ( TVTimers ) + ! Window . IsVisible ( RadioTimers ) + ! Window . IsVisible ( TVTimerRules ) + ! Window . IsVisible ( RadioTimerRules ) + ! Window . IsVisible ( TVRecordings ) + ! Window . IsVisible ( RadioRecordings ) + ! SlideShow . IsActive < / visible > <nl> < / control > <nl> < control type = " visualisation " > <nl> < posx > 0 < / posx > <nl> < posy > 0 < / posy > <nl> < include > ScreenWidth < / include > <nl> < height > 960 < / height > <nl> - < visible > ! Skin . HasSetting ( HideVizBackground ) + Player . HasAudio < / visible > <nl> + < visible > ! Skin . HasSetting ( HideVizBackground ) + Player . HasAudio + ! SlideShow . IsActive < / visible > <nl> < / control > <nl> < control type = " image " > <nl> < posx > 0 < / posx > <nl> mmm a / addons / skin . estuary / 1080i / Includes . xml <nl> ppp b / addons / skin . estuary / 1080i / Includes . xml <nl> <nl> < control type = " videowindow " > <nl> < depth > DepthBackground < / depth > <nl> < include > FullScreenDimensions < / include > <nl> - < visible > Player . HasVideo < / visible > <nl> + < visible > Player . HasVideo + ! Slideshow . IsActive < / visible > <nl> < / control > <nl> < control type = " visualisation " > <nl> < include > FullScreenDimensions < / include > <nl> - < visible > Player . HasAudio + String . IsEmpty ( Window ( Videos ) . Property ( PlayingBackgroundMedia ) ) < / visible > <nl> + < visible > Player . HasAudio + String . IsEmpty ( Window ( Videos ) . Property ( PlayingBackgroundMedia ) ) + ! Slideshow . IsActive < / visible > <nl> < / control > <nl> < control type = " group " > <nl> < animation effect = " zoom " center = " 960 , 540 " end = " 102 , 102 " time = " 0 " condition = " Integer . IsGreater ( System . StereoscopicMode , 0 ) " > conditional < / animation > <nl> mmm a / xbmc / Application . cpp <nl> ppp b / xbmc / Application . cpp <nl> void CApplication : : SeekPercentage ( float percent ) <nl> / / SwitchToFullScreen ( ) returns true if a switch is made , else returns false <nl> bool CApplication : : SwitchToFullScreen ( bool force / * = false * / ) <nl> { <nl> + / / don ' t switch if the slideshow is active <nl> + if ( g_windowManager . GetFocusedWindow ( ) = = WINDOW_SLIDESHOW ) <nl> + return false ; <nl> + <nl> / / if playing from the video info window , close it first ! <nl> if ( g_windowManager . HasModalDialog ( ) & & g_windowManager . GetTopMostModalDialogID ( ) = = WINDOW_DIALOG_VIDEO_INFO ) <nl> { <nl> bool CApplication : : SwitchToFullScreen ( bool force / * = false * / ) <nl> if ( pDialog ) pDialog - > Close ( true ) ; <nl> } <nl> <nl> - / / don ' t switch if the slideshow is active <nl> - if ( g_windowManager . GetActiveWindow ( ) = = WINDOW_SLIDESHOW ) <nl> - return false ; <nl> - <nl> int windowID = WINDOW_INVALID ; <nl> / / See if we ' re playing a video , and are in GUI mode <nl> if ( m_pPlayer - > IsPlayingVideo ( ) & & g_windowManager . GetActiveWindow ( ) ! = WINDOW_FULLSCREEN_VIDEO ) <nl> mmm a / xbmc / pictures / GUIWindowSlideShow . cpp <nl> ppp b / xbmc / pictures / GUIWindowSlideShow . cpp <nl> void CGUIWindowSlideShow : : ShowPrevious ( ) <nl> m_bLoadNextPic = true ; <nl> } <nl> <nl> - <nl> void CGUIWindowSlideShow : : Select ( const std : : string & strPicture ) <nl> { <nl> - for ( int i = 0 ; i < m_slides . size ( ) ; + + i ) <nl> + for ( size_t i = 0 ; i < m_slides . size ( ) ; + + i ) <nl> { <nl> const CFileItemPtr item = m_slides . at ( i ) ; <nl> if ( item - > GetPath ( ) = = strPicture ) <nl> void CGUIWindowSlideShow : : Process ( unsigned int currentTime , CDirtyRegionList & re <nl> } <nl> else if ( m_Image [ 1 - m_iCurrentPic ] . IsLoaded ( ) ) <nl> { <nl> + g_application . m_pPlayer - > CloseFile ( ) ; <nl> + m_bPlayingVideo = false ; <nl> + <nl> / / first time render the next image , make sure using current display effect . <nl> if ( ! m_Image [ 1 - m_iCurrentPic ] . IsStarted ( ) ) <nl> { <nl> void CGUIWindowSlideShow : : Render ( ) <nl> { <nl> g_graphicsContext . Clear ( 0xff000000 ) ; <nl> <nl> - if ( m_Image [ m_iCurrentPic ] . IsLoaded ( ) ) <nl> - m_Image [ m_iCurrentPic ] . Render ( ) ; <nl> + if ( m_slides . at ( m_iCurrentSlide ) - > IsVideo ( ) ) <nl> + { <nl> + g_graphicsContext . SetViewWindow ( 0 , 0 , m_coordsRes . iWidth , m_coordsRes . iHeight ) ; <nl> + g_graphicsContext . SetRenderingResolution ( g_graphicsContext . GetVideoResolution ( ) , false ) ; <nl> + g_application . m_pPlayer - > Render ( true , 255 ) ; <nl> + g_graphicsContext . SetRenderingResolution ( m_coordsRes , m_needsScaling ) ; <nl> + } <nl> + else <nl> + { <nl> + if ( m_Image [ m_iCurrentPic ] . IsLoaded ( ) ) <nl> + m_Image [ m_iCurrentPic ] . Render ( ) ; <nl> <nl> - if ( m_Image [ m_iCurrentPic ] . DrawNextImage ( ) & & m_Image [ 1 - m_iCurrentPic ] . IsLoaded ( ) ) <nl> - m_Image [ 1 - m_iCurrentPic ] . Render ( ) ; <nl> + if ( m_Image [ m_iCurrentPic ] . DrawNextImage ( ) & & m_Image [ 1 - m_iCurrentPic ] . IsLoaded ( ) ) <nl> + m_Image [ 1 - m_iCurrentPic ] . Render ( ) ; <nl> + } <nl> <nl> RenderErrorMessage ( ) ; <nl> CGUIWindow : : Render ( ) ; <nl> bool CGUIWindowSlideShow : : OnAction ( const CAction & action ) <nl> case ACTION_STOP : <nl> if ( m_slides . size ( ) ) <nl> AnnouncePlayerStop ( m_slides . at ( m_iCurrentSlide ) ) ; <nl> + g_application . m_pPlayer - > CloseFile ( ) ; <nl> Close ( ) ; <nl> break ; <nl> <nl> bool CGUIWindowSlideShow : : OnMessage ( CGUIMessage & message ) <nl> } <nl> break ; <nl> <nl> - case GUI_MSG_PLAYBACK_STARTED : <nl> - { <nl> - if ( m_bPlayingVideo ) <nl> - g_windowManager . ActivateWindow ( WINDOW_FULLSCREEN_VIDEO ) ; <nl> - } <nl> - break ; <nl> - <nl> case GUI_MSG_PLAYBACK_STOPPED : <nl> { <nl> if ( m_bPlayingVideo ) <nl>
|
Merge pull request from FernetMenta / slide
|
xbmc/xbmc
|
4778b5f36742f64da6858093aeb50ab26821c5d5
|
2016-10-18T06:54:56Z
|
mmm a / tensorflow / tools / api / golden / v1 / tensorflow . math . pbtxt <nl> ppp b / tensorflow / tools / api / golden / v1 / tensorflow . math . pbtxt <nl> tf_module { <nl> name : " reciprocal " <nl> argspec : " args = [ \ ' x \ ' , \ ' name \ ' ] , varargs = None , keywords = None , defaults = [ \ ' None \ ' ] , " <nl> } <nl> + member_method { <nl> + name : " reciprocal_no_nan " <nl> + argspec : " args = [ \ ' x \ ' , \ ' name \ ' ] , varargs = None , keywords = None , defaults = [ \ ' None \ ' ] , " <nl> + } <nl> member_method { <nl> name : " reduce_all " <nl> argspec : " args = [ \ ' input_tensor \ ' , \ ' axis \ ' , \ ' keepdims \ ' , \ ' name \ ' , \ ' reduction_indices \ ' , \ ' keep_dims \ ' ] , varargs = None , keywords = None , defaults = [ \ ' None \ ' , \ ' None \ ' , \ ' None \ ' , \ ' None \ ' , \ ' None \ ' ] , " <nl> mmm a / tensorflow / tools / api / golden / v1 / tensorflow . pbtxt <nl> ppp b / tensorflow / tools / api / golden / v1 / tensorflow . pbtxt <nl> tf_module { <nl> name : " reciprocal " <nl> argspec : " args = [ \ ' x \ ' , \ ' name \ ' ] , varargs = None , keywords = None , defaults = [ \ ' None \ ' ] , " <nl> } <nl> + member_method { <nl> + name : " reciprocal_no_nan " <nl> + argspec : " args = [ \ ' x \ ' , \ ' name \ ' ] , varargs = None , keywords = None , defaults = [ \ ' None \ ' ] , " <nl> + } <nl> member_method { <nl> name : " recompute_grad " <nl> argspec : " args = [ \ ' f \ ' ] , varargs = None , keywords = None , defaults = None " <nl> mmm a / tensorflow / tools / api / golden / v2 / tensorflow . math . pbtxt <nl> ppp b / tensorflow / tools / api / golden / v2 / tensorflow . math . pbtxt <nl> tf_module { <nl> name : " reciprocal " <nl> argspec : " args = [ \ ' x \ ' , \ ' name \ ' ] , varargs = None , keywords = None , defaults = [ \ ' None \ ' ] , " <nl> } <nl> + member_method { <nl> + name : " reciprocal_no_nan " <nl> + argspec : " args = [ \ ' x \ ' , \ ' name \ ' ] , varargs = None , keywords = None , defaults = [ \ ' None \ ' ] , " <nl> + } <nl> member_method { <nl> name : " reduce_all " <nl> argspec : " args = [ \ ' input_tensor \ ' , \ ' axis \ ' , \ ' keepdims \ ' , \ ' name \ ' ] , varargs = None , keywords = None , defaults = [ \ ' None \ ' , \ ' False \ ' , \ ' None \ ' ] , " <nl> mmm a / tensorflow / tools / api / golden / v2 / tensorflow . pbtxt <nl> ppp b / tensorflow / tools / api / golden / v2 / tensorflow . pbtxt <nl> tf_module { <nl> name : " realdiv " <nl> argspec : " args = [ \ ' x \ ' , \ ' y \ ' , \ ' name \ ' ] , varargs = None , keywords = None , defaults = [ \ ' None \ ' ] , " <nl> } <nl> + member_method { <nl> + name : " reciprocal_no_nan " <nl> + argspec : " args = [ \ ' x \ ' , \ ' name \ ' ] , varargs = None , keywords = None , defaults = [ \ ' None \ ' ] , " <nl> + } <nl> member_method { <nl> name : " recompute_grad " <nl> argspec : " args = [ \ ' f \ ' ] , varargs = None , keywords = None , defaults = None " <nl>
|
Regen API golden for reciprocal_no_nan ( ) .
|
tensorflow/tensorflow
|
d816bfcd707751f59672be2045471f4e662f849f
|
2019-07-22T20:49:08Z
|
mmm a / xbmc / guiinfo / GUIInfoLabels . h <nl> ppp b / xbmc / guiinfo / GUIInfoLabels . h <nl> <nl> # define PVR_HAS_TV_CHANNELS ( PVR_CONDITIONS_START + 10 ) <nl> # define PVR_HAS_RADIO_CHANNELS ( PVR_CONDITIONS_START + 11 ) <nl> # define PVR_IS_TIMESHIFTING ( PVR_CONDITIONS_START + 12 ) <nl> - # define PVR_CONDITIONS_END PVR_HAS_RADIO_CHANNELS <nl> + # define PVR_CONDITIONS_END PVR_IS_TIMESHIFTING <nl> <nl> # define PVR_STRINGS_START 1200 <nl> # define PVR_NEXT_RECORDING_CHANNEL ( PVR_STRINGS_START ) <nl>
|
Merge pull request from ksooo / fix - guiinfo - pvr - is - timeshifting
|
xbmc/xbmc
|
0bb06907f51e4279753c9407767a86e68ee8da2b
|
2015-07-23T20:33:17Z
|
mmm a / samples / web / filaweb . cpp <nl> ppp b / samples / web / filaweb . cpp <nl> void Application : : render ( ) { <nl> Asset getRawFile ( const char * name ) { <nl> / / Obtain size and URL from JavaScript . <nl> Asset result = { } ; <nl> - uint32_t nbytes ; <nl> EM_ASM ( { <nl> var nbytes = $ 0 > > 2 ; <nl> var name = UTF8ToString ( $ 1 ) ; <nl> HEAP32 [ nbytes ] = assets [ name ] . data . byteLength ; <nl> stringToUTF8 ( assets [ name ] . url , $ 2 , $ 3 ) ; <nl> - <nl> - } , & nbytes , name , & result . url [ 0 ] , sizeof ( result . url ) ) ; <nl> + } , & result . nbytes , name , & result . url [ 0 ] , sizeof ( result . url ) ) ; <nl> <nl> / / Move the data from JavaScript . <nl> - uint8_t * data = new uint8_t [ nbytes ] ; <nl> + uint8_t * data = new uint8_t [ result . nbytes ] ; <nl> EM_ASM ( { <nl> var data = $ 0 ; <nl> var name = UTF8ToString ( $ 1 ) ; <nl> Asset getRawFile ( const char * name ) { <nl> assets [ name ] . data = null ; <nl> } , data , name ) ; <nl> result . data = decltype ( Asset : : data ) ( data ) ; <nl> - result . nbytes = nbytes ; <nl> return result ; <nl> } <nl> <nl>
|
Minor filaweb cleanup .
|
google/filament
|
44b4cee4b183767c8870154ad12492118d817c0d
|
2018-09-20T00:18:44Z
|
mmm a / test / 1_stdlib / CollectionCasts . swift . gyb <nl> ppp b / test / 1_stdlib / CollectionCasts . swift . gyb <nl> <nl> - / / = = = mmm CollectionCasts . swift . gyb mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / = = = mmm CollectionCasts . swift . gyb mmmmmmmmmmmmmmmmmmmmmmmmmmm - * - swift - * - = = = / / <nl> / / <nl> / / This source file is part of the Swift . org open source project <nl> / / <nl> mmm a / test / Prototypes / Algorithms . swift . gyb <nl> ppp b / test / Prototypes / Algorithms . swift . gyb <nl> <nl> - / / = = = mmm Algorithms . swift . gyb mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm = = = / / <nl> + / / = = = mmm Algorithms . swift . gyb mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * - swift - * - = = = / / <nl> / / <nl> / / This source file is part of the Swift . org open source project <nl> / / <nl>
|
Fix recently introduced headers .
|
apple/swift
|
7088046c4a3499ff65a3b8dc1c645f84fda28b78
|
2016-08-06T10:38:45Z
|
mmm a / src / core / settings . h <nl> ppp b / src / core / settings . h <nl> struct Values { <nl> bool use_asynchronous_gpu_emulation ; <nl> bool use_vsync ; <nl> bool force_30fps_mode ; <nl> + bool use_fast_gpu_time ; <nl> <nl> float bg_red ; <nl> float bg_green ; <nl> mmm a / src / video_core / dma_pusher . cpp <nl> ppp b / src / video_core / dma_pusher . cpp <nl> bool DmaPusher : : Step ( ) { <nl> gpu . MemoryManager ( ) . ReadBlockUnsafe ( dma_get , command_headers . data ( ) , <nl> command_list_header . size * sizeof ( u32 ) ) ; <nl> <nl> - for ( const CommandHeader & command_header : command_headers ) { <nl> - <nl> - / / now , see if we ' re in the middle of a command <nl> - if ( dma_state . length_pending ) { <nl> - / / Second word of long non - inc methods command - method count <nl> - dma_state . length_pending = 0 ; <nl> - dma_state . method_count = command_header . method_count_ ; <nl> - } else if ( dma_state . method_count ) { <nl> + for ( std : : size_t index = 0 ; index < command_headers . size ( ) ; ) { <nl> + const CommandHeader & command_header = command_headers [ index ] ; <nl> + <nl> + if ( dma_state . method_count ) { <nl> / / Data word of methods command <nl> - CallMethod ( command_header . argument ) ; <nl> + if ( dma_state . non_incrementing ) { <nl> + const u32 max_write = static_cast < u32 > ( <nl> + std : : min < std : : size_t > ( index + dma_state . method_count , command_headers . size ( ) ) - <nl> + index ) ; <nl> + CallMultiMethod ( & command_header . argument , max_write ) ; <nl> + dma_state . method_count - = max_write ; <nl> + index + = max_write ; <nl> + continue ; <nl> + } else { <nl> + CallMethod ( command_header . argument ) ; <nl> + } <nl> <nl> if ( ! dma_state . non_incrementing ) { <nl> dma_state . method + + ; <nl> bool DmaPusher : : Step ( ) { <nl> break ; <nl> } <nl> } <nl> + index + + ; <nl> } <nl> <nl> if ( ! non_main ) { <nl> void DmaPusher : : CallMethod ( u32 argument ) const { <nl> gpu . CallMethod ( { dma_state . method , argument , dma_state . subchannel , dma_state . method_count } ) ; <nl> } <nl> <nl> + void DmaPusher : : CallMultiMethod ( const u32 * base_start , u32 num_methods ) const { <nl> + gpu . CallMultiMethod ( dma_state . method , dma_state . subchannel , base_start , num_methods , <nl> + dma_state . method_count ) ; <nl> + } <nl> + <nl> } / / namespace Tegra <nl> mmm a / src / video_core / dma_pusher . h <nl> ppp b / src / video_core / dma_pusher . h <nl> class DmaPusher { <nl> void SetState ( const CommandHeader & command_header ) ; <nl> <nl> void CallMethod ( u32 argument ) const ; <nl> + void CallMultiMethod ( const u32 * base_start , u32 num_methods ) const ; <nl> <nl> std : : vector < CommandHeader > command_headers ; / / / < Buffer for list of commands fetched at once <nl> <nl> mmm a / src / video_core / engines / fermi_2d . cpp <nl> ppp b / src / video_core / engines / fermi_2d . cpp <nl> void Fermi2D : : CallMethod ( const GPU : : MethodCall & method_call ) { <nl> } <nl> } <nl> <nl> + void Fermi2D : : CallMultiMethod ( u32 method , const u32 * base_start , u32 amount , u32 methods_pending ) { <nl> + for ( std : : size_t i = 0 ; i < amount ; i + + ) { <nl> + CallMethod ( { method , base_start [ i ] , 0 , methods_pending - static_cast < u32 > ( i ) } ) ; <nl> + } <nl> + } <nl> + <nl> static std : : pair < u32 , u32 > DelimitLine ( u32 src_1 , u32 src_2 , u32 dst_1 , u32 dst_2 , u32 src_line ) { <nl> const u32 line_a = src_2 - src_1 ; <nl> const u32 line_b = dst_2 - dst_1 ; <nl> mmm a / src / video_core / engines / fermi_2d . h <nl> ppp b / src / video_core / engines / fermi_2d . h <nl> class Fermi2D final { <nl> / / / Write the value to the register identified by method . <nl> void CallMethod ( const GPU : : MethodCall & method_call ) ; <nl> <nl> + / / / Write multiple values to the register identified by method . <nl> + void CallMultiMethod ( u32 method , const u32 * base_start , u32 amount , u32 methods_pending ) ; <nl> + <nl> enum class Origin : u32 { <nl> Center = 0 , <nl> Corner = 1 , <nl> mmm a / src / video_core / engines / kepler_compute . cpp <nl> ppp b / src / video_core / engines / kepler_compute . cpp <nl> void KeplerCompute : : CallMethod ( const GPU : : MethodCall & method_call ) { <nl> } <nl> } <nl> <nl> + void KeplerCompute : : CallMultiMethod ( u32 method , const u32 * base_start , u32 amount , <nl> + u32 methods_pending ) { <nl> + for ( std : : size_t i = 0 ; i < amount ; i + + ) { <nl> + CallMethod ( { method , base_start [ i ] , 0 , methods_pending - static_cast < u32 > ( i ) } ) ; <nl> + } <nl> + } <nl> + <nl> Texture : : FullTextureInfo KeplerCompute : : GetTexture ( std : : size_t offset ) const { <nl> const std : : bitset < 8 > cbuf_mask = launch_description . const_buffer_enable_mask . Value ( ) ; <nl> ASSERT ( cbuf_mask [ regs . tex_cb_index ] ) ; <nl> mmm a / src / video_core / engines / kepler_compute . h <nl> ppp b / src / video_core / engines / kepler_compute . h <nl> class KeplerCompute final : public ConstBufferEngineInterface { <nl> / / / Write the value to the register identified by method . <nl> void CallMethod ( const GPU : : MethodCall & method_call ) ; <nl> <nl> + / / / Write multiple values to the register identified by method . <nl> + void CallMultiMethod ( u32 method , const u32 * base_start , u32 amount , u32 methods_pending ) ; <nl> + <nl> Texture : : FullTextureInfo GetTexture ( std : : size_t offset ) const ; <nl> <nl> / / / Given a texture handle , returns the TSC and TIC entries . <nl> mmm a / src / video_core / engines / kepler_memory . cpp <nl> ppp b / src / video_core / engines / kepler_memory . cpp <nl> void KeplerMemory : : CallMethod ( const GPU : : MethodCall & method_call ) { <nl> } <nl> } <nl> <nl> + void KeplerMemory : : CallMultiMethod ( u32 method , const u32 * base_start , u32 amount , <nl> + u32 methods_pending ) { <nl> + for ( std : : size_t i = 0 ; i < amount ; i + + ) { <nl> + CallMethod ( { method , base_start [ i ] , 0 , methods_pending - static_cast < u32 > ( i ) } ) ; <nl> + } <nl> + } <nl> + <nl> } / / namespace Tegra : : Engines <nl> mmm a / src / video_core / engines / kepler_memory . h <nl> ppp b / src / video_core / engines / kepler_memory . h <nl> class KeplerMemory final { <nl> / / / Write the value to the register identified by method . <nl> void CallMethod ( const GPU : : MethodCall & method_call ) ; <nl> <nl> + / / / Write multiple values to the register identified by method . <nl> + void CallMultiMethod ( u32 method , const u32 * base_start , u32 amount , u32 methods_pending ) ; <nl> + <nl> struct Regs { <nl> static constexpr size_t NUM_REGS = 0x7F ; <nl> <nl> mmm a / src / video_core / engines / maxwell_3d . cpp <nl> ppp b / src / video_core / engines / maxwell_3d . cpp <nl> void Maxwell3D : : CallMethod ( const GPU : : MethodCall & method_call ) { <nl> } <nl> } <nl> <nl> + void Maxwell3D : : CallMultiMethod ( u32 method , const u32 * base_start , u32 amount , <nl> + u32 methods_pending ) { <nl> + / / Methods after 0xE00 are special , they ' re actually triggers for some microcode that was <nl> + / / uploaded to the GPU during initialization . <nl> + if ( method > = MacroRegistersStart ) { <nl> + / / We ' re trying to execute a macro <nl> + if ( executing_macro = = 0 ) { <nl> + / / A macro call must begin by writing the macro method ' s register , not its argument . <nl> + ASSERT_MSG ( ( method % 2 ) = = 0 , <nl> + " Can ' t start macro execution by writing to the ARGS register " ) ; <nl> + executing_macro = method ; <nl> + } <nl> + <nl> + for ( std : : size_t i = 0 ; i < amount ; i + + ) { <nl> + macro_params . push_back ( base_start [ i ] ) ; <nl> + } <nl> + <nl> + / / Call the macro when there are no more parameters in the command buffer <nl> + if ( amount = = methods_pending ) { <nl> + CallMacroMethod ( executing_macro , macro_params . size ( ) , macro_params . data ( ) ) ; <nl> + macro_params . clear ( ) ; <nl> + } <nl> + return ; <nl> + } <nl> + switch ( method ) { <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 0 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 1 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 2 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 3 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 4 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 5 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 6 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 7 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 8 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 9 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 10 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 11 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 12 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 13 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 14 ] ) : <nl> + case MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 15 ] ) : { <nl> + ProcessCBMultiData ( method , base_start , amount ) ; <nl> + break ; <nl> + } <nl> + default : { <nl> + for ( std : : size_t i = 0 ; i < amount ; i + + ) { <nl> + CallMethod ( { method , base_start [ i ] , 0 , methods_pending - static_cast < u32 > ( i ) } ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> void Maxwell3D : : StepInstance ( const MMEDrawMode expected_mode , const u32 count ) { <nl> if ( mme_draw . current_mode = = MMEDrawMode : : Undefined ) { <nl> if ( mme_draw . gl_begin_consume ) { <nl> void Maxwell3D : : StartCBData ( u32 method ) { <nl> ProcessCBData ( regs . const_buffer . cb_data [ cb_data_state . id ] ) ; <nl> } <nl> <nl> + void Maxwell3D : : ProcessCBMultiData ( u32 method , const u32 * start_base , u32 amount ) { <nl> + if ( cb_data_state . current ! = method ) { <nl> + if ( cb_data_state . current ! = null_cb_data ) { <nl> + FinishCBData ( ) ; <nl> + } <nl> + constexpr u32 first_cb_data = MAXWELL3D_REG_INDEX ( const_buffer . cb_data [ 0 ] ) ; <nl> + cb_data_state . start_pos = regs . const_buffer . cb_pos ; <nl> + cb_data_state . id = method - first_cb_data ; <nl> + cb_data_state . current = method ; <nl> + cb_data_state . counter = 0 ; <nl> + } <nl> + const std : : size_t id = cb_data_state . id ; <nl> + const std : : size_t size = amount ; <nl> + std : : size_t i = 0 ; <nl> + for ( ; i < size ; i + + ) { <nl> + cb_data_state . buffer [ id ] [ cb_data_state . counter ] = start_base [ i ] ; <nl> + cb_data_state . counter + + ; <nl> + } <nl> + / / Increment the current buffer position . <nl> + regs . const_buffer . cb_pos = regs . const_buffer . cb_pos + 4 * amount ; <nl> + } <nl> + <nl> void Maxwell3D : : FinishCBData ( ) { <nl> / / Write the input value to the current const buffer at the current position . <nl> const GPUVAddr buffer_address = regs . const_buffer . BufferAddress ( ) ; <nl> mmm a / src / video_core / engines / maxwell_3d . h <nl> ppp b / src / video_core / engines / maxwell_3d . h <nl> class Maxwell3D final : public ConstBufferEngineInterface { <nl> / / / Write the value to the register identified by method . <nl> void CallMethod ( const GPU : : MethodCall & method_call ) ; <nl> <nl> + / / / Write multiple values to the register identified by method . <nl> + void CallMultiMethod ( u32 method , const u32 * base_start , u32 amount , u32 methods_pending ) ; <nl> + <nl> / / / Write the value to the register identified by method . <nl> void CallMethodFromMME ( const GPU : : MethodCall & method_call ) ; <nl> <nl> class Maxwell3D final : public ConstBufferEngineInterface { <nl> / / / Handles a write to the CB_DATA [ i ] register . <nl> void StartCBData ( u32 method ) ; <nl> void ProcessCBData ( u32 value ) ; <nl> + void ProcessCBMultiData ( u32 method , const u32 * start_base , u32 amount ) ; <nl> void FinishCBData ( ) ; <nl> <nl> / / / Handles a write to the CB_BIND register . <nl> mmm a / src / video_core / engines / maxwell_dma . cpp <nl> ppp b / src / video_core / engines / maxwell_dma . cpp <nl> void MaxwellDMA : : CallMethod ( const GPU : : MethodCall & method_call ) { <nl> # undef MAXWELLDMA_REG_INDEX <nl> } <nl> <nl> + void MaxwellDMA : : CallMultiMethod ( u32 method , const u32 * base_start , u32 amount , <nl> + u32 methods_pending ) { <nl> + for ( std : : size_t i = 0 ; i < amount ; i + + ) { <nl> + CallMethod ( { method , base_start [ i ] , 0 , methods_pending - static_cast < u32 > ( i ) } ) ; <nl> + } <nl> + } <nl> + <nl> void MaxwellDMA : : HandleCopy ( ) { <nl> LOG_TRACE ( HW_GPU , " Requested a DMA copy " ) ; <nl> <nl> mmm a / src / video_core / engines / maxwell_dma . h <nl> ppp b / src / video_core / engines / maxwell_dma . h <nl> class MaxwellDMA final { <nl> / / / Write the value to the register identified by method . <nl> void CallMethod ( const GPU : : MethodCall & method_call ) ; <nl> <nl> + / / / Write multiple values to the register identified by method . <nl> + void CallMultiMethod ( u32 method , const u32 * base_start , u32 amount , u32 methods_pending ) ; <nl> + <nl> struct Regs { <nl> static constexpr std : : size_t NUM_REGS = 0x1D6 ; <nl> <nl> mmm a / src / video_core / gpu . cpp <nl> ppp b / src / video_core / gpu . cpp <nl> <nl> # include " core / core_timing_util . h " <nl> # include " core / frontend / emu_window . h " <nl> # include " core / memory . h " <nl> + # include " core / settings . h " <nl> # include " video_core / engines / fermi_2d . h " <nl> # include " video_core / engines / kepler_compute . h " <nl> # include " video_core / engines / kepler_memory . h " <nl> u64 GPU : : GetTicks ( ) const { <nl> constexpr u64 gpu_ticks_den = 625 ; <nl> <nl> const u64 cpu_ticks = system . CoreTiming ( ) . GetTicks ( ) ; <nl> - const u64 nanoseconds = Core : : Timing : : CyclesToNs ( cpu_ticks ) . count ( ) ; <nl> + u64 nanoseconds = Core : : Timing : : CyclesToNs ( cpu_ticks ) . count ( ) ; <nl> + if ( Settings : : values . use_fast_gpu_time ) { <nl> + nanoseconds / = 256 ; <nl> + } <nl> const u64 nanoseconds_num = nanoseconds / gpu_ticks_den ; <nl> const u64 nanoseconds_rem = nanoseconds % gpu_ticks_den ; <nl> return nanoseconds_num * gpu_ticks_num + ( nanoseconds_rem * gpu_ticks_num ) / gpu_ticks_den ; <nl> void GPU : : CallMethod ( const MethodCall & method_call ) { <nl> <nl> ASSERT ( method_call . subchannel < bound_engines . size ( ) ) ; <nl> <nl> - if ( ExecuteMethodOnEngine ( method_call ) ) { <nl> + if ( ExecuteMethodOnEngine ( method_call . method ) ) { <nl> CallEngineMethod ( method_call ) ; <nl> } else { <nl> CallPullerMethod ( method_call ) ; <nl> } <nl> } <nl> <nl> - bool GPU : : ExecuteMethodOnEngine ( const MethodCall & method_call ) { <nl> - const auto method = static_cast < BufferMethods > ( method_call . method ) ; <nl> - return method > = BufferMethods : : NonPullerMethods ; <nl> + void GPU : : CallMultiMethod ( u32 method , u32 subchannel , const u32 * base_start , u32 amount , <nl> + u32 methods_pending ) { <nl> + LOG_TRACE ( HW_GPU , " Processing method { : 08X } on subchannel { } " , method , subchannel ) ; <nl> + <nl> + ASSERT ( subchannel < bound_engines . size ( ) ) ; <nl> + <nl> + if ( ExecuteMethodOnEngine ( method ) ) { <nl> + CallEngineMultiMethod ( method , subchannel , base_start , amount , methods_pending ) ; <nl> + } else { <nl> + for ( std : : size_t i = 0 ; i < amount ; i + + ) { <nl> + CallPullerMethod ( <nl> + { method , base_start [ i ] , subchannel , methods_pending - static_cast < u32 > ( i ) } ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + bool GPU : : ExecuteMethodOnEngine ( u32 method ) { <nl> + const auto buffer_method = static_cast < BufferMethods > ( method ) ; <nl> + return buffer_method > = BufferMethods : : NonPullerMethods ; <nl> } <nl> <nl> void GPU : : CallPullerMethod ( const MethodCall & method_call ) { <nl> void GPU : : CallEngineMethod ( const MethodCall & method_call ) { <nl> } <nl> } <nl> <nl> + void GPU : : CallEngineMultiMethod ( u32 method , u32 subchannel , const u32 * base_start , u32 amount , <nl> + u32 methods_pending ) { <nl> + const EngineID engine = bound_engines [ subchannel ] ; <nl> + <nl> + switch ( engine ) { <nl> + case EngineID : : FERMI_TWOD_A : <nl> + fermi_2d - > CallMultiMethod ( method , base_start , amount , methods_pending ) ; <nl> + break ; <nl> + case EngineID : : MAXWELL_B : <nl> + maxwell_3d - > CallMultiMethod ( method , base_start , amount , methods_pending ) ; <nl> + break ; <nl> + case EngineID : : KEPLER_COMPUTE_B : <nl> + kepler_compute - > CallMultiMethod ( method , base_start , amount , methods_pending ) ; <nl> + break ; <nl> + case EngineID : : MAXWELL_DMA_COPY_A : <nl> + maxwell_dma - > CallMultiMethod ( method , base_start , amount , methods_pending ) ; <nl> + break ; <nl> + case EngineID : : KEPLER_INLINE_TO_MEMORY_B : <nl> + kepler_memory - > CallMultiMethod ( method , base_start , amount , methods_pending ) ; <nl> + break ; <nl> + default : <nl> + UNIMPLEMENTED_MSG ( " Unimplemented engine " ) ; <nl> + } <nl> + } <nl> + <nl> void GPU : : ProcessBindMethod ( const MethodCall & method_call ) { <nl> / / Bind the current subchannel to the desired engine id . <nl> LOG_DEBUG ( HW_GPU , " Binding subchannel { } to engine { } " , method_call . subchannel , <nl> mmm a / src / video_core / gpu . h <nl> ppp b / src / video_core / gpu . h <nl> class GPU { <nl> / / / Calls a GPU method . <nl> void CallMethod ( const MethodCall & method_call ) ; <nl> <nl> + / / / Calls a GPU multivalue method . <nl> + void CallMultiMethod ( u32 method , u32 subchannel , const u32 * base_start , u32 amount , <nl> + u32 methods_pending ) ; <nl> + <nl> / / / Flush all current written commands into the host GPU for execution . <nl> void FlushCommands ( ) ; <nl> / / / Synchronizes CPU writes with Host GPU memory . <nl> class GPU { <nl> / / / Calls a GPU engine method . <nl> void CallEngineMethod ( const MethodCall & method_call ) ; <nl> <nl> + / / / Calls a GPU engine multivalue method . <nl> + void CallEngineMultiMethod ( u32 method , u32 subchannel , const u32 * base_start , u32 amount , <nl> + u32 methods_pending ) ; <nl> + <nl> / / / Determines where the method should be executed . <nl> - bool ExecuteMethodOnEngine ( const MethodCall & method_call ) ; <nl> + bool ExecuteMethodOnEngine ( u32 method ) ; <nl> <nl> protected : <nl> std : : unique_ptr < Tegra : : DmaPusher > dma_pusher ; <nl> mmm a / src / yuzu / configuration / config . cpp <nl> ppp b / src / yuzu / configuration / config . cpp <nl> void Config : : ReadRendererValues ( ) { <nl> Settings : : values . use_asynchronous_gpu_emulation = <nl> ReadSetting ( QStringLiteral ( " use_asynchronous_gpu_emulation " ) , false ) . toBool ( ) ; <nl> Settings : : values . use_vsync = ReadSetting ( QStringLiteral ( " use_vsync " ) , true ) . toBool ( ) ; <nl> + Settings : : values . use_fast_gpu_time = <nl> + ReadSetting ( QStringLiteral ( " use_fast_gpu_time " ) , true ) . toBool ( ) ; <nl> Settings : : values . force_30fps_mode = <nl> ReadSetting ( QStringLiteral ( " force_30fps_mode " ) , false ) . toBool ( ) ; <nl> <nl> void Config : : SaveRendererValues ( ) { <nl> WriteSetting ( QStringLiteral ( " use_asynchronous_gpu_emulation " ) , <nl> Settings : : values . use_asynchronous_gpu_emulation , false ) ; <nl> WriteSetting ( QStringLiteral ( " use_vsync " ) , Settings : : values . use_vsync , true ) ; <nl> + WriteSetting ( QStringLiteral ( " use_fast_gpu_time " ) , Settings : : values . use_fast_gpu_time , true ) ; <nl> WriteSetting ( QStringLiteral ( " force_30fps_mode " ) , Settings : : values . force_30fps_mode , false ) ; <nl> <nl> / / Cast to double because Qt ' s written float values are not human - readable <nl> mmm a / src / yuzu / configuration / configure_graphics_advanced . cpp <nl> ppp b / src / yuzu / configuration / configure_graphics_advanced . cpp <nl> void ConfigureGraphicsAdvanced : : SetConfiguration ( ) { <nl> ui - > gpu_accuracy - > setCurrentIndex ( static_cast < int > ( Settings : : values . gpu_accuracy ) ) ; <nl> ui - > use_vsync - > setEnabled ( runtime_lock ) ; <nl> ui - > use_vsync - > setChecked ( Settings : : values . use_vsync ) ; <nl> + ui - > use_fast_gpu_time - > setChecked ( Settings : : values . use_fast_gpu_time ) ; <nl> ui - > force_30fps_mode - > setEnabled ( runtime_lock ) ; <nl> ui - > force_30fps_mode - > setChecked ( Settings : : values . force_30fps_mode ) ; <nl> ui - > anisotropic_filtering_combobox - > setEnabled ( runtime_lock ) ; <nl> void ConfigureGraphicsAdvanced : : ApplyConfiguration ( ) { <nl> auto gpu_accuracy = static_cast < Settings : : GPUAccuracy > ( ui - > gpu_accuracy - > currentIndex ( ) ) ; <nl> Settings : : values . gpu_accuracy = gpu_accuracy ; <nl> Settings : : values . use_vsync = ui - > use_vsync - > isChecked ( ) ; <nl> + Settings : : values . use_fast_gpu_time = ui - > use_fast_gpu_time - > isChecked ( ) ; <nl> Settings : : values . force_30fps_mode = ui - > force_30fps_mode - > isChecked ( ) ; <nl> Settings : : values . max_anisotropy = ui - > anisotropic_filtering_combobox - > currentIndex ( ) ; <nl> } <nl> mmm a / src / yuzu / configuration / configure_graphics_advanced . ui <nl> ppp b / src / yuzu / configuration / configure_graphics_advanced . ui <nl> <nl> < / property > <nl> < / widget > <nl> < / item > <nl> + < item > <nl> + < widget class = " QCheckBox " name = " use_fast_gpu_time " > <nl> + < property name = " text " > <nl> + < string > Use Fast GPU Time < / string > <nl> + < / property > <nl> + < / widget > <nl> + < / item > <nl> < item > <nl> < layout class = " QHBoxLayout " name = " horizontalLayout_1 " > <nl> < item > <nl> mmm a / src / yuzu_cmd / config . cpp <nl> ppp b / src / yuzu_cmd / config . cpp <nl> void Config : : ReadValues ( ) { <nl> sdl2_config - > GetBoolean ( " Renderer " , " use_asynchronous_gpu_emulation " , false ) ; <nl> Settings : : values . use_vsync = <nl> static_cast < u16 > ( sdl2_config - > GetInteger ( " Renderer " , " use_vsync " , 1 ) ) ; <nl> + Settings : : values . use_fast_gpu_time = <nl> + sdl2_config - > GetBoolean ( " Renderer " , " use_fast_gpu_time " , true ) ; <nl> <nl> Settings : : values . bg_red = static_cast < float > ( sdl2_config - > GetReal ( " Renderer " , " bg_red " , 0 . 0 ) ) ; <nl> Settings : : values . bg_green = <nl> mmm a / src / yuzu_tester / config . cpp <nl> ppp b / src / yuzu_tester / config . cpp <nl> void Config : : ReadValues ( ) { <nl> Settings : : values . gpu_accuracy = static_cast < Settings : : GPUAccuracy > ( gpu_accuracy_level ) ; <nl> Settings : : values . use_asynchronous_gpu_emulation = <nl> sdl2_config - > GetBoolean ( " Renderer " , " use_asynchronous_gpu_emulation " , false ) ; <nl> + Settings : : values . use_fast_gpu_time = <nl> + sdl2_config - > GetBoolean ( " Renderer " , " use_fast_gpu_time " , true ) ; <nl> <nl> Settings : : values . bg_red = static_cast < float > ( sdl2_config - > GetReal ( " Renderer " , " bg_red " , 0 . 0 ) ) ; <nl> Settings : : values . bg_green = <nl>
|
Merge pull request from FernandoS27 / command - list
|
yuzu-emu/yuzu
|
6c7d8073be9ab0ce92d346742989800895beeffe
|
2020-04-27T04:18:46Z
|
mmm a / WORKSPACE <nl> ppp b / WORKSPACE <nl> tf_workspace ( ) <nl> <nl> # Specify the minimum required bazel version . <nl> load ( " / / tensorflow : tensorflow . bzl " , " check_version " ) <nl> - check_version ( " 0 . 3 . 0 " ) <nl> + check_version ( " 0 . 3 . 2 " ) <nl> <nl> # TENSORBOARD_BOWER_AUTOGENERATED_BELOW_THIS_LINE_DO_NOT_EDIT <nl> <nl> mmm a / tensorflow / contrib / layers / python / layers / layers . py <nl> ppp b / tensorflow / contrib / layers / python / layers / layers . py <nl> <nl> ' conv2d ' , <nl> ' conv2d_in_plane ' , <nl> ' conv2d_transpose ' , <nl> + ' convolution ' , <nl> ' convolution2d ' , <nl> ' convolution2d_in_plane ' , <nl> ' convolution2d_transpose ' , <nl> <nl> ' fully_connected ' , <nl> ' layer_norm ' , <nl> ' linear ' , <nl> + ' pool ' , <nl> ' max_pool2d ' , <nl> ' one_hot_encoding ' , <nl> ' relu ' , <nl> def bias_add ( inputs , <nl> sc . original_name_scope , outputs ) <nl> <nl> <nl> + # TODO ( jbms ) : change ` rate ` parameter to ` dilation_rate ` for consistency with <nl> + # underlying op . <nl> @ add_arg_scope <nl> - def convolution2d ( inputs , <nl> - num_outputs , <nl> - kernel_size , <nl> - stride = 1 , <nl> - padding = ' SAME ' , <nl> - data_format = DATA_FORMAT_NHWC , <nl> - rate = 1 , <nl> - activation_fn = nn . relu , <nl> - normalizer_fn = None , <nl> - normalizer_params = None , <nl> - weights_initializer = initializers . xavier_initializer ( ) , <nl> - weights_regularizer = None , <nl> - biases_initializer = init_ops . zeros_initializer , <nl> - biases_regularizer = None , <nl> - reuse = None , <nl> - variables_collections = None , <nl> - outputs_collections = None , <nl> - trainable = True , <nl> - scope = None ) : <nl> - " " " Adds a 2D convolution followed by an optional batch_norm layer . <nl> - <nl> - ` convolution2d ` creates a variable called ` weights ` , representing the <nl> - convolutional kernel , that is convolved with the ` inputs ` to produce a <nl> - ` Tensor ` of activations . If a ` normalizer_fn ` is provided ( such as <nl> - ` batch_norm ` ) , it is then applied . Otherwise , if ` normalizer_fn ` is <nl> - None and a ` biases_initializer ` is provided then a ` biases ` variable would be <nl> - created and added the activations . Finally , if ` activation_fn ` is not ` None ` , <nl> - it is applied to the activations as well . <nl> - <nl> - Performs a ' trous convolution with input stride equal to rate if rate is <nl> - greater than one . <nl> + def convolution ( inputs , <nl> + num_outputs , <nl> + kernel_size , <nl> + stride = 1 , <nl> + padding = ' SAME ' , <nl> + data_format = None , <nl> + rate = 1 , <nl> + activation_fn = nn . relu , <nl> + normalizer_fn = None , <nl> + normalizer_params = None , <nl> + weights_initializer = initializers . xavier_initializer ( ) , <nl> + weights_regularizer = None , <nl> + biases_initializer = init_ops . zeros_initializer , <nl> + biases_regularizer = None , <nl> + reuse = None , <nl> + variables_collections = None , <nl> + outputs_collections = None , <nl> + trainable = True , <nl> + scope = None ) : <nl> + " " " Adds an N - D convolution followed by an optional batch_norm layer . <nl> + <nl> + It is required that 1 < = N < = 3 . <nl> + <nl> + ` convolution ` creates a variable called ` weights ` , representing the <nl> + convolutional kernel , that is convolved ( actually cross - correlated ) with the <nl> + ` inputs ` to produce a ` Tensor ` of activations . If a ` normalizer_fn ` is <nl> + provided ( such as ` batch_norm ` ) , it is then applied . Otherwise , if <nl> + ` normalizer_fn ` is None and a ` biases_initializer ` is provided then a ` biases ` <nl> + variable would be created and added the activations . Finally , if <nl> + ` activation_fn ` is not ` None ` , it is applied to the activations as well . <nl> + <nl> + Performs a ' trous convolution with input stride / dilation rate equal to ` rate ` <nl> + if a value > 1 for any dimension of ` rate ` is specified . In this case <nl> + ` stride ` values ! = 1 are not supported . <nl> <nl> Args : <nl> - inputs : a 4 - D tensor of shape ` [ batch_size , height , width , channels ] ` if <nl> - ` data_format ` is ` NHWC ` , and ` [ batch_size , channels , height , width ] ` if <nl> - ` data_format ` is ` NCHW ` . <nl> + inputs : a Tensor of rank N + 2 of shape <nl> + ` [ batch_size ] + input_spatial_shape + [ in_channels ] ` if data_format does <nl> + not start with " NC " ( default ) , or <nl> + ` [ batch_size , in_channels ] + input_spatial_shape ` if data_format starts <nl> + with " NC " . <nl> num_outputs : integer , the number of output filters . <nl> - kernel_size : a list of length 2 ` [ kernel_height , kernel_width ] ` of <nl> - of the filters . Can be an int if both values are the same . <nl> - stride : a list of length 2 ` [ stride_height , stride_width ] ` . <nl> - Can be an int if both strides are the same . Note that presently <nl> - both strides must have the same value . <nl> - padding : one of ` VALID ` or ` SAME ` . <nl> - data_format : A string . ` NHWC ` ( default ) and ` NCHW ` are supported . <nl> - rate : integer . If less than or equal to 1 , a standard convolution is used . <nl> - If greater than 1 , than the a ' trous convolution is applied and ` stride ` <nl> - must be set to 1 , ` data_format ` must be set to ` NHWC ` . <nl> + kernel_size : a sequence of N positive integers specifying the spatial <nl> + dimensions of of the filters . Can be a single integer to specify the same <nl> + value for all spatial dimensions . <nl> + stride : a sequence of N positive integers specifying the stride at which to <nl> + compute output . Can be a single integer to specify the same value for all <nl> + spatial dimensions . Specifying any ` stride ` value ! = 1 is incompatible <nl> + with specifying any ` rate ` value ! = 1 . <nl> + padding : one of ` " VALID " ` or ` " SAME " ` . <nl> + data_format : A string or None . Specifies whether the channel dimension of <nl> + the ` input ` and output is the last dimension ( default , or if ` data_format ` <nl> + does not start with " NC " ) , or the second dimension ( if ` data_format ` <nl> + starts with " NC " ) . For N = 1 , the valid values are " NWC " ( default ) and <nl> + " NCW " . For N = 2 , the valid values are " NHWC " ( default ) and " NCHW " . For <nl> + N = 3 , currently the only valid value is " NDHWC " . <nl> + rate : a sequence of N positive integers specifying the dilation rate to use <nl> + for a ' trous convolution . Can be a single integer to specify the same <nl> + value for all spatial dimensions . Specifying any ` rate ` value ! = 1 is <nl> + incompatible with specifying any ` stride ` value ! = 1 . <nl> activation_fn : activation function , set to None to skip it and maintain <nl> a linear activation . <nl> normalizer_fn : normalization function to use instead of ` biases ` . If <nl> def convolution2d ( inputs , <nl> a tensor representing the output of the operation . <nl> <nl> Raises : <nl> - ValueError : if ` data_format ` is neither ` NHWC ` nor ` NCHW ` . <nl> - ValueError : if ` rate ` is larger than one and ` data_format ` is ` NCHW ` . <nl> - ValueError : if both ` rate ` and ` stride ` are larger than one . <nl> + ValueError : if ` data_format ` is invalid . <nl> + ValueError : both ' rate ' and ` stride ` are not uniformly 1 . <nl> " " " <nl> + if data_format not in [ None , ' NWC ' , ' NCW ' , ' NHWC ' , ' NCHW ' , ' NDHWC ' ] : <nl> + raise ValueError ( ' Invalid data_format : % r ' % ( data_format , ) ) <nl> with variable_scope . variable_scope ( scope , ' Conv ' , [ inputs ] , <nl> reuse = reuse ) as sc : <nl> - if data_format not in ( DATA_FORMAT_NCHW , DATA_FORMAT_NHWC ) : <nl> - raise ValueError ( ' data_format has to be either NCHW or NHWC . ' ) <nl> - if rate > 1 and data_format = = DATA_FORMAT_NCHW : <nl> - raise ValueError ( ' If rate > 1 , data_format must be NHWC ' ) <nl> inputs = ops . convert_to_tensor ( inputs ) <nl> dtype = inputs . dtype . base_dtype <nl> - kernel_h , kernel_w = utils . two_element_tuple ( kernel_size ) <nl> - stride_h , stride_w = utils . two_element_tuple ( stride ) <nl> - if rate > 1 and ( stride_h > 1 or stride_w > 1 ) : <nl> - raise ValueError ( ' Only one of rate or stride can be larger than one ' ) <nl> - if data_format = = DATA_FORMAT_NHWC : <nl> - num_filters_in = utils . last_dimension ( inputs . get_shape ( ) , min_rank = 4 ) <nl> + input_rank = inputs . get_shape ( ) . ndims <nl> + if input_rank is None : <nl> + raise ValueError ( ' Rank of inputs must be known ' ) <nl> + if input_rank < 3 or input_rank > 5 : <nl> + raise ValueError ( ' Rank of inputs is % d , which is not > = 3 and < = 5 ' % <nl> + input_rank ) <nl> + conv_dims = input_rank - 2 <nl> + kernel_size = utils . n_positive_integers ( conv_dims , kernel_size ) <nl> + stride = utils . n_positive_integers ( conv_dims , stride ) <nl> + rate = utils . n_positive_integers ( conv_dims , rate ) <nl> + <nl> + if data_format is None or data_format . endswith ( ' C ' ) : <nl> + num_input_channels = inputs . get_shape ( ) [ input_rank - 1 ] . value <nl> + elif data_format . startswith ( ' NC ' ) : <nl> + num_input_channels = inputs . get_shape ( ) [ 1 ] . value <nl> else : <nl> - num_filters_in = inputs . get_shape ( ) . dims [ 1 ] <nl> - weights_shape = [ kernel_h , kernel_w , <nl> - num_filters_in , num_outputs ] <nl> - weights_collections = utils . get_variable_collections ( <nl> - variables_collections , ' weights ' ) <nl> + raise ValueError ( ' Invalid data_format ' ) <nl> + <nl> + if num_input_channels is None : <nl> + raise ValueError ( ' Number of in_channels must be known . ' ) <nl> + <nl> + weights_shape = ( <nl> + list ( kernel_size ) + [ num_input_channels , num_outputs ] ) <nl> + weights_collections = utils . get_variable_collections ( variables_collections , <nl> + ' weights ' ) <nl> weights = variables . model_variable ( ' weights ' , <nl> shape = weights_shape , <nl> dtype = dtype , <nl> def convolution2d ( inputs , <nl> regularizer = weights_regularizer , <nl> collections = weights_collections , <nl> trainable = trainable ) <nl> - if rate > 1 : <nl> - outputs = nn . atrous_conv2d ( inputs , weights , rate , padding = padding ) <nl> - else : <nl> - if data_format = = DATA_FORMAT_NHWC : <nl> - strides = [ 1 , stride_h , stride_w , 1 ] <nl> - else : <nl> - strides = [ 1 , 1 , stride_h , stride_w ] <nl> - outputs = nn . conv2d ( <nl> - inputs , weights , strides , padding = padding , data_format = data_format ) <nl> + outputs = nn . convolution ( input = inputs , <nl> + filter = weights , <nl> + dilation_rate = rate , <nl> + strides = stride , <nl> + padding = padding , <nl> + data_format = data_format ) <nl> if normalizer_fn is not None : <nl> normalizer_params = normalizer_params or { } <nl> outputs = normalizer_fn ( outputs , * * normalizer_params ) <nl> def convolution2d ( inputs , <nl> biases_collections = utils . get_variable_collections ( <nl> variables_collections , ' biases ' ) <nl> biases = variables . model_variable ( ' biases ' , <nl> - shape = [ num_outputs , ] , <nl> + shape = [ num_outputs ] , <nl> dtype = dtype , <nl> initializer = biases_initializer , <nl> regularizer = biases_regularizer , <nl> def convolution2d ( inputs , <nl> sc . original_name_scope , outputs ) <nl> <nl> <nl> + convolution2d = convolution <nl> + <nl> + <nl> @ add_arg_scope <nl> def convolution2d_in_plane ( <nl> inputs , <nl> def max_pool2d ( inputs , <nl> return utils . collect_named_outputs ( outputs_collections , sc , outputs ) <nl> <nl> <nl> + @ add_arg_scope <nl> + def pool ( inputs , <nl> + kernel_size , <nl> + pooling_type , <nl> + padding = ' VALID ' , <nl> + data_format = None , <nl> + dilation_rate = 1 , <nl> + stride = 1 , <nl> + outputs_collections = None , <nl> + scope = None ) : <nl> + # pylint : disable = line - too - long <nl> + " " " Adds a pooling op . <nl> + <nl> + <nl> + Args : <nl> + inputs : Tensor of rank N + 2 , of shape <nl> + ` [ batch_size ] + input_spatial_shape + [ num_channels ] ` if data_format does <nl> + not start with " NC " ( default ) , or <nl> + ` [ batch_size , num_channels ] + input_spatial_shape ` if data_format starts <nl> + with " NC " . Pooling happens over the spatial dimensions only . <nl> + kernel_size : Sequence of N ints > = 1 . Can also be a single integer to <nl> + specify the same value for all spatial dimensions . <nl> + pooling_type : Specifies pooling operation , must be " AVG " or " MAX " . <nl> + padding : The padding algorithm , must be " SAME " or " VALID " . <nl> + data_format : A string or None . Specifies whether the channel dimension of <nl> + the ` input ` and output is the last dimension ( default , or if ` data_format ` <nl> + does not start with " NC " ) , or the second dimension ( if ` data_format ` <nl> + starts with " NC " ) . For N = 1 , the valid values are " NWC " ( default ) and <nl> + " NCW " . For N = 2 , the valid values are " NHWC " ( default ) and " NCHW " . For <nl> + N = 3 , currently the only valid value is " NDHWC " . <nl> + dilation_rate : Optional . Dilation rate . Sequence of N ints > = 1 . Defaults <nl> + to [ 1 ] * N . Can also be a single integer to specify the same value for all <nl> + spatial dimensions . If any value of dilation_rate is > 1 , then all values <nl> + of stride must be 1 . <nl> + stride : Optional . Sequence of N ints > = 1 . Defaults to [ 1 ] * N . Can also be <nl> + a single integer to specify the same value for all spatial dimensions . If <nl> + any value of stride is > 1 , then all values of dilation_rate must be 1 . <nl> + outputs_collections : The collections to which the outputs are added . <nl> + scope : Optional scope for name_scope . <nl> + <nl> + Returns : <nl> + A ` Tensor ` representing the results of the pooling operation . <nl> + <nl> + Raises : <nl> + ValueError : if arguments are invalid . <nl> + <nl> + " " " <nl> + # pylint : enable = line - too - long <nl> + with ops . name_scope ( scope , ' % s_pool ' % <nl> + ( pooling_type . lower ( ) ) , [ inputs ] ) as sc : <nl> + inputs = ops . convert_to_tensor ( inputs ) <nl> + input_rank = inputs . get_shape ( ) . ndims <nl> + if input_rank is None : <nl> + raise ValueError ( ' Rank of inputs must be known ' ) <nl> + if input_rank < 3 : <nl> + raise ValueError ( ' Rank of inputs must be > = 3 ' ) <nl> + num_spatial_dims = input_rank - 2 <nl> + output = nn . pool ( <nl> + input = inputs , <nl> + window_shape = utils . n_positive_integers ( num_spatial_dims , kernel_size ) , <nl> + pooling_type = pooling_type , <nl> + padding = padding , <nl> + data_format = data_format , <nl> + dilation_rate = utils . n_positive_integers ( num_spatial_dims , <nl> + dilation_rate ) , <nl> + strides = utils . n_positive_integers ( num_spatial_dims , stride ) , <nl> + name = sc ) <nl> + return utils . collect_named_outputs ( outputs_collections , sc , output ) <nl> + <nl> + <nl> @ add_arg_scope <nl> def one_hot_encoding ( labels , <nl> num_classes , <nl> mmm a / tensorflow / contrib / layers / python / layers / layers_test . py <nl> ppp b / tensorflow / contrib / layers / python / layers / layers_test . py <nl> def testGlobalAvgPool ( self ) : <nl> self . assertListEqual ( output . get_shape ( ) . as_list ( ) , [ 5 , 1 , 1 , 3 ] ) <nl> <nl> <nl> + class PoolTest ( tf . test . TestCase ) : <nl> + <nl> + def testCreatePool ( self ) : <nl> + height , width = 3 , 3 <nl> + images = np . random . uniform ( size = ( 5 , height , width , 3 ) ) <nl> + output = tf . contrib . layers . pool ( images , [ 3 , 3 ] , pooling_type = ' AVG ' ) <nl> + self . assertEqual ( output . op . name , ' avg_pool ' ) <nl> + self . assertListEqual ( output . get_shape ( ) . as_list ( ) , [ 5 , 1 , 1 , 3 ] ) <nl> + <nl> + def testCreatePoolNCHW ( self ) : <nl> + height , width = 3 , 3 <nl> + images = np . random . uniform ( size = ( 5 , 3 , height , width ) ) <nl> + output = tf . contrib . layers . pool ( <nl> + images , [ 3 , 3 ] , pooling_type = ' AVG ' , data_format = ' NCHW ' ) <nl> + self . assertEqual ( output . op . name , ' avg_pool ' ) <nl> + self . assertListEqual ( output . get_shape ( ) . as_list ( ) , [ 5 , 3 , 1 , 1 ] ) <nl> + <nl> + def testCollectOutputs ( self ) : <nl> + height , width = 3 , 3 <nl> + images = tf . random_uniform ( ( 5 , height , width , 3 ) , seed = 1 ) <nl> + output = tf . contrib . layers . pool ( images , [ 3 , 3 ] , <nl> + pooling_type = ' AVG ' , <nl> + outputs_collections = ' outputs ' ) <nl> + output_collected = tf . get_collection ( ' outputs ' ) [ 0 ] <nl> + self . assertEqual ( output_collected . alias , ' avg_pool ' ) <nl> + self . assertEqual ( output_collected , output ) <nl> + <nl> + def testCreateSquareAvgPool ( self ) : <nl> + height , width = 3 , 3 <nl> + images = tf . random_uniform ( ( 5 , height , width , 3 ) , seed = 1 ) <nl> + output = tf . contrib . layers . pool ( images , 3 , pooling_type = ' AVG ' ) <nl> + self . assertEqual ( output . op . name , ' avg_pool ' ) <nl> + self . assertEqual ( output . get_shape ( ) . as_list ( ) , [ 5 , 1 , 1 , 3 ] ) <nl> + <nl> + def testCreateMaxPoolWithScope ( self ) : <nl> + height , width = 3 , 3 <nl> + images = tf . random_uniform ( ( 5 , height , width , 3 ) , seed = 1 ) <nl> + output = tf . contrib . layers . pool ( <nl> + images , [ 3 , 3 ] , pooling_type = ' MAX ' , scope = ' pool1 ' ) <nl> + self . assertEqual ( output . op . name , ' pool1 ' ) <nl> + <nl> + def testCreateMaxPoolWithSamePadding ( self ) : <nl> + height , width = 3 , 3 <nl> + images = tf . random_uniform ( ( 5 , height , width , 3 ) , seed = 1 ) <nl> + output = tf . contrib . layers . pool ( <nl> + images , [ 3 , 3 ] , pooling_type = ' MAX ' , padding = ' SAME ' ) <nl> + self . assertEqual ( output . get_shape ( ) . as_list ( ) , [ 5 , 3 , 3 , 3 ] ) <nl> + <nl> + def testCreateAvgPoolStrideWithSamePadding ( self ) : <nl> + height , width = 3 , 3 <nl> + images = tf . random_uniform ( ( 5 , height , width , 3 ) , seed = 1 ) <nl> + output = tf . contrib . layers . pool ( <nl> + images , [ 3 , 3 ] , stride = 1 , padding = ' SAME ' , pooling_type = ' AVG ' ) <nl> + self . assertEqual ( output . get_shape ( ) . as_list ( ) , [ 5 , height , width , 3 ] ) <nl> + <nl> + def testGlobalAvgPool ( self ) : <nl> + height , width = 3 , 3 <nl> + images = tf . random_uniform ( ( 5 , height , width , 3 ) , seed = 1 ) <nl> + output = tf . contrib . layers . pool ( <nl> + images , images . get_shape ( ) [ 1 : 3 ] , stride = 1 , pooling_type = ' AVG ' ) <nl> + self . assertEqual ( output . get_shape ( ) . as_list ( ) , [ 5 , 1 , 1 , 3 ] ) <nl> + <nl> + def testAvgPoolWithStride ( self ) : <nl> + height , width = 5 , 8 <nl> + images = tf . random_uniform ( ( 5 , height , width , 3 ) , seed = 1 ) <nl> + output = tf . contrib . layers . pool ( <nl> + images , [ 2 , 3 ] , stride = [ 1 , 2 ] , pooling_type = ' AVG ' ) <nl> + self . assertEqual ( output . get_shape ( ) . as_list ( ) , [ 5 , 4 , 3 , 3 ] ) <nl> + <nl> + def testAvgPoolWithDilation ( self ) : <nl> + height , width = 5 , 8 <nl> + images = tf . random_uniform ( ( 5 , height , width , 3 ) , seed = 1 ) <nl> + output = tf . contrib . layers . pool ( <nl> + images , [ 2 , 3 ] , dilation_rate = [ 1 , 2 ] , pooling_type = ' AVG ' ) <nl> + self . assertEqual ( output . get_shape ( ) . as_list ( ) , [ 5 , 4 , 4 , 3 ] ) <nl> + <nl> + def testAvgPoolWithDilationNCHW ( self ) : <nl> + height , width = 5 , 8 <nl> + images = tf . random_uniform ( ( 5 , 3 , height , width ) , seed = 1 ) <nl> + output = tf . contrib . layers . pool ( <nl> + images , [ 2 , 3 ] , dilation_rate = [ 1 , 2 ] , pooling_type = ' AVG ' , data_format = ' NCHW ' ) <nl> + self . assertEqual ( output . get_shape ( ) . as_list ( ) , [ 5 , 3 , 4 , 4 ] ) <nl> + <nl> + <nl> class BiasAddTest ( tf . test . TestCase ) : <nl> <nl> def testCreate ( self ) : <nl> def testCreateDimensions ( self ) : <nl> self . assertListEqual ( biases . get_shape ( ) . as_list ( ) , [ input_shape [ - 1 ] ] ) <nl> <nl> <nl> - class Convolution2dTest ( tf . test . TestCase ) : <nl> + class ConvolutionTest ( tf . test . TestCase ) : <nl> <nl> def testInvalidDataFormat ( self ) : <nl> height , width = 7 , 9 <nl> with self . test_session ( ) : <nl> images = tf . random_uniform ( ( 5 , height , width , 3 ) , seed = 1 ) <nl> with self . assertRaisesRegexp ( <nl> - ValueError , ' data_format has to be either NCHW or NHWC . ' ) : <nl> + ValueError , ' data_format ' ) : <nl> tf . contrib . layers . convolution2d ( images , 32 , 3 , data_format = ' CHWN ' ) <nl> <nl> def testCreateConv ( self ) : <nl> def testOutputSizeWithRateTwoValidPadding ( self ) : <nl> self . assertEqual ( output . op . name , ' Conv / Relu ' ) <nl> self . assertListEqual ( list ( output . eval ( ) . shape ) , expected_size ) <nl> <nl> + def testOutputSizeWithRateTwoThreeValidPadding ( self ) : <nl> + num_filters = 32 <nl> + input_size = [ 5 , 10 , 12 , 3 ] <nl> + expected_size = [ 5 , 6 , 6 , num_filters ] <nl> + <nl> + images = tf . random_uniform ( input_size , seed = 1 ) <nl> + output = tf . contrib . layers . convolution2d ( images , num_filters , [ 3 , 3 ] , <nl> + rate = [ 2 , 3 ] , padding = ' VALID ' ) <nl> + self . assertListEqual ( list ( output . get_shape ( ) . as_list ( ) ) , expected_size ) <nl> + with self . test_session ( ) as sess : <nl> + sess . run ( tf . initialize_all_variables ( ) ) <nl> + self . assertEquals ( output . op . name , ' Conv / Relu ' ) <nl> + self . assertListEqual ( list ( output . eval ( ) . shape ) , expected_size ) <nl> + <nl> def testDynamicOutputSizeWithRateOneValidPadding ( self ) : <nl> num_filters = 32 <nl> input_size = [ 5 , 9 , 11 , 3 ] <nl> def testRepeat ( self ) : <nl> images = np . random . uniform ( size = ( 5 , height , width , 3 ) ) <nl> output = tf . contrib . layers . repeat ( images , 3 , <nl> tf . contrib . layers . conv2d , 32 , [ 3 , 3 ] ) <nl> - self . assertEqual ( output . op . name , ' Repeat / convolution2d_3 / Relu ' ) <nl> + self . assertEqual ( output . op . name , ' Repeat / convolution_3 / Relu ' ) <nl> self . assertListEqual ( output . get_shape ( ) . as_list ( ) , [ 5 , 3 , 3 , 32 ] ) <nl> <nl> def testRepeatWithScope ( self ) : <nl> def testStackConvolution2d ( self ) : <nl> [ 10 , 20 , 30 ] , <nl> kernel_size = [ 3 , 3 ] , <nl> padding = ' SAME ' ) <nl> - self . assertEqual ( output . op . name , ' Stack / convolution2d_3 / Relu ' ) <nl> + self . assertEqual ( output . op . name , ' Stack / convolution_3 / Relu ' ) <nl> self . assertListEqual ( output . get_shape ( ) . as_list ( ) , [ 5 , 3 , 3 , 30 ] ) <nl> <nl> def testStackWithScope ( self ) : <nl> mmm a / tensorflow / contrib / layers / python / layers / utils . py <nl> ppp b / tensorflow / contrib / layers / python / layers / utils . py <nl> <nl> ' smart_cond ' , <nl> ' get_variable_collections ' , <nl> ' two_element_tuple ' , <nl> + ' n_positive_integers ' , <nl> ' last_dimension ' , <nl> ' first_dimension ' ] <nl> <nl> def two_element_tuple ( int_or_tuple ) : <nl> return int_or_tuple [ 0 ] , int_or_tuple [ 1 ] <nl> raise ValueError ( ' Must be an int , a list with 2 elements or a TensorShape of ' <nl> ' length 2 ' ) <nl> + <nl> + <nl> + def n_positive_integers ( n , value ) : <nl> + " " " Converts ` value ` to a sequence of ` n ` positive integers . <nl> + <nl> + ` value ` may be either be a sequence of values convertible to ` int ` , or a <nl> + single value convertible to ` int ` , in which case the the resultant integer is <nl> + duplicated ` n ` times . It may also be a TensorShape of rank ` n ` . <nl> + <nl> + Args : <nl> + n : Length of sequence to return . <nl> + value : Either a single value convertible to a positive ` int ` or an <nl> + ` n ` - element sequence of values convertible to a positive ` int ` . <nl> + <nl> + Returns : <nl> + A tuple of ` n ` positive integers . <nl> + <nl> + Raises : <nl> + TypeError : If ` n ` is not convertible to an integer . <nl> + ValueError : If ` n ` or ` value ` are invalid . <nl> + " " " <nl> + <nl> + n_orig = n <nl> + n = int ( n ) <nl> + if n < 1 or n ! = n_orig : <nl> + raise ValueError ( ' n must be a positive integer ' ) <nl> + <nl> + try : <nl> + value = int ( value ) <nl> + except ( TypeError , ValueError ) : <nl> + sequence_len = len ( value ) <nl> + if sequence_len ! = n : <nl> + raise ValueError ( <nl> + ' Expected sequence of % d positive integers , but received % r ' % <nl> + ( n , value ) ) <nl> + try : <nl> + values = tuple ( int ( x ) for x in value ) <nl> + except : <nl> + raise ValueError ( <nl> + ' Expected sequence of % d positive integers , but received % r ' % <nl> + ( n , value ) ) <nl> + for x in values : <nl> + if x < 1 : <nl> + raise ValueError ( ' expected positive integer , but received % d ' % x ) <nl> + return values <nl> + <nl> + if value < 1 : <nl> + raise ValueError ( ' expected positive integer , but received % d ' % value ) <nl> + return ( value , ) * n <nl> mmm a / tensorflow / contrib / layers / python / layers / utils_test . py <nl> ppp b / tensorflow / contrib / layers / python / layers / utils_test . py <nl> def test_gather_aliases ( self ) : <nl> self . assertListEqual ( aliases , [ ' a1 ' , ' a2 ' , ' t3 ' ] ) <nl> <nl> <nl> + class NPositiveIntegersTest ( tf . test . TestCase ) : <nl> + <nl> + def test_invalid_input ( self ) : <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( ' 3 ' , [ 1 ] ) <nl> + <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( 3 . 3 , [ 1 ] ) <nl> + <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( - 1 , [ 1 ] ) <nl> + <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( 0 , [ 1 ] ) <nl> + <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( 1 , [ 1 , 2 ] ) <nl> + <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( 1 , [ - 1 ] ) <nl> + <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( 1 , [ 0 ] ) <nl> + <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( 1 , [ 0 ] ) <nl> + <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( 2 , [ 1 ] ) <nl> + <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( 2 , [ 1 , 2 , 3 ] ) <nl> + <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( 2 , [ ' hello ' , 2 ] ) <nl> + <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( 2 , tf . TensorShape ( [ 2 , 3 , 1 ] ) ) <nl> + <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( 3 , tf . TensorShape ( [ 2 , None , 1 ] ) ) <nl> + <nl> + with self . assertRaises ( ValueError ) : <nl> + utils . n_positive_integers ( 3 , tf . TensorShape ( None ) ) <nl> + <nl> + def test_valid_input ( self ) : <nl> + self . assertEqual ( utils . n_positive_integers ( 1 , 2 ) , ( 2 , ) ) <nl> + self . assertEqual ( utils . n_positive_integers ( 2 , 2 ) , ( 2 , 2 ) ) <nl> + self . assertEqual ( utils . n_positive_integers ( 2 , ( 2 , 3 ) ) , ( 2 , 3 ) ) <nl> + self . assertEqual ( utils . n_positive_integers ( 3 , ( 2 , 3 , 1 ) ) , ( 2 , 3 , 1 ) ) <nl> + self . assertEqual ( utils . n_positive_integers ( 3 , ( 2 , 3 , 1 ) ) , ( 2 , 3 , 1 ) ) <nl> + self . assertEqual ( <nl> + utils . n_positive_integers ( 3 , tf . TensorShape ( [ 2 , 3 , 1 ] ) ) , ( 2 , 3 , 1 ) ) <nl> + <nl> + <nl> if __name__ = = ' __main__ ' : <nl> tf . test . main ( ) <nl> mmm a / tensorflow / contrib / tensor_forest / core / ops / finished_nodes_op . cc <nl> ppp b / tensorflow / contrib / tensor_forest / core / ops / finished_nodes_op . cc <nl> void Evaluate ( const EvaluateParams & params , mutex * mutex , int32 start , <nl> std : : vector < int32 > stale ; <nl> <nl> std : : unique_ptr < random : : SimplePhilox > simple_philox ; <nl> + random : : PhiloxRandom rnd_gen ( params . random_seed ) ; <nl> <nl> if ( params . need_random ) { <nl> - random : : PhiloxRandom rnd_gen ( params . random_seed ) ; <nl> simple_philox . reset ( new random : : SimplePhilox ( & rnd_gen ) ) ; <nl> } <nl> <nl> mmm a / tensorflow / contrib / tensor_forest / python / tensor_forest . py <nl> ppp b / tensorflow / contrib / tensor_forest / python / tensor_forest . py <nl> <nl> from tensorflow . python . ops import random_ops <nl> from tensorflow . python . ops import state_ops <nl> from tensorflow . python . ops import variable_scope <nl> - from tensorflow . python . ops import variables as tf_variables <nl> from tensorflow . python . platform import tf_logging as logging <nl> <nl> <nl> def __init__ ( self , <nl> split_after_samples = 250 , <nl> min_split_samples = 5 , <nl> valid_leaf_threshold = 1 , <nl> + dominate_method = ' hoeffding ' , <nl> + dominate_fraction = 0 . 99 , <nl> * * kwargs ) : <nl> self . num_trees = num_trees <nl> self . max_nodes = max_nodes <nl> def __init__ ( self , <nl> self . split_after_samples = split_after_samples <nl> self . min_split_samples = min_split_samples <nl> self . valid_leaf_threshold = valid_leaf_threshold <nl> + self . dominate_method = dominate_method <nl> + self . dominate_fraction = dominate_fraction <nl> <nl> for name , value in kwargs . items ( ) : <nl> setattr ( self , name , value ) <nl> def __init__ ( self , params , tree_num , training ) : <nl> name = self . get_tree_name ( ' end_of_tree ' , tree_num ) , <nl> dtype = dtypes . int32 , <nl> initializer = constant_op . constant ( [ 1 ] ) ) <nl> - self . start_epoch = tf_variables . Variable ( <nl> - [ 0 ] * ( params . max_nodes ) , name = ' start_epoch ' ) <nl> + self . start_epoch = variable_scope . get_variable ( <nl> + name = self . get_tree_name ( ' start_epoch ' , tree_num ) , <nl> + dtype = dtypes . int32 , shape = [ params . max_nodes ] , <nl> + initializer = init_ops . constant_initializer ( 0 ) ) <nl> <nl> if training : <nl> self . node_to_accumulator_map = variable_scope . get_variable ( <nl> def training_graph ( self , <nl> self . variables . start_epoch , <nl> epoch , <nl> num_split_after_samples = self . params . split_after_samples , <nl> - min_split_samples = self . params . min_split_samples ) <nl> + min_split_samples = self . params . min_split_samples , <nl> + dominate_method = self . params . dominate_method , <nl> + dominate_fraction = self . params . dominate_fraction ) <nl> <nl> # Update leaf scores . <nl> # TODO ( thomaswc ) : Store the leaf scores in a TopN and only update the <nl> mmm a / tensorflow / core / debug / debug_gateway_test . cc <nl> ppp b / tensorflow / core / debug / debug_gateway_test . cc <nl> TEST_F ( SessionDebugMinusAXTest , <nl> } <nl> } <nl> <nl> + class SessionDebugOutputSlotWithoutOngoingEdgeTest : public : : testing : : Test { <nl> + public : <nl> + void Initialize ( ) { <nl> + Graph graph ( OpRegistry : : Global ( ) ) ; <nl> + <nl> + # if GOOGLE_CUDA <nl> + const string kDeviceName = " / job : localhost / replica : 0 / task : 0 / gpu : 0 " ; <nl> + # else <nl> + const string kDeviceName = " / job : localhost / replica : 0 / task : 0 / cpu : 0 " ; <nl> + # endif <nl> + <nl> + Tensor a_tensor ( DT_FLOAT , TensorShape ( { 1 , 1 } ) ) ; <nl> + test : : FillValues < float > ( & a_tensor , { 42 . 0 } ) ; <nl> + Node * a = test : : graph : : Constant ( & graph , a_tensor ) ; <nl> + a - > set_assigned_device_name ( kDeviceName ) ; <nl> + <nl> + Node * c = test : : graph : : Constant ( & graph , a_tensor ) ; <nl> + c - > set_assigned_device_name ( kDeviceName ) ; <nl> + c_ = c - > name ( ) ; <nl> + <nl> + / / Node c will be executed only because of the control edge from c to y . <nl> + / / Its output slot ( slot 0 ) does not have an outgoing edge . This test <nl> + / / is for testing that the debugger can watch that slot properly . <nl> + Node * y = test : : graph : : NoOp ( & graph , { c } ) ; <nl> + y - > set_assigned_device_name ( kDeviceName ) ; <nl> + y_ = y - > name ( ) ; <nl> + <nl> + test : : graph : : ToGraphDef ( & graph , & def_ ) ; <nl> + } <nl> + <nl> + string c_ ; <nl> + string y_ ; <nl> + GraphDef def_ ; <nl> + } ; <nl> + <nl> + TEST_F ( SessionDebugOutputSlotWithoutOngoingEdgeTest , <nl> + WatchSlotWithoutOutgoingEdge ) { <nl> + Initialize ( ) ; <nl> + std : : unique_ptr < DirectSession > session ( CreateSession ( ) ) ; <nl> + ASSERT_TRUE ( session ! = nullptr ) ; <nl> + <nl> + DebugGateway debug_gateway ( session . get ( ) ) ; <nl> + <nl> + / / Supply completion and value callbacks <nl> + mutex mu ; <nl> + <nl> + string debug_identity_node_name = DebugNodeInserter : : GetDebugNodeName ( <nl> + strings : : StrCat ( c_ , " : " , 0 ) , 0 , " DebugIdentity " ) ; <nl> + <nl> + Notification callbacks_done ; <nl> + <nl> + debug_gateway . SetNodeCompletionCallback ( <nl> + [ & mu , & callbacks_done ] ( const string & node_name , const bool any_output ) { <nl> + mutex_lock l ( mu ) ; <nl> + if ( node_name = = " _SINK " & & ! callbacks_done . HasBeenNotified ( ) ) { <nl> + callbacks_done . Notify ( ) ; <nl> + } <nl> + } ) ; <nl> + <nl> + std : : vector < Tensor > debug_identity_tensor_vals ; <nl> + debug_gateway . SetNodeValueCallback ( <nl> + [ this , & mu , & debug_identity_node_name , & debug_identity_tensor_vals ] ( <nl> + const string & node_name , const int output_slot , <nl> + const Tensor & tensor_value , const bool is_ref ) { <nl> + mutex_lock l ( mu ) ; <nl> + <nl> + if ( node_name = = debug_identity_node_name & & output_slot = = 0 ) { <nl> + debug_identity_tensor_vals . push_back ( tensor_value ) ; <nl> + } <nl> + } ) ; <nl> + <nl> + / / Add DebugIdentity watch on c : 0 , which does not have an outgoing edge . <nl> + RunOptions run_opts ; <nl> + run_opts . set_output_partition_graphs ( true ) ; <nl> + <nl> + DebugTensorWatch * tensor_watch_opts = run_opts . add_debug_tensor_watch_opts ( ) ; <nl> + tensor_watch_opts - > set_node_name ( c_ ) ; <nl> + tensor_watch_opts - > set_output_slot ( 0 ) ; <nl> + tensor_watch_opts - > add_debug_ops ( " DebugIdentity " ) ; <nl> + <nl> + TF_ASSERT_OK ( session - > Create ( def_ ) ) ; <nl> + <nl> + / / Invoke Session : : Run ( ) on y . <nl> + std : : vector < std : : pair < string , Tensor > > inputs ; <nl> + std : : vector < string > output_names ; <nl> + std : : vector < string > target_nodes = { y_ } ; <nl> + std : : vector < Tensor > outputs ; <nl> + <nl> + RunMetadata run_metadata ; <nl> + Status s = session - > Run ( run_opts , inputs , output_names , target_nodes , <nl> + & outputs , & run_metadata ) ; <nl> + TF_ASSERT_OK ( s ) ; <nl> + <nl> + / / Wait for callbacks to complete . <nl> + callbacks_done . WaitForNotification ( ) ; <nl> + <nl> + / / Assert that DebugIdentity node watching the control edge has been run . <nl> + ASSERT_EQ ( 1 , debug_identity_tensor_vals . size ( ) ) ; <nl> + auto mat_identity = debug_identity_tensor_vals [ 0 ] . matrix < float > ( ) ; <nl> + ASSERT_EQ ( 42 . 0 , mat_identity ( 0 , 0 ) ) ; <nl> + } <nl> + <nl> class SessionDebugVariableTest : public : : testing : : Test { <nl> public : <nl> void Initialize ( ) { <nl> mmm a / tensorflow / core / debug / debug_graph_utils . cc <nl> ppp b / tensorflow / core / debug / debug_graph_utils . cc <nl> Status DebugNodeInserter : : InsertNodes ( <nl> } <nl> <nl> DeviceType device_type = DeviceType { device - > device_type ( ) } ; <nl> - / / 1 . Record existing edges in the graph . <nl> - std : : vector < const Edge * > existing_edges ; <nl> - for ( const Edge * edge : graph - > edges ( ) ) { <nl> - existing_edges . push_back ( edge ) ; <nl> - } <nl> - <nl> - / / A map from tensor names to edges to be removed <nl> - std : : unordered_map < string , std : : vector < const Edge * > > edges_to_remove ; <nl> - / / A map from tensor names to newly added debug nodes ( maybe more than one <nl> - / / for a given tensor ) . <nl> - std : : unordered_map < string , std : : vector < Node * > > added_debug_nodes ; <nl> - std : : unordered_map < string , Node * > added_copy_nodes ; <nl> <nl> - / / 2 . Iterate through the edges , look for edges that match the tensor watch <nl> - / / list . <nl> - for ( const Edge * edge : existing_edges ) { <nl> - Node * src_node = edge - > src ( ) ; <nl> - Node * dst_node = edge - > dst ( ) ; <nl> - <nl> - if ( edge - > IsControlEdge ( ) ) { <nl> - continue ; <nl> + / / Keep track of all edges to be removed . <nl> + std : : vector < const Edge * > edges_to_remove ; <nl> + <nl> + for ( Node * src_node : graph - > nodes ( ) ) { <nl> + / / Make a map from output slot to outgoing edges from the slot . <nl> + std : : unordered_map < int , std : : vector < const Edge * > > output_slot_to_edges ; <nl> + for ( const Edge * edge : src_node - > out_edges ( ) ) { <nl> + const int src_output = edge - > src_output ( ) ; <nl> + if ( output_slot_to_edges . find ( src_output ) = = output_slot_to_edges . end ( ) ) { <nl> + output_slot_to_edges [ src_output ] = { edge } ; <nl> + } else { <nl> + output_slot_to_edges [ src_output ] . push_back ( edge ) ; <nl> + } <nl> } <nl> <nl> - const bool is_ref = IsRefType ( dst_node - > input_type ( edge - > dst_input ( ) ) ) ; <nl> - MemoryType memory_type ; <nl> - MemoryTypeForOutput ( device_type , graph , src_node , edge - > src_output ( ) , <nl> - & memory_type ) ; <nl> - <nl> - const string tensor_name = <nl> - strings : : StrCat ( src_node - > name ( ) , " : " , edge - > src_output ( ) ) ; <nl> - if ( tensor_watches . find ( tensor_name ) = = tensor_watches . end ( ) ) { <nl> - / / Add debug nodes only for edges with matching source node and source <nl> - / / output slot . <nl> - continue ; <nl> - } <nl> + / / Iterate through all output slots of the node . <nl> + for ( int src_output_slot = 0 ; src_output_slot < src_node - > num_outputs ( ) ; <nl> + + + src_output_slot ) { <nl> + const string tensor_name = <nl> + strings : : StrCat ( src_node - > name ( ) , " : " , src_output_slot ) ; <nl> + if ( tensor_watches . find ( tensor_name ) = = tensor_watches . end ( ) ) { <nl> + / / Add debug nodes only for edges with matching source node and source <nl> + / / output slot . <nl> + continue ; <nl> + } <nl> <nl> - if ( added_copy_nodes . find ( tensor_name ) = = added_copy_nodes . end ( ) ) { <nl> - / / It is the first time an edge with this source tensor is encountered : <nl> - / / we will : <nl> - / / 1 ) Mark this edge as to be removed , iff the destination node has <nl> - / / non - Ref input <nl> - / / 2 ) Create a Copy node <nl> + / / Now we have encountered a watched tensor . We will : <nl> + / / 1 ) Mark this edge as to be removed , iff this is a non - Reference <nl> + / / tensor <nl> + / / 2 ) Create a Copy node for the tensor <nl> / / 3 ) Add a new edge , from the source tensor to the Copy node <nl> / / 4 ) Add a new edge , from the Copy node to the destination node , iff <nl> - / / the destination node has non - Ref input <nl> + / / this is a non - Reference tensor . <nl> / / 5 ) Create all the requested debug nodes and their edges to the Copy <nl> / / node . <nl> - if ( ! is_ref ) { <nl> - std : : vector < const Edge * > node_edges_to_remove ; <nl> - node_edges_to_remove . push_back ( edge ) ; <nl> - edges_to_remove [ tensor_name ] = node_edges_to_remove ; <nl> - } <nl> + / / 6 ) Add control edges from the debug nodes to the destination nodes <nl> + / / to ensure that the tensors values exported by the debug nodes <nl> + / / to the debug URLs reflect the values before the execution of <nl> + / / the destination nodes . <nl> <nl> - const DataType src_dt = src_node - > output_type ( edge - > src_output ( ) ) ; <nl> + const DataType src_dt = src_node - > output_type ( src_output_slot ) ; <nl> + MemoryType memory_type ; <nl> + MemoryTypeForOutput ( device_type , graph , src_node , src_output_slot , <nl> + & memory_type ) ; <nl> <nl> - / / Create the copy node . <nl> + / / Create the copy node for the watched tensor . <nl> Node * copy_node ; <nl> Status copy_s = CreateCopyNode ( <nl> graph , device_type , memory_type = = HOST_MEMORY , src_node - > name ( ) , <nl> - edge - > src_output ( ) , src_dt , tensor_name , & copy_node ) ; <nl> + src_output_slot , src_dt , tensor_name , & copy_node ) ; <nl> if ( ! copy_s . ok ( ) ) { <nl> return Status ( <nl> error : : FAILED_PRECONDITION , <nl> Status DebugNodeInserter : : InsertNodes ( <nl> tensor_name , " , due to : " , copy_s . error_message ( ) ) ) ; <nl> } <nl> <nl> - / / Record the added copy node for later use . <nl> - added_copy_nodes [ tensor_name ] = copy_node ; <nl> - <nl> / / Add edge from watched tensor to the copy node . <nl> - graph - > AddEdge ( src_node , edge - > src_output ( ) , copy_node , 0 ) ; <nl> - <nl> - / / Add edge from the copy node to the destination node , iff the <nl> - / / destination node has non - Ref input . <nl> - if ( ! is_ref ) { <nl> - graph - > AddEdge ( copy_node , 0 , dst_node , edge - > dst_input ( ) ) ; <nl> - } <nl> + graph - > AddEdge ( src_node , src_output_slot , copy_node , 0 ) ; <nl> <nl> / / Create all requested debug nodes and their edges to the Copy node . <nl> - std : : vector < Node * > node_added_debug_nodes ; <nl> + std : : vector < Node * > debug_nodes ; <nl> for ( size_t i = 0 ; i < tensor_watches [ tensor_name ] . size ( ) ; + + i ) { <nl> const string & debug_op_name = tensor_watches [ tensor_name ] [ i ] ; <nl> <nl> Status DebugNodeInserter : : InsertNodes ( <nl> debug_s . error_message ( ) ) ) ; <nl> } <nl> <nl> - node_added_debug_nodes . push_back ( debug_node ) ; <nl> - <nl> / / Create edges from the Copy node to the debug node . <nl> graph - > AddEdge ( copy_node , 0 , debug_node , 0 ) ; <nl> <nl> + debug_nodes . push_back ( debug_node ) ; <nl> + } <nl> + <nl> + / / Is the output a reference ? <nl> + const bool is_ref = IsRefType ( src_node - > output_type ( src_output_slot ) ) ; <nl> + <nl> + / / Iterate through all outgoing edges attached to the slot . <nl> + for ( const Edge * edge : output_slot_to_edges [ src_output_slot ] ) { <nl> + / / Mark the edge for removal . <nl> + if ( ! is_ref ) { <nl> + edges_to_remove . push_back ( edge ) ; <nl> + graph - > AddEdge ( copy_node , 0 , edge - > dst ( ) , edge - > dst_input ( ) ) ; <nl> + } <nl> + <nl> / / Add control edges from the debug nodes to the destination node <nl> / / to ensure that the debug nodes are executed before the destination <nl> / / node . <nl> - graph - > AddEdge ( debug_node , Graph : : kControlSlot , dst_node , <nl> - Graph : : kControlSlot ) ; <nl> - } <nl> - added_debug_nodes [ tensor_name ] = node_added_debug_nodes ; <nl> - } else { <nl> - / / It is not the first time an edge with this source is encountered . <nl> - / / We will do the following iff the destination node has non - Ref input <nl> - / / 1 ) Mark the edge for removal <nl> - / / 2 ) Create an edge from the copy node to the destination node <nl> - / / Iff the destination has Ref - input , the edge will not change . <nl> - / / Regardless of whether the destination has Ref - inpt , we will <nl> - / / 3 ) Add control edges from the already - created debug node ( s ) for the <nl> - / / watched tensor to the destination node . <nl> - if ( ! is_ref ) { <nl> - edges_to_remove [ tensor_name ] . push_back ( edge ) ; <nl> - graph - > AddEdge ( added_copy_nodes [ tensor_name ] , 0 , dst_node , <nl> - edge - > dst_input ( ) ) ; <nl> - } <nl> - <nl> - for ( Node * debug_node : added_debug_nodes [ tensor_name ] ) { <nl> - graph - > AddEdge ( debug_node , Graph : : kControlSlot , dst_node , <nl> - Graph : : kControlSlot ) ; <nl> + for ( Node * debug_node : debug_nodes ) { <nl> + graph - > AddEdge ( debug_node , Graph : : kControlSlot , edge - > dst ( ) , <nl> + Graph : : kControlSlot ) ; <nl> + } <nl> } <nl> } <nl> } <nl> <nl> / / Remove all edges marked for removal . <nl> - for ( auto it : edges_to_remove ) { <nl> - std : : vector < const Edge * > edges = it . second ; <nl> - <nl> - for ( const Edge * edge : edges ) { <nl> - graph - > RemoveEdge ( edge ) ; <nl> - } <nl> + for ( const Edge * edge : edges_to_remove ) { <nl> + graph - > RemoveEdge ( edge ) ; <nl> } <nl> <nl> return Status : : OK ( ) ; <nl> mmm a / tensorflow / core / framework / selective_registration . h <nl> ppp b / tensorflow / core / framework / selective_registration . h <nl> limitations under the License . <nl> / / un - registered objects unused , and therefore allow the linker to strip them <nl> / / out . See tools / print_required_ops / print_selective_registration_header . py <nl> / / for a tool that can be used to generate ops_to_register . h . <nl> - # include " ops_to_register . h " <nl> - <nl> - / / Op kernel classes for which ShouldRegisterOpKernel returns false will not be <nl> - / / registered . <nl> - # define SHOULD_REGISTER_OP_KERNEL ( clz ) \ <nl> - ( strstr ( kNecessaryOpKernelClasses , " , " clz " , " ) ! = nullptr ) <nl> - <nl> - / / Ops for which ShouldRegisterOp returns false will not be registered . <nl> - # define SHOULD_REGISTER_OP ( op ) ShouldRegisterOp ( op ) <nl> + / / <nl> + / / ops_to_register . h should define macros for : <nl> + / / / / Ops for which this is false will not be registered . <nl> + / / SHOULD_REGISTER_OP ( op ) <nl> + / / / / If this is false , then no gradient ops are registered . <nl> + / / SHOULD_REGISTER_OP_GRADIENT <nl> + / / / / Op kernel classes where this is false won ' t be registered . <nl> + / / SHOULD_REGISTER_OP_KERNEL ( clz ) <nl> + / / The macros should be defined using constexprs . <nl> <nl> - / / If kRequiresSymbolicGradients is false , then no gradient ops are registered . <nl> - # define SHOULD_REGISTER_OP_GRADIENT kRequiresSymbolicGradients <nl> + # include " ops_to_register . h " <nl> <nl> + # if ( ! defined ( SHOULD_REGISTER_OP ) | | ! defined ( SHOULD_REGISTER_OP_GRADIENT ) | | \ <nl> + ! defined ( SHOULD_REGISTER_OP_KERNEL ) ) <nl> + static_assert ( false , " ops_to_register . h must define SHOULD_REGISTER macros " ) ; <nl> + # endif <nl> # else <nl> - # define SHOULD_REGISTER_OP_KERNEL ( filename ) true <nl> # define SHOULD_REGISTER_OP ( op ) true <nl> # define SHOULD_REGISTER_OP_GRADIENT true <nl> + # define SHOULD_REGISTER_OP_KERNEL ( clz ) true <nl> # endif <nl> <nl> # endif / / TENSORFLOW_FRAMEWORK_SELECTIVE_REGISTRATION_H_ <nl> mmm a / tensorflow / core / kernels / adjust_contrast_op_benchmark_test . cc <nl> ppp b / tensorflow / core / kernels / adjust_contrast_op_benchmark_test . cc <nl> static Graph * BM_AdjustContrast ( int batches , int width , int height ) { <nl> / / Benchmark results as of cl / 109478777 <nl> / / ( note that the definition has changed to perform no min / max or clamping , <nl> / / so a comparison to cl / 106323955 is inherently unfair ) <nl> - / / The GPU test ran with - c opt - - config = gcudacc - - copt = - mavx , CPU ran without <nl> - / / - - config = gcudacc because for some reason that killed throughput measurement . <nl> + / / The GPU test ran with - c opt - - config = cuda - - copt = - mavx , CPU ran without <nl> + / / - - config = cuda because for some reason that killed throughput measurement . <nl> / / CPU : Intel Haswell with HyperThreading ( 6 cores ) dL1 : 32KB dL2 : 256KB dL3 : 15MB <nl> / / GPU : Tesla K40m <nl> / / BM_AdjustContrast_cpu_1_299_299 179084 340186 2181 751 . 9M items / s <nl> mmm a / tensorflow / core / ops / array_ops . cc <nl> ppp b / tensorflow / core / ops / array_ops . cc <nl> REGISTER_OP ( " GatherNd " ) <nl> . Doc ( R " doc ( <nl> Gather values or slices from ` params ` according to ` indices ` . <nl> <nl> - ` params ` is a Tensor of rank ` R ` and ` indices ` is a Tensor of rank ` M ` . <nl> + ` params ` is a Tensor of rank ` P ` and ` indices ` is a Tensor of rank ` Q ` . <nl> <nl> ` indices ` must be integer tensor , containing indices into ` params ` . <nl> - It must be shape ` [ d_0 , . . . , d_N , R ] ` where ` 0 < R < = M ` . <nl> + It must be shape ` [ d_0 , . . . , d_ { Q - 2 } , K ] ` where ` 0 < K < = P ` . <nl> <nl> - The innermost dimension of ` indices ` ( with length ` R ` ) corresponds to <nl> - indices into elements ( if ` R = M ` ) or slices ( if ` R < M ` ) along the ` N ` th <nl> + The innermost dimension of ` indices ` ( with length ` K ` ) corresponds to <nl> + indices into elements ( if ` K = P ` ) or slices ( if ` K < P ` ) along the ` K ` th <nl> dimension of ` params ` . <nl> <nl> Produces an output tensor with shape <nl> <nl> - [ d_0 , . . . , d_ { n - 1 } , params . shape [ R ] , . . . , params . shape [ M - 1 ] ] . <nl> + ` ` ` <nl> + [ d_0 , . . . , d_ { Q - 2 } , params . shape [ K ] , . . . , params . shape [ P - 1 ] ] . <nl> + ` ` ` <nl> <nl> Some examples below . <nl> <nl> Batched indexing into a 3 - tensor : <nl> output = [ [ ' b0 ' , ' b1 ' ] , [ ' d0 ' , ' c1 ' ] ] <nl> ` ` ` <nl> <nl> - params : ` M - D ` . The tensor from which to gather values . <nl> - indices : ` ( N + 1 ) - D ` . Index tensor having shape ` [ d_0 , . . . , d_N , R ] ` . <nl> - output : ` ( N + M - R ) - D ` . Values from ` params ` gathered from indices given by <nl> + params : ` P - D ` . The tensor from which to gather values . <nl> + indices : ` Q - D ` . Index tensor having shape ` [ d_0 , . . . , d_ { Q - 2 } , K ] ` . <nl> + output : ` ( P + Q - K - 1 ) - D ` . Values from ` params ` gathered from indices given by <nl> ` indices ` . <nl> ) doc " ) ; <nl> <nl> mmm a / tensorflow / core / ops / ops . pbtxt <nl> ppp b / tensorflow / core / ops / ops . pbtxt <nl> op { <nl> name : " GatherNd " <nl> input_arg { <nl> name : " params " <nl> - description : " ` M - D ` . The tensor from which to gather values . " <nl> + description : " ` P - D ` . The tensor from which to gather values . " <nl> type_attr : " Tparams " <nl> } <nl> input_arg { <nl> name : " indices " <nl> - description : " ` ( N + 1 ) - D ` . Index tensor having shape ` [ d_0 , . . . , d_N , R ] ` . " <nl> + description : " ` Q - D ` . Index tensor having shape ` [ d_0 , . . . , d_ { Q - 2 } , K ] ` . " <nl> type_attr : " Tindices " <nl> } <nl> output_arg { <nl> name : " output " <nl> - description : " ` ( N + M - R ) - D ` . Values from ` params ` gathered from indices given by \ n ` indices ` . " <nl> + description : " ` ( P + Q - K - 1 ) - D ` . Values from ` params ` gathered from indices given by \ n ` indices ` . " <nl> type_attr : " Tparams " <nl> } <nl> attr { <nl> op { <nl> } <nl> } <nl> summary : " Gather values or slices from ` params ` according to ` indices ` . " <nl> - description : " ` params ` is a Tensor of rank ` R ` and ` indices ` is a Tensor of rank ` M ` . \ n \ n ` indices ` must be integer tensor , containing indices into ` params ` . \ nIt must be shape ` [ d_0 , . . . , d_N , R ] ` where ` 0 < R < = M ` . \ n \ nThe innermost dimension of ` indices ` ( with length ` R ` ) corresponds to \ nindices into elements ( if ` R = M ` ) or slices ( if ` R < M ` ) along the ` N ` th \ ndimension of ` params ` . \ n \ nProduces an output tensor with shape \ n \ n [ d_0 , . . . , d_ { n - 1 } , params . shape [ R ] , . . . , params . shape [ M - 1 ] ] . \ n \ nSome examples below . \ n \ nSimple indexing into a matrix : \ n \ n ` ` ` python \ n indices = [ [ 0 , 0 ] , [ 1 , 1 ] ] \ n params = [ [ \ ' a \ ' , \ ' b \ ' ] , [ \ ' c \ ' , \ ' d \ ' ] ] \ n output = [ \ ' a \ ' , \ ' d \ ' ] \ n ` ` ` \ n \ nSlice indexing into a matrix : \ n \ n ` ` ` python \ n indices = [ [ 1 ] , [ 0 ] ] \ n params = [ [ \ ' a \ ' , \ ' b \ ' ] , [ \ ' c \ ' , \ ' d \ ' ] ] \ n output = [ [ \ ' c \ ' , \ ' d \ ' ] , [ \ ' a \ ' , \ ' b \ ' ] ] \ n ` ` ` \ n \ nIndexing into a 3 - tensor : \ n \ n ` ` ` python \ n indices = [ [ 1 ] ] \ n params = [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] , \ n [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n output = [ [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n \ n \ n indices = [ [ 0 , 1 ] , [ 1 , 0 ] ] \ n params = [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] , \ n [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n output = [ [ \ ' c0 \ ' , \ ' d0 \ ' ] , [ \ ' a1 \ ' , \ ' b1 \ ' ] ] \ n \ n \ n indices = [ [ 0 , 0 , 1 ] , [ 1 , 0 , 1 ] ] \ n params = [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] , \ n [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n output = [ \ ' b0 \ ' , \ ' b1 \ ' ] \ n ` ` ` \ n \ nBatched indexing into a matrix : \ n \ n ` ` ` python \ n indices = [ [ [ 0 , 0 ] ] , [ [ 0 , 1 ] ] ] \ n params = [ [ \ ' a \ ' , \ ' b \ ' ] , [ \ ' c \ ' , \ ' d \ ' ] ] \ n output = [ [ \ ' a \ ' ] , [ \ ' b \ ' ] ] \ n ` ` ` \ n \ nBatched slice indexing into a matrix : \ n \ n ` ` ` python \ n indices = [ [ [ 1 ] ] , [ [ 0 ] ] ] \ n params = [ [ \ ' a \ ' , \ ' b \ ' ] , [ \ ' c \ ' , \ ' d \ ' ] ] \ n output = [ [ [ \ ' c \ ' , \ ' d \ ' ] ] , [ [ \ ' a \ ' , \ ' b \ ' ] ] ] \ n ` ` ` \ n \ nBatched indexing into a 3 - tensor : \ n \ n ` ` ` python \ n indices = [ [ [ 1 ] ] , [ [ 0 ] ] ] \ n params = [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] , \ n [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n output = [ [ [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] , \ n [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] ] ] \ n \ n indices = [ [ [ 0 , 1 ] , [ 1 , 0 ] ] , [ [ 0 , 0 ] , [ 1 , 1 ] ] ] \ n params = [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] , \ n [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n output = [ [ [ \ ' c0 \ ' , \ ' d0 \ ' ] , [ \ ' a1 \ ' , \ ' b1 \ ' ] ] , \ n [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n \ n \ n indices = [ [ [ 0 , 0 , 1 ] , [ 1 , 0 , 1 ] ] , [ [ 0 , 1 , 1 ] , [ 1 , 1 , 0 ] ] ] \ n params = [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] , \ n [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n output = [ [ \ ' b0 \ ' , \ ' b1 \ ' ] , [ \ ' d0 \ ' , \ ' c1 \ ' ] ] \ n ` ` ` " <nl> + description : " ` params ` is a Tensor of rank ` P ` and ` indices ` is a Tensor of rank ` Q ` . \ n \ n ` indices ` must be integer tensor , containing indices into ` params ` . \ nIt must be shape ` [ d_0 , . . . , d_ { Q - 2 } , K ] ` where ` 0 < K < = P ` . \ n \ nThe innermost dimension of ` indices ` ( with length ` K ` ) corresponds to \ nindices into elements ( if ` K = P ` ) or slices ( if ` K < P ` ) along the ` K ` th \ ndimension of ` params ` . \ n \ nProduces an output tensor with shape \ n \ n ` ` ` \ n [ d_0 , . . . , d_ { Q - 2 } , params . shape [ K ] , . . . , params . shape [ P - 1 ] ] . \ n ` ` ` \ n \ nSome examples below . \ n \ nSimple indexing into a matrix : \ n \ n ` ` ` python \ n indices = [ [ 0 , 0 ] , [ 1 , 1 ] ] \ n params = [ [ \ ' a \ ' , \ ' b \ ' ] , [ \ ' c \ ' , \ ' d \ ' ] ] \ n output = [ \ ' a \ ' , \ ' d \ ' ] \ n ` ` ` \ n \ nSlice indexing into a matrix : \ n \ n ` ` ` python \ n indices = [ [ 1 ] , [ 0 ] ] \ n params = [ [ \ ' a \ ' , \ ' b \ ' ] , [ \ ' c \ ' , \ ' d \ ' ] ] \ n output = [ [ \ ' c \ ' , \ ' d \ ' ] , [ \ ' a \ ' , \ ' b \ ' ] ] \ n ` ` ` \ n \ nIndexing into a 3 - tensor : \ n \ n ` ` ` python \ n indices = [ [ 1 ] ] \ n params = [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] , \ n [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n output = [ [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n \ n \ n indices = [ [ 0 , 1 ] , [ 1 , 0 ] ] \ n params = [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] , \ n [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n output = [ [ \ ' c0 \ ' , \ ' d0 \ ' ] , [ \ ' a1 \ ' , \ ' b1 \ ' ] ] \ n \ n \ n indices = [ [ 0 , 0 , 1 ] , [ 1 , 0 , 1 ] ] \ n params = [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] , \ n [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n output = [ \ ' b0 \ ' , \ ' b1 \ ' ] \ n ` ` ` \ n \ nBatched indexing into a matrix : \ n \ n ` ` ` python \ n indices = [ [ [ 0 , 0 ] ] , [ [ 0 , 1 ] ] ] \ n params = [ [ \ ' a \ ' , \ ' b \ ' ] , [ \ ' c \ ' , \ ' d \ ' ] ] \ n output = [ [ \ ' a \ ' ] , [ \ ' b \ ' ] ] \ n ` ` ` \ n \ nBatched slice indexing into a matrix : \ n \ n ` ` ` python \ n indices = [ [ [ 1 ] ] , [ [ 0 ] ] ] \ n params = [ [ \ ' a \ ' , \ ' b \ ' ] , [ \ ' c \ ' , \ ' d \ ' ] ] \ n output = [ [ [ \ ' c \ ' , \ ' d \ ' ] ] , [ [ \ ' a \ ' , \ ' b \ ' ] ] ] \ n ` ` ` \ n \ nBatched indexing into a 3 - tensor : \ n \ n ` ` ` python \ n indices = [ [ [ 1 ] ] , [ [ 0 ] ] ] \ n params = [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] , \ n [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n output = [ [ [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] , \ n [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] ] ] \ n \ n indices = [ [ [ 0 , 1 ] , [ 1 , 0 ] ] , [ [ 0 , 0 ] , [ 1 , 1 ] ] ] \ n params = [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] , \ n [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n output = [ [ [ \ ' c0 \ ' , \ ' d0 \ ' ] , [ \ ' a1 \ ' , \ ' b1 \ ' ] ] , \ n [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n \ n \ n indices = [ [ [ 0 , 0 , 1 ] , [ 1 , 0 , 1 ] ] , [ [ 0 , 1 , 1 ] , [ 1 , 1 , 0 ] ] ] \ n params = [ [ [ \ ' a0 \ ' , \ ' b0 \ ' ] , [ \ ' c0 \ ' , \ ' d0 \ ' ] ] , \ n [ [ \ ' a1 \ ' , \ ' b1 \ ' ] , [ \ ' c1 \ ' , \ ' d1 \ ' ] ] ] \ n output = [ [ \ ' b0 \ ' , \ ' b1 \ ' ] , [ \ ' d0 \ ' , \ ' c1 \ ' ] ] \ n ` ` ` " <nl> } <nl> op { <nl> name : " GetSessionHandle " <nl> mmm a / tensorflow / g3doc / api_docs / python / array_ops . md <nl> ppp b / tensorflow / g3doc / api_docs / python / array_ops . md <nl> this operation will permute ` params ` accordingly . <nl> <nl> Gather values or slices from ` params ` according to ` indices ` . <nl> <nl> - ` params ` is a Tensor of rank ` R ` and ` indices ` is a Tensor of rank ` M ` . <nl> + ` params ` is a Tensor of rank ` P ` and ` indices ` is a Tensor of rank ` Q ` . <nl> <nl> ` indices ` must be integer tensor , containing indices into ` params ` . <nl> - It must be shape ` [ d_0 , . . . , d_N , R ] ` where ` 0 < R < = M ` . <nl> + It must be shape ` [ d_0 , . . . , d_ { Q - 2 } , K ] ` where ` 0 < K < = P ` . <nl> <nl> - The innermost dimension of ` indices ` ( with length ` R ` ) corresponds to <nl> - indices into elements ( if ` R = M ` ) or slices ( if ` R < M ` ) along the ` N ` th <nl> + The innermost dimension of ` indices ` ( with length ` K ` ) corresponds to <nl> + indices into elements ( if ` K = P ` ) or slices ( if ` K < P ` ) along the ` K ` th <nl> dimension of ` params ` . <nl> <nl> Produces an output tensor with shape <nl> <nl> - [ d_0 , . . . , d_ { n - 1 } , params . shape [ R ] , . . . , params . shape [ M - 1 ] ] . <nl> + ` ` ` <nl> + [ d_0 , . . . , d_ { Q - 2 } , params . shape [ K ] , . . . , params . shape [ P - 1 ] ] . <nl> + ` ` ` <nl> <nl> Some examples below . <nl> <nl> Batched indexing into a 3 - tensor : <nl> # # # # # Args : <nl> <nl> <nl> - * < b > ` params ` < / b > : A ` Tensor ` . ` M - D ` . The tensor from which to gather values . <nl> + * < b > ` params ` < / b > : A ` Tensor ` . ` P - D ` . The tensor from which to gather values . <nl> * < b > ` indices ` < / b > : A ` Tensor ` . Must be one of the following types : ` int32 ` , ` int64 ` . <nl> - ` ( N + 1 ) - D ` . Index tensor having shape ` [ d_0 , . . . , d_N , R ] ` . <nl> + ` Q - D ` . Index tensor having shape ` [ d_0 , . . . , d_ { Q - 2 } , K ] ` . <nl> * < b > ` name ` < / b > : A name for the operation ( optional ) . <nl> <nl> # # # # # Returns : <nl> <nl> A ` Tensor ` . Has the same type as ` params ` . <nl> - ` ( N + M - R ) - D ` . Values from ` params ` gathered from indices given by <nl> + ` ( P + Q - K - 1 ) - D ` . Values from ` params ` gathered from indices given by <nl> ` indices ` . <nl> <nl> <nl> mmm a / tensorflow / g3doc / api_docs / python / contrib . distributions . md <nl> ppp b / tensorflow / g3doc / api_docs / python / contrib . distributions . md <nl> Additional documentation from ` TransformedDistribution ` : <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> Additional documentation from ` TransformedDistribution ` : <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> Implements ` ( log o p o g ^ { - 1 } ) ( y ) + ( log o det o J o g ^ { - 1 } ) ( y ) ` , <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> Additional documentation from ` TransformedDistribution ` : <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> Implements ` p ( g ^ { - 1 } ( y ) ) det | J ( g ^ { - 1 } ( y ) ) | ` , where ` g ^ { - 1 } ` is the <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> Samples from the base distribution and then passes through <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> Additional documentation from ` TransformedDistribution ` : <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> mmm a / tensorflow / g3doc / api_docs / python / contrib . layers . md <nl> ppp b / tensorflow / g3doc / api_docs / python / contrib . layers . md <nl> can have speed penalty , specially in distributed settings . <nl> <nl> # # # ` tf . contrib . layers . convolution2d ( * args , * * kwargs ) ` { # convolution2d } <nl> <nl> - Adds a 2D convolution followed by an optional batch_norm layer . <nl> + Adds an N - D convolution followed by an optional batch_norm layer . <nl> <nl> - ` convolution2d ` creates a variable called ` weights ` , representing the <nl> - convolutional kernel , that is convolved with the ` inputs ` to produce a <nl> - ` Tensor ` of activations . If a ` normalizer_fn ` is provided ( such as <nl> - ` batch_norm ` ) , it is then applied . Otherwise , if ` normalizer_fn ` is <nl> - None and a ` biases_initializer ` is provided then a ` biases ` variable would be <nl> - created and added the activations . Finally , if ` activation_fn ` is not ` None ` , <nl> - it is applied to the activations as well . <nl> + It is required that 1 < = N < = 3 . <nl> + <nl> + ` convolution ` creates a variable called ` weights ` , representing the <nl> + convolutional kernel , that is convolved ( actually cross - correlated ) with the <nl> + ` inputs ` to produce a ` Tensor ` of activations . If a ` normalizer_fn ` is <nl> + provided ( such as ` batch_norm ` ) , it is then applied . Otherwise , if <nl> + ` normalizer_fn ` is None and a ` biases_initializer ` is provided then a ` biases ` <nl> + variable would be created and added the activations . Finally , if <nl> + ` activation_fn ` is not ` None ` , it is applied to the activations as well . <nl> <nl> - Performs a ' trous convolution with input stride equal to rate if rate is <nl> - greater than one . <nl> + Performs a ' trous convolution with input stride / dilation rate equal to ` rate ` <nl> + if a value > 1 for any dimension of ` rate ` is specified . In this case <nl> + ` stride ` values ! = 1 are not supported . <nl> <nl> # # # # # Args : <nl> <nl> <nl> - * < b > ` inputs ` < / b > : a 4 - D tensor of shape ` [ batch_size , height , width , channels ] ` if <nl> - ` data_format ` is ` NHWC ` , and ` [ batch_size , channels , height , width ] ` if <nl> - ` data_format ` is ` NCHW ` . <nl> + * < b > ` inputs ` < / b > : a Tensor of rank N + 2 of shape <nl> + ` [ batch_size ] + input_spatial_shape + [ in_channels ] ` if data_format does <nl> + not start with " NC " ( default ) , or <nl> + ` [ batch_size , in_channels ] + input_spatial_shape ` if data_format starts <nl> + with " NC " . <nl> * < b > ` num_outputs ` < / b > : integer , the number of output filters . <nl> - * < b > ` kernel_size ` < / b > : a list of length 2 ` [ kernel_height , kernel_width ] ` of <nl> - of the filters . Can be an int if both values are the same . <nl> - * < b > ` stride ` < / b > : a list of length 2 ` [ stride_height , stride_width ] ` . <nl> - Can be an int if both strides are the same . Note that presently <nl> - both strides must have the same value . <nl> - * < b > ` padding ` < / b > : one of ` VALID ` or ` SAME ` . <nl> - * < b > ` data_format ` < / b > : A string . ` NHWC ` ( default ) and ` NCHW ` are supported . <nl> - * < b > ` rate ` < / b > : integer . If less than or equal to 1 , a standard convolution is used . <nl> - If greater than 1 , than the a ' trous convolution is applied and ` stride ` <nl> - must be set to 1 , ` data_format ` must be set to ` NHWC ` . <nl> + * < b > ` kernel_size ` < / b > : a sequence of N positive integers specifying the spatial <nl> + dimensions of of the filters . Can be a single integer to specify the same <nl> + value for all spatial dimensions . <nl> + * < b > ` stride ` < / b > : a sequence of N positive integers specifying the stride at which to <nl> + compute output . Can be a single integer to specify the same value for all <nl> + spatial dimensions . Specifying any ` stride ` value ! = 1 is incompatible <nl> + with specifying any ` rate ` value ! = 1 . <nl> + * < b > ` padding ` < / b > : one of ` " VALID " ` or ` " SAME " ` . <nl> + * < b > ` data_format ` < / b > : A string or None . Specifies whether the channel dimension of <nl> + the ` input ` and output is the last dimension ( default , or if ` data_format ` <nl> + does not start with " NC " ) , or the second dimension ( if ` data_format ` <nl> + starts with " NC " ) . For N = 1 , the valid values are " NWC " ( default ) and <nl> + " NCW " . For N = 2 , the valid values are " NHWC " ( default ) and " NCHW " . For <nl> + N = 3 , currently the only valid value is " NDHWC " . <nl> + * < b > ` rate ` < / b > : a sequence of N positive integers specifying the dilation rate to use <nl> + for a ' trous convolution . Can be a single integer to specify the same <nl> + value for all spatial dimensions . Specifying any ` rate ` value ! = 1 is <nl> + incompatible with specifying any ` stride ` value ! = 1 . <nl> * < b > ` activation_fn ` < / b > : activation function , set to None to skip it and maintain <nl> a linear activation . <nl> * < b > ` normalizer_fn ` < / b > : normalization function to use instead of ` biases ` . If <nl> greater than one . <nl> # # # # # Raises : <nl> <nl> <nl> - * < b > ` ValueError ` < / b > : if ` data_format ` is neither ` NHWC ` nor ` NCHW ` . <nl> - * < b > ` ValueError ` < / b > : if ` rate ` is larger than one and ` data_format ` is ` NCHW ` . <nl> - * < b > ` ValueError ` < / b > : if both ` rate ` and ` stride ` are larger than one . <nl> + * < b > ` ValueError ` < / b > : if ` data_format ` is invalid . <nl> + * < b > ` ValueError ` < / b > : both ' rate ' and ` stride ` are not uniformly 1 . <nl> <nl> <nl> - - - <nl> mmm a / tensorflow / g3doc / api_docs / python / functions_and_classes / shard1 / tf . contrib . distributions . TransformedDistribution . md <nl> ppp b / tensorflow / g3doc / api_docs / python / functions_and_classes / shard1 / tf . contrib . distributions . TransformedDistribution . md <nl> Additional documentation from ` TransformedDistribution ` : <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> Additional documentation from ` TransformedDistribution ` : <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> Implements ` ( log o p o g ^ { - 1 } ) ( y ) + ( log o det o J o g ^ { - 1 } ) ( y ) ` , <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> Additional documentation from ` TransformedDistribution ` : <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> Implements ` p ( g ^ { - 1 } ( y ) ) det | J ( g ^ { - 1 } ( y ) ) | ` , where ` g ^ { - 1 } ` is the <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> Samples from the base distribution and then passes through <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> Additional documentation from ` TransformedDistribution ` : <nl> <nl> # # # # # < b > ` condition_kwargs ` < / b > : <nl> <nl> - * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> * < b > ` distribution_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the distribution . <nl> + * < b > ` bijector_kwargs ` < / b > : Python dictionary of arg names / values forwarded to the bijector . <nl> <nl> # # # # # Args : <nl> <nl> mmm a / tensorflow / g3doc / api_docs / python / functions_and_classes / shard2 / tf . gather_nd . md <nl> ppp b / tensorflow / g3doc / api_docs / python / functions_and_classes / shard2 / tf . gather_nd . md <nl> <nl> <nl> Gather values or slices from ` params ` according to ` indices ` . <nl> <nl> - ` params ` is a Tensor of rank ` R ` and ` indices ` is a Tensor of rank ` M ` . <nl> + ` params ` is a Tensor of rank ` P ` and ` indices ` is a Tensor of rank ` Q ` . <nl> <nl> ` indices ` must be integer tensor , containing indices into ` params ` . <nl> - It must be shape ` [ d_0 , . . . , d_N , R ] ` where ` 0 < R < = M ` . <nl> + It must be shape ` [ d_0 , . . . , d_ { Q - 2 } , K ] ` where ` 0 < K < = P ` . <nl> <nl> - The innermost dimension of ` indices ` ( with length ` R ` ) corresponds to <nl> - indices into elements ( if ` R = M ` ) or slices ( if ` R < M ` ) along the ` N ` th <nl> + The innermost dimension of ` indices ` ( with length ` K ` ) corresponds to <nl> + indices into elements ( if ` K = P ` ) or slices ( if ` K < P ` ) along the ` K ` th <nl> dimension of ` params ` . <nl> <nl> Produces an output tensor with shape <nl> <nl> - [ d_0 , . . . , d_ { n - 1 } , params . shape [ R ] , . . . , params . shape [ M - 1 ] ] . <nl> + ` ` ` <nl> + [ d_0 , . . . , d_ { Q - 2 } , params . shape [ K ] , . . . , params . shape [ P - 1 ] ] . <nl> + ` ` ` <nl> <nl> Some examples below . <nl> <nl> Batched indexing into a 3 - tensor : <nl> # # # # # Args : <nl> <nl> <nl> - * < b > ` params ` < / b > : A ` Tensor ` . ` M - D ` . The tensor from which to gather values . <nl> + * < b > ` params ` < / b > : A ` Tensor ` . ` P - D ` . The tensor from which to gather values . <nl> * < b > ` indices ` < / b > : A ` Tensor ` . Must be one of the following types : ` int32 ` , ` int64 ` . <nl> - ` ( N + 1 ) - D ` . Index tensor having shape ` [ d_0 , . . . , d_N , R ] ` . <nl> + ` Q - D ` . Index tensor having shape ` [ d_0 , . . . , d_ { Q - 2 } , K ] ` . <nl> * < b > ` name ` < / b > : A name for the operation ( optional ) . <nl> <nl> # # # # # Returns : <nl> <nl> A ` Tensor ` . Has the same type as ` params ` . <nl> - ` ( N + M - R ) - D ` . Values from ` params ` gathered from indices given by <nl> + ` ( P + Q - K - 1 ) - D ` . Values from ` params ` gathered from indices given by <nl> ` indices ` . <nl> <nl> mmm a / tensorflow / g3doc / api_docs / python / functions_and_classes / shard5 / tf . contrib . layers . convolution2d . md <nl> ppp b / tensorflow / g3doc / api_docs / python / functions_and_classes / shard5 / tf . contrib . layers . convolution2d . md <nl> <nl> # # # ` tf . contrib . layers . convolution2d ( * args , * * kwargs ) ` { # convolution2d } <nl> <nl> - Adds a 2D convolution followed by an optional batch_norm layer . <nl> + Adds an N - D convolution followed by an optional batch_norm layer . <nl> <nl> - ` convolution2d ` creates a variable called ` weights ` , representing the <nl> - convolutional kernel , that is convolved with the ` inputs ` to produce a <nl> - ` Tensor ` of activations . If a ` normalizer_fn ` is provided ( such as <nl> - ` batch_norm ` ) , it is then applied . Otherwise , if ` normalizer_fn ` is <nl> - None and a ` biases_initializer ` is provided then a ` biases ` variable would be <nl> - created and added the activations . Finally , if ` activation_fn ` is not ` None ` , <nl> - it is applied to the activations as well . <nl> + It is required that 1 < = N < = 3 . <nl> <nl> - Performs a ' trous convolution with input stride equal to rate if rate is <nl> - greater than one . <nl> + ` convolution ` creates a variable called ` weights ` , representing the <nl> + convolutional kernel , that is convolved ( actually cross - correlated ) with the <nl> + ` inputs ` to produce a ` Tensor ` of activations . If a ` normalizer_fn ` is <nl> + provided ( such as ` batch_norm ` ) , it is then applied . Otherwise , if <nl> + ` normalizer_fn ` is None and a ` biases_initializer ` is provided then a ` biases ` <nl> + variable would be created and added the activations . Finally , if <nl> + ` activation_fn ` is not ` None ` , it is applied to the activations as well . <nl> + <nl> + Performs a ' trous convolution with input stride / dilation rate equal to ` rate ` <nl> + if a value > 1 for any dimension of ` rate ` is specified . In this case <nl> + ` stride ` values ! = 1 are not supported . <nl> <nl> # # # # # Args : <nl> <nl> <nl> - * < b > ` inputs ` < / b > : a 4 - D tensor of shape ` [ batch_size , height , width , channels ] ` if <nl> - ` data_format ` is ` NHWC ` , and ` [ batch_size , channels , height , width ] ` if <nl> - ` data_format ` is ` NCHW ` . <nl> + * < b > ` inputs ` < / b > : a Tensor of rank N + 2 of shape <nl> + ` [ batch_size ] + input_spatial_shape + [ in_channels ] ` if data_format does <nl> + not start with " NC " ( default ) , or <nl> + ` [ batch_size , in_channels ] + input_spatial_shape ` if data_format starts <nl> + with " NC " . <nl> * < b > ` num_outputs ` < / b > : integer , the number of output filters . <nl> - * < b > ` kernel_size ` < / b > : a list of length 2 ` [ kernel_height , kernel_width ] ` of <nl> - of the filters . Can be an int if both values are the same . <nl> - * < b > ` stride ` < / b > : a list of length 2 ` [ stride_height , stride_width ] ` . <nl> - Can be an int if both strides are the same . Note that presently <nl> - both strides must have the same value . <nl> - * < b > ` padding ` < / b > : one of ` VALID ` or ` SAME ` . <nl> - * < b > ` data_format ` < / b > : A string . ` NHWC ` ( default ) and ` NCHW ` are supported . <nl> - * < b > ` rate ` < / b > : integer . If less than or equal to 1 , a standard convolution is used . <nl> - If greater than 1 , than the a ' trous convolution is applied and ` stride ` <nl> - must be set to 1 , ` data_format ` must be set to ` NHWC ` . <nl> + * < b > ` kernel_size ` < / b > : a sequence of N positive integers specifying the spatial <nl> + dimensions of of the filters . Can be a single integer to specify the same <nl> + value for all spatial dimensions . <nl> + * < b > ` stride ` < / b > : a sequence of N positive integers specifying the stride at which to <nl> + compute output . Can be a single integer to specify the same value for all <nl> + spatial dimensions . Specifying any ` stride ` value ! = 1 is incompatible <nl> + with specifying any ` rate ` value ! = 1 . <nl> + * < b > ` padding ` < / b > : one of ` " VALID " ` or ` " SAME " ` . <nl> + * < b > ` data_format ` < / b > : A string or None . Specifies whether the channel dimension of <nl> + the ` input ` and output is the last dimension ( default , or if ` data_format ` <nl> + does not start with " NC " ) , or the second dimension ( if ` data_format ` <nl> + starts with " NC " ) . For N = 1 , the valid values are " NWC " ( default ) and <nl> + " NCW " . For N = 2 , the valid values are " NHWC " ( default ) and " NCHW " . For <nl> + N = 3 , currently the only valid value is " NDHWC " . <nl> + * < b > ` rate ` < / b > : a sequence of N positive integers specifying the dilation rate to use <nl> + for a ' trous convolution . Can be a single integer to specify the same <nl> + value for all spatial dimensions . Specifying any ` rate ` value ! = 1 is <nl> + incompatible with specifying any ` stride ` value ! = 1 . <nl> * < b > ` activation_fn ` < / b > : activation function , set to None to skip it and maintain <nl> a linear activation . <nl> * < b > ` normalizer_fn ` < / b > : normalization function to use instead of ` biases ` . If <nl> greater than one . <nl> # # # # # Raises : <nl> <nl> <nl> - * < b > ` ValueError ` < / b > : if ` data_format ` is neither ` NHWC ` nor ` NCHW ` . <nl> - * < b > ` ValueError ` < / b > : if ` rate ` is larger than one and ` data_format ` is ` NCHW ` . <nl> - * < b > ` ValueError ` < / b > : if both ` rate ` and ` stride ` are larger than one . <nl> + * < b > ` ValueError ` < / b > : if ` data_format ` is invalid . <nl> + * < b > ` ValueError ` < / b > : both ' rate ' and ` stride ` are not uniformly 1 . <nl> <nl> mmm a / tensorflow / python / debug / session_debug_test . py <nl> ppp b / tensorflow / python / debug / session_debug_test . py <nl> <nl> <nl> import numpy as np <nl> from six . moves import xrange # pylint : disable = redefined - builtin <nl> + import tensorflow as tf <nl> <nl> from tensorflow . core . protobuf import config_pb2 <nl> from tensorflow . python . client import session <nl> <nl> from tensorflow . python . debug import debug_utils <nl> from tensorflow . python . framework import constant_op <nl> from tensorflow . python . framework import dtypes <nl> + from tensorflow . python . framework import ops <nl> from tensorflow . python . framework import test_util <nl> from tensorflow . python . ops import control_flow_ops <nl> from tensorflow . python . ops import math_ops <nl> def testDumpCausalityCheck ( self ) : <nl> partition_graphs = run_metadata . partition_graphs , <nl> validate = False ) <nl> <nl> + def testWatchingOutputSlotWithoutOutgoingEdge ( self ) : <nl> + " " " Test watching output slots not attached to any outgoing edges . " " " <nl> + <nl> + with session . Session ( ) as sess : <nl> + u_init_val = np . array ( [ [ 5 . 0 , 3 . 0 ] , [ - 1 . 0 , 0 . 0 ] ] ) <nl> + u = constant_op . constant ( u_init_val , shape = [ 2 , 2 ] , name = " u " ) <nl> + <nl> + # Create a control edge from a node with an output : From u to z . <nl> + # Node u will get executed only because of the control edge . The output <nl> + # tensor u : 0 is not attached to any outgoing edge in the graph . This test <nl> + # checks that the debugger can watch such a tensor . <nl> + with ops . control_dependencies ( [ u ] ) : <nl> + z = control_flow_ops . no_op ( name = " z " ) <nl> + <nl> + run_options = config_pb2 . RunOptions ( output_partition_graphs = True ) <nl> + debug_utils . watch_graph ( <nl> + run_options , <nl> + sess . graph , <nl> + debug_ops = [ " DebugIdentity " ] , <nl> + debug_urls = " file : / / % s " % self . _dump_root ) <nl> + <nl> + run_metadata = config_pb2 . RunMetadata ( ) <nl> + sess . run ( z , options = run_options , run_metadata = run_metadata ) <nl> + <nl> + dump = debug_data . DebugDumpDir ( <nl> + self . _dump_root , partition_graphs = run_metadata . partition_graphs ) <nl> + <nl> + # Assert that the DebugIdentity watch on u works properly . <nl> + self . assertEqual ( 1 , len ( dump . dumped_tensor_data ) ) <nl> + datum = dump . dumped_tensor_data [ 0 ] <nl> + self . assertEqual ( " u " , datum . node_name ) <nl> + self . assertEqual ( 0 , datum . output_slot ) <nl> + self . assertEqual ( " DebugIdentity " , datum . debug_op ) <nl> + self . assertAllClose ( [ [ 5 . 0 , 3 . 0 ] , [ - 1 . 0 , 0 . 0 ] ] , datum . get_tensor ( ) ) <nl> + <nl> + def testWatchingVariableUpdateOps ( self ) : <nl> + " " " Watch output slots on Variable - updating ops , with no emitted edges . " " " <nl> + <nl> + with session . Session ( ) as sess : <nl> + u_init = constant_op . constant ( 10 . 0 ) <nl> + u = variables . Variable ( u_init , name = " gdo / u " ) <nl> + v_init = constant_op . constant ( 20 . 0 ) <nl> + v = variables . Variable ( v_init , name = " gdo / v " ) <nl> + <nl> + w = math_ops . mul ( u , v , name = " gdo / w " ) <nl> + # gdo stands for GradientDescentOptimizer . <nl> + <nl> + train_op = tf . train . GradientDescentOptimizer ( learning_rate = 0 . 1 ) . minimize ( <nl> + w , name = " gdo / train " ) <nl> + <nl> + u . initializer . run ( ) <nl> + v . initializer . run ( ) <nl> + <nl> + run_options = config_pb2 . RunOptions ( output_partition_graphs = True ) <nl> + debug_utils . watch_graph ( <nl> + run_options , <nl> + sess . graph , <nl> + debug_ops = [ " DebugIdentity " ] , <nl> + debug_urls = " file : / / % s " % self . _dump_root ) <nl> + <nl> + run_metadata = config_pb2 . RunMetadata ( ) <nl> + sess . run ( train_op , options = run_options , run_metadata = run_metadata ) <nl> + <nl> + dump = debug_data . DebugDumpDir ( <nl> + self . _dump_root , partition_graphs = run_metadata . partition_graphs ) <nl> + <nl> + update_u_data = dump . watch_key_to_data ( <nl> + " gdo / train / update_gdo / u / ApplyGradientDescent : 0 : DebugIdentity " ) <nl> + self . assertEqual ( 1 , len ( update_u_data ) ) <nl> + <nl> + # Gradient descent on u : w = u * v , so dw / du = v . <nl> + # Updated value of u should be : <nl> + # 10 . 0 - learning_rate * v = 10 . 0 - 0 . 1 * 20 . 0 = 8 . 0 <nl> + self . assertAllClose ( 8 . 0 , update_u_data [ 0 ] . get_tensor ( ) ) <nl> + <nl> + update_v_data = dump . watch_key_to_data ( <nl> + " gdo / train / update_gdo / v / ApplyGradientDescent : 0 : DebugIdentity " ) <nl> + self . assertEqual ( 1 , len ( update_v_data ) ) <nl> + <nl> + # Gradient descent on u : w = u * v , so dw / dv = u . <nl> + # Updated value of u should be : <nl> + # 20 . 0 - learning_rate * u = 20 . 0 - 0 . 1 * 10 . 0 = 19 . 0 <nl> + self . assertAllClose ( 19 . 0 , update_v_data [ 0 ] . get_tensor ( ) ) <nl> + <nl> + # Verify that the Variables u and v are updated properly . <nl> + self . assertAllClose ( 8 . 0 , sess . run ( u ) ) <nl> + self . assertAllClose ( 19 . 0 , sess . run ( v ) ) <nl> + <nl> + def testWatchingUnconnectedOutputTensor ( self ) : <nl> + " " " Watch an output slot not emitting any edges . <nl> + <nl> + ( Not even control edges from the node . ) <nl> + " " " <nl> + <nl> + with session . Session ( ) as sess : <nl> + x_init = constant_op . constant ( [ 2 , 2 , 3 , 5 , 5 ] ) <nl> + x = variables . Variable ( x_init , name = " unconnected / x " ) <nl> + <nl> + # The UniqueOp ( tf . unique ) has two output slots . Use only slot 0 in the <nl> + # graph . Let the debugger watch the unused slot 1 . <nl> + unique_x , _ = tf . unique ( x , name = " unconnected / unique_x " ) <nl> + y = tf . add ( unique_x , [ 0 , 1 , 2 ] , name = " unconnected / y " ) <nl> + <nl> + x . initializer . run ( ) <nl> + <nl> + # Verify that only slot 0 of unique_x has recipients , while slot 1 of the <nl> + # same node does not have recipients . <nl> + unique_x_slot_0_recipients = [ ] <nl> + unique_x_slot_1_recipients = [ ] <nl> + for op in sess . graph . get_operations ( ) : <nl> + for inp in op . inputs : <nl> + if inp . name = = " unconnected / unique_x : 0 " : <nl> + unique_x_slot_0_recipients . append ( op . name ) <nl> + elif inp . name = = " unconnected / unique_x : 1 " : <nl> + unique_x_slot_1_recipients . append ( op . name ) <nl> + <nl> + self . assertEqual ( [ " unconnected / y " ] , unique_x_slot_0_recipients ) <nl> + self . assertEqual ( [ ] , unique_x_slot_1_recipients ) <nl> + <nl> + run_options = config_pb2 . RunOptions ( output_partition_graphs = True ) <nl> + debug_utils . watch_graph ( <nl> + run_options , <nl> + sess . graph , <nl> + debug_ops = [ " DebugIdentity " ] , <nl> + debug_urls = " file : / / % s " % self . _dump_root ) <nl> + <nl> + run_metadata = config_pb2 . RunMetadata ( ) <nl> + result = sess . run ( y , options = run_options , run_metadata = run_metadata ) <nl> + self . assertAllClose ( [ 2 , 4 , 7 ] , result ) <nl> + <nl> + dump = debug_data . DebugDumpDir ( <nl> + self . _dump_root , partition_graphs = run_metadata . partition_graphs ) <nl> + <nl> + # Assert that the connected slot ( slot 0 ) is dumped properly . <nl> + unique_x_slot_0_dumps = dump . watch_key_to_data ( <nl> + " unconnected / unique_x : 0 : DebugIdentity " ) <nl> + self . assertEqual ( 1 , len ( unique_x_slot_0_dumps ) ) <nl> + self . assertEqual ( " unconnected / unique_x " , <nl> + unique_x_slot_0_dumps [ 0 ] . node_name ) <nl> + self . assertEqual ( 0 , unique_x_slot_0_dumps [ 0 ] . output_slot ) <nl> + self . assertAllClose ( [ 2 , 3 , 5 ] , unique_x_slot_0_dumps [ 0 ] . get_tensor ( ) ) <nl> + <nl> + # Assert that the unconnected slot ( slot 1 ) is dumped properly . <nl> + unique_x_slot_1_dumps = dump . watch_key_to_data ( <nl> + " unconnected / unique_x : 1 : DebugIdentity " ) <nl> + self . assertEqual ( 1 , len ( unique_x_slot_1_dumps ) ) <nl> + self . assertEqual ( " unconnected / unique_x " , <nl> + unique_x_slot_1_dumps [ 0 ] . node_name ) <nl> + self . assertEqual ( 1 , unique_x_slot_1_dumps [ 0 ] . output_slot ) <nl> + self . assertAllClose ( [ 0 , 0 , 1 , 2 , 2 ] , <nl> + unique_x_slot_1_dumps [ 0 ] . get_tensor ( ) ) <nl> + <nl> <nl> if __name__ = = " __main__ " : <nl> googletest . main ( ) <nl> mmm a / tensorflow / python / tools / print_selective_registration_header . py <nl> ppp b / tensorflow / python / tools / print_selective_registration_header . py <nl> <nl> ' graphs ' , ' ' , <nl> ' Comma - separated list of paths to model files to be analyzed . ' ) <nl> <nl> - tf . app . flags . DEFINE_string ( ' default_ops ' , ' NoOp : NoOp , _Recv : RecvOp , _Send : SendOp ' , <nl> - ' Default operator : kernel pairs to always include ' <nl> - ' implementation for ' ) <nl> + tf . app . flags . DEFINE_string ( <nl> + ' default_ops ' , ' NoOp : NoOp , _Recv : RecvOp , _Send : SendOp ' , <nl> + ' Default operator : kernel pairs to always include implementation for . ' <nl> + ' Pass " all " to have all operators and kernels included ; note that this ' <nl> + ' should be used only when it is useful compared with simply not using ' <nl> + ' selective registration , as it can in some cases limit the effect of ' <nl> + ' compilation caches ' ) <nl> <nl> <nl> def get_ops_and_kernels ( proto_fileformat , proto_files , default_ops_str ) : <nl> def get_ops_and_kernels ( proto_fileformat , proto_files , default_ops_str ) : <nl> ' Warning : no kernel found for op % s ' % node_def . op , file = sys . stderr ) <nl> <nl> # Add default ops . <nl> - for s in default_ops_str . split ( ' , ' ) : <nl> - op , kernel = s . split ( ' : ' ) <nl> - op_and_kernel = ( op , kernel ) <nl> - if op_and_kernel not in ops : <nl> - ops . add ( op_and_kernel ) <nl> + if default_ops_str ! = ' all ' : <nl> + for s in default_ops_str . split ( ' , ' ) : <nl> + op , kernel = s . split ( ' : ' ) <nl> + op_and_kernel = ( op , kernel ) <nl> + if op_and_kernel not in ops : <nl> + ops . add ( op_and_kernel ) <nl> <nl> return list ( sorted ( ops ) ) <nl> <nl> <nl> - def print_header ( ops_and_kernels , ops ) : <nl> - " " " Prints a header for use with tensorflow SELECTIVE_REGISTRATION . " " " <nl> - print ( ' # ifndef OPS_TO_REGISTER ' ) <nl> - print ( ' # define OPS_TO_REGISTER ' ) <nl> - <nl> - print ( ' constexpr inline bool ShouldRegisterOp ( const char op [ ] ) { ' ) <nl> - print ( ' return false ' ) <nl> - for op in sorted ( ops ) : <nl> - print ( ' | | ( strcmp ( op , " % s " ) = = 0 ) ' % op ) <nl> - print ( ' ; ' ) <nl> - print ( ' } ' ) <nl> - <nl> - line = ' const char kNecessaryOpKernelClasses [ ] = " , " \ n ' <nl> - for _ , kernel_class in ops_and_kernels : <nl> - line + = ' " % s , " \ n ' % kernel_class <nl> - line + = ' ; ' <nl> - print ( line ) <nl> + def get_header ( ops_and_kernels , include_all_ops_and_kernels ) : <nl> + " " " Returns a header for use with tensorflow SELECTIVE_REGISTRATION . <nl> <nl> - print ( ' const bool kRequiresSymbolicGradients = % s ; ' % <nl> - ( ' true ' if ' SymbolicGradient ' in ops else ' false ' ) ) <nl> + Args : <nl> + ops_and_kernels : a set of ( op_name , kernel_class_name ) pairs to include . <nl> + include_all_ops_and_kernels : if True , ops_and_kernels is ignored and all op <nl> + kernels are included . <nl> <nl> - print ( ' # endif ' ) <nl> + Returns : <nl> + the string of the header that should be written as ops_to_register . h . <nl> + " " " <nl> + ops = set ( [ op for op , _ in ops_and_kernels ] ) <nl> + result_list = [ ] <nl> + <nl> + def append ( s ) : <nl> + result_list . append ( s ) <nl> + <nl> + append ( ' # ifndef OPS_TO_REGISTER ' ) <nl> + append ( ' # define OPS_TO_REGISTER ' ) <nl> + <nl> + if include_all_ops_and_kernels : <nl> + append ( ' # define SHOULD_REGISTER_OP ( op ) true ' ) <nl> + append ( ' # define SHOULD_REGISTER_OP_KERNEL ( clz ) true ' ) <nl> + append ( ' # define SHOULD_REGISTER_OP_GRADIENT true ' ) <nl> + else : <nl> + append ( ' constexpr inline bool ShouldRegisterOp ( const char op [ ] ) { ' ) <nl> + append ( ' return false ' ) <nl> + for op in sorted ( ops ) : <nl> + append ( ' | | ( strcmp ( op , " % s " ) = = 0 ) ' % op ) <nl> + append ( ' ; ' ) <nl> + append ( ' } ' ) <nl> + append ( ' # define SHOULD_REGISTER_OP ( op ) ShouldRegisterOp ( op ) ' ) <nl> + append ( ' ' ) <nl> + <nl> + line = ' const char kNecessaryOpKernelClasses [ ] = " , " \ n ' <nl> + for _ , kernel_class in ops_and_kernels : <nl> + line + = ' " % s , " \ n ' % kernel_class <nl> + line + = ' ; ' <nl> + append ( line ) <nl> + append ( ' # define SHOULD_REGISTER_OP_KERNEL ( clz ) ' <nl> + ' ( strstr ( kNecessaryOpKernelClasses , " , " clz " , " ) ! = nullptr ) ' ) <nl> + append ( ' ' ) <nl> + <nl> + append ( ' # define SHOULD_REGISTER_OP_GRADIENT ' + ( <nl> + ' true ' if ' SymbolicGradient ' in ops else ' false ' ) ) <nl> + <nl> + append ( ' # endif ' ) <nl> + return ' \ n ' . join ( result_list ) <nl> <nl> <nl> def main ( unused_argv ) : <nl> def main ( unused_argv ) : <nl> graphs = FLAGS . graphs . split ( ' , ' ) <nl> ops_and_kernels = get_ops_and_kernels ( FLAGS . proto_fileformat , graphs , <nl> FLAGS . default_ops ) <nl> - ops = set ( [ op for op , _ in ops_and_kernels ] ) <nl> - if not ops : <nl> + if not ops_and_kernels : <nl> print ( ' Error reading graph ! ' ) <nl> return 1 <nl> <nl> - print_header ( ops_and_kernels , ops ) <nl> + print ( get_header ( ops_and_kernels , FLAGS . default_ops = = ' all ' ) ) <nl> <nl> <nl> if __name__ = = ' __main__ ' : <nl> mmm a / tensorflow / python / tools / print_selective_registration_header_test . py <nl> ppp b / tensorflow / python / tools / print_selective_registration_header_test . py <nl> def testGetOps ( self ) : <nl> ] , <nl> ops_and_kernels ) <nl> <nl> + def testAll ( self ) : <nl> + default_ops = ' all ' <nl> + graphs = [ <nl> + text_format . Parse ( d , graph_pb2 . GraphDef ( ) ) <nl> + for d in [ GRAPH_DEF_TXT , GRAPH_DEF_TXT_2 ] <nl> + ] <nl> + ops_and_kernels = print_selective_registration_header . get_ops_and_kernels ( <nl> + ' rawproto ' , self . WriteGraphFiles ( graphs ) , default_ops ) <nl> + <nl> + header = print_selective_registration_header . get_header ( ops_and_kernels , <nl> + default_ops ) <nl> + self . assertListEqual ( <nl> + [ <nl> + ' # ifndef OPS_TO_REGISTER ' , # <nl> + ' # define OPS_TO_REGISTER ' , # <nl> + ' # define SHOULD_REGISTER_OP ( op ) true ' , # <nl> + ' # define SHOULD_REGISTER_OP_KERNEL ( clz ) true ' , # <nl> + ' # define SHOULD_REGISTER_OP_GRADIENT true ' , # <nl> + ' # endif ' <nl> + ] , <nl> + header . split ( ' \ n ' ) ) <nl> + <nl> <nl> if __name__ = = ' __main__ ' : <nl> tf . test . main ( ) <nl> mmm a / tensorflow / tensorflow . bzl <nl> ppp b / tensorflow / tensorflow . bzl <nl> def tf_cuda_library ( deps = None , cuda_deps = None , copts = None , * * kwargs ) : <nl> When the library is built with - - config = cuda : <nl> <nl> - both deps and cuda_deps are used as dependencies <nl> - - the gcudacc runtime is added as a dependency ( if necessary ) <nl> + - the cuda runtime is added as a dependency ( if necessary ) <nl> - The library additionally passes - DGOOGLE_CUDA = 1 to the list of copts <nl> <nl> Args : <nl> mmm a / tensorflow / tools / ci_build / install / install_bazel . sh <nl> ppp b / tensorflow / tools / ci_build / install / install_bazel . sh <nl> <nl> set - e <nl> <nl> # Select bazel version . <nl> - BAZEL_VERSION = " 0 . 3 . 1 " <nl> + BAZEL_VERSION = " 0 . 3 . 2 " <nl> <nl> # Install bazel . <nl> mkdir / bazel <nl>
|
Merge commit for internal changes
|
tensorflow/tensorflow
|
4446f7cc661842ce91ce8666940c66e5cbe178ca
|
2016-10-21T20:10:12Z
|
mmm a / xbmc / utils / log . cpp <nl> ppp b / xbmc / utils / log . cpp <nl> void LogGraphicsInfo ( ) <nl> else <nl> CLog : : Log ( LOGNOTICE , " GL_SHADING_LANGUAGE_VERSION = NULL " ) ; <nl> <nl> + / / GL_NVX_gpu_memory_info extension <nl> + # define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 <nl> + # define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 <nl> + # define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 <nl> + # define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A <nl> + # define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B <nl> + <nl> + if ( glewGetExtension ( " GL_NVX_gpu_memory_info " ) ) <nl> + { <nl> + GLint mem = 0 ; <nl> + <nl> + glGetIntegerv ( GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX , & mem ) ; <nl> + CLog : : Log ( LOGNOTICE , " GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX = % i " , mem ) ; <nl> + <nl> + / / this seems to be the amount of ram on the videocard <nl> + glGetIntegerv ( GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX , & mem ) ; <nl> + CLog : : Log ( LOGNOTICE , " GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX = % i " , mem ) ; <nl> + } <nl> + <nl> s = glGetString ( GL_EXTENSIONS ) ; <nl> if ( s ) <nl> CLog : : Log ( LOGNOTICE , " GL_EXTENSIONS = % s " , s ) ; <nl>
|
added : gpu memory information in the log using GL_NVX_gpu_memory_info ( when available ) , this might provide useful information when VDPAU is failing
|
xbmc/xbmc
|
10903db09a162e812023f7c0adbd0a08c811fe3e
|
2011-01-11T21:43:57Z
|
mmm a / Code / CryManaged / CESharp / Core / Camera . cs <nl> ppp b / Code / CryManaged / CESharp / Core / Camera . cs <nl> <nl> / / Copyright 2001 - 2016 Crytek GmbH / Crytek Group . All rights reserved . <nl> <nl> + using System . Runtime . CompilerServices ; <nl> using CryEngine . Common ; <nl> using CryEngine . Rendering ; <nl> <nl> public static Quaternion Rotation <nl> } <nl> } <nl> <nl> + / / / < summary > <nl> + / / / The amount of horizontal pixels this camera is currently rendering . <nl> + / / / < / summary > <nl> + public static int RenderWidth <nl> + { <nl> + get <nl> + { <nl> + var camera = Engine . System . GetViewCamera ( ) ; <nl> + return camera . GetViewSurfaceX ( ) ; <nl> + } <nl> + } <nl> + <nl> + / / / < summary > <nl> + / / / The amount of vertical pixels this camera is currently rendering . <nl> + / / / < / summary > <nl> + public static int RenderHeight <nl> + { <nl> + get <nl> + { <nl> + var camera = Engine . System . GetViewCamera ( ) ; <nl> + return camera . GetViewSurfaceZ ( ) ; <nl> + } <nl> + } <nl> + <nl> / / / < summary > <nl> / / / Gets or sets the field of view of the view camera in degrees . <nl> / / / < / summary > <nl> public static float FieldOfView <nl> { <nl> var camera = Engine . System . GetViewCamera ( ) ; <nl> <nl> - camera . SetFrustum ( Global . gEnv . pRenderer . GetWidth ( ) , Global . gEnv . pRenderer . GetHeight ( ) , MathHelpers . DegreesToRadians ( value ) ) ; <nl> + camera . SetFrustum ( camera . GetViewSurfaceX ( ) , camera . GetViewSurfaceZ ( ) , MathHelpers . DegreesToRadians ( value ) ) ; <nl> } <nl> } <nl> <nl> / / / < summary > <nl> - / / / Converts a screenpoint from screen - space to world - space . <nl> + / / / Converts a viewport point to a position in world - space . <nl> / / / < / summary > <nl> - / / / < param name = " x " > < / param > <nl> - / / / < param name = " y " > < / param > <nl> - / / / < returns > < / returns > <nl> - public static Vector3 Unproject ( int x , int y ) <nl> + / / / < param name = " x " > Horizontal viewport position . < / param > <nl> + / / / < param name = " y " > Vertical viewport position . < / param > <nl> + / / / < param name = " depth " > Depth of the viewport point . < / param > <nl> + / / / < param name = " position " > Position of the viewport point in world - space . < / param > <nl> + / / / < returns > < c > true < / c > if the viewport point could be converted , < c > false < / c > otherwise . < / returns > <nl> + public static bool ViewportPointToWorldPoint ( float x , float y , float depth , out Vector3 position ) <nl> + { <nl> + var camera = Engine . System . GetViewCamera ( ) ; <nl> + int width = camera . GetViewSurfaceX ( ) ; <nl> + int height = camera . GetViewSurfaceZ ( ) ; <nl> + int screenX = ( int ) ( width * x + 0 . 5f ) ; <nl> + int screenY = ( int ) ( height * y + 0 . 5f ) ; <nl> + <nl> + Vec3 result = new Vec3 ( ) ; <nl> + bool visible = camera . Unproject ( new Vec3 ( x , height - y , depth ) , result ) ; <nl> + position = result ; <nl> + return visible ; <nl> + } <nl> + <nl> + / / / < summary > <nl> + / / / Converts a viewport point to a position in world - space . <nl> + / / / < / summary > <nl> + / / / < param name = " viewportPoint " > Viewport point that will be converted . < / param > <nl> + / / / < param name = " depth " > Depth of the viewport point . < / param > <nl> + / / / < param name = " position " > Position of the viewport point in world - space . < / param > <nl> + / / / < returns > < c > true < / c > if the viewport point could be converted , < c > false < / c > otherwise . < / returns > <nl> + [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ] <nl> + public static bool ViewportPointToWorldPoint ( Vector2 viewportPoint , float depth , out Vector3 position ) <nl> { <nl> - return Global . gEnv . pRenderer . UnprojectFromScreen ( x , Renderer . ScreenHeight - y ) ; <nl> + return ViewportPointToWorldPoint ( viewportPoint . x , viewportPoint . y , depth , out position ) ; <nl> + } <nl> + <nl> + / / / < summary > <nl> + / / / Converts a viewport point to a direction in world - space . <nl> + / / / < / summary > <nl> + / / / < param name = " x " > Horizontal viewport position . < / param > <nl> + / / / < param name = " y " > Vertical viewport position . < / param > <nl> + / / / < param name = " direction " > Direction into world - space . < / param > <nl> + / / / < returns > < c > true < / c > if the viewport point could be converted , < c > false < / c > otherwise . < / returns > <nl> + public static bool ViewportPointToDirection ( float x , float y , out Vector3 direction ) <nl> + { <nl> + var camera = Engine . System . GetViewCamera ( ) ; <nl> + int width = camera . GetViewSurfaceX ( ) ; <nl> + int height = camera . GetViewSurfaceZ ( ) ; <nl> + int screenX = ( int ) ( width * x + 0 . 5f ) ; <nl> + int screenY = ( int ) ( height * y + 0 . 5f ) ; <nl> + <nl> + Vec3 result = new Vec3 ( ) ; <nl> + bool visible = camera . Unproject ( new Vec3 ( x , height - y , 1 ) , result ) ; <nl> + var position = result ; <nl> + direction = ( position - Position ) . Normalized ; <nl> + return visible ; <nl> + } <nl> + <nl> + / / / < summary > <nl> + / / / Converts a viewport point to a direction in world - space . <nl> + / / / < / summary > <nl> + / / / < param name = " viewportPoint " > Viewport point that will be converted . < / param > <nl> + / / / < param name = " direction " > Direction into world - space . < / param > <nl> + / / / < returns > < c > true < / c > if the viewport point could be converted , < c > false < / c > otherwise . < / returns > <nl> + [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ] <nl> + public static bool ViewportPointToDirection ( Vector2 viewportPoint , out Vector3 direction ) <nl> + { <nl> + return ViewportPointToDirection ( viewportPoint . x , viewportPoint . y , out direction ) ; <nl> + } <nl> + <nl> + / / / < summary > <nl> + / / / Converts a screen position to a position in world - space . <nl> + / / / < / summary > <nl> + / / / < param name = " x " > Horizontal position on the screen . < / param > <nl> + / / / < param name = " y " > Vertical position on the screen . < / param > <nl> + / / / < param name = " depth " > Depth of the screenpoint . < / param > <nl> + / / / < param name = " position " > Position of the screenpoint in world - space . < / param > <nl> + / / / < returns > < c > true < / c > if the screenpoint could be converted , < c > false < / c > otherwise . < / returns > <nl> + public static bool ScreenPointToWorldPoint ( int x , int y , float depth , out Vector3 position ) <nl> + { <nl> + var camera = Engine . System . GetViewCamera ( ) ; <nl> + Vec3 result = new Vec3 ( ) ; <nl> + bool visible = camera . Unproject ( new Vec3 ( x , camera . GetViewSurfaceZ ( ) - y , depth ) , result ) ; <nl> + position = result ; <nl> + return visible ; <nl> + } <nl> + <nl> + / / / < summary > <nl> + / / / Converts a screen position to a direction in world - space . <nl> + / / / < / summary > <nl> + / / / < param name = " x " > Horizontal position on the screen . < / param > <nl> + / / / < param name = " y " > Vertical position on the screen . < / param > <nl> + / / / < param name = " direction " > Direction into world - space . < / param > <nl> + / / / < returns > < c > true < / c > if the screenpoint could be converted , < c > false < / c > otherwise . < / returns > <nl> + public static bool ScreenPointToDirection ( int x , int y , out Vector3 direction ) <nl> + { <nl> + var camera = Engine . System . GetViewCamera ( ) ; <nl> + Vec3 result = new Vec3 ( ) ; <nl> + bool visible = camera . Unproject ( new Vec3 ( x , camera . GetViewSurfaceZ ( ) - y , 1 ) , result ) ; <nl> + var position = result ; <nl> + direction = ( position - Position ) . Normalized ; <nl> + return visible ; <nl> } <nl> <nl> / / / < summary > <nl> public static Vector3 Unproject ( int x , int y ) <nl> / / / < returns > < c > true < / c > , if the point is visible , < c > false < / c > otherwise . < / returns > <nl> / / / < param name = " position " > Position of the point in world - space . < / param > <nl> / / / < param name = " screenPosition " > Position of the point in the camera ' s screen - space . < / param > <nl> - public static bool ProjectToScreen ( Vector3 position , out Vector3 screenPosition ) <nl> + public static bool WorldPointToScreenPoint ( Vector3 position , out Vector3 screenPosition ) <nl> { <nl> - var camera = Global . gEnv . pSystem . GetViewCamera ( ) ; <nl> + var camera = Engine . System . GetViewCamera ( ) ; <nl> Vec3 result = new Vec3 ( ) ; <nl> var visible = camera . Project ( position , result ) ; <nl> screenPosition = result ; <nl> public static bool ProjectToScreen ( Vector3 position , out Vector3 screenPosition ) <nl> / / / < returns > < c > true < / c > , if the point is visible , < c > false < / c > otherwise . < / returns > <nl> / / / < param name = " position " > Position of the point in world - space . < / param > <nl> / / / < param name = " viewportPosition " > Position of the point in the camera ' s viewport - space . < / param > <nl> - public static bool ProjectToViewport ( Vector3 position , out Vector3 viewportPosition ) <nl> + public static bool WorldPointToViewportPoint ( Vector3 position , out Vector3 viewportPosition ) <nl> { <nl> - var camera = Global . gEnv . pSystem . GetViewCamera ( ) ; <nl> + var camera = Engine . System . GetViewCamera ( ) ; <nl> Vec3 result = new Vec3 ( ) ; <nl> var visible = camera . Project ( position , result ) ; <nl> viewportPosition = result ; <nl> public static bool ProjectToViewport ( Vector3 position , out Vector3 viewportPosit <nl> / / / < / summary > <nl> / / / < param name = " direction " > < / param > <nl> / / / < returns > < / returns > <nl> + [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ] <nl> public static Vector3 TransformDirection ( Vector3 direction ) <nl> { <nl> return Rotation * direction ; <nl> mmm a / Code / CryManaged / CESharp / Core / Engine . cs <nl> ppp b / Code / CryManaged / CESharp / Core / Engine . cs <nl> public static void Shutdown ( ) <nl> else <nl> { <nl> Console . ExecuteString ( " ed_disable_game_mode " , false , true ) ; <nl> - OnUnloadStart ( ) ; <nl> } <nl> } <nl> <nl> mmm a / Code / CryManaged / CESharp / Core / EntitySystem / EntityComponent . cs <nl> ppp b / Code / CryManaged / CESharp / Core / EntitySystem / EntityComponent . cs <nl> internal void SetEntity ( IntPtr entityHandle , uint id ) <nl> <nl> protected virtual void OnCollision ( CollisionEvent collisionEvent ) { } <nl> <nl> - private void OnCollisionInternal ( IntPtr sourceEntityPhysics , IntPtr targetEntityPhysics ) <nl> + private void OnCollisionInternal ( IntPtr sourceEntityPhysics , IntPtr targetEntityPhysics , Vector3 point , Vector3 normal , Vector3 ownVelocity , Vector3 otherVelocity , float ownMass , float otherMass , float penetrationDepth , float normImpulse , float radius , float decalMaxSize ) <nl> { <nl> - var collisionEvent = new CollisionEvent ( ) ; <nl> - collisionEvent . Source = new PhysicsObject ( new IPhysicalEntity ( sourceEntityPhysics , false ) ) ; <nl> - collisionEvent . Target = new PhysicsObject ( new IPhysicalEntity ( targetEntityPhysics , false ) ) ; <nl> + <nl> + var collisionEvent = new CollisionEvent ( ) <nl> + { <nl> + MaxDecalSize = decalMaxSize , <nl> + Normal = normal , <nl> + ResolvingImpulse = normImpulse , <nl> + PenetrationDepth = penetrationDepth , <nl> + Point = point , <nl> + Radius = radius , <nl> + Masses = new float [ ] { ownMass , otherMass } , <nl> + Velocities = new Vector3 [ ] { ownVelocity , otherVelocity } , <nl> + PhysicsObjects = new PhysicsObject [ ] <nl> + { <nl> + new PhysicsObject ( new IPhysicalEntity ( sourceEntityPhysics , false ) ) , <nl> + new PhysicsObject ( new IPhysicalEntity ( targetEntityPhysics , false ) ) <nl> + } <nl> + } ; <nl> OnCollision ( collisionEvent ) ; <nl> } <nl> <nl> mmm a / Code / CryManaged / CESharp / Core / EntitySystem / PhysicsEntity . cs <nl> ppp b / Code / CryManaged / CESharp / Core / EntitySystem / PhysicsEntity . cs <nl> <nl> namespace CryEngine . EntitySystem <nl> { <nl> / / / < summary > <nl> - / / / Contains the source and target object of a collision event . <nl> + / / / Contains the data a collision event . If the data is an array the first element will always be the < see cref = " EntityComponent " / > that received the < see cref = " EntityComponent . OnCollision ( CollisionEvent ) " / > call . <nl> / / / < / summary > <nl> public struct CollisionEvent <nl> { <nl> / / / < summary > <nl> - / / / The source object of the collision . <nl> + / / / The objects involved in the collision . The first element will always be the < see cref = " EntityComponent " / > that received the < see cref = " EntityComponent . OnCollision ( CollisionEvent ) " / > call . <nl> / / / < / summary > <nl> - public PhysicsObject Source { get ; set ; } <nl> + public PhysicsObject [ ] PhysicsObjects { get ; internal set ; } <nl> + <nl> + / / / < summary > <nl> + / / / Contact point in world space . <nl> + / / / < / summary > <nl> + public Vector3 Point { get ; internal set ; } <nl> + <nl> + / / / < summary > <nl> + / / / Contact point normal . <nl> + / / / < / summary > <nl> + public Vector3 Normal { get ; internal set ; } <nl> <nl> / / / < summary > <nl> - / / / The target object of the collision . <nl> + / / / Velocities at the contact point . <nl> + / / / < / summary > <nl> + public Vector3 [ ] Velocities { get ; internal set ; } <nl> + <nl> + / / / < summary > <nl> + / / / The mass of each < see cref = " PhysicsObject " / > . <nl> + / / / < / summary > <nl> + public float [ ] Masses { get ; internal set ; } <nl> + <nl> + / / / < summary > <nl> + / / / Contact ' s penetration depth . <nl> + / / / < / summary > <nl> + public float PenetrationDepth { get ; internal set ; } <nl> + <nl> + / / / < summary > <nl> + / / / Impulse applied by the solver to resolve the collision . <nl> + / / / < / summary > <nl> + public float ResolvingImpulse { get ; internal set ; } <nl> + <nl> + / / / < summary > <nl> + / / / Characteristic size of the contact area . <nl> + / / / < / summary > <nl> + public float Radius { get ; internal set ; } <nl> + <nl> + / / / < summary > <nl> + / / / Maximum allowed size of decals caused by this collision . <nl> / / / < / summary > <nl> - public PhysicsObject Target { get ; set ; } <nl> + public float MaxDecalSize { get ; internal set ; } <nl> } <nl> <nl> / / / < summary > <nl> public class PhysicsObject <nl> public PhysicalizationType PhysicsType { get ; set ; } = PhysicalizationType . None ; <nl> <nl> / / / < summary > <nl> - / / / Gets the Entity that this < see cref = " PhysicsObject " / > belongs to . <nl> + / / / Gets the Entity that this < see cref = " PhysicsObject " / > belongs to . <nl> + / / / It ' s possible for this to be null if the owner is not an Entity but a Brush or Terrain . <nl> / / / < / summary > <nl> public virtual Entity OwnerEntity <nl> { <nl> mmm a / Code / CryManaged / CESharp / Core / Input / Input . cs <nl> ppp b / Code / CryManaged / CESharp / Core / Input / Input . cs <nl> internal struct KeyState <nl> <nl> static Input ( ) <nl> { <nl> - Engine . StartReload + = UnloadListener ; <nl> - Engine . EndReload + = LoadListener ; <nl> + Engine . StartReload + = RemoveListener ; <nl> + Engine . EndReload + = AddListener ; <nl> } <nl> <nl> - private static void LoadListener ( ) <nl> + private static void AddListener ( ) <nl> { <nl> if ( _listener ! = null ) <nl> { <nl> - UnloadListener ( ) ; <nl> + RemoveListener ( ) ; <nl> } <nl> <nl> _listener = new InputListener ( ) ; <nl> _listener . OnInputReceived + = OnInput ; <nl> } <nl> <nl> - private static void UnloadListener ( ) <nl> + private static void RemoveListener ( ) <nl> { <nl> _listener ? . Dispose ( ) ; <nl> _listener = null ; <nl> private static void UnloadListener ( ) <nl> / / / < / summary > <nl> internal static void Initialize ( ) <nl> { <nl> - LoadListener ( ) ; <nl> + AddListener ( ) ; <nl> <nl> if ( _listener = = null ) <nl> { <nl> mmm a / Code / CryManaged / CESharp / Core / Input / Mouse . cs <nl> ppp b / Code / CryManaged / CESharp / Core / Input / Mouse . cs <nl> public static void HitScenes ( int x , int y ) <nl> } <nl> <nl> HitEntityId = 0 ; <nl> - var mouseDir = Camera . Unproject ( x , y ) ; <nl> - RaycastHit hit ; <nl> - if ( Physics . Raycast ( Camera . Position , mouseDir , 100 , out hit ) ) <nl> + if ( Camera . ScreenPointToDirection ( x , y , out Vector3 direction ) <nl> + & & Physics . Raycast ( Camera . Position , direction , 100 , out RaycastHit hit ) ) <nl> { <nl> HitEntityId = hit . EntityId ; <nl> _hitEntityUV = hit . UvPoint ; <nl> public static void HitScenes ( int x , int y ) <nl> _hitEntityUV . x = 0 ; <nl> _hitEntityUV . y = 0 ; <nl> } <nl> - <nl> } <nl> <nl> / / / < summary > <nl> mmm a / Code / CryManaged / CryMonoBridge / NativeComponents / EntityComponentFactory . cpp <nl> ppp b / Code / CryManaged / CryMonoBridge / NativeComponents / EntityComponentFactory . cpp <nl> void CManagedEntityComponentFactory : : CacheMethods ( bool isAbstract ) <nl> <nl> if ( ! m_pClass - > FindMethodWithDescInInheritedClasses ( " OnCollision ( CollisionEvent ) " , pEntityComponentClass ) . expired ( ) ) <nl> { <nl> - m_pCollisionMethod = pEntityComponentClass - > FindMethod ( " OnCollisionInternal " , 2 ) ; <nl> + m_pCollisionMethod = pEntityComponentClass - > FindMethod ( " OnCollisionInternal " , 12 ) ; <nl> if ( ! m_pCollisionMethod . expired ( ) ) <nl> { <nl> m_pCollisionMethod . lock ( ) - > GetSignatureDescription ( true , true ) ; <nl> mmm a / Code / CryManaged / CryMonoBridge / NativeComponents / ManagedEntityComponent . cpp <nl> ppp b / Code / CryManaged / CryMonoBridge / NativeComponents / ManagedEntityComponent . cpp <nl> void CManagedEntityComponent : : ProcessEvent ( const SEntityEvent & event ) <nl> case ENTITY_EVENT_COLLISION : <nl> { <nl> EventPhysCollision * pCollision = ( EventPhysCollision * ) event . nParam [ 0 ] ; <nl> + <nl> + / / Make sure all references to this entity are slotted in the first element of the arrays . <nl> + int entityIndex = pCollision - > pEntity [ 0 ] ! = m_pEntity - > GetPhysicalEntity ( ) ? 1 : 0 ; <nl> + int otherIndex = ( entityIndex + 1 ) % 2 ; <nl> <nl> - void * pParams [ 2 ] ; <nl> - pParams [ 0 ] = & pCollision - > pEntity [ 0 ] ; <nl> - pParams [ 1 ] = & pCollision - > pEntity [ 1 ] ; <nl> + void * pParams [ 12 ] ; <nl> + pParams [ 0 ] = & pCollision - > pEntity [ entityIndex ] ; / / sourceEntityPhysics <nl> + pParams [ 1 ] = & pCollision - > pEntity [ otherIndex ] ; / / targetEntityPhysics <nl> + pParams [ 2 ] = & pCollision - > pt ; / / point <nl> + pParams [ 3 ] = & pCollision - > n ; / / normal <nl> + pParams [ 4 ] = & pCollision - > vloc [ entityIndex ] ; / / ownVelocity <nl> + pParams [ 5 ] = & pCollision - > vloc [ otherIndex ] ; / / otherVelocity <nl> + pParams [ 6 ] = & pCollision - > mass [ entityIndex ] ; / / ownMass <nl> + pParams [ 7 ] = & pCollision - > mass [ otherIndex ] ; / / otherMass <nl> + pParams [ 8 ] = & pCollision - > penetration ; / / penetrationDepth <nl> + pParams [ 9 ] = & pCollision - > normImpulse ; / / normImpulse <nl> + pParams [ 10 ] = & pCollision - > radius ; / / radius <nl> + pParams [ 11 ] = & pCollision - > fDecalPlacementTestMaxSize ; / / decalMaxSize <nl> <nl> if ( std : : shared_ptr < CMonoMethod > pMethod = m_factory . m_pCollisionMethod . lock ( ) ) <nl> { <nl>
|
! XB ( C # ) Fixed UI input disabling in Sandbox after exiting GameMode .
|
CRYTEK/CRYENGINE
|
7eba2546f781a74e2877f75d3f05b0d725184feb
|
2018-02-05T15:43:50Z
|
mmm a / xbmc / windowing / X11 / CMakeLists . txt <nl> ppp b / xbmc / windowing / X11 / CMakeLists . txt <nl> <nl> set ( SOURCES GLContextEGL . cpp <nl> GLContextGLX . cpp <nl> GLContext . cpp <nl> + OSScreenSaverX11 . cpp <nl> WinEventsX11 . cpp <nl> WinSystemX11 . cpp <nl> WinSystemX11GLContext . cpp <nl> set ( SOURCES GLContextEGL . cpp <nl> set ( HEADERS GLContext . h <nl> GLContextEGL . h <nl> GLContextGLX . h <nl> + OSScreenSaverX11 . h <nl> WinEventsX11 . h <nl> WinSystemX11 . h <nl> WinSystemX11GLContext . h <nl> new file mode 100644 <nl> index 000000000000 . . 6fc4061845d1 <nl> mmm / dev / null <nl> ppp b / xbmc / windowing / X11 / OSScreenSaverX11 . cpp <nl> <nl> + / * <nl> + * Copyright ( C ) 2017 Team XBMC <nl> + * http : / / xbmc . org <nl> + * <nl> + * This Program is free software ; you can redistribute it and / or modify <nl> + * it under the terms of the GNU General Public License as published by <nl> + * the Free Software Foundation ; either version 2 , or ( at your option ) <nl> + * any later version . <nl> + * <nl> + * This Program is distributed in the hope that it will be useful , <nl> + * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + * GNU General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU General Public License <nl> + * along with XBMC ; see the file COPYING . If not , see <nl> + * < http : / / www . gnu . org / licenses / > . <nl> + * <nl> + * / <nl> + <nl> + # include " OSScreenSaverX11 . h " <nl> + <nl> + # include < cassert > <nl> + <nl> + COSScreenSaverX11 : : COSScreenSaverX11 ( Display * dpy ) <nl> + : m_dpy ( dpy ) , m_screensaverResetTimer ( std : : bind ( & COSScreenSaverX11 : : ResetScreenSaver , this ) ) <nl> + { <nl> + assert ( m_dpy ) ; <nl> + } <nl> + <nl> + void COSScreenSaverX11 : : Inhibit ( ) <nl> + { <nl> + / / disallow the screensaver by periodically calling XResetScreenSaver ( ) , <nl> + / / for some reason setting a 0 timeout with XSetScreenSaver doesn ' t work with gnome <nl> + m_screensaverResetTimer . Start ( 5000 , true ) ; <nl> + } <nl> + <nl> + void COSScreenSaverX11 : : Uninhibit ( ) <nl> + { <nl> + m_screensaverResetTimer . Stop ( true ) ; <nl> + } <nl> + <nl> + void COSScreenSaverX11 : : ResetScreenSaver ( ) <nl> + { <nl> + XResetScreenSaver ( m_dpy ) ; <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . f6eee36c2a06 <nl> mmm / dev / null <nl> ppp b / xbmc / windowing / X11 / OSScreenSaverX11 . h <nl> <nl> + / * <nl> + * Copyright ( C ) 2017 Team XBMC <nl> + * http : / / xbmc . org <nl> + * <nl> + * This Program is free software ; you can redistribute it and / or modify <nl> + * it under the terms of the GNU General Public License as published by <nl> + * the Free Software Foundation ; either version 2 , or ( at your option ) <nl> + * any later version . <nl> + * <nl> + * This Program is distributed in the hope that it will be useful , <nl> + * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + * GNU General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU General Public License <nl> + * along with XBMC ; see the file COPYING . If not , see <nl> + * < http : / / www . gnu . org / licenses / > . <nl> + * <nl> + * / <nl> + # pragma once <nl> + <nl> + # include < X11 / Xlib . h > <nl> + <nl> + # include " . . / OSScreenSaver . h " <nl> + # include " threads / Timer . h " <nl> + <nl> + class COSScreenSaverX11 : public KODI : : WINDOWING : : IOSScreenSaver <nl> + { <nl> + public : <nl> + COSScreenSaverX11 ( Display * dpy ) ; <nl> + void Inhibit ( ) override ; <nl> + void Uninhibit ( ) override ; <nl> + <nl> + private : <nl> + void ResetScreenSaver ( ) ; <nl> + <nl> + Display * m_dpy ; <nl> + CTimer m_screensaverResetTimer ; <nl> + } ; <nl> \ No newline at end of file <nl>
|
Add IOSScreenSaver implementation for X11
|
xbmc/xbmc
|
00987b3a2d2cc6c151c7c741749710d406556427
|
2017-06-27T07:33:33Z
|
mmm a / LinuxAddons / bin / generate_version_header_for_marlin <nl> ppp b / LinuxAddons / bin / generate_version_header_for_marlin <nl> echo " # define STRING_DISTRIBUTION_DATE " ` date ' + " % Y - % m - % d % H : % M " ' ` > > " $ OUTFILE " <nl> else <nl> BRANCH = " $ BRANCH " <nl> fi <nl> - VERSION = ` git describe - - tags - - first - parent 2 > / dev / null ` <nl> + VERSION = ` git describe - - tags - - first - parent 2 > / dev / null ` <nl> if [ " x $ VERSION " ! = " x " ] ; then <nl> - echo " # define BUILD_VERSION \ " $ VERSION \ " " | sed " s / - / $ BRANCH - / " > > " $ OUTFILE " <nl> + echo " # define SHORT_BUILD_VERSION \ " $ VERSION \ " " | sed " s / - . * / $ BRANCH \ " / " > > " $ OUTFILE " <nl> + echo " # define DETAILED_BUILD_VERSION \ " $ VERSION \ " " | sed " s / - / $ BRANCH - / " > > " $ OUTFILE " <nl> + else <nl> + VERSION = ` git describe - - tags - - first - parent - - always 2 > / dev / null ` <nl> + echo " # define SHORT_BUILD_VERSION \ " $ BRANCH \ " " > > " $ OUTFILE " <nl> + echo " # define DETAILED_BUILD_VERSION \ " $ { BRANCH } - $ VERSION \ " " > > " $ OUTFILE " <nl> fi <nl> - URL = ` git config - - local - - get remote . origin . url | sed " sx . * github . com : xhttps : / / github . com / x " | sed " sx \ . gitx / x " ` <nl> + URL = ` git config - - local - - get remote . origin . url | sed " sx . * github . com . xhttps : / / github . com / x " | sed " sx \ . gitx / x " ` <nl> if [ " x $ URL " ! = " x " ] ; then <nl> echo " # define SOURCE_CODE_URL \ " " $ URL " \ " " > > " $ OUTFILE " <nl> echo " / / Deprecated URL definition " > > " $ OUTFILE " <nl> mmm a / Marlin / Configuration . h <nl> ppp b / Marlin / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / Marlin_main . cpp <nl> ppp b / Marlin / Marlin_main . cpp <nl> void setup ( ) { <nl> MCUSR = 0 ; <nl> <nl> SERIAL_ECHOPGM ( MSG_MARLIN ) ; <nl> - SERIAL_ECHOLNPGM ( " " BUILD_VERSION ) ; <nl> + SERIAL_ECHOLNPGM ( " " SHORT_BUILD_VERSION ) ; <nl> <nl> # ifdef STRING_DISTRIBUTION_DATE <nl> # ifdef STRING_CONFIG_H_AUTHOR <nl> mmm a / Marlin / configurator / config / Configuration . h <nl> ppp b / Marlin / configurator / config / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / configurator / config / language . h <nl> ppp b / Marlin / configurator / config / language . h <nl> <nl> # define SOURCE_CODE_URL " https : / / github . com / MarlinFirmware / Marlin " <nl> # endif <nl> <nl> - # ifndef BUILD_VERSION <nl> - # define BUILD_VERSION " V1 ; Sprinter / grbl mashup for gen6 " <nl> + # ifndef DETAILED_BUILD_VERSION <nl> + # error BUILD_VERSION Information must be specified <nl> # endif <nl> <nl> # ifndef MACHINE_UUID <nl> <nl> # define MSG_INVALID_EXTRUDER " Invalid extruder " <nl> # define MSG_INVALID_SOLENOID " Invalid solenoid " <nl> # define MSG_ERR_NO_THERMISTORS " No thermistors - no temperature " <nl> - # define MSG_M115_REPORT " FIRMWARE_NAME : Marlin " BUILD_VERSION " SOURCE_CODE_URL : " SOURCE_CODE_URL " PROTOCOL_VERSION : " PROTOCOL_VERSION " MACHINE_TYPE : " MACHINE_NAME " EXTRUDER_COUNT : " STRINGIFY ( EXTRUDERS ) " UUID : " MACHINE_UUID " \ n " <nl> + # define MSG_M115_REPORT " FIRMWARE_NAME : Marlin " DETAILED_BUILD_VERSION " SOURCE_CODE_URL : " SOURCE_CODE_URL " PROTOCOL_VERSION : " PROTOCOL_VERSION " MACHINE_TYPE : " MACHINE_NAME " EXTRUDER_COUNT : " STRINGIFY ( EXTRUDERS ) " UUID : " MACHINE_UUID " \ n " <nl> # define MSG_COUNT_X " Count X : " <nl> # define MSG_ERR_KILLED " Printer halted . kill ( ) called ! " <nl> # define MSG_ERR_STOPPED " Printer stopped due to errors . Fix the error and use M999 to restart . ( Temperature is reset . Set it after restarting ) " <nl> mmm a / Marlin / example_configurations / Felix / Configuration . h <nl> ppp b / Marlin / example_configurations / Felix / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / Felix / Configuration_DUAL . h <nl> ppp b / Marlin / example_configurations / Felix / Configuration_DUAL . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / Hephestos / Configuration . h <nl> ppp b / Marlin / example_configurations / Hephestos / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / K8200 / Configuration . h <nl> ppp b / Marlin / example_configurations / K8200 / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( K8200 , CONSULitAS ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / RepRapWorld / Megatronics / Configuration . h <nl> ppp b / Marlin / example_configurations / RepRapWorld / Megatronics / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " RepRapWorld . com " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / RigidBot / Configuration . h <nl> ppp b / Marlin / example_configurations / RigidBot / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / SCARA / Configuration . h <nl> ppp b / Marlin / example_configurations / SCARA / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / WITBOX / Configuration . h <nl> ppp b / Marlin / example_configurations / WITBOX / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( bq Witbox ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / adafruit / ST7565 / Configuration . h <nl> ppp b / Marlin / example_configurations / adafruit / ST7565 / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / delta / biv2 . 5 / Configuration . h <nl> ppp b / Marlin / example_configurations / delta / biv2 . 5 / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / delta / generic / Configuration . h <nl> ppp b / Marlin / example_configurations / delta / generic / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / delta / kossel_mini / Configuration . h <nl> ppp b / Marlin / example_configurations / delta / kossel_mini / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / delta / kossel_pro / Configuration . h <nl> ppp b / Marlin / example_configurations / delta / kossel_pro / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / makibox / Configuration . h <nl> ppp b / Marlin / example_configurations / makibox / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / example_configurations / tvrrug / Round2 / Configuration . h <nl> ppp b / Marlin / example_configurations / tvrrug / Round2 / Configuration . h <nl> Here are some standard links for getting your machine calibrated : <nl> / / build by the user have been successfully uploaded into firmware . <nl> # define STRING_CONFIG_H_AUTHOR " ( none , default config ) " / / Who made the changes . <nl> # define SHOW_BOOTSCREEN <nl> - # define STRING_SPLASH_LINE1 BUILD_VERSION / / will be shown during bootup in line 1 <nl> + # define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION / / will be shown during bootup in line 1 <nl> / / # define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE / / will be shown during bootup in line 2 <nl> <nl> / / @ section machine <nl> mmm a / Marlin / language . h <nl> ppp b / Marlin / language . h <nl> <nl> # define SOURCE_CODE_URL " https : / / github . com / MarlinFirmware / Marlin " <nl> # endif <nl> <nl> - # ifndef BUILD_VERSION <nl> - # define BUILD_VERSION " V1 ; Sprinter / grbl mashup for gen6 " <nl> + # ifndef DETAILED_BUILD_VERSION <nl> + # error BUILD_VERSION Information must be specified <nl> # endif <nl> <nl> # ifndef MACHINE_UUID <nl> <nl> # define MSG_INVALID_EXTRUDER " Invalid extruder " <nl> # define MSG_INVALID_SOLENOID " Invalid solenoid " <nl> # define MSG_ERR_NO_THERMISTORS " No thermistors - no temperature " <nl> - # define MSG_M115_REPORT " FIRMWARE_NAME : Marlin " BUILD_VERSION " SOURCE_CODE_URL : " SOURCE_CODE_URL " PROTOCOL_VERSION : " PROTOCOL_VERSION " MACHINE_TYPE : " MACHINE_NAME " EXTRUDER_COUNT : " STRINGIFY ( EXTRUDERS ) " UUID : " MACHINE_UUID " \ n " <nl> + # define MSG_M115_REPORT " FIRMWARE_NAME : Marlin " DETAILED_BUILD_VERSION " SOURCE_CODE_URL : " SOURCE_CODE_URL " PROTOCOL_VERSION : " PROTOCOL_VERSION " MACHINE_TYPE : " MACHINE_NAME " EXTRUDER_COUNT : " STRINGIFY ( EXTRUDERS ) " UUID : " MACHINE_UUID " \ n " <nl> # define MSG_COUNT_X " Count X : " <nl> # define MSG_ERR_KILLED " Printer halted . kill ( ) called ! " <nl> # define MSG_ERR_STOPPED " Printer stopped due to errors . Fix the error and use M999 to restart . ( Temperature is reset . Set it after restarting ) " <nl>
|
Supply a VERSION in a short form for displays
|
MarlinFirmware/Marlin
|
b227d8c12880e407b28868e9ffcaed507558df9a
|
2015-08-03T13:21:09Z
|
mmm a / README . md <nl> ppp b / README . md <nl> Please see [ Getting Started ] ( https : / / github . com / IteratorAdvance / taichi / wiki / Get <nl> <nl> ! [ image ] ( https : / / github . com / IteratorAdvance / taichi_assets / raw / master / demos / snow . gif ) <nl> ! [ image ] ( https : / / github . com / IteratorAdvance / taichi_assets / raw / master / demos / smoke_cropped . gif ) <nl> + ! [ image ] ( https : / / github . com / IteratorAdvance / taichi_assets / raw / master / demos / microfacet . gif ) <nl> ! [ image ] ( https : / / github . com / IteratorAdvance / taichi_assets / raw / master / demos / paper - cut . png ) <nl> <nl> # # Create your world with Taichi <nl>
|
Added microfacet . gif
|
taichi-dev/taichi
|
ee88dcccb41a564f350b91f487e3f62b59ef78ca
|
2017-01-27T12:28:33Z
|
mmm a / templates / cocos2dx_files . json <nl> ppp b / templates / cocos2dx_files . json <nl> <nl> " cocos / scripting / lua - bindings / auto / api / ControlSwitch . lua " , <nl> " cocos / scripting / lua - bindings / auto / api / Controller . lua " , <nl> " cocos / scripting / lua - bindings / auto / api / DelayTime . lua " , <nl> + " cocos / scripting / lua - bindings / auto / api / Device . lua " , <nl> " cocos / scripting / lua - bindings / auto / api / Director . lua " , <nl> " cocos / scripting / lua - bindings / auto / api / DisplayData . lua " , <nl> " cocos / scripting / lua - bindings / auto / api / DisplayManager . lua " , <nl>
|
Merge pull request from CocosRobot / update_cocosfiles_1411714811
|
cocos2d/cocos2d-x
|
a61352f624a0a11f02dcb857a564fbad5a4382fa
|
2014-09-26T07:09:29Z
|
mmm a / tensorflow / core / kernels / xent_op . cc <nl> ppp b / tensorflow / core / kernels / xent_op . cc <nl> class SoftmaxXentWithLogitsOp : public OpKernel { <nl> / / Try to reuse the logits_in buffer for the backprop output . <nl> OP_REQUIRES_OK ( context , context - > forward_input_or_allocate_output ( <nl> { 0 } , 1 , logits_in . shape ( ) , & back_out ) ) ; <nl> - functor : : XentFunctor < Device , T > functor ; <nl> - functor ( context - > eigen_device < Device > ( ) , logits_in . matrix < T > ( ) , <nl> - labels_in . matrix < T > ( ) , scratch . matrix < T > ( ) , loss_out - > vec < T > ( ) , <nl> - back_out - > matrix < T > ( ) ) ; <nl> + if ( logits_in . dim_size ( 0 ) > 0 ) { <nl> + functor : : XentFunctor < Device , T > functor ; <nl> + functor ( context - > eigen_device < Device > ( ) , logits_in . matrix < T > ( ) , <nl> + labels_in . matrix < T > ( ) , scratch . matrix < T > ( ) , loss_out - > vec < T > ( ) , <nl> + back_out - > matrix < T > ( ) ) ; <nl> + } <nl> } <nl> } ; <nl> <nl> mmm a / tensorflow / python / kernel_tests / xent_op_test . py <nl> ppp b / tensorflow / python / kernel_tests / xent_op_test . py <nl> def testWrapper ( self ) : <nl> self . _testXentWrapper ( features , labels , dim = - 1 , use_gpu = False ) <nl> self . _testXentWrapper ( features , labels , dim = - 1 , use_gpu = True ) <nl> <nl> + def testZeroDimension ( self ) : <nl> + features = np . zeros ( [ 0 , 2 , 4 ] ) . astype ( np . float32 ) <nl> + labels = np . zeros ( [ 0 , 2 , 4 ] ) . astype ( np . float32 ) <nl> + np_loss , _ = self . _npXent ( features , labels ) <nl> + with self . test_session ( use_gpu = True ) as sess : <nl> + loss = nn_ops . softmax_cross_entropy_with_logits ( <nl> + labels = labels , logits = features ) <nl> + tf_loss = sess . run ( loss ) <nl> + self . assertAllEqual ( np_loss , tf_loss ) <nl> + <nl> <nl> if __name__ = = " __main__ " : <nl> test . main ( ) <nl>
|
Fix crash on GPU ( out of GPU memory ) for ` softmax_cross_entropy_with_logits ` ( )
|
tensorflow/tensorflow
|
07e6ca0ac7cdfcb6105fb3410fc68355c04df1d5
|
2018-01-23T21:12:40Z
|
mmm a / modules / canbus / vehicle / lincoln / protocol / accel_6b . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / accel_6b . h <nl> class Accel6b : public ProtocolData { <nl> * @ brief parse received data <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> private : <nl> / * * <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / brake_61 . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / brake_61 . h <nl> class Brake61 : public ProtocolData { <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> * @ param timestamp the timestamp of input data <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> private : <nl> / * * <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / fuellevel_72 . cc <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / fuellevel_72 . cc <nl> namespace lincoln { <nl> const int32_t Fuellevel72 : : ID = 0x72 ; <nl> <nl> void Fuellevel72 : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const { <nl> - car_status - > mutable_battery ( ) - > set_fuel_level ( fuel_level ( bytes , length ) ) ; <nl> + ChassisDetail * chassis_detail ) const { <nl> + chassis_detail - > mutable_battery ( ) - > set_fuel_level ( fuel_level ( bytes , length ) ) ; <nl> } <nl> <nl> double Fuellevel72 : : fuel_level ( const std : : uint8_t * bytes , <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / fuellevel_72 . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / fuellevel_72 . h <nl> class Fuellevel72 : public ProtocolData { <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> * @ param timestamp the timestamp of input data <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> private : <nl> / * * <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / gear_67 . cc <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / gear_67 . cc <nl> namespace lincoln { <nl> const int32_t Gear67 : : ID = 0x67 ; <nl> <nl> void Gear67 : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const { <nl> + ChassisDetail * chassis_detail ) const { <nl> int32_t gear = gear_state ( bytes , length ) ; <nl> switch ( gear ) { <nl> case 0x01 : <nl> - car_status - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_PARKING ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_PARKING ) ; <nl> break ; <nl> case 0x02 : <nl> - car_status - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_REVERSE ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_REVERSE ) ; <nl> break ; <nl> case 0x03 : <nl> - car_status - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_NEUTRAL ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_NEUTRAL ) ; <nl> break ; <nl> case 0x04 : <nl> - car_status - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_DRIVE ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_DRIVE ) ; <nl> break ; <nl> case 0x05 : <nl> - car_status - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_LOW ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_LOW ) ; <nl> break ; <nl> case 0x00 : <nl> - car_status - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_NONE ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_NONE ) ; <nl> break ; <nl> default : <nl> - car_status - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_INVALID ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_state ( Chassis : : GEAR_INVALID ) ; <nl> break ; <nl> } <nl> <nl> if ( is_driver_override ( bytes , length ) ) { <nl> / / last shift requested by driver <nl> - car_status - > mutable_gear ( ) - > set_is_shift_position_valid ( false ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_is_shift_position_valid ( false ) ; <nl> } else { <nl> / / last shift requested by - wire <nl> - car_status - > mutable_gear ( ) - > set_is_shift_position_valid ( true ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_is_shift_position_valid ( true ) ; <nl> } <nl> - car_status - > mutable_gear ( ) - > set_driver_override ( <nl> + chassis_detail - > mutable_gear ( ) - > set_driver_override ( <nl> is_driver_override ( bytes , length ) ) ; <nl> <nl> int32_t gear_cmd = reported_gear_cmd ( bytes , length ) ; <nl> switch ( gear_cmd ) { <nl> case 0x01 : <nl> - car_status - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_PARKING ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_PARKING ) ; <nl> break ; <nl> case 0x02 : <nl> - car_status - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_REVERSE ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_REVERSE ) ; <nl> break ; <nl> case 0x03 : <nl> - car_status - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_NEUTRAL ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_NEUTRAL ) ; <nl> break ; <nl> case 0x04 : <nl> - car_status - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_DRIVE ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_DRIVE ) ; <nl> break ; <nl> case 0x05 : <nl> - car_status - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_LOW ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_LOW ) ; <nl> break ; <nl> case 0x00 : <nl> - car_status - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_NONE ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_NONE ) ; <nl> break ; <nl> default : <nl> - car_status - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_INVALID ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_gear_cmd ( Chassis : : GEAR_INVALID ) ; <nl> break ; <nl> } <nl> <nl> - car_status - > mutable_gear ( ) - > set_canbus_fault ( is_canbus_fault ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_gear ( ) - > set_canbus_fault ( is_canbus_fault ( bytes , length ) ) ; <nl> } <nl> <nl> int32_t Gear67 : : gear_state ( const std : : uint8_t * bytes , int32_t length ) const { <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / gear_67 . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / gear_67 . h <nl> class Gear67 : public ProtocolData { <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> * @ param timestamp the timestamp of input data <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> / * * <nl> * @ brief get the gear state from byte array <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / gps_6d . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / gps_6d . h <nl> class Gps6d : public ProtocolData { <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> * @ param timestamp the timestamp of input data <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> / * * <nl> * @ brief get latitude from byte array <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / gps_6e . cc <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / gps_6e . cc <nl> namespace lincoln { <nl> const int32_t Gps6e : : ID = 0x6E ; <nl> <nl> void Gps6e : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const { <nl> - car_status - > mutable_basic ( ) - > set_year ( year ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_month ( month ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_day ( day ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_hours ( hours ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_minutes ( minutes ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_seconds ( seconds ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_compass_direction ( <nl> + ChassisDetail * chassis_detail ) const { <nl> + chassis_detail - > mutable_basic ( ) - > set_year ( year ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_month ( month ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_day ( day ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_hours ( hours ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_minutes ( minutes ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_seconds ( seconds ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_compass_direction ( <nl> compass_direction ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_pdop ( pdop ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_is_gps_fault ( is_gps_fault ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_is_inferred ( <nl> + chassis_detail - > mutable_basic ( ) - > set_pdop ( pdop ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_is_gps_fault ( is_gps_fault ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_is_inferred ( <nl> is_inferred_position ( bytes , length ) ) ; <nl> } <nl> <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / gps_6e . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / gps_6e . h <nl> class Gps6e : public ProtocolData { <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> * @ param timestamp the timestamp of input data <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> / * * <nl> * @ brief get year from byte array <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / gps_6f . cc <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / gps_6f . cc <nl> namespace lincoln { <nl> const int32_t Gps6f : : ID = 0x6F ; <nl> <nl> void Gps6f : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const { <nl> - car_status - > mutable_basic ( ) - > set_altitude ( altitude ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_heading ( heading ( bytes , length ) ) ; <nl> + ChassisDetail * chassis_detail ) const { <nl> + chassis_detail - > mutable_basic ( ) - > set_altitude ( altitude ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_heading ( heading ( bytes , length ) ) ; <nl> / / speed mph - > mps <nl> - car_status - > mutable_basic ( ) - > set_gps_speed ( speed ( bytes , length ) * 0 . 44704 ) ; <nl> - car_status - > mutable_basic ( ) - > set_hdop ( hdop ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_vdop ( vdop ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_gps_speed ( speed ( bytes , length ) * 0 . 44704 ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_hdop ( hdop ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_vdop ( vdop ( bytes , length ) ) ; <nl> switch ( fix_quality ( bytes , length ) ) { <nl> case 0 : <nl> - car_status - > mutable_basic ( ) - > set_quality ( BasicInfo : : FIX_NO ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_quality ( BasicInfo : : FIX_NO ) ; <nl> break ; <nl> case 1 : <nl> - car_status - > mutable_basic ( ) - > set_quality ( BasicInfo : : FIX_2D ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_quality ( BasicInfo : : FIX_2D ) ; <nl> break ; <nl> case 2 : <nl> - car_status - > mutable_basic ( ) - > set_quality ( BasicInfo : : FIX_3D ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_quality ( BasicInfo : : FIX_3D ) ; <nl> break ; <nl> default : <nl> - car_status - > mutable_basic ( ) - > set_quality ( BasicInfo : : FIX_INVALID ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_quality ( BasicInfo : : FIX_INVALID ) ; <nl> break ; <nl> } <nl> - car_status - > mutable_basic ( ) - > set_num_satellites ( <nl> + chassis_detail - > mutable_basic ( ) - > set_num_satellites ( <nl> num_satellites ( bytes , length ) ) ; <nl> } <nl> <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / gps_6f . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / gps_6f . h <nl> class Gps6f : public ProtocolData { <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> * @ param timestamp the timestamp of input data <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> / * * <nl> * @ brief get altitude from byte array <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / gyro_6c . cc <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / gyro_6c . cc <nl> namespace lincoln { <nl> const int32_t Gyro6c : : ID = 0x6C ; <nl> <nl> void Gyro6c : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const { <nl> + ChassisDetail * chassis_detail ) const { <nl> / / TODO <nl> - car_status - > mutable_vehicle_spd ( ) - > set_roll_rate ( roll_rate ( bytes , length ) ) ; <nl> - car_status - > mutable_vehicle_spd ( ) - > set_yaw_rate ( yaw_rate ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_roll_rate ( roll_rate ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_yaw_rate ( yaw_rate ( bytes , length ) ) ; <nl> / / why <nl> - car_status - > mutable_vehicle_spd ( ) - > set_is_yaw_rate_valid ( true ) ; <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_is_yaw_rate_valid ( true ) ; <nl> } <nl> <nl> double Gyro6c : : roll_rate ( const std : : uint8_t * bytes , int32_t length ) const { <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / gyro_6c . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / gyro_6c . h <nl> class Gyro6c : public ProtocolData { <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> * @ param timestamp the timestamp of input data <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> / * * <nl> * @ brief calculate the roll rate based on byte array . <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / misc_69 . cc <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / misc_69 . cc <nl> namespace lincoln { <nl> const int32_t Misc69 : : ID = 0x69 ; <nl> <nl> void Misc69 : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const { <nl> + ChassisDetail * chassis_detail ) const { <nl> int32_t turn_light_type = turn_signal_status ( bytes , length ) ; <nl> switch ( turn_light_type ) { <nl> case 0 : <nl> - car_status - > mutable_light ( ) - > set_turn_light_type ( Light : : TURN_LIGHT_OFF ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_turn_light_type ( Light : : TURN_LIGHT_OFF ) ; <nl> break ; <nl> case 1 : <nl> - car_status - > mutable_light ( ) - > set_turn_light_type ( Light : : TURN_LEFT_ON ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_turn_light_type ( Light : : TURN_LEFT_ON ) ; <nl> break ; <nl> case 2 : <nl> - car_status - > mutable_light ( ) - > set_turn_light_type ( Light : : TURN_RIGHT_ON ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_turn_light_type ( Light : : TURN_RIGHT_ON ) ; <nl> break ; <nl> case 3 : <nl> break ; <nl> void Misc69 : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> int32_t hi_beam_status = high_beam_status ( bytes , length ) ; <nl> switch ( hi_beam_status ) { <nl> case 0 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_lamp_type ( Light : : BEAM_NULL ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_lamp_type ( Light : : BEAM_NULL ) ; <nl> break ; <nl> case 1 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_lamp_type ( <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_lamp_type ( <nl> Light : : BEAM_FLASH_TO_PASS ) ; <nl> break ; <nl> case 2 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_lamp_type ( Light : : BEAM_HIGH ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_lamp_type ( Light : : BEAM_HIGH ) ; <nl> break ; <nl> case 3 : <nl> default : <nl> - car_status - > mutable_light ( ) - > set_lincoln_lamp_type ( Light : : BEAM_INVALID ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_lamp_type ( Light : : BEAM_INVALID ) ; <nl> break ; <nl> } <nl> <nl> void Misc69 : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> int32_t wiper = wiper_status ( bytes , length ) ; <nl> switch ( wiper ) { <nl> case 0 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_OFF ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_OFF ) ; <nl> break ; <nl> case 1 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_AUTO_OFF ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_AUTO_OFF ) ; <nl> break ; <nl> case 2 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_OFF_MOVING ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_OFF_MOVING ) ; <nl> break ; <nl> case 3 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_MANUAL_OFF ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_MANUAL_OFF ) ; <nl> break ; <nl> case 4 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_MANUAL_ON ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_MANUAL_ON ) ; <nl> break ; <nl> case 5 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_MANUAL_LOW ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_MANUAL_LOW ) ; <nl> break ; <nl> case 6 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_MANUAL_HIGH ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_MANUAL_HIGH ) ; <nl> break ; <nl> case 7 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_MIST_FLICK ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_MIST_FLICK ) ; <nl> break ; <nl> case 8 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_WASH ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_WASH ) ; <nl> break ; <nl> case 9 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_AUTO_LOW ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_AUTO_LOW ) ; <nl> break ; <nl> case 10 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_AUTO_HIGH ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_AUTO_HIGH ) ; <nl> break ; <nl> case 11 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( <nl> Light : : WIPER_COURTESY_WIPE ) ; <nl> break ; <nl> case 12 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_AUTO_ADJUST ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_AUTO_ADJUST ) ; <nl> break ; <nl> case 13 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_RESERVED ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_RESERVED ) ; <nl> break ; <nl> case 14 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_STALLED ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_STALLED ) ; <nl> break ; <nl> case 15 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_NO_DATA ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_wiper ( Light : : WIPER_NO_DATA ) ; <nl> break ; <nl> } <nl> <nl> int32_t ambient = ambient_light_status ( bytes , length ) ; <nl> switch ( ambient ) { <nl> case 0 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_ambient ( Light : : AMBIENT_DARK ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_ambient ( Light : : AMBIENT_DARK ) ; <nl> break ; <nl> case 1 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_ambient ( Light : : AMBIENT_LIGHT ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_ambient ( Light : : AMBIENT_LIGHT ) ; <nl> break ; <nl> case 2 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_ambient ( Light : : AMBIENT_TWILIGHT ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_ambient ( Light : : AMBIENT_TWILIGHT ) ; <nl> break ; <nl> case 3 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_ambient ( <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_ambient ( <nl> Light : : AMBIENT_TUNNEL_ON ) ; <nl> break ; <nl> case 4 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_ambient ( <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_ambient ( <nl> Light : : AMBIENT_TUNNEL_OFF ) ; <nl> break ; <nl> case 7 : <nl> - car_status - > mutable_light ( ) - > set_lincoln_ambient ( Light : : AMBIENT_NO_DATA ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_ambient ( Light : : AMBIENT_NO_DATA ) ; <nl> break ; <nl> default : <nl> - car_status - > mutable_light ( ) - > set_lincoln_ambient ( Light : : AMBIENT_INVALID ) ; <nl> + chassis_detail - > mutable_light ( ) - > set_lincoln_ambient ( Light : : AMBIENT_INVALID ) ; <nl> break ; <nl> } <nl> <nl> / / acc button related <nl> - car_status - > mutable_basic ( ) - > set_acc_on_button ( <nl> + chassis_detail - > mutable_basic ( ) - > set_acc_on_button ( <nl> is_acc_on_pressed ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_acc_off_button ( <nl> + chassis_detail - > mutable_basic ( ) - > set_acc_off_button ( <nl> is_acc_off_pressed ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_acc_res_button ( <nl> + chassis_detail - > mutable_basic ( ) - > set_acc_res_button ( <nl> is_acc_resume_pressed ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_acc_cancel_button ( <nl> + chassis_detail - > mutable_basic ( ) - > set_acc_cancel_button ( <nl> is_acc_cancel_pressed ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_acc_on_off_button ( <nl> + chassis_detail - > mutable_basic ( ) - > set_acc_on_off_button ( <nl> is_acc_on_or_off_pressed ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_acc_res_cancel_button ( <nl> + chassis_detail - > mutable_basic ( ) - > set_acc_res_cancel_button ( <nl> is_acc_resume_or_cancel_pressed ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_acc_inc_spd_button ( <nl> + chassis_detail - > mutable_basic ( ) - > set_acc_inc_spd_button ( <nl> is_acc_increment_set_speed_pressed ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_acc_dec_spd_button ( <nl> + chassis_detail - > mutable_basic ( ) - > set_acc_dec_spd_button ( <nl> is_acc_decrement_set_speed_pressed ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_acc_inc_gap_button ( <nl> + chassis_detail - > mutable_basic ( ) - > set_acc_inc_gap_button ( <nl> is_acc_increment_following_gap_pressed ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_acc_dec_gap_button ( <nl> + chassis_detail - > mutable_basic ( ) - > set_acc_dec_gap_button ( <nl> is_acc_decrement_following_gap_pressed ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_lka_button ( <nl> + chassis_detail - > mutable_basic ( ) - > set_lka_button ( <nl> is_lka_on_or_off_pressed ( bytes , length ) ) ; <nl> - car_status - > mutable_basic ( ) - > set_canbus_fault ( is_canbus_fault ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_basic ( ) - > set_canbus_fault ( is_canbus_fault ( bytes , length ) ) ; <nl> <nl> / / driver door <nl> if ( is_driver_door_open ( bytes , length ) ) { <nl> - car_status - > mutable_safety ( ) - > set_is_driver_car_door_close ( false ) ; <nl> + chassis_detail - > mutable_safety ( ) - > set_is_driver_car_door_close ( false ) ; <nl> } else { <nl> - car_status - > mutable_safety ( ) - > set_is_driver_car_door_close ( true ) ; <nl> + chassis_detail - > mutable_safety ( ) - > set_is_driver_car_door_close ( true ) ; <nl> } <nl> <nl> - car_status - > mutable_safety ( ) - > set_is_passenger_door_open ( <nl> + chassis_detail - > mutable_safety ( ) - > set_is_passenger_door_open ( <nl> is_passenger_door_open ( bytes , length ) ) ; <nl> - car_status - > mutable_safety ( ) - > set_is_rearleft_door_open ( <nl> + chassis_detail - > mutable_safety ( ) - > set_is_rearleft_door_open ( <nl> is_rear_left_door_open ( bytes , length ) ) ; <nl> - car_status - > mutable_safety ( ) - > set_is_rearright_door_open ( <nl> + chassis_detail - > mutable_safety ( ) - > set_is_rearright_door_open ( <nl> is_rear_right_door_open ( bytes , length ) ) ; <nl> - car_status - > mutable_safety ( ) - > set_is_hood_open ( is_hood_open ( bytes , length ) ) ; <nl> - car_status - > mutable_safety ( ) - > set_is_trunk_open ( is_trunk_open ( bytes , length ) ) ; <nl> - car_status - > mutable_safety ( ) - > set_is_passenger_detected ( <nl> + chassis_detail - > mutable_safety ( ) - > set_is_hood_open ( is_hood_open ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_safety ( ) - > set_is_trunk_open ( is_trunk_open ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_safety ( ) - > set_is_passenger_detected ( <nl> is_passenger_detected ( bytes , length ) ) ; <nl> - car_status - > mutable_safety ( ) - > set_is_passenger_airbag_enabled ( <nl> + chassis_detail - > mutable_safety ( ) - > set_is_passenger_airbag_enabled ( <nl> is_passenger_airbag_enabled ( bytes , length ) ) ; <nl> <nl> / / airbag ? driver airbag ? <nl> - / / car_status - > mutable_basic ( ) - > set_is_air_bag_deployed ( <nl> + / / chassis_detail - > mutable_basic ( ) - > set_is_air_bag_deployed ( <nl> / / is_passenger_airbag_enabled ( bytes , length ) ) ; <nl> <nl> / / driver buckled <nl> - car_status - > mutable_safety ( ) - > set_is_driver_buckled ( <nl> + chassis_detail - > mutable_safety ( ) - > set_is_driver_buckled ( <nl> is_driver_belt_buckled ( bytes , length ) ) ; <nl> - car_status - > mutable_safety ( ) - > set_is_passenger_buckled ( <nl> + chassis_detail - > mutable_safety ( ) - > set_is_passenger_buckled ( <nl> is_passenger_belt_buckled ( bytes , length ) ) ; <nl> <nl> / / has error ? , non - compatible <nl> - / / car_status - > mutable_safety ( ) - > set_has_error ( <nl> + / / chassis_detail - > mutable_safety ( ) - > set_has_error ( <nl> / / is_canbus_fault ( bytes , length ) ) ; <nl> } <nl> <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / misc_69 . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / misc_69 . h <nl> class Misc69 : public ProtocolData { <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> * @ param timestamp the timestamp of input data <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> / * * <nl> * @ brief calculate the turn signal status based on byte array . <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / steering_65 . cc <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / steering_65 . cc <nl> namespace lincoln { <nl> const int32_t Steering65 : : ID = 0x65 ; <nl> <nl> void Steering65 : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const { <nl> - car_status - > mutable_eps ( ) - > set_steering_angle ( steering_angle ( bytes , length ) ) ; <nl> + ChassisDetail * chassis_detail ) const { <nl> + chassis_detail - > mutable_eps ( ) - > set_steering_angle ( steering_angle ( bytes , length ) ) ; <nl> / / no steering angle speed <nl> <nl> - car_status - > mutable_eps ( ) - > set_steering_angle_cmd ( <nl> + chassis_detail - > mutable_eps ( ) - > set_steering_angle_cmd ( <nl> reported_steering_angle_cmd ( bytes , length ) ) ; <nl> / / ? <nl> - car_status - > mutable_eps ( ) - > set_is_steering_angle_valid ( true ) ; <nl> + chassis_detail - > mutable_eps ( ) - > set_is_steering_angle_valid ( true ) ; <nl> / / vehicle speed from steering , kph - > mps <nl> - car_status - > mutable_eps ( ) - > set_vehicle_speed ( vehicle_speed ( bytes , length ) / <nl> + chassis_detail - > mutable_eps ( ) - > set_vehicle_speed ( vehicle_speed ( bytes , length ) / <nl> 3 . 6 ) ; <nl> <nl> / / speed , as it has a higher accuracy <nl> / / kph - > mps <nl> - car_status - > mutable_vehicle_spd ( ) - > set_vehicle_spd ( <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_vehicle_spd ( <nl> vehicle_speed ( bytes , length ) / 3 . 6 ) ; <nl> - car_status - > mutable_vehicle_spd ( ) - > set_is_vehicle_spd_valid ( true ) ; <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_is_vehicle_spd_valid ( true ) ; <nl> <nl> - car_status - > mutable_eps ( ) - > set_epas_torque ( epas_torque ( bytes , length ) ) ; <nl> - car_status - > mutable_eps ( ) - > set_steering_enabled ( is_enabled ( bytes , length ) ) ; <nl> - car_status - > mutable_eps ( ) - > set_driver_override ( <nl> + chassis_detail - > mutable_eps ( ) - > set_epas_torque ( epas_torque ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_eps ( ) - > set_steering_enabled ( is_enabled ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_eps ( ) - > set_driver_override ( <nl> is_driver_override ( bytes , length ) ) ; <nl> - car_status - > mutable_eps ( ) - > set_driver_activity ( <nl> + chassis_detail - > mutable_eps ( ) - > set_driver_activity ( <nl> is_driver_activity ( bytes , length ) ) ; <nl> - car_status - > mutable_eps ( ) - > set_watchdog_fault ( <nl> + chassis_detail - > mutable_eps ( ) - > set_watchdog_fault ( <nl> is_watchdog_counter_fault ( bytes , length ) ) ; <nl> - car_status - > mutable_eps ( ) - > set_channel_1_fault ( <nl> + chassis_detail - > mutable_eps ( ) - > set_channel_1_fault ( <nl> is_channel_1_fault ( bytes , length ) ) ; <nl> - car_status - > mutable_eps ( ) - > set_channel_2_fault ( <nl> + chassis_detail - > mutable_eps ( ) - > set_channel_2_fault ( <nl> is_channel_2_fault ( bytes , length ) ) ; <nl> - car_status - > mutable_eps ( ) - > set_calibration_fault ( <nl> + chassis_detail - > mutable_eps ( ) - > set_calibration_fault ( <nl> is_calibration_fault ( bytes , length ) ) ; <nl> - car_status - > mutable_eps ( ) - > set_connector_fault ( <nl> + chassis_detail - > mutable_eps ( ) - > set_connector_fault ( <nl> is_connector_fault ( bytes , length ) ) ; <nl> - car_status - > mutable_check_response ( ) - > set_is_eps_online ( <nl> + chassis_detail - > mutable_check_response ( ) - > set_is_eps_online ( <nl> ! is_driver_override ( bytes , length ) ) ; <nl> } <nl> <nl> void Steering65 : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> const struct timeval & timestamp , <nl> - ChassisDetail * car_status ) const { <nl> - car_status - > mutable_eps ( ) - > set_timestamp_65 ( timestamp . tv_sec + <nl> + ChassisDetail * chassis_detail ) const { <nl> + chassis_detail - > mutable_eps ( ) - > set_timestamp_65 ( timestamp . tv_sec + <nl> timestamp . tv_usec / 1000000 . 0 ) ; <nl> - Parse ( bytes , length , car_status ) ; <nl> + Parse ( bytes , length , chassis_detail ) ; <nl> } <nl> <nl> double Steering65 : : steering_angle ( const std : : uint8_t * bytes , <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / steering_65 . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / steering_65 . h <nl> class Steering65 : public ProtocolData { <nl> * @ brief parse received data <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> / * <nl> * @ brief parse received data <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> * @ param timestamp the timestamp of input data <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> const struct timeval & timestamp , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> / * * <nl> * @ brief calculate steering angle based on byte array . <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / throttle_63 . cc <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / throttle_63 . cc <nl> namespace lincoln { <nl> const int32_t Throttle63 : : ID = 0x63 ; <nl> <nl> void Throttle63 : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const { <nl> - car_status - > mutable_gas ( ) - > set_throttle_input ( pedal_input ( bytes , length ) ) ; <nl> - car_status - > mutable_gas ( ) - > set_throttle_cmd ( pedal_cmd ( bytes , length ) ) ; <nl> - car_status - > mutable_gas ( ) - > set_throttle_output ( pedal_output ( bytes , length ) ) ; <nl> - car_status - > mutable_gas ( ) - > set_watchdog_source ( <nl> + ChassisDetail * chassis_detail ) const { <nl> + chassis_detail - > mutable_gas ( ) - > set_throttle_input ( pedal_input ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_gas ( ) - > set_throttle_cmd ( pedal_cmd ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_gas ( ) - > set_throttle_output ( pedal_output ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_gas ( ) - > set_watchdog_source ( <nl> watchdog_counter_source ( bytes , length ) ) ; <nl> - car_status - > mutable_gas ( ) - > set_throttle_enabled ( is_enabled ( bytes , length ) ) ; <nl> - car_status - > mutable_gas ( ) - > set_driver_override ( <nl> + chassis_detail - > mutable_gas ( ) - > set_throttle_enabled ( is_enabled ( bytes , length ) ) ; <nl> + chassis_detail - > mutable_gas ( ) - > set_driver_override ( <nl> is_driver_override ( bytes , length ) ) ; <nl> - car_status - > mutable_gas ( ) - > set_driver_activity ( <nl> + chassis_detail - > mutable_gas ( ) - > set_driver_activity ( <nl> is_driver_activity ( bytes , length ) ) ; <nl> - car_status - > mutable_gas ( ) - > set_watchdog_fault ( <nl> + chassis_detail - > mutable_gas ( ) - > set_watchdog_fault ( <nl> is_watchdog_counter_fault ( bytes , length ) ) ; <nl> - car_status - > mutable_gas ( ) - > set_channel_1_fault ( <nl> + chassis_detail - > mutable_gas ( ) - > set_channel_1_fault ( <nl> is_channel_1_fault ( bytes , length ) ) ; <nl> - car_status - > mutable_gas ( ) - > set_channel_2_fault ( <nl> + chassis_detail - > mutable_gas ( ) - > set_channel_2_fault ( <nl> is_channel_2_fault ( bytes , length ) ) ; <nl> - car_status - > mutable_gas ( ) - > set_connector_fault ( <nl> + chassis_detail - > mutable_gas ( ) - > set_connector_fault ( <nl> is_connector_fault ( bytes , length ) ) ; <nl> - car_status - > mutable_check_response ( ) - > set_is_vcu_online ( <nl> + chassis_detail - > mutable_check_response ( ) - > set_is_vcu_online ( <nl> ! is_driver_override ( bytes , length ) ) ; <nl> } <nl> <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / throttle_63 . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / throttle_63 . h <nl> class Throttle63 : public ProtocolData { <nl> * @ brief parse received data <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> / * * <nl> * @ brief calculate pedal input based on byte array . <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / throttleinfo_75 . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / throttleinfo_75 . h <nl> class Throttleinfo75 : public ProtocolData { <nl> * @ brief parse received data <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> / * * <nl> * @ brief calculate engine rpm based on byte array . <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / tirepressure_71 . cc <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / tirepressure_71 . cc <nl> namespace lincoln { <nl> const int32_t Tirepressure71 : : ID = 0x71 ; <nl> <nl> void Tirepressure71 : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const { <nl> - car_status - > mutable_safety ( ) - > set_front_left_tire_press ( <nl> + ChassisDetail * chassis_detail ) const { <nl> + chassis_detail - > mutable_safety ( ) - > set_front_left_tire_press ( <nl> front_left_tire ( bytes , length ) ) ; <nl> - car_status - > mutable_safety ( ) - > set_front_right_tire_press ( <nl> + chassis_detail - > mutable_safety ( ) - > set_front_right_tire_press ( <nl> front_right_tire ( bytes , length ) ) ; <nl> - car_status - > mutable_safety ( ) - > set_rear_left_tire_press ( <nl> + chassis_detail - > mutable_safety ( ) - > set_rear_left_tire_press ( <nl> rear_left_tire ( bytes , length ) ) ; <nl> - car_status - > mutable_safety ( ) - > set_rear_right_tire_press ( <nl> + chassis_detail - > mutable_safety ( ) - > set_rear_right_tire_press ( <nl> rear_right_tire ( bytes , length ) ) ; <nl> } <nl> <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / tirepressure_71 . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / tirepressure_71 . h <nl> class Tirepressure71 : public ProtocolData { <nl> * @ brief parse received data <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> private : <nl> / * * <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / version_7f . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / version_7f . h <nl> class Version7f : public ProtocolData { <nl> * @ brief parse received data <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> / * * <nl> * @ brief get module name based on byte array . <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / wheelspeed_6a . cc <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / wheelspeed_6a . cc <nl> namespace lincoln { <nl> const int32_t Wheelspeed6a : : ID = 0x6A ; <nl> <nl> void Wheelspeed6a : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const { <nl> + ChassisDetail * chassis_detail ) const { <nl> / / TODO <nl> <nl> / / how to set direction <nl> / / what is " valid " <nl> / / front left <nl> - car_status - > mutable_vehicle_spd ( ) - > set_wheel_spd_fl ( <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_wheel_spd_fl ( <nl> front_left_wheel_speed ( bytes , length ) ) ; <nl> - car_status - > mutable_vehicle_spd ( ) - > set_is_wheel_spd_fl_valid ( true ) ; <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_is_wheel_spd_fl_valid ( true ) ; <nl> / / front right <nl> - car_status - > mutable_vehicle_spd ( ) - > set_wheel_spd_fr ( <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_wheel_spd_fr ( <nl> front_right_wheel_speed ( bytes , length ) ) ; <nl> - car_status - > mutable_vehicle_spd ( ) - > set_is_wheel_spd_fr_valid ( true ) ; <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_is_wheel_spd_fr_valid ( true ) ; <nl> / / rear left <nl> - car_status - > mutable_vehicle_spd ( ) - > set_wheel_spd_rl ( <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_wheel_spd_rl ( <nl> rear_left_wheel_speed ( bytes , length ) ) ; <nl> - car_status - > mutable_vehicle_spd ( ) - > set_is_wheel_spd_rl_valid ( true ) ; <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_is_wheel_spd_rl_valid ( true ) ; <nl> / / rear right <nl> - car_status - > mutable_vehicle_spd ( ) - > set_wheel_spd_rr ( <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_wheel_spd_rr ( <nl> rear_right_wheel_speed ( bytes , length ) ) ; <nl> - car_status - > mutable_vehicle_spd ( ) - > set_is_wheel_spd_rr_valid ( true ) ; <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_is_wheel_spd_rr_valid ( true ) ; <nl> / * <nl> - ? ( rr ( bytes , length ) ) ; <nl> - ? ( rl ( bytes , length ) ) ; <nl> void Wheelspeed6a : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> <nl> void Wheelspeed6a : : Parse ( const std : : uint8_t * bytes , int32_t length , <nl> const struct timeval & timestamp , <nl> - ChassisDetail * car_status ) const { <nl> - car_status - > mutable_vehicle_spd ( ) - > set_timestamp_sec ( <nl> + ChassisDetail * chassis_detail ) const { <nl> + chassis_detail - > mutable_vehicle_spd ( ) - > set_timestamp_sec ( <nl> timestamp . tv_sec + timestamp . tv_usec / 1000000 . 0 ) ; <nl> - Parse ( bytes , length , car_status ) ; <nl> + Parse ( bytes , length , chassis_detail ) ; <nl> } <nl> <nl> double Wheelspeed6a : : front_left_wheel_speed ( const std : : uint8_t * bytes , <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / wheelspeed_6a . h <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / wheelspeed_6a . h <nl> class Wheelspeed6a : public ProtocolData { <nl> * @ brief parse received data <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> / * <nl> * @ brief parse received data <nl> * @ param bytes a pointer to the input bytes <nl> * @ param length the length of the input bytes <nl> * @ param timestamp the timestamp of input bytes <nl> - * @ param car_status the parsed car_status <nl> + * @ param chassis_detail the parsed chassis_detail <nl> * / <nl> virtual void Parse ( const std : : uint8_t * bytes , int32_t length , <nl> const struct timeval & timestamp , <nl> - ChassisDetail * car_status ) const ; <nl> + ChassisDetail * chassis_detail ) const ; <nl> <nl> / * * <nl> * @ brief calculate front left wheel speed based on byte array . <nl> mmm a / modules / canbus / vehicle / lincoln / protocol / wheelspeed_6a_test . cc <nl> ppp b / modules / canbus / vehicle / lincoln / protocol / wheelspeed_6a_test . cc <nl> TEST ( Wheelspeed6aTest , General ) { <nl> EXPECT_DOUBLE_EQ ( cd . vehicle_spd ( ) . wheel_spd_fr ( ) , 256 . 99 ) ; <nl> EXPECT_TRUE ( cd . vehicle_spd ( ) . is_wheel_spd_rr_valid ( ) ) ; <nl> EXPECT_DOUBLE_EQ ( cd . vehicle_spd ( ) . wheel_spd_fl ( ) , 251 . 85 ) ; <nl> - EXPECT_DOUBLE_EQ ( cd . vehicle_spd ( ) . timestamp_sec ( ) , 206158 . 430216 ) ; <nl> } <nl> <nl> } / / namespace lincoln <nl>
|
replace car_status by chassis_detail in canbus proto
|
ApolloAuto/apollo
|
9b7bb484bb588436eb9dc55a665d29a79444ca0a
|
2017-07-12T00:56:34Z
|
mmm a / . travis . yml <nl> ppp b / . travis . yml <nl> common_sources : & 1 <nl> language : cpp <nl> matrix : <nl> include : <nl> - - os : osx <nl> - osx_image : xcode10 <nl> - env : <nl> - - MATRIX_EVAL = " CC = clang & & CXX = clang + + & & PYTHON = python3 . 6 " <nl> - os : osx <nl> osx_image : xcode10 <nl> env : <nl> - MATRIX_EVAL = " CC = clang & & CXX = clang + + & & PYTHON = python3 . 7 " <nl> - os : linux <nl> - dist : trusty <nl> + dist : xenial <nl> addons : <nl> apt : <nl> sources : * 1 <nl> matrix : <nl> env : <nl> - MATRIX_EVAL = " CC = gcc - 5 & & CXX = g + + - 5 & & PYTHON = python3 . 5 " <nl> - os : linux <nl> - dist : trusty <nl> + dist : xenial <nl> addons : <nl> apt : <nl> sources : * 1 <nl> matrix : <nl> env : <nl> - MATRIX_EVAL = " CC = gcc - 6 & & CXX = g + + - 6 & & PYTHON = python3 . 5 " <nl> - os : linux <nl> - dist : trusty <nl> + dist : xenial <nl> addons : <nl> apt : <nl> sources : * 1 <nl> matrix : <nl> env : <nl> - MATRIX_EVAL = " CC = gcc - 6 & & CXX = g + + - 6 & & PYTHON = python3 . 6 " <nl> - os : linux <nl> - dist : trusty <nl> + dist : xenial <nl> + language : python <nl> + python : <nl> + - 3 . 7 <nl> addons : <nl> apt : <nl> sources : * 1 <nl> matrix : <nl> env : <nl> - MATRIX_EVAL = " CC = gcc - 6 & & CXX = g + + - 6 & & PYTHON = python3 . 7 " <nl> - os : linux <nl> - dist : trusty <nl> + dist : xenial <nl> addons : <nl> apt : <nl> sources : * 1 <nl> matrix : <nl> env : <nl> - MATRIX_EVAL = " CC = gcc - 7 & & CXX = g + + - 7 & & PYTHON = python3 . 5 " <nl> - os : linux <nl> - dist : trusty <nl> + dist : xenial <nl> addons : <nl> apt : <nl> sources : * 1 <nl> matrix : <nl> env : <nl> - MATRIX_EVAL = " CC = gcc - 7 & & CXX = g + + - 7 & & PYTHON = python3 . 6 " <nl> - os : linux <nl> - dist : trusty <nl> + dist : xenial <nl> + language : python <nl> + python : <nl> + - 3 . 7 <nl> addons : <nl> apt : <nl> sources : * 1 <nl> matrix : <nl> - g + + - 7 <nl> env : <nl> - MATRIX_EVAL = " CC = gcc - 7 & & CXX = g + + - 7 & & PYTHON = python3 . 7 " <nl> - - <nl> before_install : <nl> - eval " $ { MATRIX_EVAL } " <nl> - echo $ CXX <nl> script : <nl> <nl> env : <nl> global : <nl> - secure : ZfG0FCWsSFSkeHtwfdHy2wR + nAq / IIFyHyTsFIVjUQdui5k6P3szXCkVonabtmZVccZF + 8BXjedzwUfGw6cDY8DzzbBPC + rx4XxxuCh3ueCNfhyz + BmsnOMk20U5yBpiwHDmGSiO9jt0Tw4gPNhk / GegNT21f8nJyYzOjH4IONAby0AXDf35R7pFE3LlPEC / TsCoWEEY5 / U7r8N1UJChoK3m2rGsK3TVKLY1UQYT94Ytg2a3IgjneEybQB73823K9uIS2CXM77rWJWcjhM9lDBqOc + 2MoWdhVgpFst90s + 8sjpjGMbMBQYz089sP6FrvGm3kYlWQ9LQ / eVqSVIstNTf176mxA1vyqkLDcuYZ / VcR + P0hTLgEo4kURy + ghXOHcDGhZW5mSXsTI5rq2xQYs6zqnc + MCIJQTOqytMPVc04to / Y5q2dLqrByZvkqeGUafa3bS8bgBr7SjAjwW3xjnWFQc2QMWHLKFP / q7eUnr6jeY4R / YpKdjIf2v + Qs54toAOqQl5Enf7 + lYE + iPjU9UmHu / LliyEfIKkVWjajpRFBaF7jQMhsGby + 6MDxomZdzKlJpwsfisBLh1HOq65N0erLVXMtqsy0eMxX9zBoUqcANnb0kj8MY / GdkUdZnx09yyXiQU8N + 7BSETOIRxriVVGRjhcefyyaeyn5yS7oZ / kY = <nl> + secure : ZfG1FCWsSFSkeHtwfdHy2wR + nAq / IIFyHyTsFIVjUQdui5k6P3szXCkVonabtmZVccZF + 8BXjedzwUfGw6cDY8DzzbBPC + rx4XxxuCh3ueCNfhyz + BmsnOMk20U5yBpiwHDmGSiO9jt0Tw4gPNhk / GegNT21f8nJyYzOjH4IONAby0AXDf35R7pFE3LlPEC / TsCoWEEY5 / U7r8N1UJChoK3m2rGsK3TVKLY1UQYT94Ytg2a3IgjneEybQB73823K9uIS2CXM77rWJWcjhM9lDBqOc + 2MoWdhVgpFst90s + 8sjpjGMbMBQYz089sP6FrvGm3kYlWQ9LQ / eVqSVIstNTf176mxA1vyqkLDcuYZ / VcR + P0hTLgEo4kURy + ghXOHcDGhZW5mSXsTI5rq2xQYs6zqnc + MCIJQTOqytMPVc04to / Y5q2dLqrByZvkqeGUafa3bS8bgBr7SjAjwW3xjnWFQc2QMWHLKFP / q7eUnr6jeY4R / YpKdjIf2v + Qs54toAOqQl5Enf7 + lYE + iPjU9UmHu / LliyEfIKkVWjajpRFBaF7jQMhsGby + 6MDxomZdzKlJpwsfisBLh1HOq65N0erLVXMtqsy0eMxX9zBoUqcANnb0kj8MY / GdkUdZnx09yyXiQU8N + 7BSETOIRxriVVGRjhcefyyaeyn5yS7oZ / kY = <nl>
|
Update . travis . yml
|
taichi-dev/taichi
|
d7ebc939e5214f1eb5eedb0434b07707f91e86d5
|
2019-03-18T13:15:10Z
|
mmm a / xbmc / GUIInfoManager . cpp <nl> ppp b / xbmc / GUIInfoManager . cpp <nl> const infomap integer_bools [ ] = { { " isequal " , INTEGER_IS_EQUAL } , <nl> / / / _boolean_ , <nl> / / / Returns true if the player has an audio file . <nl> / / / } <nl> + / / / \ table_row3 { < b > ` Player . HasGame ` < / b > , <nl> + / / / \ anchor Player_HasGame <nl> + / / / _boolean_ , <nl> + / / / Returns true if the player has a game file . <nl> + / / / } <nl> / / / \ table_row3 { < b > ` Player . HasMedia ` < / b > , <nl> / / / \ anchor Player_HasMedia <nl> / / / _boolean_ , <nl> const infomap integer_bools [ ] = { { " isequal " , INTEGER_IS_EQUAL } , <nl> / / / Returns true if pvr channel preview is active ( used channel tag different <nl> / / / from played tag ) <nl> / / / } <nl> + / / / \ table_row3 { < b > ` Player . TempoEnabled ` < / b > , <nl> + / / / \ anchor Player_TempoEnabled <nl> + / / / _boolean_ , <nl> + / / / Returns true if player supports tempo ( i . e . speed up / down normal playback speed ) <nl> + / / / } <nl> + / / / \ table_row3 { < b > ` Player . IsTempo ` < / b > , <nl> + / / / \ anchor Player_IsTempo <nl> + / / / _boolean_ , <nl> + / / / Returns true if player has tempo ( i . e . is playing with a playback speed higher or <nl> + / / / lower than normal playback speed ) <nl> + / / / } <nl> + / / / \ table_row3 { < b > ` Player . PlaySpeed ` < / b > , <nl> + / / / \ anchor Player_PlaySpeed <nl> + / / / _string_ , <nl> + / / / Returns the player playback speed with the format % 1 . 2f ( 1 . 00 means normal <nl> + / / / playback speed ) . For Tempo , the default range is 0 . 80 - 1 . 50 ( it can be changed <nl> + / / / in advanced settings ) . If ` Player . PlaySpeed ` returns a value different from 1 . 00 <nl> + / / / and ` Player . IsTempo ` is false it means the player is in ff / rw mode . <nl> + / / / } <nl> + / / / \ table_row3 { < b > ` Player . HasResolutions ` < / b > , <nl> + / / / \ anchor Player_HasResolutions <nl> + / / / _boolean_ , <nl> + / / / Returns true if the player is allowed to switch resolution and refresh rate <nl> + / / / ( i . e . if whitelist modes are configured in Kodi ' s System / Display settings ) <nl> + / / / } <nl> + / / / \ table_row3 { < b > ` Player . HasPrograms ` < / b > , <nl> + / / / \ anchor Player_HasPrograms <nl> + / / / _boolean_ , <nl> + / / / Returns true if the media file being played has programs \ , i . e . groups of streams . <nl> + / / / Ex : if a media file has multiple streams ( quality \ , channels \ , etc ) a program represents <nl> + / / / a particular stream combo . <nl> + / / / } <nl> / / / \ table_row3 { < b > ` Player . FrameAdvance ` < / b > , <nl> / / / \ anchor Player_FrameAdvance <nl> / / / _boolean_ , <nl>
|
[ docs ] Add missing missing Player infolabels / boolean conditions
|
xbmc/xbmc
|
4068e730a5b802385a3e45a82c33ce958f4e18ac
|
2018-08-10T12:47:09Z
|
mmm a / Telegram / SourceFiles / history / history_media_types . cpp <nl> ppp b / Telegram / SourceFiles / history / history_media_types . cpp <nl> QSize HistoryWebPage : : countOptimalSize ( ) { <nl> <nl> if ( ! _openl & & ! _data - > url . isEmpty ( ) ) { <nl> const auto previewOfHiddenUrl = [ & ] { <nl> + const auto simplify = [ ] ( const QString & url ) { <nl> + auto result = url . toLower ( ) ; <nl> + if ( result . endsWith ( ' / ' ) ) { <nl> + result . chop ( 1 ) ; <nl> + } <nl> + const auto prefixes = { qstr ( " http : / / " ) , qstr ( " https : / / " ) } ; <nl> + for ( const auto & prefix : prefixes ) { <nl> + if ( result . startsWith ( prefix ) ) { <nl> + result = result . mid ( prefix . size ( ) ) ; <nl> + break ; <nl> + } <nl> + } <nl> + return result ; <nl> + } ; <nl> + const auto simplified = simplify ( _data - > url ) ; <nl> const auto full = _parent - > data ( ) - > originalText ( ) ; <nl> for ( const auto & entity : full . entities ) { <nl> - if ( entity . type ( ) = = EntityInTextCustomUrl <nl> - & & entity . data ( ) = = _data - > url ) { <nl> - return true ; <nl> + if ( entity . type ( ) ! = EntityInTextUrl ) { <nl> + continue ; <nl> + } <nl> + const auto link = full . text . mid ( <nl> + entity . offset ( ) , <nl> + entity . length ( ) ) ; <nl> + if ( simplify ( link ) = = simplified ) { <nl> + return false ; <nl> } <nl> } <nl> - return false ; <nl> + return true ; <nl> } ( ) ; <nl> _openl = previewOfHiddenUrl <nl> ? std : : make_shared < HiddenUrlClickHandler > ( _data - > url ) <nl>
|
Improve checks for a hidden webpage url .
|
telegramdesktop/tdesktop
|
a2b04c9d71191e32c162b757b3f7f603d828043b
|
2018-11-07T10:55:38Z
|
mmm a / cocos / renderer / CCGroupCommand . cpp <nl> ppp b / cocos / renderer / CCGroupCommand . cpp <nl> bool GroupCommandManager : : init ( ) <nl> int GroupCommandManager : : getGroupID ( ) <nl> { <nl> / / Reuse old id <nl> - for ( auto it = _groupMapping . begin ( ) ; it ! = _groupMapping . end ( ) ; + + it ) <nl> + if ( ! _unusedIDs . empty ( ) ) <nl> { <nl> - if ( ! it - > second ) <nl> - { <nl> - _groupMapping [ it - > first ] = true ; <nl> - return it - > first ; <nl> - } <nl> + int groupID = * _unusedIDs . rbegin ( ) ; <nl> + _unusedIDs . pop_back ( ) ; <nl> + _groupMapping [ groupID ] = true ; <nl> + return groupID ; <nl> } <nl> <nl> / / Create new ID <nl> int GroupCommandManager : : getGroupID ( ) <nl> void GroupCommandManager : : releaseGroupID ( int groupID ) <nl> { <nl> _groupMapping [ groupID ] = false ; <nl> + _unusedIDs . push_back ( groupID ) ; <nl> } <nl> <nl> GroupCommand : : GroupCommand ( ) <nl> mmm a / cocos / renderer / CCGroupCommand . h <nl> ppp b / cocos / renderer / CCGroupCommand . h <nl> <nl> # ifndef _CC_GROUPCOMMAND_H_ <nl> # define _CC_GROUPCOMMAND_H_ <nl> <nl> + # include < vector > <nl> # include < unordered_map > <nl> <nl> # include " base / CCRef . h " <nl> class GroupCommandManager : public Ref <nl> ~ GroupCommandManager ( ) ; <nl> bool init ( ) ; <nl> std : : unordered_map < int , bool > _groupMapping ; <nl> + std : : vector < int > _unusedIDs ; <nl> } ; <nl> <nl> class CC_DLL GroupCommand : public RenderCommand <nl>
|
Merge pull request from darkdukey / G17hao - patch - 12
|
cocos2d/cocos2d-x
|
6f537197726dd25a55c5efcf017b58a03dddadc0
|
2015-02-02T22:12:50Z
|
mmm a / programs / odbc - bridge / ODBCBlockInputStream . cpp <nl> ppp b / programs / odbc - bridge / ODBCBlockInputStream . cpp <nl> namespace <nl> assert_cast < ColumnString & > ( column ) . insert ( value . convert < String > ( ) ) ; <nl> break ; <nl> case ValueType : : vtDate : <nl> + { <nl> Poco : : DateTime date = value . convert < Poco : : DateTime > ( ) ; <nl> assert_cast < ColumnUInt16 & > ( column ) . insertValue ( UInt16 { LocalDate ( date . year ( ) , date . month ( ) , date . day ( ) ) . getDayNum ( ) } ) ; <nl> break ; <nl> + } <nl> case ValueType : : vtDateTime : <nl> + { <nl> Poco : : DateTime datetime = value . convert < Poco : : DateTime > ( ) ; <nl> assert_cast < ColumnUInt32 & > ( column ) . insertValue ( time_t { LocalDateTime ( <nl> datetime . year ( ) , datetime . month ( ) , datetime . day ( ) , datetime . hour ( ) , datetime . minute ( ) , datetime . second ( ) ) } ) ; <nl> break ; <nl> + } <nl> case ValueType : : vtUUID : <nl> assert_cast < ColumnUInt128 & > ( column ) . insert ( parse < UUID > ( value . convert < std : : string > ( ) ) ) ; <nl> break ; <nl>
|
Update ODBCBlockInputStream . cpp
|
ClickHouse/ClickHouse
|
8eccf680d8d6224134a6a9217255046cf4b8fb84
|
2020-11-26T04:11:34Z
|
mmm a / Makefile . am <nl> ppp b / Makefile . am <nl> sbin_PROGRAMS = \ <nl> bin / arango - password \ <nl> bin / arango - dfdb <nl> <nl> - # exclude arango - password from sources list <nl> + # exclude arango - password and arango - dfdb from sources list , otherwise make TAGS will fail <nl> bin_arango_password_SOURCES = <nl> + bin_arango_dfdb_SOURCES = <nl> <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> # # # @ brief / bin programs <nl> mmm a / Makefile . in <nl> ppp b / Makefile . in <nl> am__UnitTests_geo_suite_SOURCES_DIST = UnitTests / Cambridge / Runner . cpp \ <nl> @ ENABLE_BOOST_TEST_TRUE @ UnitTests / Cambridge / UnitTests_geo_suite - georeg . $ ( OBJEXT ) \ <nl> @ ENABLE_BOOST_TEST_TRUE @ arangod / GeoIndex / UnitTests_geo_suite - GeoIndex . $ ( OBJEXT ) <nl> UnitTests_geo_suite_OBJECTS = $ ( am_UnitTests_geo_suite_OBJECTS ) <nl> - bin_arango_dfdb_SOURCES = bin / arango - dfdb . c <nl> - bin_arango_dfdb_OBJECTS = bin / arango - dfdb . $ ( OBJEXT ) <nl> + am_bin_arango_dfdb_OBJECTS = <nl> + bin_arango_dfdb_OBJECTS = $ ( am_bin_arango_dfdb_OBJECTS ) <nl> bin_arango_dfdb_LDADD = $ ( LDADD ) <nl> am_bin_arango_password_OBJECTS = <nl> bin_arango_password_OBJECTS = $ ( am_bin_arango_password_OBJECTS ) <nl> SOURCES = $ ( lib_libarango_a_SOURCES ) $ ( lib_libarango_client_a_SOURCES ) \ <nl> $ ( lib_libarango_fe_a_SOURCES ) $ ( lib_libarango_mruby_a_SOURCES ) \ <nl> $ ( lib_libarango_v8_a_SOURCES ) \ <nl> $ ( UnitTests_basics_suite_SOURCES ) \ <nl> - $ ( UnitTests_geo_suite_SOURCES ) bin / arango - dfdb . c \ <nl> + $ ( UnitTests_geo_suite_SOURCES ) $ ( bin_arango_dfdb_SOURCES ) \ <nl> $ ( bin_arango_password_SOURCES ) $ ( bin_arangod_SOURCES ) \ <nl> $ ( bin_arangoimp_SOURCES ) $ ( bin_arangoirb_SOURCES ) \ <nl> $ ( bin_arangosh_SOURCES ) $ ( bin_zclient_SOURCES ) \ <nl> DIST_SOURCES = $ ( am__lib_libarango_a_SOURCES_DIST ) \ <nl> $ ( am__lib_libarango_mruby_a_SOURCES_DIST ) \ <nl> $ ( lib_libarango_v8_a_SOURCES ) \ <nl> $ ( am__UnitTests_basics_suite_SOURCES_DIST ) \ <nl> - $ ( am__UnitTests_geo_suite_SOURCES_DIST ) bin / arango - dfdb . c \ <nl> - $ ( bin_arango_password_SOURCES ) $ ( am__bin_arangod_SOURCES_DIST ) \ <nl> - $ ( bin_arangoimp_SOURCES ) $ ( am__bin_arangoirb_SOURCES_DIST ) \ <nl> - $ ( bin_arangosh_SOURCES ) $ ( bin_zclient_SOURCES ) \ <nl> - $ ( bin_zserver_SOURCES ) <nl> + $ ( am__UnitTests_geo_suite_SOURCES_DIST ) \ <nl> + $ ( bin_arango_dfdb_SOURCES ) $ ( bin_arango_password_SOURCES ) \ <nl> + $ ( am__bin_arangod_SOURCES_DIST ) $ ( bin_arangoimp_SOURCES ) \ <nl> + $ ( am__bin_arangoirb_SOURCES_DIST ) $ ( bin_arangosh_SOURCES ) \ <nl> + $ ( bin_zclient_SOURCES ) $ ( bin_zserver_SOURCES ) <nl> am__vpath_adj_setup = srcdirstrip = ` echo " $ ( srcdir ) " | sed ' s | . | . | g ' ` ; <nl> am__vpath_adj = case $ $ p in \ <nl> $ ( srcdir ) / * ) f = ` echo " $ $ p " | sed " s | ^ $ $ srcdirstrip / | | " ` ; ; \ <nl> AM_LDFLAGS = @ BOOST_LDFLAGS @ @ LIBEV_LDFLAGS @ @ MATH_LDFLAGS @ \ <nl> noinst_LIBRARIES = lib / libarango . a lib / libarango_v8 . a \ <nl> lib / libarango_fe . a lib / libarango_client . a $ ( am__append_8 ) <nl> <nl> - # exclude arango - password from sources list <nl> + # exclude arango - password and arango - dfdb from sources list , otherwise make TAGS will fail <nl> bin_arango_password_SOURCES = <nl> + bin_arango_dfdb_SOURCES = <nl> <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> # # # @ brief / etc data <nl> UnitTests / geo_suite $ ( EXEEXT ) : $ ( UnitTests_geo_suite_OBJECTS ) $ ( UnitTests_geo_sui <nl> bin / $ ( am__dirstamp ) : <nl> @ $ ( MKDIR_P ) bin <nl> @ : > bin / $ ( am__dirstamp ) <nl> - bin / $ ( DEPDIR ) / $ ( am__dirstamp ) : <nl> - @ $ ( MKDIR_P ) bin / $ ( DEPDIR ) <nl> - @ : > bin / $ ( DEPDIR ) / $ ( am__dirstamp ) <nl> - bin / arango - dfdb . $ ( OBJEXT ) : bin / $ ( am__dirstamp ) \ <nl> - bin / $ ( DEPDIR ) / $ ( am__dirstamp ) <nl> arangod / Actions / $ ( am__dirstamp ) : <nl> @ $ ( MKDIR_P ) arangod / Actions <nl> @ : > arangod / Actions / $ ( am__dirstamp ) <nl> mostlyclean - compile : <nl> - rm - f arangosh / V8Client / bin_arangosh - ImportHelper . $ ( OBJEXT ) <nl> - rm - f arangosh / V8Client / bin_arangosh - V8ClientConnection . $ ( OBJEXT ) <nl> - rm - f arangosh / V8Client / bin_arangosh - arangosh . $ ( OBJEXT ) <nl> - - rm - f bin / arango - dfdb . $ ( OBJEXT ) <nl> - rm - f lib / Admin / ApplicationAdminServer . $ ( OBJEXT ) <nl> - rm - f lib / Admin / RestAdminBaseHandler . $ ( OBJEXT ) <nl> - rm - f lib / Admin / RestAdminFeConfigurationHandler . $ ( OBJEXT ) <nl> distclean - compile : <nl> @ AMDEP_TRUE @ @ am__include @ @ am__quote @ arangosh / V8Client / $ ( DEPDIR ) / bin_arangosh - ImportHelper . Po @ am__quote @ <nl> @ AMDEP_TRUE @ @ am__include @ @ am__quote @ arangosh / V8Client / $ ( DEPDIR ) / bin_arangosh - V8ClientConnection . Po @ am__quote @ <nl> @ AMDEP_TRUE @ @ am__include @ @ am__quote @ arangosh / V8Client / $ ( DEPDIR ) / bin_arangosh - arangosh . Po @ am__quote @ <nl> - @ AMDEP_TRUE @ @ am__include @ @ am__quote @ bin / $ ( DEPDIR ) / arango - dfdb . Po @ am__quote @ <nl> @ AMDEP_TRUE @ @ am__include @ @ am__quote @ lib / Admin / $ ( DEPDIR ) / ApplicationAdminServer . Po @ am__quote @ <nl> @ AMDEP_TRUE @ @ am__include @ @ am__quote @ lib / Admin / $ ( DEPDIR ) / RestAdminBaseHandler . Po @ am__quote @ <nl> @ AMDEP_TRUE @ @ am__include @ @ am__quote @ lib / Admin / $ ( DEPDIR ) / RestAdminFeConfigurationHandler . Po @ am__quote @ <nl> distclean - generic : <nl> - rm - f arangoirb / MRClient / $ ( am__dirstamp ) <nl> - rm - f arangosh / V8Client / $ ( DEPDIR ) / $ ( am__dirstamp ) <nl> - rm - f arangosh / V8Client / $ ( am__dirstamp ) <nl> - - rm - f bin / $ ( DEPDIR ) / $ ( am__dirstamp ) <nl> - rm - f bin / $ ( am__dirstamp ) <nl> - rm - f lib / $ ( am__dirstamp ) <nl> - rm - f lib / Admin / $ ( DEPDIR ) / $ ( am__dirstamp ) <nl> clean - am : clean - binPROGRAMS clean - generic clean - local \ <nl> <nl> distclean : distclean - am <nl> - rm - f $ ( am__CONFIG_DISTCLEAN_FILES ) <nl> - - rm - rf PerfTests / $ ( DEPDIR ) UnitTests / $ ( DEPDIR ) UnitTests / Cambridge / $ ( DEPDIR ) UnitTests / Jutland / $ ( DEPDIR ) UnitTests / Philadelphia / $ ( DEPDIR ) arangod / Actions / $ ( DEPDIR ) arangod / Ahuacatl / $ ( DEPDIR ) arangod / BitIndexes / $ ( DEPDIR ) arangod / GeoIndex / $ ( DEPDIR ) arangod / HashIndex / $ ( DEPDIR ) arangod / IndexIterators / $ ( DEPDIR ) arangod / IndexOperators / $ ( DEPDIR ) arangod / MRServer / $ ( DEPDIR ) arangod / PriorityQueue / $ ( DEPDIR ) arangod / RestHandler / $ ( DEPDIR ) arangod / RestServer / $ ( DEPDIR ) arangod / SkipLists / $ ( DEPDIR ) arangod / V8Server / $ ( DEPDIR ) arangod / VocBase / $ ( DEPDIR ) arangoirb / MRClient / $ ( DEPDIR ) arangosh / V8Client / $ ( DEPDIR ) bin / $ ( DEPDIR ) lib / Admin / $ ( DEPDIR ) lib / ApplicationServer / $ ( DEPDIR ) lib / Basics / $ ( DEPDIR ) lib / BasicsC / $ ( DEPDIR ) lib / Dispatcher / $ ( DEPDIR ) lib / HttpServer / $ ( DEPDIR ) lib / JsonParser / $ ( DEPDIR ) lib / JsonParserX / $ ( DEPDIR ) lib / Logger / $ ( DEPDIR ) lib / MRuby / $ ( DEPDIR ) lib / ProgramOptions / $ ( DEPDIR ) lib / ProtocolBuffers / $ ( DEPDIR ) lib / Rest / $ ( DEPDIR ) lib / ResultGenerator / $ ( DEPDIR ) lib / Scheduler / $ ( DEPDIR ) lib / ShapedJson / $ ( DEPDIR ) lib / SimpleHttpClient / $ ( DEPDIR ) lib / Statistics / $ ( DEPDIR ) lib / UserManager / $ ( DEPDIR ) lib / Utilities / $ ( DEPDIR ) lib / V8 / $ ( DEPDIR ) lib / Variant / $ ( DEPDIR ) lib / ZeroMQ / $ ( DEPDIR ) <nl> + - rm - rf PerfTests / $ ( DEPDIR ) UnitTests / $ ( DEPDIR ) UnitTests / Cambridge / $ ( DEPDIR ) UnitTests / Jutland / $ ( DEPDIR ) UnitTests / Philadelphia / $ ( DEPDIR ) arangod / Actions / $ ( DEPDIR ) arangod / Ahuacatl / $ ( DEPDIR ) arangod / BitIndexes / $ ( DEPDIR ) arangod / GeoIndex / $ ( DEPDIR ) arangod / HashIndex / $ ( DEPDIR ) arangod / IndexIterators / $ ( DEPDIR ) arangod / IndexOperators / $ ( DEPDIR ) arangod / MRServer / $ ( DEPDIR ) arangod / PriorityQueue / $ ( DEPDIR ) arangod / RestHandler / $ ( DEPDIR ) arangod / RestServer / $ ( DEPDIR ) arangod / SkipLists / $ ( DEPDIR ) arangod / V8Server / $ ( DEPDIR ) arangod / VocBase / $ ( DEPDIR ) arangoirb / MRClient / $ ( DEPDIR ) arangosh / V8Client / $ ( DEPDIR ) lib / Admin / $ ( DEPDIR ) lib / ApplicationServer / $ ( DEPDIR ) lib / Basics / $ ( DEPDIR ) lib / BasicsC / $ ( DEPDIR ) lib / Dispatcher / $ ( DEPDIR ) lib / HttpServer / $ ( DEPDIR ) lib / JsonParser / $ ( DEPDIR ) lib / JsonParserX / $ ( DEPDIR ) lib / Logger / $ ( DEPDIR ) lib / MRuby / $ ( DEPDIR ) lib / ProgramOptions / $ ( DEPDIR ) lib / ProtocolBuffers / $ ( DEPDIR ) lib / Rest / $ ( DEPDIR ) lib / ResultGenerator / $ ( DEPDIR ) lib / Scheduler / $ ( DEPDIR ) lib / ShapedJson / $ ( DEPDIR ) lib / SimpleHttpClient / $ ( DEPDIR ) lib / Statistics / $ ( DEPDIR ) lib / UserManager / $ ( DEPDIR ) lib / Utilities / $ ( DEPDIR ) lib / V8 / $ ( DEPDIR ) lib / Variant / $ ( DEPDIR ) lib / ZeroMQ / $ ( DEPDIR ) <nl> - rm - f Makefile <nl> distclean - am : clean - am distclean - compile distclean - generic \ <nl> distclean - hdr distclean - tags <nl> installcheck - am : <nl> maintainer - clean : maintainer - clean - am <nl> - rm - f $ ( am__CONFIG_DISTCLEAN_FILES ) <nl> - rm - rf $ ( top_srcdir ) / autom4te . cache <nl> - - rm - rf PerfTests / $ ( DEPDIR ) UnitTests / $ ( DEPDIR ) UnitTests / Cambridge / $ ( DEPDIR ) UnitTests / Jutland / $ ( DEPDIR ) UnitTests / Philadelphia / $ ( DEPDIR ) arangod / Actions / $ ( DEPDIR ) arangod / Ahuacatl / $ ( DEPDIR ) arangod / BitIndexes / $ ( DEPDIR ) arangod / GeoIndex / $ ( DEPDIR ) arangod / HashIndex / $ ( DEPDIR ) arangod / IndexIterators / $ ( DEPDIR ) arangod / IndexOperators / $ ( DEPDIR ) arangod / MRServer / $ ( DEPDIR ) arangod / PriorityQueue / $ ( DEPDIR ) arangod / RestHandler / $ ( DEPDIR ) arangod / RestServer / $ ( DEPDIR ) arangod / SkipLists / $ ( DEPDIR ) arangod / V8Server / $ ( DEPDIR ) arangod / VocBase / $ ( DEPDIR ) arangoirb / MRClient / $ ( DEPDIR ) arangosh / V8Client / $ ( DEPDIR ) bin / $ ( DEPDIR ) lib / Admin / $ ( DEPDIR ) lib / ApplicationServer / $ ( DEPDIR ) lib / Basics / $ ( DEPDIR ) lib / BasicsC / $ ( DEPDIR ) lib / Dispatcher / $ ( DEPDIR ) lib / HttpServer / $ ( DEPDIR ) lib / JsonParser / $ ( DEPDIR ) lib / JsonParserX / $ ( DEPDIR ) lib / Logger / $ ( DEPDIR ) lib / MRuby / $ ( DEPDIR ) lib / ProgramOptions / $ ( DEPDIR ) lib / ProtocolBuffers / $ ( DEPDIR ) lib / Rest / $ ( DEPDIR ) lib / ResultGenerator / $ ( DEPDIR ) lib / Scheduler / $ ( DEPDIR ) lib / ShapedJson / $ ( DEPDIR ) lib / SimpleHttpClient / $ ( DEPDIR ) lib / Statistics / $ ( DEPDIR ) lib / UserManager / $ ( DEPDIR ) lib / Utilities / $ ( DEPDIR ) lib / V8 / $ ( DEPDIR ) lib / Variant / $ ( DEPDIR ) lib / ZeroMQ / $ ( DEPDIR ) <nl> + - rm - rf PerfTests / $ ( DEPDIR ) UnitTests / $ ( DEPDIR ) UnitTests / Cambridge / $ ( DEPDIR ) UnitTests / Jutland / $ ( DEPDIR ) UnitTests / Philadelphia / $ ( DEPDIR ) arangod / Actions / $ ( DEPDIR ) arangod / Ahuacatl / $ ( DEPDIR ) arangod / BitIndexes / $ ( DEPDIR ) arangod / GeoIndex / $ ( DEPDIR ) arangod / HashIndex / $ ( DEPDIR ) arangod / IndexIterators / $ ( DEPDIR ) arangod / IndexOperators / $ ( DEPDIR ) arangod / MRServer / $ ( DEPDIR ) arangod / PriorityQueue / $ ( DEPDIR ) arangod / RestHandler / $ ( DEPDIR ) arangod / RestServer / $ ( DEPDIR ) arangod / SkipLists / $ ( DEPDIR ) arangod / V8Server / $ ( DEPDIR ) arangod / VocBase / $ ( DEPDIR ) arangoirb / MRClient / $ ( DEPDIR ) arangosh / V8Client / $ ( DEPDIR ) lib / Admin / $ ( DEPDIR ) lib / ApplicationServer / $ ( DEPDIR ) lib / Basics / $ ( DEPDIR ) lib / BasicsC / $ ( DEPDIR ) lib / Dispatcher / $ ( DEPDIR ) lib / HttpServer / $ ( DEPDIR ) lib / JsonParser / $ ( DEPDIR ) lib / JsonParserX / $ ( DEPDIR ) lib / Logger / $ ( DEPDIR ) lib / MRuby / $ ( DEPDIR ) lib / ProgramOptions / $ ( DEPDIR ) lib / ProtocolBuffers / $ ( DEPDIR ) lib / Rest / $ ( DEPDIR ) lib / ResultGenerator / $ ( DEPDIR ) lib / Scheduler / $ ( DEPDIR ) lib / ShapedJson / $ ( DEPDIR ) lib / SimpleHttpClient / $ ( DEPDIR ) lib / Statistics / $ ( DEPDIR ) lib / UserManager / $ ( DEPDIR ) lib / Utilities / $ ( DEPDIR ) lib / V8 / $ ( DEPDIR ) lib / Variant / $ ( DEPDIR ) lib / ZeroMQ / $ ( DEPDIR ) <nl> - rm - f Makefile <nl> maintainer - clean - am : distclean - am maintainer - clean - generic <nl> <nl>
|
fixed unittests
|
arangodb/arangodb
|
c4e6a35bddcd0cf73afcc7b1f3f97bc3eda0e3f6
|
2012-08-06T11:17:53Z
|
mmm a / tensorflow / contrib / lite / context . h <nl> ppp b / tensorflow / contrib / lite / context . h <nl> typedef enum { <nl> kTfLiteInt64 = 4 , <nl> kTfLiteString = 5 , <nl> kTfLiteBool = 6 , <nl> + kTfLiteInt16 = 7 , <nl> } TfLiteType ; <nl> <nl> / / Parameters for asymmetric quantization . Quantized values can be converted <nl> typedef struct { <nl> int32_t zero_point ; <nl> } TfLiteQuantizationParams ; <nl> <nl> - / / A union of points that points to memory for a given tensor . <nl> + / / A union of pointers that points to memory for a given tensor . <nl> typedef union { <nl> int * i32 ; <nl> int64_t * i64 ; <nl> typedef union { <nl> const char * raw_const ; <nl> uint8_t * uint8 ; <nl> bool * b ; <nl> + int16_t * i16 ; <nl> } TfLitePtrUnion ; <nl> <nl> / / Memory allocation strategies . kTfLiteMmapRo is for read - only memory - mapped <nl> mmm a / tensorflow / contrib / lite / interpreter . cc <nl> ppp b / tensorflow / contrib / lite / interpreter . cc <nl> TfLiteStatus Interpreter : : BytesRequired ( TfLiteType type , const int * dims , <nl> case kTfLiteFloat32 : <nl> * bytes = sizeof ( float ) * count ; <nl> break ; <nl> + case kTfLiteInt16 : <nl> + * bytes = sizeof ( int16_t ) * count ; <nl> + break ; <nl> case kTfLiteInt32 : <nl> * bytes = sizeof ( int32_t ) * count ; <nl> break ; <nl> TfLiteStatus Interpreter : : BytesRequired ( TfLiteType type , const int * dims , <nl> * bytes = sizeof ( bool ) * count ; <nl> break ; <nl> default : <nl> - ReportError ( <nl> - & context_ , <nl> - " Only float32 , int32 , int64 , uint8 , bool supported currently . " ) ; <nl> + ReportError ( & context_ , <nl> + " Only float32 , int16 , int32 , int64 , uint8 , bool supported " <nl> + " currently . " ) ; <nl> return kTfLiteError ; <nl> } <nl> return kTfLiteOk ; <nl> mmm a / tensorflow / contrib / lite / interpreter_test . cc <nl> ppp b / tensorflow / contrib / lite / interpreter_test . cc <nl> TEST ( BasicInterpreter , CheckAllocate ) { <nl> TfLiteType type ; <nl> size_t size ; <nl> } cases [ ] = { <nl> - { kTfLiteFloat32 , sizeof ( float ) } , <nl> - { kTfLiteInt32 , sizeof ( int32_t ) } , <nl> - { kTfLiteUInt8 , sizeof ( uint8_t ) } , <nl> - { kTfLiteInt64 , sizeof ( int64_t ) } , <nl> + { kTfLiteFloat32 , sizeof ( float ) } , { kTfLiteInt32 , sizeof ( int32_t ) } , <nl> + { kTfLiteUInt8 , sizeof ( uint8_t ) } , { kTfLiteInt64 , sizeof ( int64_t ) } , <nl> + { kTfLiteInt16 , sizeof ( int16_t ) } , <nl> } ; <nl> <nl> for ( auto test : cases ) { <nl> TEST ( BasicInterpreter , CheckResize ) { <nl> const int32_t int32s [ ] = { - 3 , - 4 } ; <nl> const uint8_t uint8s [ ] = { 3 , 4 } ; <nl> const int64_t int64s [ ] = { 6 , - 7 } ; <nl> + const int16_t int16s [ ] = { 8 , - 9 } ; <nl> <nl> struct { <nl> TfLiteType type ; <nl> TEST ( BasicInterpreter , CheckResize ) { <nl> { kTfLiteInt32 , sizeof ( int32_t ) , reinterpret_cast < const char * > ( int32s ) } , <nl> { kTfLiteUInt8 , sizeof ( uint8_t ) , reinterpret_cast < const char * > ( uint8s ) } , <nl> { kTfLiteInt64 , sizeof ( int64_t ) , reinterpret_cast < const char * > ( int64s ) } , <nl> + { kTfLiteInt16 , sizeof ( int16_t ) , reinterpret_cast < const char * > ( int16s ) } , <nl> } ; <nl> <nl> for ( auto test : cases ) { <nl> TEST ( BasicInterpreter , CheckAlignment ) { <nl> struct { <nl> TfLiteType type ; <nl> } cases [ ] = { <nl> - { kTfLiteFloat32 } , <nl> - { kTfLiteInt32 } , <nl> - { kTfLiteUInt8 } , <nl> - { kTfLiteInt64 } , <nl> + { kTfLiteFloat32 } , { kTfLiteInt32 } , { kTfLiteUInt8 } , <nl> + { kTfLiteInt64 } , { kTfLiteInt16 } , <nl> } ; <nl> <nl> for ( auto test : cases ) { <nl> mmm a / tensorflow / contrib / lite / kernels / internal / tensor . h <nl> ppp b / tensorflow / contrib / lite / kernels / internal / tensor . h <nl> inline uint8_t * GetTensorData ( TfLiteTensor * tensor ) { <nl> return tensor ! = nullptr ? tensor - > data . uint8 : nullptr ; <nl> } <nl> <nl> + template < > <nl> + inline int16_t * GetTensorData ( TfLiteTensor * tensor ) { <nl> + return tensor ! = nullptr ? tensor - > data . i16 : nullptr ; <nl> + } <nl> + <nl> template < > <nl> inline int32_t * GetTensorData ( TfLiteTensor * tensor ) { <nl> return tensor ! = nullptr ? tensor - > data . i32 : nullptr ; <nl> inline const uint8_t * GetTensorData ( const TfLiteTensor * tensor ) { <nl> return tensor ! = nullptr ? tensor - > data . uint8 : nullptr ; <nl> } <nl> <nl> + template < > <nl> + inline const int16_t * GetTensorData ( const TfLiteTensor * tensor ) { <nl> + return tensor ! = nullptr ? tensor - > data . i16 : nullptr ; <nl> + } <nl> + <nl> template < > <nl> inline const int32_t * GetTensorData ( const TfLiteTensor * tensor ) { <nl> return tensor ! = nullptr ? tensor - > data . i32 : nullptr ; <nl> mmm a / tensorflow / contrib / lite / model . cc <nl> ppp b / tensorflow / contrib / lite / model . cc <nl> TfLiteStatus ConvertTensorType ( TensorType tensor_type , TfLiteType * type , <nl> case TensorType_FLOAT32 : <nl> * type = kTfLiteFloat32 ; <nl> break ; <nl> + case TensorType_INT16 : <nl> + * type = kTfLiteInt16 ; <nl> + break ; <nl> case TensorType_INT32 : <nl> * type = kTfLiteInt32 ; <nl> break ; <nl> mmm a / tensorflow / contrib / lite / optional_debug_tools . cc <nl> ppp b / tensorflow / contrib / lite / optional_debug_tools . cc <nl> const char * TensorTypeName ( TfLiteType type ) { <nl> return " kTfLiteString " ; <nl> case kTfLiteBool : <nl> return " kTfLiteBool " ; <nl> + case kTfLiteInt16 : <nl> + return " kTfLiteInt16 " ; <nl> } <nl> return " ( invalid ) " ; <nl> } <nl> mmm a / tensorflow / contrib / lite / python / interpreter_wrapper / interpreter_wrapper . cc <nl> ppp b / tensorflow / contrib / lite / python / interpreter_wrapper / interpreter_wrapper . cc <nl> int TfLiteTypeToPyArrayType ( TfLiteType tf_lite_type ) { <nl> return NPY_FLOAT32 ; <nl> case kTfLiteInt32 : <nl> return NPY_INT32 ; <nl> + case kTfLiteInt16 : <nl> + return NPY_INT16 ; <nl> case kTfLiteUInt8 : <nl> return NPY_UINT8 ; <nl> case kTfLiteInt64 : <nl> TfLiteType TfLiteTypeFromPyArray ( PyArrayObject * array ) { <nl> return kTfLiteFloat32 ; <nl> case NPY_INT32 : <nl> return kTfLiteInt32 ; <nl> + case NPY_INT16 : <nl> + return kTfLiteInt16 ; <nl> case NPY_UINT8 : <nl> return kTfLiteUInt8 ; <nl> case NPY_INT64 : <nl> mmm a / tensorflow / contrib / lite / schema / schema . fbs <nl> ppp b / tensorflow / contrib / lite / schema / schema . fbs <nl> enum TensorType : byte { <nl> INT64 = 4 , <nl> STRING = 5 , <nl> BOOL = 6 , <nl> + INT16 = 7 , <nl> } <nl> <nl> / / Parameters for converting a quantized tensor back to float . Given a <nl> mmm a / tensorflow / contrib / lite / schema / schema_generated . h <nl> ppp b / tensorflow / contrib / lite / schema / schema_generated . h <nl> enum TensorType { <nl> TensorType_INT64 = 4 , <nl> TensorType_STRING = 5 , <nl> TensorType_BOOL = 6 , <nl> + TensorType_INT16 = 7 , <nl> TensorType_MIN = TensorType_FLOAT32 , <nl> - TensorType_MAX = TensorType_BOOL <nl> + TensorType_MAX = TensorType_INT16 <nl> } ; <nl> <nl> - inline TensorType ( & EnumValuesTensorType ( ) ) [ 7 ] { <nl> + inline TensorType ( & EnumValuesTensorType ( ) ) [ 8 ] { <nl> static TensorType values [ ] = { <nl> TensorType_FLOAT32 , <nl> TensorType_FLOAT16 , <nl> inline TensorType ( & EnumValuesTensorType ( ) ) [ 7 ] { <nl> TensorType_UINT8 , <nl> TensorType_INT64 , <nl> TensorType_STRING , <nl> - TensorType_BOOL <nl> + TensorType_BOOL , <nl> + TensorType_INT16 <nl> } ; <nl> return values ; <nl> } <nl> inline const char * * EnumNamesTensorType ( ) { <nl> " INT64 " , <nl> " STRING " , <nl> " BOOL " , <nl> + " INT16 " , <nl> nullptr <nl> } ; <nl> return names ; <nl> mmm a / tensorflow / contrib / lite / toco / tflite / types . cc <nl> ppp b / tensorflow / contrib / lite / toco / tflite / types . cc <nl> : : tflite : : TensorType DataType : : Serialize ( ArrayDataType array_data_type ) { <nl> switch ( array_data_type ) { <nl> case ArrayDataType : : kFloat : <nl> return : : tflite : : TensorType_FLOAT32 ; <nl> + case ArrayDataType : : kInt16 : <nl> + return : : tflite : : TensorType_INT16 ; <nl> case ArrayDataType : : kInt32 : <nl> return : : tflite : : TensorType_INT32 ; <nl> case ArrayDataType : : kInt64 : <nl> ArrayDataType DataType : : Deserialize ( int tensor_type ) { <nl> switch ( : : tflite : : TensorType ( tensor_type ) ) { <nl> case : : tflite : : TensorType_FLOAT32 : <nl> return ArrayDataType : : kFloat ; <nl> + case : : tflite : : TensorType_INT16 : <nl> + return ArrayDataType : : kInt16 ; <nl> case : : tflite : : TensorType_INT32 : <nl> return ArrayDataType : : kInt32 ; <nl> case : : tflite : : TensorType_INT64 : <nl> flatbuffers : : Offset < flatbuffers : : Vector < uint8_t > > DataBuffer : : Serialize ( <nl> switch ( array . data_type ) { <nl> case ArrayDataType : : kFloat : <nl> return CopyBuffer < ArrayDataType : : kFloat > ( array , builder ) ; <nl> + case ArrayDataType : : kInt16 : <nl> + return CopyBuffer < ArrayDataType : : kInt16 > ( array , builder ) ; <nl> case ArrayDataType : : kInt32 : <nl> return CopyBuffer < ArrayDataType : : kInt32 > ( array , builder ) ; <nl> case ArrayDataType : : kInt64 : <nl> void DataBuffer : : Deserialize ( const : : tflite : : Tensor & tensor , <nl> switch ( tensor . type ( ) ) { <nl> case : : tflite : : TensorType_FLOAT32 : <nl> return CopyBuffer < ArrayDataType : : kFloat > ( buffer , array ) ; <nl> + case : : tflite : : TensorType_INT16 : <nl> + return CopyBuffer < ArrayDataType : : kInt16 > ( buffer , array ) ; <nl> case : : tflite : : TensorType_INT32 : <nl> return CopyBuffer < ArrayDataType : : kInt32 > ( buffer , array ) ; <nl> case : : tflite : : TensorType_INT64 : <nl> mmm a / tensorflow / contrib / lite / toco / tflite / types_test . cc <nl> ppp b / tensorflow / contrib / lite / toco / tflite / types_test . cc <nl> TEST ( DataBuffer , Int32 ) { <nl> : : testing : : ElementsAre ( 1 , 1 < < 30 ) ) ; <nl> } <nl> <nl> + TEST ( DataBuffer , Int16 ) { <nl> + Array recovered = ToFlatBufferAndBack < ArrayDataType : : kInt16 > ( { 1 , 1 < < 14 } ) ; <nl> + EXPECT_THAT ( recovered . GetBuffer < ArrayDataType : : kInt16 > ( ) . data , <nl> + : : testing : : ElementsAre ( 1 , 1 < < 14 ) ) ; <nl> + } <nl> + <nl> TEST ( DataBuffer , String ) { <nl> Array recovered = ToFlatBufferAndBack < ArrayDataType : : kString > ( <nl> { " AA " , " BBB " , " Best . String . Ever . " } ) ; <nl>
|
support int16 - quantized data in TFLite interpreter .
|
tensorflow/tensorflow
|
b253e6b874d4f4d242b5d31777462cac146935d2
|
2018-06-13T20:27:55Z
|
mmm a / src / dbg / debugger_commands . cpp <nl> ppp b / src / dbg / debugger_commands . cpp <nl> CMDRESULT cbDebugDisasm ( int argc , char * argv [ ] ) <nl> addr = GetContextDataEx ( hActiveThread , UE_CIP ) ; <nl> } <nl> DebugUpdateGuiAsync ( addr , false ) ; <nl> + GuiShowCpu ( ) ; <nl> return STATUS_CONTINUE ; <nl> } <nl> <nl> CMDRESULT cbDebugDump ( int argc , char * argv [ ] ) <nl> } <nl> else <nl> GuiDumpAt ( addr ) ; <nl> + GuiShowCpu ( ) ; <nl> return STATUS_CONTINUE ; <nl> } <nl> <nl> CMDRESULT cbDebugStackDump ( int argc , char * argv [ ] ) <nl> DebugUpdateStack ( addr , csp , true ) ; <nl> else <nl> dputs ( QT_TRANSLATE_NOOP ( " DBG " , " Invalid stack address ! " ) ) ; <nl> + GuiShowCpu ( ) ; <nl> return STATUS_CONTINUE ; <nl> } <nl> <nl> CMDRESULT cbDebugMemmapdump ( int argc , char * argv [ ] ) <nl> return STATUS_ERROR ; <nl> } <nl> GuiSelectInMemoryMap ( addr ) ; <nl> + GuiShowCpu ( ) ; <nl> return STATUS_CONTINUE ; <nl> } <nl> <nl> mmm a / src / gui / Src / Gui / MainWindow . cpp <nl> ppp b / src / gui / Src / Gui / MainWindow . cpp <nl> MainWindow : : MainWindow ( QWidget * parent ) <nl> connect ( Bridge : : getBridge ( ) , SIGNAL ( dbgStateChanged ( DBGSTATE ) ) , this , SLOT ( dbgStateChangedSlot ( DBGSTATE ) ) ) ; <nl> connect ( Bridge : : getBridge ( ) , SIGNAL ( addFavouriteItem ( int , QString , QString ) ) , this , SLOT ( addFavouriteItem ( int , QString , QString ) ) ) ; <nl> connect ( Bridge : : getBridge ( ) , SIGNAL ( setFavouriteItemShortcut ( int , QString , QString ) ) , this , SLOT ( setFavouriteItemShortcut ( int , QString , QString ) ) ) ; <nl> - connect ( Bridge : : getBridge ( ) , SIGNAL ( selectInMemoryMap ( duint ) ) , this , SLOT ( displayMemMapWidget ( ) ) ) ; <nl> - connect ( Bridge : : getBridge ( ) , SIGNAL ( disassembleAt ( dsint , dsint ) ) , this , SLOT ( displayCpuWidget ( ) ) ) ; <nl> - connect ( Bridge : : getBridge ( ) , SIGNAL ( dumpAt ( dsint ) ) , this , SLOT ( displayCpuWidget ( ) ) ) ; <nl> - connect ( Bridge : : getBridge ( ) , SIGNAL ( dumpAtN ( duint , int ) ) , this , SLOT ( displayCpuWidget ( ) ) ) ; <nl> - connect ( Bridge : : getBridge ( ) , SIGNAL ( stackDumpAt ( duint , duint ) ) , this , SLOT ( displayCpuWidget ( ) ) ) ; <nl> <nl> / / Setup menu API <nl> initMenuApi ( ) ; <nl>
|
GUI : partially reverted performance breaking change
|
x64dbg/x64dbg
|
626728d08f738ae064d3bd16468a8b15160a6e1e
|
2016-09-10T12:10:48Z
|
mmm a / include / mlir / StandardOps / StandardOps . h <nl> ppp b / include / mlir / StandardOps / StandardOps . h <nl> class AddFOp <nl> : public BinaryOp < AddFOp , OpTrait : : ResultsAreFloatLike , <nl> OpTrait : : IsCommutative , OpTrait : : HasNoSideEffect > { <nl> public : <nl> + static void build ( Builder * builder , OperationState * result , SSAValue * lhs , <nl> + SSAValue * rhs ) ; <nl> + <nl> static StringRef getOperationName ( ) { return " addf " ; } <nl> <nl> Attribute constantFold ( ArrayRef < Attribute > operands , <nl> mmm a / include / mlir / Transforms / LoopUtils . h <nl> ppp b / include / mlir / Transforms / LoopUtils . h <nl> AffineMap getUnrolledLoopUpperBound ( const ForStmt & forStmt , <nl> MLFuncBuilder * builder ) ; <nl> <nl> / / / Skew the statements in the body of a ' for ' statement with the specified <nl> - / / / statement - wise delays . <nl> - UtilResult stmtBodySkew ( ForStmt * forStmt , ArrayRef < uint64_t > delays , <nl> + / / / statement - wise shifts . The shifts are with respect to the original execution <nl> + / / / order , and are multiplied by the loop ' step ' before being applied . <nl> + UtilResult stmtBodySkew ( ForStmt * forStmt , ArrayRef < uint64_t > shifts , <nl> bool unrollPrologueEpilogue = false ) ; <nl> <nl> / / / Tiles the specified band of perfectly nested loops creating tile - space loops <nl> mmm a / lib / StandardOps / StandardOps . cpp <nl> ppp b / lib / StandardOps / StandardOps . cpp <nl> struct MemRefCastFolder : public RewritePattern { <nl> / / AddFOp <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> + void AddFOp : : build ( Builder * builder , OperationState * result , SSAValue * lhs , <nl> + SSAValue * rhs ) { <nl> + assert ( lhs - > getType ( ) = = rhs - > getType ( ) ) ; <nl> + result - > addOperands ( { lhs , rhs } ) ; <nl> + result - > types . push_back ( lhs - > getType ( ) ) ; <nl> + } <nl> + <nl> Attribute AddFOp : : constantFold ( ArrayRef < Attribute > operands , <nl> MLIRContext * context ) const { <nl> assert ( operands . size ( ) = = 2 & & " addf takes two operands " ) ; <nl> void DmaStartOp : : print ( OpAsmPrinter * p ) const { <nl> * p < < " : " < < getSrcMemRef ( ) - > getType ( ) ; <nl> * p < < " , " < < getDstMemRef ( ) - > getType ( ) ; <nl> * p < < " , " < < getTagMemRef ( ) - > getType ( ) ; <nl> - p - > printOptionalAttrDict ( getAttrs ( ) ) ; <nl> } <nl> <nl> / / Parse DmaStartOp . <nl> void DmaWaitOp : : print ( OpAsmPrinter * p ) const { <nl> p - > printOperands ( getTagIndices ( ) ) ; <nl> * p < < " ] , " ; <nl> p - > printOperand ( getNumElements ( ) ) ; <nl> - * p < < " : " < < getTagMemRef ( ) - > getType ( ) ; <nl> p - > printOptionalAttrDict ( getAttrs ( ) ) ; <nl> + * p < < " : " < < getTagMemRef ( ) - > getType ( ) ; <nl> } <nl> <nl> / / Parse DmaWaitOp . <nl> mmm a / lib / Transforms / PipelineDataTransfer . cpp <nl> ppp b / lib / Transforms / PipelineDataTransfer . cpp <nl> PassResult PipelineDataTransfer : : runOnForStmt ( ForStmt * forStmt ) { <nl> startWaitPairs . clear ( ) ; <nl> findMatchingStartFinishStmts ( forStmt , startWaitPairs ) ; <nl> <nl> - / / Store delay for statement for later lookup for AffineApplyOp ' s . <nl> - DenseMap < const Statement * , unsigned > stmtDelayMap ; <nl> + / / Store shift for statement for later lookup for AffineApplyOp ' s . <nl> + DenseMap < const Statement * , unsigned > stmtShiftMap ; <nl> for ( auto & pair : startWaitPairs ) { <nl> auto * dmaStartStmt = pair . first ; <nl> assert ( dmaStartStmt - > isa < DmaStartOp > ( ) ) ; <nl> - stmtDelayMap [ dmaStartStmt ] = 0 ; <nl> + stmtShiftMap [ dmaStartStmt ] = 0 ; <nl> / / Set shifts for DMA start stmt ' s affine operand computation slices to 0 . <nl> if ( auto * slice = mlir : : createAffineComputationSlice ( dmaStartStmt ) ) { <nl> - stmtDelayMap [ slice ] = 0 ; <nl> + stmtShiftMap [ slice ] = 0 ; <nl> } else { <nl> / / If a slice wasn ' t created , the reachable affine_apply op ' s from its <nl> / / operands are the ones that go with it . <nl> PassResult PipelineDataTransfer : : runOnForStmt ( ForStmt * forStmt ) { <nl> SmallVector < MLValue * , 4 > operands ( dmaStartStmt - > getOperands ( ) ) ; <nl> getReachableAffineApplyOps ( operands , affineApplyStmts ) ; <nl> for ( const auto * stmt : affineApplyStmts ) { <nl> - stmtDelayMap [ stmt ] = 0 ; <nl> + stmtShiftMap [ stmt ] = 0 ; <nl> } <nl> } <nl> } <nl> / / Everything else ( including compute ops and dma finish ) are shifted by one . <nl> for ( const auto & stmt : * forStmt ) { <nl> - if ( stmtDelayMap . find ( & stmt ) = = stmtDelayMap . end ( ) ) { <nl> - stmtDelayMap [ & stmt ] = 1 ; <nl> + if ( stmtShiftMap . find ( & stmt ) = = stmtShiftMap . end ( ) ) { <nl> + stmtShiftMap [ & stmt ] = 1 ; <nl> } <nl> } <nl> <nl> - / / Get delays stored in map . <nl> - std : : vector < uint64_t > delays ( forStmt - > getStatements ( ) . size ( ) ) ; <nl> + / / Get shifts stored in map . <nl> + std : : vector < uint64_t > shifts ( forStmt - > getStatements ( ) . size ( ) ) ; <nl> unsigned s = 0 ; <nl> for ( auto & stmt : * forStmt ) { <nl> - assert ( stmtDelayMap . find ( & stmt ) ! = stmtDelayMap . end ( ) ) ; <nl> - delays [ s + + ] = stmtDelayMap [ & stmt ] ; <nl> + assert ( stmtShiftMap . find ( & stmt ) ! = stmtShiftMap . end ( ) ) ; <nl> + shifts [ s + + ] = stmtShiftMap [ & stmt ] ; <nl> LLVM_DEBUG ( <nl> - / / Tagging statements with delays for debugging purposes . <nl> + / / Tagging statements with shifts for debugging purposes . <nl> if ( auto * opStmt = dyn_cast < OperationStmt > ( & stmt ) ) { <nl> MLFuncBuilder b ( opStmt ) ; <nl> - opStmt - > setAttr ( b . getIdentifier ( " delay " ) , <nl> - b . getIntegerAttr ( delays [ s - 1 ] ) ) ; <nl> + opStmt - > setAttr ( b . getIdentifier ( " shift " ) , <nl> + b . getIntegerAttr ( shifts [ s - 1 ] ) ) ; <nl> } ) ; <nl> } <nl> <nl> - if ( ! isStmtwiseShiftValid ( * forStmt , delays ) ) { <nl> + if ( ! isStmtwiseShiftValid ( * forStmt , shifts ) ) { <nl> / / Violates dependences . <nl> LLVM_DEBUG ( llvm : : dbgs ( ) < < " Shifts invalid - unexpected \ n " ; ) ; <nl> return success ( ) ; <nl> } <nl> <nl> - if ( stmtBodySkew ( forStmt , delays ) ) { <nl> + if ( stmtBodySkew ( forStmt , shifts ) ) { <nl> LLVM_DEBUG ( llvm : : dbgs ( ) < < " stmt body skewing failed - unexpected \ n " ; ) ; <nl> return success ( ) ; <nl> } <nl> mmm a / lib / Transforms / Utils / LoopUtils . cpp <nl> ppp b / lib / Transforms / Utils / LoopUtils . cpp <nl> void mlir : : promoteSingleIterationLoops ( MLFunction * f ) { <nl> fsw . walkPostOrder ( f ) ; <nl> } <nl> <nl> - / / / Generates a for ' stmt ' with the specified lower and upper bounds while <nl> - / / / generating the right IV remappings for the delayed statements . The <nl> + / / / Generates a ' for ' stmt with the specified lower and upper bounds while <nl> + / / / generating the right IV remappings for the shifted statements . The <nl> / / / statement blocks that go into the loop are specified in stmtGroupQueue <nl> / / / starting from the specified offset , and in that order ; the first element of <nl> - / / / the pair specifies the delay applied to that group of statements . Returns <nl> + / / / the pair specifies the shift applied to that group of statements ; note that <nl> + / / / the shift is multiplied by the loop step before being applied . Returns <nl> / / / nullptr if the generated loop simplifies to a single iteration one . <nl> static ForStmt * <nl> - generateLoop ( AffineMap lb , AffineMap ub , <nl> + generateLoop ( AffineMap lbMap , AffineMap ubMap , <nl> const std : : vector < std : : pair < uint64_t , ArrayRef < Statement * > > > <nl> & stmtGroupQueue , <nl> unsigned offset , ForStmt * srcForStmt , MLFuncBuilder * b ) { <nl> SmallVector < MLValue * , 4 > lbOperands ( srcForStmt - > getLowerBoundOperands ( ) ) ; <nl> SmallVector < MLValue * , 4 > ubOperands ( srcForStmt - > getUpperBoundOperands ( ) ) ; <nl> <nl> - auto * loopChunk = <nl> - b - > createFor ( srcForStmt - > getLoc ( ) , lbOperands , lb , ubOperands , ub ) ; <nl> + assert ( lbMap . getNumInputs ( ) = = lbOperands . size ( ) ) ; <nl> + assert ( ubMap . getNumInputs ( ) = = ubOperands . size ( ) ) ; <nl> + <nl> + auto * loopChunk = b - > createFor ( srcForStmt - > getLoc ( ) , lbOperands , lbMap , <nl> + ubOperands , ubMap , srcForStmt - > getStep ( ) ) ; <nl> + <nl> OperationStmt : : OperandMapTy operandMap ; <nl> <nl> for ( auto it = stmtGroupQueue . begin ( ) + offset , e = stmtGroupQueue . end ( ) ; <nl> it ! = e ; + + it ) { <nl> - auto elt = * it ; <nl> - / / All ' same delay ' statements get added with the operands being remapped <nl> - / / ( to results of cloned statements ) . <nl> - / / Generate the remapping if the delay is not zero : oldIV = newIV - delay . <nl> - / / TODO ( bondhugula ) : check if srcForStmt is actually used in elt . second <nl> - / / instead of just checking if it ' s used at all . <nl> - if ( ! srcForStmt - > use_empty ( ) & & elt . first ! = 0 ) { <nl> + uint64_t shift = it - > first ; <nl> + auto stmts = it - > second ; <nl> + / / All ' same shift ' statements get added with their operands being remapped <nl> + / / to results of cloned statements , and their IV used remapped . <nl> + / / Generate the remapping if the shift is not zero : remappedIV = newIV - <nl> + / / shift . <nl> + if ( ! srcForStmt - > use_empty ( ) & & shift ! = 0 ) { <nl> auto b = MLFuncBuilder : : getForStmtBodyBuilder ( loopChunk ) ; <nl> - auto * oldIV = <nl> - b . create < AffineApplyOp > ( <nl> - srcForStmt - > getLoc ( ) , <nl> - b . getSingleDimShiftAffineMap ( - static_cast < int64_t > ( elt . first ) ) , <nl> - loopChunk ) <nl> - - > getResult ( 0 ) ; <nl> - operandMap [ srcForStmt ] = cast < MLValue > ( oldIV ) ; <nl> + auto * ivRemap = b . create < AffineApplyOp > ( <nl> + srcForStmt - > getLoc ( ) , <nl> + b . getSingleDimShiftAffineMap ( - static_cast < int64_t > ( <nl> + srcForStmt - > getStep ( ) * shift ) ) , <nl> + loopChunk ) <nl> + - > getResult ( 0 ) ; <nl> + operandMap [ srcForStmt ] = cast < MLValue > ( ivRemap ) ; <nl> } else { <nl> - operandMap [ srcForStmt ] = static_cast < MLValue * > ( loopChunk ) ; <nl> + operandMap [ srcForStmt ] = loopChunk ; <nl> } <nl> - for ( auto * stmt : elt . second ) { <nl> + for ( auto * stmt : stmts ) { <nl> loopChunk - > push_back ( stmt - > clone ( operandMap , b - > getContext ( ) ) ) ; <nl> } <nl> } <nl> generateLoop ( AffineMap lb , AffineMap ub , <nl> } <nl> <nl> / / / Skew the statements in the body of a ' for ' statement with the specified <nl> - / / / statement - wise delays . The delays are with respect to the original execution <nl> - / / / order . A delay of zero for each statement will lead to no change . <nl> + / / / statement - wise shifts . The shifts are with respect to the original execution <nl> + / / / order , and are multiplied by the loop ' step ' before being applied . A shift <nl> + / / / of zero for each statement will lead to no change . <nl> / / The skewing of statements with respect to one another can be used for example <nl> / / to allow overlap of asynchronous operations ( such as DMA communication ) with <nl> / / computation , or just relative shifting of statements for better register <nl> - / / reuse , locality or parallelism . As such , the delays are typically expected to <nl> + / / reuse , locality or parallelism . As such , the shifts are typically expected to <nl> / / be at most of the order of the number of statements . This method should not <nl> / / be used as a substitute for loop distribution / fission . <nl> / / This method uses an algorithm / / in time linear in the number of statements in <nl> generateLoop ( AffineMap lb , AffineMap ub , <nl> / / asserts preservation of SSA dominance . A check for that as well as that for <nl> / / memory - based depedence preservation check rests with the users of this <nl> / / method . <nl> - UtilResult mlir : : stmtBodySkew ( ForStmt * forStmt , ArrayRef < uint64_t > delays , <nl> + UtilResult mlir : : stmtBodySkew ( ForStmt * forStmt , ArrayRef < uint64_t > shifts , <nl> bool unrollPrologueEpilogue ) { <nl> if ( forStmt - > getStatements ( ) . empty ( ) ) <nl> return UtilResult : : Success ; <nl> UtilResult mlir : : stmtBodySkew ( ForStmt * forStmt , ArrayRef < uint64_t > delays , <nl> } <nl> uint64_t tripCount = mayBeConstTripCount . getValue ( ) ; <nl> <nl> - assert ( isStmtwiseShiftValid ( * forStmt , delays ) & & <nl> + assert ( isStmtwiseShiftValid ( * forStmt , shifts ) & & <nl> " shifts will lead to an invalid transformation \ n " ) ; <nl> <nl> + int64_t step = forStmt - > getStep ( ) ; <nl> + <nl> unsigned numChildStmts = forStmt - > getStatements ( ) . size ( ) ; <nl> <nl> - / / Do a linear time ( counting ) sort for the delays . <nl> - uint64_t maxDelay = 0 ; <nl> + / / Do a linear time ( counting ) sort for the shifts . <nl> + uint64_t maxShift = 0 ; <nl> for ( unsigned i = 0 ; i < numChildStmts ; i + + ) { <nl> - maxDelay = std : : max ( maxDelay , delays [ i ] ) ; <nl> + maxShift = std : : max ( maxShift , shifts [ i ] ) ; <nl> } <nl> - / / Such large delays are not the typical use case . <nl> - if ( maxDelay > = numChildStmts ) { <nl> - LLVM_DEBUG ( llvm : : dbgs ( ) < < " stmt delays too large - unexpected \ n " ; ) ; <nl> + / / Such large shifts are not the typical use case . <nl> + if ( maxShift > = numChildStmts ) { <nl> + LLVM_DEBUG ( llvm : : dbgs ( ) < < " stmt shifts too large - unexpected \ n " ; ) ; <nl> return UtilResult : : Success ; <nl> } <nl> <nl> - / / An array of statement groups sorted by delay amount ; each group has all <nl> - / / statements with the same delay in the order in which they appear in the <nl> + / / An array of statement groups sorted by shift amount ; each group has all <nl> + / / statements with the same shift in the order in which they appear in the <nl> / / body of the ' for ' stmt . <nl> - std : : vector < std : : vector < Statement * > > sortedStmtGroups ( maxDelay + 1 ) ; <nl> + std : : vector < std : : vector < Statement * > > sortedStmtGroups ( maxShift + 1 ) ; <nl> unsigned pos = 0 ; <nl> for ( auto & stmt : * forStmt ) { <nl> - auto delay = delays [ pos + + ] ; <nl> - sortedStmtGroups [ delay ] . push_back ( & stmt ) ; <nl> + auto shift = shifts [ pos + + ] ; <nl> + sortedStmtGroups [ shift ] . push_back ( & stmt ) ; <nl> } <nl> <nl> / / Unless the shifts have a specific pattern ( which actually would be the <nl> UtilResult mlir : : stmtBodySkew ( ForStmt * forStmt , ArrayRef < uint64_t > delays , <nl> ForStmt * prologue = nullptr ; <nl> ForStmt * epilogue = nullptr ; <nl> <nl> - / / Do a sweep over the sorted delays while storing open groups in a <nl> + / / Do a sweep over the sorted shifts while storing open groups in a <nl> / / vector , and generating loop portions as necessary during the sweep . A block <nl> - / / of statements is paired with its delay . <nl> + / / of statements is paired with its shift . <nl> std : : vector < std : : pair < uint64_t , ArrayRef < Statement * > > > stmtGroupQueue ; <nl> <nl> auto origLbMap = forStmt - > getLowerBoundMap ( ) ; <nl> - uint64_t lbDelay = 0 ; <nl> + uint64_t lbShift = 0 ; <nl> MLFuncBuilder b ( forStmt ) ; <nl> for ( uint64_t d = 0 , e = sortedStmtGroups . size ( ) ; d < e ; + + d ) { <nl> - / / If nothing is delayed by d , continue . <nl> + / / If nothing is shifted by d , continue . <nl> if ( sortedStmtGroups [ d ] . empty ( ) ) <nl> continue ; <nl> if ( ! stmtGroupQueue . empty ( ) ) { <nl> assert ( d > = 1 & & <nl> " Queue expected to be empty when the first block is found " ) ; <nl> / / The interval for which the loop needs to be generated here is : <nl> - / / ( lbDelay , min ( lbDelay + tripCount , d ) ) and the body of the <nl> + / / [ lbShift , min ( lbShift + tripCount , d ) ) and the body of the <nl> / / loop needs to have all statements in stmtQueue in that order . <nl> ForStmt * res ; <nl> - if ( lbDelay + tripCount < d ) { <nl> - res = <nl> - generateLoop ( b . getShiftedAffineMap ( origLbMap , lbDelay ) , <nl> - b . getShiftedAffineMap ( origLbMap , lbDelay + tripCount ) , <nl> - stmtGroupQueue , 0 , forStmt , & b ) ; <nl> + if ( lbShift + tripCount * step < d * step ) { <nl> + res = generateLoop ( <nl> + b . getShiftedAffineMap ( origLbMap , lbShift ) , <nl> + b . getShiftedAffineMap ( origLbMap , lbShift + tripCount * step ) , <nl> + stmtGroupQueue , 0 , forStmt , & b ) ; <nl> / / Entire loop for the queued stmt groups generated , empty it . <nl> stmtGroupQueue . clear ( ) ; <nl> - lbDelay + = tripCount ; <nl> + lbShift + = tripCount * step ; <nl> } else { <nl> - res = generateLoop ( b . getShiftedAffineMap ( origLbMap , lbDelay ) , <nl> + res = generateLoop ( b . getShiftedAffineMap ( origLbMap , lbShift ) , <nl> b . getShiftedAffineMap ( origLbMap , d ) , stmtGroupQueue , <nl> 0 , forStmt , & b ) ; <nl> - lbDelay = d ; <nl> + lbShift = d * step ; <nl> } <nl> if ( ! prologue & & res ) <nl> prologue = res ; <nl> epilogue = res ; <nl> } else { <nl> / / Start of first interval . <nl> - lbDelay = d ; <nl> + lbShift = d * step ; <nl> } <nl> / / Augment the list of statements that get into the current open interval . <nl> stmtGroupQueue . push_back ( { d , sortedStmtGroups [ d ] } ) ; <nl> UtilResult mlir : : stmtBodySkew ( ForStmt * forStmt , ArrayRef < uint64_t > delays , <nl> / / Those statements groups left in the queue now need to be processed ( FIFO ) <nl> / / and their loops completed . <nl> for ( unsigned i = 0 , e = stmtGroupQueue . size ( ) ; i < e ; + + i ) { <nl> - uint64_t ubDelay = stmtGroupQueue [ i ] . first + tripCount ; <nl> - epilogue = generateLoop ( b . getShiftedAffineMap ( origLbMap , lbDelay ) , <nl> - b . getShiftedAffineMap ( origLbMap , ubDelay ) , <nl> + uint64_t ubShift = ( stmtGroupQueue [ i ] . first + tripCount ) * step ; <nl> + epilogue = generateLoop ( b . getShiftedAffineMap ( origLbMap , lbShift ) , <nl> + b . getShiftedAffineMap ( origLbMap , ubShift ) , <nl> stmtGroupQueue , i , forStmt , & b ) ; <nl> - lbDelay = ubDelay ; <nl> + lbShift = ubShift ; <nl> if ( ! prologue ) <nl> prologue = epilogue ; <nl> } <nl> mmm a / test / Transforms / pipeline - data - transfer . mlir <nl> ppp b / test / Transforms / pipeline - data - transfer . mlir <nl> <nl> / / RUN : mlir - opt % s - pipeline - data - transfer | FileCheck % s <nl> <nl> + / / CHECK - DAG : [ [ MOD_2_2D : # map [ 0 - 9 ] + ] ] = ( d0 ) - > ( d0 mod 2 , d0 mod 2 ) <nl> + / / CHECK - DAG : [ [ MOD_2 : # map [ 0 - 9 ] + ] ] = ( d0 ) - > ( d0 mod 2 ) <nl> + / / CHECK - DAG : [ [ REMAP_SHIFT_MINUS_4 : # map [ 0 - 9 ] + ] ] = ( d0 ) - > ( d0 - 4 ) <nl> + <nl> / / CHECK - LABEL : mlfunc @ loop_nest_dma ( ) { <nl> mlfunc @ loop_nest_dma ( ) { <nl> / / CHECK : % 0 = alloc ( ) : memref < 256xf32 > <nl> mlfunc @ loop_nest_dma ( ) { <nl> return <nl> } <nl> <nl> + / / CHECK - LABEL : @ loop_step <nl> + mlfunc @ loop_step ( % arg0 : memref < 512xf32 > , <nl> + % arg1 : memref < 512xf32 > ) { <nl> + % c0 = constant 0 : index <nl> + % c4 = constant 4 : index <nl> + for % i0 = 0 to 512 step 4 { <nl> + % 1 = alloc ( ) : memref < 4xf32 , 1 > <nl> + % 2 = alloc ( ) : memref < 1xi32 > <nl> + dma_start % arg0 [ % i0 ] , % 1 [ % c0 ] , % c4 , % 2 [ % c0 ] <nl> + : memref < 512xf32 > , memref < 4xf32 , 1 > , memref < 1xi32 > <nl> + dma_wait % 2 [ % c0 ] , % c4 : memref < 1xi32 > <nl> + " compute " ( % i0 ) : ( index ) - > ( ) <nl> + } <nl> + return <nl> + } <nl> + / / CHECK : [ [ TAG : % [ 0 - 9 ] + ] ] = alloc ( ) : memref < 2x1xi32 > <nl> + / / CHECK : % 2 = affine_apply [ [ MOD_2_2D ] ] ( % c0 ) <nl> + / / CHECK - NEXT : dma_start % arg0 [ % c0 ] , % 0 [ % 2 # 0 , % c0_0 ] , % c4 , [ [ TAG ] ] [ % 2 # 1 , % c0_0 ] : memref < 512xf32 > , memref < 2x4xf32 , 1 > , memref < 2x1xi32 > <nl> + / / CHECK - NEXT : for % i0 = 4 to 512 step 4 { <nl> + / / CHECK - NEXT : % 3 = affine_apply [ [ MOD_2_2D ] ] ( % i0 ) <nl> + / / CHECK - NEXT : dma_start % arg0 [ % i0 ] , % 0 [ % 3 # 0 , % c0_0 ] , % c4 , [ [ TAG ] ] [ % 3 # 1 , % c0_0 ] : memref < 512xf32 > , memref < 2x4xf32 , 1 > , memref < 2x1xi32 > <nl> + / / CHECK - NEXT : % 4 = affine_apply # map3 ( % i0 ) <nl> + / / CHECK - NEXT : % 5 = affine_apply [ [ MOD_2 ] ] ( % 4 ) <nl> + / / CHECK - NEXT : % 6 = affine_apply [ [ MOD_2 ] ] ( % 4 ) <nl> + / / CHECK - NEXT : dma_wait [ [ TAG ] ] [ % 5 , % c0_0 ] , % c4 : memref < 2x1xi32 > <nl> + / / CHECK - NEXT : " compute " ( % 4 ) : ( index ) - > ( ) <nl> + / / CHECK - NEXT : } <nl> + / / CHECK - NEXT : % 7 = affine_apply [ [ REMAP_SHIFT_MINUS_4 ] ] ( % c512 ) <nl> + / / CHECK - NEXT : % 8 = affine_apply [ [ MOD_2 ] ] ( % 7 ) <nl> + / / CHECK - NEXT : % 9 = affine_apply [ [ MOD_2 ] ] ( % 7 ) <nl> + / / CHECK - NEXT : dma_wait [ [ TAG ] ] [ % 8 , % c0_0 ] , % c4 : memref < 2x1xi32 > <nl> + / / CHECK - NEXT : " compute " ( % 7 ) : ( index ) - > ( ) <nl> + / / CHECK - NEXT : return <nl> + / / CHECK - NEXT : } <nl> + <nl> # map0 = ( d0 , d1 ) - > ( d0 , d1 ) <nl> # map1 = ( d0 , d1 ) - > ( ( d0 * 2048 + d1 * 256 ) floordiv 32 , 0 ) <nl> # map2 = ( d0 ) - > ( ( d0 * 2048 ) floordiv 32 , 0 ) <nl>
|
Update / Fix LoopUtils : : stmtBodySkew to handle loop step .
|
tensorflow/tensorflow
|
2b743845c34bf3dac9cf2a5a8ae7d0b5ab436efb
|
2019-03-29T21:25:07Z
|
mmm a / stdlib / public / Darwin / Foundation / Data . swift <nl> ppp b / stdlib / public / Darwin / Foundation / Data . swift <nl> public struct Data : ReferenceConvertible , Equatable , Hashable , RandomAccessColl <nl> } <nl> } <nl> <nl> - @ inlinable <nl> - @ _alwaysEmitIntoClient <nl> - internal mutating func _truncateOrZeroExtend ( toCount newCount : Int ) { <nl> - switch self { <nl> - case . empty : <nl> - if newCount = = 0 { <nl> - return <nl> - } else if InlineData . canStore ( count : newCount ) { <nl> - self = . inline ( InlineData ( count : newCount ) ) <nl> - } else if InlineSlice . canStore ( count : newCount ) { <nl> - self = . slice ( InlineSlice ( count : newCount ) ) <nl> - } else { <nl> - self = . large ( LargeSlice ( count : newCount ) ) <nl> - } <nl> - case . inline ( var inline ) : <nl> - if newCount = = 0 { <nl> - self = . empty <nl> - } else if InlineData . canStore ( count : newCount ) { <nl> - guard inline . count ! = newCount else { return } <nl> - inline . count = newCount <nl> - self = . inline ( inline ) <nl> - } else if InlineSlice . canStore ( count : newCount ) { <nl> - var slice = InlineSlice ( inline ) <nl> - slice . count = newCount <nl> - self = . slice ( slice ) <nl> - } else { <nl> - var slice = LargeSlice ( inline ) <nl> - slice . count = newCount <nl> - self = . large ( slice ) <nl> - } <nl> - case . slice ( var slice ) : <nl> - if newCount = = 0 & & slice . startIndex = = 0 { <nl> - self = . empty <nl> - } else if slice . startIndex = = 0 & & InlineData . canStore ( count : newCount ) { <nl> - self = . inline ( InlineData ( slice , count : newCount ) ) <nl> - } else if InlineSlice . canStore ( count : newCount + slice . startIndex ) { <nl> - guard slice . count ! = newCount else { return } <nl> - self = . empty / / TODO : remove this when mgottesman lands optimizations <nl> - slice . count = newCount <nl> - self = . slice ( slice ) <nl> - } else { <nl> - var newSlice = LargeSlice ( slice ) <nl> - newSlice . count = newCount <nl> - self = . large ( newSlice ) <nl> - } <nl> - case . large ( var slice ) : <nl> - if newCount = = 0 & & slice . startIndex = = 0 { <nl> - self = . empty <nl> - } else if slice . startIndex = = 0 & & InlineData . canStore ( count : newCount ) { <nl> - self = . inline ( InlineData ( slice , count : newCount ) ) <nl> - } else { <nl> - guard slice . count ! = newCount else { return } <nl> - self = . empty / / TODO : remove this when mgottesman lands optimizations <nl> - slice . count = newCount <nl> - self = . large ( slice ) <nl> - } <nl> - } <nl> - } <nl> - <nl> @ inlinable / / This is @ inlinable as reasonably small . <nl> var count : Int { <nl> get { <nl> public struct Data : ReferenceConvertible , Equatable , Hashable , RandomAccessColl <nl> } <nl> } <nl> set ( newValue ) { <nl> - _truncateOrZeroExtend ( toCount : newValue ) <nl> + / / HACK : The definition of this inline function takes an inout reference to self , giving the optimizer a unique referencing guarantee . <nl> + / / This allows us to avoid excessive retain - release traffic around modifying enum values , and inlining the function then avoids the additional frame . <nl> + @ inline ( __always ) <nl> + func apply ( _ representation : inout _Representation , _ newValue : Int ) - > _Representation ? { <nl> + switch representation { <nl> + case . empty : <nl> + if newValue = = 0 { <nl> + return nil <nl> + } else if InlineData . canStore ( count : newValue ) { <nl> + return . inline ( InlineData ( count : newValue ) ) <nl> + } else if InlineSlice . canStore ( count : newValue ) { <nl> + return . slice ( InlineSlice ( count : newValue ) ) <nl> + } else { <nl> + return . large ( LargeSlice ( count : newValue ) ) <nl> + } <nl> + case . inline ( var inline ) : <nl> + if newValue = = 0 { <nl> + return . empty <nl> + } else if InlineData . canStore ( count : newValue ) { <nl> + guard inline . count ! = newValue else { return nil } <nl> + inline . count = newValue <nl> + return . inline ( inline ) <nl> + } else if InlineSlice . canStore ( count : newValue ) { <nl> + var slice = InlineSlice ( inline ) <nl> + slice . count = newValue <nl> + return . slice ( slice ) <nl> + } else { <nl> + var slice = LargeSlice ( inline ) <nl> + slice . count = newValue <nl> + return . large ( slice ) <nl> + } <nl> + case . slice ( var slice ) : <nl> + if newValue = = 0 & & slice . startIndex = = 0 { <nl> + return . empty <nl> + } else if slice . startIndex = = 0 & & InlineData . canStore ( count : newValue ) { <nl> + return . inline ( InlineData ( slice , count : newValue ) ) <nl> + } else if InlineSlice . canStore ( count : newValue + slice . startIndex ) { <nl> + guard slice . count ! = newValue else { return nil } <nl> + representation = . empty / / TODO : remove this when mgottesman lands optimizations <nl> + slice . count = newValue <nl> + return . slice ( slice ) <nl> + } else { <nl> + var newSlice = LargeSlice ( slice ) <nl> + newSlice . count = newValue <nl> + return . large ( newSlice ) <nl> + } <nl> + case . large ( var slice ) : <nl> + if newValue = = 0 & & slice . startIndex = = 0 { <nl> + return . empty <nl> + } else if slice . startIndex = = 0 & & InlineData . canStore ( count : newValue ) { <nl> + return . inline ( InlineData ( slice , count : newValue ) ) <nl> + } else { <nl> + guard slice . count ! = newValue else { return nil } <nl> + representation = . empty / / TODO : remove this when mgottesman lands optimizations <nl> + slice . count = newValue <nl> + return . large ( slice ) <nl> + } <nl> + } <nl> + } <nl> + <nl> + if let rep = apply ( & self , newValue ) { <nl> + self = rep <nl> + } <nl> } <nl> } <nl> <nl> public struct Data : ReferenceConvertible , Equatable , Hashable , RandomAccessColl <nl> / / Copy as much as we can in one shot . <nl> let underestimatedCount = elements . underestimatedCount <nl> let originalCount = _representation . count <nl> - _representation . _truncateOrZeroExtend ( toCount : originalCount + underestimatedCount ) <nl> + resetBytes ( in : self . endIndex . . < self . endIndex + underestimatedCount ) <nl> var ( iter , copiedCount ) : ( S . Iterator , Int ) = _representation . withUnsafeMutableBytes { buffer in <nl> + assert ( buffer . count = = originalCount + underestimatedCount ) <nl> let start = buffer . baseAddress ! . assumingMemoryBound ( to : UInt8 . self ) + originalCount <nl> let b = UnsafeMutableBufferPointer ( start : start , count : buffer . count - originalCount ) <nl> return elements . _copyContents ( initializing : b ) <nl> public struct Data : ReferenceConvertible , Equatable , Hashable , RandomAccessColl <nl> guard copiedCount = = underestimatedCount else { <nl> / / We can ' t trap here . We have to allow an underfilled buffer <nl> / / to emulate the previous implementation . <nl> - _representation . _truncateOrZeroExtend ( toCount : originalCount + copiedCount ) <nl> + _representation . replaceSubrange ( startIndex + originalCount + copiedCount . . < endIndex , with : nil , count : 0 ) <nl> return <nl> } <nl> <nl> mmm a / test / Interop / Cxx / class / Inputs / module . modulemap <nl> ppp b / test / Interop / Cxx / class / Inputs / module . modulemap <nl> module MemoryLayout { <nl> module MemberVariables { <nl> header " member - variables . h " <nl> } <nl> + <nl> + module ProtocolConformance { <nl> + header " protocol - conformance . h " <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . d607b5a3caa5 <nl> mmm / dev / null <nl> ppp b / test / Interop / Cxx / class / Inputs / protocol - conformance . h <nl> <nl> + struct ConformsToProtocol { <nl> + int return42 ( ) { return 42 ; } <nl> + } ; <nl> + <nl> + struct DoesNotConformToProtocol { <nl> + int returnFortyTwo ( ) { return 42 ; } <nl> + } ; <nl> new file mode 100644 <nl> index 000000000000 . . 951f10a0b9ca <nl> mmm / dev / null <nl> ppp b / test / Interop / Cxx / class / protocol - conformance - silgen . swift <nl> <nl> + / / Tests that a C + + class can conform to a Swift protocol . <nl> + <nl> + / / RUN : % target - swift - emit - silgen - I % S / Inputs - enable - cxx - interop % s <nl> + <nl> + import ProtocolConformance <nl> + <nl> + protocol HasReturn42 { <nl> + mutating func return42 ( ) - > CInt <nl> + } <nl> + <nl> + / / FIXME : <nl> + / / https : / / bugs . swift . org / browse / SR - 12750 <nl> + / / SILGen currently hits an assertion failure in getParameterTypes ( ) when the <nl> + / / following protocol conformance is declared . <nl> + / / extension ConformsToProtocol : HasReturn42 { } <nl> new file mode 100644 <nl> index 000000000000 . . bafb5809b6d4 <nl> mmm / dev / null <nl> ppp b / test / Interop / Cxx / class / protocol - conformance - typechecker . swift <nl> <nl> + / / Tests that a C + + class can conform to a Swift protocol . <nl> + <nl> + / / RUN : % target - typecheck - verify - swift - I % S / Inputs - enable - cxx - interop <nl> + <nl> + import ProtocolConformance <nl> + <nl> + protocol HasReturn42 { <nl> + mutating func return42 ( ) - > CInt / / expected - note { { requires function ' return42 ( ) ' } } <nl> + } <nl> + <nl> + extension ConformsToProtocol : HasReturn42 { } <nl> + <nl> + extension DoesNotConformToProtocol : HasReturn42 { } / / expected - error { { ' DoesNotConformToProtocol ' does not conform to protocol } } <nl> mmm a / test / stdlib / TestData . swift <nl> ppp b / test / stdlib / TestData . swift <nl> class TestData : TestDataSuper { <nl> } <nl> } <nl> } <nl> + <nl> + / / This is a ( potentially invalid ) sequence that produces a configurable number of 42s and has a freely customizable ` underestimatedCount ` . <nl> + struct TestSequence : Sequence { <nl> + typealias Element = UInt8 <nl> + struct Iterator : IteratorProtocol { <nl> + var _remaining : Int <nl> + init ( _ count : Int ) { <nl> + _remaining = count <nl> + } <nl> + mutating func next ( ) - > UInt8 ? { <nl> + guard _remaining > 0 else { return nil } <nl> + _remaining - = 1 <nl> + return 42 <nl> + } <nl> + } <nl> + let underestimatedCount : Int <nl> + let count : Int <nl> + <nl> + func makeIterator ( ) - > Iterator { <nl> + return Iterator ( count ) <nl> + } <nl> + } <nl> + <nl> + func test_init_TestSequence ( ) { <nl> + / / Underestimated count <nl> + do { <nl> + let d = Data ( TestSequence ( underestimatedCount : 0 , count : 10 ) ) <nl> + expectEqual ( 10 , d . count ) <nl> + expectEqual ( Array ( repeating : 42 as UInt8 , count : 10 ) , Array ( d ) ) <nl> + } <nl> + <nl> + / / Very underestimated count ( to exercise realloc path ) <nl> + do { <nl> + let d = Data ( TestSequence ( underestimatedCount : 0 , count : 1000 ) ) <nl> + expectEqual ( 1000 , d . count ) <nl> + expectEqual ( Array ( repeating : 42 as UInt8 , count : 1000 ) , Array ( d ) ) <nl> + } <nl> + <nl> + / / Exact count <nl> + do { <nl> + let d = Data ( TestSequence ( underestimatedCount : 10 , count : 10 ) ) <nl> + expectEqual ( 10 , d . count ) <nl> + expectEqual ( Array ( repeating : 42 as UInt8 , count : 10 ) , Array ( d ) ) <nl> + } <nl> + <nl> + / / Overestimated count . This is an illegal case , so trapping would be fine . <nl> + / / However , for compatibility with the implementation in Swift 5 , Data <nl> + / / handles this case by simply truncating itself to the actual size . <nl> + do { <nl> + let d = Data ( TestSequence ( underestimatedCount : 20 , count : 10 ) ) <nl> + expectEqual ( 10 , d . count ) <nl> + expectEqual ( Array ( repeating : 42 as UInt8 , count : 10 ) , Array ( d ) ) <nl> + } <nl> + } <nl> + <nl> + func test_append_TestSequence ( ) { <nl> + let base = Data ( Array ( repeating : 23 as UInt8 , count : 10 ) ) <nl> + <nl> + / / Underestimated count <nl> + do { <nl> + var d = base <nl> + d . append ( contentsOf : TestSequence ( underestimatedCount : 0 , count : 10 ) ) <nl> + expectEqual ( 20 , d . count ) <nl> + expectEqual ( Array ( base ) + Array ( repeating : 42 as UInt8 , count : 10 ) , <nl> + Array ( d ) ) <nl> + } <nl> + <nl> + / / Very underestimated count ( to exercise realloc path ) <nl> + do { <nl> + var d = base <nl> + d . append ( contentsOf : TestSequence ( underestimatedCount : 0 , count : 1000 ) ) <nl> + expectEqual ( 1010 , d . count ) <nl> + expectEqual ( Array ( base ) + Array ( repeating : 42 as UInt8 , count : 1000 ) , Array ( d ) ) <nl> + } <nl> + <nl> + / / Exact count <nl> + do { <nl> + var d = base <nl> + d . append ( contentsOf : TestSequence ( underestimatedCount : 10 , count : 10 ) ) <nl> + expectEqual ( 20 , d . count ) <nl> + expectEqual ( Array ( base ) + Array ( repeating : 42 as UInt8 , count : 10 ) , Array ( d ) ) <nl> + } <nl> + <nl> + / / Overestimated count . This is an illegal case , so trapping would be fine . <nl> + / / However , for compatibility with the implementation in Swift 5 , Data <nl> + / / handles this case by simply truncating itself to the actual size . <nl> + do { <nl> + var d = base <nl> + d . append ( contentsOf : TestSequence ( underestimatedCount : 20 , count : 10 ) ) <nl> + expectEqual ( 20 , d . count ) <nl> + expectEqual ( Array ( base ) + Array ( repeating : 42 as UInt8 , count : 10 ) , Array ( d ) ) <nl> + } <nl> + } <nl> } <nl> <nl> # if ! FOUNDATION_XCTEST <nl> if # available ( macOS 10 . 15 , iOS 13 , tvOS 13 , watchOS 6 , * ) { <nl> } <nl> DataTests . test ( " test_increaseCount " ) { TestData ( ) . test_increaseCount ( ) } <nl> DataTests . test ( " test_decreaseCount " ) { TestData ( ) . test_decreaseCount ( ) } <nl> + DataTests . test ( " test_increaseCount " ) { TestData ( ) . test_init_TestSequence ( ) } <nl> + DataTests . test ( " test_decreaseCount " ) { TestData ( ) . test_append_TestSequence ( ) } <nl> <nl> <nl> / / XCTest does not have a crash detection , whereas lit does <nl>
|
Merge remote - tracking branch ' origin / master ' into master - next
|
apple/swift
|
f2f465a6bc47fbf3bdff75c97f7ce0d9166b23d6
|
2020-05-07T18:03:35Z
|
mmm a / db / update . cpp <nl> ppp b / db / update . cpp <nl> namespace mongo { <nl> / / if elt isn ' t an object , then comparison will work <nl> return toMatch . woCompare ( elt , false ) = = 0 ; <nl> } <nl> + <nl> + if ( matcherOnPrimitive ) <nl> + return matcher - > matches ( toMatch . wrap ( " " ) ) ; <nl> <nl> if ( toMatch . type ( ) ! = Object ) { <nl> / / looking for an object , so this can ' t match <nl> mmm a / db / update . h <nl> ppp b / db / update . h <nl> namespace mongo { <nl> <nl> BSONElement elt ; / / x : 5 note : this is the actual element from the updateobj <nl> boost : : shared_ptr < Matcher > matcher ; <nl> + bool matcherOnPrimitive ; <nl> <nl> void init ( Op o , BSONElement & e ) { <nl> op = o ; <nl> elt = e ; <nl> - if ( op = = PULL & & e . type ( ) = = Object ) <nl> - matcher . reset ( new Matcher ( e . embeddedObject ( ) ) ) ; <nl> + if ( op = = PULL & & e . type ( ) = = Object ) { <nl> + BSONObj t = e . embeddedObject ( ) ; <nl> + if ( t . firstElement ( ) . getGtLtOp ( ) = = 0 ) { <nl> + matcher . reset ( new Matcher ( t ) ) ; <nl> + matcherOnPrimitive = false ; <nl> + } <nl> + else { <nl> + matcher . reset ( new Matcher ( BSON ( " " < < t ) ) ) ; <nl> + matcherOnPrimitive = true ; <nl> + } <nl> + } <nl> } <nl> <nl> void setFieldName ( const char * s ) { <nl> mmm a / jstests / pull_remove1 . js <nl> ppp b / jstests / pull_remove1 . js <nl> assert . eq ( o , t . findOne ( ) , " A1 " ) <nl> o . a = o . a . filter ( function ( z ) { return z > = 6 ; } ) <nl> t . update ( { } , { $ pull : { a : { $ lt : 6 } } } ) <nl> <nl> - / / assert . eq ( o . a , t . findOne ( ) . a , " A2 " ) <nl> + assert . eq ( o . a , t . findOne ( ) . a , " A2 " ) <nl> <nl>
|
fix pull with primitives and $ ops SERVER - 1697
|
mongodb/mongo
|
0d8b5981ff7a3df062cfa5839e292718b61911c2
|
2010-09-24T19:40:59Z
|
mmm a / doc / py_tutorials / py_feature2d / py_brief / py_brief . markdown <nl> ppp b / doc / py_tutorials / py_feature2d / py_brief / py_brief . markdown <nl> BRIEF in OpenCV <nl> <nl> Below code shows the computation of BRIEF descriptors with the help of CenSurE detector . ( CenSurE <nl> detector is called STAR detector in OpenCV ) <nl> + <nl> + note , that you need [ opencv contrib ] ( https : / / github . com / Itseez / opencv_contrib ) ) to use this . <nl> @ code { . py } <nl> import numpy as np <nl> import cv2 <nl> from matplotlib import pyplot as plt <nl> <nl> img = cv2 . imread ( ' simple . jpg ' , 0 ) <nl> <nl> - # Initiate STAR detector <nl> - star = cv2 . FeatureDetector_create ( " STAR " ) <nl> + # Initiate FAST detector <nl> + star = cv2 . xfeatures2d . StarDetector_create ( ) <nl> <nl> # Initiate BRIEF extractor <nl> - brief = cv2 . DescriptorExtractor_create ( " BRIEF " ) <nl> + brief = cv2 . BriefDescriptorExtractor_create ( ) <nl> <nl> # find the keypoints with STAR <nl> kp = star . detect ( img , None ) <nl> mmm a / doc / py_tutorials / py_feature2d / py_fast / py_fast . markdown <nl> ppp b / doc / py_tutorials / py_feature2d / py_fast / py_fast . markdown <nl> from matplotlib import pyplot as plt <nl> img = cv2 . imread ( ' simple . jpg ' , 0 ) <nl> <nl> # Initiate FAST object with default values <nl> - fast = cv2 . FastFeatureDetector ( ) <nl> + fast = cv2 . FastFeatureDetector_create ( ) <nl> <nl> # find and draw the keypoints <nl> kp = fast . detect ( img , None ) <nl> mmm a / doc / py_tutorials / py_feature2d / py_feature_homography / py_feature_homography . markdown <nl> ppp b / doc / py_tutorials / py_feature2d / py_feature_homography / py_feature_homography . markdown <nl> img1 = cv2 . imread ( ' box . png ' , 0 ) # queryImage <nl> img2 = cv2 . imread ( ' box_in_scene . png ' , 0 ) # trainImage <nl> <nl> # Initiate SIFT detector <nl> - sift = cv2 . SIFT ( ) <nl> + sift = cv2 . xfeatures2d . SIFT_create ( ) <nl> <nl> # find the keypoints and descriptors with SIFT <nl> kp1 , des1 = sift . detectAndCompute ( img1 , None ) <nl> if len ( good ) > MIN_MATCH_COUNT : <nl> M , mask = cv2 . findHomography ( src_pts , dst_pts , cv2 . RANSAC , 5 . 0 ) <nl> matchesMask = mask . ravel ( ) . tolist ( ) <nl> <nl> - h , w = img1 . shape <nl> + h , w , d = img1 . shape <nl> pts = np . float32 ( [ [ 0 , 0 ] , [ 0 , h - 1 ] , [ w - 1 , h - 1 ] , [ w - 1 , 0 ] ] ) . reshape ( - 1 , 1 , 2 ) <nl> dst = cv2 . perspectiveTransform ( pts , M ) <nl> <nl> mmm a / doc / py_tutorials / py_feature2d / py_orb / py_orb . markdown <nl> ppp b / doc / py_tutorials / py_feature2d / py_orb / py_orb . markdown <nl> from matplotlib import pyplot as plt <nl> <nl> img = cv2 . imread ( ' simple . jpg ' , 0 ) <nl> <nl> - # Initiate STAR detector <nl> - orb = cv2 . ORB ( ) <nl> + # Initiate ORB detector <nl> + orb = cv2 . ORB_create ( ) <nl> <nl> # find the keypoints with ORB <nl> kp = orb . detect ( img , None ) <nl> mmm a / doc / py_tutorials / py_feature2d / py_sift_intro / py_sift_intro . markdown <nl> ppp b / doc / py_tutorials / py_feature2d / py_sift_intro / py_sift_intro . markdown <nl> greater than 0 . 8 , they are rejected . It eliminaters around 90 % of false matches <nl> <nl> So this is a summary of SIFT algorithm . For more details and understanding , reading the original <nl> paper is highly recommended . Remember one thing , this algorithm is patented . So this algorithm is <nl> - included in Non - free module in OpenCV . <nl> + included in [ the opencv contrib repo ] ( https : / / github . com / Itseez / opencv_contrib ) <nl> <nl> SIFT in OpenCV <nl> mmmmmmmmmmmm - - <nl> import numpy as np <nl> img = cv2 . imread ( ' home . jpg ' ) <nl> gray = cv2 . cvtColor ( img , cv2 . COLOR_BGR2GRAY ) <nl> <nl> - sift = cv2 . SIFT ( ) <nl> + sift = cv2 . xfeatures2d . SIFT_create ( ) <nl> kp = sift . detect ( gray , None ) <nl> <nl> img = cv2 . drawKeypoints ( gray , kp ) <nl> Now to calculate the descriptor , OpenCV provides two methods . <nl> <nl> We will see the second method : <nl> @ code { . py } <nl> - sift = cv2 . SIFT ( ) <nl> + sift = cv2 . xfeatures2d . SIFT_create ( ) <nl> kp , des = sift . detectAndCompute ( gray , None ) <nl> @ endcode <nl> Here kp will be a list of keypoints and des is a numpy array of shape <nl> mmm a / doc / py_tutorials / py_feature2d / py_surf_intro / py_surf_intro . markdown <nl> ppp b / doc / py_tutorials / py_feature2d / py_surf_intro / py_surf_intro . markdown <nl> examples are shown in Python terminal since it is just same as SIFT only . <nl> <nl> # Create SURF object . You can specify params here or later . <nl> # Here I set Hessian Threshold to 400 <nl> - > > > surf = cv2 . SURF ( 400 ) <nl> + > > > surf = cv2 . xfeatures2d . SURF_create ( 400 ) <nl> <nl> # Find keypoints and descriptors directly <nl> > > > kp , des = surf . detectAndCompute ( img , None ) <nl> examples are shown in Python terminal since it is just same as SIFT only . <nl> While matching , we may need all those features , but not now . So we increase the Hessian Threshold . <nl> @ code { . py } <nl> # Check present Hessian threshold <nl> - > > > print surf . hessianThreshold <nl> + > > > print surf . getHessianThreshold ( ) <nl> 400 . 0 <nl> <nl> # We set it to some 50000 . Remember , it is just for representing in picture . <nl> # In actual cases , it is better to have a value 300 - 500 <nl> - > > > surf . hessianThreshold = 50000 <nl> + > > > surf . setHessianThreshold ( 50000 ) <nl> <nl> # Again compute keypoints and check its number . <nl> > > > kp , des = surf . detectAndCompute ( img , None ) <nl> on wings of butterfly . You can test it with other images . <nl> Now I want to apply U - SURF , so that it won ' t find the orientation . <nl> @ code { . py } <nl> # Check upright flag , if it False , set it to True <nl> - > > > print surf . upright <nl> + > > > print surf . getUpright ( ) <nl> False <nl> <nl> - > > > surf . upright = True <nl> + > > > surf . setUpright ( True ) <nl> <nl> # Recompute the feature points and draw it <nl> > > > kp = surf . detect ( img , None ) <nl> Finally we check the descriptor size and change it to 128 if it is only 64 - dim . <nl> 64 <nl> <nl> # That means flag , " extended " is False . <nl> - > > > surf . extended <nl> + > > > surf . getExtended ( ) <nl> False <nl> <nl> # So we make it to True to get 128 - dim descriptors . <nl>
|
Merge pull request from berak : patch - 2
|
opencv/opencv
|
a91dcb015d65eaca1891dd89d4b03ed43d5e1632
|
2015-10-21T11:41:25Z
|
mmm a / arangod / Agency / AgentConfiguration . cpp <nl> ppp b / arangod / Agency / AgentConfiguration . cpp <nl> bool config_t : : merge ( VPackSlice const & conf ) { <nl> ss < < " Min RAFT interval : " ; <nl> if ( _minPing = = 0 ) { / / Command line beats persistence <nl> if ( conf . hasKey ( minPingStr ) ) { <nl> - _minPing = conf . get ( minPingStr ) . getUInt ( ) ; <nl> + _minPing = conf . get ( minPingStr ) . getDouble ( ) ; <nl> ss < < _minPing < < " ( persisted ) " ; <nl> } else { <nl> _minPing = 0 . 5 ; <nl> bool config_t : : merge ( VPackSlice const & conf ) { <nl> ss < < " Max RAFT interval : " ; <nl> if ( _maxPing = = 0 ) { / / Command line beats persistence <nl> if ( conf . hasKey ( maxPingStr ) ) { <nl> - _maxPing = conf . get ( maxPingStr ) . getUInt ( ) ; <nl> + _maxPing = conf . get ( maxPingStr ) . getDouble ( ) ; <nl> ss < < _maxPing < < " ( persisted ) " ; <nl> } else { <nl> _maxPing = 2 . 5 ; <nl> mmm a / arangod / RestServer / BootstrapFeature . cpp <nl> ppp b / arangod / RestServer / BootstrapFeature . cpp <nl> void BootstrapFeature : : start ( ) { <nl> auto vocbase = DatabaseFeature : : DATABASE - > vocbase ( ) ; <nl> <nl> auto ss = ServerState : : instance ( ) ; <nl> - if ( ! ss - > isRunningInCluster ( ) & & ! ss - > isAgent ( ) ) { <nl> + if ( ! ss - > isRunningInCluster ( ) ) { <nl> LOG_TOPIC ( DEBUG , Logger : : STARTUP ) < < " Running server / server . js " ; <nl> V8DealerFeature : : DEALER - > loadJavascript ( vocbase , " server / server . js " ) ; <nl> } else if ( ss - > isCoordinator ( ) ) { <nl> mmm a / js / server / modules / @ arangodb / foxx / queues / index . js <nl> ppp b / js / server / modules / @ arangodb / foxx / queues / index . js <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> const isCluster = require ( " @ arangodb / cluster " ) . isCluster ( ) ; <nl> + const isAgent = global . ArangoAgent . enabled ( ) ; <nl> <nl> var _ = require ( ' lodash ' ) ; <nl> var flatten = require ( ' internal ' ) . flatten ; <nl> function asNumber ( num ) { <nl> } <nl> <nl> function updateQueueDelayClusterAware ( ) { <nl> - if ( isCluster ) { <nl> + if ( isCluster & & ! isAgent ) { <nl> global . ArangoAgency . set ( ' Current / FoxxmasterQueueupdate ' , true ) ; <nl> } <nl> updateQueueDelay ( ) ; <nl>
|
minor fixes
|
arangodb/arangodb
|
c53428ce893e1684701d8be23a894b221ad4969d
|
2016-08-29T15:13:33Z
|
new file mode 100644 <nl> index 000000000000 . . 498aceecf777 <nl> mmm / dev / null <nl> ppp b / validation - test / compiler_crashers / 28687 - unreachable - executed - at - swift - lib - ast - type - cpp - 1349 . swift <nl> <nl> + / / This source file is part of the Swift . org open source project <nl> + / / Copyright ( c ) 2014 - 2017 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See https : / / swift . org / LICENSE . txt for license information <nl> + / / See https : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + <nl> + / / REQUIRES : deterministic - behavior <nl> + / / RUN : not - - crash % target - swift - frontend % s - emit - ir <nl> + { { { { func a ( UInt = 1 + 1 as ? Int ) { { { { { { A { { { { { { { { { { { { { { { { { { { { { { { { <nl>
|
Merge pull request from practicalswift / swiftc - 28687 - unreachable - executed - at - swift - lib - ast - type - cpp - 1349
|
apple/swift
|
977df36be5749838641a68b206d872a73bb4126e
|
2017-02-08T13:56:38Z
|
mmm a / modules / core / src / convert . cpp <nl> ppp b / modules / core / src / convert . cpp <nl> struct Cvt_SIMD < double , int > <nl> int cWidth = v_float64x2 : : nlanes ; <nl> for ( ; x < = width - cWidth * 2 ; x + = cWidth * 2 ) <nl> { <nl> - v_float32x4 v_src0 = v_cvt_f32 ( v_load ( src + x ) ) ; <nl> - v_float32x4 v_src1 = v_cvt_f32 ( v_load ( src + x + cWidth ) ) ; <nl> + v_int32x4 v_src0 = v_round ( v_load ( src + x ) ) ; <nl> + v_int32x4 v_src1 = v_round ( v_load ( src + x + cWidth ) ) ; <nl> <nl> - v_store ( dst + x , v_round ( v_combine_low ( v_src0 , v_src1 ) ) ) ; <nl> + v_store ( dst + x , v_combine_low ( v_src0 , v_src1 ) ) ; <nl> } <nl> } <nl> return x ; <nl>
|
SSE2 : use _mm_cvtpd_epi32 when converting from CV_64F to CV_32S ( )
|
opencv/opencv
|
c219f97f487ce092ee5bae6e0aef88f9e3c25811
|
2018-03-06T06:50:53Z
|
mmm a / . github / workflows / linux . yml <nl> ppp b / . github / workflows / linux . yml <nl> env : <nl> jobs : <nl> build : <nl> runs - on : ubuntu - 18 . 04 <nl> + strategy : <nl> + matrix : <nl> + cxx : [ g + + - 4 . 8 , g + + - 8 ] <nl> <nl> steps : <nl> - uses : actions / checkout @ v2 <nl> <nl> - name : Create Build Environment <nl> run : cmake - E make_directory $ { { runner . workspace } } / build <nl> + run : apt install $ { { matrix . cxx } } <nl> <nl> - name : Configure CMake <nl> working - directory : $ { { runner . workspace } } / build <nl>
|
Update CI config
|
fmtlib/fmt
|
95077d60c986d571e75381030f5e00d9f113fe92
|
2020-11-03T19:41:25Z
|
new file mode 100644 <nl> index 00000000000 . . 02a58d4f956 <nl> mmm / dev / null <nl> ppp b / folly / experimental / wangle / rx / Dummy . cpp <nl> <nl> + / * <nl> + * Copyright 2014 Facebook , Inc . <nl> + * <nl> + * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + * you may not use this file except in compliance with the License . <nl> + * You may obtain a copy of the License at <nl> + * <nl> + * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + * <nl> + * Unless required by applicable law or agreed to in writing , software <nl> + * distributed under the License is distributed on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + * See the License for the specific language governing permissions and <nl> + * limitations under the License . <nl> + * / <nl> + <nl> + / / fbbuild is too dumb to know that . h files in the directory affect <nl> + / / our project , unless we have a . cpp file in the target , in the same <nl> + / / directory . <nl> new file mode 100644 <nl> index 00000000000 . . 02a58d4f956 <nl> mmm / dev / null <nl> ppp b / folly / wangle / detail / Dummy . cpp <nl> <nl> + / * <nl> + * Copyright 2014 Facebook , Inc . <nl> + * <nl> + * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + * you may not use this file except in compliance with the License . <nl> + * You may obtain a copy of the License at <nl> + * <nl> + * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + * <nl> + * Unless required by applicable law or agreed to in writing , software <nl> + * distributed under the License is distributed on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + * See the License for the specific language governing permissions and <nl> + * limitations under the License . <nl> + * / <nl> + <nl> + / / fbbuild is too dumb to know that . h files in the directory affect <nl> + / / our project , unless we have a . cpp file in the target , in the same <nl> + / / directory . <nl>
|
( wangle ) dummy cpp files
|
facebook/folly
|
6c03fe981774e56f47e6955ec0a1b31fa37a684a
|
2014-10-29T23:02:45Z
|
mmm a / include / v8 - profiler . h <nl> ppp b / include / v8 - profiler . h <nl> struct HeapStatsUpdate { <nl> uint32_t size ; / / New value of size field for the interval with this index . <nl> } ; <nl> <nl> + # define CODE_EVENTS_LIST ( V ) \ <nl> + V ( Builtin ) \ <nl> + V ( Callback ) \ <nl> + V ( Eval ) \ <nl> + V ( Function ) \ <nl> + V ( InterpretedFunction ) \ <nl> + V ( Handler ) \ <nl> + V ( BytecodeHandler ) \ <nl> + V ( LazyCompile ) \ <nl> + V ( RegExp ) \ <nl> + V ( Script ) \ <nl> + V ( Stub ) <nl> + <nl> + / * * <nl> + * Note that this enum may be extended in the future . Please include a default <nl> + * case if this enum is used in a switch statement . <nl> + * / <nl> + enum CodeEventType { <nl> + kUnknownType = 0 <nl> + # define V ( Name ) , k # # Name # # Type <nl> + CODE_EVENTS_LIST ( V ) <nl> + # undef V <nl> + } ; <nl> + <nl> + / * * <nl> + * Representation of a code creation event <nl> + * / <nl> + class V8_EXPORT CodeEvent { <nl> + public : <nl> + uintptr_t GetCodeStartAddress ( ) ; <nl> + size_t GetCodeSize ( ) ; <nl> + Local < String > GetFunctionName ( ) ; <nl> + Local < String > GetScriptName ( ) ; <nl> + int GetScriptLine ( ) ; <nl> + int GetScriptColumn ( ) ; <nl> + / * * <nl> + * NOTE ( mmarchini ) : We can ' t allocate objects in the heap when we collect <nl> + * existing code , and both the code type and the comment are not stored in the <nl> + * heap , so we return those as const char * . <nl> + * / <nl> + CodeEventType GetCodeType ( ) ; <nl> + const char * GetComment ( ) ; <nl> + <nl> + static const char * GetCodeEventTypeName ( CodeEventType code_event_type ) ; <nl> + } ; <nl> + <nl> + / * * <nl> + * Interface to listen to code creation events . <nl> + * / <nl> + class V8_EXPORT CodeEventHandler { <nl> + public : <nl> + / * * <nl> + * Creates a new listener for the | isolate | . The isolate must be initialized . <nl> + * The listener object must be disposed after use by calling | Dispose | method . <nl> + * Multiple listeners can be created for the same isolate . <nl> + * / <nl> + explicit CodeEventHandler ( Isolate * isolate ) ; <nl> + virtual ~ CodeEventHandler ( ) ; <nl> + <nl> + virtual void Handle ( CodeEvent * code_event ) = 0 ; <nl> + <nl> + void Enable ( ) ; <nl> + void Disable ( ) ; <nl> + <nl> + private : <nl> + CodeEventHandler ( ) ; <nl> + CodeEventHandler ( const CodeEventHandler & ) ; <nl> + CodeEventHandler & operator = ( const CodeEventHandler & ) ; <nl> + void * internal_listener_ ; <nl> + } ; <nl> <nl> } / / namespace v8 <nl> <nl> mmm a / src / api . cc <nl> ppp b / src / api . cc <nl> void CpuProfiler : : SetIdle ( bool is_idle ) { <nl> isolate - > SetIdle ( is_idle ) ; <nl> } <nl> <nl> + uintptr_t CodeEvent : : GetCodeStartAddress ( ) { <nl> + return reinterpret_cast < i : : CodeEvent * > ( this ) - > code_start_address ; <nl> + } <nl> + <nl> + size_t CodeEvent : : GetCodeSize ( ) { <nl> + return reinterpret_cast < i : : CodeEvent * > ( this ) - > code_size ; <nl> + } <nl> + <nl> + Local < String > CodeEvent : : GetFunctionName ( ) { <nl> + return ToApiHandle < String > ( <nl> + reinterpret_cast < i : : CodeEvent * > ( this ) - > function_name ) ; <nl> + } <nl> + <nl> + Local < String > CodeEvent : : GetScriptName ( ) { <nl> + return ToApiHandle < String > ( <nl> + reinterpret_cast < i : : CodeEvent * > ( this ) - > script_name ) ; <nl> + } <nl> + <nl> + int CodeEvent : : GetScriptLine ( ) { <nl> + return reinterpret_cast < i : : CodeEvent * > ( this ) - > script_line ; <nl> + } <nl> + <nl> + int CodeEvent : : GetScriptColumn ( ) { <nl> + return reinterpret_cast < i : : CodeEvent * > ( this ) - > script_column ; <nl> + } <nl> + <nl> + CodeEventType CodeEvent : : GetCodeType ( ) { <nl> + return reinterpret_cast < i : : CodeEvent * > ( this ) - > code_type ; <nl> + } <nl> + <nl> + const char * CodeEvent : : GetComment ( ) { <nl> + return reinterpret_cast < i : : CodeEvent * > ( this ) - > comment ; <nl> + } <nl> + <nl> + const char * CodeEvent : : GetCodeEventTypeName ( CodeEventType code_event_type ) { <nl> + switch ( code_event_type ) { <nl> + case kUnknownType : <nl> + return " Unknown " ; <nl> + # define V ( Name ) \ <nl> + case k # # Name # # Type : \ <nl> + return # Name ; <nl> + CODE_EVENTS_LIST ( V ) <nl> + # undef V <nl> + } <nl> + } <nl> + <nl> + CodeEventHandler : : CodeEventHandler ( Isolate * isolate ) { <nl> + internal_listener_ = <nl> + new i : : ExternalCodeEventListener ( reinterpret_cast < i : : Isolate * > ( isolate ) ) ; <nl> + } <nl> + <nl> + CodeEventHandler : : ~ CodeEventHandler ( ) { <nl> + delete reinterpret_cast < i : : ExternalCodeEventListener * > ( internal_listener_ ) ; <nl> + } <nl> + <nl> + void CodeEventHandler : : Enable ( ) { <nl> + reinterpret_cast < i : : ExternalCodeEventListener * > ( internal_listener_ ) <nl> + - > StartListening ( this ) ; <nl> + } <nl> + <nl> + void CodeEventHandler : : Disable ( ) { <nl> + reinterpret_cast < i : : ExternalCodeEventListener * > ( internal_listener_ ) <nl> + - > StopListening ( ) ; <nl> + } <nl> <nl> static i : : HeapGraphEdge * ToInternal ( const HeapGraphEdge * edge ) { <nl> return const_cast < i : : HeapGraphEdge * > ( <nl> mmm a / src / code - events . h <nl> ppp b / src / code - events . h <nl> class WasmCode ; <nl> using WasmName = Vector < const char > ; <nl> } / / namespace wasm <nl> <nl> - # define LOG_EVENTS_AND_TAGS_LIST ( V ) \ <nl> - V ( CODE_CREATION_EVENT , " code - creation " ) \ <nl> - V ( CODE_DISABLE_OPT_EVENT , " code - disable - optimization " ) \ <nl> - V ( CODE_MOVE_EVENT , " code - move " ) \ <nl> - V ( CODE_DELETE_EVENT , " code - delete " ) \ <nl> - V ( CODE_MOVING_GC , " code - moving - gc " ) \ <nl> - V ( SHARED_FUNC_MOVE_EVENT , " sfi - move " ) \ <nl> - V ( SNAPSHOT_CODE_NAME_EVENT , " snapshot - code - name " ) \ <nl> - V ( TICK_EVENT , " tick " ) \ <nl> - V ( BUILTIN_TAG , " Builtin " ) \ <nl> - V ( CALLBACK_TAG , " Callback " ) \ <nl> - V ( EVAL_TAG , " Eval " ) \ <nl> - V ( FUNCTION_TAG , " Function " ) \ <nl> - V ( INTERPRETED_FUNCTION_TAG , " InterpretedFunction " ) \ <nl> - V ( HANDLER_TAG , " Handler " ) \ <nl> - V ( BYTECODE_HANDLER_TAG , " BytecodeHandler " ) \ <nl> - V ( LAZY_COMPILE_TAG , " LazyCompile " ) \ <nl> - V ( REG_EXP_TAG , " RegExp " ) \ <nl> - V ( SCRIPT_TAG , " Script " ) \ <nl> - V ( STUB_TAG , " Stub " ) \ <nl> - V ( NATIVE_FUNCTION_TAG , " Function " ) \ <nl> - V ( NATIVE_LAZY_COMPILE_TAG , " LazyCompile " ) \ <nl> - V ( NATIVE_SCRIPT_TAG , " Script " ) <nl> + # define LOG_EVENTS_LIST ( V ) \ <nl> + V ( CODE_CREATION_EVENT , code - creation ) \ <nl> + V ( CODE_DISABLE_OPT_EVENT , code - disable - optimization ) \ <nl> + V ( CODE_MOVE_EVENT , code - move ) \ <nl> + V ( CODE_DELETE_EVENT , code - delete ) \ <nl> + V ( CODE_MOVING_GC , code - moving - gc ) \ <nl> + V ( SHARED_FUNC_MOVE_EVENT , sfi - move ) \ <nl> + V ( SNAPSHOT_CODE_NAME_EVENT , snapshot - code - name ) \ <nl> + V ( TICK_EVENT , tick ) <nl> + <nl> + # define TAGS_LIST ( V ) \ <nl> + V ( BUILTIN_TAG , Builtin ) \ <nl> + V ( CALLBACK_TAG , Callback ) \ <nl> + V ( EVAL_TAG , Eval ) \ <nl> + V ( FUNCTION_TAG , Function ) \ <nl> + V ( INTERPRETED_FUNCTION_TAG , InterpretedFunction ) \ <nl> + V ( HANDLER_TAG , Handler ) \ <nl> + V ( BYTECODE_HANDLER_TAG , BytecodeHandler ) \ <nl> + V ( LAZY_COMPILE_TAG , LazyCompile ) \ <nl> + V ( REG_EXP_TAG , RegExp ) \ <nl> + V ( SCRIPT_TAG , Script ) \ <nl> + V ( STUB_TAG , Stub ) \ <nl> + V ( NATIVE_FUNCTION_TAG , Function ) \ <nl> + V ( NATIVE_LAZY_COMPILE_TAG , LazyCompile ) \ <nl> + V ( NATIVE_SCRIPT_TAG , Script ) <nl> / / Note that ' NATIVE_ ' cases for functions and scripts are mapped onto <nl> / / original tags when writing to the log . <nl> <nl> + # define LOG_EVENTS_AND_TAGS_LIST ( V ) \ <nl> + LOG_EVENTS_LIST ( V ) \ <nl> + TAGS_LIST ( V ) <nl> + <nl> # define PROFILE ( the_isolate , Call ) ( the_isolate ) - > code_event_dispatcher ( ) - > Call ; <nl> <nl> class CodeEventListener { <nl> class CodeEventListener { <nl> enum DeoptKind { kSoft , kLazy , kEager } ; <nl> virtual void CodeDeoptEvent ( Code * code , DeoptKind kind , Address pc , <nl> int fp_to_sp_delta ) = 0 ; <nl> + <nl> + virtual bool is_listening_to_code_events ( ) { return false ; } <nl> } ; <nl> <nl> class CodeEventDispatcher { <nl> class CodeEventDispatcher { <nl> base : : LockGuard < base : : Mutex > guard ( & mutex_ ) ; <nl> listeners_ . erase ( listener ) ; <nl> } <nl> + bool IsListeningToCodeEvents ( ) { <nl> + for ( auto it : listeners_ ) { <nl> + if ( it - > is_listening_to_code_events ( ) ) { <nl> + return true ; <nl> + } <nl> + } <nl> + return false ; <nl> + } <nl> <nl> # define CODE_EVENT_DISPATCH ( code ) \ <nl> base : : LockGuard < base : : Mutex > guard ( & mutex_ ) ; \ <nl> mmm a / src / compiler . cc <nl> ppp b / src / compiler . cc <nl> void LogFunctionCompilation ( CodeEventListener : : LogEventsAndTags tag , <nl> / / Log the code generation . If source information is available include <nl> / / script name and line number . Check explicitly whether logging is <nl> / / enabled as finding the line number is not free . <nl> - if ( ! isolate - > logger ( ) - > is_logging_code_events ( ) & & <nl> - ! isolate - > is_profiling ( ) & & ! FLAG_log_function_events ) { <nl> + if ( ! isolate - > logger ( ) - > is_listening_to_code_events ( ) & & <nl> + ! isolate - > is_profiling ( ) & & ! FLAG_log_function_events & & <nl> + ! isolate - > code_event_dispatcher ( ) - > IsListeningToCodeEvents ( ) ) { <nl> return ; <nl> } <nl> <nl> mmm a / src / compiler / wasm - compiler . cc <nl> ppp b / src / compiler / wasm - compiler . cc <nl> Node * WasmGraphBuilder : : AtomicOp ( wasm : : WasmOpcode opcode , Node * const * inputs , <nl> <nl> namespace { <nl> bool must_record_function_compilation ( Isolate * isolate ) { <nl> - return isolate - > logger ( ) - > is_logging_code_events ( ) | | isolate - > is_profiling ( ) ; <nl> + return isolate - > logger ( ) - > is_listening_to_code_events ( ) | | <nl> + isolate - > is_profiling ( ) ; <nl> } <nl> <nl> PRINTF_FORMAT ( 4 , 5 ) <nl> mmm a / src / heap / mark - compact . cc <nl> ppp b / src / heap / mark - compact . cc <nl> void MarkCompactCollectorBase : : CreateAndExecuteEvacuationTasks ( <nl> <nl> const bool profiling = <nl> heap ( ) - > isolate ( ) - > is_profiling ( ) | | <nl> - heap ( ) - > isolate ( ) - > logger ( ) - > is_logging_code_events ( ) | | <nl> + heap ( ) - > isolate ( ) - > logger ( ) - > is_listening_to_code_events ( ) | | <nl> heap ( ) - > isolate ( ) - > heap_profiler ( ) - > is_tracking_object_moves ( ) | | <nl> heap ( ) - > has_heap_object_allocation_tracker ( ) ; <nl> ProfilingMigrationObserver profiling_observer ( heap ( ) ) ; <nl> mmm a / src / isolate . cc <nl> ppp b / src / isolate . cc <nl> void CreateOffHeapTrampolines ( Isolate * isolate ) { <nl> / / thus collected by the GC . <nl> builtins - > set_builtin ( i , * trampoline ) ; <nl> <nl> - if ( isolate - > logger ( ) - > is_logging_code_events ( ) | | <nl> + if ( isolate - > logger ( ) - > is_listening_to_code_events ( ) | | <nl> isolate - > is_profiling ( ) ) { <nl> isolate - > logger ( ) - > LogCodeObject ( * trampoline ) ; <nl> } <nl> mmm a / src / isolate . h <nl> ppp b / src / isolate . h <nl> class BuiltinsConstantsTableBuilder ; <nl> class CallInterfaceDescriptorData ; <nl> class CancelableTaskManager ; <nl> class CodeEventDispatcher ; <nl> + class ExternalCodeEventListener ; <nl> class CodeGenerator ; <nl> class CodeRange ; <nl> class CodeStubDescriptor ; <nl> mmm a / src / log . cc <nl> ppp b / src / log . cc <nl> <nl> namespace v8 { <nl> namespace internal { <nl> <nl> - # define DECLARE_EVENT ( ignore1 , name ) name , <nl> + # define DECLARE_EVENT ( ignore1 , name ) # name , <nl> static const char * kLogEventsNames [ CodeEventListener : : NUMBER_OF_LOG_EVENTS ] = { <nl> LOG_EVENTS_AND_TAGS_LIST ( DECLARE_EVENT ) } ; <nl> # undef DECLARE_EVENT <nl> <nl> + static v8 : : CodeEventType GetCodeEventTypeForTag ( <nl> + CodeEventListener : : LogEventsAndTags tag ) { <nl> + switch ( tag ) { <nl> + case CodeEventListener : : NUMBER_OF_LOG_EVENTS : <nl> + # define V ( Event , _ ) case CodeEventListener : : Event : <nl> + LOG_EVENTS_LIST ( V ) <nl> + # undef V <nl> + return v8 : : CodeEventType : : kUnknownType ; <nl> + # define V ( From , To ) \ <nl> + case CodeEventListener : : From : \ <nl> + return v8 : : CodeEventType : : k # # To # # Type ; <nl> + TAGS_LIST ( V ) <nl> + # undef V <nl> + } <nl> + } <nl> + # define CALL_CODE_EVENT_HANDLER ( Call ) \ <nl> + if ( listener_ ) { \ <nl> + listener_ - > Call ; \ <nl> + } else { \ <nl> + PROFILE ( isolate_ , Call ) ; \ <nl> + } <nl> + <nl> static const char * ComputeMarker ( SharedFunctionInfo * shared , <nl> AbstractCode * code ) { <nl> switch ( code - > kind ( ) ) { <nl> void PerfBasicLogger : : LogRecordedBuffer ( const wasm : : WasmCode * code , <nl> code - > instructions ( ) . length ( ) , name , length ) ; <nl> } <nl> <nl> - / / Low - level logging support . <nl> - # define LL_LOG ( Call ) if ( ll_logger_ ) ll_logger_ - > Call ; <nl> + / / External CodeEventListener <nl> + ExternalCodeEventListener : : ExternalCodeEventListener ( Isolate * isolate ) <nl> + : is_listening_ ( false ) , isolate_ ( isolate ) , code_event_handler_ ( nullptr ) { } <nl> + <nl> + ExternalCodeEventListener : : ~ ExternalCodeEventListener ( ) { <nl> + if ( is_listening_ ) { <nl> + StopListening ( ) ; <nl> + } <nl> + } <nl> + <nl> + void ExternalCodeEventListener : : LogExistingCode ( ) { <nl> + HandleScope scope ( isolate_ ) ; <nl> + ExistingCodeLogger logger ( isolate_ , this ) ; <nl> + logger . LogCodeObjects ( ) ; <nl> + logger . LogBytecodeHandlers ( ) ; <nl> + logger . LogCompiledFunctions ( ) ; <nl> + } <nl> + <nl> + void ExternalCodeEventListener : : StartListening ( <nl> + CodeEventHandler * code_event_handler ) { <nl> + if ( is_listening_ | | code_event_handler = = nullptr ) { <nl> + return ; <nl> + } <nl> + code_event_handler_ = code_event_handler ; <nl> + is_listening_ = isolate_ - > code_event_dispatcher ( ) - > AddListener ( this ) ; <nl> + if ( is_listening_ ) { <nl> + LogExistingCode ( ) ; <nl> + } <nl> + } <nl> <nl> + void ExternalCodeEventListener : : StopListening ( ) { <nl> + if ( ! is_listening_ ) { <nl> + return ; <nl> + } <nl> + <nl> + isolate_ - > code_event_dispatcher ( ) - > RemoveListener ( this ) ; <nl> + is_listening_ = false ; <nl> + } <nl> + <nl> + void ExternalCodeEventListener : : CodeCreateEvent ( <nl> + CodeEventListener : : LogEventsAndTags tag , AbstractCode * code , <nl> + const char * comment ) { <nl> + CodeEvent code_event ; <nl> + code_event . code_start_address = <nl> + static_cast < uintptr_t > ( code - > InstructionStart ( ) ) ; <nl> + code_event . code_size = static_cast < size_t > ( code - > InstructionSize ( ) ) ; <nl> + code_event . function_name = isolate_ - > factory ( ) - > empty_string ( ) ; <nl> + code_event . script_name = isolate_ - > factory ( ) - > empty_string ( ) ; <nl> + code_event . script_line = 0 ; <nl> + code_event . script_column = 0 ; <nl> + code_event . code_type = GetCodeEventTypeForTag ( tag ) ; <nl> + code_event . comment = comment ; <nl> + <nl> + code_event_handler_ - > Handle ( reinterpret_cast < v8 : : CodeEvent * > ( & code_event ) ) ; <nl> + } <nl> + <nl> + void ExternalCodeEventListener : : CodeCreateEvent ( <nl> + CodeEventListener : : LogEventsAndTags tag , AbstractCode * code , Name * name ) { <nl> + Handle < String > name_string = <nl> + Name : : ToFunctionName ( Handle < Name > ( name , isolate_ ) ) . ToHandleChecked ( ) ; <nl> + <nl> + CodeEvent code_event ; <nl> + code_event . code_start_address = <nl> + static_cast < uintptr_t > ( code - > InstructionStart ( ) ) ; <nl> + code_event . code_size = static_cast < size_t > ( code - > InstructionSize ( ) ) ; <nl> + code_event . function_name = name_string ; <nl> + code_event . script_name = isolate_ - > factory ( ) - > empty_string ( ) ; <nl> + code_event . script_line = 0 ; <nl> + code_event . script_column = 0 ; <nl> + code_event . code_type = GetCodeEventTypeForTag ( tag ) ; <nl> + code_event . comment = " " ; <nl> + <nl> + code_event_handler_ - > Handle ( reinterpret_cast < v8 : : CodeEvent * > ( & code_event ) ) ; <nl> + } <nl> + <nl> + void ExternalCodeEventListener : : CodeCreateEvent ( <nl> + CodeEventListener : : LogEventsAndTags tag , AbstractCode * code , <nl> + SharedFunctionInfo * shared , Name * name ) { <nl> + Handle < String > name_string = <nl> + Name : : ToFunctionName ( Handle < Name > ( name , isolate_ ) ) . ToHandleChecked ( ) ; <nl> + <nl> + CodeEvent code_event ; <nl> + code_event . code_start_address = <nl> + static_cast < uintptr_t > ( code - > InstructionStart ( ) ) ; <nl> + code_event . code_size = static_cast < size_t > ( code - > InstructionSize ( ) ) ; <nl> + code_event . function_name = name_string ; <nl> + code_event . script_name = isolate_ - > factory ( ) - > empty_string ( ) ; <nl> + code_event . script_line = 0 ; <nl> + code_event . script_column = 0 ; <nl> + code_event . code_type = GetCodeEventTypeForTag ( tag ) ; <nl> + code_event . comment = " " ; <nl> + <nl> + code_event_handler_ - > Handle ( reinterpret_cast < v8 : : CodeEvent * > ( & code_event ) ) ; <nl> + } <nl> + <nl> + void ExternalCodeEventListener : : CodeCreateEvent ( <nl> + CodeEventListener : : LogEventsAndTags tag , AbstractCode * code , <nl> + SharedFunctionInfo * shared , Name * source , int line , int column ) { <nl> + Handle < String > name_string = <nl> + Name : : ToFunctionName ( Handle < Name > ( shared - > Name ( ) , isolate_ ) ) <nl> + . ToHandleChecked ( ) ; <nl> + Handle < String > source_string = <nl> + Name : : ToFunctionName ( Handle < Name > ( source , isolate_ ) ) . ToHandleChecked ( ) ; <nl> + <nl> + CodeEvent code_event ; <nl> + code_event . code_start_address = <nl> + static_cast < uintptr_t > ( code - > InstructionStart ( ) ) ; <nl> + code_event . code_size = static_cast < size_t > ( code - > InstructionSize ( ) ) ; <nl> + code_event . function_name = name_string ; <nl> + code_event . script_name = source_string ; <nl> + code_event . script_line = line ; <nl> + code_event . script_column = column ; <nl> + code_event . code_type = GetCodeEventTypeForTag ( tag ) ; <nl> + code_event . comment = " " ; <nl> + <nl> + code_event_handler_ - > Handle ( reinterpret_cast < v8 : : CodeEvent * > ( & code_event ) ) ; <nl> + } <nl> + <nl> + void ExternalCodeEventListener : : CodeCreateEvent ( LogEventsAndTags tag , <nl> + const wasm : : WasmCode * code , <nl> + wasm : : WasmName name ) { <nl> + / / TODO ( mmarchini ) : handle later <nl> + } <nl> + <nl> + void ExternalCodeEventListener : : RegExpCodeCreateEvent ( AbstractCode * code , <nl> + String * source ) { <nl> + CodeEvent code_event ; <nl> + code_event . code_start_address = <nl> + static_cast < uintptr_t > ( code - > InstructionStart ( ) ) ; <nl> + code_event . code_size = static_cast < size_t > ( code - > InstructionSize ( ) ) ; <nl> + code_event . function_name = Handle < String > ( source , isolate_ ) ; <nl> + code_event . script_name = isolate_ - > factory ( ) - > empty_string ( ) ; <nl> + code_event . script_line = 0 ; <nl> + code_event . script_column = 0 ; <nl> + code_event . code_type = GetCodeEventTypeForTag ( CodeEventListener : : REG_EXP_TAG ) ; <nl> + code_event . comment = " " ; <nl> + <nl> + code_event_handler_ - > Handle ( reinterpret_cast < v8 : : CodeEvent * > ( & code_event ) ) ; <nl> + } <nl> + <nl> + / / Low - level logging support . <nl> class LowLevelLogger : public CodeEventLogger { <nl> public : <nl> explicit LowLevelLogger ( const char * file_name ) ; <nl> Logger : : Logger ( Isolate * isolate ) <nl> perf_jit_logger_ ( nullptr ) , <nl> ll_logger_ ( nullptr ) , <nl> jit_logger_ ( nullptr ) , <nl> - is_initialized_ ( false ) { } <nl> + is_initialized_ ( false ) , <nl> + existing_code_logger_ ( isolate ) { } <nl> <nl> Logger : : ~ Logger ( ) { <nl> delete log_ ; <nl> void AppendCodeCreateHeader ( Log : : MessageBuilder & msg , <nl> <nl> void Logger : : CodeCreateEvent ( CodeEventListener : : LogEventsAndTags tag , <nl> AbstractCode * code , const char * comment ) { <nl> - if ( ! is_logging_code_events ( ) ) return ; <nl> + if ( ! is_listening_to_code_events ( ) ) return ; <nl> if ( ! FLAG_log_code | | ! log_ - > IsEnabled ( ) ) return ; <nl> Log : : MessageBuilder msg ( log_ ) ; <nl> AppendCodeCreateHeader ( msg , tag , code , & timer_ ) ; <nl> void Logger : : CodeCreateEvent ( CodeEventListener : : LogEventsAndTags tag , <nl> <nl> void Logger : : CodeCreateEvent ( CodeEventListener : : LogEventsAndTags tag , <nl> AbstractCode * code , Name * name ) { <nl> - if ( ! is_logging_code_events ( ) ) return ; <nl> + if ( ! is_listening_to_code_events ( ) ) return ; <nl> if ( ! FLAG_log_code | | ! log_ - > IsEnabled ( ) ) return ; <nl> Log : : MessageBuilder msg ( log_ ) ; <nl> AppendCodeCreateHeader ( msg , tag , code , & timer_ ) ; <nl> void Logger : : CodeCreateEvent ( CodeEventListener : : LogEventsAndTags tag , <nl> void Logger : : CodeCreateEvent ( CodeEventListener : : LogEventsAndTags tag , <nl> AbstractCode * code , SharedFunctionInfo * shared , <nl> Name * name ) { <nl> - if ( ! is_logging_code_events ( ) ) return ; <nl> + if ( ! is_listening_to_code_events ( ) ) return ; <nl> if ( ! FLAG_log_code | | ! log_ - > IsEnabled ( ) ) return ; <nl> if ( code = = AbstractCode : : cast ( <nl> isolate_ - > builtins ( ) - > builtin ( Builtins : : kCompileLazy ) ) ) { <nl> void Logger : : CodeCreateEvent ( CodeEventListener : : LogEventsAndTags tag , <nl> <nl> void Logger : : CodeCreateEvent ( CodeEventListener : : LogEventsAndTags tag , <nl> const wasm : : WasmCode * code , wasm : : WasmName name ) { <nl> - if ( ! is_logging_code_events ( ) ) return ; <nl> + if ( ! is_listening_to_code_events ( ) ) return ; <nl> if ( ! FLAG_log_code | | ! log_ - > IsEnabled ( ) ) return ; <nl> Log : : MessageBuilder msg ( log_ ) ; <nl> AppendCodeCreateHeader ( msg , tag , AbstractCode : : Kind : : WASM_FUNCTION , <nl> void Logger : : CodeCreateEvent ( CodeEventListener : : LogEventsAndTags tag , <nl> void Logger : : CodeCreateEvent ( CodeEventListener : : LogEventsAndTags tag , <nl> AbstractCode * code , SharedFunctionInfo * shared , <nl> Name * source , int line , int column ) { <nl> - if ( ! is_logging_code_events ( ) ) return ; <nl> + if ( ! is_listening_to_code_events ( ) ) return ; <nl> if ( ! FLAG_log_code | | ! log_ - > IsEnabled ( ) ) return ; <nl> <nl> Log : : MessageBuilder msg ( log_ ) ; <nl> void Logger : : CodeCreateEvent ( CodeEventListener : : LogEventsAndTags tag , <nl> <nl> void Logger : : CodeDisableOptEvent ( AbstractCode * code , <nl> SharedFunctionInfo * shared ) { <nl> - if ( ! is_logging_code_events ( ) ) return ; <nl> + if ( ! is_listening_to_code_events ( ) ) return ; <nl> if ( ! FLAG_log_code | | ! log_ - > IsEnabled ( ) ) return ; <nl> Log : : MessageBuilder msg ( log_ ) ; <nl> msg < < kLogEventsNames [ CodeEventListener : : CODE_DISABLE_OPT_EVENT ] < < kNext <nl> void Logger : : CodeDisableOptEvent ( AbstractCode * code , <nl> <nl> <nl> void Logger : : CodeMovingGCEvent ( ) { <nl> - if ( ! is_logging_code_events ( ) ) return ; <nl> + if ( ! is_listening_to_code_events ( ) ) return ; <nl> if ( ! log_ - > IsEnabled ( ) | | ! FLAG_ll_prof ) return ; <nl> base : : OS : : SignalCodeMovingGC ( ) ; <nl> } <nl> <nl> void Logger : : RegExpCodeCreateEvent ( AbstractCode * code , String * source ) { <nl> - if ( ! is_logging_code_events ( ) ) return ; <nl> + if ( ! is_listening_to_code_events ( ) ) return ; <nl> if ( ! FLAG_log_code | | ! log_ - > IsEnabled ( ) ) return ; <nl> Log : : MessageBuilder msg ( log_ ) ; <nl> AppendCodeCreateHeader ( msg , CodeEventListener : : REG_EXP_TAG , code , & timer_ ) ; <nl> void Logger : : RegExpCodeCreateEvent ( AbstractCode * code , String * source ) { <nl> } <nl> <nl> void Logger : : CodeMoveEvent ( AbstractCode * from , Address to ) { <nl> - if ( ! is_logging_code_events ( ) ) return ; <nl> + if ( ! is_listening_to_code_events ( ) ) return ; <nl> MoveEventInternal ( CodeEventListener : : CODE_MOVE_EVENT , from - > address ( ) , to ) ; <nl> } <nl> <nl> void Logger : : CodeNameEvent ( Address addr , int pos , const char * code_name ) { <nl> <nl> <nl> void Logger : : SharedFunctionInfoMoveEvent ( Address from , Address to ) { <nl> - if ( ! is_logging_code_events ( ) ) return ; <nl> + if ( ! is_listening_to_code_events ( ) ) return ; <nl> MoveEventInternal ( CodeEventListener : : SHARED_FUNC_MOVE_EVENT , from , to ) ; <nl> } <nl> <nl> static int EnumerateWasmModules ( Heap * heap , <nl> } <nl> <nl> void Logger : : LogCodeObject ( Object * object ) { <nl> - AbstractCode * code_object = AbstractCode : : cast ( object ) ; <nl> - CodeEventListener : : LogEventsAndTags tag = CodeEventListener : : STUB_TAG ; <nl> - const char * description = " Unknown code from the snapshot " ; <nl> - switch ( code_object - > kind ( ) ) { <nl> - case AbstractCode : : INTERPRETED_FUNCTION : <nl> - case AbstractCode : : OPTIMIZED_FUNCTION : <nl> - return ; / / We log this later using LogCompiledFunctions . <nl> - case AbstractCode : : BYTECODE_HANDLER : <nl> - return ; / / We log it later by walking the dispatch table . <nl> - case AbstractCode : : STUB : <nl> - description = <nl> - CodeStub : : MajorName ( CodeStub : : GetMajorKey ( code_object - > GetCode ( ) ) ) ; <nl> - if ( description = = nullptr ) description = " A stub from the snapshot " ; <nl> - tag = CodeEventListener : : STUB_TAG ; <nl> - break ; <nl> - case AbstractCode : : REGEXP : <nl> - description = " Regular expression code " ; <nl> - tag = CodeEventListener : : REG_EXP_TAG ; <nl> - break ; <nl> - case AbstractCode : : BUILTIN : <nl> - description = <nl> - isolate_ - > builtins ( ) - > name ( code_object - > GetCode ( ) - > builtin_index ( ) ) ; <nl> - tag = CodeEventListener : : BUILTIN_TAG ; <nl> - break ; <nl> - case AbstractCode : : WASM_FUNCTION : <nl> - description = " A Wasm function " ; <nl> - tag = CodeEventListener : : FUNCTION_TAG ; <nl> - break ; <nl> - case AbstractCode : : JS_TO_WASM_FUNCTION : <nl> - description = " A JavaScript to Wasm adapter " ; <nl> - tag = CodeEventListener : : STUB_TAG ; <nl> - break ; <nl> - case AbstractCode : : WASM_TO_JS_FUNCTION : <nl> - description = " A Wasm to JavaScript adapter " ; <nl> - tag = CodeEventListener : : STUB_TAG ; <nl> - break ; <nl> - case AbstractCode : : WASM_INTERPRETER_ENTRY : <nl> - description = " A Wasm to Interpreter adapter " ; <nl> - tag = CodeEventListener : : STUB_TAG ; <nl> - break ; <nl> - case AbstractCode : : C_WASM_ENTRY : <nl> - description = " A C to Wasm entry stub " ; <nl> - tag = CodeEventListener : : STUB_TAG ; <nl> - break ; <nl> - case AbstractCode : : NUMBER_OF_KINDS : <nl> - UNIMPLEMENTED ( ) ; <nl> - } <nl> - PROFILE ( isolate_ , CodeCreateEvent ( tag , code_object , description ) ) ; <nl> + existing_code_logger_ . LogCodeObject ( object ) ; <nl> } <nl> <nl> - void Logger : : LogCodeObjects ( ) { <nl> - Heap * heap = isolate_ - > heap ( ) ; <nl> - HeapIterator iterator ( heap ) ; <nl> - DisallowHeapAllocation no_gc ; <nl> - for ( HeapObject * obj = iterator . next ( ) ; obj ! = nullptr ; <nl> - obj = iterator . next ( ) ) { <nl> - if ( obj - > IsCode ( ) ) LogCodeObject ( obj ) ; <nl> - if ( obj - > IsBytecodeArray ( ) ) LogCodeObject ( obj ) ; <nl> - } <nl> - } <nl> + void Logger : : LogCodeObjects ( ) { existing_code_logger_ . LogCodeObjects ( ) ; } <nl> <nl> void Logger : : LogBytecodeHandler ( interpreter : : Bytecode bytecode , <nl> interpreter : : OperandScale operand_scale , <nl> Code * code ) { <nl> - std : : string bytecode_name = <nl> - interpreter : : Bytecodes : : ToString ( bytecode , operand_scale ) ; <nl> - PROFILE ( isolate_ , <nl> - CodeCreateEvent ( CodeEventListener : : BYTECODE_HANDLER_TAG , <nl> - AbstractCode : : cast ( code ) , bytecode_name . c_str ( ) ) ) ; <nl> + existing_code_logger_ . LogBytecodeHandler ( bytecode , operand_scale , code ) ; <nl> } <nl> <nl> void Logger : : LogBytecodeHandlers ( ) { <nl> - const interpreter : : OperandScale kOperandScales [ ] = { <nl> - # define VALUE ( Name , _ ) interpreter : : OperandScale : : k # # Name , <nl> - OPERAND_SCALE_LIST ( VALUE ) <nl> - # undef VALUE <nl> - } ; <nl> - <nl> - const int last_index = static_cast < int > ( interpreter : : Bytecode : : kLast ) ; <nl> - interpreter : : Interpreter * interpreter = isolate_ - > interpreter ( ) ; <nl> - for ( auto operand_scale : kOperandScales ) { <nl> - for ( int index = 0 ; index < = last_index ; + + index ) { <nl> - interpreter : : Bytecode bytecode = interpreter : : Bytecodes : : FromByte ( index ) ; <nl> - if ( interpreter : : Bytecodes : : BytecodeHasHandler ( bytecode , operand_scale ) ) { <nl> - Code * code = interpreter - > GetBytecodeHandler ( bytecode , operand_scale ) ; <nl> - if ( isolate_ - > heap ( ) - > IsDeserializeLazyHandler ( code ) ) continue ; <nl> - LogBytecodeHandler ( bytecode , operand_scale , code ) ; <nl> - } <nl> - } <nl> - } <nl> + existing_code_logger_ . LogBytecodeHandlers ( ) ; <nl> } <nl> <nl> void Logger : : LogExistingFunction ( Handle < SharedFunctionInfo > shared , <nl> Handle < AbstractCode > code ) { <nl> - if ( shared - > script ( ) - > IsScript ( ) ) { <nl> - Handle < Script > script ( Script : : cast ( shared - > script ( ) ) ) ; <nl> - int line_num = Script : : GetLineNumber ( script , shared - > StartPosition ( ) ) + 1 ; <nl> - int column_num = <nl> - Script : : GetColumnNumber ( script , shared - > StartPosition ( ) ) + 1 ; <nl> - if ( script - > name ( ) - > IsString ( ) ) { <nl> - Handle < String > script_name ( String : : cast ( script - > name ( ) ) ) ; <nl> - if ( line_num > 0 ) { <nl> - PROFILE ( isolate_ , <nl> - CodeCreateEvent ( <nl> - Logger : : ToNativeByScript ( <nl> - CodeEventListener : : LAZY_COMPILE_TAG , * script ) , <nl> - * code , * shared , * script_name , line_num , column_num ) ) ; <nl> - } else { <nl> - / / Can ' t distinguish eval and script here , so always use Script . <nl> - PROFILE ( isolate_ , <nl> - CodeCreateEvent ( Logger : : ToNativeByScript ( <nl> - CodeEventListener : : SCRIPT_TAG , * script ) , <nl> - * code , * shared , * script_name ) ) ; <nl> - } <nl> - } else { <nl> - PROFILE ( isolate_ , <nl> - CodeCreateEvent ( Logger : : ToNativeByScript ( <nl> - CodeEventListener : : LAZY_COMPILE_TAG , * script ) , <nl> - * code , * shared , isolate_ - > heap ( ) - > empty_string ( ) , <nl> - line_num , column_num ) ) ; <nl> - } <nl> - } else if ( shared - > IsApiFunction ( ) ) { <nl> - / / API function . <nl> - FunctionTemplateInfo * fun_data = shared - > get_api_func_data ( ) ; <nl> - Object * raw_call_data = fun_data - > call_code ( ) ; <nl> - if ( ! raw_call_data - > IsUndefined ( isolate_ ) ) { <nl> - CallHandlerInfo * call_data = CallHandlerInfo : : cast ( raw_call_data ) ; <nl> - Object * callback_obj = call_data - > callback ( ) ; <nl> - Address entry_point = v8 : : ToCData < Address > ( callback_obj ) ; <nl> - # if USES_FUNCTION_DESCRIPTORS <nl> - entry_point = * FUNCTION_ENTRYPOINT_ADDRESS ( entry_point ) ; <nl> - # endif <nl> - PROFILE ( isolate_ , CallbackEvent ( shared - > DebugName ( ) , entry_point ) ) ; <nl> - } <nl> - } else { <nl> - PROFILE ( isolate_ , <nl> - CodeCreateEvent ( CodeEventListener : : LAZY_COMPILE_TAG , * code , * shared , <nl> - isolate_ - > heap ( ) - > empty_string ( ) ) ) ; <nl> - } <nl> + existing_code_logger_ . LogExistingFunction ( shared , code ) ; <nl> } <nl> <nl> void Logger : : LogCompiledFunctions ( ) { <nl> - Heap * heap = isolate_ - > heap ( ) ; <nl> - HandleScope scope ( isolate_ ) ; <nl> - const int compiled_funcs_count = <nl> - EnumerateCompiledFunctions ( heap , nullptr , nullptr ) ; <nl> - ScopedVector < Handle < SharedFunctionInfo > > sfis ( compiled_funcs_count ) ; <nl> - ScopedVector < Handle < AbstractCode > > code_objects ( compiled_funcs_count ) ; <nl> - EnumerateCompiledFunctions ( heap , sfis . start ( ) , code_objects . start ( ) ) ; <nl> - <nl> - / / During iteration , there can be heap allocation due to <nl> - / / GetScriptLineNumber call . <nl> - for ( int i = 0 ; i < compiled_funcs_count ; + + i ) { <nl> - if ( code_objects [ i ] . is_identical_to ( BUILTIN_CODE ( isolate_ , CompileLazy ) ) ) <nl> - continue ; <nl> - LogExistingFunction ( sfis [ i ] , code_objects [ i ] ) ; <nl> - } <nl> - <nl> - const int compiled_wasm_modules_count = EnumerateWasmModules ( heap , nullptr ) ; <nl> - ScopedVector < Handle < WasmCompiledModule > > modules ( compiled_wasm_modules_count ) ; <nl> - EnumerateWasmModules ( heap , modules . start ( ) ) ; <nl> - for ( int i = 0 ; i < compiled_wasm_modules_count ; + + i ) { <nl> - modules [ i ] - > LogWasmCodes ( isolate_ ) ; <nl> - } <nl> + existing_code_logger_ . LogCompiledFunctions ( ) ; <nl> } <nl> <nl> void Logger : : LogAccessorCallbacks ( ) { <nl> FILE * Logger : : TearDown ( ) { <nl> return log_ - > Close ( ) ; <nl> } <nl> <nl> + void ExistingCodeLogger : : LogCodeObject ( Object * object ) { <nl> + AbstractCode * code_object = AbstractCode : : cast ( object ) ; <nl> + CodeEventListener : : LogEventsAndTags tag = CodeEventListener : : STUB_TAG ; <nl> + const char * description = " Unknown code from before profiling " ; <nl> + switch ( code_object - > kind ( ) ) { <nl> + case AbstractCode : : INTERPRETED_FUNCTION : <nl> + case AbstractCode : : OPTIMIZED_FUNCTION : <nl> + return ; / / We log this later using LogCompiledFunctions . <nl> + case AbstractCode : : BYTECODE_HANDLER : <nl> + return ; / / We log it later by walking the dispatch table . <nl> + case AbstractCode : : STUB : <nl> + description = <nl> + CodeStub : : MajorName ( CodeStub : : GetMajorKey ( code_object - > GetCode ( ) ) ) ; <nl> + if ( description = = nullptr ) description = " A stub from before profiling " ; <nl> + tag = CodeEventListener : : STUB_TAG ; <nl> + break ; <nl> + case AbstractCode : : REGEXP : <nl> + description = " Regular expression code " ; <nl> + tag = CodeEventListener : : REG_EXP_TAG ; <nl> + break ; <nl> + case AbstractCode : : BUILTIN : <nl> + description = <nl> + isolate_ - > builtins ( ) - > name ( code_object - > GetCode ( ) - > builtin_index ( ) ) ; <nl> + tag = CodeEventListener : : BUILTIN_TAG ; <nl> + break ; <nl> + case AbstractCode : : WASM_FUNCTION : <nl> + description = " A Wasm function " ; <nl> + tag = CodeEventListener : : FUNCTION_TAG ; <nl> + break ; <nl> + case AbstractCode : : JS_TO_WASM_FUNCTION : <nl> + description = " A JavaScript to Wasm adapter " ; <nl> + tag = CodeEventListener : : STUB_TAG ; <nl> + break ; <nl> + case AbstractCode : : WASM_TO_JS_FUNCTION : <nl> + description = " A Wasm to JavaScript adapter " ; <nl> + tag = CodeEventListener : : STUB_TAG ; <nl> + break ; <nl> + case AbstractCode : : WASM_INTERPRETER_ENTRY : <nl> + description = " A Wasm to Interpreter adapter " ; <nl> + tag = CodeEventListener : : STUB_TAG ; <nl> + break ; <nl> + case AbstractCode : : C_WASM_ENTRY : <nl> + description = " A C to Wasm entry stub " ; <nl> + tag = CodeEventListener : : STUB_TAG ; <nl> + break ; <nl> + case AbstractCode : : NUMBER_OF_KINDS : <nl> + UNIMPLEMENTED ( ) ; <nl> + } <nl> + CALL_CODE_EVENT_HANDLER ( CodeCreateEvent ( tag , code_object , description ) ) <nl> + } <nl> + <nl> + void ExistingCodeLogger : : LogCodeObjects ( ) { <nl> + Heap * heap = isolate_ - > heap ( ) ; <nl> + HeapIterator iterator ( heap ) ; <nl> + DisallowHeapAllocation no_gc ; <nl> + for ( HeapObject * obj = iterator . next ( ) ; obj ! = nullptr ; <nl> + obj = iterator . next ( ) ) { <nl> + if ( obj - > IsCode ( ) ) LogCodeObject ( obj ) ; <nl> + if ( obj - > IsBytecodeArray ( ) ) LogCodeObject ( obj ) ; <nl> + } <nl> + } <nl> + <nl> + void ExistingCodeLogger : : LogCompiledFunctions ( ) { <nl> + Heap * heap = isolate_ - > heap ( ) ; <nl> + HandleScope scope ( isolate_ ) ; <nl> + const int compiled_funcs_count = <nl> + EnumerateCompiledFunctions ( heap , nullptr , nullptr ) ; <nl> + ScopedVector < Handle < SharedFunctionInfo > > sfis ( compiled_funcs_count ) ; <nl> + ScopedVector < Handle < AbstractCode > > code_objects ( compiled_funcs_count ) ; <nl> + EnumerateCompiledFunctions ( heap , sfis . start ( ) , code_objects . start ( ) ) ; <nl> + <nl> + / / During iteration , there can be heap allocation due to <nl> + / / GetScriptLineNumber call . <nl> + for ( int i = 0 ; i < compiled_funcs_count ; + + i ) { <nl> + if ( code_objects [ i ] . is_identical_to ( BUILTIN_CODE ( isolate_ , CompileLazy ) ) ) <nl> + continue ; <nl> + LogExistingFunction ( sfis [ i ] , code_objects [ i ] ) ; <nl> + } <nl> + <nl> + const int compiled_wasm_modules_count = EnumerateWasmModules ( heap , nullptr ) ; <nl> + ScopedVector < Handle < WasmCompiledModule > > modules ( compiled_wasm_modules_count ) ; <nl> + EnumerateWasmModules ( heap , modules . start ( ) ) ; <nl> + for ( int i = 0 ; i < compiled_wasm_modules_count ; + + i ) { <nl> + modules [ i ] - > LogWasmCodes ( isolate_ ) ; <nl> + } <nl> + } <nl> + <nl> + void ExistingCodeLogger : : LogBytecodeHandler ( <nl> + interpreter : : Bytecode bytecode , interpreter : : OperandScale operand_scale , <nl> + Code * code ) { <nl> + std : : string bytecode_name = <nl> + interpreter : : Bytecodes : : ToString ( bytecode , operand_scale ) ; <nl> + CALL_CODE_EVENT_HANDLER ( <nl> + CodeCreateEvent ( CodeEventListener : : BYTECODE_HANDLER_TAG , <nl> + AbstractCode : : cast ( code ) , bytecode_name . c_str ( ) ) ) <nl> + } <nl> + <nl> + void ExistingCodeLogger : : LogBytecodeHandlers ( ) { <nl> + const interpreter : : OperandScale kOperandScales [ ] = { <nl> + # define VALUE ( Name , _ ) interpreter : : OperandScale : : k # # Name , <nl> + OPERAND_SCALE_LIST ( VALUE ) <nl> + # undef VALUE <nl> + } ; <nl> + <nl> + const int last_index = static_cast < int > ( interpreter : : Bytecode : : kLast ) ; <nl> + interpreter : : Interpreter * interpreter = isolate_ - > interpreter ( ) ; <nl> + for ( auto operand_scale : kOperandScales ) { <nl> + for ( int index = 0 ; index < = last_index ; + + index ) { <nl> + interpreter : : Bytecode bytecode = interpreter : : Bytecodes : : FromByte ( index ) ; <nl> + if ( interpreter : : Bytecodes : : BytecodeHasHandler ( bytecode , operand_scale ) ) { <nl> + Code * code = interpreter - > GetBytecodeHandler ( bytecode , operand_scale ) ; <nl> + if ( isolate_ - > heap ( ) - > IsDeserializeLazyHandler ( code ) ) continue ; <nl> + LogBytecodeHandler ( bytecode , operand_scale , code ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + void ExistingCodeLogger : : LogExistingFunction ( Handle < SharedFunctionInfo > shared , <nl> + Handle < AbstractCode > code ) { <nl> + if ( shared - > script ( ) - > IsScript ( ) ) { <nl> + Handle < Script > script ( Script : : cast ( shared - > script ( ) ) ) ; <nl> + int line_num = Script : : GetLineNumber ( script , shared - > StartPosition ( ) ) + 1 ; <nl> + int column_num = <nl> + Script : : GetColumnNumber ( script , shared - > StartPosition ( ) ) + 1 ; <nl> + if ( script - > name ( ) - > IsString ( ) ) { <nl> + Handle < String > script_name ( String : : cast ( script - > name ( ) ) ) ; <nl> + if ( line_num > 0 ) { <nl> + CALL_CODE_EVENT_HANDLER ( <nl> + CodeCreateEvent ( Logger : : ToNativeByScript ( <nl> + CodeEventListener : : LAZY_COMPILE_TAG , * script ) , <nl> + * code , * shared , * script_name , line_num , column_num ) ) <nl> + } else { <nl> + / / Can ' t distinguish eval and script here , so always use Script . <nl> + CALL_CODE_EVENT_HANDLER ( CodeCreateEvent ( <nl> + Logger : : ToNativeByScript ( CodeEventListener : : SCRIPT_TAG , * script ) , <nl> + * code , * shared , * script_name ) ) <nl> + } <nl> + } else { <nl> + CALL_CODE_EVENT_HANDLER ( <nl> + CodeCreateEvent ( Logger : : ToNativeByScript ( <nl> + CodeEventListener : : LAZY_COMPILE_TAG , * script ) , <nl> + * code , * shared , isolate_ - > heap ( ) - > empty_string ( ) , <nl> + line_num , column_num ) ) <nl> + } <nl> + } else if ( shared - > IsApiFunction ( ) ) { <nl> + / / API function . <nl> + FunctionTemplateInfo * fun_data = shared - > get_api_func_data ( ) ; <nl> + Object * raw_call_data = fun_data - > call_code ( ) ; <nl> + if ( ! raw_call_data - > IsUndefined ( isolate_ ) ) { <nl> + CallHandlerInfo * call_data = CallHandlerInfo : : cast ( raw_call_data ) ; <nl> + Object * callback_obj = call_data - > callback ( ) ; <nl> + Address entry_point = v8 : : ToCData < Address > ( callback_obj ) ; <nl> + # if USES_FUNCTION_DESCRIPTORS <nl> + entry_point = * FUNCTION_ENTRYPOINT_ADDRESS ( entry_point ) ; <nl> + # endif <nl> + CALL_CODE_EVENT_HANDLER ( CallbackEvent ( shared - > DebugName ( ) , entry_point ) ) <nl> + } <nl> + } else { <nl> + CALL_CODE_EVENT_HANDLER ( CodeCreateEvent ( CodeEventListener : : LAZY_COMPILE_TAG , <nl> + * code , * shared , <nl> + isolate_ - > heap ( ) - > empty_string ( ) ) ) <nl> + } <nl> + } <nl> + <nl> + # undef CALL_CODE_EVENT_HANDLER <nl> + <nl> } / / namespace internal <nl> } / / namespace v8 <nl> mmm a / src / log . h <nl> ppp b / src / log . h <nl> <nl> # include < set > <nl> # include < string > <nl> <nl> + # include " include / v8 - profiler . h " <nl> # include " src / allocation . h " <nl> # include " src / base / compiler - specific . h " <nl> # include " src / base / platform / elapsed - timer . h " <nl> class WasmCode ; <nl> if ( logger - > is_logging ( ) ) logger - > Call ; \ <nl> } while ( false ) <nl> <nl> - # define LOG_CODE_EVENT ( isolate , Call ) \ <nl> - do { \ <nl> - v8 : : internal : : Logger * logger = ( isolate ) - > logger ( ) ; \ <nl> - if ( logger - > is_logging_code_events ( ) ) logger - > Call ; \ <nl> + # define LOG_CODE_EVENT ( isolate , Call ) \ <nl> + do { \ <nl> + v8 : : internal : : Logger * logger = ( isolate ) - > logger ( ) ; \ <nl> + if ( logger - > is_listening_to_code_events ( ) ) logger - > Call ; \ <nl> } while ( false ) <nl> <nl> + class ExistingCodeLogger { <nl> + public : <nl> + explicit ExistingCodeLogger ( Isolate * isolate , <nl> + CodeEventListener * listener = nullptr ) <nl> + : isolate_ ( isolate ) , listener_ ( listener ) { } <nl> + <nl> + void LogCodeObjects ( ) ; <nl> + void LogBytecodeHandlers ( ) ; <nl> + <nl> + void LogCompiledFunctions ( ) ; <nl> + void LogExistingFunction ( Handle < SharedFunctionInfo > shared , <nl> + Handle < AbstractCode > code ) ; <nl> + void LogCodeObject ( Object * object ) ; <nl> + void LogBytecodeHandler ( interpreter : : Bytecode bytecode , <nl> + interpreter : : OperandScale operand_scale , Code * code ) ; <nl> + <nl> + private : <nl> + Isolate * isolate_ ; <nl> + CodeEventListener * listener_ ; <nl> + } ; <nl> + <nl> class Logger : public CodeEventListener { <nl> public : <nl> enum StartEnd { START = 0 , END = 1 , STAMP = 2 } ; <nl> class Logger : public CodeEventListener { <nl> return is_logging_ ; <nl> } <nl> <nl> - bool is_logging_code_events ( ) { <nl> + bool is_listening_to_code_events ( ) { <nl> return is_logging ( ) | | jit_logger_ ! = nullptr ; <nl> } <nl> <nl> class Logger : public CodeEventListener { <nl> / / ' true ' between SetUp ( ) and TearDown ( ) . <nl> bool is_initialized_ ; <nl> <nl> + ExistingCodeLogger existing_code_logger_ ; <nl> + <nl> base : : ElapsedTimer timer_ ; <nl> <nl> friend class CpuProfiler ; <nl> class CodeEventLogger : public CodeEventListener { <nl> NameBuffer * name_buffer_ ; <nl> } ; <nl> <nl> + struct CodeEvent { <nl> + uintptr_t code_start_address ; <nl> + size_t code_size ; <nl> + Handle < String > function_name ; <nl> + Handle < String > script_name ; <nl> + int script_line ; <nl> + int script_column ; <nl> + CodeEventType code_type ; <nl> + const char * comment ; <nl> + } ; <nl> + <nl> + class ExternalCodeEventListener : public CodeEventListener { <nl> + public : <nl> + explicit ExternalCodeEventListener ( Isolate * isolate ) ; <nl> + ~ ExternalCodeEventListener ( ) override ; <nl> + <nl> + void CodeCreateEvent ( LogEventsAndTags tag , AbstractCode * code , <nl> + const char * comment ) override ; <nl> + void CodeCreateEvent ( LogEventsAndTags tag , AbstractCode * code , <nl> + Name * name ) override ; <nl> + void CodeCreateEvent ( LogEventsAndTags tag , AbstractCode * code , <nl> + SharedFunctionInfo * shared , Name * name ) override ; <nl> + void CodeCreateEvent ( LogEventsAndTags tag , AbstractCode * code , <nl> + SharedFunctionInfo * shared , Name * source , int line , <nl> + int column ) override ; <nl> + void CodeCreateEvent ( LogEventsAndTags tag , const wasm : : WasmCode * code , <nl> + wasm : : WasmName name ) override ; <nl> + <nl> + void RegExpCodeCreateEvent ( AbstractCode * code , String * source ) override ; <nl> + void CallbackEvent ( Name * name , Address entry_point ) override { } <nl> + void GetterCallbackEvent ( Name * name , Address entry_point ) override { } <nl> + void SetterCallbackEvent ( Name * name , Address entry_point ) override { } <nl> + void SharedFunctionInfoMoveEvent ( Address from , Address to ) override { } <nl> + void CodeMoveEvent ( AbstractCode * from , Address to ) override { } <nl> + void CodeDisableOptEvent ( AbstractCode * code , <nl> + SharedFunctionInfo * shared ) override { } <nl> + void CodeMovingGCEvent ( ) override { } <nl> + void CodeDeoptEvent ( Code * code , DeoptKind kind , Address pc , <nl> + int fp_to_sp_delta ) override { } <nl> + <nl> + void StartListening ( CodeEventHandler * code_event_handler ) ; <nl> + void StopListening ( ) ; <nl> + <nl> + bool is_listening_to_code_events ( ) override { return true ; } <nl> + <nl> + private : <nl> + void LogExistingCode ( ) ; <nl> + <nl> + bool is_listening_ ; <nl> + Isolate * isolate_ ; <nl> + v8 : : CodeEventHandler * code_event_handler_ ; <nl> + } ; <nl> <nl> } / / namespace internal <nl> } / / namespace v8 <nl> mmm a / src / runtime / runtime - function . cc <nl> ppp b / src / runtime / runtime - function . cc <nl> RUNTIME_FUNCTION ( Runtime_SetCode ) { <nl> / / the target_shared optimized code map . <nl> JSFunction : : EnsureFeedbackVector ( target ) ; <nl> <nl> - if ( isolate - > logger ( ) - > is_logging_code_events ( ) | | isolate - > is_profiling ( ) ) { <nl> + if ( isolate - > logger ( ) - > is_listening_to_code_events ( ) | | <nl> + isolate - > is_profiling ( ) ) { <nl> isolate - > logger ( ) - > LogExistingFunction ( <nl> source_shared , Handle < AbstractCode > ( source_shared - > abstract_code ( ) ) ) ; <nl> } <nl> mmm a / src / snapshot / code - serializer . cc <nl> ppp b / src / snapshot / code - serializer . cc <nl> MaybeHandle < SharedFunctionInfo > CodeSerializer : : Deserialize ( <nl> PrintF ( " [ Deserializing from % d bytes took % 0 . 3f ms ] \ n " , length , ms ) ; <nl> } <nl> <nl> - if ( isolate - > logger ( ) - > is_logging_code_events ( ) | | isolate - > is_profiling ( ) ) { <nl> + if ( isolate - > logger ( ) - > is_listening_to_code_events ( ) | | <nl> + isolate - > is_profiling ( ) ) { <nl> String * name = isolate - > heap ( ) - > empty_string ( ) ; <nl> if ( result - > script ( ) - > IsScript ( ) ) { <nl> Script * script = Script : : cast ( result - > script ( ) ) ; <nl> mmm a / src / snapshot / snapshot - common . cc <nl> ppp b / src / snapshot / snapshot - common . cc <nl> Code * Snapshot : : DeserializeBuiltin ( Isolate * isolate , int builtin_id ) { <nl> Builtins : : name ( builtin_id ) , bytes , ms ) ; <nl> } <nl> <nl> - if ( isolate - > logger ( ) - > is_logging_code_events ( ) | | isolate - > is_profiling ( ) ) { <nl> + if ( isolate - > logger ( ) - > is_listening_to_code_events ( ) | | <nl> + isolate - > is_profiling ( ) ) { <nl> isolate - > logger ( ) - > LogCodeObject ( code ) ; <nl> } <nl> <nl> Code * Snapshot : : DeserializeHandler ( Isolate * isolate , <nl> bytes , ms ) ; <nl> } <nl> <nl> - if ( isolate - > logger ( ) - > is_logging_code_events ( ) | | isolate - > is_profiling ( ) ) { <nl> + if ( isolate - > logger ( ) - > is_listening_to_code_events ( ) | | <nl> + isolate - > is_profiling ( ) ) { <nl> isolate - > logger ( ) - > LogBytecodeHandler ( bytecode , operand_scale , code ) ; <nl> } <nl> <nl> mmm a / src / wasm / wasm - code - manager . cc <nl> ppp b / src / wasm / wasm - code - manager . cc <nl> bool WasmCode : : HasTrapHandlerIndex ( ) const { return trap_handler_index_ > = 0 ; } <nl> void WasmCode : : ResetTrapHandlerIndex ( ) { trap_handler_index_ = - 1 ; } <nl> <nl> bool WasmCode : : ShouldBeLogged ( Isolate * isolate ) { <nl> - return isolate - > logger ( ) - > is_logging_code_events ( ) | | <nl> + return isolate - > logger ( ) - > is_listening_to_code_events ( ) | | <nl> isolate - > is_profiling ( ) | | FLAG_print_wasm_code | | FLAG_print_code ; <nl> } <nl> <nl> mmm a / test / cctest / test - log . cc <nl> ppp b / test / cctest / test - log . cc <nl> <nl> # endif / / __linux__ <nl> <nl> # include < unordered_set > <nl> + # include < vector > <nl> # include " src / api . h " <nl> # include " src / log - utils . h " <nl> # include " src / log . h " <nl> class ScopedLoggerInitializer { <nl> DISALLOW_COPY_AND_ASSIGN ( ScopedLoggerInitializer ) ; <nl> } ; <nl> <nl> + class TestCodeEventHandler : public v8 : : CodeEventHandler { <nl> + public : <nl> + explicit TestCodeEventHandler ( v8 : : Isolate * isolate ) <nl> + : v8 : : CodeEventHandler ( isolate ) { } <nl> + <nl> + const char * FindLine ( const char * prefix , const char * suffix = nullptr , <nl> + const char * start = nullptr ) { <nl> + if ( ! log_ . length ( ) ) return NULL ; <nl> + const char * c_log = log_ . c_str ( ) ; <nl> + if ( start = = nullptr ) start = c_log ; <nl> + const char * end = c_log + log_ . length ( ) ; <nl> + return FindLogLine ( start , end , prefix , suffix ) ; <nl> + } <nl> + <nl> + void Handle ( v8 : : CodeEvent * code_event ) override { <nl> + const char * code_type = <nl> + v8 : : CodeEvent : : GetCodeEventTypeName ( code_event - > GetCodeType ( ) ) ; <nl> + char function_name [ 1000 ] ; <nl> + strncpy ( function_name , code_type , 1000 ) ; <nl> + function_name [ strlen ( code_type ) ] = ' ' ; <nl> + code_event - > GetFunctionName ( ) - > WriteUtf8 ( <nl> + function_name + strlen ( code_type ) + 1 , 1000 ) ; <nl> + function_name [ strlen ( function_name ) + 1 ] = ' \ 0 ' ; <nl> + function_name [ strlen ( function_name ) ] = ' \ n ' ; <nl> + <nl> + log_ + = std : : string ( function_name ) ; <nl> + } <nl> + <nl> + private : <nl> + std : : string log_ ; <nl> + } ; <nl> + <nl> } / / namespace <nl> <nl> TEST ( FindLogLine ) { <nl> TEST ( LogInterpretedFramesNativeStack ) { <nl> isolate - > Dispose ( ) ; <nl> } <nl> <nl> + TEST ( ExternalCodeEventListener ) { <nl> + i : : FLAG_log = false ; <nl> + i : : FLAG_prof = false ; <nl> + <nl> + v8 : : Isolate : : CreateParams create_params ; <nl> + create_params . array_buffer_allocator = CcTest : : array_buffer_allocator ( ) ; <nl> + v8 : : Isolate * isolate = v8 : : Isolate : : New ( create_params ) ; <nl> + <nl> + { <nl> + v8 : : HandleScope scope ( isolate ) ; <nl> + v8 : : Isolate : : Scope isolate_scope ( isolate ) ; <nl> + v8 : : Local < v8 : : Context > context = v8 : : Context : : New ( isolate ) ; <nl> + context - > Enter ( ) ; <nl> + <nl> + TestCodeEventHandler code_event_handler ( isolate ) ; <nl> + <nl> + const char * source_text_before_start = <nl> + " function testCodeEventListenerBeforeStart ( a , b ) { return a + b } ; " <nl> + " testCodeEventListenerBeforeStart ( ' 1 ' , 1 ) ; " ; <nl> + CompileRun ( source_text_before_start ) ; <nl> + <nl> + CHECK_NULL ( code_event_handler . FindLine ( " LazyCompile " , <nl> + " testCodeEventListenerBeforeStart " ) ) ; <nl> + <nl> + code_event_handler . Enable ( ) ; <nl> + <nl> + CHECK_NOT_NULL ( code_event_handler . FindLine ( <nl> + " LazyCompile " , " testCodeEventListenerBeforeStart " ) ) ; <nl> + <nl> + const char * source_text_after_start = <nl> + " function testCodeEventListenerAfterStart ( a , b ) { return a + b } ; " <nl> + " testCodeEventListenerAfterStart ( ' 1 ' , 1 ) ; " ; <nl> + CompileRun ( source_text_after_start ) ; <nl> + <nl> + CHECK_NOT_NULL ( code_event_handler . FindLine ( <nl> + " LazyCompile " , " testCodeEventListenerAfterStart " ) ) ; <nl> + <nl> + context - > Exit ( ) ; <nl> + } <nl> + isolate - > Dispose ( ) ; <nl> + } <nl> + <nl> TEST ( TraceMaps ) { <nl> SETUP_FLAGS ( ) ; <nl> i : : FLAG_trace_maps = true ; <nl>
|
[ log ] [ api ] introduce public CodeEventListener API
|
v8/v8
|
aa6ce3ee617b2f324bea3a5d8e3263aee4cde6d7
|
2018-05-28T09:27:24Z
|
mmm a / fdbserver / OldTLogServer_6_0 . actor . cpp <nl> ppp b / fdbserver / OldTLogServer_6_0 . actor . cpp <nl> struct LogData : NonCopyable , public ReferenceCounted < LogData > { <nl> struct PeekTrackerData { <nl> std : : map < int , Promise < std : : pair < Version , bool > > > sequence_version ; <nl> double lastUpdate ; <nl> + <nl> + Tag tag ; <nl> + <nl> + double lastLogged ; <nl> + int64_t totalPeeks ; <nl> + int64_t replyBytes ; <nl> + int64_t duplicatePeeks ; <nl> + double queueTime ; <nl> + double queueMax ; <nl> + double blockTime ; <nl> + double blockMax ; <nl> + double workTime ; <nl> + double workMax ; <nl> + <nl> + int64_t unblockedPeeks ; <nl> + double idleTime ; <nl> + double idleMax ; <nl> + <nl> + PeekTrackerData ( ) : lastUpdate ( 0 ) { <nl> + resetMetrics ( ) ; <nl> + } <nl> + <nl> + void resetMetrics ( ) { <nl> + lastLogged = now ( ) ; <nl> + totalPeeks = 0 ; <nl> + replyBytes = 0 ; <nl> + duplicatePeeks = 0 ; <nl> + queueTime = 0 ; <nl> + queueMax = 0 ; <nl> + blockTime = 0 ; <nl> + blockMax = 0 ; <nl> + workTime = 0 ; <nl> + workMax = 0 ; <nl> + unblockedPeeks = 0 ; <nl> + idleTime = 0 ; <nl> + idleMax = 0 ; <nl> + } <nl> } ; <nl> <nl> std : : map < UID , PeekTrackerData > peekTracker ; <nl> ACTOR Future < Void > tLogPeekMessages ( TLogData * self , TLogPeekRequest req , Refere <nl> state BinaryWriter messages2 ( Unversioned ( ) ) ; <nl> state int sequence = - 1 ; <nl> state UID peekId ; <nl> + state double queueStart = now ( ) ; <nl> <nl> if ( req . sequence . present ( ) ) { <nl> try { <nl> ACTOR Future < Void > tLogPeekMessages ( TLogData * self , TLogPeekRequest req , Refere <nl> } <nl> auto & trackerData = logData - > peekTracker [ peekId ] ; <nl> if ( sequence = = 0 & & trackerData . sequence_version . find ( 0 ) = = trackerData . sequence_version . end ( ) ) { <nl> + trackerData . tag = req . tag ; <nl> trackerData . sequence_version [ 0 ] . send ( std : : make_pair ( req . begin , req . onlySpilled ) ) ; <nl> } <nl> auto seqBegin = trackerData . sequence_version . begin ( ) ; <nl> ACTOR Future < Void > tLogPeekMessages ( TLogData * self , TLogPeekRequest req , Refere <nl> throw timed_out ( ) ; <nl> } <nl> <nl> + Future < std : : pair < Version , bool > > fPrevPeekData = trackerData . sequence_version [ sequence ] . getFuture ( ) ; <nl> + if ( fPrevPeekData . isReady ( ) ) { <nl> + trackerData . unblockedPeeks + + ; <nl> + double t = now ( ) - trackerData . lastUpdate ; <nl> + if ( t > trackerData . idleMax ) trackerData . idleMax = t ; <nl> + trackerData . idleTime + = t ; <nl> + } <nl> trackerData . lastUpdate = now ( ) ; <nl> - std : : pair < Version , bool > prevPeekData = wait ( trackerData . sequence_version [ sequence ] . getFuture ( ) ) ; <nl> + std : : pair < Version , bool > prevPeekData = wait ( fPrevPeekData ) ; <nl> + <nl> req . begin = prevPeekData . first ; <nl> req . onlySpilled = prevPeekData . second ; <nl> wait ( yield ( ) ) ; <nl> ACTOR Future < Void > tLogPeekMessages ( TLogData * self , TLogPeekRequest req , Refere <nl> } <nl> } <nl> <nl> + state double blockStart = now ( ) ; <nl> + <nl> if ( req . returnIfBlocked & & logData - > version . get ( ) < req . begin ) { <nl> req . reply . sendError ( end_of_stream ( ) ) ; <nl> if ( req . sequence . present ( ) ) { <nl> ACTOR Future < Void > tLogPeekMessages ( TLogData * self , TLogPeekRequest req , Refere <nl> wait ( delay ( 0 , TaskPriority : : TLogSpilledPeekReply ) ) ; <nl> } <nl> <nl> + state double workStart = now ( ) ; <nl> + <nl> Version poppedVer = poppedVersion ( logData , req . tag ) ; <nl> if ( poppedVer > req . begin ) { <nl> TLogPeekReply rep ; <nl> ACTOR Future < Void > tLogPeekMessages ( TLogData * self , TLogPeekRequest req , Refere <nl> if ( req . sequence . present ( ) ) { <nl> auto & trackerData = logData - > peekTracker [ peekId ] ; <nl> trackerData . lastUpdate = now ( ) ; <nl> + <nl> + double queueT = blockStart - queueStart ; <nl> + double blockT = workStart - blockStart ; <nl> + double workT = now ( ) - workStart ; <nl> + <nl> + trackerData . totalPeeks + + ; <nl> + trackerData . replyBytes + = reply . messages . size ( ) ; <nl> + <nl> + if ( queueT > trackerData . queueMax ) trackerData . queueMax = queueT ; <nl> + if ( blockT > trackerData . blockMax ) trackerData . blockMax = blockT ; <nl> + if ( workT > trackerData . workMax ) trackerData . workMax = workT ; <nl> + <nl> + trackerData . queueTime + = queueT ; <nl> + trackerData . blockTime + = blockT ; <nl> + trackerData . workTime + = workT ; <nl> + <nl> auto & sequenceData = trackerData . sequence_version [ sequence + 1 ] ; <nl> if ( trackerData . sequence_version . size ( ) & & sequence + 1 < trackerData . sequence_version . begin ( ) - > first ) { <nl> req . reply . sendError ( timed_out ( ) ) ; <nl> ACTOR Future < Void > tLogPeekMessages ( TLogData * self , TLogPeekRequest req , Refere <nl> return Void ( ) ; <nl> } <nl> if ( sequenceData . isSet ( ) ) { <nl> + trackerData . duplicatePeeks + + ; <nl> if ( sequenceData . getFuture ( ) . get ( ) . first ! = reply . end ) { <nl> TEST ( true ) ; / / tlog peek second attempt ended at a different version <nl> req . reply . sendError ( timed_out ( ) ) ; <nl> ACTOR Future < Void > cleanupPeekTrackers ( LogData * logData ) { <nl> } <nl> } <nl> <nl> + ACTOR Future < Void > logPeekTrackers ( LogData * logData ) { <nl> + loop { <nl> + int64_t logThreshold = 1 ; <nl> + if ( logData - > peekTracker . size ( ) > SERVER_KNOBS - > PEEK_LOGGING_AMOUNT ) { <nl> + std : : vector < int64_t > peekCounts ; <nl> + peekCounts . reserve ( logData - > peekTracker . size ( ) ) ; <nl> + for ( auto & it : logData - > peekTracker ) { <nl> + peekCounts . push_back ( it . second . totalPeeks ) ; <nl> + } <nl> + size_t pivot = peekCounts . size ( ) - SERVER_KNOBS - > PEEK_LOGGING_AMOUNT ; <nl> + std : : nth_element ( peekCounts . begin ( ) , peekCounts . begin ( ) + pivot , peekCounts . end ( ) ) ; <nl> + logThreshold = std : : max < int64_t > ( 1 , peekCounts [ pivot ] ) ; <nl> + } <nl> + int logCount = 0 ; <nl> + for ( auto & it : logData - > peekTracker ) { <nl> + if ( it . second . totalPeeks > = logThreshold ) { <nl> + logCount + + ; <nl> + TraceEvent ( " PeekMetrics " , logData - > logId ) <nl> + . detail ( " Tag " , it . second . tag . toString ( ) ) <nl> + . detail ( " Elapsed " , now ( ) - it . second . lastLogged ) <nl> + . detail ( " MeanReplyBytes " , it . second . replyBytes / it . second . totalPeeks ) <nl> + . detail ( " TotalPeeks " , it . second . totalPeeks ) <nl> + . detail ( " UnblockedPeeks " , it . second . unblockedPeeks ) <nl> + . detail ( " DuplicatePeeks " , it . second . duplicatePeeks ) <nl> + . detail ( " Sequence " , it . second . sequence_version . size ( ) ? it . second . sequence_version . begin ( ) - > first : - 1 ) <nl> + . detail ( " IdleSeconds " , it . second . idleTime ) <nl> + . detail ( " IdleMax " , it . second . idleMax ) <nl> + . detail ( " QueueSeconds " , it . second . queueTime ) <nl> + . detail ( " QueueMax " , it . second . queueMax ) <nl> + . detail ( " BlockSeconds " , it . second . blockTime ) <nl> + . detail ( " BlockMax " , it . second . blockMax ) <nl> + . detail ( " WorkSeconds " , it . second . workTime ) <nl> + . detail ( " WorkMax " , it . second . workMax ) ; <nl> + it . second . resetMetrics ( ) ; <nl> + } <nl> + } <nl> + <nl> + wait ( delay ( SERVER_KNOBS - > PEEK_LOGGING_DELAY * std : : max ( 1 , logCount ) ) ) ; <nl> + } <nl> + } <nl> + <nl> void getQueuingMetrics ( TLogData * self , Reference < LogData > logData , TLogQueuingMetricsRequest const & req ) { <nl> TLogQueuingMetricsReply reply ; <nl> reply . localTime = now ( ) ; <nl> ACTOR Future < Void > tLogCore ( TLogData * self , Reference < LogData > logData , TLogInt <nl> logData - > addActor . send ( traceCounters ( " TLogMetrics " , logData - > logId , SERVER_KNOBS - > STORAGE_LOGGING_DELAY , & logData - > cc , logData - > logId . toString ( ) + " / TLogMetrics " ) ) ; <nl> logData - > addActor . send ( serveTLogInterface ( self , tli , logData , warningCollectorInput ) ) ; <nl> logData - > addActor . send ( cleanupPeekTrackers ( logData . getPtr ( ) ) ) ; <nl> + logData - > addActor . send ( logPeekTrackers ( logData . getPtr ( ) ) ) ; <nl> <nl> if ( ! logData - > isPrimary ) { <nl> std : : vector < Tag > tags ; <nl>
|
ported peek metrics to old tlog 6 . 0
|
apple/foundationdb
|
91fba9106dcdf5b42cb8b953a11584a5d58e4dec
|
2020-04-23T06:35:48Z
|
mmm a / src / csharp / GrpcCore / Utils / RecordingQueue . cs <nl> ppp b / src / csharp / GrpcCore / Utils / RecordingQueue . cs <nl> <nl> <nl> namespace Google . GRPC . Core . Utils <nl> { <nl> + / / / < summary > <nl> + / / / Observer that allows us to await incoming messages one - by - one . <nl> + / / / The implementation is not ideal and class will be probably replaced <nl> + / / / by something more versatile in the future . <nl> + / / / < / summary > <nl> public class RecordingQueue < T > : IObserver < T > <nl> { <nl> readonly BlockingCollection < T > queue = new BlockingCollection < T > ( ) ; <nl> similarity index 98 % <nl> rename from src / csharp / InteropClient / InteropClient . cs <nl> rename to src / csharp / InteropClient / Client . cs <nl> mmm a / src / csharp / InteropClient / InteropClient . cs <nl> ppp b / src / csharp / InteropClient / Client . cs <nl> <nl> using Google . ProtocolBuffers ; <nl> using grpc . testing ; <nl> <nl> - namespace InteropClient <nl> + namespace Google . GRPC . Interop <nl> { <nl> - class InteropClient <nl> + class Client <nl> { <nl> private class ClientOptions <nl> { <nl> private class ClientOptions <nl> <nl> ClientOptions options ; <nl> <nl> - private InteropClient ( ClientOptions options ) { <nl> + private Client ( ClientOptions options ) <nl> + { <nl> this . options = options ; <nl> } <nl> <nl> public static void Main ( string [ ] args ) <nl> Environment . Exit ( 1 ) ; <nl> } <nl> <nl> - var interopClient = new InteropClient ( options ) ; <nl> + var interopClient = new Client ( options ) ; <nl> interopClient . Run ( ) ; <nl> } <nl> <nl> mmm a / src / csharp / InteropClient / InteropClient . csproj <nl> ppp b / src / csharp / InteropClient / InteropClient . csproj <nl> <nl> < OutputType > Exe < / OutputType > <nl> < RootNamespace > InteropClient < / RootNamespace > <nl> < AssemblyName > InteropClient < / AssemblyName > <nl> - < StartupObject > InteropClient . InteropClient < / StartupObject > <nl> + < StartupObject > Google . GRPC . Interop . Client < / StartupObject > <nl> < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> < / PropertyGroup > <nl> < PropertyGroup Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug | x86 ' " > <nl> <nl> < / ItemGroup > <nl> < ItemGroup > <nl> < Compile Include = " Properties \ AssemblyInfo . cs " / > <nl> - < Compile Include = " InteropClient . cs " / > <nl> + < Compile Include = " Client . cs " / > <nl> < / ItemGroup > <nl> < Import Project = " $ ( MSBuildBinPath ) \ Microsoft . CSharp . targets " / > <nl> < ItemGroup > <nl>
|
addressed review comments
|
grpc/grpc
|
392d1e0cfe0c478dbf08cadc75618b2588dc028a
|
2015-02-09T19:13:51Z
|
mmm a / js / apps / system / _admin / aardvark / APP / frontend / js / templates / databaseView . ejs <nl> ppp b / js / apps / system / _admin / aardvark / APP / frontend / js / templates / databaseView . ejs <nl> <nl> <nl> <nl> < div class = " contentDiv " id = " arangoCollectionsContainer " > <nl> - < div id = " userManagementThumbnailsIn " class = " tileList " > <nl> + < div class = " tileList " > <nl> < div class = " tile " > <nl> < div class = " fullBorderBox " > <nl> < a href = " # " id = " createDatabase " class = " add " > <nl> mmm a / js / apps / system / _admin / aardvark / APP / frontend / js / views / userManagementView . js <nl> ppp b / js / apps / system / _admin / aardvark / APP / frontend / js / views / userManagementView . js <nl> <nl> template : templateEngine . createTemplate ( " userManagementView . ejs " ) , <nl> <nl> events : { <nl> - " click # createUser " : " createUser " , <nl> - " click # submitCreateUser " : " submitCreateUser " , <nl> + " click # createUser " : " createUser " , <nl> + " click # submitCreateUser " : " submitCreateUser " , <nl> / / " click # deleteUser " : " removeUser " , <nl> / / " click # submitDeleteUser " : " submitDeleteUser " , <nl> / / " click . editUser " : " editUser " , <nl> / / " click . icon " : " editUser " , <nl> - " click . tile " : " editUser " , <nl> - " click # submitEditUser " : " submitEditUser " , <nl> - " click # userManagementToggle " : " toggleView " , <nl> - " keyup # userManagementSearchInput " : " search " , <nl> - " click # userManagementSearchSubmit " : " search " , <nl> - " click # callEditUserPassword " : " editUserPassword " , <nl> - " click # submitEditUserPassword " : " submitEditUserPassword " , <nl> - " click # submitEditCurrentUserProfile " : " submitEditCurrentUserProfile " , <nl> - " click . css - label " : " checkBoxes " , <nl> - " change # userSortDesc " : " sorting " <nl> + " click # userManagementThumbnailsIn . tile " : " editUser " , <nl> + " click # submitEditUser " : " submitEditUser " , <nl> + " click # userManagementToggle " : " toggleView " , <nl> + " keyup # userManagementSearchInput " : " search " , <nl> + " click # userManagementSearchSubmit " : " search " , <nl> + " click # callEditUserPassword " : " editUserPassword " , <nl> + " click # submitEditUserPassword " : " submitEditUserPassword " , <nl> + " click # submitEditCurrentUserProfile " : " submitEditCurrentUserProfile " , <nl> + " click . css - label " : " checkBoxes " , <nl> + " change # userSortDesc " : " sorting " <nl> <nl> } , <nl> <nl>
|
web ui database view used wrong id for binding events
|
arangodb/arangodb
|
185907c859250e5f9bc543c1c05b71f4a393344c
|
2015-12-21T12:33:51Z
|
mmm a / _WAF_ / specs / gamesdk . json <nl> ppp b / _WAF_ / specs / gamesdk . json <nl> <nl> " jsmn " , <nl> " png16 " , <nl> " jpeg " , <nl> - " curl " , <nl> <nl> " CryGameSDK " <nl> ] , <nl>
|
! XT ( WAF ) Don ' t build curl yet . ( Approved by davidka )
|
CRYTEK/CRYENGINE
|
7a86ead6de7163e5f6fbe4e191857503b5f87566
|
2016-09-26T07:36:56Z
|
mmm a / hphp / runtime / ext_hhvm / CMakeLists . txt <nl> ppp b / hphp / runtime / ext_hhvm / CMakeLists . txt <nl> <nl> - <nl> - message ( " Including ext_hhvm files " ) <nl> + message ( STATUS " Including ext_hhvm files " ) <nl> <nl> set ( files ) <nl> set ( CXX_SOURCES ) <nl>
|
Show message like the regular status messages
|
facebook/hhvm
|
943b945e1b73e60e97f31d0b92dfebfb1f7bac2b
|
2013-02-25T07:22:55Z
|
mmm a / xbmc / filesystem / PVRFile . cpp <nl> ppp b / xbmc / filesystem / PVRFile . cpp <nl> bool CPVRFile : : Open ( const CURL & url ) <nl> return false ; <nl> <nl> m_isPlayRecording = true ; <nl> - CLog : : Log ( LOGDEBUG , " % s - Recording has started on filename % s " , __FUNCTION__ , strURL . c_str ( ) ) ; <nl> + CLog : : Log ( LOGDEBUG , " % s - playback has started on recording % s ( % s ) " , __FUNCTION__ , strURL . c_str ( ) , tag - > GetPVRRecordingInfoTag ( ) - > m_strIconPath . c_str ( ) ) ; <nl> } <nl> else <nl> { <nl>
|
[ pvr ] change misleading log message
|
xbmc/xbmc
|
a2e49dc1e124108d6b0e629a8dd7e7b3559f1572
|
2014-03-11T20:52:54Z
|
mmm a / src / arm64 / constants - arm64 . h <nl> ppp b / src / arm64 / constants - arm64 . h <nl> const unsigned kRegCodeMask = 0x1f ; <nl> const unsigned kShiftAmountWRegMask = 0x1f ; <nl> const unsigned kShiftAmountXRegMask = 0x3f ; <nl> / / Standard machine types defined by AAPCS64 . <nl> - const unsigned kByteSize = 8 ; <nl> - const unsigned kByteSizeInBytes = kByteSize > > 3 ; <nl> const unsigned kHalfWordSize = 16 ; <nl> const unsigned kHalfWordSizeLog2 = 4 ; <nl> const unsigned kHalfWordSizeInBytes = kHalfWordSize > > 3 ; <nl> mmm a / src / globals . h <nl> ppp b / src / globals . h <nl> constexpr uint32_t kMaxUInt32 = 0xFFFFFFFFu ; <nl> constexpr int kMinUInt32 = 0 ; <nl> <nl> constexpr int kUInt8Size = sizeof ( uint8_t ) ; <nl> + constexpr int kByteSize = sizeof ( byte ) ; <nl> constexpr int kCharSize = sizeof ( char ) ; <nl> constexpr int kShortSize = sizeof ( short ) ; / / NOLINT <nl> constexpr int kUInt16Size = sizeof ( uint16_t ) ; <nl> mmm a / src / heap / factory . cc <nl> ppp b / src / heap / factory . cc <nl> Handle < ModuleInfo > Factory : : NewModuleInfo ( ) { <nl> ModuleInfo : : kLength , TENURED ) ; <nl> } <nl> <nl> - Handle < PreparseData > Factory : : NewPreparseData ( int length ) { <nl> - int size = PreparseData : : SizeFor ( length ) ; <nl> + Handle < PreparseData > Factory : : NewPreparseData ( int data_length , <nl> + int children_length ) { <nl> + int size = PreparseData : : SizeFor ( data_length , children_length ) ; <nl> Handle < PreparseData > result ( PreparseData : : cast ( AllocateRawWithImmortalMap ( <nl> size , TENURED , * preparse_data_map ( ) ) ) , <nl> isolate ( ) ) ; <nl> - result - > set_scope_data ( PodArray < uint8_t > : : cast ( * empty_byte_array ( ) ) ) ; <nl> - result - > set_length ( length ) ; <nl> - MemsetTagged ( result - > child_data_start ( ) , * null_value ( ) , length ) ; <nl> - <nl> + result - > set_data_length ( data_length ) ; <nl> + result - > set_children_length ( children_length ) ; <nl> + MemsetTagged ( result - > inner_data_start ( ) , * null_value ( ) , children_length ) ; <nl> result - > clear_padding ( ) ; <nl> return result ; <nl> } <nl> mmm a / src / heap / factory . h <nl> ppp b / src / heap / factory . h <nl> class V8_EXPORT_PRIVATE Factory { <nl> <nl> Handle < ModuleInfo > NewModuleInfo ( ) ; <nl> <nl> - Handle < PreparseData > NewPreparseData ( int length ) ; <nl> + Handle < PreparseData > NewPreparseData ( int data_length , int children_length ) ; <nl> <nl> Handle < UncompiledDataWithoutPreparseData > <nl> NewUncompiledDataWithoutPreparseData ( Handle < String > inferred_name , <nl> mmm a / src / heap / object - stats . cc <nl> ppp b / src / heap / object - stats . cc <nl> class ObjectStatsCollectorImpl { <nl> void RecordVirtualExternalStringDetails ( ExternalString script ) ; <nl> void RecordVirtualSharedFunctionInfoDetails ( SharedFunctionInfo info ) ; <nl> void RecordVirtualJSFunctionDetails ( JSFunction function ) ; <nl> - void RecordVirtualPreparseDataDetails ( PreparseData data ) ; <nl> <nl> void RecordVirtualArrayBoilerplateDescription ( <nl> ArrayBoilerplateDescription description ) ; <nl> void ObjectStatsCollectorImpl : : RecordVirtualFeedbackVectorDetails ( <nl> CHECK_EQ ( calculated_size , vector - > Size ( ) ) ; <nl> } <nl> <nl> - void ObjectStatsCollectorImpl : : RecordVirtualPreparseDataDetails ( <nl> - PreparseData data ) { <nl> - if ( virtual_objects_ . find ( data ) ! = virtual_objects_ . end ( ) ) return ; <nl> - / / Manually insert the PreparseData since we ' re combining the size with it ' s <nl> - / / byte_data size . <nl> - virtual_objects_ . insert ( data ) ; <nl> - virtual_objects_ . insert ( data - > scope_data ( ) ) ; <nl> - size_t size = data - > Size ( ) + data - > scope_data ( ) - > Size ( ) ; <nl> - DCHECK_LE ( 0 , data - > scope_data ( ) - > length ( ) ) ; <nl> - stats_ - > RecordObjectStats ( PREPARSE_DATA_TYPE , size ) ; <nl> - } <nl> - <nl> void ObjectStatsCollectorImpl : : RecordVirtualFixedArrayDetails ( <nl> FixedArray array ) { <nl> if ( IsCowArray ( array ) ) { <nl> void ObjectStatsCollectorImpl : : CollectStatistics ( <nl> } else if ( obj - > IsArrayBoilerplateDescription ( ) ) { <nl> RecordVirtualArrayBoilerplateDescription ( <nl> ArrayBoilerplateDescription : : cast ( obj ) ) ; <nl> - } else if ( obj - > IsPreparseData ( ) ) { <nl> - RecordVirtualPreparseDataDetails ( PreparseData : : cast ( obj ) ) ; <nl> } else if ( obj - > IsFixedArrayExact ( ) ) { <nl> / / Has to go last as it triggers too eagerly . <nl> RecordVirtualFixedArrayDetails ( FixedArray : : cast ( obj ) ) ; <nl> mmm a / src / objects - body - descriptors - inl . h <nl> ppp b / src / objects - body - descriptors - inl . h <nl> class FeedbackVector : : BodyDescriptor final : public BodyDescriptorBase { <nl> class PreparseData : : BodyDescriptor final : public BodyDescriptorBase { <nl> public : <nl> static bool IsValidSlot ( Map map , HeapObject obj , int offset ) { <nl> - return offset = = kScopeDataOffset | | offset > = kChildDataStartOffset ; <nl> + return offset > = PreparseData : : cast ( obj ) - > inner_start_offset ( ) ; <nl> } <nl> <nl> template < typename ObjectVisitor > <nl> static inline void IterateBody ( Map map , HeapObject obj , int object_size , <nl> ObjectVisitor * v ) { <nl> - IteratePointer ( obj , kScopeDataOffset , v ) ; <nl> - IteratePointers ( obj , kChildDataStartOffset , object_size , v ) ; <nl> + PreparseData data = PreparseData : : cast ( obj ) ; <nl> + int start_offset = data - > inner_start_offset ( ) ; <nl> + int end_offset = start_offset + data - > children_length ( ) * kTaggedSize ; <nl> + IteratePointers ( obj , start_offset , end_offset , v ) ; <nl> } <nl> <nl> static inline int SizeOf ( Map map , HeapObject obj ) { <nl> - return PreparseData : : SizeFor ( PreparseData : : cast ( obj ) - > length ( ) ) ; <nl> + PreparseData data = PreparseData : : cast ( obj ) ; <nl> + return PreparseData : : SizeFor ( data - > data_length ( ) , data - > children_length ( ) ) ; <nl> } <nl> } ; <nl> <nl> mmm a / src / objects - debug . cc <nl> ppp b / src / objects - debug . cc <nl> void StackFrameInfo : : StackFrameInfoVerify ( Isolate * isolate ) { <nl> <nl> void PreparseData : : PreparseDataVerify ( Isolate * isolate ) { <nl> CHECK ( IsPreparseData ( ) ) ; <nl> - CHECK ( scope_data ( ) - > IsByteArray ( ) ) ; <nl> - CHECK_GE ( length ( ) , 0 ) ; <nl> + CHECK_LE ( 0 , data_length ( ) ) ; <nl> + CHECK_LE ( 0 , children_length ( ) ) ; <nl> <nl> - for ( int i = 0 ; i < length ( ) ; + + i ) { <nl> - Object child = child_data ( i ) ; <nl> - CHECK ( child - > IsPreparseData ( ) | | child - > IsNull ( ) ) ; <nl> - VerifyPointer ( isolate , child ) ; <nl> + for ( int i = 0 ; i < children_length ( ) ; + + i ) { <nl> + VerifyPointer ( isolate , get_child ( i ) ) ; <nl> } <nl> } <nl> <nl> mmm a / src / objects - inl . h <nl> ppp b / src / objects - inl . h <nl> int HeapObject : : SizeFromMap ( Map map ) const { <nl> return BigInt : : SizeFor ( BigInt : : unchecked_cast ( * this ) - > length ( ) ) ; <nl> } <nl> if ( instance_type = = PREPARSE_DATA_TYPE ) { <nl> - return PreparseData : : SizeFor ( PreparseData : : unchecked_cast ( * this ) - > length ( ) ) ; <nl> + PreparseData data = PreparseData : : unchecked_cast ( * this ) ; <nl> + return PreparseData : : SizeFor ( data - > data_length ( ) , data - > children_length ( ) ) ; <nl> } <nl> if ( instance_type = = CODE_TYPE ) { <nl> return Code : : unchecked_cast ( * this ) - > CodeSize ( ) ; <nl> mmm a / src / objects - printer . cc <nl> ppp b / src / objects - printer . cc <nl> void LayoutDescriptor : : Print ( std : : ostream & os ) { / / NOLINT <nl> <nl> void PreparseData : : PreparseDataPrint ( std : : ostream & os ) { / / NOLINT <nl> PrintHeader ( os , " PreparseData " ) ; <nl> - os < < " \ n - scope_data : " < < Brief ( scope_data ( ) ) ; <nl> - os < < " \ n - length : " < < length ( ) ; <nl> - for ( int i = 0 ; i < length ( ) ; + + i ) { <nl> - os < < " \ n - [ " < < i < < " ] : " < < Brief ( child_data ( i ) ) ; <nl> + os < < " \ n - data_length : " < < data_length ( ) ; <nl> + os < < " \ n - children_length : " < < children_length ( ) ; <nl> + for ( int i = 0 ; i < children_length ( ) ; + + i ) { <nl> + os < < " \ n - [ " < < i < < " ] : " < < Brief ( get_child ( i ) ) ; <nl> } <nl> os < < " \ n " ; <nl> } <nl> mmm a / src / objects . cc <nl> ppp b / src / objects . cc <nl> void HeapObject : : HeapObjectShortPrint ( std : : ostream & os ) { / / NOLINT <nl> <nl> case PREPARSE_DATA_TYPE : { <nl> PreparseData data = PreparseData : : cast ( * this ) ; <nl> - os < < " < PreparseData [ " < < data - > length ( ) < < " ] > " ; <nl> + os < < " < PreparseData [ data = " < < data - > data_length ( ) <nl> + < < " children = " < < data - > children_length ( ) < < " ] > " ; <nl> break ; <nl> } <nl> <nl> mmm a / src / objects / shared - function - info - inl . h <nl> ppp b / src / objects / shared - function - info - inl . h <nl> namespace internal { <nl> OBJECT_CONSTRUCTORS_IMPL ( PreparseData , HeapObject ) <nl> <nl> CAST_ACCESSOR ( PreparseData ) <nl> - ACCESSORS ( PreparseData , scope_data , PodArray < uint8_t > , kScopeDataOffset ) <nl> - INT_ACCESSORS ( PreparseData , length , kLengthOffset ) <nl> + INT_ACCESSORS ( PreparseData , data_length , kDataLengthOffset ) <nl> + INT_ACCESSORS ( PreparseData , children_length , kInnerLengthOffset ) <nl> <nl> - Object PreparseData : : child_data ( int index ) const { <nl> - DCHECK_GE ( index , 0 ) ; <nl> - DCHECK_LT ( index , this - > length ( ) ) ; <nl> - int offset = kChildDataStartOffset + index * kTaggedSize ; <nl> - return RELAXED_READ_FIELD ( * this , offset ) ; <nl> + int PreparseData : : inner_start_offset ( ) const { <nl> + return InnerOffset ( data_length ( ) ) ; <nl> } <nl> <nl> - void PreparseData : : set_child_data ( int index , Object value , <nl> - WriteBarrierMode mode ) { <nl> - DCHECK_GE ( index , 0 ) ; <nl> - DCHECK_LT ( index , this - > length ( ) ) ; <nl> - int offset = kChildDataStartOffset + index * kTaggedSize ; <nl> - RELAXED_WRITE_FIELD ( * this , offset , value ) ; <nl> - CONDITIONAL_WRITE_BARRIER ( * this , offset , value , mode ) ; <nl> + ObjectSlot PreparseData : : inner_data_start ( ) const { <nl> + return RawField ( inner_start_offset ( ) ) ; <nl> } <nl> <nl> - ObjectSlot PreparseData : : child_data_start ( ) const { <nl> - return RawField ( kChildDataStartOffset ) ; <nl> + void PreparseData : : clear_padding ( ) { <nl> + int data_end_offset = kDataStartOffset + data_length ( ) ; <nl> + int padding_size = inner_start_offset ( ) - data_end_offset ; <nl> + DCHECK_LE ( 0 , padding_size ) ; <nl> + if ( padding_size = = 0 ) return ; <nl> + memset ( reinterpret_cast < void * > ( address ( ) + data_end_offset ) , 0 , padding_size ) ; <nl> } <nl> <nl> - void PreparseData : : clear_padding ( ) { <nl> - if ( FIELD_SIZE ( kOptionalPaddingOffset ) ! = 0 ) { <nl> - DCHECK_EQ ( 4 , FIELD_SIZE ( kOptionalPaddingOffset ) ) ; <nl> - memset ( reinterpret_cast < void * > ( address ( ) + kOptionalPaddingOffset ) , 0 , <nl> - FIELD_SIZE ( kOptionalPaddingOffset ) ) ; <nl> - } <nl> + byte PreparseData : : get ( int index ) const { <nl> + DCHECK_LE ( 0 , index ) ; <nl> + DCHECK_LT ( index , data_length ( ) ) ; <nl> + int offset = kDataStartOffset + index * kByteSize ; <nl> + return READ_BYTE_FIELD ( * this , offset ) ; <nl> + } <nl> + <nl> + void PreparseData : : set ( int index , byte value ) { <nl> + DCHECK_LE ( 0 , index ) ; <nl> + DCHECK_LT ( index , data_length ( ) ) ; <nl> + int offset = kDataStartOffset + index * kByteSize ; <nl> + WRITE_BYTE_FIELD ( * this , offset , value ) ; <nl> + } <nl> + <nl> + void PreparseData : : copy_in ( int index , const byte * buffer , int length ) { <nl> + DCHECK ( index > = 0 & & length > = 0 & & length < = kMaxInt - index & & <nl> + index + length < = this - > data_length ( ) ) ; <nl> + Address dst_addr = FIELD_ADDR ( this , kDataStartOffset + index * kByteSize ) ; <nl> + memcpy ( reinterpret_cast < void * > ( dst_addr ) , buffer , length ) ; <nl> + } <nl> + <nl> + PreparseData PreparseData : : get_child ( int index ) const { <nl> + DCHECK_LE ( 0 , index ) ; <nl> + DCHECK_LT ( index , this - > children_length ( ) ) ; <nl> + int offset = inner_start_offset ( ) + index * kTaggedSize ; <nl> + Object result = RELAXED_READ_FIELD ( * this , offset ) ; <nl> + return PreparseData : : cast ( result ) ; <nl> + } <nl> + <nl> + void PreparseData : : set_child ( int index , PreparseData value , <nl> + WriteBarrierMode mode ) { <nl> + DCHECK_LE ( 0 , index ) ; <nl> + DCHECK_LT ( index , this - > children_length ( ) ) ; <nl> + int offset = inner_start_offset ( ) + index * kTaggedSize ; <nl> + RELAXED_WRITE_FIELD ( * this , offset , value ) ; <nl> + CONDITIONAL_WRITE_BARRIER ( * this , offset , value , mode ) ; <nl> } <nl> <nl> OBJECT_CONSTRUCTORS_IMPL ( UncompiledData , HeapObject ) <nl> INT32_ACCESSORS ( UncompiledData , end_position , kEndPositionOffset ) <nl> INT32_ACCESSORS ( UncompiledData , function_literal_id , kFunctionLiteralIdOffset ) <nl> <nl> void UncompiledData : : clear_padding ( ) { <nl> - if ( FIELD_SIZE ( kOptionalPaddingOffset ) ! = 0 ) { <nl> - DCHECK_EQ ( 4 , FIELD_SIZE ( kOptionalPaddingOffset ) ) ; <nl> - memset ( reinterpret_cast < void * > ( address ( ) + kOptionalPaddingOffset ) , 0 , <nl> - FIELD_SIZE ( kOptionalPaddingOffset ) ) ; <nl> - } <nl> + if ( FIELD_SIZE ( kOptionalPaddingOffset ) = = 0 ) return ; <nl> + DCHECK_EQ ( 4 , FIELD_SIZE ( kOptionalPaddingOffset ) ) ; <nl> + memset ( reinterpret_cast < void * > ( address ( ) + kOptionalPaddingOffset ) , 0 , <nl> + FIELD_SIZE ( kOptionalPaddingOffset ) ) ; <nl> } <nl> <nl> CAST_ACCESSOR ( UncompiledDataWithoutPreparseData ) <nl> mmm a / src / objects / shared - function - info . h <nl> ppp b / src / objects / shared - function - info . h <nl> class WasmExportedFunctionData ; <nl> <nl> / / Data collected by the pre - parser storing information about scopes and inner <nl> / / functions . <nl> + / / <nl> + / / PreparseData Layout : <nl> + / / + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + / / | data_length | children_length | <nl> + / / + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + / / | Scope Byte Data . . . | <nl> + / / | . . . | <nl> + / / + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + / / | [ Padding ] | <nl> + / / + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + / / | Inner PreparseData 1 | <nl> + / / + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + / / | . . . | <nl> + / / + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + / / | Inner PreparseData N | <nl> + / / + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> class PreparseData : public HeapObject { <nl> public : <nl> - DECL_ACCESSORS ( scope_data , PodArray < uint8_t > ) <nl> - DECL_INT_ACCESSORS ( length ) <nl> + DECL_INT_ACCESSORS ( data_length ) <nl> + DECL_INT_ACCESSORS ( children_length ) <nl> <nl> - inline Object child_data ( int index ) const ; <nl> - inline void set_child_data ( int index , Object value , <nl> - WriteBarrierMode mode = UPDATE_WRITE_BARRIER ) ; <nl> + inline int inner_start_offset ( ) const ; <nl> + inline ObjectSlot inner_data_start ( ) const ; <nl> <nl> - inline ObjectSlot child_data_start ( ) const ; <nl> + inline byte get ( int index ) const ; <nl> + inline void set ( int index , byte value ) ; <nl> + inline void copy_in ( int index , const byte * buffer , int length ) ; <nl> + <nl> + inline PreparseData get_child ( int index ) const ; <nl> + inline void set_child ( int index , PreparseData value , <nl> + WriteBarrierMode mode = UPDATE_WRITE_BARRIER ) ; <nl> <nl> / / Clear uninitialized padding space . <nl> inline void clear_padding ( ) ; <nl> class PreparseData : public HeapObject { <nl> DECL_VERIFIER ( PreparseData ) <nl> <nl> / / Layout description . <nl> - # define PREPARSE_DATA_FIELDS ( V ) \ <nl> - V ( kScopeDataOffset , kTaggedSize ) \ <nl> - V ( kLengthOffset , kIntSize ) \ <nl> - V ( kOptionalPaddingOffset , POINTER_SIZE_PADDING ( kOptionalPaddingOffset ) ) \ <nl> - / * Header size . * / \ <nl> - V ( kChildDataStartOffset , 0 ) <nl> + # define PREPARSE_DATA_FIELDS ( V ) \ <nl> + V ( kDataLengthOffset , kInt32Size ) \ <nl> + V ( kInnerLengthOffset , kInt32Size ) \ <nl> + / * Header size . * / \ <nl> + V ( kDataStartOffset , 0 ) \ <nl> + V ( kHeaderSize , 0 ) <nl> <nl> DEFINE_FIELD_OFFSET_CONSTANTS ( HeapObject : : kHeaderSize , PREPARSE_DATA_FIELDS ) <nl> # undef PREPARSE_DATA_FIELDS <nl> <nl> class BodyDescriptor ; <nl> <nl> - static constexpr int SizeFor ( int length ) { <nl> - return kChildDataStartOffset + length * kTaggedSize ; <nl> + static int InnerOffset ( int data_length ) { <nl> + return RoundUp ( kDataStartOffset + data_length * kByteSize , kTaggedSize ) ; <nl> + } <nl> + <nl> + static int SizeFor ( int data_length , int children_length ) { <nl> + return InnerOffset ( data_length ) + children_length * kTaggedSize ; <nl> } <nl> <nl> OBJECT_CONSTRUCTORS ( PreparseData , HeapObject ) ; <nl> class UncompiledData : public HeapObject { <nl> [ ] ( HeapObject object , ObjectSlot slot , HeapObject target ) { } ) ; <nl> <nl> / / Layout description . <nl> - <nl> # define UNCOMPILED_DATA_FIELDS ( V ) \ <nl> V ( kStartOfPointerFieldsOffset , 0 ) \ <nl> V ( kInferredNameOffset , kTaggedSize ) \ <nl> mmm a / src / parsing / preparse - data - impl . h <nl> ppp b / src / parsing / preparse - data - impl . h <nl> class PreparseDataBuilder : : ByteData : public ZoneObject , <nl> void OverwriteFirstUint32 ( uint32_t data ) ; <nl> # endif <nl> <nl> - Handle < PodArray < uint8_t > > Serialize ( Isolate * isolate ) ; <nl> + void StoreInto ( PreparseData data ) ; <nl> <nl> size_t size ( ) const { return backing_store_ . size ( ) ; } <nl> <nl> class PreparseDataBuilder : : ByteData : public ZoneObject , <nl> ZoneChunkList < uint8_t > backing_store_ ; <nl> } ; <nl> <nl> + / / Wraps a ZoneVector < uint8_t > to have with functions named the same as <nl> + / / PodArray < uint8_t > . <nl> + class ZoneVectorWrapper { <nl> + public : <nl> + ZoneVectorWrapper ( ) = default ; <nl> + explicit ZoneVectorWrapper ( ZoneVector < uint8_t > * data ) : data_ ( data ) { } <nl> + <nl> + int data_length ( ) const { return static_cast < int > ( data_ - > size ( ) ) ; } <nl> + <nl> + uint8_t get ( int index ) const { return data_ - > at ( index ) ; } <nl> + <nl> + private : <nl> + ZoneVector < uint8_t > * data_ = nullptr ; <nl> + } ; <nl> + <nl> template < class Data > <nl> class BaseConsumedPreparseData : public ConsumedPreparseData { <nl> public : <nl> class BaseConsumedPreparseData : public ConsumedPreparseData { <nl> } ; <nl> <nl> void SetPosition ( int position ) { <nl> - DCHECK_LE ( position , data_ . length ( ) ) ; <nl> + DCHECK_LE ( position , data_ . data_length ( ) ) ; <nl> index_ = position ; <nl> } <nl> <nl> size_t RemainingBytes ( ) const { <nl> DCHECK ( has_data_ ) ; <nl> - DCHECK_LE ( index_ , data_ . length ( ) ) ; <nl> - return data_ . length ( ) - index_ ; <nl> + DCHECK_LE ( index_ , data_ . data_length ( ) ) ; <nl> + return data_ . data_length ( ) - index_ ; <nl> } <nl> <nl> bool HasRemainingBytes ( size_t bytes ) const { <nl> DCHECK ( has_data_ ) ; <nl> - return index_ < = data_ . length ( ) & & bytes < = RemainingBytes ( ) ; <nl> + return index_ < = data_ . data_length ( ) & & bytes < = RemainingBytes ( ) ; <nl> } <nl> <nl> int32_t ReadUint32 ( ) { <nl> class BaseConsumedPreparseData : public ConsumedPreparseData { <nl> <nl> / / Implementation of ConsumedPreparseData for on - heap data . <nl> class OnHeapConsumedPreparseData final <nl> - : public BaseConsumedPreparseData < PodArray < uint8_t > > { <nl> + : public BaseConsumedPreparseData < PreparseData > { <nl> public : <nl> OnHeapConsumedPreparseData ( Isolate * isolate , Handle < PreparseData > data ) ; <nl> <nl> - PodArray < uint8_t > GetScopeData ( ) final ; <nl> - ProducedPreparseData * GetChildData ( Zone * zone , int child_index ) final ; <nl> + PreparseData GetScopeData ( ) final ; <nl> + ProducedPreparseData * GetChildData ( Zone * zone , int index ) final ; <nl> <nl> private : <nl> Isolate * isolate_ ; <nl> Handle < PreparseData > data_ ; <nl> } ; <nl> <nl> - / / Wraps a ZoneVector < uint8_t > to have with functions named the same as <nl> - / / PodArray < uint8_t > . <nl> - class ZoneVectorWrapper { <nl> - public : <nl> - ZoneVectorWrapper ( ) = default ; <nl> - explicit ZoneVectorWrapper ( ZoneVector < uint8_t > * data ) : data_ ( data ) { } <nl> - <nl> - int length ( ) const { return static_cast < int > ( data_ - > size ( ) ) ; } <nl> - <nl> - uint8_t get ( int index ) const { return data_ - > at ( index ) ; } <nl> - <nl> - private : <nl> - ZoneVector < uint8_t > * data_ = nullptr ; <nl> - } ; <nl> - <nl> / / A serialized PreparseData in zone memory ( as apposed to being on - heap ) . <nl> class ZonePreparseData : public ZoneObject { <nl> public : <nl> mmm a / src / parsing / preparse - data . cc <nl> ppp b / src / parsing / preparse - data . cc <nl> void PreparseDataBuilder : : ByteData : : WriteQuarter ( uint8_t data ) { <nl> backing_store_ . back ( ) | = ( data < < shift_amount ) ; <nl> } <nl> <nl> - Handle < PodArray < uint8_t > > PreparseDataBuilder : : ByteData : : Serialize ( <nl> - Isolate * isolate ) { <nl> - Handle < PodArray < uint8_t > > array = PodArray < uint8_t > : : New ( <nl> - isolate , static_cast < int > ( backing_store_ . size ( ) ) , TENURED ) ; <nl> - <nl> + void PreparseDataBuilder : : ByteData : : StoreInto ( PreparseData data ) { <nl> DisallowHeapAllocation no_gc ; <nl> - PodArray < uint8_t > raw_array = * array ; <nl> - <nl> int i = 0 ; <nl> for ( uint8_t item : backing_store_ ) { <nl> - raw_array - > set ( i + + , item ) ; <nl> + data - > set ( i + + , item ) ; <nl> } <nl> - return array ; <nl> } <nl> <nl> PreparseDataBuilder : : PreparseDataBuilder ( Zone * zone , <nl> Handle < PreparseData > PreparseDataBuilder : : Serialize ( Isolate * isolate ) { <nl> DCHECK ( ! ThisOrParentBailedOut ( ) ) ; <nl> <nl> int child_data_length = static_cast < int > ( data_for_inner_functions_ . size ( ) ) ; <nl> - Handle < PreparseData > data = <nl> - isolate - > factory ( ) - > NewPreparseData ( child_data_length ) ; <nl> - <nl> - Handle < PodArray < uint8_t > > scope_data_array = byte_data_ - > Serialize ( isolate ) ; <nl> - data - > set_scope_data ( * scope_data_array ) ; <nl> + Handle < PreparseData > data = isolate - > factory ( ) - > NewPreparseData ( <nl> + static_cast < int > ( byte_data_ - > size ( ) ) , child_data_length ) ; <nl> + byte_data_ - > StoreInto ( * data ) ; <nl> <nl> int i = 0 ; <nl> for ( const auto & item : data_for_inner_functions_ ) { <nl> DCHECK_NOT_NULL ( item ) ; <nl> Handle < PreparseData > child_data = item - > Serialize ( isolate ) ; <nl> - data - > set_child_data ( i + + , * child_data ) ; <nl> + data - > set_child ( i + + , * child_data ) ; <nl> } <nl> <nl> return data ; <nl> void BaseConsumedPreparseData < Data > : : VerifyDataStart ( ) { <nl> } <nl> # endif <nl> <nl> - PodArray < uint8_t > OnHeapConsumedPreparseData : : GetScopeData ( ) { <nl> - return data_ - > scope_data ( ) ; <nl> - } <nl> + PreparseData OnHeapConsumedPreparseData : : GetScopeData ( ) { return * data_ ; } <nl> <nl> - ProducedPreparseData * OnHeapConsumedPreparseData : : GetChildData ( <nl> - Zone * zone , int child_index ) { <nl> - CHECK_GT ( data_ - > length ( ) , child_index ) ; <nl> - Object child_data = data_ - > child_data ( child_index ) ; <nl> - if ( ! child_data - > IsPreparseData ( ) ) return nullptr ; <nl> - Handle < PreparseData > child_data_handle ( PreparseData : : cast ( child_data ) , <nl> - isolate_ ) ; <nl> + ProducedPreparseData * OnHeapConsumedPreparseData : : GetChildData ( Zone * zone , <nl> + int index ) { <nl> + DisallowHeapAllocation no_gc ; <nl> + Handle < PreparseData > child_data_handle ( data_ - > get_child ( index ) , isolate_ ) ; <nl> return ProducedPreparseData : : For ( child_data_handle , zone ) ; <nl> } <nl> <nl> OnHeapConsumedPreparseData : : OnHeapConsumedPreparseData ( <nl> Isolate * isolate , Handle < PreparseData > data ) <nl> - : BaseConsumedPreparseData < PodArray < uint8_t > > ( ) , <nl> - isolate_ ( isolate ) , <nl> - data_ ( data ) { <nl> + : BaseConsumedPreparseData < PreparseData > ( ) , isolate_ ( isolate ) , data_ ( data ) { <nl> DCHECK_NOT_NULL ( isolate ) ; <nl> DCHECK ( data - > IsPreparseData ( ) ) ; <nl> # ifdef DEBUG <nl> ZonePreparseData : : ZonePreparseData ( Zone * zone , <nl> children_ ( child_length , zone ) { } <nl> <nl> Handle < PreparseData > ZonePreparseData : : Serialize ( Isolate * isolate ) { <nl> + int data_size = static_cast < int > ( byte_data ( ) - > size ( ) ) ; <nl> int child_data_length = child_length ( ) ; <nl> Handle < PreparseData > result = <nl> - isolate - > factory ( ) - > NewPreparseData ( child_data_length ) ; <nl> - <nl> - Handle < PodArray < uint8_t > > scope_data_array = PodArray < uint8_t > : : New ( <nl> - isolate , static_cast < int > ( byte_data ( ) - > size ( ) ) , TENURED ) ; <nl> - scope_data_array - > copy_in ( 0 , byte_data ( ) - > data ( ) , <nl> - static_cast < int > ( byte_data ( ) - > size ( ) ) ) ; <nl> - result - > set_scope_data ( * scope_data_array ) ; <nl> + isolate - > factory ( ) - > NewPreparseData ( data_size , child_data_length ) ; <nl> + result - > copy_in ( 0 , byte_data ( ) - > data ( ) , data_size ) ; <nl> <nl> for ( int i = 0 ; i < child_data_length ; i + + ) { <nl> ZonePreparseData * child = get_child ( i ) ; <nl> - if ( child ) { <nl> - Handle < PreparseData > child_data = child - > Serialize ( isolate ) ; <nl> - result - > set_child_data ( i , * child_data ) ; <nl> - } <nl> + DCHECK_NOT_NULL ( child ) ; <nl> + Handle < PreparseData > child_data = child - > Serialize ( isolate ) ; <nl> + result - > set_child ( i , * child_data ) ; <nl> } <nl> return result ; <nl> } <nl> mmm a / test / cctest / parsing / test - preparser . cc <nl> ppp b / test / cctest / parsing / test - preparser . cc <nl> TEST ( ProducingAndConsumingByteData ) { <nl> <nl> { <nl> / / Serialize as an OnHeapConsumedPreparseData , and read back data . <nl> - i : : Handle < i : : PodArray < uint8_t > > data_on_heap = bytes . Serialize ( isolate ) ; <nl> + i : : Handle < i : : PreparseData > data_on_heap = <nl> + isolate - > factory ( ) - > NewPreparseData ( static_cast < int > ( bytes . size ( ) ) , 0 ) ; <nl> + bytes . StoreInto ( * data_on_heap ) ; <nl> i : : OnHeapConsumedPreparseData : : ByteData bytes_for_reading ; <nl> i : : OnHeapConsumedPreparseData : : ByteData : : ReadingScope reading_scope ( <nl> & bytes_for_reading , * data_on_heap ) ; <nl>
|
[ parser ] Inline byte scope data into PreparseData object
|
v8/v8
|
e2d44ede95da3a380089c6eb8960b1d59faf750a
|
2019-01-11T15:20:37Z
|
mmm a / src / core / file_sys / archive_extsavedata . cpp <nl> ppp b / src / core / file_sys / archive_extsavedata . cpp <nl> Path ConstructExtDataBinaryPath ( u32 media_type , u32 high , u32 low ) { <nl> ArchiveFactory_ExtSaveData : : ArchiveFactory_ExtSaveData ( const std : : string & mount_location , <nl> bool shared ) <nl> : shared ( shared ) , mount_point ( GetExtDataContainerPath ( mount_location , shared ) ) { <nl> - LOG_INFO ( Service_FS , " Directory % s set as base for ExtSaveData . " , mount_point . c_str ( ) ) ; <nl> + LOG_DEBUG ( Service_FS , " Directory % s set as base for ExtSaveData . " , mount_point . c_str ( ) ) ; <nl> } <nl> <nl> bool ArchiveFactory_ExtSaveData : : Initialize ( ) { <nl> mmm a / src / core / file_sys / archive_sdmc . cpp <nl> ppp b / src / core / file_sys / archive_sdmc . cpp <nl> u64 SDMCArchive : : GetFreeBytes ( ) const { <nl> <nl> ArchiveFactory_SDMC : : ArchiveFactory_SDMC ( const std : : string & sdmc_directory ) <nl> : sdmc_directory ( sdmc_directory ) { <nl> - LOG_INFO ( Service_FS , " Directory % s set as SDMC . " , sdmc_directory . c_str ( ) ) ; <nl> + LOG_DEBUG ( Service_FS , " Directory % s set as SDMC . " , sdmc_directory . c_str ( ) ) ; <nl> } <nl> <nl> bool ArchiveFactory_SDMC : : Initialize ( ) { <nl> mmm a / src / core / file_sys / archive_sdmcwriteonly . cpp <nl> ppp b / src / core / file_sys / archive_sdmcwriteonly . cpp <nl> ResultVal < std : : unique_ptr < DirectoryBackend > > SDMCWriteOnlyArchive : : OpenDirectory <nl> <nl> ArchiveFactory_SDMCWriteOnly : : ArchiveFactory_SDMCWriteOnly ( const std : : string & mount_point ) <nl> : sdmc_directory ( mount_point ) { <nl> - LOG_INFO ( Service_FS , " Directory % s set as SDMCWriteOnly . " , sdmc_directory . c_str ( ) ) ; <nl> + LOG_DEBUG ( Service_FS , " Directory % s set as SDMCWriteOnly . " , sdmc_directory . c_str ( ) ) ; <nl> } <nl> <nl> bool ArchiveFactory_SDMCWriteOnly : : Initialize ( ) { <nl> mmm a / src / core / file_sys / archive_source_sd_savedata . cpp <nl> ppp b / src / core / file_sys / archive_source_sd_savedata . cpp <nl> std : : string GetSaveDataMetadataPath ( const std : : string & mount_location , u64 progr <nl> <nl> ArchiveSource_SDSaveData : : ArchiveSource_SDSaveData ( const std : : string & sdmc_directory ) <nl> : mount_point ( GetSaveDataContainerPath ( sdmc_directory ) ) { <nl> - LOG_INFO ( Service_FS , " Directory % s set as SaveData . " , mount_point . c_str ( ) ) ; <nl> + LOG_DEBUG ( Service_FS , " Directory % s set as SaveData . " , mount_point . c_str ( ) ) ; <nl> } <nl> <nl> ResultVal < std : : unique_ptr < ArchiveBackend > > ArchiveSource_SDSaveData : : Open ( u64 program_id ) { <nl>
|
file_sys : lower log level for setting host path
|
yuzu-emu/yuzu
|
047a1586fe8440e8c6f11e3dd11938ca97743f83
|
2017-03-08T15:47:24Z
|
mmm a / include / swift / AST / ArchetypeBuilder . h <nl> ppp b / include / swift / AST / ArchetypeBuilder . h <nl> class ArchetypeBuilder { <nl> ProtocolDecl * Proto , <nl> RequirementSource Source , <nl> llvm : : SmallPtrSetImpl < ProtocolDecl * > & Visited ) ; <nl> - <nl> + <nl> + public : <nl> / / / \ brief Add a new conformance requirement specifying that the given <nl> / / / potential archetypes are equivalent . <nl> bool addSameTypeRequirementBetweenArchetypes ( PotentialArchetype * T1 , <nl> class ArchetypeBuilder { <nl> bool addSameTypeRequirementToConcrete ( PotentialArchetype * T , <nl> Type Concrete , <nl> RequirementSource Source ) ; <nl> - <nl> + <nl> + private : <nl> / / / \ brief Add a new superclass requirement specifying that the given <nl> / / / potential archetype has the given type as an ancestor . <nl> bool addSuperclassRequirement ( PotentialArchetype * T , <nl> mmm a / lib / AST / ArchetypeBuilder . cpp <nl> ppp b / lib / AST / ArchetypeBuilder . cpp <nl> void ArchetypeBuilder : : PotentialArchetype : : resolveAssociatedType ( <nl> - - builder . Impl - > NumUnresolvedNestedTypes ; <nl> } <nl> <nl> + / / / Retrieve the conformance for the superclass constraint of the given <nl> + / / / potential archetype ( if present ) to the given protocol . <nl> + / / / <nl> + / / / \ param pa The potential archetype whose superclass constraint is being <nl> + / / / queried . <nl> + / / / <nl> + / / / \ param proto The protocol to which we are establisting conformance . <nl> + / / / <nl> + / / / \ param cache A cache of the result , so we don ' t perform this query <nl> + / / / multiple times . <nl> + / / / <nl> + / / / \ param builder The archetype builder in which the potential archetype <nl> + / / / resides . <nl> + static ProtocolConformance * getSuperConformance ( <nl> + ArchetypeBuilder : : PotentialArchetype * pa , <nl> + ProtocolDecl * proto , <nl> + Optional < ProtocolConformance * > & cache , <nl> + ArchetypeBuilder & builder ) { <nl> + / / If we cached a result already , return it . <nl> + if ( cache ) return * cache ; <nl> + <nl> + / / Get the superclass constraint . <nl> + Type superclass = pa - > getSuperclass ( ) ; <nl> + if ( ! superclass ) { <nl> + cache = nullptr ; <nl> + return nullptr ; <nl> + } <nl> + <nl> + / / Lookup the conformance of the superclass to this protocol . <nl> + auto conformance = <nl> + builder . getModule ( ) . lookupConformance ( superclass , proto , <nl> + builder . getLazyResolver ( ) ) ; <nl> + switch ( conformance . getInt ( ) ) { <nl> + case ConformanceKind : : Conforms : <nl> + cache = conformance . getPointer ( ) ; <nl> + return conformance . getPointer ( ) ; <nl> + <nl> + case ConformanceKind : : DoesNotConform : <nl> + case ConformanceKind : : UncheckedConforms : <nl> + cache = nullptr ; <nl> + return nullptr ; <nl> + } <nl> + } <nl> + <nl> + / / / If there is a same - type requirement to be added for the given nested type <nl> + / / / due to a superclass constraint on the parent type , add it now . <nl> + static void maybeAddSameTypeRequirementForNestedType ( <nl> + ArchetypeBuilder : : PotentialArchetype * parentPA , <nl> + ArchetypeBuilder : : PotentialArchetype * nestedPA , <nl> + RequirementSource fromSource , <nl> + Optional < ProtocolConformance * > & cache , <nl> + ArchetypeBuilder & builder ) { <nl> + auto assocType = nestedPA - > getResolvedAssociatedType ( ) ; <nl> + assert ( assocType & & " Not resolved to an associated type ? " ) ; <nl> + <nl> + / / Find the superclass conformance . <nl> + auto proto = assocType - > getProtocol ( ) ; <nl> + auto conformance = getSuperConformance ( parentPA , proto , cache , builder ) ; <nl> + if ( ! conformance ) return ; <nl> + <nl> + / / Dig out the type witness . <nl> + auto concreteType = conformance - > getTypeWitness ( assocType , <nl> + builder . getLazyResolver ( ) ) <nl> + . getReplacement ( ) ; <nl> + if ( ! concreteType ) return ; <nl> + <nl> + / / Add the same - type constraint . <nl> + RequirementSource source ( RequirementSource : : Protocol , fromSource . getLoc ( ) ) ; <nl> + concreteType = ArchetypeBuilder : : mapTypeOutOfContext ( <nl> + conformance - > getDeclContext ( ) , concreteType ) ; <nl> + if ( auto otherPA = builder . resolveArchetype ( concreteType ) ) <nl> + builder . addSameTypeRequirementBetweenArchetypes ( nestedPA , otherPA , source ) ; <nl> + else <nl> + builder . addSameTypeRequirementToConcrete ( nestedPA , concreteType , source ) ; <nl> + } <nl> + <nl> bool ArchetypeBuilder : : PotentialArchetype : : addConformance ( <nl> ProtocolDecl * proto , <nl> const RequirementSource & source , <nl> bool ArchetypeBuilder : : PotentialArchetype : : addConformance ( <nl> <nl> / / Check whether any associated types in this protocol resolve <nl> / / nested types of this potential archetype . <nl> + Optional < ProtocolConformance * > cachedSuperConformance ; <nl> for ( auto member : proto - > getMembers ( ) ) { <nl> auto assocType = dyn_cast < AssociatedTypeDecl > ( member ) ; <nl> if ( ! assocType ) <nl> bool ArchetypeBuilder : : PotentialArchetype : : addConformance ( <nl> / / If the nested type was not already resolved , do so now . <nl> if ( ! known - > second . front ( ) - > getResolvedAssociatedType ( ) ) { <nl> known - > second . front ( ) - > resolveAssociatedType ( assocType , builder ) ; <nl> + <nl> + / / If there ' s a superclass constraint that conforms to the protocol , <nl> + / / add the appropriate same - type relationship . <nl> + maybeAddSameTypeRequirementForNestedType ( this , known - > second . front ( ) , <nl> + source , <nl> + cachedSuperConformance , <nl> + builder ) ; <nl> continue ; <nl> } <nl> <nl> bool ArchetypeBuilder : : PotentialArchetype : : addConformance ( <nl> otherPA - > SameTypeSource = RequirementSource ( RequirementSource : : Inferred , <nl> source . getLoc ( ) ) ; <nl> known - > second . push_back ( otherPA ) ; <nl> + <nl> + / / If there ' s a superclass constraint that conforms to the protocol , <nl> + / / add the appropriate same - type relationship . <nl> + maybeAddSameTypeRequirementForNestedType ( this , otherPA , <nl> + source , <nl> + cachedSuperConformance , <nl> + builder ) ; <nl> } <nl> <nl> return true ; <nl> auto ArchetypeBuilder : : PotentialArchetype : : getNestedType ( <nl> if ( Representative ! = this ) <nl> return getRepresentative ( ) - > getNestedType ( nestedName , builder ) ; <nl> <nl> + / / If we already have a nested type with this name , return it . <nl> llvm : : TinyPtrVector < PotentialArchetype * > & nested = NestedTypes [ nestedName ] ; <nl> - <nl> if ( ! nested . empty ( ) ) { <nl> return nested . front ( ) ; <nl> } <nl> auto ArchetypeBuilder : : PotentialArchetype : : getNestedType ( <nl> / / of one of the protocols to which the parent potential <nl> / / archetype conforms . <nl> for ( const auto & conforms : ConformsTo ) { <nl> + Optional < ProtocolConformance * > cachedSuperConformance ; <nl> + <nl> for ( auto member : conforms . first - > lookupDirect ( nestedName ) ) { <nl> auto assocType = dyn_cast < AssociatedTypeDecl > ( member ) ; <nl> if ( ! assocType ) <nl> auto ArchetypeBuilder : : PotentialArchetype : : getNestedType ( <nl> <nl> / / If we have resolved this nested type to more than one associated <nl> / / type , create same - type constraints between them . <nl> + RequirementSource source ( RequirementSource : : Inferred , SourceLoc ( ) ) ; <nl> if ( ! nested . empty ( ) ) { <nl> pa - > Representative = nested . front ( ) - > getRepresentative ( ) ; <nl> pa - > Representative - > EquivalenceClass . push_back ( pa ) ; <nl> - pa - > SameTypeSource = RequirementSource ( RequirementSource : : Inferred , <nl> - SourceLoc ( ) ) ; <nl> + pa - > SameTypeSource = source ; <nl> } <nl> <nl> / / Add this resolved nested type . <nl> nested . push_back ( pa ) ; <nl> + <nl> + / / If there ' s a superclass constraint that conforms to the protocol , <nl> + / / add the appropriate same - type relationship . <nl> + maybeAddSameTypeRequirementForNestedType ( this , pa , source , <nl> + cachedSuperConformance , <nl> + builder ) ; <nl> } <nl> } <nl> <nl> bool ArchetypeBuilder : : addSuperclassRequirement ( PotentialArchetype * T , <nl> T - > Superclass = Superclass ; <nl> T - > SuperclassSource = Source ; <nl> <nl> + / / Resolve any nested types via the superclass . <nl> + for ( auto & nested : T - > getNestedTypes ( ) ) { <nl> + Optional < ProtocolConformance * > superclassConformance ; <nl> + for ( auto nestedPA : nested . second ) { <nl> + if ( nestedPA - > getResolvedAssociatedType ( ) ) { <nl> + maybeAddSameTypeRequirementForNestedType ( T , nested . second . front ( ) , <nl> + Source , <nl> + superclassConformance , * this ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> return false ; <nl> } <nl> <nl> mmm a / test / Generics / superclass_constraint . swift <nl> ppp b / test / Generics / superclass_constraint . swift <nl> <nl> / / RUN : % target - parse - verify - swift <nl> <nl> + / / RUN : % target - parse - verify - swift - parse - debug - generic - signatures % s > % t . dump 2 > & 1 <nl> + / / RUN : FileCheck % s < % t . dump <nl> + <nl> class A { <nl> func foo ( ) { } <nl> } <nl> func f10 < T : GB < A > where T : GA < A > > ( _ : T ) { } <nl> func f11 < T : GA < T > > ( _ : T ) { } / / expected - error { { superclass constraint ' GA < T > ' is recursive } } <nl> func f12 < T : GA < U > , U : GB < T > > ( _ : T , _ : U ) { } / / expected - error { { superclass constraint ' GA < U > ' is recursive } } <nl> func f13 < T : U , U : GA < T > > ( _ : T , _ : U ) { } / / expected - error { { inheritance from non - protocol , non - class type ' U ' } } <nl> + <nl> + / / rdar : / / problem / 24730536 <nl> + / / Superclass constraints can be used to resolve nested types to concrete types . <nl> + <nl> + protocol P3 { <nl> + associatedtype T <nl> + } <nl> + <nl> + protocol P2 { <nl> + associatedtype T : P3 <nl> + } <nl> + <nl> + class C : P3 { <nl> + typealias T = Int <nl> + } <nl> + <nl> + class S : P2 { <nl> + typealias T = C <nl> + } <nl> + <nl> + extension P2 where Self . T : C { <nl> + / / CHECK : superclass_constraint . ( file ) . P2 . concreteTypeWitnessViaSuperclass1 <nl> + / / CHECK : Generic signature : < Self where Self : P2 , Self . T : C , Self . T : P3 , Self . T . T = = T > <nl> + / / CHECK : Canonical generic signature : < τ_0_0 where τ_0_0 : P2 , τ_0_0 . T : C , τ_0_0 . T : P3 , τ_0_0 . T . T = = Int > <nl> + func concreteTypeWitnessViaSuperclass1 ( x : Self . T . T ) { } <nl> + } <nl>
|
[ Archetype builder ] Use protocol conformances of superclass to resolve nested types .
|
apple/swift
|
02dd1e407b04d81f6ea5e38aebe223b91a0571c4
|
2016-02-24T21:18:27Z
|
mmm a / src / Interpreters / MutationsInterpreter . cpp <nl> ppp b / src / Interpreters / MutationsInterpreter . cpp <nl> ASTPtr MutationsInterpreter : : prepare ( bool dry_run ) <nl> throw Exception ( " Unknown mutation command type : " + DB : : toString < int > ( command . type ) , ErrorCodes : : UNKNOWN_MUTATION_COMMAND ) ; <nl> } <nl> <nl> - / / / We cares about affected indices because we also need to rewrite them <nl> + / / / We care about affected indices because we also need to rewrite them <nl> / / / when one of index columns updated or filtered with delete . <nl> / / / The same about colums , that are needed for calculation of TTL expressions . <nl> if ( ! dependencies . empty ( ) ) <nl>
|
Fix typo
|
ClickHouse/ClickHouse
|
e3594b89ea7ae15d30b4d7d45992b6ec619cc7d6
|
2020-07-21T17:48:54Z
|
mmm a / src / arch / arch . hpp <nl> ppp b / src / arch / arch . hpp <nl> <nl> # ifndef __ARCH_ARCH_HPP__ <nl> # define __ARCH_ARCH_HPP__ <nl> <nl> - / * Cross - platform stuff * / <nl> - <nl> - # include < stdint . h > <nl> - <nl> - typedef uint64_t block_id_t ; <nl> - # define NULL_BLOCK_ID ( block_id_t ( - 1 ) ) <nl> - <nl> - typedef char byte ; <nl> - <nl> / * Select platform - specific stuff * / <nl> <nl> / * # if WE_ARE_ON_LINUX * / <nl> mmm a / src / arch / linux / io . hpp <nl> ppp b / src / arch / linux / io . hpp <nl> <nl> # include " utils2 . hpp " <nl> # include " config / args . hpp " <nl> # include " config / alloc . hpp " <nl> - # include " arch / resource . hpp " <nl> # include " arch / linux / event_queue . hpp " <nl> # include " event . hpp " <nl> # include " corefwd . hpp " <nl> deleted file mode 100644 <nl> index c313f8c8e83 . . 00000000000 <nl> mmm a / src / arch / resource . hpp <nl> ppp / dev / null <nl> <nl> - <nl> - # ifndef __ARCH_COMMON_HPP__ <nl> - # define __ARCH_COMMON_HPP__ <nl> - <nl> - # include < stdint . h > <nl> - <nl> - typedef uint64_t block_id_t ; <nl> - # define NULL_BLOCK_ID ( block_id_t ( - 1 ) ) <nl> - <nl> - typedef char byte ; <nl> - <nl> - # endif / / __ARCH_COMMON_HPP__ <nl> - <nl> mmm a / src / btree / node . hpp <nl> ppp b / src / btree / node . hpp <nl> <nl> # include < string . h > <nl> # include < time . h > <nl> # include " utils . hpp " <nl> - # include " arch / resource . hpp " <nl> + # include " buffer_cache / types . hpp " <nl> <nl> struct btree_superblock_t { <nl> int database_exists ; <nl> mmm a / src / buffer_cache / large_buf . hpp <nl> ppp b / src / buffer_cache / large_buf . hpp <nl> <nl> # define __LARGE_BUF_HPP__ <nl> <nl> # include " buffer_cache / buffer_cache . hpp " <nl> - # include " arch / resource . hpp " <nl> # include " config / args . hpp " <nl> # include " btree / node . hpp " <nl> # include " conn_fsm . hpp " <nl> mmm a / src / buffer_cache / mirrored / mirrored . hpp <nl> ppp b / src / buffer_cache / mirrored / mirrored . hpp <nl> <nl> # define __MIRRORED_CACHE_HPP__ <nl> <nl> # include " arch / arch . hpp " <nl> + # include " buffer_cache / types . hpp " <nl> # include " concurrency / access . hpp " <nl> # include " concurrency / rwi_lock . hpp " <nl> # include " buffer_cache / mirrored / callbacks . hpp " <nl> mmm a / src / buffer_cache / mock . hpp <nl> ppp b / src / buffer_cache / mock . hpp <nl> <nl> # ifndef __BUFFER_CACHE_MOCK_HPP__ <nl> # define __BUFFER_CACHE_MOCK_HPP__ <nl> <nl> - # include " arch / resource . hpp " <nl> + # include " buffer_cache / types . hpp " <nl> # include " concurrency / access . hpp " <nl> # include " containers / segmented_vector . hpp " <nl> # include " utils . hpp " <nl> mmm a / src / buffer_cache / semantic_checking . hpp <nl> ppp b / src / buffer_cache / semantic_checking . hpp <nl> <nl> # ifndef __BUFFER_CACHE_SEMANTIC_CHECKING_HPP__ <nl> # define __BUFFER_CACHE_SEMANTIC_CHECKING_HPP__ <nl> <nl> - # include " arch / resource . hpp " <nl> + # include " buffer_cache / types . hpp " <nl> # include " utils . hpp " <nl> <nl> / * The semantic - checking cache ( scc_cache_t ) is a wrapper around another cache that will <nl> new file mode 100644 <nl> index 00000000000 . . a08094c97ee <nl> mmm / dev / null <nl> ppp b / src / buffer_cache / types . hpp <nl> <nl> + # ifndef __BUFFER_CACHE_TYPES_HPP__ <nl> + # define __BUFFER_CACHE_TYPES_HPP__ <nl> + <nl> + # include " utils2 . hpp " <nl> + <nl> + typedef uint64_t block_id_t ; <nl> + # define NULL_BLOCK_ID ( block_id_t ( - 1 ) ) <nl> + <nl> + # endif / * __BUFFER_CACHE_TYPES_HPP__ * / <nl> mmm a / src / event . hpp <nl> ppp b / src / event . hpp <nl> <nl> # ifndef __EVENT_HPP__ <nl> # define __EVENT_HPP__ <nl> <nl> - # include " arch / resource . hpp " <nl> # include < sys / types . h > <nl> <nl> / / Event <nl> mmm a / src / serializer / in_place . cc <nl> ppp b / src / serializer / in_place . cc <nl> bool in_place_serializer_t : : start ( ready_callback_t * cb ) { <nl> return true ; <nl> } <nl> <nl> - bool in_place_serializer_t : : do_read ( block_id_t block_id , void * buf , read_callback_t * callback ) { <nl> + bool in_place_serializer_t : : do_read ( ser_block_id_t block_id , void * buf , read_callback_t * callback ) { <nl> <nl> assert ( state = = state_ready ) ; <nl> <nl> bool in_place_serializer_t : : do_write ( write_t * writes , int num_writes , write_txn_ <nl> return ( num_actual_writes = = 0 ) ; <nl> } <nl> <nl> - block_id_t in_place_serializer_t : : gen_block_id ( ) { <nl> + ser_block_id_t in_place_serializer_t : : gen_block_id ( ) { <nl> assert ( dbsize ! = 0 ) ; / / Superblock ID is reserved <nl> off64_t new_block_id = dbsize / block_size ; <nl> dbsize + = block_size ; <nl> bool in_place_serializer_t : : shutdown ( shutdown_callback_t * cb ) { <nl> return true ; <nl> } <nl> <nl> - off64_t in_place_serializer_t : : id_to_offset ( block_id_t id ) { <nl> + off64_t in_place_serializer_t : : id_to_offset ( ser_block_id_t id ) { <nl> return id * block_size ; <nl> } <nl> mmm a / src / serializer / in_place . hpp <nl> ppp b / src / serializer / in_place . hpp <nl> <nl> # include < sys / stat . h > <nl> # include < unistd . h > <nl> # include < fcntl . h > <nl> - # include " arch / resource . hpp " <nl> + # include " serializer / types . hpp " <nl> # include " arch / arch . hpp " <nl> # include " utils . hpp " <nl> <nl> struct in_place_serializer_t { <nl> on_serializer_read ( ) ; <nl> } <nl> } ; <nl> - bool do_read ( block_id_t block_id , void * buf , read_callback_t * callback ) ; <nl> + bool do_read ( ser_block_id_t block_id , void * buf , read_callback_t * callback ) ; <nl> <nl> / * do_write ( ) updates or deletes a group of bufs . <nl> <nl> struct in_place_serializer_t { <nl> } <nl> } ; <nl> struct write_t { <nl> - block_id_t block_id ; <nl> + ser_block_id_t block_id ; <nl> void * buf ; <nl> write_block_callback_t * callback ; <nl> } ; <nl> struct in_place_serializer_t { <nl> <nl> public : <nl> / * Generates a unique block id . * / <nl> - block_id_t gen_block_id ( ) ; <nl> + ser_block_id_t gen_block_id ( ) ; <nl> <nl> / * shutdown ( ) should be called when you are done with the serializer . It is safe to call <nl> shutdown ( ) before the serializer finishes starting up . <nl> struct in_place_serializer_t { <nl> size_t block_size ; <nl> <nl> private : <nl> - off64_t id_to_offset ( block_id_t id ) ; <nl> + off64_t id_to_offset ( ser_block_id_t id ) ; <nl> <nl> enum state_t { <nl> state_unstarted , <nl> mmm a / src / serializer / log / data_block_manager . cc <nl> ppp b / src / serializer / log / data_block_manager . cc <nl> void data_block_manager_t : : run_gc ( ) { <nl> <nl> for ( unsigned int i = 0 ; i < extent_manager - > extent_size / BTREE_BLOCK_SIZE ; i + + ) { <nl> if ( ! gc_state . current_entry . g_array [ i ] ) { <nl> - writes [ nwrites ] . block_id = * ( ( block_id_t * ) ( gc_state . gc_blocks + ( i * block_size ) ) ) ; <nl> + writes [ nwrites ] . block_id = * ( ( ser_block_id_t * ) ( gc_state . gc_blocks + ( i * block_size ) ) ) ; <nl> writes [ nwrites ] . buf = gc_state . gc_blocks + ( i * block_size ) ; <nl> writes [ nwrites ] . callback = NULL ; <nl> nwrites + + ; <nl> mmm a / src / serializer / log / data_block_manager . hpp <nl> ppp b / src / serializer / log / data_block_manager . hpp <nl> <nl> # define __SERIALIZER_LOG_DATA_BLOCK_MANAGER_HPP__ <nl> <nl> # include " arch / arch . hpp " <nl> + # include " serializer / types . hpp " <nl> # include " extents / extent_manager . hpp " <nl> # include " log_serializer_callbacks . hpp " <nl> # include " containers / priority_queue . hpp " <nl> class data_block_manager_t { <nl> public : <nl> / * data to be serialized to disk with each block * / <nl> struct buf_data_t { <nl> - block_id_t block_id ; <nl> + ser_block_id_t block_id ; <nl> } ; <nl> <nl> public : <nl> mmm a / src / serializer / log / lba / disk_extent . hpp <nl> ppp b / src / serializer / log / lba / disk_extent . hpp <nl> class lba_disk_extent_t : <nl> return amount_filled ( ) = = em - > extent_size ; <nl> } <nl> <nl> - void add_entry ( block_id_t id , off64_t offset ) { <nl> + void add_entry ( ser_block_id_t id , off64_t offset ) { <nl> <nl> / / Make sure that entries will align with DEVICE_BLOCK_SIZE <nl> assert ( DEVICE_BLOCK_SIZE % sizeof ( lba_entry_t ) = = 0 ) ; <nl> mmm a / src / serializer / log / lba / disk_format . hpp <nl> ppp b / src / serializer / log / lba / disk_format . hpp <nl> <nl> <nl> <nl> <nl> + # include " serializer / types . hpp " <nl> + <nl> + <nl> + <nl> # define NULL_OFFSET off64_t ( - 1 ) <nl> <nl> struct lba_metablock_mixin_t { <nl> struct lba_metablock_mixin_t { <nl> <nl> / / PADDING_BLOCK_ID and PADDING_OFFSET indicate that an entry in the LBA list only exists to fill <nl> / / out a DEVICE_BLOCK_SIZE - sized chunk of the extent . <nl> - # define PADDING_BLOCK_ID block_id_t ( - 1 ) <nl> + # define PADDING_BLOCK_ID ser_block_id_t ( - 1 ) <nl> # define PADDING_OFFSET off64_t ( - 1 ) <nl> <nl> # define DELETE_BLOCK off64_t ( - 1 ) <nl> <nl> struct lba_entry_t { <nl> - block_id_t block_id ; <nl> + ser_block_id_t block_id ; <nl> off64_t offset ; / / Is either an offset into the file or DELETE_BLOCK <nl> } ; <nl> <nl> mmm a / src / serializer / log / lba / disk_structure . cc <nl> ppp b / src / serializer / log / lba / disk_structure . cc <nl> struct lba_writer_t : <nl> } <nl> } ; <nl> <nl> - void lba_disk_structure_t : : add_entry ( block_id_t block_id , off64_t offset ) { <nl> + void lba_disk_structure_t : : add_entry ( ser_block_id_t block_id , off64_t offset ) { <nl> <nl> if ( last_extent & & last_extent - > full ( ) ) { <nl> <nl> mmm a / src / serializer / log / lba / disk_structure . hpp <nl> ppp b / src / serializer / log / lba / disk_structure . hpp <nl> class lba_disk_structure_t : <nl> static bool load ( extent_manager_t * em , direct_file_t * file , lba_metablock_mixin_t * metablock , <nl> lba_disk_structure_t * * out , load_callback_t * cb ) ; <nl> <nl> - void add_entry ( block_id_t block_id , off64_t offset ) ; <nl> + void add_entry ( ser_block_id_t block_id , off64_t offset ) ; <nl> bool sync ( sync_callback_t * cb ) ; <nl> void prepare_metablock ( lba_metablock_mixin_t * mb_out ) ; <nl> <nl> mmm a / src / serializer / log / lba / in_memory_index . hpp <nl> ppp b / src / serializer / log / lba / in_memory_index . hpp <nl> struct in_memory_index_t : <nl> offset = _offset ; <nl> } <nl> <nl> - block_id_t get_next_free_id ( ) { <nl> + ser_block_id_t get_next_free_id ( ) { <nl> assert ( get_state ( ) = = block_unused ) ; <nl> - / / We need to do this because NULL_BLOCK_ID is - 1 , <nl> - / / block_id_t is uint , and _id and next_free_id have <nl> + / / We need to do this because NULL_SER_BLOCK_ID is - 1 , <nl> + / / ser_block_id_t is uint , and _id and next_free_id have <nl> / / different number of bits <nl> struct temp_t { <nl> - block_id_t id : 62 ; <nl> + ser_block_id_t id : 62 ; <nl> } ; <nl> temp_t temp ; <nl> temp . id = 0 ; <nl> temp . id - - ; <nl> if ( next_free_id = = temp . id ) <nl> - return NULL_BLOCK_ID ; <nl> + return NULL_SER_BLOCK_ID ; <nl> else <nl> return next_free_id ; <nl> } <nl> - void set_next_free_id ( block_id_t _id ) { <nl> + void set_next_free_id ( ser_block_id_t _id ) { <nl> assert ( get_state ( ) = = block_unused ) ; <nl> - / / We need to do this because NULL_BLOCK_ID is - 1 , <nl> - / / block_id_t is uint , and _id and next_free_id have <nl> + / / We need to do this because NULL_SER_BLOCK_ID is - 1 , <nl> + / / ser_block_id_t is uint , and _id and next_free_id have <nl> / / different number of bits <nl> - if ( _id = = NULL_BLOCK_ID ) { <nl> + if ( _id = = NULL_SER_BLOCK_ID ) { <nl> next_free_id = 0 ; <nl> next_free_id - - ; <nl> } <nl> struct in_memory_index_t : <nl> private : <nl> block_state_t state : 2 ; <nl> union { <nl> - off64_t offset : 62 ; / / If state = = block_used , the location of the block in the file <nl> - block_id_t next_free_id : 62 ; / / If state = = block_unused , contains the id of the next free block <nl> + off64_t offset : 62 ; / / If state = = block_used , the location of the block in the file <nl> + ser_block_id_t next_free_id : 62 ; / / If state = = block_unused , contains the id of the next free block <nl> } ; <nl> } ; <nl> <nl> segmented_vector_t < block_info_t , MAX_BLOCK_ID > blocks ; <nl> - block_id_t next_free_id ; <nl> + ser_block_id_t next_free_id ; <nl> <nl> public : <nl> in_memory_index_t ( ) { <nl> struct in_memory_index_t : <nl> the best way to guarantee that block ID 0 is the superblock . * / <nl> blocks . set_size ( 1 ) ; <nl> blocks [ SUPERBLOCK_ID ] . set_state ( block_in_limbo ) ; <nl> - next_free_id = NULL_BLOCK_ID ; <nl> + next_free_id = NULL_SER_BLOCK_ID ; <nl> } <nl> <nl> in_memory_index_t ( lba_disk_structure_t * s , data_block_manager_t * dbm , extent_manager_t * em ) { <nl> struct in_memory_index_t : <nl> / / but will do for first release . TODO : fix the lba system <nl> / / to avoid O ( n ) algorithms on startup . <nl> dbm - > start_reconstruct ( ) ; <nl> - next_free_id = NULL_BLOCK_ID ; <nl> - for ( block_id_t id = 0 ; id < blocks . get_size ( ) ; id + + ) { <nl> + next_free_id = NULL_SER_BLOCK_ID ; <nl> + for ( ser_block_id_t id = 0 ; id < blocks . get_size ( ) ; id + + ) { <nl> / / Remap blocks that weren ' t found to unused <nl> switch ( blocks [ id ] . get_state ( ) ) { <nl> case block_not_found : <nl> struct in_memory_index_t : <nl> return false ; <nl> } <nl> <nl> - bool is_offset_referenced ( block_id_t block_id , off64_t offset ) { <nl> + bool is_offset_referenced ( ser_block_id_t block_id , off64_t offset ) { <nl> for ( unsigned int i = 0 ; i < blocks . get_size ( ) ; i + + ) { <nl> block_info_t block = blocks [ i ] ; <nl> if ( block . get_state ( ) = = block_used & & block . get_offset ( ) = = offset & & i ! = block_id ) <nl> struct in_memory_index_t : <nl> } <nl> } <nl> <nl> - block_id_t gen_block_id ( void ) { <nl> - if ( next_free_id = = NULL_BLOCK_ID ) { <nl> + ser_block_id_t gen_block_id ( void ) { <nl> + if ( next_free_id = = NULL_SER_BLOCK_ID ) { <nl> / / There is no recyclable block id <nl> - block_id_t id = blocks . get_size ( ) ; <nl> + ser_block_id_t id = blocks . get_size ( ) ; <nl> blocks . set_size ( blocks . get_size ( ) + 1 ) ; <nl> blocks [ id ] . set_state ( block_in_limbo ) ; <nl> return id ; <nl> } else { <nl> / / Grab a recyclable id from the freelist <nl> - block_id_t id = next_free_id ; <nl> + ser_block_id_t id = next_free_id ; <nl> assert ( blocks [ id ] . get_state ( ) = = block_unused ) ; <nl> next_free_id = blocks [ id ] . get_next_free_id ( ) ; <nl> blocks [ id ] . set_state ( block_in_limbo ) ; <nl> struct in_memory_index_t : <nl> } <nl> } <nl> <nl> - block_id_t max_block_id ( ) { <nl> + ser_block_id_t max_block_id ( ) { <nl> return blocks . get_size ( ) ; <nl> } <nl> <nl> - off64_t get_block_offset ( block_id_t id ) { <nl> + off64_t get_block_offset ( ser_block_id_t id ) { <nl> if ( id > = blocks . get_size ( ) ) { <nl> fail ( " Tried to get offset of a block that doesn ' t exist ( id % lu too high ) " , id ) ; <nl> } <nl> struct in_memory_index_t : <nl> } <nl> } <nl> <nl> - void set_block_offset ( block_id_t id , off64_t offset ) { <nl> + void set_block_offset ( ser_block_id_t id , off64_t offset ) { <nl> <nl> / / Blocks must be returned by gen_block_id ( ) before they are legal to use <nl> assert ( blocks [ id ] . get_state ( ) ! = block_unused ) ; <nl> struct in_memory_index_t : <nl> blocks [ id ] . set_offset ( offset ) ; <nl> } <nl> <nl> - void delete_block ( block_id_t id ) { <nl> + void delete_block ( ser_block_id_t id ) { <nl> <nl> assert ( blocks [ id ] . get_state ( ) ! = block_unused ) ; <nl> blocks [ id ] . set_state ( block_unused ) ; <nl> mmm a / src / serializer / log / lba / lba_list . cc <nl> ppp b / src / serializer / log / lba / lba_list . cc <nl> bool lba_list_t : : start ( direct_file_t * file , metablock_mixin_t * last_metablock , r <nl> return starter - > run ( last_metablock , cb ) ; <nl> } <nl> <nl> - block_id_t lba_list_t : : gen_block_id ( ) { <nl> + ser_block_id_t lba_list_t : : gen_block_id ( ) { <nl> assert ( state = = state_ready ) ; <nl> <nl> return in_memory_index - > gen_block_id ( ) ; <nl> } <nl> <nl> - block_id_t lba_list_t : : max_block_id ( ) { <nl> + ser_block_id_t lba_list_t : : max_block_id ( ) { <nl> assert ( state = = state_ready ) ; <nl> <nl> return in_memory_index - > max_block_id ( ) ; <nl> } <nl> <nl> - off64_t lba_list_t : : get_block_offset ( block_id_t block ) { <nl> + off64_t lba_list_t : : get_block_offset ( ser_block_id_t block ) { <nl> assert ( state = = state_ready ) ; <nl> <nl> return in_memory_index - > get_block_offset ( block ) ; <nl> int lba_list_t : : extent_refcount ( off64_t offset ) { <nl> } <nl> # endif <nl> <nl> - void lba_list_t : : set_block_offset ( block_id_t block , off64_t offset ) { <nl> + void lba_list_t : : set_block_offset ( ser_block_id_t block , off64_t offset ) { <nl> assert ( state = = state_ready ) ; <nl> <nl> in_memory_index - > set_block_offset ( block , offset ) ; <nl> void lba_list_t : : set_block_offset ( block_id_t block , off64_t offset ) { <nl> disk_structure - > add_entry ( block , offset ) ; <nl> } <nl> <nl> - void lba_list_t : : delete_block ( block_id_t block ) { <nl> + void lba_list_t : : delete_block ( ser_block_id_t block ) { <nl> assert ( state = = state_ready ) ; <nl> <nl> in_memory_index - > delete_block ( block ) ; <nl> struct gc_fsm_t : <nl> <nl> / * Put entries in the new empty LBA * / <nl> <nl> - for ( block_id_t id = 0 ; id < owner - > max_block_id ( ) ; id + + ) { <nl> + for ( ser_block_id_t id = 0 ; id < owner - > max_block_id ( ) ; id + + ) { <nl> owner - > disk_structure - > add_entry ( id , owner - > get_block_offset ( id ) ) ; <nl> } <nl> <nl> mmm a / src / serializer / log / lba / lba_list . hpp <nl> ppp b / src / serializer / log / lba / lba_list . hpp <nl> <nl> # ifndef __SERIALIZER_LOG_LBA_LIST_HPP__ <nl> # define __SERIALIZER_LOG_LBA_LIST_HPP__ <nl> <nl> - # include " arch / resource . hpp " <nl> + # include " serializer / types . hpp " <nl> # include " . . / extents / extent_manager . hpp " <nl> # include " disk_format . hpp " <nl> # include " in_memory_index . hpp " <nl> class lba_list_t <nl> / * gen_block_id ( ) will return a block ID which is " in limbo " . It is not considered to be <nl> " in use " until it is actually written to disk , but gen_block_id ( ) will not return the same <nl> ID again until either it is written to disk and then deleted or the database is restarted . * / <nl> - block_id_t gen_block_id ( ) ; <nl> + ser_block_id_t gen_block_id ( ) ; <nl> <nl> / * Returns DELETE_BLOCK if the block does not exist * / <nl> - off64_t get_block_offset ( block_id_t block ) ; <nl> + off64_t get_block_offset ( ser_block_id_t block ) ; <nl> <nl> - block_id_t max_block_id ( ) ; <nl> + ser_block_id_t max_block_id ( ) ; <nl> # ifndef NDEBUG <nl> bool is_extent_referenced ( off64_t offset ) ; <nl> bool is_offset_referenced ( off64_t offset ) ; <nl> class lba_list_t <nl> # endif <nl> <nl> public : <nl> - void set_block_offset ( block_id_t block , off64_t offset ) ; <nl> - void delete_block ( block_id_t block ) ; <nl> + void set_block_offset ( ser_block_id_t block , off64_t offset ) ; <nl> + void delete_block ( ser_block_id_t block ) ; <nl> <nl> struct sync_callback_t { <nl> virtual void on_lba_sync ( ) = 0 ; <nl> mmm a / src / serializer / log / log_serializer . cc <nl> ppp b / src / serializer / log / log_serializer . cc <nl> struct ls_block_writer_t : <nl> if ( write . buf ) { <nl> <nl> off64_t new_offset ; <nl> - * ( block_id_t * ) write . buf = write . block_id ; <nl> + * ( ser_block_id_t * ) write . buf = write . block_id ; <nl> bool done = ser - > data_block_manager . write ( write . buf , & new_offset , this ) ; <nl> ser - > lba_index . set_block_offset ( write . block_id , new_offset ) ; <nl> <nl> bool log_serializer_t : : do_write ( write_t * writes , int num_writes , write_txn_callb <nl> return res ; <nl> } <nl> <nl> - bool log_serializer_t : : do_read ( block_id_t block_id , void * buf , read_callback_t * callback ) { <nl> + bool log_serializer_t : : do_read ( ser_block_id_t block_id , void * buf , read_callback_t * callback ) { <nl> <nl> assert ( state = = state_ready ) ; <nl> <nl> bool log_serializer_t : : do_read ( block_id_t block_id , void * buf , read_callback_t * <nl> } <nl> } <nl> <nl> - block_id_t log_serializer_t : : gen_block_id ( ) { <nl> + ser_block_id_t log_serializer_t : : gen_block_id ( ) { <nl> assert ( state = = state_ready ) ; <nl> return lba_index . gen_block_id ( ) ; <nl> } <nl> mmm a / src / serializer / log / log_serializer . hpp <nl> ppp b / src / serializer / log / log_serializer . hpp <nl> <nl> # include < fcntl . h > <nl> # include < map > <nl> <nl> - # include " arch / resource . hpp " <nl> + # include " serializer / types . hpp " <nl> # include " config / cmd_args . hpp " <nl> # include " config / alloc . hpp " <nl> # include " utils . hpp " <nl> struct log_serializer_t : private data_block_manager_t : : shutdown_callback_t , <nl> on_serializer_read ( ) ; <nl> } <nl> } ; <nl> - bool do_read ( block_id_t block_id , void * buf , read_callback_t * callback ) ; <nl> + bool do_read ( ser_block_id_t block_id , void * buf , read_callback_t * callback ) ; <nl> <nl> / * do_write ( ) updates or deletes a group of bufs . <nl> <nl> struct log_serializer_t : private data_block_manager_t : : shutdown_callback_t , <nl> typedef _write_block_callback_t write_block_callback_t ; <nl> <nl> struct write_t { <nl> - block_id_t block_id ; <nl> + ser_block_id_t block_id ; <nl> void * buf ; / * If NULL , a deletion * / <nl> write_block_callback_t * callback ; <nl> } ; <nl> struct log_serializer_t : private data_block_manager_t : : shutdown_callback_t , <nl> <nl> public : <nl> / * Generates a unique block id . * / <nl> - block_id_t gen_block_id ( ) ; <nl> + ser_block_id_t gen_block_id ( ) ; <nl> <nl> / * shutdown ( ) should be called when you are done with the serializer . <nl> <nl> struct log_serializer_t : private data_block_manager_t : : shutdown_callback_t , <nl> for a block ID that we are currently writing but is not on disk yet , we can return <nl> the most current version . * / <nl> typedef std : : map < <nl> - block_id_t , ls_block_writer_t * , <nl> - std : : less < block_id_t > , <nl> - gnew_alloc < std : : pair < block_id_t , ls_block_writer_t * > > <nl> + ser_block_id_t , ls_block_writer_t * , <nl> + std : : less < ser_block_id_t > , <nl> + gnew_alloc < std : : pair < ser_block_id_t , ls_block_writer_t * > > <nl> > block_writer_map_t ; <nl> block_writer_map_t block_writer_map ; <nl> # ifndef NDEBUG <nl> mmm a / src / serializer / semantic_checking . hpp <nl> ppp b / src / serializer / semantic_checking . hpp <nl> class semantic_checking_serializer_t <nl> <nl> private : <nl> struct persisted_block_info_t { <nl> - block_id_t block_id ; <nl> + ser_block_id_t block_id ; <nl> block_info_t block_info ; <nl> } ; <nl> int semantic_fd ; <nl> class semantic_checking_serializer_t <nl> public alloc_mixin_t < tls_small_obj_alloc_accessor < alloc_t > , reader_t > <nl> { <nl> semantic_checking_serializer_t * parent ; <nl> - block_id_t block_id ; <nl> + ser_block_id_t block_id ; <nl> void * buf ; <nl> block_info_t expected_block_state ; <nl> read_callback_t * callback ; <nl> <nl> - reader_t ( semantic_checking_serializer_t * parent , block_id_t block_id , void * buf , block_info_t expected_block_state ) <nl> + reader_t ( semantic_checking_serializer_t * parent , ser_block_id_t block_id , void * buf , block_info_t expected_block_state ) <nl> : parent ( parent ) , block_id ( block_id ) , buf ( buf ) , expected_block_state ( expected_block_state ) { } <nl> <nl> void on_serializer_read ( ) { <nl> class semantic_checking_serializer_t <nl> } <nl> } ; <nl> <nl> - bool do_read ( block_id_t block_id , void * buf , read_callback_t * callback ) { <nl> + bool do_read ( ser_block_id_t block_id , void * buf , read_callback_t * callback ) { <nl> # ifdef SERIALIZER_DEBUG_PRINT <nl> printf ( " Reading % ld \ n " , block_id ) ; <nl> # endif <nl> class semantic_checking_serializer_t <nl> } <nl> <nl> public : <nl> - block_id_t gen_block_id ( ) { <nl> + ser_block_id_t gen_block_id ( ) { <nl> return inner_serializer . gen_block_id ( ) ; <nl> } <nl> <nl> new file mode 100644 <nl> index 00000000000 . . d4b33660fcd <nl> mmm / dev / null <nl> ppp b / src / serializer / types . hpp <nl> <nl> + # ifndef __SERIALIZER_TYPES_HPP__ <nl> + # define __SERIALIZER_TYPES_HPP__ <nl> + <nl> + # include " utils2 . hpp " <nl> + <nl> + typedef uint64_t ser_block_id_t ; <nl> + # define NULL_SER_BLOCK_ID ( ser_block_id_t ( - 1 ) ) <nl> + <nl> + # endif / * __SERIALIZER_TYPES_HPP__ * / <nl> mmm a / src / utils2 . hpp <nl> ppp b / src / utils2 . hpp <nl> <nl> The reason it is separate from utils . hpp is that the IO layer needs some of the things in <nl> utils2 . hpp , but utils . hpp needs some things in the IO layer . * / <nl> <nl> + # include < stdint . h > <nl> # include " errors . hpp " <nl> # include " config / alloc . hpp " <nl> <nl> int get_cpu_count ( ) ; <nl> long get_available_ram ( ) ; <nl> long get_total_ram ( ) ; <nl> <nl> + typedef char byte ; <nl> + <nl> template < typename T1 , typename T2 > <nl> T1 ceil_aligned ( T1 value , T2 alignment ) { <nl> if ( value % alignment ! = 0 ) { <nl>
|
Split block_id_t into ser_block_id_t and block_id_t in preparation for multi - caches - per - serializer .
|
rethinkdb/rethinkdb
|
c2c94fab5a482284a479f7fa9df8857be28f1bb0
|
2010-10-12T18:11:45Z
|
mmm a / contracts / eoslib / action . h <nl> ppp b / contracts / eoslib / action . h <nl> <nl> <nl> extern " C " { <nl> / * * <nl> - * @ defgroup messageapi message API <nl> + * @ defgroup actionapi action API <nl> * @ ingroup contractdev <nl> - * @ brief Define API for querying message properties <nl> + * @ brief Define API for querying action properties <nl> * <nl> * / <nl> <nl> / * * <nl> - * @ defgroup messagecapi Message C API <nl> - * @ ingroup messageapi <nl> - * @ brief Define API for querying message properties <nl> + * @ defgroup actioncapi Action C API <nl> + * @ ingroup actionapi <nl> + * @ brief Define API for querying action properties <nl> * <nl> * <nl> - * A EOS . IO message has the following abstract structure : <nl> + * A EOS . IO action has the following abstract structure : <nl> * <nl> * ` ` ` <nl> - * struct message { <nl> - * account_name code ; / / the contract defining the primary code to execute for code / type <nl> - * func_name type ; / / the action to be taken <nl> - * AccountPermission [ ] authorization ; / / the accounts and permission levels provided <nl> + * struct action { <nl> + * scope_name scope ; / / the contract defining the primary code to execute for code / type <nl> + * action_name name ; / / the action to be taken <nl> + * permission_level [ ] authorization ; / / the accounts and permission levels provided <nl> * bytes data ; / / opaque data processed by code <nl> * } ; <nl> * ` ` ` <nl> * <nl> - * This API enables your contract to inspect the fields on the current message and act accordingly . <nl> + * This API enables your contract to inspect the fields on the current action and act accordingly . <nl> * <nl> * Example : <nl> * @ code <nl> - * / / Assume this message is used for the following examples : <nl> + * / / Assume this action is used for the following examples : <nl> * / / { <nl> * / / " code " : " eos " , <nl> * / / " type " : " transfer " , <nl> extern " C " { <nl> * / / } <nl> * <nl> * char buffer [ 128 ] ; <nl> - * uint32_t total = read_action ( buffer , 5 ) ; / / buffer contains the content of the message up to 5 bytes <nl> + * uint32_t total = read_action ( buffer , 5 ) ; / / buffer contains the content of the action up to 5 bytes <nl> * print ( total ) ; / / Output : 5 <nl> * <nl> * uint32_t msgsize = action_size ( ) ; <nl> - * print ( msgsize ) ; / / Output : size of the above message ' s data field <nl> + * print ( msgsize ) ; / / Output : size of the above action ' s data field <nl> * <nl> - * require_recipient ( N ( initc ) ) ; / / initc account will be notified for this message <nl> + * require_recipient ( N ( initc ) ) ; / / initc account will be notified for this action <nl> * <nl> * require_auth ( N ( inita ) ) ; / / Do nothing since inita exists in the auth list <nl> * require_auth ( N ( initb ) ) ; / / Throws an exception <nl> extern " C " { <nl> * account_name code = current_receiver ( ) ; <nl> * print ( Name ( code ) ) ; / / Output : eos <nl> * <nl> - * assert ( Name ( current_receiver ( ) ) = = = " eos " , " This message expects to be received by eos " ) ; / / Do nothing <nl> - * assert ( Name ( current_receiver ( ) ) = = = " inita " , " This message expects to be received by inita " ) ; / / Throws exception and roll back transfer transaction <nl> + * assert ( Name ( current_receiver ( ) ) = = = " eos " , " This action expects to be received by eos " ) ; / / Do nothing <nl> + * assert ( Name ( current_receiver ( ) ) = = = " inita " , " This action expects to be received by inita " ) ; / / Throws exception and roll back transfer transaction <nl> * <nl> * print ( now ( ) ) ; / / Output : timestamp of last accepted block <nl> * <nl> extern " C " { <nl> * / <nl> <nl> / * * <nl> - * Copy up to @ ref len bytes of current message to the specified location <nl> - * @ brief Copy current message to the specified location <nl> - * @ param msg - a pointer where up to @ ref len bytes of the current message will be copied <nl> - * @ param len - len of the current message to be copied <nl> + * Copy up to @ ref len bytes of current action to the specified location <nl> + * @ brief Copy current action to the specified location <nl> + * @ param msg - a pointer where up to @ ref len bytes of the current action will be copied <nl> + * @ param len - len of the current action to be copied <nl> * @ return the number of bytes copied to msg <nl> * / <nl> uint32_t read_action ( void * msg , uint32_t len ) ; <nl> <nl> / * * <nl> - * Get the length of the current message ' s data field <nl> - * This method is useful for dynamically sized messages <nl> - * @ brief Get the length of current message ' s data field <nl> - * @ return the length of the current message ' s data field <nl> + * Get the length of the current action ' s data field <nl> + * This method is useful for dynamically sized actions <nl> + * @ brief Get the length of current action ' s data field <nl> + * @ return the length of the current action ' s data field <nl> * / <nl> uint32_t action_size ( ) ; <nl> <nl> extern " C " { <nl> void require_recipient ( account_name name ) ; <nl> <nl> / * * <nl> - * Verifies that @ ref name exists in the set of provided auths on a message . Throws if not found <nl> + * Verifies that @ ref name exists in the set of provided auths on a action . Throws if not found <nl> * @ brief Verify specified account exists in the set of provided auths <nl> * @ param name - name of the account to be verified <nl> * / <nl> extern " C " { <nl> * / <nl> account_name current_receiver ( ) ; <nl> <nl> - / / / @ } messagecapi <nl> + / / / @ } actioncapi <nl> } <nl>
|
Update message - > action
|
EOSIO/eos
|
0b7468adb52fb232e9b11d2a9401e4074ed61719
|
2018-01-05T20:46:56Z
|
mmm a / test / cpp / qps / usage_timer . cc <nl> ppp b / test / cpp / qps / usage_timer . cc <nl> static void get_cpu_usage ( unsigned long long * total_cpu_time , <nl> std : : stringstream first_line_s ( first_line ) ; <nl> for ( int i = 0 ; i < 10 ; + + i ) { <nl> std : : getline ( first_line_s , cpu_time_str , ' ' ) ; <nl> - * total_cpu_time + = std : : stoi ( cpu_time_str ) ; <nl> + * total_cpu_time + = std : : stol ( cpu_time_str ) ; <nl> if ( i = = 3 ) { <nl> - * idle_cpu_time = std : : stoi ( cpu_time_str ) ; <nl> + * idle_cpu_time = std : : stol ( cpu_time_str ) ; <nl> } <nl> } <nl> } <nl>
|
resolve out_of_range error from stoi function .
|
grpc/grpc
|
6a5b9924f3c4cc25bf1137b1e0223197ec276948
|
2016-10-07T00:31:40Z
|
mmm a / project / cmake / addons / CMakeLists . txt <nl> ppp b / project / cmake / addons / CMakeLists . txt <nl> foreach ( addon $ { addons } ) <nl> file ( REMOVE_RECURSE " $ { CMAKE_INSTALL_PREFIX } / $ { id } / " ) <nl> endif ( ) <nl> <nl> + # prepare the setup of the call to externalproject_add ( ) <nl> + set ( EXTERNALPROJECT_SETUP INSTALL_DIR " $ { CMAKE_INSTALL_PREFIX } " <nl> + CMAKE_ARGS $ { BUILD_ARGS } ) <nl> + <nl> # get the URL and revision of the addon <nl> + list ( LENGTH def deflength ) <nl> list ( GET def 1 url ) <nl> - list ( GET def 2 revision ) <nl> - <nl> - # add the addon as an external project for automatic building <nl> - externalproject_add ( $ { id } <nl> - GIT_REPOSITORY $ { url } <nl> - GIT_TAG $ { revision } <nl> - INSTALL_DIR " $ { CMAKE_INSTALL_PREFIX } " <nl> - CMAKE_ARGS $ { BUILD_ARGS } <nl> - ) <nl> + # check if there ' s a third parameter in the file <nl> + if ( deflength GREATER 2 ) <nl> + # the third parameter is considered as a revision of a git repository <nl> + list ( GET def 2 revision ) <nl> + <nl> + externalproject_add ( $ { id } <nl> + GIT_REPOSITORY $ { url } <nl> + GIT_TAG $ { revision } <nl> + " $ { EXTERNALPROJECT_SETUP } " <nl> + ) <nl> + else ( ) <nl> + externalproject_add ( $ { id } <nl> + URL $ { url } <nl> + " $ { EXTERNALPROJECT_SETUP } " <nl> + ) <nl> + endif ( ) <nl> endif ( ) <nl> endif ( ) <nl> endif ( ) <nl>
|
binary addons : allow downloading addons as source packages instead of git repositories
|
xbmc/xbmc
|
c96e2203fcb039ca5f5e533adfe2794eea45df8b
|
2014-08-05T11:39:58Z
|
mmm a / tensorflow / compiler / mlir / xla / ir / hlo_ops . td <nl> ppp b / tensorflow / compiler / mlir / xla / ir / hlo_ops . td <nl> def HLO_XorOp : HLO_BinaryLogicalElementwiseOp < " xor " > , BASE_HLO_XorOp ; <nl> / / XLA communication op definitions . <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> + / / Represents a unique identifier for each Send / Recv instruction pair or <nl> + / / optionally for collective instructions ( AllReduce , CollectivePermute , <nl> + / / AllToAll ) . Non - positive channel_id handle is equivalent to no channel id . <nl> + def ChannelHandle : StructAttr < " ChannelHandle " , HLO_Dialect , [ <nl> + StructFieldAttr < " handle " , I64Attr > , <nl> + StructFieldAttr < " type " , I64Attr > ] > { <nl> + let description = " two 64 - bit integers ' handle ' and ' type ' " ; <nl> + } <nl> + <nl> / / InfeedOp corresponds to ' InfeedWithToken ' xla client API and not ' Infeed ' . <nl> / / InfeedWithToken allows ordering of infeed HLO instructions using tokens . <nl> def HLO_InfeedOp : HLO_Op < " infeed " , [ ] > { <nl> def HLO_OutfeedOp : HLO_Op < " outfeed " , [ ] > { <nl> let hasCustomHLOConverter = 1 ; <nl> } <nl> <nl> + def HLO_SendOp : HLO_Op < " send " , [ ] > { <nl> + <nl> + string summary = " Send operator " ; <nl> + <nl> + string description = [ { <nl> + Sends the given operand data to a Recv instruction in another computation <nl> + that shares the same channel handle . Does not return any data . Similar to <nl> + the Recv operation , Send operation represents synchronous communication , <nl> + and is internally decomposed into 2 HLO instructions ( Send and SendDone ) to <nl> + enable asynchronous data transfers . <nl> + <nl> + See https : / / www . tensorflow . org / xla / operation_semantics # send . <nl> + } ] ; <nl> + <nl> + let arguments = ( ins <nl> + HLO_TensorOrTuple : $ operand , <nl> + HLO_Token : $ token , <nl> + ChannelHandle : $ channel_id , <nl> + DefaultValuedAttr < BoolAttr , " false " > : $ is_host_transfer <nl> + ) ; <nl> + <nl> + let results = ( outs HLO_Token ) ; <nl> + let hasCustomHLOConverter = 1 ; <nl> + } <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> / / XLA parallelism related op definitions . <nl> def HLO_WhileOp : HLO_Op < " while " , [ NoSideEffect , SameOperandsAndResultType ] > { <nl> let hasCustomHLOConverter = 1 ; <nl> } <nl> <nl> - / / Represents a unique identifier for each Send / Recv instruction pair or <nl> - / / optionally for collective instructions ( AllReduce , CollectivePermute , <nl> - / / AllToAll ) . Non - positive channel_id handle is equivalent to no channel id . <nl> - def ChannelHandle : StructAttr < " ChannelHandle " , HLO_Dialect , [ <nl> - StructFieldAttr < " handle " , I64Attr > , <nl> - StructFieldAttr < " type " , I64Attr > ] > { <nl> - let description = " two 64 - bit integers ' handle ' and ' type ' " ; <nl> - } <nl> - <nl> def HLO_AllReduceOp : HLO_Op < " all_reduce " , <nl> [ NoSideEffect , SameOperandsAndResultType ] > , BASE_HLO_AllReduceOp { <nl> <nl> mmm a / tensorflow / compiler / mlir / xla / mlir_hlo_to_hlo . cc <nl> ppp b / tensorflow / compiler / mlir / xla / mlir_hlo_to_hlo . cc <nl> LogicalResult ExportXlaOp ( SelectAndScatterOp op , OpLoweringContext ctx ) { <nl> return success ( ) ; <nl> } <nl> <nl> + LogicalResult ExportXlaOp ( SendOp op , OpLoweringContext ctx ) { <nl> + auto & value_map = * ctx . values ; <nl> + if ( op . is_host_transfer ( ) ) { <nl> + value_map [ op ] = <nl> + xla : : SendToHost ( value_map [ op . operand ( ) ] , value_map [ op . token ( ) ] , <nl> + xla : : TypeToShape ( op . operand ( ) . getType ( ) ) , <nl> + Convert_channel_handle ( op . channel_id ( ) ) ) ; <nl> + return success ( ) ; <nl> + } <nl> + value_map [ op ] = <nl> + xla : : SendWithToken ( value_map [ op . operand ( ) ] , value_map [ op . token ( ) ] , <nl> + Convert_channel_handle ( op . channel_id ( ) ) ) ; <nl> + return success ( ) ; <nl> + } <nl> + <nl> LogicalResult ExportXlaOp ( SliceOp op , OpLoweringContext ctx ) { <nl> return failure ( ) ; <nl> } <nl> mmm a / tensorflow / compiler / mlir / xla / tests / translate / export . mlir <nl> ppp b / tensorflow / compiler / mlir / xla / tests / translate / export . mlir <nl> func @ main ( % arg0 : tensor < 10x24x24x64xf32 > , % arg1 : tensor < 10x12x12x64xf32 > ) - > te <nl> <nl> / / mmm - - <nl> <nl> + / / CHECK : HloModule <nl> + func @ main ( % arg : tensor < 3x4xi32 > , % token : ! xla_hlo . token ) - > ! xla_hlo . token { <nl> + % 0 = " xla_hlo . send " ( % arg , % token ) { <nl> + channel_id = { <nl> + handle = 5 : i64 , <nl> + type = 2 : i64 / / Device to host channel <nl> + } , <nl> + is_host_transfer = true <nl> + } : ( tensor < 3x4xi32 > , ! xla_hlo . token ) - > ! xla_hlo . token <nl> + return % 0 : ! xla_hlo . token <nl> + } <nl> + <nl> + / / CHECK : ENTRY <nl> + / / CHECK : [ [ ARG : % . * ] ] = s32 [ 3 , 4 ] parameter ( 0 ) <nl> + / / CHECK : [ [ TOKEN : % . * ] ] = token [ ] parameter ( 1 ) <nl> + / / CHECK : [ [ SEND : % . * ] ] = ( s32 [ 3 , 4 ] , u32 [ ] , token [ ] ) send ( s32 [ 3 , 4 ] [ [ ARG ] ] , token [ ] [ [ TOKEN ] ] ) , channel_id = 5 , is_host_transfer = true <nl> + / / CHECK : ROOT <nl> + / / CHECK - SAME : token [ ] send - done ( ( s32 [ 3 , 4 ] , u32 [ ] , token [ ] ) [ [ SEND ] ] ) , channel_id = 5 , is_host_transfer = true <nl> + <nl> + / / mmm - - <nl> + <nl> + / / CHECK : HloModule <nl> + func @ main ( % arg : tensor < 3x4xi32 > , % token : ! xla_hlo . token ) - > ! xla_hlo . token { <nl> + % 0 = " xla_hlo . send " ( % arg , % token ) { <nl> + channel_id = { <nl> + handle = 5 : i64 , <nl> + type = 1 : i64 / / Device to device channel <nl> + } , <nl> + is_host_transfer = false <nl> + } : ( tensor < 3x4xi32 > , ! xla_hlo . token ) - > ! xla_hlo . token <nl> + return % 0 : ! xla_hlo . token <nl> + } <nl> + <nl> + / / CHECK : ENTRY <nl> + / / CHECK : [ [ ARG : % . * ] ] = s32 [ 3 , 4 ] parameter ( 0 ) <nl> + / / CHECK : [ [ TOKEN : % . * ] ] = token [ ] parameter ( 1 ) <nl> + / / CHECK : [ [ SEND : % . * ] ] = ( s32 [ 3 , 4 ] , u32 [ ] , token [ ] ) send ( s32 [ 3 , 4 ] [ [ ARG ] ] , token [ ] [ [ TOKEN ] ] ) , channel_id = 5 <nl> + / / CHECK : ROOT <nl> + / / CHECK - SAME : token [ ] send - done ( ( s32 [ 3 , 4 ] , u32 [ ] , token [ ] ) [ [ SEND ] ] ) , channel_id = 5 <nl> + <nl> + / / mmm - - <nl> + <nl> / / CHECK : HloModule <nl> func @ main ( % arg : tensor < 3x4xi32 > ) - > tensor < 1x2xi32 > { <nl> % 0 = " xla_hlo . slice " ( % arg ) { start_indices = dense < [ 1 , 0 ] > : tensor < 2xi64 > , limit_indices = dense < [ 2 , 4 ] > : tensor < 2xi64 > , strides = dense < [ 1 , 2 ] > : tensor < 2xi64 > } : ( tensor < 3x4xi32 > ) - > tensor < 1x2xi32 > <nl>
|
Add SendOp to HLO dialect .
|
tensorflow/tensorflow
|
7648e586b174143bb072bfe082652611467baf24
|
2019-12-27T20:01:57Z
|
mmm a / hphp / runtime / base / object - data . cpp <nl> ppp b / hphp / runtime / base / object - data . cpp <nl> const StaticString <nl> s_serialize ( " serialize " ) , <nl> s_clone ( " __clone " ) ; <nl> <nl> - static Array ArrayObject_toArray ( const ObjectData * obj ) { <nl> + static Array convert_to_array ( const ObjectData * obj , HPHP : : Class * cls ) { <nl> bool visible , accessible , unset ; <nl> auto prop = obj - > getProp ( <nl> - SystemLib : : s_ArrayObjectClass , s_storage . get ( ) , <nl> + cls , s_storage . get ( ) , <nl> visible , accessible , unset <nl> ) ; <nl> assert ( visible & & accessible & & ! unset ) ; <nl> Array ObjectData : : o_toArray ( bool pubOnly / * = false * / ) const { <nl> assert ( instanceof ( c_SimpleXMLElement : : classof ( ) ) ) ; <nl> return c_SimpleXMLElement : : ToArray ( this ) ; <nl> } else if ( UNLIKELY ( instanceof ( SystemLib : : s_ArrayObjectClass ) ) ) { <nl> - return ArrayObject_toArray ( this ) ; <nl> + return convert_to_array ( this , SystemLib : : s_ArrayObjectClass ) ; <nl> + } else if ( UNLIKELY ( instanceof ( SystemLib : : s_ArrayIteratorClass ) ) ) { <nl> + return convert_to_array ( this , SystemLib : : s_ArrayIteratorClass ) ; <nl> } else { <nl> Array ret ( ArrayData : : Create ( ) ) ; <nl> o_getArray ( ret , pubOnly ) ; <nl> inline Array getSerializeProps ( const ObjectData * obj , <nl> auto cls = obj - > getVMClass ( ) ; <nl> auto debuginfo = cls - > lookupMethod ( s_debugInfo . get ( ) ) ; <nl> if ( ! debuginfo ) { <nl> + / / When ArrayIterator is casted to an array , it return it ' s array object , <nl> + / / however when it ' s being var_dump ' d or print_r ' d , it shows it ' s properties <nl> + if ( UNLIKELY ( obj - > instanceof ( SystemLib : : s_ArrayIteratorClass ) ) ) { <nl> + Array ret ( ArrayData : : Create ( ) ) ; <nl> + obj - > o_getArray ( ret ) ; <nl> + return ret ; <nl> + } <nl> + <nl> return obj - > o_toArray ( ) ; <nl> } <nl> if ( debuginfo - > attrs ( ) & ( AttrPrivate | AttrProtected | <nl> mmm a / hphp / runtime / ext / ext_array . h <nl> ppp b / hphp / runtime / ext / ext_array . h <nl> Variant f_i18n_loc_get_error_code ( ) ; <nl> <nl> Variant f_hphp_array_idx ( const Variant & search , const Variant & key , const Variant & def ) ; <nl> <nl> - Array ArrayObject_toArray ( const ObjectData * obj ) ; <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> } <nl> <nl> mmm a / hphp / system / systemlib . h <nl> ppp b / hphp / system / systemlib . h <nl> namespace Eval { <nl> x ( Serializable ) \ <nl> x ( ArrayAccess ) \ <nl> x ( ArrayObject ) \ <nl> + x ( ArrayIterator ) \ <nl> x ( Iterator ) \ <nl> x ( IteratorAggregate ) \ <nl> x ( Traversable ) \ <nl> new file mode 100644 <nl> index 00000000000 . . 4c26911ba4b <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / array_iterator / cast_to_array . php <nl> <nl> + < ? php <nl> + $ ao = new ArrayObject ( array ( " a " = > 1 , " b " = > 2 , " c " = > 3 ) ) ; <nl> + var_dump ( $ ao - > getIterator ( ) ) ; <nl> + var_dump ( ( array ) $ ao - > getIterator ( ) ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 6a4d8330c4a <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / array_iterator / cast_to_array . php . expect <nl> <nl> + object ( ArrayIterator ) # 2 ( 2 ) { <nl> + [ " storage " : " ArrayIterator " : private ] = > <nl> + array ( 3 ) { <nl> + [ " a " ] = > <nl> + int ( 1 ) <nl> + [ " b " ] = > <nl> + int ( 2 ) <nl> + [ " c " ] = > <nl> + int ( 3 ) <nl> + } <nl> + [ " flags " : " ArrayIterator " : private ] = > <nl> + int ( 0 ) <nl> + } <nl> + array ( 3 ) { <nl> + [ " a " ] = > <nl> + int ( 1 ) <nl> + [ " b " ] = > <nl> + int ( 2 ) <nl> + [ " c " ] = > <nl> + int ( 3 ) <nl> + } <nl>
|
ArrayIterator casted to array should result to the storage array
|
facebook/hhvm
|
fd4f120699fafcdb70e50e5c7d5a482ef5b71b7c
|
2014-04-14T23:58:47Z
|
mmm a / dbms / src / Functions / array / arrayIntersect . cpp <nl> ppp b / dbms / src / Functions / array / arrayIntersect . cpp <nl> class FunctionArrayIntersect : public IFunction <nl> const ColumnArray : : ColumnOffsets : : Container * offsets = nullptr ; <nl> const IColumn * nested_column = nullptr ; <nl> <nl> - Columns column_holders ; <nl> } ; <nl> <nl> std : : vector < UnpackedArray > args ; <nl> + Columns column_holders ; <nl> <nl> UnpackedArrays ( ) = default ; <nl> } ; <nl>
|
Small refactoring .
|
ClickHouse/ClickHouse
|
2b5cb7d6b9854ed3b6447a579e2f302f7cc5e573
|
2019-11-15T14:19:54Z
|
mmm a / tensorflow / core / framework / numeric_types . h <nl> ppp b / tensorflow / core / framework / numeric_types . h <nl> limitations under the License . <nl> # include " third_party / eigen3 / unsupported / Eigen / CXX11 / FixedPoint " <nl> / / clang - format on <nl> <nl> + # include " tensorflow / core / platform / cpu_info . h " <nl> # include " tensorflow / core / platform / types . h " <nl> <nl> namespace tensorflow { <nl>
|
Fix a bug : bfloat16 is unsigned on Windows ( )
|
tensorflow/tensorflow
|
fdf34a88bec9645473f10ba2d52df4cfcb80d582
|
2017-12-18T06:05:28Z
|
mmm a / libraries / chain / apply_context . cpp <nl> ppp b / libraries / chain / apply_context . cpp <nl> void apply_context : : schedule_deferred_transaction ( const uint128_t & sender_id , a <nl> control . add_to_ram_correction ( ptr - > payer , orig_trx_ram_bytes ) ; <nl> } <nl> <nl> - db . modify < generated_transaction_object > ( * ptr , [ & ] ( auto & gtx ) { <nl> - if ( replace_deferred_activated ) { <nl> - gtx . trx_id = trx . id ( ) ; <nl> - } <nl> + transaction_id_type trx_id_for_new_obj ; <nl> + if ( replace_deferred_activated ) { <nl> + trx_id_for_new_obj = trx . id ( ) ; <nl> + } else { <nl> + trx_id_for_new_obj = ptr - > trx_id ; <nl> + } <nl> + <nl> + / / Use remove and create rather than modify because mutating the trx_id field in a modifier is unsafe . <nl> + db . remove ( * ptr ) ; <nl> + db . create < generated_transaction_object > ( [ & ] ( auto & gtx ) { <nl> + gtx . trx_id = trx_id_for_new_obj ; <nl> gtx . sender = receiver ; <nl> gtx . sender_id = sender_id ; <nl> gtx . payer = payer ; <nl> mmm a / libraries / chain / eosio_contract . cpp <nl> ppp b / libraries / chain / eosio_contract . cpp <nl> <nl> # include < eosio / chain / permission_link_object . hpp > <nl> # include < eosio / chain / global_property_object . hpp > <nl> # include < eosio / chain / contract_types . hpp > <nl> - # include < eosio / chain / producer_object . hpp > <nl> <nl> # include < eosio / chain / wasm_interface . hpp > <nl> # include < eosio / chain / abi_serializer . hpp > <nl> mmm a / libraries / chain / include / eosio / chain / account_object . hpp <nl> ppp b / libraries / chain / include / eosio / chain / account_object . hpp <nl> namespace eosio { namespace chain { <nl> OBJECT_CTOR ( account_object , ( abi ) ) <nl> <nl> id_type id ; <nl> - account_name name ; <nl> + account_name name ; / / < name should not be changed within a chainbase modifier lambda <nl> block_timestamp_type creation_date ; <nl> shared_blob abi ; <nl> <nl> namespace eosio { namespace chain { <nl> } ; <nl> <nl> id_type id ; <nl> - account_name name ; <nl> + account_name name ; / / < name should not be changed within a chainbase modifier lambda <nl> uint64_t recv_sequence = 0 ; <nl> uint64_t auth_sequence = 0 ; <nl> uint64_t code_sequence = 0 ; <nl> namespace eosio { namespace chain { <nl> OBJECT_CTOR ( account_ram_correction_object ) ; <nl> <nl> id_type id ; <nl> - account_name name ; <nl> + account_name name ; / / < name should not be changed within a chainbase modifier lambda <nl> uint64_t ram_correction = 0 ; <nl> } ; <nl> <nl> mmm a / libraries / chain / include / eosio / chain / code_object . hpp <nl> ppp b / libraries / chain / include / eosio / chain / code_object . hpp <nl> namespace eosio { namespace chain { <nl> OBJECT_CTOR ( code_object , ( code ) ) <nl> <nl> id_type id ; <nl> - digest_type code_hash ; <nl> + digest_type code_hash ; / / < code_hash should not be changed within a chainbase modifier lambda <nl> shared_blob code ; <nl> uint64_t code_ref_count ; <nl> uint32_t first_block_used ; <nl> - uint8_t vm_type = 0 ; <nl> - uint8_t vm_version = 0 ; <nl> + uint8_t vm_type = 0 ; / / < vm_type should not be changed within a chainbase modifier lambda <nl> + uint8_t vm_version = 0 ; / / < vm_version should not be changed within a chainbase modifier lambda <nl> } ; <nl> <nl> struct by_code_hash ; <nl> mmm a / libraries / chain / include / eosio / chain / contract_table_objects . hpp <nl> ppp b / libraries / chain / include / eosio / chain / contract_table_objects . hpp <nl> namespace eosio { namespace chain { <nl> OBJECT_CTOR ( table_id_object ) <nl> <nl> id_type id ; <nl> - account_name code ; <nl> - scope_name scope ; <nl> - table_name table ; <nl> + account_name code ; / / < code should not be changed within a chainbase modifier lambda <nl> + scope_name scope ; / / < scope should not be changed within a chainbase modifier lambda <nl> + table_name table ; / / < table should not be changed within a chainbase modifier lambda <nl> account_name payer ; <nl> uint32_t count = 0 ; / / / the number of elements in the table <nl> } ; <nl> namespace eosio { namespace chain { <nl> static const int number_of_keys = 1 ; <nl> <nl> id_type id ; <nl> - table_id t_id ; <nl> - uint64_t primary_key ; <nl> + table_id t_id ; / / < t_id should not be changed within a chainbase modifier lambda <nl> + uint64_t primary_key ; / / < primary_key should not be changed within a chainbase modifier lambda <nl> account_name payer = 0 ; <nl> shared_blob value ; <nl> } ; <nl> namespace eosio { namespace chain { <nl> typedef SecondaryKey secondary_key_type ; <nl> <nl> typename chainbase : : object < ObjectTypeId , index_object > : : id_type id ; <nl> - table_id t_id ; <nl> - uint64_t primary_key ; <nl> + table_id t_id ; / / < t_id should not be changed within a chainbase modifier lambda <nl> + uint64_t primary_key ; / / < primary_key should not be changed within a chainbase modifier lambda <nl> account_name payer = 0 ; <nl> - SecondaryKey secondary_key ; <nl> + SecondaryKey secondary_key ; / / < secondary_key should not be changed within a chainbase modifier lambda <nl> } ; <nl> <nl> <nl> mmm a / libraries / chain / include / eosio / chain / generated_transaction_object . hpp <nl> ppp b / libraries / chain / include / eosio / chain / generated_transaction_object . hpp <nl> namespace eosio { namespace chain { <nl> OBJECT_CTOR ( generated_transaction_object , ( packed_trx ) ) <nl> <nl> id_type id ; <nl> - transaction_id_type trx_id ; <nl> - account_name sender ; <nl> - uint128_t sender_id = 0 ; / / / ID given this transaction by the sender <nl> + transaction_id_type trx_id ; / / < trx_id should not be changed within a chainbase modifier lambda <nl> + account_name sender ; / / < sender should not be changed within a chainbase modifier lambda <nl> + uint128_t sender_id = 0 ; / / / ID given this transaction by the sender ( should not be changed within a chainbase modifier lambda ) <nl> account_name payer ; <nl> time_point delay_until ; / / / this generated transaction will not be applied until the specified time <nl> time_point expiration ; / / / this generated transaction will not be applied after this time <nl> mmm a / libraries / chain / include / eosio / chain / permission_link_object . hpp <nl> ppp b / libraries / chain / include / eosio / chain / permission_link_object . hpp <nl> namespace eosio { namespace chain { <nl> / / / May be empty ; if so , it sets a default @ ref required_permission for all messages to @ ref code <nl> action_name message_type ; <nl> / / / The permission level which @ ref account requires for the specified message types <nl> + / / / all of the above fields should not be changed within a chainbase modifier lambda <nl> permission_name required_permission ; <nl> } ; <nl> <nl> namespace eosio { namespace chain { <nl> composite_key < permission_link_object , <nl> BOOST_MULTI_INDEX_MEMBER ( permission_link_object , account_name , account ) , <nl> BOOST_MULTI_INDEX_MEMBER ( permission_link_object , permission_name , required_permission ) , <nl> - BOOST_MULTI_INDEX_MEMBER ( permission_link_object , account_name , code ) , <nl> - BOOST_MULTI_INDEX_MEMBER ( permission_link_object , action_name , message_type ) <nl> + BOOST_MULTI_INDEX_MEMBER ( permission_link_object , permission_link_object : : id_type , id ) <nl> > <nl> > <nl> > <nl> mmm a / libraries / chain / include / eosio / chain / permission_object . hpp <nl> ppp b / libraries / chain / include / eosio / chain / permission_object . hpp <nl> namespace eosio { namespace chain { <nl> id_type id ; <nl> permission_usage_object : : id_type usage_id ; <nl> id_type parent ; / / / < parent permission <nl> - account_name owner ; / / / < the account this permission belongs to <nl> - permission_name name ; / / / < human - readable name for the permission <nl> + account_name owner ; / / / < the account this permission belongs to ( should not be changed within a chainbase modifier lambda ) <nl> + permission_name name ; / / / < human - readable name for the permission ( should not be changed within a chainbase modifier lambda ) <nl> time_point last_updated ; / / / < the last time this authority was updated <nl> shared_authority auth ; / / / < authority required to execute this permission <nl> <nl> deleted file mode 100644 <nl> index 61d2387028 . . 0000000000 <nl> mmm a / libraries / chain / include / eosio / chain / producer_object . hpp <nl> ppp / dev / null <nl> <nl> - / * * <nl> - * @ file <nl> - * @ copyright defined in eos / LICENSE <nl> - * / <nl> - # pragma once <nl> - # include < eosio / chain / types . hpp > <nl> - # include < eosio / chain / chain_config . hpp > <nl> - <nl> - # include " multi_index_includes . hpp " <nl> - <nl> - namespace eosio { namespace chain { <nl> - class producer_object : public chainbase : : object < producer_object_type , producer_object > { <nl> - OBJECT_CTOR ( producer_object ) <nl> - <nl> - id_type id ; <nl> - account_name owner ; <nl> - uint64_t last_aslot = 0 ; <nl> - public_key_type signing_key ; <nl> - int64_t total_missed = 0 ; <nl> - uint32_t last_confirmed_block_num = 0 ; <nl> - <nl> - <nl> - / / / The blockchain configuration values this producer recommends <nl> - chain_config configuration ; <nl> - } ; <nl> - <nl> - struct by_key ; <nl> - struct by_owner ; <nl> - using producer_multi_index = chainbase : : shared_multi_index_container < <nl> - producer_object , <nl> - indexed_by < <nl> - ordered_unique < tag < by_id > , member < producer_object , producer_object : : id_type , & producer_object : : id > > , <nl> - ordered_unique < tag < by_owner > , member < producer_object , account_name , & producer_object : : owner > > , <nl> - ordered_unique < tag < by_key > , <nl> - composite_key < producer_object , <nl> - member < producer_object , public_key_type , & producer_object : : signing_key > , <nl> - member < producer_object , producer_object : : id_type , & producer_object : : id > <nl> - > <nl> - > <nl> - > <nl> - > ; <nl> - <nl> - } } / / eosio : : chain <nl> - <nl> - CHAINBASE_SET_INDEX_TYPE ( eosio : : chain : : producer_object , eosio : : chain : : producer_multi_index ) <nl> - <nl> - FC_REFLECT ( eosio : : chain : : producer_object : : id_type , ( _id ) ) <nl> - FC_REFLECT ( eosio : : chain : : producer_object , ( id ) ( owner ) ( last_aslot ) ( signing_key ) ( total_missed ) ( last_confirmed_block_num ) <nl> - ( configuration ) ) <nl> mmm a / libraries / chain / include / eosio / chain / resource_limits_private . hpp <nl> ppp b / libraries / chain / include / eosio / chain / resource_limits_private . hpp <nl> namespace eosio { namespace chain { namespace resource_limits { <nl> OBJECT_CTOR ( resource_limits_object ) <nl> <nl> id_type id ; <nl> - account_name owner ; <nl> - bool pending = false ; <nl> + account_name owner ; / / < owner should not be changed within a chainbase modifier lambda <nl> + bool pending = false ; / / < pending should not be changed within a chainbase modifier lambda <nl> <nl> int64_t net_weight = - 1 ; <nl> int64_t cpu_weight = - 1 ; <nl> namespace eosio { namespace chain { namespace resource_limits { <nl> OBJECT_CTOR ( resource_usage_object ) <nl> <nl> id_type id ; <nl> - account_name owner ; <nl> + account_name owner ; / / < owner should not be changed within a chainbase modifier lambda <nl> <nl> usage_accumulator net_usage ; <nl> usage_accumulator cpu_usage ; <nl> mmm a / libraries / chain / include / eosio / chain / reversible_block_object . hpp <nl> ppp b / libraries / chain / include / eosio / chain / reversible_block_object . hpp <nl> namespace eosio { namespace chain { <nl> OBJECT_CTOR ( reversible_block_object , ( packedblock ) ) <nl> <nl> id_type id ; <nl> - uint32_t blocknum = 0 ; <nl> + uint32_t blocknum = 0 ; / / < blocknum should not be changed within a chainbase modifier lambda <nl> shared_string packedblock ; <nl> <nl> void set_block ( const signed_block_ptr & b ) { <nl> mmm a / libraries / chain / include / eosio / chain / transaction_object . hpp <nl> ppp b / libraries / chain / include / eosio / chain / transaction_object . hpp <nl> namespace eosio { namespace chain { <nl> <nl> id_type id ; <nl> time_point_sec expiration ; <nl> - transaction_id_type trx_id ; <nl> + transaction_id_type trx_id ; / / < trx_id should not be changed within a chainbase modifier lambda <nl> } ; <nl> <nl> struct by_expiration ; <nl> mmm a / libraries / chain / include / eosio / chain / types . hpp <nl> ppp b / libraries / chain / include / eosio / chain / types . hpp <nl> namespace eosio { namespace chain { <nl> block_summary_object_type , <nl> transaction_object_type , <nl> generated_transaction_object_type , <nl> - producer_object_type , <nl> + UNUSED_producer_object_type , <nl> UNUSED_chain_property_object_type , <nl> account_control_history_object_type , / / / < Defined by history_plugin <nl> UNUSED_account_transaction_history_object_type , <nl> namespace eosio { namespace chain { <nl> OBJECT_TYPE_COUNT / / / < Sentry value which contains the number of different object types <nl> } ; <nl> <nl> + / * * <nl> + * Important notes on using chainbase objects in EOSIO code : <nl> + * <nl> + * There are several constraints that need to be followed when using chainbase objects . <nl> + * Some of these constraints are due to the requirements imposed by the chainbase library , <nl> + * others are due to requirements to ensure determinism in the EOSIO chain library . <nl> + * <nl> + * Before listing the constraints , the " restricted field set " must be defined . <nl> + * <nl> + * Every chainbase object includes a field called id which has the type id_type . <nl> + * The id field is always included in the restricted field set . <nl> + * <nl> + * A field of a chainbase object is considered to be in the restricted field set if it is involved in the <nl> + * derivation of the key used for one of the indices in the chainbase multi - index unless its only involvement <nl> + * is through being included in composite_keys that end with the id field . <nl> + * <nl> + * So if the multi - index includes an index like the following <nl> + * ` ` ` <nl> + * ordered_unique < tag < by_sender_id > , <nl> + * composite_key < generated_transaction_object , <nl> + * BOOST_MULTI_INDEX_MEMBER ( generated_transaction_object , account_name , sender ) , <nl> + * BOOST_MULTI_INDEX_MEMBER ( generated_transaction_object , uint128_t , sender_id ) <nl> + * > <nl> + * > <nl> + * ` ` ` <nl> + * both ` sender ` and ` sender_id ` fields are part of the restricted field set . <nl> + * <nl> + * On the other hand , an index like the following <nl> + * ` ` ` <nl> + * ordered_unique < tag < by_expiration > , <nl> + * composite_key < generated_transaction_object , <nl> + * BOOST_MULTI_INDEX_MEMBER ( generated_transaction_object , time_point , expiration ) , <nl> + * BOOST_MULTI_INDEX_MEMBER ( generated_transaction_object , generated_transaction_object : : id_type , id ) <nl> + * > <nl> + * > <nl> + * ` ` ` <nl> + * would not by itself require the ` expiration ` field to be part of the restricted field set . <nl> + * <nl> + * The restrictions on usage of the chainbase objects within this code base are : <nl> + * + The chainbase object includes the id field discussed above . <nl> + * + The multi - index must include an ordered_unique index tagged with by_id that is based on the id field as the sole key . <nl> + * + No other types of indices other than ordered_unique are allowed . <nl> + * If an index is desired that does not enforce uniqueness , then use a composite key that ends with the id field . <nl> + * + When creating a chainbase object , the constructor lambda should never mutate the id field . <nl> + * + When modifying a chainbase object , the modifier lambda should never mutate any fields in the restricted field set . <nl> + * / <nl> + <nl> class account_object ; <nl> - class producer_object ; <nl> <nl> using block_id_type = fc : : sha256 ; <nl> using checksum_type = fc : : sha256 ; <nl> mmm a / libraries / chainbase <nl> ppp b / libraries / chainbase <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 118c513436e1310d8e1395303c964430f26b0bb4 <nl> + Subproject commit 57b97a0a794f23f3eb7bae32388755e27528c930 <nl> mmm a / plugins / chain_plugin / chain_plugin . cpp <nl> ppp b / plugins / chain_plugin / chain_plugin . cpp <nl> <nl> # include < eosio / chain / block_log . hpp > <nl> # include < eosio / chain / exceptions . hpp > <nl> # include < eosio / chain / authorization_manager . hpp > <nl> - # include < eosio / chain / producer_object . hpp > <nl> # include < eosio / chain / code_object . hpp > <nl> # include < eosio / chain / config . hpp > <nl> # include < eosio / chain / wasm_interface . hpp > <nl> mmm a / plugins / producer_plugin / producer_plugin . cpp <nl> ppp b / plugins / producer_plugin / producer_plugin . cpp <nl> <nl> * @ copyright defined in eos / LICENSE <nl> * / <nl> # include < eosio / producer_plugin / producer_plugin . hpp > <nl> - # include < eosio / chain / producer_object . hpp > <nl> # include < eosio / chain / plugin_interface . hpp > <nl> # include < eosio / chain / global_property_object . hpp > <nl> # include < eosio / chain / generated_transaction_object . hpp > <nl> mmm a / unittests / auth_tests . cpp <nl> ppp b / unittests / auth_tests . cpp <nl> <nl> # include < eosio / chain / resource_limits_private . hpp > <nl> <nl> # include < eosio / testing / tester_network . hpp > <nl> - # include < eosio / chain / producer_object . hpp > <nl> <nl> # ifdef NON_VALIDATING_TEST <nl> # define TESTER tester <nl> mmm a / unittests / delay_tests . cpp <nl> ppp b / unittests / delay_tests . cpp <nl> <nl> * / <nl> # include < eosio / chain / generated_transaction_object . hpp > <nl> # include < eosio / chain / global_property_object . hpp > <nl> - # include < eosio / chain / producer_object . hpp > <nl> # include < eosio / testing / tester_network . hpp > <nl> <nl> # include < boost / test / unit_test . hpp > <nl> BOOST_AUTO_TEST_CASE ( delete_auth_test ) { try { <nl> expect_assert_message ( e , " permission_query_exception : Permission Query Exception \ nFailed to retrieve permission " ) ; <nl> return true ; <nl> } ) ; <nl> - <nl> + <nl> / / update auth <nl> chain . push_action ( config : : system_account_name , updateauth : : get_name ( ) , tester_account , fc : : mutable_variant_object ( ) <nl> ( " account " , " tester " ) <nl>
|
change how replace existing deferred transaction is implemented to not violate the new ( and now explicitly stated ) requirements imposed on chainbase objects that should be respected in this code base ; following those new requirements will automatically satisfy the critical preconditions on the chainbase modify function
|
EOSIO/eos
|
e2bca95567365fc5b25957831b628ed111cc5ecf
|
2019-05-04T01:22:53Z
|
new file mode 100644 <nl> index 000000000 . . 488b55461 <nl> mmm / dev / null <nl> ppp b / appendix / manipulator_timer / Makefile <nl> <nl> + all : main . o <nl> + c + + - framework CoreFoundation - framework SystemConfiguration main . o <nl> + <nl> + run : all <nl> + . / a . out <nl> + <nl> + include . . / Makefile . rules <nl> + CXXFLAGS + = - I . . / . . / src / core / grabber / include <nl> new file mode 100644 <nl> index 000000000 . . 766afbac3 <nl> mmm / dev / null <nl> ppp b / appendix / manipulator_timer / main . cpp <nl> <nl> + # include " logger . hpp " <nl> + # include " manipulator / manipulator_timer . hpp " <nl> + # include " thread_utility . hpp " <nl> + # include < CoreFoundation / CoreFoundation . h > <nl> + <nl> + int main ( int argc , const char * argv [ ] ) { <nl> + krbn : : thread_utility : : register_main_thread ( ) ; <nl> + <nl> + krbn : : manipulator : : manipulator_timer : : get_instance ( ) . enable ( ) ; <nl> + <nl> + krbn : : manipulator : : manipulator_timer : : get_instance ( ) . timer_invoked . connect ( [ & ] ( auto timer_id ) { <nl> + krbn : : logger : : get_logger ( ) . info ( " timer_id { 0 } " , static_cast < uint64_t > ( timer_id ) ) ; <nl> + if ( timer_id = = krbn : : manipulator : : manipulator_timer : : timer_id ( 10 ) ) { <nl> + exit ( 0 ) ; <nl> + } <nl> + } ) ; <nl> + <nl> + for ( int i = 0 ; i < 10 ; + + i ) { <nl> + krbn : : manipulator : : manipulator_timer : : get_instance ( ) . add_entry ( dispatch_time ( DISPATCH_TIME_NOW , i * 300 * NSEC_PER_MSEC ) ) ; <nl> + } <nl> + <nl> + CFRunLoopRun ( ) ; <nl> + return 0 ; <nl> + } <nl> mmm a / src / core / grabber / include / manipulator / details / base . hpp <nl> ppp b / src / core / grabber / include / manipulator / details / base . hpp <nl> <nl> <nl> # include " event_queue . hpp " <nl> # include " manipulator / condition_manager . hpp " <nl> + # include " manipulator / manipulator_timer . hpp " <nl> # include " modifier_flag_manager . hpp " <nl> <nl> namespace krbn { <nl> class base { <nl> virtual void force_post_pointing_button_event ( const event_queue : : queued_event & front_input_event , <nl> event_queue & output_event_queue ) = 0 ; <nl> <nl> + virtual void manipulator_timer_invoked ( manipulator_timer : : timer_id timer_id ) = 0 ; <nl> + <nl> bool get_valid ( void ) const { <nl> return valid_ ; <nl> } <nl> mmm a / src / core / grabber / include / manipulator / details / basic . hpp <nl> ppp b / src / core / grabber / include / manipulator / details / basic . hpp <nl> <nl> # pragma once <nl> <nl> - # include " gcd_utility . hpp " <nl> # include " krbn_notification_center . hpp " <nl> # include " manipulator / details / base . hpp " <nl> # include " manipulator / details / types . hpp " <nl> class basic final : public base { <nl> class to_delayed_action final { <nl> public : <nl> to_delayed_action ( basic & basic , <nl> - const nlohmann : : json & json ) : basic_ ( basic ) { <nl> + const nlohmann : : json & json ) : basic_ ( basic ) , <nl> + output_event_queue_ ( nullptr ) { <nl> if ( json . is_object ( ) ) { <nl> for ( auto it = std : : begin ( json ) ; it ! = std : : end ( json ) ; std : : advance ( it , 1 ) ) { <nl> / / it . key ( ) is always std : : string . <nl> class basic final : public base { <nl> <nl> front_input_event_ = front_input_event ; <nl> from_mandatory_modifiers_ = from_mandatory_modifiers ; <nl> + output_event_queue_ = & output_event_queue ; <nl> <nl> - timer_ = std : : make_unique < gcd_utility : : main_queue_timer > ( <nl> - dispatch_time ( DISPATCH_TIME_NOW , 300 * NSEC_PER_MSEC ) , <nl> - 1 * NSEC_PER_SEC , <nl> - 0 , <nl> - ^ { <nl> - post_events ( to_invoked_ , output_event_queue ) ; <nl> - <nl> - timer_ = nullptr ; <nl> - } ) ; <nl> + manipulator_timer_id_ = manipulator_timer : : get_instance ( ) . add_entry ( dispatch_time ( DISPATCH_TIME_NOW , 300 * NSEC_PER_MSEC ) ) ; <nl> } <nl> <nl> - void cancel ( const event_queue : : queued_event & front_input_event , <nl> - event_queue & output_event_queue ) { <nl> + void cancel ( const event_queue : : queued_event & front_input_event ) { <nl> if ( front_input_event . get_event_type ( ) ! = event_type : : key_down ) { <nl> return ; <nl> } <nl> <nl> - if ( ! timer_ ) { <nl> + if ( ! manipulator_timer_id_ ) { <nl> return ; <nl> } <nl> <nl> - timer_ = nullptr ; <nl> + manipulator_timer_id_ = boost : : none ; <nl> <nl> - post_events ( to_canceled_ , output_event_queue ) ; <nl> + post_events ( to_canceled_ ) ; <nl> + } <nl> + <nl> + void manipulator_timer_invoked ( manipulator_timer : : timer_id timer_id ) { <nl> + if ( timer_id = = manipulator_timer_id_ ) { <nl> + manipulator_timer_id_ = boost : : none ; <nl> + post_events ( to_invoked_ ) ; <nl> + krbn_notification_center : : get_instance ( ) . input_event_arrived ( ) ; <nl> + } <nl> } <nl> <nl> private : <nl> - void post_events ( const std : : vector < to_event_definition > & events , <nl> - event_queue & output_event_queue ) const { <nl> - if ( front_input_event_ ) { <nl> + void post_events ( const std : : vector < to_event_definition > & events ) const { <nl> + if ( front_input_event_ & & <nl> + output_event_queue_ ) { <nl> uint64_t time_stamp_delay = 0 ; <nl> <nl> / / Release from_mandatory_modifiers <nl> class basic final : public base { <nl> from_mandatory_modifiers_ , <nl> event_type : : key_up , <nl> time_stamp_delay , <nl> - output_event_queue ) ; <nl> + * output_event_queue_ ) ; <nl> <nl> / / Post events <nl> <nl> - for ( const auto & e : events ) { <nl> - if ( auto event = e . to_event ( ) ) { <nl> - output_event_queue . emplace_back_event ( front_input_event_ - > get_device_id ( ) , <nl> - front_input_event_ - > get_time_stamp ( ) + time_stamp_delay + + , <nl> - * event , <nl> - event_type : : key_down , <nl> - front_input_event_ - > get_original_event ( ) ) ; <nl> - <nl> - output_event_queue . emplace_back_event ( front_input_event_ - > get_device_id ( ) , <nl> - front_input_event_ - > get_time_stamp ( ) + time_stamp_delay + + , <nl> - * event , <nl> - event_type : : key_up , <nl> - front_input_event_ - > get_original_event ( ) ) ; <nl> - } <nl> - } <nl> + basic_ . post_extra_to_events ( * front_input_event_ , <nl> + events , <nl> + time_stamp_delay , <nl> + * output_event_queue_ ) ; <nl> <nl> / / Restore from_mandatory_modifiers <nl> <nl> class basic final : public base { <nl> from_mandatory_modifiers_ , <nl> event_type : : key_down , <nl> time_stamp_delay , <nl> - output_event_queue ) ; <nl> - <nl> - krbn_notification_center : : get_instance ( ) . input_event_arrived ( ) ; <nl> + * output_event_queue_ ) ; <nl> } <nl> } <nl> <nl> basic & basic_ ; <nl> std : : vector < to_event_definition > to_invoked_ ; <nl> std : : vector < to_event_definition > to_canceled_ ; <nl> - std : : unique_ptr < gcd_utility : : main_queue_timer > timer_ ; <nl> + boost : : optional < manipulator_timer : : timer_id > manipulator_timer_id_ ; <nl> boost : : optional < event_queue : : queued_event > front_input_event_ ; <nl> std : : unordered_set < modifier_flag > from_mandatory_modifiers_ ; <nl> + event_queue * output_event_queue_ ; <nl> } ; <nl> <nl> basic ( const nlohmann : : json & json , <nl> class basic final : public base { <nl> front_input_event . get_event_type ( ) ) ; <nl> <nl> if ( to_delayed_action_ ) { <nl> - to_delayed_action_ - > cancel ( front_input_event , output_event_queue ) ; <nl> + to_delayed_action_ - > cancel ( front_input_event ) ; <nl> } <nl> <nl> bool is_target = false ; <nl> class basic final : public base { <nl> event_queue & output_event_queue ) { <nl> } <nl> <nl> + virtual void manipulator_timer_invoked ( manipulator_timer : : timer_id timer_id ) { <nl> + if ( to_delayed_action_ ) { <nl> + to_delayed_action_ - > manipulator_timer_invoked ( timer_id ) ; <nl> + } <nl> + } <nl> + <nl> const from_event_definition & get_from ( void ) const { <nl> return from_ ; <nl> } <nl> mmm a / src / core / grabber / include / manipulator / details / nop . hpp <nl> ppp b / src / core / grabber / include / manipulator / details / nop . hpp <nl> class nop final : public base { <nl> virtual void force_post_pointing_button_event ( const event_queue : : queued_event & front_input_event , <nl> event_queue & output_event_queue ) { <nl> } <nl> + <nl> + virtual void manipulator_timer_invoked ( manipulator_timer : : timer_id timer_id ) { <nl> + } <nl> } ; <nl> } / / namespace details <nl> } / / namespace manipulator <nl> mmm a / src / core / grabber / include / manipulator / details / post_event_to_virtual_devices . hpp <nl> ppp b / src / core / grabber / include / manipulator / details / post_event_to_virtual_devices . hpp <nl> class post_event_to_virtual_devices final : public base { <nl> pressed_buttons_ = output_event_queue . get_pointing_button_manager ( ) . get_hid_report_bits ( ) ; <nl> } <nl> <nl> + virtual void manipulator_timer_invoked ( manipulator_timer : : timer_id timer_id ) { <nl> + } <nl> + <nl> virtual void set_valid ( bool value ) { <nl> / / This manipulator is always valid . <nl> } <nl> mmm a / src / core / grabber / include / manipulator / manipulator_manager . hpp <nl> ppp b / src / core / grabber / include / manipulator / manipulator_manager . hpp <nl> class manipulator_manager final { <nl> manipulator_manager ( const manipulator_manager & ) = delete ; <nl> <nl> manipulator_manager ( void ) { <nl> + manipulator_timer_connection_ = manipulator_timer : : get_instance ( ) . timer_invoked . connect ( [ & ] ( auto timer_id ) { <nl> + for ( auto & & m : manipulators_ ) { <nl> + m - > manipulator_timer_invoked ( timer_id ) ; <nl> + } <nl> + } ) ; <nl> + } <nl> + <nl> + ~ manipulator_manager ( void ) { <nl> + manipulator_timer_connection_ . disconnect ( ) ; <nl> } <nl> <nl> void push_back_manipulator ( const nlohmann : : json & json , <nl> class manipulator_manager final { <nl> } <nl> <nl> std : : vector < std : : shared_ptr < details : : base > > manipulators_ ; <nl> + boost : : signals2 : : connection manipulator_timer_connection_ ; <nl> } ; <nl> } / / namespace manipulator <nl> } / / namespace krbn <nl> new file mode 100644 <nl> index 000000000 . . 39e69ec69 <nl> mmm / dev / null <nl> ppp b / src / core / grabber / include / manipulator / manipulator_timer . hpp <nl> <nl> + # pragma once <nl> + <nl> + # include " boost_defs . hpp " <nl> + <nl> + # include " gcd_utility . hpp " <nl> + # include < boost / signals2 . hpp > <nl> + # include < deque > <nl> + # include < mach / mach_time . h > <nl> + <nl> + namespace krbn { <nl> + namespace manipulator { <nl> + class manipulator_timer final { <nl> + public : <nl> + enum class timer_id : uint64_t { <nl> + zero = 0 , <nl> + } ; <nl> + <nl> + class entry final { <nl> + public : <nl> + entry ( uint64_t when ) : when_ ( when ) { <nl> + static std : : mutex mutex ; <nl> + std : : lock_guard < std : : mutex > guard ( mutex ) ; <nl> + <nl> + static timer_id id ; <nl> + id = timer_id ( static_cast < uint64_t > ( id ) + 1 ) ; <nl> + timer_id_ = id ; <nl> + } <nl> + <nl> + timer_id get_timer_id ( void ) const { <nl> + return timer_id_ ; <nl> + } <nl> + <nl> + uint64_t get_when ( void ) const { <nl> + return when_ ; <nl> + } <nl> + <nl> + bool compare ( const entry & other ) { <nl> + if ( when_ ! = other . when_ ) { <nl> + return when_ < other . when_ ; <nl> + } else { <nl> + return timer_id_ < other . timer_id_ ; <nl> + } <nl> + } <nl> + <nl> + private : <nl> + timer_id timer_id_ ; <nl> + uint64_t when_ ; <nl> + } ; <nl> + <nl> + class core final { <nl> + public : <nl> + boost : : signals2 : : signal < void ( timer_id ) > timer_invoked ; <nl> + <nl> + core ( void ) : enabled_ ( false ) { <nl> + } <nl> + <nl> + / / For unit testing <nl> + const std : : deque < entry > & get_entries ( void ) const { <nl> + return entries_ ; <nl> + } <nl> + <nl> + void enable ( void ) { <nl> + std : : lock_guard < std : : mutex > guard ( mutex_ ) ; <nl> + <nl> + enabled_ = true ; <nl> + } <nl> + <nl> + void disable ( void ) { <nl> + std : : lock_guard < std : : mutex > guard ( mutex_ ) ; <nl> + <nl> + enabled_ = false ; <nl> + } <nl> + <nl> + timer_id add_entry ( uint64_t when ) { <nl> + std : : lock_guard < std : : mutex > guard ( mutex_ ) ; <nl> + <nl> + entries_ . emplace_back ( when ) ; <nl> + auto result = entries_ . back ( ) . get_timer_id ( ) ; <nl> + <nl> + std : : sort ( std : : begin ( entries_ ) , <nl> + std : : end ( entries_ ) , <nl> + [ ] ( auto & a , auto & b ) { <nl> + return a . compare ( b ) ; <nl> + } ) ; <nl> + <nl> + set_timer ( ) ; <nl> + <nl> + return result ; <nl> + } <nl> + <nl> + void signal ( uint64_t now ) { <nl> + for ( ; ; ) { <nl> + boost : : optional < timer_id > id ; <nl> + <nl> + { <nl> + std : : lock_guard < std : : mutex > guard ( mutex_ ) ; <nl> + <nl> + if ( ! entries_ . empty ( ) & & entries_ . front ( ) . get_when ( ) < = now ) { <nl> + id = entries_ . front ( ) . get_timer_id ( ) ; <nl> + entries_ . pop_front ( ) ; <nl> + } <nl> + } <nl> + <nl> + if ( id ) { <nl> + timer_invoked ( * id ) ; <nl> + } else { <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + set_timer ( ) ; <nl> + } <nl> + <nl> + private : <nl> + void set_timer ( void ) { <nl> + if ( ! enabled_ ) { <nl> + timer_ = nullptr ; <nl> + return ; <nl> + } <nl> + <nl> + if ( entries_ . empty ( ) ) { <nl> + timer_ = nullptr ; <nl> + return ; <nl> + } <nl> + <nl> + timer_ = std : : make_unique < gcd_utility : : main_queue_after_timer > ( entries_ . front ( ) . get_when ( ) , ^ { <nl> + uint64_t now = mach_absolute_time ( ) ; <nl> + signal ( now ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + std : : mutex mutex_ ; <nl> + bool enabled_ ; <nl> + std : : deque < entry > entries_ ; <nl> + std : : unique_ptr < gcd_utility : : main_queue_after_timer > timer_ ; <nl> + } ; <nl> + <nl> + static core & get_instance ( void ) { <nl> + static std : : mutex mutex ; <nl> + std : : lock_guard < std : : mutex > guard ( mutex ) ; <nl> + <nl> + static std : : unique_ptr < core > core_ ; <nl> + if ( ! core_ ) { <nl> + core_ = std : : make_unique < core > ( ) ; <nl> + } <nl> + <nl> + return * core_ ; <nl> + } <nl> + } ; <nl> + } / / namespace manipulator <nl> + } / / namespace krbn <nl> mmm a / src / core / grabber / main . cpp <nl> ppp b / src / core / grabber / main . cpp <nl> int main ( int argc , const char * argv [ ] ) { <nl> chmod ( krbn : : constants : : get_console_user_server_socket_directory ( ) , 0755 ) ; <nl> } <nl> <nl> + krbn : : manipulator : : manipulator_timer : : get_instance ( ) . enable ( ) ; <nl> auto device_grabber_ptr = std : : make_unique < krbn : : device_grabber > ( ) ; <nl> krbn : : connection_manager connection_manager ( * version_monitor_ptr , * device_grabber_ptr ) ; <nl> <nl> mmm a / tests / src / manipulator / test . cpp <nl> ppp b / tests / src / manipulator / test . cpp <nl> <nl> # include " manipulator / manipulator_factory . hpp " <nl> # include " manipulator / manipulator_manager . hpp " <nl> # include " manipulator / manipulator_managers_connector . hpp " <nl> + # include " manipulator / manipulator_timer . hpp " <nl> # include " thread_utility . hpp " <nl> # include < boost / optional / optional_io . hpp > <nl> <nl> TEST_CASE ( " manipulator . manipulator_manager " ) { <nl> } <nl> } <nl> <nl> + TEST_CASE ( " manipulator_timer " ) { <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) . empty ( ) ) ; <nl> + <nl> + std : : vector < krbn : : manipulator : : manipulator_timer : : timer_id > timer_ids ; <nl> + timer_ids . push_back ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . add_entry ( 1234 ) ) ; <nl> + timer_ids . push_back ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . add_entry ( 1234 ) ) ; <nl> + timer_ids . push_back ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . add_entry ( 5678 ) ) ; <nl> + timer_ids . push_back ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . add_entry ( 5678 ) ) ; <nl> + timer_ids . push_back ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . add_entry ( 2345 ) ) ; <nl> + timer_ids . push_back ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . add_entry ( 2345 ) ) ; <nl> + <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) . size ( ) = = 6 ) ; <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) [ 0 ] . get_when ( ) = = 1234 ) ; <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) [ 1 ] . get_when ( ) = = 1234 ) ; <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) [ 2 ] . get_when ( ) = = 2345 ) ; <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) [ 3 ] . get_when ( ) = = 2345 ) ; <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) [ 4 ] . get_when ( ) = = 5678 ) ; <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) [ 5 ] . get_when ( ) = = 5678 ) ; <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) [ 0 ] . get_timer_id ( ) = = timer_ids [ 0 ] ) ; <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) [ 1 ] . get_timer_id ( ) = = timer_ids [ 1 ] ) ; <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) [ 2 ] . get_timer_id ( ) = = timer_ids [ 4 ] ) ; <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) [ 3 ] . get_timer_id ( ) = = timer_ids [ 5 ] ) ; <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) [ 4 ] . get_timer_id ( ) = = timer_ids [ 2 ] ) ; <nl> + REQUIRE ( krbn : : manipulator : : manipulator_timer : : get_instance ( ) . get_entries ( ) [ 5 ] . get_timer_id ( ) = = timer_ids [ 3 ] ) ; <nl> + } <nl> + <nl> TEST_CASE ( " needs_virtual_hid_pointing " ) { <nl> for ( const auto & file_name : { <nl> std : : string ( " json / needs_virtual_hid_pointing_test1 . json " ) , <nl> mmm a / tests / src / post_event_to_virtual_devices / test . cpp <nl> ppp b / tests / src / post_event_to_virtual_devices / test . cpp <nl> <nl> # include " manipulator / manipulator_factory . hpp " <nl> # include " manipulator / manipulator_manager . hpp " <nl> # include " manipulator / manipulator_managers_connector . hpp " <nl> + # include " manipulator / manipulator_timer . hpp " <nl> # include " thread_utility . hpp " <nl> # include < boost / optional / optional_io . hpp > <nl> <nl>
|
add manipulator_timer
|
pqrs-org/Karabiner-Elements
|
79c4a6083f82ed4d7ccfa97aab0ee63de84f76e2
|
2017-10-27T12:03:04Z
|
mmm a / docs / tutorial / net_layer_blob . md <nl> ppp b / docs / tutorial / net_layer_blob . md <nl> Blobs conceal the computational and mental overhead of mixed CPU / GPU operation b <nl> <nl> The conventional blob dimensions for batches of image data are number N x channel K x height H x width W . Blob memory is row - major in layout , so the last / rightmost dimension changes fastest . For example , in a 4D blob , the value at index ( n , k , h , w ) is physically located at index ( ( n * K + k ) * H + h ) * W + w . <nl> <nl> - - Number / N is the batch size of the data . Batch processing achieves better throughput for communication and device processing . For an ImageNet training batch of 256 images B = 256 . <nl> + - Number / N is the batch size of the data . Batch processing achieves better throughput for communication and device processing . For an ImageNet training batch of 256 images N = 256 . <nl> - Channel / K is the feature dimension e . g . for RGB images K = 3 . <nl> <nl> Note that although many blobs in Caffe examples are 4D with axes for image applications , it is totally valid to use blobs for non - image applications . For example , if you simply need fully - connected networks like the conventional multi - layer perceptron , use 2D blobs ( shape ( N , D ) ) and call the InnerProductLayer ( which we will cover soon ) . <nl>
|
Update net_layer_blob . md
|
BVLC/caffe
|
4ccc052e6e2bd4293dfb530febc9bf441786363d
|
2015-07-12T11:06:31Z
|
mmm a / xbmc / Application . cpp <nl> ppp b / xbmc / Application . cpp <nl> PlayBackRet CApplication : : PlayFile ( const CFileItem & item , bool bRestart ) <nl> } <nl> else <nl> # endif <nl> - CGUIDialogOK : : ShowAndGetInput ( 435 , 0 , 436 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 435 , 436 ) ; <nl> <nl> return PLAYBACK_OK ; <nl> } <nl> void CApplication : : ShowAppMigrationMessage ( ) <nl> if ( CFile : : Exists ( " special : / / home / . kodi_data_was_migrated " ) & & <nl> ! CFile : : Exists ( " special : / / home / . kodi_migration_info_shown " ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 24128 , 0 , 24129 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 24128 , 24129 ) ; <nl> CFile tmpFile ; <nl> / / create the file which will prevent this dialog from appearing in the future <nl> tmpFile . OpenForWrite ( " special : / / home / . kodi_migration_info_shown " ) ; <nl> mmm a / xbmc / GUIPassword . cpp <nl> ppp b / xbmc / GUIPassword . cpp <nl> bool CGUIPassword : : IsItemUnlocked ( CFileItem * pItem , const std : : string & strType ) <nl> { <nl> if ( 0 ! = CSettings : : Get ( ) . GetInt ( " masterlock . maxretries " ) & & pItem - > m_iBadPwdCount > = CSettings : : Get ( ) . GetInt ( " masterlock . maxretries " ) ) <nl> { / / user previously exhausted all retries , show access denied error <nl> - CGUIDialogOK : : ShowAndGetInput ( 12345 , 12346 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 12345 , 12346 ) ; <nl> return false ; <nl> } <nl> / / show the appropriate lock dialog <nl> void CGUIPassword : : UpdateMasterLockRetryCount ( bool bResetCount ) <nl> / / user has run out of retry attempts <nl> g_passwordManager . iMasterLockRetriesLeft = 0 ; <nl> / / Tell the user they ran out of retry attempts <nl> - CGUIDialogOK : : ShowAndGetInput ( 12345 , 12346 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 12345 , 12346 ) ; <nl> return ; <nl> } <nl> } <nl> mmm a / xbmc / addons / GUIDialogAddonSettings . cpp <nl> ppp b / xbmc / addons / GUIDialogAddonSettings . cpp <nl> bool CGUIDialogAddonSettings : : ShowAndGetInput ( const AddonPtr & addon , bool saveTo <nl> } <nl> else <nl> { / / addon does not support settings , inform user <nl> - CGUIDialogOK : : ShowAndGetInput ( 24000 , 0 , 24030 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 24000 , 24030 ) ; <nl> } <nl> <nl> return ret ; <nl> mmm a / xbmc / dialogs / GUIDialogFileBrowser . cpp <nl> ppp b / xbmc / dialogs / GUIDialogFileBrowser . cpp <nl> bool CGUIDialogFileBrowser : : OnMessage ( CGUIMessage & message ) <nl> Close ( ) ; <nl> } <nl> else <nl> - CGUIDialogOK : : ShowAndGetInput ( 257 , 20072 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 257 , 20072 ) ; <nl> } <nl> else <nl> { <nl> bool CGUIDialogFileBrowser : : HaveDiscOrConnection ( int iDriveType ) <nl> { <nl> if ( ! g_mediaManager . IsDiscInDrive ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 218 , 219 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 218 , 219 ) ; <nl> return false ; <nl> } <nl> } <nl> bool CGUIDialogFileBrowser : : HaveDiscOrConnection ( int iDriveType ) <nl> / / TODO : Handle not connected to a remote share <nl> if ( ! g_application . getNetwork ( ) . IsConnected ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 220 , 221 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 220 , 221 ) ; <nl> return false ; <nl> } <nl> } <nl> mmm a / xbmc / dialogs / GUIDialogGamepad . cpp <nl> ppp b / xbmc / dialogs / GUIDialogGamepad . cpp <nl> bool CGUIDialogGamepad : : ShowAndVerifyNewPassword ( std : : string & strNewPassword ) <nl> if ( ShowAndVerifyInput ( strUserInput , " 12340 " , " 12330 " , " 12331 " , " " , true , true ) ) <nl> { <nl> / / TODO : Show error to user saying the password entry was blank <nl> - CGUIDialogOK : : ShowAndGetInput ( 12357 , 12358 , 0 , 0 ) ; / / Password is empty / blank <nl> + CGUIDialogOK : : ShowAndGetInput ( 12357 , 12358 ) ; / / Password is empty / blank <nl> return false ; <nl> } <nl> <nl> bool CGUIDialogGamepad : : ShowAndVerifyNewPassword ( std : : string & strNewPassword ) <nl> if ( ! ShowAndVerifyInput ( strUserInput , " 12341 " , " 12330 " , " 12331 " , " " , false , true ) ) <nl> { <nl> / / TODO : Show error to user saying the password re - entry failed <nl> - CGUIDialogOK : : ShowAndGetInput ( 12357 , 12344 , 0 , 0 ) ; / / Password do not match <nl> + CGUIDialogOK : : ShowAndGetInput ( 12357 , 12344 ) ; / / Password do not match <nl> return false ; <nl> } <nl> <nl> mmm a / xbmc / dialogs / GUIDialogNumeric . cpp <nl> ppp b / xbmc / dialogs / GUIDialogNumeric . cpp <nl> bool CGUIDialogNumeric : : ShowAndVerifyNewPassword ( std : : string & strNewPassword ) <nl> if ( ! ShowAndVerifyInput ( strUserInput , g_localizeStrings . Get ( 12340 ) , false ) ) <nl> { <nl> / / Show error to user saying the password entry was blank <nl> - CGUIDialogOK : : ShowAndGetInput ( 12357 , 12358 , 0 , 0 ) ; / / Password is empty / blank <nl> + CGUIDialogOK : : ShowAndGetInput ( 12357 , 12358 ) ; / / Password is empty / blank <nl> return false ; <nl> } <nl> <nl> bool CGUIDialogNumeric : : ShowAndVerifyNewPassword ( std : : string & strNewPassword ) <nl> if ( ! ShowAndVerifyInput ( strUserInput , g_localizeStrings . Get ( 12341 ) , true ) ) <nl> { <nl> / / Show error to user saying the password re - entry failed <nl> - CGUIDialogOK : : ShowAndGetInput ( 12357 , 12344 , 0 , 0 ) ; / / Password do not match <nl> + CGUIDialogOK : : ShowAndGetInput ( 12357 , 12344 ) ; / / Password do not match <nl> return false ; <nl> } <nl> <nl> mmm a / xbmc / guilib / GUIKeyboardFactory . cpp <nl> ppp b / xbmc / guilib / GUIKeyboardFactory . cpp <nl> bool CGUIKeyboardFactory : : ShowAndVerifyNewPassword ( std : : string & newPassword , con <nl> StringUtils : : ToLower ( newPassword ) ; <nl> return true ; <nl> } <nl> - CGUIDialogOK : : ShowAndGetInput ( 12341 , 12344 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 12341 , 12344 ) ; <nl> return false ; <nl> } <nl> <nl> mmm a / xbmc / music / MusicDatabase . cpp <nl> ppp b / xbmc / music / MusicDatabase . cpp <nl> void CMusicDatabase : : DeleteCDDBInfo ( ) <nl> CFileItemList items ; <nl> if ( ! CDirectory : : GetDirectory ( CProfilesManager : : Get ( ) . GetCDDBFolder ( ) , items , " . cddb " , DIR_FLAG_NO_FILE_DIRS ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 313 , 426 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 313 , 426 ) ; <nl> return ; <nl> } <nl> / / Show a selectdialog that the user can select the album to delete <nl> void CMusicDatabase : : Clean ( ) <nl> / / other writing access to the database is prohibited . <nl> if ( g_application . IsMusicScanning ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 189 , 14057 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 189 , 14057 ) ; <nl> return ; <nl> } <nl> <nl> void CMusicDatabase : : Clean ( ) <nl> <nl> if ( iReturnString ! = ERROR_OK ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 313 , iReturnString , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 313 , iReturnString ) ; <nl> } <nl> } <nl> } <nl> void CMusicDatabase : : ExportToXML ( const std : : string & xmlFile , bool singleFiles , b <nl> progress - > Close ( ) ; <nl> <nl> if ( iFailCount > 0 ) <nl> - CGUIDialogOK : : ShowAndGetInput ( g_localizeStrings . Get ( 20196 ) , StringUtils : : Format ( g_localizeStrings . Get ( 15011 ) . c_str ( ) , iFailCount ) , " " , " " ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 20196 , StringUtils : : Format ( g_localizeStrings . Get ( 15011 ) . c_str ( ) , iFailCount ) ) ; <nl> } <nl> <nl> void CMusicDatabase : : ImportFromXML ( const std : : string & xmlFile ) <nl> mmm a / xbmc / music / windows / GUIWindowMusicBase . cpp <nl> ppp b / xbmc / music / windows / GUIWindowMusicBase . cpp <nl> void CGUIWindowMusicBase : : ShowArtistInfo ( const CFileItem * pItem , bool bShowInfo <nl> <nl> if ( g_application . IsMusicScanning ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 189 , 14057 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 189 , 14057 ) ; <nl> break ; <nl> } <nl> <nl> void CGUIWindowMusicBase : : ShowArtistInfo ( const CFileItem * pItem , bool bShowInfo <nl> CMusicInfoScanner scanner ; <nl> if ( scanner . UpdateDatabaseArtistInfo ( artist , scraper , bShowInfo , m_dlgProgress ) ! = INFO_ADDED ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 21889 , 0 , 20199 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 21889 , 20199 ) ; <nl> break ; <nl> } <nl> } <nl> bool CGUIWindowMusicBase : : ShowAlbumInfo ( const CFileItem * pItem , bool bShowInfo / <nl> <nl> if ( g_application . IsMusicScanning ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 189 , 14057 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 189 , 14057 ) ; <nl> if ( m_dlgProgress ) <nl> m_dlgProgress - > Close ( ) ; <nl> return false ; <nl> bool CGUIWindowMusicBase : : ShowAlbumInfo ( const CFileItem * pItem , bool bShowInfo / <nl> CMusicInfoScanner scanner ; <nl> if ( scanner . UpdateDatabaseAlbumInfo ( album , scraper , bShowInfo , m_dlgProgress ) ! = INFO_ADDED ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 185 , 0 , 500 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 185 , 500 ) ; <nl> if ( m_dlgProgress ) <nl> m_dlgProgress - > Close ( ) ; <nl> return false ; <nl> void CGUIWindowMusicBase : : AddItemToPlayList ( const CFileItemPtr & pItem , CFileItem <nl> / / load it <nl> if ( ! pPlayList - > Load ( pItem - > GetPath ( ) ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 6 , 0 , 477 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 6 , 477 ) ; <nl> return ; / / hmmm unable to load playlist ? <nl> } <nl> <nl> void CGUIWindowMusicBase : : OnRipCD ( ) <nl> # endif <nl> } <nl> else <nl> - CGUIDialogOK : : ShowAndGetInput ( 257 , 20099 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 257 , 20099 ) ; <nl> } <nl> } <nl> <nl> void CGUIWindowMusicBase : : OnRipTrack ( int iItem ) <nl> # endif <nl> } <nl> else <nl> - CGUIDialogOK : : ShowAndGetInput ( 257 , 20099 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 257 , 20099 ) ; <nl> } <nl> } <nl> <nl> void CGUIWindowMusicBase : : LoadPlayList ( const std : : string & strPlayList ) <nl> / / load it <nl> if ( ! pPlayList - > Load ( strPlayList ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 6 , 0 , 477 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 6 , 477 ) ; <nl> return ; / / hmmm unable to load playlist ? <nl> } <nl> } <nl> mmm a / xbmc / music / windows / GUIWindowMusicNav . cpp <nl> ppp b / xbmc / music / windows / GUIWindowMusicNav . cpp <nl> bool CGUIWindowMusicNav : : GetSongsFromPlayList ( const std : : string & strPlayList , CF <nl> / / load it <nl> if ( ! pPlayList - > Load ( strPlayList ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 6 , 0 , 477 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 6 , 477 ) ; <nl> return false ; / / hmmm unable to load playlist ? <nl> } <nl> CPlayList playlist = * pPlayList ; <nl> mmm a / xbmc / network / NetworkServices . cpp <nl> ppp b / xbmc / network / NetworkServices . cpp <nl> bool CNetworkServices : : OnSettingChanging ( const CSetting * setting ) <nl> { <nl> if ( ! StartWebserver ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( g_localizeStrings . Get ( 33101 ) , " " , g_localizeStrings . Get ( 33100 ) , " " ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 33101 , 33100 ) ; <nl> return false ; <nl> } <nl> } <nl> bool CNetworkServices : : OnSettingChanging ( const CSetting * setting ) <nl> # ifdef HAS_AIRTUNES <nl> if ( ! StartAirTunesServer ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( g_localizeStrings . Get ( 1274 ) , " " , g_localizeStrings . Get ( 33100 ) , " " ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 1274 , 33100 ) ; <nl> return false ; <nl> } <nl> # endif / / HAS_AIRTUNES <nl> <nl> if ( ! StartAirPlayServer ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( g_localizeStrings . Get ( 1273 ) , " " , g_localizeStrings . Get ( 33100 ) , " " ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 1273 , 33100 ) ; <nl> return false ; <nl> } <nl> } <nl> bool CNetworkServices : : OnSettingChanging ( const CSetting * setting ) <nl> { <nl> if ( ! StartEventServer ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( g_localizeStrings . Get ( 33102 ) , " " , g_localizeStrings . Get ( 33100 ) , " " ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 33102 , 33100 ) ; <nl> return false ; <nl> } <nl> } <nl> bool CNetworkServices : : OnSettingChanging ( const CSetting * setting ) <nl> { <nl> if ( ! StartJSONRPCServer ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( g_localizeStrings . Get ( 33103 ) , " " , g_localizeStrings . Get ( 33100 ) , " " ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 33103 , 33100 ) ; <nl> return false ; <nl> } <nl> } <nl> bool CNetworkServices : : OnSettingChanging ( const CSetting * setting ) <nl> <nl> if ( ! StartEventServer ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( g_localizeStrings . Get ( 33102 ) , " " , g_localizeStrings . Get ( 33100 ) , " " ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 33102 , 33100 ) ; <nl> return false ; <nl> } <nl> <nl> bool CNetworkServices : : OnSettingChanging ( const CSetting * setting ) <nl> <nl> if ( ! StartEventServer ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( g_localizeStrings . Get ( 33102 ) , " " , g_localizeStrings . Get ( 33100 ) , " " ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 33102 , 33100 ) ; <nl> return false ; <nl> } <nl> } <nl> bool CNetworkServices : : OnSettingChanging ( const CSetting * setting ) <nl> { <nl> if ( ! StartJSONRPCServer ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( g_localizeStrings . Get ( 33103 ) , " " , g_localizeStrings . Get ( 33100 ) , " " ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 33103 , 33100 ) ; <nl> return false ; <nl> } <nl> } <nl> mmm a / xbmc / osx / XBMCHelper . cpp <nl> ppp b / xbmc / osx / XBMCHelper . cpp <nl> bool XBMCHelper : : OnSettingChanging ( const CSetting * setting ) <nl> if ( ErrorStarting ( ) = = true ) <nl> { <nl> / / inform user about error <nl> - CGUIDialogOK : : ShowAndGetInput ( 13620 , 13621 , 20022 , 20022 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 13620 , 13621 ) ; <nl> return false ; <nl> } <nl> } <nl> mmm a / xbmc / pictures / GUIWindowPictures . cpp <nl> ppp b / xbmc / pictures / GUIWindowPictures . cpp <nl> void CGUIWindowPictures : : LoadPlayList ( const std : : string & strPlayList ) <nl> { <nl> if ( ! pPlayList - > Load ( strPlayList ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 6 , 0 , 477 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 6 , 477 ) ; <nl> return ; / / hmmm unable to load playlist ? <nl> } <nl> } <nl> mmm a / xbmc / pvr / PVRManager . cpp <nl> ppp b / xbmc / pvr / PVRManager . cpp <nl> bool CPVRManager : : ToggleRecordingOnChannel ( unsigned int iChannelId ) <nl> { <nl> bReturn = m_timers - > InstantTimer ( channel ) ; <nl> if ( ! bReturn ) <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 0 , 19164 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19164 ) ; <nl> } <nl> else <nl> { <nl> bool CPVRManager : : StartRecordingOnPlayingChannel ( bool bOnOff ) <nl> { <nl> bReturn = m_timers - > InstantTimer ( channel ) ; <nl> if ( ! bReturn ) <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 0 , 19164 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19164 ) ; <nl> } <nl> else if ( ! bOnOff & & channel - > IsRecording ( ) ) <nl> { <nl> bool CPVRManager : : CheckParentalPIN ( const std : : string & strTitle / * = " " * / ) <nl> bool bValidPIN = CGUIDialogNumeric : : ShowAndVerifyInput ( pinCode , ! strTitle . empty ( ) ? strTitle : g_localizeStrings . Get ( 19263 ) , true ) ; <nl> if ( ! bValidPIN ) <nl> / / display message : The entered PIN number was incorrect <nl> - CGUIDialogOK : : ShowAndGetInput ( 19264 , 0 , 19265 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19264 , 19265 ) ; <nl> else if ( m_parentalTimer ) <nl> { <nl> / / reset the timer <nl> mmm a / xbmc / pvr / addons / PVRClients . cpp <nl> ppp b / xbmc / pvr / addons / PVRClients . cpp <nl> void CPVRClients : : StartChannelScan ( void ) <nl> / * no clients found * / <nl> else if ( ! scanClient ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 0 , 19192 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19192 ) ; <nl> return ; <nl> } <nl> <nl> void CPVRClients : : StartChannelScan ( void ) <nl> / * do the scan * / <nl> if ( scanClient - > StartChannelScan ( ) ! = PVR_ERROR_NO_ERROR ) <nl> / * an error occured * / <nl> - CGUIDialogOK : : ShowAndGetInput ( 19111 , 0 , 19193 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19111 , 19193 ) ; <nl> <nl> / * restart the supervisor thread * / <nl> g_PVRManager . StartUpdateThreads ( ) ; <nl> bool CPVRClients : : OpenDialogChannelAdd ( const CPVRChannelPtr & channel ) <nl> <nl> if ( error = = PVR_ERROR_NOT_IMPLEMENTED ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 19038 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19038 ) ; <nl> return true ; <nl> } <nl> <nl> bool CPVRClients : : OpenDialogChannelSettings ( const CPVRChannelPtr & channel ) <nl> <nl> if ( error = = PVR_ERROR_NOT_IMPLEMENTED ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 19038 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19038 ) ; <nl> return true ; <nl> } <nl> <nl> bool CPVRClients : : DeleteChannel ( const CPVRChannelPtr & channel ) <nl> <nl> if ( error = = PVR_ERROR_NOT_IMPLEMENTED ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 19038 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19038 ) ; <nl> return true ; <nl> } <nl> <nl> mmm a / xbmc / pvr / dialogs / GUIDialogPVRChannelManager . cpp <nl> ppp b / xbmc / pvr / dialogs / GUIDialogPVRChannelManager . cpp <nl> bool CGUIDialogPVRChannelManager : : OnClickButtonNewChannel ( ) <nl> if ( g_PVRClients - > OpenDialogChannelAdd ( channel ) ) <nl> Update ( ) ; <nl> else <nl> - CGUIDialogOK : : ShowAndGetInput ( 2103 , 0 , 16029 , 0 ) ; / / Add - on error ; Check the log file for details . <nl> + CGUIDialogOK : : ShowAndGetInput ( 2103 , 16029 ) ; / / Add - on error ; Check the log file for details . <nl> } <nl> return true ; <nl> } <nl> bool CGUIDialogPVRChannelManager : : OnContextButton ( int itemNumber , CONTEXT_BUTTON <nl> else if ( button = = CONTEXT_BUTTON_SETTINGS ) <nl> { <nl> if ( ! g_PVRClients - > OpenDialogChannelSettings ( pItem - > GetPVRChannelInfoTag ( ) ) ) <nl> - CGUIDialogOK : : ShowAndGetInput ( 2103 , 0 , 16029 , 0 ) ; / / Add - on error ; Check the log file for details . <nl> + CGUIDialogOK : : ShowAndGetInput ( 2103 , 16029 ) ; / / Add - on error ; Check the log file for details . <nl> } <nl> else if ( button = = CONTEXT_BUTTON_DELETE ) <nl> { <nl> bool CGUIDialogPVRChannelManager : : OnContextButton ( int itemNumber , CONTEXT_BUTTON <nl> Renumber ( ) ; <nl> } <nl> else <nl> - CGUIDialogOK : : ShowAndGetInput ( 2103 , 0 , 16029 , 0 ) ; / / Add - on error ; Check the log file for details . <nl> + CGUIDialogOK : : ShowAndGetInput ( 2103 , 16029 ) ; / / Add - on error ; Check the log file for details . <nl> } <nl> } <nl> else if ( button = = CONTEXT_BUTTON_EDIT_SOURCE ) <nl> void CGUIDialogPVRChannelManager : : RenameChannel ( CFileItemPtr pItem ) <nl> channel - > SetChannelName ( strChannelName ) ; <nl> <nl> if ( ! g_PVRClients - > RenameChannel ( channel ) ) <nl> - CGUIDialogOK : : ShowAndGetInput ( 2103 , 0 , 16029 , 0 ) ; / / Add - on error ; Check the log file for details . <nl> + CGUIDialogOK : : ShowAndGetInput ( 2103 , 16029 ) ; / / Add - on error ; Check the log file for details . <nl> } <nl> } <nl> <nl> mmm a / xbmc / pvr / dialogs / GUIDialogPVRGuideInfo . cpp <nl> ppp b / xbmc / pvr / dialogs / GUIDialogPVRGuideInfo . cpp <nl> bool CGUIDialogPVRGuideInfo : : OnClickButtonRecord ( CGUIMessage & message ) <nl> if ( ! tag | | ! tag - > HasPVRChannel ( ) ) <nl> { <nl> / * invalid channel * / <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 19067 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19067 ) ; <nl> Close ( ) ; <nl> return bReturn ; <nl> } <nl> bool CGUIDialogPVRGuideInfo : : OnClickButtonPlay ( CGUIMessage & message ) <nl> if ( ret = = PLAYBACK_FAIL ) <nl> { <nl> std : : string msg = StringUtils : : Format ( g_localizeStrings . Get ( 19035 ) . c_str ( ) , g_localizeStrings . Get ( 19029 ) . c_str ( ) ) ; / / Channel could not be played . Check the log for details . <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 0 , msg , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , msg ) ; <nl> } <nl> else if ( ret = = PLAYBACK_OK ) <nl> { <nl> mmm a / xbmc / pvr / timers / PVRTimers . cpp <nl> ppp b / xbmc / pvr / timers / PVRTimers . cpp <nl> bool CPVRTimers : : AddTimer ( const CPVRTimerInfoTagPtr & item ) <nl> if ( ! item - > m_channel ) <nl> { <nl> CLog : : Log ( LOGERROR , " PVRTimers - % s - no channel given " , __FUNCTION__ ) ; <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 0 , 19109 , 0 ) ; / / Couldn ' t save timer <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19109 ) ; / / Couldn ' t save timer <nl> return false ; <nl> } <nl> <nl> if ( ! g_PVRClients - > SupportsTimers ( item - > m_iClientId ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 0 , 19215 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19215 ) ; <nl> return false ; <nl> } <nl> <nl> mmm a / xbmc / pvr / windows / GUIWindowPVRBase . cpp <nl> ppp b / xbmc / pvr / windows / GUIWindowPVRBase . cpp <nl> bool CGUIWindowPVRBase : : StartRecordFile ( const CFileItem & item ) <nl> CFileItemPtr timer = g_PVRTimers - > GetTimerForEpgTag ( & item ) ; <nl> if ( timer & & timer - > HasPVRTimerInfoTag ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 19034 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19034 ) ; <nl> return false ; <nl> } <nl> <nl> bool CGUIWindowPVRBase : : PlayRecording ( CFileItem * item , bool bPlayMinimized / * = <nl> else <nl> { <nl> CLog : : Log ( LOGERROR , " CGUIWindowPVRCommon - % s - can ' t open recording : no valid filename " , __FUNCTION__ ) ; <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 0 , 19036 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19036 ) ; <nl> return false ; <nl> } <nl> <nl> void CGUIWindowPVRBase : : ShowEPGInfo ( CFileItem * item ) <nl> bHasChannel = true ; <nl> if ( ! epgnow ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 0 , 19055 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19055 ) ; <nl> return ; <nl> } <nl> tag = new CFileItem ( epgnow ) ; <nl> bool CGUIWindowPVRBase : : ActionPlayEpg ( CFileItem * item , bool bPlayRecording ) <nl> { <nl> / / CHANNELNAME could not be played . Check the log for details . <nl> std : : string msg = StringUtils : : Format ( g_localizeStrings . Get ( 19035 ) . c_str ( ) , channel - > ChannelName ( ) . c_str ( ) ) ; <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 0 , msg , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , msg ) ; <nl> return false ; <nl> } <nl> <nl> bool CGUIWindowPVRBase : : ActionRecord ( CFileItem * item ) <nl> } <nl> else <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 19034 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19034 ) ; <nl> bReturn = true ; <nl> } <nl> <nl> mmm a / xbmc / pvr / windows / GUIWindowPVRChannels . cpp <nl> ppp b / xbmc / pvr / windows / GUIWindowPVRChannels . cpp <nl> bool CGUIWindowPVRChannels : : OnContextButtonAdd ( CFileItem * item , CONTEXT_BUTTON b <nl> <nl> if ( button = = CONTEXT_BUTTON_ADD ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 0 , 19038 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19038 ) ; <nl> bReturn = true ; <nl> } <nl> <nl> mmm a / xbmc / pvr / windows / GUIWindowPVRSearch . cpp <nl> ppp b / xbmc / pvr / windows / GUIWindowPVRSearch . cpp <nl> void CGUIWindowPVRSearch : : OnPrepareFileItems ( CFileItemList & items ) <nl> <nl> if ( items . IsEmpty ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 194 , 284 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 194 , 284 ) ; <nl> m_bSearchConfirmed = false ; <nl> } <nl> } <nl> mmm a / xbmc / video / VideoDatabase . cpp <nl> ppp b / xbmc / video / VideoDatabase . cpp <nl> void CVideoDatabase : : ExportToXML ( const std : : string & path , bool singleFiles / * = <nl> progress - > Close ( ) ; <nl> <nl> if ( iFailCount > 0 ) <nl> - CGUIDialogOK : : ShowAndGetInput ( g_localizeStrings . Get ( 647 ) , StringUtils : : Format ( g_localizeStrings . Get ( 15011 ) . c_str ( ) , iFailCount ) , " " , " " ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 647 , StringUtils : : Format ( g_localizeStrings . Get ( 15011 ) . c_str ( ) , iFailCount ) ) ; <nl> } <nl> <nl> void CVideoDatabase : : ExportActorThumbs ( const std : : string & strDir , const CVideoInfoTag & tag , bool singleFiles , bool overwrite / * = false * / ) <nl> mmm a / xbmc / video / VideoInfoScanner . cpp <nl> ppp b / xbmc / video / VideoInfoScanner . cpp <nl> namespace VIDEO <nl> <nl> if ( pDialog ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 20448 , 20449 , 20022 , 20022 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 20448 , 20449 ) ; <nl> return false ; <nl> } <nl> return CGUIDialogYesNo : : ShowAndGetInput ( 20448 , 20449 , 20450 , 20022 ) ; <nl> mmm a / xbmc / video / dialogs / GUIDialogVideoInfo . cpp <nl> ppp b / xbmc / video / dialogs / GUIDialogVideoInfo . cpp <nl> void CGUIDialogVideoInfo : : OnSearch ( std : : string & strSearch ) <nl> } <nl> else <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 194 , 284 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 194 , 284 ) ; <nl> } <nl> } <nl> <nl> bool CGUIDialogVideoInfo : : UpdateVideoItemTitle ( const CFileItemPtr & pItem ) <nl> / / dont allow update while scanning <nl> if ( g_application . IsVideoScanning ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 257 , 0 , 14057 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 257 , 14057 ) ; <nl> return false ; <nl> } <nl> <nl> bool CGUIDialogVideoInfo : : DeleteVideoItemFromDatabase ( const CFileItemPtr & item , <nl> / / dont allow update while scanning <nl> if ( g_application . IsVideoScanning ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 257 , 0 , 14057 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 257 , 14057 ) ; <nl> return false ; <nl> } <nl> <nl> bool CGUIDialogVideoInfo : : UpdateVideoItemSortTitle ( const CFileItemPtr & pItem ) <nl> / / dont allow update while scanning <nl> if ( g_application . IsVideoScanning ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 257 , 0 , 14057 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 257 , 14057 ) ; <nl> return false ; <nl> } <nl> <nl> mmm a / xbmc / video / windows / GUIWindowVideoBase . cpp <nl> ppp b / xbmc / video / windows / GUIWindowVideoBase . cpp <nl> void CGUIWindowVideoBase : : OnInfo ( CFileItem * pItem , ADDON : : ScraperPtr & scraper ) <nl> / / no video file in this folder <nl> if ( ! bFoundFile ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 13346 , 20349 , 20022 , 20022 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 13346 , 20349 ) ; <nl> return ; <nl> } <nl> } <nl> bool CGUIWindowVideoBase : : ShowIMDB ( CFileItem * item , const ScraperPtr & info2 , boo <nl> <nl> if ( g_application . IsVideoScanning ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 13346 , 14057 , - 1 , - 1 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 13346 , 14057 ) ; <nl> return false ; <nl> } <nl> <nl> bool CGUIWindowVideoBase : : ShowIMDB ( CFileItem * item , const ScraperPtr & info2 , boo <nl> m_database . Close ( ) ; <nl> return listNeedsUpdating ; / / user cancelled <nl> } <nl> - CGUIDialogOK : : ShowAndGetInput ( 195 , movieName , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 195 , movieName ) ; <nl> m_database . Close ( ) ; <nl> return listNeedsUpdating ; <nl> } <nl> void CGUIWindowVideoBase : : AddItemToPlayList ( const CFileItemPtr & pItem , CFileItem <nl> / / load it <nl> if ( ! pPlayList - > Load ( pItem - > GetPath ( ) ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 6 , 0 , 477 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 6 , 477 ) ; <nl> return ; / / hmmm unable to load playlist ? <nl> } <nl> <nl> bool CGUIWindowVideoBase : : OnPlayMedia ( int iItem ) <nl> else <nl> { <nl> CLog : : Log ( LOGERROR , " CGUIWindowTV : Can ' t open recording , no valid filename ! " ) ; <nl> - CGUIDialogOK : : ShowAndGetInput ( 19033 , 0 , 19036 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 19033 , 19036 ) ; <nl> return false ; <nl> } <nl> } <nl> void CGUIWindowVideoBase : : LoadPlayList ( const std : : string & strPlayList , int iPlay <nl> / / load it <nl> if ( ! pPlayList - > Load ( strPlayList ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 6 , 0 , 477 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 6 , 477 ) ; <nl> return ; / / hmmm unable to load playlist ? <nl> } <nl> } <nl> void CGUIWindowVideoBase : : OnSearch ( ) <nl> } <nl> else <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 194 , 284 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 194 , 284 ) ; <nl> } <nl> } <nl> <nl> mmm a / xbmc / video / windows / GUIWindowVideoNav . cpp <nl> ppp b / xbmc / video / windows / GUIWindowVideoNav . cpp <nl> bool CGUIWindowVideoNav : : OnClick ( int iItem ) <nl> } <nl> else <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 257 , 0 , 662 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 257 , 662 ) ; <nl> return true ; <nl> } <nl> } <nl> bool CGUIWindowVideoNav : : OnClick ( int iItem ) <nl> / / dont allow update while scanning <nl> if ( g_application . IsVideoScanning ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 257 , 0 , 14057 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 257 , 14057 ) ; <nl> return true ; <nl> } <nl> <nl> bool CGUIWindowVideoNav : : OnClick ( int iItem ) <nl> if ( ! videodb . GetSingleValue ( " tag " , " tag . tag_id " , videodb . PrepareSQL ( " tag . name = ' % s ' AND tag . tag_id IN ( SELECT tag_link . tag_id FROM tag_link WHERE tag_link . media_type = ' % s ' ) " , strTag . c_str ( ) , mediaType . c_str ( ) ) ) . empty ( ) ) <nl> { <nl> std : : string strError = StringUtils : : Format ( g_localizeStrings . Get ( 20463 ) . c_str ( ) , strTag . c_str ( ) ) ; <nl> - CGUIDialogOK : : ShowAndGetInput ( 20462 , " " , strError , " " ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 20462 , strError ) ; <nl> return true ; <nl> } <nl> <nl> mmm a / xbmc / windows / GUIMediaWindow . cpp <nl> ppp b / xbmc / windows / GUIMediaWindow . cpp <nl> bool CGUIMediaWindow : : HaveDiscOrConnection ( const std : : string & strPath , int iDriv <nl> { <nl> if ( ! g_mediaManager . IsDiscInDrive ( strPath ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 218 , 219 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 218 , 219 ) ; <nl> return false ; <nl> } <nl> } <nl> bool CGUIMediaWindow : : HaveDiscOrConnection ( const std : : string & strPath , int iDriv <nl> / / TODO : Handle not connected to a remote share <nl> if ( ! g_application . getNetwork ( ) . IsConnected ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 220 , 221 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 220 , 221 ) ; <nl> return false ; <nl> } <nl> } <nl> void CGUIMediaWindow : : ShowShareErrorMessage ( CFileItem * pItem ) <nl> else <nl> idMessageText = 15300 ; / / Path not found or invalid <nl> <nl> - CGUIDialogOK : : ShowAndGetInput ( 220 , idMessageText , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 220 , idMessageText ) ; <nl> } <nl> <nl> / / \ brief The functon goes up one level in the directory tree <nl> mmm a / xbmc / windows / GUIWindowFileManager . cpp <nl> ppp b / xbmc / windows / GUIWindowFileManager . cpp <nl> void CGUIWindowFileManager : : OnStart ( CFileItem * pItem ) <nl> { <nl> if ( ! pPlayList - > Load ( strPlayList ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 6 , 0 , 477 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 6 , 477 ) ; <nl> return ; <nl> } <nl> } <nl> bool CGUIWindowFileManager : : HaveDiscOrConnection ( std : : string & strPath , int iDri <nl> { <nl> if ( ! g_mediaManager . IsDiscInDrive ( strPath ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 218 , 219 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 218 , 219 ) ; <nl> int iList = GetFocusedList ( ) ; <nl> int iItem = GetSelectedItem ( iList ) ; <nl> Update ( iList , " " ) ; <nl> bool CGUIWindowFileManager : : HaveDiscOrConnection ( std : : string & strPath , int iDri <nl> / / TODO : Handle not connected to a remote share <nl> if ( ! g_application . getNetwork ( ) . IsConnected ( ) ) <nl> { <nl> - CGUIDialogOK : : ShowAndGetInput ( 220 , 221 , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 220 , 221 ) ; <nl> return false ; <nl> } <nl> } <nl> void CGUIWindowFileManager : : ShowShareErrorMessage ( CFileItem * pItem ) <nl> else <nl> idMessageText = 15300 ; / / Path not found or invalid <nl> <nl> - CGUIDialogOK : : ShowAndGetInput ( 220 , idMessageText , 0 , 0 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 220 , idMessageText ) ; <nl> } <nl> <nl> void CGUIWindowFileManager : : OnInitWindow ( ) <nl> mmm a / xbmc / windows / GUIWindowLoginScreen . cpp <nl> ppp b / xbmc / windows / GUIWindowLoginScreen . cpp <nl> bool CGUIWindowLoginScreen : : OnMessage ( CGUIMessage & message ) <nl> else <nl> { <nl> if ( ! bCanceled & & iItem ! = 0 ) <nl> - CGUIDialogOK : : ShowAndGetInput ( 20068 , 20117 , 20022 , 20022 ) ; <nl> + CGUIDialogOK : : ShowAndGetInput ( 20068 , 20117 ) ; <nl> } <nl> } <nl> } <nl>
|
always use the DialogOK with the textbox input instead of separate lines
|
xbmc/xbmc
|
e6abb9d68f27a05710463787c1dc43a4f02b5a56
|
2015-05-23T15:20:38Z
|
mmm a / scripts / azure - pipelines / azure - pipelines . yml <nl> ppp b / scripts / azure - pipelines / azure - pipelines . yml <nl> variables : <nl> windows - pool : ' PrWin - 2020 - 06 - 30 ' <nl> linux - pool : ' PrLin - 2020 - 06 - 30 ' <nl> <nl> - jobs : <nl> + stages : <nl> + - stage : check_cxx_formatting <nl> + displayName : ' Check the formatting of the C + + ' <nl> + pool : $ ( windows - pool ) <nl> + jobs : <nl> + - job : <nl> + steps : <nl> + - task : Powershell @ 2 <nl> + displayName : ' Check C + + Formatting ' <nl> + inputs : <nl> + filePath : ' scripts / azure - pipelines / windows / Check - CxxFormatting . ps1 ' <nl> + arguments : ' - Root . ' <nl> + - stage : check_manifest_formatting <nl> + displayName : Check the formatting of port manifests <nl> + pool : $ ( windows - pool ) <nl> + dependsOn : [ ] <nl> + jobs : <nl> + - job : <nl> + steps : <nl> + - task : Powershell @ 2 <nl> + displayName : ' Check port manifest Formatting ' <nl> + inputs : <nl> + filePath : ' scripts / azure - pipelines / windows / Check - ManifestFormatting . ps1 ' <nl> + arguments : ' - Root . - Downloads D : \ Downloads ' <nl> + - stage : run_port_ci <nl> + displayName : ' Run the Port CI ' <nl> + dependsOn : <nl> + - check_cxx_formatting <nl> + - check_manifest_formatting <nl> + jobs : <nl> - template : windows / azure - pipelines . yml <nl> parameters : <nl> triplet : x86 - windows <nl> similarity index 69 % <nl> rename from scripts / azure - pipelines / windows / check - formatting . ps1 <nl> rename to scripts / azure - pipelines / windows / Check - CxxFormatting . ps1 <nl> mmm a / scripts / azure - pipelines / windows / check - formatting . ps1 <nl> ppp b / scripts / azure - pipelines / windows / Check - CxxFormatting . ps1 <nl> <nl> [ CmdletBinding ( ) ] <nl> Param ( <nl> [ Parameter ( Mandatory = $ True ) ] <nl> - [ string ] $ Toolsrc , <nl> + [ string ] $ Root , <nl> [ Parameter ( ) ] <nl> [ switch ] $ IgnoreErrors # allows one to just format <nl> ) <nl> if ( - not ( Test - Path $ clangFormat ) ) <nl> throw <nl> } <nl> <nl> - $ Toolsrc = Get - Item $ Toolsrc <nl> - Push - Location $ Toolsrc <nl> + $ toolsrc = Get - Item " $ Root / toolsrc " <nl> + Push - Location $ toolsrc <nl> <nl> try <nl> { <nl> - $ files = Get - ChildItem - Recurse - LiteralPath " $ Toolsrc / src " - Filter ' * . cpp ' <nl> - $ files + = Get - ChildItem - Recurse - LiteralPath " $ Toolsrc / include / vcpkg " - Filter ' * . h ' <nl> - $ files + = Get - ChildItem - Recurse - LiteralPath " $ Toolsrc / include / vcpkg - test " - Filter ' * . h ' <nl> - $ files + = Get - Item " $ Toolsrc / include / pch . h " <nl> + $ files = Get - ChildItem - Recurse - LiteralPath " $ toolsrc / src " - Filter ' * . cpp ' <nl> + $ files + = Get - ChildItem - Recurse - LiteralPath " $ toolsrc / include / vcpkg " - Filter ' * . h ' <nl> + $ files + = Get - ChildItem - Recurse - LiteralPath " $ toolsrc / include / vcpkg - test " - Filter ' * . h ' <nl> + $ files + = Get - Item " $ toolsrc / include / pch . h " <nl> $ fileNames = $ files . FullName <nl> <nl> & $ clangFormat - style = file - i @ fileNames <nl> <nl> - $ changedFiles = git status - - porcelain $ Toolsrc | ForEach - Object { <nl> - ( - split $ _ ) [ 1 ] <nl> - } <nl> - <nl> + $ changedFiles = & " $ PSScriptRoot / Get - ChangedFiles . ps1 " - Directory $ toolsrc <nl> if ( - not $ IgnoreErrors - and $ null - ne $ changedFiles ) <nl> { <nl> $ msg = @ ( <nl> try <nl> $ msg + = " " <nl> <nl> $ msg + = " clang - format should produce the following diff : " <nl> - $ msg + = git diff $ Toolsrc <nl> + $ msg + = git diff $ toolsrc <nl> <nl> Write - Error ( $ msg - join " ` n " ) <nl> throw <nl> new file mode 100644 <nl> index 00000000000 . . e4f52ae7b44 <nl> mmm / dev / null <nl> ppp b / scripts / azure - pipelines / windows / Check - ManifestFormatting . ps1 <nl> <nl> + [ CmdletBinding ( ) ] <nl> + Param ( <nl> + [ Parameter ( Mandatory = $ True ) ] <nl> + [ string ] $ Root , <nl> + [ Parameter ( ) ] <nl> + [ string ] $ DownloadsDirectory , <nl> + [ Parameter ( ) ] <nl> + [ switch ] $ IgnoreErrors # allows one to just format <nl> + ) <nl> + <nl> + $ portsTree = Get - Item " $ Root / ports " <nl> + <nl> + if ( - not ( Test - Path " $ Root / . vcpkg - root " ) ) <nl> + { <nl> + Write - Error " The vcpkg root was not at $ Root " <nl> + throw <nl> + } <nl> + <nl> + if ( - not [ string ] : : IsNullOrEmpty ( $ DownloadsDirectory ) ) <nl> + { <nl> + $ env : VCPKG_DOWNLOADS = $ DownloadsDirectory <nl> + } <nl> + <nl> + if ( - not ( Test - Path " $ Root / vcpkg . exe " ) ) <nl> + { <nl> + & " $ Root / bootstrap - vcpkg . bat " <nl> + if ( - not $ ? ) <nl> + { <nl> + Write - Error " Bootstrapping vcpkg failed " <nl> + throw <nl> + } <nl> + } <nl> + <nl> + & " $ Root / vcpkg . exe " ' x - format - manifest ' ' - - all ' <nl> + $ changedFiles = & " $ PSScriptRoot / Get - ChangedFiles . ps1 " - Directory $ portsTree <nl> + if ( - not $ IgnoreErrors - and $ null - ne $ changedFiles ) <nl> + { <nl> + $ msg = @ ( <nl> + " " , <nl> + " The formatting of the manifest files didn ' t match our expectation . " , <nl> + " If your build fails here , you need to run : " <nl> + ) <nl> + $ msg + = " vcpkg x - format - manifest - - all " <nl> + $ msg + = " " <nl> + <nl> + $ msg + = " vcpkg should produce the following diff : " <nl> + $ msg + = git diff $ portsTree <nl> + <nl> + Write - Error ( $ msg - join " ` n " ) <nl> + throw <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . e299369a047 <nl> mmm / dev / null <nl> ppp b / scripts / azure - pipelines / windows / Get - ChangedFiles . ps1 <nl> <nl> + [ CmdletBinding ( ) ] <nl> + Param ( <nl> + [ Parameter ( Mandatory = $ True ) ] <nl> + [ string ] $ Directory <nl> + ) <nl> + <nl> + git status - - porcelain $ Directory | ForEach - Object { <nl> + ( - split $ _ ) [ 1 ] <nl> + } <nl> mmm a / scripts / azure - pipelines / windows / azure - pipelines . yml <nl> ppp b / scripts / azure - pipelines / windows / azure - pipelines . yml <nl> jobs : <nl> condition : always ( ) <nl> inputs : <nl> filePath : ' scripts / azure - pipelines / windows / disk - space . ps1 ' <nl> - - task : Powershell @ 2 <nl> - displayName : ' Check C + + Formatting ' <nl> - condition : eq ( ' $ { { parameters . triplet } } ' , ' x86 - windows ' ) <nl> - inputs : <nl> - filePath : ' scripts / azure - pipelines / windows / check - formatting . ps1 ' <nl> - arguments : ' - Toolsrc . / toolsrc ' <nl> - # Note : D : is the Azure machines ' temporary disk . <nl> + # Note : D : is the Azure machines ' temporary disk . <nl> - task : CmdLine @ 2 <nl> displayName : ' Build vcpkg ' <nl> inputs : <nl>
|
[ vcpkg ci ] Update formatting CI ( )
|
microsoft/vcpkg
|
9606917c81792c52097847fa8037907d92b161a2
|
2020-07-07T21:09:33Z
|
mmm a / src / clustering / administration / main / command_line . cc <nl> ppp b / src / clustering / administration / main / command_line . cc <nl> po : : options_description get_web_options_visible ( ) { <nl> return desc ; <nl> } <nl> <nl> - po : : options_description get_network_options ( ) { <nl> + po : : options_description get_network_options ( bool join_required ) { <nl> po : : options_description desc ( " Network options " ) ; <nl> desc . add_options ( ) <nl> ( " bind " , po : : value < std : : vector < std : : string > > ( ) - > composing ( ) , " add the address of a local interface to listen on when accepting connections , may be ' all ' or an IP address , loopback addresses are enabled by default " ) <nl> ( " cluster - port " , po : : value < int > ( ) - > default_value ( port_defaults : : peer_port ) , " port for receiving connections from other nodes " ) <nl> DEBUG_ONLY ( ( " client - port " , po : : value < int > ( ) - > default_value ( port_defaults : : client_port ) , " port to use when connecting to other nodes ( for development ) " ) ) <nl> ( " driver - port " , po : : value < int > ( ) - > default_value ( port_defaults : : reql_port ) , " port for rethinkdb protocol for client drivers " ) <nl> - ( " join , j " , po : : value < std : : vector < host_and_port_t > > ( ) - > composing ( ) , " host : port of a node that we will connect to " ) <nl> ( " port - offset , o " , po : : value < int > ( ) - > default_value ( port_defaults : : port_offset ) , " all ports used locally will have this value added " ) ; <nl> + if ( join_required ) { <nl> + desc . add_options ( ) <nl> + ( " join , j " , po : : value < std : : vector < host_and_port_t > > ( ) - > composing ( ) - > required ( ) , " host : port of a rethinkdb node to connect to " ) ; <nl> + } else { <nl> + desc . add_options ( ) <nl> + ( " join , j " , po : : value < std : : vector < host_and_port_t > > ( ) - > composing ( ) , " host : port of a rethinkdb node to connect to " ) ; <nl> + } <nl> + <nl> return desc ; <nl> } <nl> <nl> po : : options_description get_rethinkdb_create_options_visible ( ) { <nl> po : : options_description get_rethinkdb_serve_options ( ) { <nl> po : : options_description desc ( " Allowed options " ) ; <nl> desc . add ( get_file_options ( ) ) ; <nl> - desc . add ( get_network_options ( ) ) ; <nl> + desc . add ( get_network_options ( false ) ) ; <nl> desc . add ( get_web_options ( ) ) ; <nl> desc . add ( get_disk_options ( ) ) ; <nl> desc . add ( get_cpu_options ( ) ) ; <nl> po : : options_description get_rethinkdb_serve_options ( ) { <nl> po : : options_description get_rethinkdb_serve_options_visible ( ) { <nl> po : : options_description desc ( " Allowed options " ) ; <nl> desc . add ( get_file_options ( ) ) ; <nl> - desc . add ( get_network_options ( ) ) ; <nl> + desc . add ( get_network_options ( false ) ) ; <nl> desc . add ( get_web_options_visible ( ) ) ; <nl> # ifdef AIOSUPPORT <nl> desc . add ( get_disk_options ( ) ) ; <nl> po : : options_description get_rethinkdb_serve_options_visible ( ) { <nl> <nl> po : : options_description get_rethinkdb_proxy_options ( ) { <nl> po : : options_description desc ( " Allowed options " ) ; <nl> - desc . add ( get_network_options ( ) ) ; <nl> + desc . add ( get_network_options ( true ) ) ; <nl> desc . add ( get_web_options ( ) ) ; <nl> desc . add ( get_service_options ( ) ) ; <nl> desc . add ( get_help_options ( ) ) ; <nl> po : : options_description get_rethinkdb_proxy_options ( ) { <nl> <nl> po : : options_description get_rethinkdb_proxy_options_visible ( ) { <nl> po : : options_description desc ( " Allowed options " ) ; <nl> - desc . add ( get_network_options ( ) ) ; <nl> + desc . add ( get_network_options ( true ) ) ; <nl> desc . add ( get_web_options_visible ( ) ) ; <nl> desc . add ( get_service_options ( ) ) ; <nl> desc . add ( get_help_options ( ) ) ; <nl> po : : options_description get_rethinkdb_admin_options ( ) { <nl> po : : options_description desc ( " Allowed options " ) ; <nl> desc . add_options ( ) <nl> DEBUG_ONLY ( ( " client - port " , po : : value < int > ( ) - > default_value ( port_defaults : : client_port ) , " port to use when connecting to other nodes ( for development ) " ) ) <nl> - ( " join , j " , po : : value < std : : vector < host_and_port_t > > ( ) - > composing ( ) , " host : port of a node that we will connect to " ) <nl> + ( " join , j " , po : : value < std : : vector < host_and_port_t > > ( ) - > composing ( ) , " host : port of a rethinkdb node to connect to " ) <nl> ( " exit - failure , x " , po : : value < bool > ( ) - > zero_tokens ( ) , " exit with an error code immediately if a command fails " ) ; <nl> return desc ; <nl> } <nl> po : : options_description get_rethinkdb_import_options ( ) { <nl> po : : options_description desc ( " Allowed options " ) ; <nl> desc . add_options ( ) <nl> DEBUG_ONLY ( ( " client - port " , po : : value < int > ( ) - > default_value ( port_defaults : : client_port ) , " port to use when connecting to other nodes ( for development ) " ) ) <nl> - ( " join , j " , po : : value < std : : vector < host_and_port_t > > ( ) - > composing ( ) , " host : port of a node that we will connect to " ) <nl> - / / Default value of empty string ? Because who knows what the duck it returns with <nl> + ( " join , j " , po : : value < std : : vector < host_and_port_t > > ( ) - > composing ( ) - > required ( ) , " host : port of a rethinkdb node to connect to " ) <nl> + / / Default value of empty string ? Because who knows what the buck it returns with <nl> / / no default value . Or am I supposed to wade my way back into the <nl> / / program_options documentation again ? <nl> / / A default value is not required . One can check vm . count ( " thing " ) in order to determine whether the user has supplied the option . - - Juggernaut <nl> - ( " table " , po : : value < std : : string > ( ) - > default_value ( " " ) , " the database and table into which to import , of the format ' database . table ' " ) <nl> + ( " table " , po : : value < std : : string > ( ) - > required ( ) , " the database and table into which to import , of the format ' database . table ' " ) <nl> ( " datacenter " , po : : value < std : : string > ( ) - > default_value ( " " ) , " the datacenter into which to create a table " ) <nl> ( " primary - key " , po : : value < std : : string > ( ) - > default_value ( " id " ) , " the primary key to create a new table with , or expected primary key " ) <nl> ( " separators , s " , po : : value < std : : string > ( ) - > default_value ( " \ t , " ) , " list of characters to be used as whitespace - - uses \ " \ \ t , \ " by default " ) <nl> - ( " input - file " , po : : value < std : : string > ( ) - > default_value ( " " ) , " the csv input file " ) ; <nl> + ( " input - file " , po : : value < std : : string > ( ) - > required ( ) , " the csv input file " ) ; <nl> desc . add ( get_help_options ( ) ) ; <nl> <nl> return desc ; <nl> po : : options_description get_rethinkdb_porcelain_options ( ) { <nl> po : : options_description desc ( " Allowed options " ) ; <nl> desc . add ( get_file_options ( ) ) ; <nl> desc . add ( get_machine_options ( ) ) ; <nl> - desc . add ( get_network_options ( ) ) ; <nl> + desc . add ( get_network_options ( false ) ) ; <nl> desc . add ( get_web_options ( ) ) ; <nl> desc . add ( get_disk_options ( ) ) ; <nl> desc . add ( get_cpu_options ( ) ) ; <nl> po : : options_description get_rethinkdb_porcelain_options_visible ( ) { <nl> po : : options_description desc ( " Allowed options " ) ; <nl> desc . add ( get_file_options ( ) ) ; <nl> desc . add ( get_machine_options_visible ( ) ) ; <nl> - desc . add ( get_network_options ( ) ) ; <nl> + desc . add ( get_network_options ( false ) ) ; <nl> desc . add ( get_web_options_visible ( ) ) ; <nl> # ifdef AIOSUPPORT <nl> desc . add ( get_disk_options ( ) ) ; <nl> MUST_USE bool pull_io_backend_option ( const po : : variables_map & vm , io_backend_t * <nl> return true ; <nl> } <nl> <nl> - MUST_USE bool parse_commands_flat ( int argc , char * argv [ ] , po : : variables_map * vm , const po : : options_description & options ) { <nl> + void output_option_description ( const std : : string & option_name , const po : : options_description & options ) { <nl> + const po : : option_description & option = options . find ( option_name , false ) ; <nl> + fprintf ( stderr , " usage : % s % s \ t ( % s ) \ n " , <nl> + option . format_name ( ) . c_str ( ) , <nl> + option . format_parameter ( ) . c_str ( ) , <nl> + option . description ( ) . c_str ( ) ) ; <nl> + } <nl> + <nl> + MUST_USE bool parse_commands ( int argc , char * argv [ ] , po : : variables_map * vm , const po : : options_description & options ) { <nl> try { <nl> int style = <nl> po : : command_line_style : : default_style & <nl> ~ po : : command_line_style : : allow_guessing ; <nl> po : : store ( po : : parse_command_line ( argc , argv , options , style ) , * vm ) ; <nl> - } catch ( const po : : multiple_occurrences & ex ) { <nl> - fprintf ( stderr , " flag specified too many times \ n " ) ; <nl> - return false ; <nl> - } <nl> - return true ; <nl> - } <nl> - <nl> - MUST_USE bool parse_commands ( int argc , char * argv [ ] , po : : variables_map * vm , const po : : options_description & options ) { <nl> - if ( parse_commands_flat ( argc , argv , vm , options ) ) { <nl> po : : notify ( * vm ) ; <nl> - } else { <nl> + } catch ( const po : : multiple_occurrences & ex ) { <nl> + fprintf ( stderr , " % s flag specified too many times \ n " , ex . get_option_name ( ) . c_str ( ) ) ; <nl> + output_option_description ( ex . get_option_name ( ) , options ) ; <nl> + return false ; <nl> + } catch ( const po : : required_option & ex ) { <nl> + fprintf ( stderr , " % s \ n " , ex . what ( ) ) ; <nl> + output_option_description ( ex . get_option_name ( ) , options ) ; <nl> + return false ; <nl> + } catch ( const po : : validation_error & ex ) { <nl> + fprintf ( stderr , " % s \ n " , ex . what ( ) ) ; <nl> + output_option_description ( ex . get_option_name ( ) , options ) ; <nl> return false ; <nl> } <nl> return true ; <nl> MUST_USE bool parse_config_file_flat ( const std : : string & conf_file_name , po : : var <nl> try { <nl> po : : store ( po : : parse_config_file ( conf_file , options , true ) , * vm ) ; <nl> } catch ( const po : : multiple_occurrences & ex ) { <nl> - fprintf ( stderr , " flag specified too many times \ n " ) ; <nl> + fprintf ( stderr , " % s flag specified too many times \ n " , ex . get_option_name ( ) . c_str ( ) ) ; <nl> + output_option_description ( ex . get_option_name ( ) , options ) ; <nl> + conf_file . close ( ) ; <nl> + return false ; <nl> + } catch ( const po : : required_option & ex ) { <nl> + fprintf ( stderr , " % s \ n " , ex . what ( ) ) ; <nl> + output_option_description ( ex . get_option_name ( ) , options ) ; <nl> + conf_file . close ( ) ; <nl> + return false ; <nl> + } catch ( const po : : validation_error & ex ) { <nl> + fprintf ( stderr , " % s \ n " , ex . what ( ) ) ; <nl> + output_option_description ( ex . get_option_name ( ) , options ) ; <nl> conf_file . close ( ) ; <nl> return false ; <nl> } catch ( . . . ) { <nl> MUST_USE bool parse_commands_deep ( int argc , char * argv [ ] , po : : variables_map * vm , <nl> } <nl> po : : notify ( * vm ) ; <nl> } catch ( const po : : multiple_occurrences & ex ) { <nl> - fprintf ( stderr , " flag specified too many times \ n " ) ; <nl> + fprintf ( stderr , " % s flag specified too many times \ n " , ex . get_option_name ( ) . c_str ( ) ) ; <nl> + output_option_description ( ex . get_option_name ( ) , options ) ; <nl> + return false ; <nl> + } catch ( const po : : required_option & ex ) { <nl> + fprintf ( stderr , " % s \ n " , ex . what ( ) ) ; <nl> + output_option_description ( ex . get_option_name ( ) , options ) ; <nl> + return false ; <nl> + } catch ( const po : : validation_error & ex ) { <nl> + fprintf ( stderr , " % s \ n " , ex . what ( ) ) ; <nl> + output_option_description ( ex . get_option_name ( ) , options ) ; <nl> return false ; <nl> } <nl> return true ; <nl> mmm a / src / errors . hpp <nl> ppp b / src / errors . hpp <nl> release mode . * / <nl> # define THROWS_ONLY ( . . . ) throw ( __VA_ARGS__ ) <nl> # endif <nl> <nl> + / / This is a workaround for old versions of boost causing a compilation error <nl> + # include < boost / version . hpp > / / NOLINT ( build / include_order ) <nl> + # if ( BOOST_VERSION > = 104200 ) & & ( BOOST_VERSION < = 104399 ) <nl> + # include < boost / config . hpp > / / NOLINT ( build / include_order ) <nl> + # undef BOOST_HAS_RVALUE_REFS <nl> + # endif <nl> <nl> # endif / * ERRORS_HPP_ * / <nl>
|
Merge commit ' f1b9427 ' into jd_secondary_indexes
|
rethinkdb/rethinkdb
|
b8f94aafccc443133a58459542a16c73eed8112e
|
2013-03-09T02:11:36Z
|
mmm a / src / mongo / db / repl / repl_set_commands . cpp <nl> ppp b / src / mongo / db / repl / repl_set_commands . cpp <nl> <nl> # include " mongo / platform / basic . h " <nl> <nl> # include < boost / algorithm / string . hpp > <nl> - # include < fmt / format . h > <nl> <nl> # include " mongo / db / repl / repl_set_command . h " <nl> <nl> namespace repl { <nl> <nl> using std : : string ; <nl> using std : : stringstream ; <nl> - using namespace fmt : : literals ; <nl> <nl> static const std : : string kReplSetReconfigNss = " local . replset . reconfig " ; <nl> <nl> class CmdReplSetReconfig : public ReplSetCommand { <nl> / / We will check again after acquiring the repl mutex in processReplSetReconfig ( ) , in case <nl> / / of concurrent reconfigs . <nl> if ( ! parsedArgs . force ) { <nl> - / / Check primary before waiting . <nl> - auto memberState = replCoord - > getMemberState ( ) ; <nl> - uassert ( ErrorCodes : : NotMaster , <nl> - " replSetReconfig should only be run on PRIMARY , but my state is { } ; " _format ( <nl> - memberState . toString ( ) ) , <nl> - memberState . primary ( ) ) ; <nl> - <nl> / / Skip the waiting if the current config is from a force reconfig . <nl> auto oplogWait = replCoord - > getConfig ( ) . getConfigTerm ( ) ! = OpTime : : kUninitializedTerm ; <nl> auto status = replCoord - > awaitConfigCommitment ( opCtx , oplogWait ) ; <nl> class CmdReplSetReconfig : public ReplSetCommand { <nl> if ( status = = ErrorCodes : : MaxTimeMSExpired ) { <nl> / / Convert the error code to be more specific . <nl> uasserted ( ErrorCodes : : CurrentConfigNotCommittedYet , status . reason ( ) ) ; <nl> + } else if ( status = = ErrorCodes : : PrimarySteppedDown ) { <nl> + / / Return NotMaster since the command has no side effect yet . <nl> + status = { ErrorCodes : : NotMaster , status . reason ( ) } ; <nl> } <nl> uassertStatusOK ( status ) ; <nl> } <nl> mmm a / src / mongo / db / repl / replication_coordinator_impl . cpp <nl> ppp b / src / mongo / db / repl / replication_coordinator_impl . cpp <nl> <nl> # include " mongo / db / repl / replication_coordinator_impl . h " <nl> <nl> # include < algorithm > <nl> + # include < fmt / format . h > <nl> # include < functional > <nl> # include < limits > <nl> <nl> Counter64 userOpsRunning ; <nl> ServerStatusMetricField < Counter64 > displayUserOpsRunning ( <nl> " repl . stateTransition . userOperationsRunning " , & userOpsRunning ) ; <nl> <nl> + using namespace fmt : : literals ; <nl> + <nl> using CallbackArgs = executor : : TaskExecutor : : CallbackArgs ; <nl> using CallbackFn = executor : : TaskExecutor : : CallbackFn ; <nl> using CallbackHandle = executor : : TaskExecutor : : CallbackHandle ; <nl> Status ReplicationCoordinatorImpl : : doReplSetReconfig ( OperationContext * opCtx , <nl> return Status ( <nl> ErrorCodes : : NotMaster , <nl> str : : stream ( ) <nl> - < < " replSetReconfig should only be run on a writable PRIMARY . Current state is " <nl> + < < " Safe reconfig is only allowed on a writable PRIMARY . Current state is " <nl> < < _getMemberState_inlock ( ) . toString ( ) ) ; <nl> } <nl> auto topCoordTerm = _topCoord - > getTerm ( ) ; <nl> void ReplicationCoordinatorImpl : : _finishReplSetReconfig ( OperationContext * opCtx , <nl> Status ReplicationCoordinatorImpl : : awaitConfigCommitment ( OperationContext * opCtx , <nl> bool waitForOplogCommitment ) { <nl> stdx : : unique_lock < Latch > lk ( _mutex ) ; <nl> + / / Check writable primary before waiting . <nl> + if ( ! _readWriteAbility - > canAcceptNonLocalWrites ( lk ) ) { <nl> + return { <nl> + ErrorCodes : : PrimarySteppedDown , <nl> + " replSetReconfig should only be run on a writable PRIMARY . Current state { } ; " _format ( <nl> + _memberState . toString ( ) ) } ; <nl> + } <nl> auto configOplogCommitmentOpTime = _topCoord - > getConfigOplogCommitmentOpTime ( ) ; <nl> auto oplogWriteConcern = _getOplogCommitmentWriteConcern ( lk ) ; <nl> OpTime fakeOpTime ( Timestamp ( 1 , 1 ) , _topCoord - > getTerm ( ) ) ; <nl> Status ReplicationCoordinatorImpl : : awaitConfigCommitment ( OperationContext * opCtx <nl> LOGV2 ( 4508702 , " Waiting for the current config to propagate to a majority of nodes . " ) ; <nl> StatusAndDuration configAwaitStatus = <nl> awaitReplication ( opCtx , fakeOpTime , _getConfigReplicationWriteConcern ( ) ) ; <nl> + <nl> + logv2 : : DynamicAttributes attr ; <nl> + attr . add ( " configVersion " , currConfig . getConfigVersion ( ) ) ; <nl> + attr . add ( " configTerm " , currConfig . getConfigTerm ( ) ) ; <nl> + attr . add ( " configWaitDuration " , configAwaitStatus . duration ) ; <nl> if ( ! configAwaitStatus . status . isOK ( ) ) { <nl> + LOGV2_WARNING ( 4714200 , " Current config hasn ' t propagated to a majority of nodes " , attr ) ; <nl> std : : stringstream ss ; <nl> ss < < " Current config with " < < currConfig . getConfigVersionAndTerm ( ) . toString ( ) <nl> < < " has not yet propagated to a majority of nodes " ; <nl> return configAwaitStatus . status . withContext ( ss . str ( ) ) ; <nl> } <nl> <nl> - logv2 : : DynamicAttributes attr ; <nl> - attr . add ( " configVersion " , currConfig . getConfigVersion ( ) ) ; <nl> - attr . add ( " configTerm " , currConfig . getConfigTerm ( ) ) ; <nl> - attr . add ( " configWaitDuration " , configAwaitStatus . duration ) ; <nl> - <nl> if ( ! waitForOplogCommitment ) { <nl> LOGV2 ( 4689401 , " Propagated current replica set config to a majority of nodes " , attr ) ; <nl> return Status : : OK ( ) ; <nl> Status ReplicationCoordinatorImpl : : awaitConfigCommitment ( OperationContext * opCtx <nl> " configOplogCommitmentOpTime " _attr = configOplogCommitmentOpTime ) ; <nl> StatusAndDuration oplogAwaitStatus = <nl> awaitReplication ( opCtx , configOplogCommitmentOpTime , oplogWriteConcern ) ; <nl> + attr . add ( " oplogWaitDuration " , oplogAwaitStatus . duration ) ; <nl> + attr . add ( " configOplogCommitmentOpTime " , configOplogCommitmentOpTime ) ; <nl> if ( ! oplogAwaitStatus . status . isOK ( ) ) { <nl> + LOGV2_WARNING ( 4714201 , <nl> + " Last committed optime in previous config isn ' t committed in current config " , <nl> + attr ) ; <nl> std : : stringstream ss ; <nl> ss < < " Last committed optime in the previous config ( " <nl> < < configOplogCommitmentOpTime . toString ( ) <nl> Status ReplicationCoordinatorImpl : : awaitConfigCommitment ( OperationContext * opCtx <nl> < < currConfig . getConfigVersionAndTerm ( ) . toString ( ) ; <nl> return oplogAwaitStatus . status . withContext ( ss . str ( ) ) ; <nl> } <nl> - attr . add ( " oplogWaitDuration " , oplogAwaitStatus . duration ) ; <nl> - attr . add ( " configOplogCommitmentOpTime " , configOplogCommitmentOpTime ) ; <nl> LOGV2 ( 4508701 , " The current replica set config is committed " , attr ) ; <nl> return Status : : OK ( ) ; <nl> } <nl> mmm a / src / mongo / db / repl / replication_coordinator_impl_reconfig_test . cpp <nl> ppp b / src / mongo / db / repl / replication_coordinator_impl_reconfig_test . cpp <nl> TEST_F ( ReplCoordTest , NodeReturnsNotMasterWhenReconfigReceivedWhileSecondary ) { <nl> ASSERT_TRUE ( result . obj ( ) . isEmpty ( ) ) ; <nl> } <nl> <nl> - TEST_F ( ReplCoordTest , NodeReturnsNotMasterWhenReconfigReceivedWhileInDrainMode ) { <nl> + TEST_F ( ReplCoordTest , NodeReturnsNotMasterWhenRunningSafeReconfigWhileInDrainMode ) { <nl> init ( ) ; <nl> <nl> assertStartSuccess ( BSON ( " _id " <nl> TEST_F ( ReplCoordTest , NodeReturnsNotMasterWhenReconfigReceivedWhileInDrainMode ) <nl> BSONObjBuilder result ; <nl> ReplSetReconfigArgs args ; <nl> args . force = false ; <nl> - ASSERT_EQUALS ( ErrorCodes : : NotMaster , <nl> - getReplCoord ( ) - > processReplSetReconfig ( opCtx . get ( ) , args , & result ) ) ; <nl> + auto status = getReplCoord ( ) - > processReplSetReconfig ( opCtx . get ( ) , args , & result ) ; <nl> + ASSERT_EQUALS ( ErrorCodes : : NotMaster , status ) ; <nl> + ASSERT_STRING_CONTAINS ( status . reason ( ) , " Safe reconfig is only allowed on a writable PRIMARY . " ) ; <nl> ASSERT_TRUE ( result . obj ( ) . isEmpty ( ) ) ; <nl> } <nl> <nl> + TEST_F ( ReplCoordTest , NodeReturnsNotMasterWhenReconfigCmdReceivedWhileInDrainMode ) { <nl> + init ( ) ; <nl> + <nl> + assertStartSuccess ( BSON ( " _id " <nl> + < < " mySet " <nl> + < < " version " < < 1 < < " members " <nl> + < < BSON_ARRAY ( BSON ( " _id " < < 0 < < " host " <nl> + < < " test1 : 1234 " ) <nl> + < < BSON ( " _id " < < 1 < < " host " <nl> + < < " test2 : 1234 " ) ) <nl> + < < " protocolVersion " < < 1 ) , <nl> + HostAndPort ( " test1 " , 1234 ) ) ; <nl> + replCoordSetMyLastAppliedOpTime ( OpTime ( Timestamp ( 100 , 1 ) , 0 ) , Date_t ( ) + Seconds ( 100 ) ) ; <nl> + replCoordSetMyLastDurableOpTime ( OpTime ( Timestamp ( 100 , 1 ) , 0 ) , Date_t ( ) + Seconds ( 100 ) ) ; <nl> + ASSERT_OK ( getReplCoord ( ) - > setFollowerMode ( MemberState : : RS_SECONDARY ) ) ; <nl> + ASSERT_TRUE ( getReplCoord ( ) - > getMemberState ( ) . secondary ( ) ) ; <nl> + <nl> + const auto opCtx = makeOperationContext ( ) ; <nl> + simulateSuccessfulV1ElectionWithoutExitingDrainMode ( <nl> + getReplCoord ( ) - > getElectionTimeout_forTest ( ) , opCtx . get ( ) ) ; <nl> + <nl> + ASSERT_EQUALS ( 1 , getReplCoord ( ) - > getTerm ( ) ) ; <nl> + ASSERT_TRUE ( getReplCoord ( ) - > getMemberState ( ) . primary ( ) ) ; <nl> + <nl> + / / Reconfig command first waits for config commitment and will get an error . <nl> + auto status = getReplCoord ( ) - > awaitConfigCommitment ( opCtx . get ( ) , true ) ; <nl> + ASSERT_EQUALS ( ErrorCodes : : PrimarySteppedDown , status ) ; <nl> + ASSERT_STRING_CONTAINS ( status . reason ( ) , " should only be run on a writable PRIMARY " ) ; <nl> + } <nl> + <nl> + <nl> TEST_F ( ReplCoordTest , NodeReturnsInvalidReplicaSetConfigWhenReconfigReceivedWithInvalidConfig ) { <nl> / / start up , become primary , receive uninitializable config <nl> assertStartSuccess ( BSON ( " _id " <nl>
|
SERVER - 47142 Don ' t allow non - force reconfig command in drain mode .
|
mongodb/mongo
|
31a60aab7a3d6b93407e0447b056c33f31a15991
|
2020-04-17T15:31:21Z
|
mmm a / plugins / net_plugin / net_plugin . cpp <nl> ppp b / plugins / net_plugin / net_plugin . cpp <nl> namespace eosio { <nl> if ( num = = peer_requested - > end_block ) { <nl> peer_requested . reset ( ) ; <nl> } <nl> - app ( ) . post ( priority : : low , [ num , trigger_send , c = shared_from_this ( ) ] ( ) { <nl> + app ( ) . post ( priority : : medium , [ num , trigger_send , c = shared_from_this ( ) ] ( ) { <nl> controller & cc = my_impl - > chain_plug - > chain ( ) ; <nl> signed_block_ptr sb = cc . fetch_block_by_number ( num ) ; <nl> if ( sb ) { <nl>
|
Get sync block at medium priority
|
EOSIO/eos
|
1e051295a05ebd0bfe497fb6b1c1dcd76560b128
|
2019-03-27T18:04:21Z
|
mmm a / xbmc / cores / VideoPlayer / DVDCodecs / Video / VDPAU . cpp <nl> ppp b / xbmc / cores / VideoPlayer / DVDCodecs / Video / VDPAU . cpp <nl> void CMixer : : FiniCycle ( ) <nl> / / Keep video surfaces for one 2 cycles longer than used <nl> / / by mixer . This avoids blocking in decoder . <nl> / / NVidia recommends num_ref + 5 <nl> - int surfToKeep = 5 ; <nl> + size_t surfToKeep = 5 ; <nl> <nl> if ( m_mixerInput . size ( ) > 0 & & <nl> ( m_mixerInput [ 0 ] . videoSurface = = VDP_INVALID_HANDLE ) ) <nl> mmm a / xbmc / cores / VideoPlayer / DVDFileInfo . cpp <nl> ppp b / xbmc / cores / VideoPlayer / DVDFileInfo . cpp <nl> bool CDVDFileInfo : : AddExternalSubtitleToDetails ( const std : : string & path , CStream <nl> if ( ! v . Open ( filename , STREAM_SOURCE_NONE , vobsubfile ) ) <nl> return false ; <nl> <nl> - int count = v . GetNrOfStreams ( ) ; <nl> - <nl> for ( CDemuxStream * stream : v . GetStreams ( ) ) <nl> { <nl> CStreamDetailSubtitle * dsub = new CStreamDetailSubtitle ( ) ; <nl>
|
fixed : Compile warnings
|
xbmc/xbmc
|
8575bdd10b2458525ddbdbedd73446eb6ae14ab3
|
2016-04-16T13:42:53Z
|
mmm a / ChangeLog . md <nl> ppp b / ChangeLog . md <nl> See docs / process . md for how version tagging works . <nl> <nl> Current Trunk <nl> mmmmmmmmmmmm - <nl> + - Pass linker flags dirctly to wasm - ld by default . We still filter out certain <nl> + flags explcitly . If there are other flags that it would be useful for us <nl> + to ignore we can add them to the list of ignored flags . <nl> - Optionally support 2GB + heap sizes . To do this we make the JS code have unsigned <nl> pointers ( we need all 32 bits in them now ) , which can slightly increase code <nl> size ( > > > instead of > > ) . This only happens when the heap size may be over <nl> Current Trunk <nl> higher value ( i . e . by default you do not get support for 2GB + heaps ) . <nl> See # 10601 <nl> - ` - - llvm - lto ` flag is now ignored when using the upstream llvm backend . <nl> - With the upstrema backend LTO is controlled via ` - flto ` . <nl> + With the upstream backend LTO is controlled via ` - flto ` . <nl> - Require format string for emscripten_log . <nl> - Program entry points without extensions are now shell scripts rather than <nl> python programs . See # 10729 . This means that ` python emcc ` no longer works . <nl> mmm a / emcc . py <nl> ppp b / emcc . py <nl> <nl> ' - whole - archive ' , ' - no - whole - archive ' <nl> ) <nl> <nl> - SUPPORTED_LLD_LINKER_FLAG_PREFIXES = ( <nl> - ' - l ' , <nl> - ' - L ' , <nl> - ' - - trace - symbol ' , <nl> - ' - debug ' , <nl> - ' - - export ' ) <nl> - <nl> - SUPPORTED_LLD_LINKER_FLAGS = ( <nl> - ' - - fatal - warnings ' , <nl> - ' - - no - check - features ' , <nl> - ' - - trace ' , <nl> - ' - - no - threads ' , <nl> - ' - mllvm ' <nl> - ) <nl> + # Maps to true if the the flag takes an argument <nl> + UNSUPPORTED_LLD_FLAGS = { <nl> + ' - - print - map ' : False , <nl> + ' - M ' : False , <nl> + ' - soname ' : True <nl> + } <nl> <nl> LIB_PREFIXES = ( ' ' , ' lib ' ) <nl> <nl> def get_all_js_library_funcs ( temp_files ) : <nl> return library_fns_list <nl> <nl> <nl> + def filter_link_flags ( flags , using_lld ) : <nl> + def is_supported ( f ) : <nl> + if using_lld : <nl> + for flag , takes_arg in UNSUPPORTED_LLD_FLAGS . items ( ) : <nl> + if f . startswith ( flag ) : <nl> + diagnostics . warning ( ' linkflags ' , ' ignoring unsupported linker flag : ` % s ` ' , f ) <nl> + return False , takes_arg <nl> + return True , False <nl> + else : <nl> + if f in SUPPORTED_LINKER_FLAGS : <nl> + return True , False <nl> + # Silently ignore - l / - L flags when not using lld . If using lld allow <nl> + # them to pass through the linker <nl> + if f . startswith ( ' - l ' ) or f . startswith ( ' - L ' ) : <nl> + return False , False <nl> + diagnostics . warning ( ' linkflags ' , ' ignoring unsupported linker flag : ` % s ` ' , f ) <nl> + return False , False <nl> + <nl> + results = [ ] <nl> + skip_next = False <nl> + for f in flags : <nl> + if skip_next : <nl> + skip_next = False <nl> + continue <nl> + keep , skip_next = is_supported ( f [ 1 ] ) <nl> + if keep : <nl> + results . append ( f ) <nl> + <nl> + return results <nl> + <nl> + <nl> # <nl> # Main run ( ) function <nl> # <nl> def check ( input_file ) : <nl> link_to_object = True <nl> <nl> using_lld = shared . Settings . WASM_BACKEND and not ( link_to_object and shared . Settings . LTO ) <nl> - <nl> - def is_supported_link_flag ( f ) : <nl> - if f in SUPPORTED_LINKER_FLAGS : <nl> - return True <nl> - if using_lld : <nl> - # Add flags here to allow - Wl , options to be passed all the way through <nl> - # to the linker . <nl> - if any ( f . startswith ( prefix ) for prefix in SUPPORTED_LLD_LINKER_FLAG_PREFIXES ) : <nl> - return True <nl> - if f in SUPPORTED_LLD_LINKER_FLAGS : <nl> - return True <nl> - else : <nl> - # Silently ignore - l / - L flags when not using lld . If using lld allow <nl> - # them to pass through the linker <nl> - if f . startswith ( ' - l ' ) or f . startswith ( ' - L ' ) : <nl> - return False <nl> - diagnostics . warning ( ' linkflags ' , ' ignoring unsupported linker flag : ` % s ` ' , f ) <nl> - return False <nl> - <nl> - link_flags = [ f for f in link_flags if is_supported_link_flag ( f [ 1 ] ) ] <nl> + link_flags = filter_link_flags ( link_flags , using_lld ) <nl> <nl> if shared . Settings . STACK_OVERFLOW_CHECK : <nl> if shared . Settings . MINIMAL_RUNTIME : <nl> mmm a / tests / test_other . py <nl> ppp b / tests / test_other . py <nl> def test_missing_stdlibs ( self ) : <nl> <nl> @ no_fastcomp ( ' lld - specific ' ) <nl> def test_supported_linker_flags ( self ) : <nl> - out = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . cpp ' ) , ' - Wl , waka ' ] , stderr = PIPE ) . stderr <nl> - self . assertContained ( ' warning : ignoring unsupported linker flag : ` waka ' , out ) <nl> + out = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . cpp ' ) , ' - Wl , - - print - map ' ] , stderr = PIPE ) . stderr <nl> + self . assertContained ( ' warning : ignoring unsupported linker flag : ` - - print - map ` ' , out ) <nl> + <nl> out = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . cpp ' ) , <nl> - ' - Wl , - - no - check - features , - - no - threads , - mllvm , - debug , - - trace , - - trace - symbol = main ' ] , stderr = PIPE ) . stderr <nl> + ' - Wl , - - no - check - features , - - no - threads , - mllvm , - debug ' ] , stderr = PIPE ) . stderr <nl> self . assertNotContained ( ' warning : ignoring unsupported linker flag ' , out ) <nl> <nl> + @ no_fastcomp ( ' lld - specific ' ) <nl> + def test_linker_flags_pass_through ( self ) : <nl> + err = self . expect_fail ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . cpp ' ) , ' - Wl , - - waka ' ] ) <nl> + self . assertContained ( ' wasm - ld : error : unknown argument : - - waka ' , err ) <nl> + <nl> def test_non_wasm_without_wasm_in_vm ( self ) : <nl> # Test that our non - wasm output does not depend on wasm support in the vm . <nl> run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . cpp ' ) , ' - s ' , ' WASM = 0 ' ] ) <nl>
|
Allow linker flags to pass through to wasm - ld by default . ( )
|
emscripten-core/emscripten
|
35746b57929f4155507eb8fc73ba86d56944ee17
|
2020-03-27T00:45:57Z
|
mmm a / . travis . yml <nl> ppp b / . travis . yml <nl> jobs : <nl> - rm - rf " $ { HOME } / . cache / bazel / _bazel_ $ { USER } / install " <nl> - rm - rf " / apollo / data / core " <nl> - stage : stage - 02 <nl> + env : <nl> + - JOB = cibuild <nl> script : <nl> - . / docker / scripts / dev_start . sh - t dev - x86_64 - 20181001_1754 - ci <nl> - - . / apollo_docker . sh cibuild <nl> + - . / apollo_docker . sh $ { JOB } <nl> - rm - rf " $ { HOME } / . cache / bazel / _bazel_ $ { USER } / install " <nl> - rm - rf " / apollo / data / core " <nl> + - # stage : stage - 02 <nl> + env : <nl> + - JOB = citest <nl> script : <nl> - . / docker / scripts / dev_start . sh - t dev - x86_64 - 20181001_1754 - ci <nl> - - . / apollo_docker . sh citest <nl> + - . / apollo_docker . sh $ { JOB } <nl> - rm - rf " $ { HOME } / . cache / bazel / _bazel_ $ { USER } / install " <nl> - rm - rf " / apollo / data / core " <nl> notifications : <nl>
|
Update . travis . yml
|
ApolloAuto/apollo
|
d12676da0d0aab8b34d57f566be880359ecddac2
|
2018-10-03T16:48:35Z
|
mmm a / src / builtins / builtins - string . cc <nl> ppp b / src / builtins / builtins - string . cc <nl> V8_WARN_UNUSED_RESULT static Object * ConvertCase ( <nl> / / character is also ASCII . This is currently the case , but it <nl> / / might break in the future if we implement more context and locale <nl> / / dependent upper / lower conversions . <nl> - if ( s - > IsOneByteRepresentationUnderneath ( ) ) { <nl> + if ( String : : IsOneByteRepresentationUnderneath ( * s ) ) { <nl> / / Same length as input . <nl> Handle < SeqOneByteString > result = <nl> isolate - > factory ( ) - > NewRawOneByteString ( length ) . ToHandleChecked ( ) ; <nl> mmm a / src / conversions . cc <nl> ppp b / src / conversions . cc <nl> class StringToIntHelper { <nl> <nl> bool IsOneByte ( ) const { <nl> return raw_one_byte_subject_ ! = nullptr | | <nl> - subject_ - > IsOneByteRepresentationUnderneath ( ) ; <nl> + String : : IsOneByteRepresentationUnderneath ( * subject_ ) ; <nl> } <nl> <nl> Vector < const uint8_t > GetOneByteVector ( ) { <nl> mmm a / src / json - stringifier . cc <nl> ppp b / src / json - stringifier . cc <nl> void JsonStringifier : : SerializeDeferredKey ( bool deferred_comma , <nl> void JsonStringifier : : SerializeString ( Handle < String > object ) { <nl> object = String : : Flatten ( isolate_ , object ) ; <nl> if ( builder_ . CurrentEncoding ( ) = = String : : ONE_BYTE_ENCODING ) { <nl> - if ( object - > IsOneByteRepresentationUnderneath ( ) ) { <nl> + if ( String : : IsOneByteRepresentationUnderneath ( * object ) ) { <nl> SerializeString_ < uint8_t , uint8_t > ( object ) ; <nl> } else { <nl> builder_ . ChangeEncoding ( ) ; <nl> SerializeString ( object ) ; <nl> } <nl> } else { <nl> - if ( object - > IsOneByteRepresentationUnderneath ( ) ) { <nl> + if ( String : : IsOneByteRepresentationUnderneath ( * object ) ) { <nl> SerializeString_ < uint8_t , uc16 > ( object ) ; <nl> } else { <nl> SerializeString_ < uc16 , uc16 > ( object ) ; <nl> mmm a / src / objects . cc <nl> ppp b / src / objects . cc <nl> MaybeHandle < String > EscapeRegExpSource ( Isolate * isolate , <nl> Handle < String > source ) { <nl> DCHECK ( source - > IsFlat ( ) ) ; <nl> if ( source - > length ( ) = = 0 ) return isolate - > factory ( ) - > query_colon_string ( ) ; <nl> - bool one_byte = source - > IsOneByteRepresentationUnderneath ( ) ; <nl> + bool one_byte = String : : IsOneByteRepresentationUnderneath ( * source ) ; <nl> int escapes = one_byte ? CountRequiredEscapes < uint8_t > ( source ) <nl> : CountRequiredEscapes < uc16 > ( source ) ; <nl> if ( escapes = = 0 ) return source ; <nl> mmm a / src / objects / string - inl . h <nl> ppp b / src / objects / string - inl . h <nl> bool String : : IsTwoByteRepresentation ( ) const { <nl> return ( type & kStringEncodingMask ) = = kTwoByteStringTag ; <nl> } <nl> <nl> - bool String : : IsOneByteRepresentationUnderneath ( ) { <nl> - uint32_t type = map ( ) - > instance_type ( ) ; <nl> - STATIC_ASSERT ( kIsIndirectStringTag ! = 0 ) ; <nl> - STATIC_ASSERT ( ( kIsIndirectStringMask & kStringEncodingMask ) = = 0 ) ; <nl> - DCHECK ( IsFlat ( ) ) ; <nl> - switch ( type & ( kIsIndirectStringMask | kStringEncodingMask ) ) { <nl> - case kOneByteStringTag : <nl> - return true ; <nl> - case kTwoByteStringTag : <nl> - return false ; <nl> - default : / / Cons , sliced , thin , strings need to go deeper . <nl> - return GetUnderlying ( ) - > IsOneByteRepresentationUnderneath ( ) ; <nl> - } <nl> - } <nl> - <nl> - bool String : : IsTwoByteRepresentationUnderneath ( ) { <nl> - uint32_t type = map ( ) - > instance_type ( ) ; <nl> - STATIC_ASSERT ( kIsIndirectStringTag ! = 0 ) ; <nl> - STATIC_ASSERT ( ( kIsIndirectStringMask & kStringEncodingMask ) = = 0 ) ; <nl> - DCHECK ( IsFlat ( ) ) ; <nl> - switch ( type & ( kIsIndirectStringMask | kStringEncodingMask ) ) { <nl> - case kOneByteStringTag : <nl> - return false ; <nl> - case kTwoByteStringTag : <nl> - return true ; <nl> - default : / / Cons , sliced , thin , strings need to go deeper . <nl> - return GetUnderlying ( ) - > IsTwoByteRepresentationUnderneath ( ) ; <nl> + bool String : : IsOneByteRepresentationUnderneath ( String string ) { <nl> + while ( true ) { <nl> + uint32_t type = string . map ( ) - > instance_type ( ) ; <nl> + STATIC_ASSERT ( kIsIndirectStringTag ! = 0 ) ; <nl> + STATIC_ASSERT ( ( kIsIndirectStringMask & kStringEncodingMask ) = = 0 ) ; <nl> + DCHECK ( string . IsFlat ( ) ) ; <nl> + switch ( type & ( kIsIndirectStringMask | kStringEncodingMask ) ) { <nl> + case kOneByteStringTag : <nl> + return true ; <nl> + case kTwoByteStringTag : <nl> + return false ; <nl> + default : / / Cons , sliced , thin , strings need to go deeper . <nl> + string = string . GetUnderlying ( ) ; <nl> + } <nl> } <nl> } <nl> <nl> mmm a / src / objects / string . h <nl> ppp b / src / objects / string . h <nl> class String : public Name { <nl> <nl> / / Cons and slices have an encoding flag that may not represent the actual <nl> / / encoding of the underlying string . This is taken into account here . <nl> - / / Requires : this - > IsFlat ( ) <nl> - inline bool IsOneByteRepresentationUnderneath ( ) ; <nl> - inline bool IsTwoByteRepresentationUnderneath ( ) ; <nl> + / / This function is static because that helps it get inlined . <nl> + / / Requires : string . IsFlat ( ) <nl> + static inline bool IsOneByteRepresentationUnderneath ( String string ) ; <nl> <nl> / / NOTE : this should be considered only a hint . False negatives are <nl> / / possible . <nl> mmm a / src / regexp / jsregexp . cc <nl> ppp b / src / regexp / jsregexp . cc <nl> int RegExpImpl : : IrregexpPrepare ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> DCHECK ( subject - > IsFlat ( ) ) ; <nl> <nl> / / Check representation of the underlying storage . <nl> - bool is_one_byte = subject - > IsOneByteRepresentationUnderneath ( ) ; <nl> + bool is_one_byte = String : : IsOneByteRepresentationUnderneath ( * subject ) ; <nl> if ( ! EnsureCompiledIrregexp ( isolate , regexp , subject , is_one_byte ) ) return - 1 ; <nl> <nl> # ifdef V8_INTERPRETED_REGEXP <nl> int RegExpImpl : : IrregexpExecRaw ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> DCHECK_LE ( index , subject - > length ( ) ) ; <nl> DCHECK ( subject - > IsFlat ( ) ) ; <nl> <nl> - bool is_one_byte = subject - > IsOneByteRepresentationUnderneath ( ) ; <nl> + bool is_one_byte = String : : IsOneByteRepresentationUnderneath ( * subject ) ; <nl> <nl> # ifndef V8_INTERPRETED_REGEXP <nl> DCHECK ( output_size > = ( IrregexpNumberOfCaptures ( * irregexp ) + 1 ) * 2 ) ; <nl> int RegExpImpl : : IrregexpExecRaw ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> / / being internal and external , and even between being Latin1 and UC16 , <nl> / / but the characters are always the same ) . <nl> IrregexpPrepare ( isolate , regexp , subject ) ; <nl> - is_one_byte = subject - > IsOneByteRepresentationUnderneath ( ) ; <nl> + is_one_byte = String : : IsOneByteRepresentationUnderneath ( * subject ) ; <nl> } while ( true ) ; <nl> UNREACHABLE ( ) ; <nl> # else / / V8_INTERPRETED_REGEXP <nl> mmm a / src / regexp / regexp - macro - assembler . cc <nl> ppp b / src / regexp / regexp - macro - assembler . cc <nl> int NativeRegExpMacroAssembler : : CheckStackGuardState ( <nl> HandleScope handles ( isolate ) ; <nl> Handle < Code > code_handle ( re_code , isolate ) ; <nl> Handle < String > subject_handle ( String : : cast ( ObjectPtr ( * subject ) ) , isolate ) ; <nl> - bool is_one_byte = subject_handle - > IsOneByteRepresentationUnderneath ( ) ; <nl> + bool is_one_byte = String : : IsOneByteRepresentationUnderneath ( * subject_handle ) ; <nl> <nl> StackLimitCheck check ( isolate ) ; <nl> bool js_has_overflowed = check . JsHasOverflowed ( ) ; <nl> int NativeRegExpMacroAssembler : : CheckStackGuardState ( <nl> / / If we continue , we need to update the subject string addresses . <nl> if ( return_value = = 0 ) { <nl> / / String encoding might have changed . <nl> - if ( subject_handle - > IsOneByteRepresentationUnderneath ( ) ! = is_one_byte ) { <nl> + if ( String : : IsOneByteRepresentationUnderneath ( * subject_handle ) ! = <nl> + is_one_byte ) { <nl> / / If we changed between an LATIN1 and an UC16 string , the specialized <nl> / / code cannot be used , and we need to restart regexp matching from <nl> / / scratch ( including , potentially , compiling a new version of the code ) . <nl> mmm a / src / uri . cc <nl> ppp b / src / uri . cc <nl> static MaybeHandle < String > EscapePrivate ( Isolate * isolate , <nl> MaybeHandle < String > Uri : : Escape ( Isolate * isolate , Handle < String > string ) { <nl> Handle < String > result ; <nl> string = String : : Flatten ( isolate , string ) ; <nl> - return string - > IsOneByteRepresentationUnderneath ( ) <nl> + return String : : IsOneByteRepresentationUnderneath ( * string ) <nl> ? EscapePrivate < uint8_t > ( isolate , string ) <nl> : EscapePrivate < uc16 > ( isolate , string ) ; <nl> } <nl> MaybeHandle < String > Uri : : Escape ( Isolate * isolate , Handle < String > string ) { <nl> MaybeHandle < String > Uri : : Unescape ( Isolate * isolate , Handle < String > string ) { <nl> Handle < String > result ; <nl> string = String : : Flatten ( isolate , string ) ; <nl> - return string - > IsOneByteRepresentationUnderneath ( ) <nl> + return String : : IsOneByteRepresentationUnderneath ( * string ) <nl> ? UnescapePrivate < uint8_t > ( isolate , string ) <nl> : UnescapePrivate < uc16 > ( isolate , string ) ; <nl> } <nl> mmm a / test / cctest / test - strings . cc <nl> ppp b / test / cctest / test - strings . cc <nl> TEST ( Regress876759 ) { <nl> CHECK ( grandparent - > IsOneByteRepresentation ( ) ) ; <nl> CHECK ( parent - > IsTwoByteRepresentation ( ) ) ; <nl> CHECK ( sliced - > IsTwoByteRepresentation ( ) ) ; <nl> - / / The * Underneath versions return the correct representation . <nl> - CHECK ( sliced - > IsOneByteRepresentationUnderneath ( ) ) ; <nl> - CHECK ( ! sliced - > IsTwoByteRepresentationUnderneath ( ) ) ; <nl> + / / The * Underneath version returns the correct representation . <nl> + CHECK ( String : : IsOneByteRepresentationUnderneath ( * sliced ) ) ; <nl> } <nl> <nl> } / / namespace test_strings <nl>
|
Make String : : IsOneByteRepresentationUnderneath static
|
v8/v8
|
63d6b7509d22aad985e4eceb3092fea531fd94ff
|
2018-12-11T21:27:01Z
|
mmm a / x64_dbg_dbg / simplescript . cpp <nl> ppp b / x64_dbg_dbg / simplescript . cpp <nl> static int scriptIp = 0 ; <nl> static bool bAbort = false ; <nl> static bool bIsRunning = false ; <nl> <nl> - static SCRIPTBRANCHTYPE getbranchtype ( const char * text ) <nl> + static SCRIPTBRANCHTYPE scriptgetbranchtype ( const char * text ) <nl> { <nl> if ( ! strncmp ( text , " jmp " , 3 ) ) <nl> return scriptjmp ; <nl> static SCRIPTBRANCHTYPE getbranchtype ( const char * text ) <nl> return scriptnobranch ; <nl> } <nl> <nl> - static bool islabel ( const char * text ) <nl> + static bool scriptislabel ( const char * text ) <nl> { <nl> if ( ! strstr ( text , " " ) and ! strstr ( text , " , " ) and ! strstr ( text , " \ \ " ) and text [ strlen ( text ) - 1 ] = = ' : ' ) <nl> return true ; <nl> return false ; <nl> } <nl> <nl> - static bool createlinemap ( const char * filename ) <nl> + static int scriptlabelfind ( const char * labelname ) <nl> + { <nl> + int linecount = linemap . size ( ) ; <nl> + for ( int i = 0 ; i < linecount ; i + + ) <nl> + if ( linemap . at ( i ) . type = = linelabel & & ! strcmp ( linemap . at ( i ) . u . label , labelname ) ) <nl> + return i + 1 ; <nl> + return 0 ; <nl> + } <nl> + <nl> + static bool scriptcreatelinemap ( const char * filename ) <nl> { <nl> HANDLE hFile = CreateFileA ( filename , GENERIC_READ , FILE_SHARE_READ , 0 , OPEN_EXISTING , 0 , 0 ) ; <nl> if ( hFile = = INVALID_HANDLE_VALUE ) <nl> static bool createlinemap ( const char * filename ) <nl> cur . type = linecomment ; <nl> strcpy ( cur . u . comment , cur . raw ) ; <nl> } <nl> - else if ( islabel ( cur . raw ) ) / / label <nl> + else if ( scriptislabel ( cur . raw ) ) / / label <nl> { <nl> cur . type = linelabel ; <nl> strncpy ( cur . u . label , cur . raw , rawlen - 1 ) ; <nl> + int foundlabel = scriptlabelfind ( cur . u . label ) ; <nl> + if ( foundlabel ) / / label defined twice <nl> + { <nl> + char message [ 256 ] = " " ; <nl> + sprintf ( message , " Duplicate label \ " % s \ " detected on lines % d and % d ! " , cur . u . label , foundlabel , i + 1 ) ; <nl> + GuiScriptError ( 0 , message ) ; <nl> + linemap . clear ( ) ; <nl> + return false ; <nl> + } <nl> } <nl> - else if ( getbranchtype ( cur . raw ) ! = scriptnobranch ) / / branch <nl> + else if ( scriptgetbranchtype ( cur . raw ) ! = scriptnobranch ) / / branch <nl> { <nl> cur . type = linebranch ; <nl> - cur . u . branch . type = getbranchtype ( cur . raw ) ; <nl> + cur . u . branch . type = scriptgetbranchtype ( cur . raw ) ; <nl> int len = strlen ( cur . raw ) ; <nl> for ( int i = 0 ; i < len ; i + + ) <nl> if ( cur . raw [ i ] = = ' ' ) <nl> static bool createlinemap ( const char * filename ) <nl> linemap . at ( i ) = cur ; <nl> } <nl> linemapsize = linemap . size ( ) ; <nl> + for ( unsigned int i = 0 ; i < linemapsize ; i + + ) <nl> + { <nl> + LINEMAPENTRY cur = linemap . at ( i ) ; <nl> + if ( cur . type = = linebranch and ! scriptlabelfind ( cur . u . branch . branchlabel ) ) / / invalid branch label <nl> + { <nl> + char message [ 256 ] = " " ; <nl> + sprintf ( message , " Invalid branch label \ " % s \ " detected on line % d ! " , cur . u . branch . branchlabel , i + 1 ) ; <nl> + GuiScriptError ( 0 , message ) ; <nl> + linemap . clear ( ) ; <nl> + return false ; <nl> + } <nl> + } <nl> if ( linemap . at ( linemapsize - 1 ) . type = = linecomment or linemap . at ( linemapsize - 1 ) . type = = linelabel ) / / label / comment on the end <nl> { <nl> memset ( & entry , 0 , sizeof ( entry ) ) ; <nl> static CMDRESULT scriptinternalcmdexec ( const char * command ) <nl> return STATUS_CONTINUE ; <nl> } <nl> <nl> - static DWORD WINAPI runThread ( void * arg ) <nl> + static DWORD WINAPI scriptRunThread ( void * arg ) <nl> { <nl> int destline = ( int ) ( duint ) arg ; <nl> if ( ! destline or destline > ( int ) linemap . size ( ) ) / / invalid line <nl> static DWORD WINAPI runThread ( void * arg ) <nl> break ; <nl> case STATUS_EXIT : <nl> bContinue = false ; <nl> + scriptIp = scriptinternalstep ( 0 ) ; <nl> break ; <nl> } <nl> } <nl> else if ( cur . type = = linebranch ) / / branch <nl> { <nl> - bContinue = false ; <nl> - GuiScriptError ( scriptIp , " Branches are not yet supported . . . " ) ; <nl> + if ( cur . u . branch . type = = scriptjmp ) / / simple jump <nl> + { <nl> + scriptIp = scriptlabelfind ( cur . u . branch . branchlabel ) ; <nl> + } <nl> + else <nl> + { <nl> + bContinue = false ; <nl> + GuiScriptError ( scriptIp , " Branches are not yet supported . . . " ) ; <nl> + } <nl> } <nl> if ( scriptIp = = scriptinternalstep ( scriptIp ) ) / / end of script <nl> { <nl> void scriptload ( const char * filename ) <nl> scriptIp = 0 ; <nl> scriptbplist . clear ( ) ; / / clear breakpoints <nl> bAbort = false ; <nl> - if ( ! createlinemap ( filename ) ) <nl> + if ( ! scriptcreatelinemap ( filename ) ) <nl> return ; <nl> for ( unsigned int i = 0 ; i < linemap . size ( ) ; i + + ) / / add script lines <nl> GuiScriptAddLine ( linemap . at ( i ) . raw ) ; <nl> void scriptrun ( int destline ) <nl> if ( bIsRunning ) / / already running <nl> return ; <nl> bIsRunning = true ; <nl> - CreateThread ( 0 , 0 , runThread , ( void * ) ( duint ) destline , 0 , 0 ) ; <nl> + CreateThread ( 0 , 0 , scriptRunThread , ( void * ) ( duint ) destline , 0 , 0 ) ; <nl> } <nl> <nl> void scriptstep ( ) <nl> void scriptstep ( ) <nl> break ; <nl> case STATUS_EXIT : <nl> bContinue = false ; <nl> + scriptIp = scriptinternalstep ( 0 ) ; <nl> + GuiScriptSetIp ( scriptIp ) ; <nl> break ; <nl> } <nl> } <nl> else if ( cur . type = = linebranch ) / / branch <nl> { <nl> - bContinue = false ; <nl> - GuiScriptError ( scriptIp , " Branches are not yet supported . . . " ) ; <nl> + if ( cur . u . branch . type = = scriptjmp ) / / simple jump <nl> + { <nl> + scriptIp = scriptlabelfind ( cur . u . branch . branchlabel ) ; <nl> + } <nl> + else <nl> + { <nl> + bContinue = false ; <nl> + GuiScriptError ( scriptIp , " Branches are not yet supported . . . " ) ; <nl> + } <nl> } <nl> <nl> if ( ! bContinue ) <nl>
|
DBG : label checks
|
x64dbg/x64dbg
|
867914b7ea7fd64378bb20e8d8e397a2ffe462d1
|
2014-02-09T21:02:28Z
|
mmm a / include / swift / ABI / Metadata . h <nl> ppp b / include / swift / ABI / Metadata . h <nl> <nl> # include " llvm / Support / Casting . h " <nl> <nl> namespace swift { <nl> - <nl> template < unsigned PointerSize > <nl> struct RuntimeTarget ; <nl> <nl> class TargetTypeContextDescriptor <nl> <nl> llvm : : ArrayRef < GenericParamDescriptor > getGenericParams ( ) const ; <nl> <nl> - bool isSynthesizedRelatedEntity ( ) const { <nl> - return getTypeContextDescriptorFlags ( ) . isSynthesizedRelatedEntity ( ) ; <nl> - } <nl> - <nl> - / / / Return the tag used to discriminate declarations synthesized by the <nl> - / / / Clang importer and give them stable identities . <nl> - StringRef getSynthesizedDeclRelatedEntityTag ( ) const { <nl> - if ( ! isSynthesizedRelatedEntity ( ) ) <nl> - return { } ; <nl> - / / The tag name comes after the null terminator for the name . <nl> - const char * nameBegin = Name . get ( ) ; <nl> - auto * nameEnd = nameBegin + strlen ( nameBegin ) + 1 ; <nl> - return nameEnd ; <nl> - } <nl> - <nl> / / / Return the offset of the start of generic arguments in the nominal <nl> / / / type ' s metadata . The returned value is measured in sizeof ( void * ) . <nl> int32_t getGenericArgumentOffset ( ) const ; <nl> mmm a / include / swift / ABI / MetadataValues . h <nl> ppp b / include / swift / ABI / MetadataValues . h <nl> class TypeContextDescriptorFlags : public FlagSet < uint16_t > { <nl> MetadataInitialization = 1 , <nl> MetadataInitialization_width = 2 , <nl> <nl> - / / / The namespace of the imported declaration that gave rise to this type . <nl> - / / / Some languages ( most importantly , C / C + + / Objective - C ) have different <nl> - / / / symbol namespaces in which types can be declared ; for example , <nl> - / / / ` struct A ` and ` typedef . . . A ` can be declared in the same scope and <nl> - / / / resolve to unrelated types . When these declarations are imported , <nl> - / / / there are several possible ways to distinguish them in Swift , e . g . <nl> - / / / by implicitly renaming them ; however , the external name used for <nl> - / / / mangling and metadata must be stable and so is based on the original <nl> - / / / declared name . Therefore , in these languages , we privilege one <nl> - / / / symbol namespace as the default ( although which may depend on the <nl> - / / / type kind ) , and declarations from the other ( s ) must be marked in <nl> - / / / order to differentiate them . <nl> + / / / Set if the type has extended import information . <nl> / / / <nl> - / / / Meaningful for all type - descriptor kinds . <nl> - ImportNamespace = 3 , <nl> - ImportNamespace_width = 3 , <nl> - <nl> - / / / Set if the type is an importer - synthesized related entity . <nl> - / / / A related entity is an entity synthesized in response to an imported <nl> - / / / type which is not the type itself ; for example , when the importer <nl> - / / / sees an ObjC error domain , it creates an error - wrapper type ( a <nl> - / / / related entity ) and a Code enum ( not a related entity because it ' s <nl> - / / / exactly the original type ) . <nl> - / / / <nl> - / / / The name and import namespace ( together with the parent context ) <nl> - / / / identify the original declaration . <nl> + / / / If true , a sequence of strings follow the null terminator in the <nl> + / / / descriptor , terminated by an empty string ( i . e . by two null <nl> + / / / terminators in a row ) . See TypeImportInfo for the details of <nl> + / / / these strings and the order in which they appear . <nl> / / / <nl> - / / / If this flag is set , then after the null terminator for the type name <nl> - / / / is another null - terminated string containing the tag that discriminates <nl> - / / / the entity from other synthesized declarations associated with the <nl> - / / / same declaration . <nl> - IsSynthesizedRelatedEntity = 6 , <nl> + / / / Meaningful for all type - descriptor kinds . <nl> + HasImportInfo = 3 , <nl> <nl> - / / / Set if the context descriptor is includes metadata for dynamically <nl> - / / / constructing a class ' s vtables at metadata instantiation time . <nl> - / / / <nl> - / / / Only meaningful for class descriptors . <nl> - Class_HasVTable = 15 , <nl> <nl> - / / / Set if the context descriptor is for a class with resilient ancestry . <nl> + / / Type - specific flags : <nl> + <nl> + / / / The kind of reference that this class makes to its superclass <nl> + / / / descriptor . A TypeReferenceKind . <nl> / / / <nl> / / / Only meaningful for class descriptors . <nl> - Class_HasResilientSuperclass = 14 , <nl> + Class_SuperclassReferenceKind = 10 , <nl> + Class_SuperclassReferenceKind_width = 3 , <nl> <nl> / / / Whether the immediate class members in this metadata are allocated <nl> / / / at negative offsets . For now , we don ' t use this . <nl> Class_AreImmediateMembersNegative = 13 , <nl> <nl> - / / / The kind of reference that this class makes to its superclass <nl> - / / / descriptor . A TypeReferenceKind . <nl> + / / / Set if the context descriptor is for a class with resilient ancestry . <nl> / / / <nl> / / / Only meaningful for class descriptors . <nl> - Class_SuperclassReferenceKind = 10 , <nl> - Class_SuperclassReferenceKind_width = 3 , <nl> + Class_HasResilientSuperclass = 14 , <nl> + <nl> + / / / Set if the context descriptor is includes metadata for dynamically <nl> + / / / constructing a class ' s vtables at metadata instantiation time . <nl> + / / / <nl> + / / / Only meaningful for class descriptors . <nl> + Class_HasVTable = 15 , <nl> } ; <nl> <nl> public : <nl> class TypeContextDescriptorFlags : public FlagSet < uint16_t > { <nl> return getMetadataInitialization ( ) = = ForeignMetadataInitialization ; <nl> } <nl> <nl> - enum ImportNamespaceKind { <nl> - / / / The type comes the default namespace for its language . <nl> - DefaultNamespace = 0 , <nl> - <nl> - / / The behavior for C imported types is complicated in ways that don ' t <nl> - / / entirely make sense according to the design laid out in the comment <nl> - / / on the ImportNamespace field . The rules are basically : <nl> - / / - Classes are assumed to come from Objective - C by default . <nl> - / / ObjC classes are in the ordinary namespace in C . <nl> - / / - Protocols are assumed to come from Objective - C by default . <nl> - / / ObjC protocols are in their own namespace in C . <nl> - / / - Structs and enums seem to always get either CTag or CTypedef . <nl> - / / It would probably make more sense to assume they come from the <nl> - / / tag namespace in C and then just use CTypedef as an override . <nl> - <nl> - / / / The type comes from an imported C tag type . <nl> - CTag = 1 , <nl> - <nl> - / / / The type comes from an imported C typedef type . <nl> - CTypedef = 2 , <nl> - <nl> - / / We only have three bits here , so be judicious about adding new <nl> - / / namespaces . <nl> - } ; <nl> - <nl> - FLAGSET_DEFINE_FIELD_ACCESSORS ( ImportNamespace , <nl> - ImportNamespace_width , <nl> - ImportNamespaceKind , <nl> - getImportNamespace , <nl> - setImportNamespace ) <nl> - <nl> - bool isCTypedef ( ) const { <nl> - return getImportNamespace ( ) = = CTypedef ; <nl> - } <nl> - <nl> - FLAGSET_DEFINE_FLAG_ACCESSORS ( IsSynthesizedRelatedEntity , <nl> - isSynthesizedRelatedEntity , <nl> - setIsSynthesizedRelatedEntity ) <nl> + FLAGSET_DEFINE_FLAG_ACCESSORS ( HasImportInfo , hasImportInfo , setHasImportInfo ) <nl> <nl> FLAGSET_DEFINE_FLAG_ACCESSORS ( Class_HasVTable , <nl> class_hasVTable , <nl> new file mode 100644 <nl> index 000000000000 . . 535199f7a49c <nl> mmm / dev / null <nl> ppp b / include / swift / ABI / TypeIdentity . h <nl> <nl> + / / = = = mmm TypeIdentity . h - Identity info about imported types mmm - - * - C + + - * - = = / / <nl> + / / <nl> + / / This source file is part of the Swift . org open source project <nl> + / / <nl> + / / Copyright ( c ) 2014 - 2017 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See https : / / swift . org / LICENSE . txt for license information <nl> + / / See https : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / <nl> + / / This header declares structures useful for working with the identity of <nl> + / / a type , especially for imported types . <nl> + / / <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + # ifndef SWIFT_ABI_TYPEIDENTITY_H <nl> + # define SWIFT_ABI_TYPEIDENTITY_H <nl> + <nl> + # include " swift / Basic / LLVM . h " <nl> + <nl> + namespace swift { <nl> + template < class > class TargetTypeContextDescriptor ; <nl> + struct InProcess ; <nl> + using TypeContextDescriptor = TargetTypeContextDescriptor < InProcess > ; <nl> + <nl> + / / / The different components that can appear in a TypeImportInfo sequence . <nl> + / / / <nl> + / / / The declaration order here is the canonical order for these components <nl> + / / / in the sequence ; the sequence is ill - formed if they are out of order . <nl> + / / / <nl> + / / / Note that the ABI name ( or the ordinary formal name , which <nl> + / / / immediately precedes it ) , symbol namespace , and related entity <nl> + / / / name together form the identity of the TypeImportInfo . <nl> + enum class TypeImportComponent : char { <nl> + ABIName = ' N ' , <nl> + SymbolNamespace = ' S ' , <nl> + RelatedEntityName = ' R ' , <nl> + } ; <nl> + <nl> + namespace TypeImportSymbolNamespace { <nl> + <nl> + / / / A value for ` SymbolNamespace ` which indicates that this type came <nl> + / / / from a C ` typedef ` that was imported as a distinct type instead <nl> + / / / of a ` typealias ` . This can happen for reasons like : <nl> + / / / <nl> + / / / - the ` typedef ` was declared with the ` swift_wrapper ` attribute <nl> + / / / - the ` typedef ` is a CF type <nl> + constexpr static const char CTypedef [ ] = " t " ; <nl> + <nl> + } <nl> + <nl> + / / / A class containing information from the type - import info . <nl> + template < class StringType > <nl> + class TypeImportInfo { <nl> + public : <nl> + / / / The ABI name of the declaration , if different from the user - facing <nl> + / / / name . <nl> + StringType ABIName ; <nl> + <nl> + / / / Set if the type doesn ' t come from the default symbol namespace for <nl> + / / / its kind and source language . ( Source language can be determined <nl> + / / / from the parent context . ) <nl> + / / / <nl> + / / / Some languages ( most importantly , C / C + + / Objective - C ) have different <nl> + / / / symbol namespaces in which types can be declared ; for example , <nl> + / / / ` struct A ` and ` typedef . . . A ` can be declared in the same scope and <nl> + / / / resolve to unrelated types . When these declarations are imported , <nl> + / / / there are several possible ways to distinguish them in Swift , e . g . <nl> + / / / by implicitly renaming them ; however , the external name used for <nl> + / / / mangling and metadata must be stable and so is based on the original <nl> + / / / declared name . Therefore , in these languages , we privilege one <nl> + / / / symbol namespace as the default ( although which may depend on the <nl> + / / / type kind ) , and declarations from the other ( s ) must be marked in <nl> + / / / order to differentiate them . <nl> + / / / <nl> + / / / C , C + + , and Objective - C <nl> + / / / mmmmmmmmmmmmmmmmmmmmm - - <nl> + / / / <nl> + / / / C , C + + , and Objective - C have several different identifier namespaces <nl> + / / / that can declare types : the ordinary namespace ( ` typedef ` s and ObjC <nl> + / / / ` @ interface ` s ) , the tag namespace ( ` struct ` s , ` enum ` s , ` union ` s , and <nl> + / / / C + + ` class ` es ) , and the ObjC protocol namespace ( ObjC ` @ protocol ` s ) . <nl> + / / / The languages all forbid multiple types from being declared in a given <nl> + / / / scope and namespace mmm at least , they do within a translation unit , <nl> + / / / and for the most part we have to assume in Swift that that applies <nl> + / / / across translation units as well . <nl> + / / <nl> + / / / Swift ' s default symbol - namespace rules for C / C + + / ObjC are as follows : <nl> + / / / - Protocols are assumed to come from the ObjC protocol namespace . <nl> + / / / - Classes are assumed to come from the ordinary namespace ( as an <nl> + / / / Objective - C class would ) . <nl> + / / / - Structs and enums are assumed to come from the tag namespace <nl> + / / / ( as a C ` struct ` , ` union ` , or ` enum ` would ) . <nl> + / / ; <nl> + / / / Note that there are some special mangling rules for types imported <nl> + / / / from C tag types in addition to the symbol - namespace rules . <nl> + StringType SymbolNamespace ; <nl> + <nl> + / / / Set if the type is an importer - synthesized related entity . <nl> + / / / A related entity is an entity synthesized in response to an imported <nl> + / / / type which is not the type itself ; for example , when the importer <nl> + / / / sees an ObjC error domain , it creates an error - wrapper type ( a <nl> + / / / related entity ) and a ` Code ` enum ( not a related entity because it ' s <nl> + / / / exactly the original type ) . <nl> + / / / <nl> + / / / The name and import namespace ( together with the parent context ) <nl> + / / / identify the original declaration . <nl> + StringType RelatedEntityName ; <nl> + <nl> + / / / Attempt to collect information from the given info chunk . <nl> + / / / <nl> + / / / \ return true if collection was successful . <nl> + template < bool Asserting > <nl> + bool collect ( StringRef value ) { <nl> + # define check ( CONDITION , COMMENT ) \ <nl> + do { \ <nl> + if ( ! Asserting ) { \ <nl> + if ( ! ( CONDITION ) ) return false ; \ <nl> + } else { \ <nl> + assert ( ( CONDITION ) & & COMMENT ) ; \ <nl> + } \ <nl> + } while ( false ) <nl> + <nl> + check ( ! value . empty ( ) , " string was empty on entrance " ) ; <nl> + auto component = TypeImportComponent ( value [ 0 ] ) ; <nl> + value = value . drop_front ( 1 ) ; <nl> + <nl> + switch ( component ) { <nl> + # define case_setIfNonEmpty ( FIELD ) \ <nl> + case TypeImportComponent : : FIELD : \ <nl> + check ( ! value . empty ( ) , " incoming value of " # FIELD " was empty " ) ; \ <nl> + check ( FIELD . empty ( ) , # FIELD " was already set " ) ; \ <nl> + FIELD = value ; \ <nl> + return true ; \ <nl> + <nl> + case_setIfNonEmpty ( ABIName ) <nl> + case_setIfNonEmpty ( SymbolNamespace ) <nl> + case_setIfNonEmpty ( RelatedEntityName ) <nl> + <nl> + # undef case_setIfNonEmpty <nl> + # undef check <nl> + } <nl> + <nl> + / / Even with Asserting = true ( i . e . in the runtime ) , we do want to be <nl> + / / future - proof against new components . <nl> + return false ; <nl> + } <nl> + <nl> + / / / Append all the information in this structure to the given buffer , <nl> + / / / including all necessary internal and trailing ' \ 0 ' characters . <nl> + / / / The buffer is assumed to already contain the ' \ 0 ' - terminated <nl> + / / / user - facing name of the type . <nl> + template < class BufferTy > <nl> + void appendTo ( BufferTy & buffer ) const { <nl> + # define append ( FIELD ) \ <nl> + do { \ <nl> + if ( ! FIELD . empty ( ) ) { \ <nl> + buffer + = char ( TypeImportComponent : : FIELD ) ; \ <nl> + buffer + = FIELD ; \ <nl> + buffer + = ' \ 0 ' ; \ <nl> + } \ <nl> + } while ( false ) <nl> + <nl> + append ( ABIName ) ; <nl> + append ( SymbolNamespace ) ; <nl> + append ( RelatedEntityName ) ; <nl> + buffer + = ' \ 0 ' ; <nl> + <nl> + # undef append <nl> + } <nl> + } ; <nl> + <nl> + / / / Parsed information about the identity of a type . <nl> + class ParsedTypeIdentity { <nl> + public : <nl> + / / / The user - facing name of the type . <nl> + StringRef UserFacingName ; <nl> + <nl> + / / / The full identity of the type . <nl> + / / / Note that this may include interior ' \ 0 ' characters . <nl> + StringRef FullIdentity ; <nl> + <nl> + / / / Any extended information that type might have . <nl> + Optional < TypeImportInfo < StringRef > > ImportInfo ; <nl> + <nl> + / / / The ABI name of the type . <nl> + StringRef getABIName ( ) const { <nl> + if ( ImportInfo & & ! ImportInfo - > ABIName . empty ( ) ) <nl> + return ImportInfo - > ABIName ; <nl> + return UserFacingName ; <nl> + } <nl> + <nl> + bool isCTypedef ( ) const { <nl> + return ImportInfo & & <nl> + ImportInfo - > SymbolNamespace = = TypeImportSymbolNamespace : : CTypedef ; <nl> + } <nl> + <nl> + bool isAnyRelatedEntity ( ) const { <nl> + return ImportInfo & & ! ImportInfo - > RelatedEntityName . empty ( ) ; <nl> + } <nl> + <nl> + bool isRelatedEntity ( StringRef entityName ) const { <nl> + return ImportInfo & & ImportInfo - > RelatedEntityName = = entityName ; <nl> + } <nl> + <nl> + StringRef getRelatedEntityName ( ) const { <nl> + assert ( isAnyRelatedEntity ( ) ) ; <nl> + return ImportInfo - > RelatedEntityName ; <nl> + } <nl> + <nl> + static ParsedTypeIdentity parse ( const TypeContextDescriptor * type ) ; <nl> + } ; <nl> + <nl> + } / / end namespace swift <nl> + <nl> + # endif / * SWIFT_ABI_TYPEIDENTITY_H * / <nl> mmm a / include / swift / Remote / MetadataReader . h <nl> ppp b / include / swift / Remote / MetadataReader . h <nl> <nl> # include " swift / Basic / Defer . h " <nl> # include " swift / Basic / Range . h " <nl> # include " swift / Basic / LLVM . h " <nl> + # include " swift / ABI / TypeIdentity . h " <nl> # include " swift / Runtime / ExistentialContainer . h " <nl> # include " swift / Runtime / HeapObject . h " <nl> # include " swift / Runtime / Unreachable . h " <nl> class MetadataReader { <nl> std : : string nodeName ; <nl> std : : string relatedTag ; <nl> Demangle : : Node : : Kind nodeKind ; <nl> - <nl> + Optional < TypeImportInfo < std : : string > > importInfo ; <nl> + <nl> auto getTypeName = [ & ] ( ) - > bool { <nl> auto typeBuffer = <nl> reinterpret_cast < const TargetTypeContextDescriptor < Runtime > * > <nl> class MetadataReader { <nl> auto nameAddress = resolveRelativeField ( descriptor , typeBuffer - > Name ) ; <nl> if ( ! Reader - > readString ( RemoteAddress ( nameAddress ) , nodeName ) ) <nl> return false ; <nl> - <nl> - if ( typeBuffer - > isSynthesizedRelatedEntity ( ) ) { <nl> + <nl> + / / Read the TypeImportInfo if present . <nl> + if ( typeBuffer - > getTypeContextDescriptorFlags ( ) . hasImportInfo ( ) ) { <nl> + importInfo . emplace ( ) ; <nl> nameAddress + = nodeName . size ( ) + 1 ; <nl> - if ( ! Reader - > readString ( RemoteAddress ( nameAddress ) , relatedTag ) ) <nl> - return false ; <nl> + <nl> + while ( true ) { <nl> + / / Read the next string . <nl> + std : : string temp ; <nl> + if ( ! Reader - > readString ( RemoteAddress ( nameAddress ) , temp ) ) <nl> + return false ; <nl> + <nl> + / / If we read an empty string , we ' re done . <nl> + if ( temp . empty ( ) ) <nl> + break ; <nl> + <nl> + / / Advance past the string . <nl> + nameAddress + = temp . size ( ) + 1 ; <nl> + <nl> + / / Collect the import information . Ignore anything we don ' t <nl> + / / understand . <nl> + importInfo - > collect < / * asserting * / false > ( std : : move ( temp ) ) ; <nl> + } <nl> + <nl> + / / Ignore the original if we have an ABI name override . <nl> + if ( ! importInfo - > ABIName . empty ( ) ) <nl> + nodeName = std : : move ( importInfo - > ABIName ) ; <nl> } <nl> <nl> return true ; <nl> class MetadataReader { <nl> return nullptr ; <nl> } <nl> <nl> - / / Override the node kind if this was a Clang - imported type . <nl> - if ( isTypeContext ) { <nl> - auto typeFlags = <nl> - TypeContextDescriptorFlags ( descriptor - > Flags . getKindSpecificFlags ( ) ) ; <nl> - <nl> - if ( typeFlags . isCTypedef ( ) ) <nl> + / / Override various aspects of the mangling for imported types . <nl> + if ( importInfo & & isCImportedContext ( parentDemangling ) ) { <nl> + if ( importInfo - > SymbolNamespace = = TypeImportSymbolNamespace : : CTypedef ) <nl> nodeKind = Demangle : : Node : : Kind : : TypeAlias ; <nl> <nl> - / / As a special case , always use the struct mangling for C - imported <nl> - / / value types . <nl> - else if ( nodeKind = = Demangle : : Node : : Kind : : Enum & & <nl> - ! typeFlags . isSynthesizedRelatedEntity ( ) & & <nl> - isCImportedContext ( parentDemangling ) ) <nl> + / / As a special case , use the struct mangling for C - imported value <nl> + / / types that don ' t have a special namespace and aren ' t a related <nl> + / / entity . <nl> + / / <nl> + / / This should be kept in sync with the AST mangler and with <nl> + / / _isCImportedTagType in the runtime . <nl> + else if ( importInfo - > SymbolNamespace . empty ( ) & & <nl> + importInfo - > RelatedEntityName . empty ( ) & & <nl> + nodeKind = = Demangle : : Node : : Kind : : Enum ) <nl> nodeKind = Demangle : : Node : : Kind : : Structure ; <nl> } <nl> <nl> auto nameNode = nodeFactory . createNode ( Node : : Kind : : Identifier , <nl> std : : move ( nodeName ) ) ; <nl> - if ( ! relatedTag . empty ( ) ) { <nl> + if ( importInfo & & ! importInfo - > RelatedEntityName . empty ( ) ) { <nl> auto relatedNode = <nl> - nodeFactory . createNode ( Node : : Kind : : RelatedEntityDeclName , relatedTag ) ; <nl> + nodeFactory . createNode ( Node : : Kind : : RelatedEntityDeclName , <nl> + std : : move ( importInfo - > RelatedEntityName ) ) ; <nl> relatedNode - > addChild ( nameNode , nodeFactory ) ; <nl> nameNode = relatedNode ; <nl> } <nl> mmm a / lib / IRGen / GenMeta . cpp <nl> ppp b / lib / IRGen / GenMeta . cpp <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> # include " swift / ABI / MetadataValues . h " <nl> + # include " swift / ABI / TypeIdentity . h " <nl> # include " swift / AST / ASTContext . h " <nl> # include " swift / AST / ASTMangler . h " <nl> # include " swift / AST / CanTypeVisitor . h " <nl> namespace { <nl> RequireMetadata_t HasMetadata ; <nl> TypeContextDescriptorFlags : : MetadataInitializationKind <nl> MetadataInitialization ; <nl> + <nl> + StringRef UserFacingName ; <nl> + Optional < TypeImportInfo < std : : string > > ImportInfo ; <nl> <nl> using super : : IGM ; <nl> using super : : B ; <nl> namespace { <nl> } <nl> <nl> void layout ( ) { <nl> + asImpl ( ) . computeIdentity ( ) ; <nl> + <nl> super : : layout ( ) ; <nl> asImpl ( ) . addName ( ) ; <nl> asImpl ( ) . addAccessFunction ( ) ; <nl> namespace { <nl> asImpl ( ) . addGenericSignature ( ) ; <nl> asImpl ( ) . maybeAddMetadataInitialization ( ) ; <nl> } <nl> - <nl> - void addName ( ) { <nl> - SmallString < 32 > nameBuf ; <nl> - StringRef name ; <nl> <nl> - / / Use the original name with tag for synthesized decls . The tag comes <nl> - / / after the null terminator for the name . <nl> + / / / Fill out all the aspects of the type identity . <nl> + void computeIdentity ( ) { <nl> + / / Remember the user - facing name . <nl> + UserFacingName = Type - > getName ( ) . str ( ) ; <nl> + <nl> + / / For related entities , set the original type name as the ABI name <nl> + / / and remember the related entity tag . <nl> + StringRef abiName ; <nl> if ( auto * synthesizedTypeAttr = <nl> Type - > getAttrs ( ) <nl> . template getAttribute < ClangImporterSynthesizedTypeAttr > ( ) ) { <nl> - nameBuf . append ( synthesizedTypeAttr - > originalTypeName ) ; <nl> - nameBuf . push_back ( ' \ 0 ' ) ; <nl> - nameBuf . append ( synthesizedTypeAttr - > getManglingName ( ) ) ; <nl> - <nl> - name = nameBuf ; <nl> - / / Try to use the Clang name if there is one . <nl> - } else if ( auto namedClangDecl = <nl> + abiName = synthesizedTypeAttr - > originalTypeName ; <nl> + <nl> + getMutableImportInfo ( ) . RelatedEntityName = <nl> + synthesizedTypeAttr - > getManglingName ( ) ; <nl> + <nl> + / / Otherwise , if this was imported from a Clang declaration , use that <nl> + / / declaration ' s name as the ABI name . <nl> + } else if ( auto clangDecl = <nl> Mangle : : ASTMangler : : getClangDeclForMangling ( Type ) ) { <nl> - name = namedClangDecl - > getName ( ) ; <nl> - } else { <nl> - name = Type - > getName ( ) . str ( ) ; <nl> + abiName = clangDecl - > getName ( ) ; <nl> + <nl> + / / Typedefs and compatibility aliases that have been promoted to <nl> + / / their own nominal types need to be marked specially . <nl> + if ( isa < clang : : TypedefNameDecl > ( clangDecl ) | | <nl> + isa < clang : : ObjCCompatibleAliasDecl > ( clangDecl ) ) { <nl> + getMutableImportInfo ( ) . SymbolNamespace = <nl> + TypeImportSymbolNamespace : : CTypedef ; <nl> + } <nl> + } <nl> + <nl> + / / If the ABI name differs from the user - facing name , add it as <nl> + / / an override . <nl> + if ( ! abiName . empty ( ) & & abiName ! = UserFacingName ) { <nl> + getMutableImportInfo ( ) . ABIName = abiName ; <nl> + } <nl> + } <nl> + <nl> + / / / Get the mutable import info . Note that calling this method itself <nl> + / / / changes the code to cause it to be used , so don ' t set it unless <nl> + / / / you ' re about to write something into it . <nl> + TypeImportInfo < std : : string > & getMutableImportInfo ( ) { <nl> + if ( ! ImportInfo ) <nl> + ImportInfo . emplace ( ) ; <nl> + return * ImportInfo ; <nl> + } <nl> + <nl> + void addName ( ) { <nl> + SmallString < 32 > name ; <nl> + name + = UserFacingName ; <nl> + <nl> + / / Collect the import info if present . <nl> + if ( ImportInfo ) { <nl> + name + = ' \ 0 ' ; <nl> + ImportInfo - > appendTo ( name ) ; <nl> + <nl> + / / getAddrOfGlobalString will add its own null terminator , so pop <nl> + / / off the second one . <nl> + assert ( name . back ( ) = = ' \ 0 ' ) ; <nl> + name . pop_back ( ) ; <nl> + assert ( name . back ( ) = = ' \ 0 ' ) ; <nl> } <nl> <nl> auto nameStr = IGM . getAddrOfGlobalString ( name , <nl> namespace { <nl> setMetadataInitializationKind ( flags ) ; <nl> } <nl> <nl> - / / / Flags to indicate Clang - imported declarations so we mangle them <nl> - / / / consistently at runtime . <nl> void setClangImportedFlags ( TypeContextDescriptorFlags & flags ) { <nl> - if ( Type - > getAttrs ( ) <nl> - . template getAttribute < ClangImporterSynthesizedTypeAttr > ( ) ) { <nl> - flags . setIsSynthesizedRelatedEntity ( true ) ; <nl> - } <nl> - <nl> - if ( auto clangDecl = Mangle : : ASTMangler : : getClangDeclForMangling ( Type ) ) { <nl> - if ( isa < clang : : TagDecl > ( clangDecl ) ) { <nl> - flags . setImportNamespace ( TypeContextDescriptorFlags : : CTag ) ; <nl> - } else if ( isa < clang : : TypedefNameDecl > ( clangDecl ) <nl> - | | isa < clang : : ObjCCompatibleAliasDecl > ( clangDecl ) ) { <nl> - flags . setImportNamespace ( TypeContextDescriptorFlags : : CTypedef ) ; <nl> - } <nl> + if ( ImportInfo ) { <nl> + flags . setHasImportInfo ( true ) ; <nl> } <nl> } <nl> <nl> mmm a / stdlib / public / runtime / Demangle . cpp <nl> ppp b / stdlib / public / runtime / Demangle . cpp <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> # include " swift / Basic / Range . h " <nl> + # include " swift / ABI / TypeIdentity . h " <nl> # include " swift / Runtime / Metadata . h " <nl> # include " swift / Runtime / Portability . h " <nl> # include " swift / Strings . h " <nl> swift : : _buildDemanglingForContext ( const ContextDescriptor * context , <nl> default : <nl> / / Form a type context demangling for type contexts . <nl> if ( auto type = llvm : : dyn_cast < TypeContextDescriptor > ( component ) ) { <nl> - auto name = type - > Name . get ( ) ; <nl> + auto identity = ParsedTypeIdentity : : parse ( type ) ; <nl> + <nl> Node : : Kind nodeKind ; <nl> Node : : Kind genericNodeKind ; <nl> switch ( kind ) { <nl> swift : : _buildDemanglingForContext ( const ContextDescriptor * context , <nl> <nl> / / Override the node kind if this is a Clang - imported type so we give it <nl> / / a stable mangling . <nl> - auto typeFlags = type - > getTypeContextDescriptorFlags ( ) ; <nl> - if ( typeFlags . isCTypedef ( ) ) { <nl> + if ( identity . isCTypedef ( ) ) { <nl> nodeKind = Node : : Kind : : TypeAlias ; <nl> } else if ( nodeKind ! = Node : : Kind : : Structure & & <nl> - isCImportedTagType ( type ) ) { <nl> + _isCImportedTagType ( type , identity ) ) { <nl> nodeKind = Node : : Kind : : Structure ; <nl> } <nl> <nl> auto typeNode = Dem . createNode ( nodeKind ) ; <nl> typeNode - > addChild ( node , Dem ) ; <nl> - auto nameNode = Dem . createNode ( Node : : Kind : : Identifier , name ) ; <nl> - if ( type - > isSynthesizedRelatedEntity ( ) ) { <nl> + auto nameNode = Dem . createNode ( Node : : Kind : : Identifier , <nl> + identity . getABIName ( ) ) ; <nl> + if ( identity . isAnyRelatedEntity ( ) ) { <nl> auto relatedName = Dem . createNode ( Node : : Kind : : RelatedEntityDeclName , <nl> - type - > getSynthesizedDeclRelatedEntityTag ( ) ) ; <nl> + identity . getRelatedEntityName ( ) ) ; <nl> relatedName - > addChild ( nameNode , Dem ) ; <nl> nameNode = relatedName ; <nl> } <nl> mmm a / stdlib / public / runtime / Metadata . cpp <nl> ppp b / stdlib / public / runtime / Metadata . cpp <nl> <nl> # include " swift / Basic / Lazy . h " <nl> # include " swift / Basic / Range . h " <nl> # include " swift / Demangling / Demangler . h " <nl> + # include " swift / ABI / TypeIdentity . h " <nl> # include " swift / Runtime / Casting . h " <nl> # include " swift / Runtime / ExistentialContainer . h " <nl> # include " swift / Runtime / HeapObject . h " <nl> namespace { <nl> StringRef Name ; <nl> public : <nl> explicit TypeContextIdentity ( const TypeContextDescriptor * type ) { <nl> - / / Use the name of the type context . <nl> - Name = type - > Name . get ( ) ; <nl> - <nl> - / / If this is a synthesized entity , include the related entity tag . <nl> - if ( type - > isSynthesizedRelatedEntity ( ) ) { <nl> - auto tag = type - > getSynthesizedDeclRelatedEntityTag ( ) ; <nl> - assert ( Name . end ( ) + 1 = = tag . begin ( ) ) ; <nl> - <nl> - / / The length computation needs to include the \ 0 at the <nl> - / / end of the name . <nl> - Name = StringRef ( Name . begin ( ) , Name . size ( ) + tag . size ( ) + 1 ) ; <nl> - } <nl> + Name = ParsedTypeIdentity : : parse ( type ) . FullIdentity ; <nl> } <nl> <nl> bool operator = = ( const TypeContextIdentity & other ) const { <nl> mmm a / stdlib / public / runtime / MetadataLookup . cpp <nl> ppp b / stdlib / public / runtime / MetadataLookup . cpp <nl> <nl> # include " swift / Demangling / Demangler . h " <nl> # include " swift / Demangling / TypeDecoder . h " <nl> # include " swift / Reflection / Records . h " <nl> + # include " swift / ABI / TypeIdentity . h " <nl> # include " swift / Runtime / Casting . h " <nl> # include " swift / Runtime / Concurrent . h " <nl> # include " swift / Runtime / HeapObject . h " <nl> static const TypeContextDescriptor * <nl> _findNominalTypeDescriptor ( Demangle : : NodePointer node , <nl> Demangle : : Demangler & Dem ) ; <nl> <nl> - bool swift : : isCImportedTagType ( const TypeContextDescriptor * type ) { <nl> + / / / Recognize imported tag types , which have a special mangling rule . <nl> + / / / <nl> + / / / This should be kept in sync with the AST mangler and with <nl> + / / / buildContextDescriptorMangling in MetadataReader . <nl> + bool swift : : _isCImportedTagType ( const TypeContextDescriptor * type , <nl> + const ParsedTypeIdentity & identity ) { <nl> / / Tag types are always imported as structs or enums . <nl> if ( type - > getKind ( ) ! = ContextDescriptorKind : : Enum & & <nl> type - > getKind ( ) ! = ContextDescriptorKind : : Struct ) <nl> return false ; <nl> <nl> / / Not a typedef imported as a nominal type . <nl> - if ( type - > getTypeContextDescriptorFlags ( ) . isCTypedef ( ) ) <nl> + if ( identity . isCTypedef ( ) ) <nl> return false ; <nl> <nl> / / Not a related entity . <nl> - if ( type - > isSynthesizedRelatedEntity ( ) ) <nl> + if ( identity . isAnyRelatedEntity ( ) ) <nl> return false ; <nl> <nl> / / Imported from C . <nl> return type - > Parent - > isCImportedContext ( ) ; <nl> } <nl> <nl> + ParsedTypeIdentity <nl> + ParsedTypeIdentity : : parse ( const TypeContextDescriptor * type ) { <nl> + ParsedTypeIdentity result ; <nl> + <nl> + / / The first component is the user - facing name and ( unless overridden ) <nl> + / / the ABI name . <nl> + StringRef component = type - > Name . get ( ) ; <nl> + result . UserFacingName = component ; <nl> + <nl> + / / If we don ' t have import info , we ' re done . <nl> + if ( ! type - > getTypeContextDescriptorFlags ( ) . hasImportInfo ( ) ) { <nl> + result . FullIdentity = result . UserFacingName ; <nl> + return result ; <nl> + } <nl> + <nl> + / / Otherwise , start parsing the import information . <nl> + result . ImportInfo . emplace ( ) ; <nl> + <nl> + / / The identity starts with the user - facing name . <nl> + const char * startOfIdentity = component . begin ( ) ; <nl> + const char * endOfIdentity = component . end ( ) ; <nl> + <nl> + # ifndef NDEBUG <nl> + enum { <nl> + AfterName , <nl> + AfterABIName , <nl> + AfterSymbolNamespace , <nl> + AfterRelatedEntityName , <nl> + AfterIdentity , <nl> + } stage = AfterName ; <nl> + # endif <nl> + <nl> + while ( true ) { <nl> + / / Parse the next component . If it ' s empty , we ' re done . <nl> + component = StringRef ( component . end ( ) + 1 ) ; <nl> + if ( component . empty ( ) ) break ; <nl> + <nl> + / / Update the identity bounds and assert that the identity <nl> + / / components are in the right order . <nl> + auto kind = TypeImportComponent ( component [ 0 ] ) ; <nl> + if ( kind = = TypeImportComponent : : ABIName ) { <nl> + # ifndef NDEBUG <nl> + assert ( stage < AfterABIName ) ; <nl> + stage = AfterABIName ; <nl> + assert ( result . UserFacingName ! = component . drop_front ( 1 ) & & <nl> + " user - facing name was same as the ABI name " ) ; <nl> + # endif <nl> + startOfIdentity = component . begin ( ) + 1 ; <nl> + endOfIdentity = component . end ( ) ; <nl> + } else if ( kind = = TypeImportComponent : : SymbolNamespace ) { <nl> + # ifndef NDEBUG <nl> + assert ( stage < AfterSymbolNamespace ) ; <nl> + stage = AfterSymbolNamespace ; <nl> + # endif <nl> + endOfIdentity = component . end ( ) ; <nl> + } else if ( kind = = TypeImportComponent : : RelatedEntityName ) { <nl> + # ifndef NDEBUG <nl> + assert ( stage < AfterRelatedEntityName ) ; <nl> + stage = AfterRelatedEntityName ; <nl> + # endif <nl> + endOfIdentity = component . end ( ) ; <nl> + } else { <nl> + # ifndef NDEBUG <nl> + / / Anything else is assumed to not be part of the identity . <nl> + stage = AfterIdentity ; <nl> + # endif <nl> + } <nl> + <nl> + / / Collect the component , whatever it is . <nl> + result . ImportInfo - > collect < / * asserting * / true > ( component ) ; <nl> + } <nl> + <nl> + assert ( stage ! = AfterName & & " no components ? " ) ; <nl> + <nl> + / / Record the full identity . <nl> + result . FullIdentity = <nl> + StringRef ( startOfIdentity , endOfIdentity - startOfIdentity ) ; <nl> + <nl> + return result ; <nl> + } <nl> + <nl> bool <nl> swift : : _contextDescriptorMatchesMangling ( const ContextDescriptor * context , <nl> Demangle : : NodePointer node ) { <nl> swift : : _contextDescriptorMatchesMangling ( const ContextDescriptor * context , <nl> <nl> default : <nl> if ( auto type = llvm : : dyn_cast < TypeContextDescriptor > ( context ) ) { <nl> + Optional < ParsedTypeIdentity > _identity ; <nl> + auto getIdentity = [ & ] ( ) - > const ParsedTypeIdentity & { <nl> + if ( _identity ) return * _identity ; <nl> + _identity = ParsedTypeIdentity : : parse ( type ) ; <nl> + return * _identity ; <nl> + } ; <nl> + <nl> switch ( node - > getKind ( ) ) { <nl> / / If the mangled name doesn ' t indicate a type kind , accept anything . <nl> / / Otherwise , try to match them up . <nl> swift : : _contextDescriptorMatchesMangling ( const ContextDescriptor * context , <nl> / / imported C tag types . This is necessary because we artificially <nl> / / make imported C tag types Kind : : Structure . <nl> if ( type - > getKind ( ) ! = ContextDescriptorKind : : Struct & & <nl> - ! isCImportedTagType ( type ) ) <nl> + ! _isCImportedTagType ( type , getIdentity ( ) ) ) <nl> return false ; <nl> break ; <nl> case Demangle : : Node : : Kind : : Class : <nl> swift : : _contextDescriptorMatchesMangling ( const ContextDescriptor * context , <nl> return false ; <nl> break ; <nl> case Demangle : : Node : : Kind : : TypeAlias : <nl> - if ( ! type - > getTypeContextDescriptorFlags ( ) . isCTypedef ( ) ) <nl> + if ( ! getIdentity ( ) . isCTypedef ( ) ) <nl> return false ; <nl> break ; <nl> <nl> swift : : _contextDescriptorMatchesMangling ( const ContextDescriptor * context , <nl> <nl> / / Declarations synthesized by the Clang importer get a small tag <nl> / / string in addition to their name . <nl> - if ( nameNode - > getKind ( ) = = Demangle : : Node : : Kind : : RelatedEntityDeclName ) { <nl> - if ( nameNode - > getText ( ) ! = type - > getSynthesizedDeclRelatedEntityTag ( ) ) <nl> + if ( nameNode - > getKind ( ) = = Demangle : : Node : : Kind : : RelatedEntityDeclName ) { <nl> + if ( ! getIdentity ( ) . isRelatedEntity ( nameNode - > getText ( ) ) ) <nl> return false ; <nl> <nl> nameNode = nameNode - > getChild ( 0 ) ; <nl> - } else if ( type - > isSynthesizedRelatedEntity ( ) ) { <nl> + } else if ( getIdentity ( ) . isAnyRelatedEntity ( ) ) { <nl> return false ; <nl> } <nl> <nl> swift : : _contextDescriptorMatchesMangling ( const ContextDescriptor * context , <nl> / / names . The runtime metadata for private declarations would be <nl> / / anonymized . <nl> if ( nameNode - > getKind ( ) = = Demangle : : Node : : Kind : : Identifier ) { <nl> - if ( nameNode - > getText ( ) ! = type - > Name . get ( ) ) <nl> + if ( nameNode - > getText ( ) ! = getIdentity ( ) . getABIName ( ) ) <nl> return false ; <nl> <nl> node = node - > getChild ( 0 ) ; <nl> mmm a / stdlib / public / runtime / Private . h <nl> ppp b / stdlib / public / runtime / Private . h <nl> <nl> # endif <nl> <nl> namespace swift { <nl> + class ParsedTypeIdentity ; <nl> <nl> class TypeReferenceOwnership { <nl> enum : uint8_t { <nl> class TypeInfo { <nl> } ; <nl> <nl> / / / Is the given type imported from a C tag type ? <nl> - bool isCImportedTagType ( const TypeContextDescriptor * type ) ; <nl> + bool _isCImportedTagType ( const TypeContextDescriptor * type , <nl> + const ParsedTypeIdentity & identity ) ; <nl> <nl> / / / Check whether a type conforms to a protocol . <nl> / / / <nl> new file mode 100644 <nl> index 000000000000 . . e93160911213 <nl> mmm / dev / null <nl> ppp b / test / IRGen / Inputs / error_domains . h <nl> <nl> + # define MY_ERROR_ENUM ( _type , _name , _domain ) \ <nl> + enum _name : _type _name ; \ <nl> + enum __attribute__ ( ( ns_error_domain ( _domain ) ) ) _name : _type <nl> + <nl> + @ class NSString ; <nl> + <nl> + extern NSString * const TagDomain1 ; <nl> + typedef MY_ERROR_ENUM ( int , TagError1 , TagDomain1 ) { <nl> + Badness <nl> + } ; <nl> + <nl> + extern NSString * const TagDomain2 ; <nl> + typedef MY_ERROR_ENUM ( int , TagError2 , TagDomain2 ) { <nl> + Sickness <nl> + } ; <nl> + <nl> + extern NSString * const TypedefDomain1 ; <nl> + typedef enum __attribute__ ( ( ns_error_domain ( TypedefDomain1 ) ) ) { <nl> + Wrongness <nl> + } TypedefError1 ; <nl> + <nl> + extern NSString * TypedefDomain2 ; <nl> + typedef enum __attribute__ ( ( ns_error_domain ( TypedefDomain2 ) ) ) { <nl> + Illness <nl> + } TypedefError2 ; <nl> mmm a / test / IRGen / Inputs / usr / include / module . map <nl> ppp b / test / IRGen / Inputs / usr / include / module . map <nl> module CoreFoundation { <nl> module ObjCInterop { <nl> header " ObjCInterop . h " <nl> } <nl> + <nl> + module error_domains { <nl> + header " error_domains . h " <nl> + } <nl> mmm a / test / IRGen / cf . sil <nl> ppp b / test / IRGen / cf . sil <nl> <nl> <nl> / / CHECK : @ " $ SSo17CCRefrigeratorRefaN " = linkonce_odr hidden constant < { { { . * } } } > < { i8 * * @ " $ SBOWV " , [ [ INT ] ] 16 , { { . * } } " $ SSo17CCRefrigeratorRefaMn " , [ [ TYPE ] ] * null , i8 * null } > <nl> <nl> - / / CHECK : [ [ MUTABLE_REFRIGERATOR_NAME : @ . * ] ] = private constant [ 25 x i8 ] c " CCMutableRefrigeratorRef \ 00 " <nl> + / / CHECK : [ [ MUTABLE_REFRIGERATOR_NAME : @ . * ] ] = private constant [ 52 x i8 ] c " CCMutableRefrigerator \ 00NCCMutableRefrigeratorRef \ 00St \ 00 \ 00 " <nl> <nl> / / CHECK - 64 : @ " $ SSo24CCMutableRefrigeratorRefaMn " = linkonce_odr hidden constant <nl> - / / - - is imported C typedef , foreign init , reflectable , is class , is nonunique <nl> - / / CHECK - 64 - SAME : < i32 0x0015_0010 > <nl> + / / - - is imported , foreign init , reflectable , is class , is nonunique <nl> + / / CHECK - 64 - SAME : < i32 0x000d_0010 > <nl> / / CHECK - 64 - SAME : [ [ MUTABLE_REFRIGERATOR_NAME ] ] <nl> / / CHECK - 64 - SAME : @ " $ SSo24CCMutableRefrigeratorRefaMa " <nl> / / CHECK - 64 - SAME : @ " $ SSo24CCMutableRefrigeratorRefaMr " <nl> new file mode 100644 <nl> index 000000000000 . . 38e84cd97464 <nl> mmm / dev / null <nl> ppp b / test / IRGen / related_entity . sil <nl> <nl> + / / RUN : % empty - directory ( % t ) <nl> + / / RUN : % { python } % utils / chex . py < % s > % t / checkfile <nl> + / / RUN : % target - swift - frontend ( mock - sdk : % clang - importer - sdk ) - enable - objc - interop - emit - ir - o - - primary - file % s - import - objc - header % S / Inputs / error_domains . h | % FileCheck % t / checkfile - - check - prefix = CHECK - - check - prefix = CHECK - % target - ptrsize - DINT = i % target - ptrsize <nl> + <nl> + sil_stage canonical <nl> + <nl> + import Swift <nl> + import Foundation <nl> + <nl> + sil public_external @ take_metatype : $ @ convention ( thin ) < T > ( @ thick T . Type ) - > ( ) <nl> + <nl> + sil @ use_metatypes : $ @ convention ( thin ) ( ) - > ( ) { <nl> + bb0 : <nl> + % take = function_ref @ take_metatype : $ @ convention ( thin ) < T > ( @ thick T . Type ) - > ( ) <nl> + <nl> + / / CHECK : [ [ TagError1_NAME : @ [ 0 - 9 ] + ] ] = private constant [ 14 x i8 ] c " TagError1 \ 00Re \ 00 \ 00 " <nl> + / / CHECK : @ " $ SSC9TagError1LeVMn " = linkonce_odr hidden constant <nl> + / / CHECK - SAME : < i32 0x000d_0011 > <nl> + / / CHECK - SAME : @ " $ SSCMXM " <nl> + / / CHECK - SAME : [ 14 x i8 ] * [ [ TagError1_NAME ] ] <nl> + % 0 = metatype $ @ thick TagError1 . Type <nl> + apply % take < TagError1 > ( % 0 ) : $ @ convention ( thin ) < T > ( @ thick T . Type ) - > ( ) <nl> + <nl> + / / CHECK : [ [ TagError2_NAME : @ [ 0 - 9 ] + ] ] = private constant [ 17 x i8 ] c " Code \ 00NTagError2 \ 00 \ 00 " <nl> + / / CHECK : @ " $ SSo9TagError2VMn " = linkonce_odr hidden constant <nl> + / / CHECK - SAME : < i32 0x000c_0012 > <nl> + / / CHECK - SAME : @ " $ SSoMXM " <nl> + / / CHECK - SAME : [ 17 x i8 ] * [ [ TagError2_NAME ] ] <nl> + % 1 = metatype $ @ thick TagError2 . Code . Type <nl> + apply % take < TagError2 . Code > ( % 1 ) : $ @ convention ( thin ) < T > ( @ thick T . Type ) - > ( ) <nl> + <nl> + / / CHECK : [ [ TypedefError1_NAME : @ [ 0 - 9 ] + ] ] = private constant [ 18 x i8 ] c " TypedefError1 \ 00RE \ 00 \ 00 " <nl> + / / CHECK : @ " $ SSC13TypedefError1LEVMn " = linkonce_odr hidden constant <nl> + / / CHECK - SAME : < i32 0x000d_0011 > <nl> + / / CHECK - SAME : @ " $ SSCMXM " <nl> + / / CHECK - SAME : [ 18 x i8 ] * [ [ TypedefError1_NAME ] ] <nl> + % 2 = metatype $ @ thick TypedefError1 . Type <nl> + apply % take < TypedefError1 > ( % 2 ) : $ @ convention ( thin ) < T > ( @ thick T . Type ) - > ( ) <nl> + <nl> + / / CHECK : [ [ TypedefError2Code_NAME : @ [ 0 - 9 ] + ] ] = private constant [ 24 x i8 ] c " Code \ 00NTypedefError2 \ 00St \ 00 \ 00 " <nl> + / / CHECK : @ " $ SSo13TypedefError2aMn " = linkonce_odr hidden constant <nl> + / / CHECK - SAME : < i32 0x000c_0012 > <nl> + / / CHECK - SAME : @ " $ SSoMXM " <nl> + / / CHECK - SAME : [ 24 x i8 ] * [ [ TypedefError2Code_NAME ] ] <nl> + % 3 = metatype $ @ thick TypedefError2 . Code . Type <nl> + apply % take < TypedefError2 . Code > ( % 3 ) : $ @ convention ( thin ) < T > ( @ thick T . Type ) - > ( ) <nl> + <nl> + % ret = tuple ( ) <nl> + return % ret : $ ( ) <nl> + } <nl>
|
Merge pull request from rjmccall / type - import - info
|
apple/swift
|
5d53766cd64fcf115bda1d33b09a3ce99dfee834
|
2018-08-02T02:02:12Z
|
mmm a / db / c . cc <nl> ppp b / db / c . cc <nl> void rocksdb_flush ( <nl> SaveError ( errptr , db - > rep - > Flush ( options - > rep ) ) ; <nl> } <nl> <nl> + void rocksdb_flush_cf ( <nl> + rocksdb_t * db , <nl> + const rocksdb_flushoptions_t * options , <nl> + rocksdb_column_family_handle_t * column_family , <nl> + char * * errptr ) { <nl> + SaveError ( errptr , db - > rep - > Flush ( options - > rep , column_family - > rep ) ) ; <nl> + } <nl> + <nl> void rocksdb_disable_file_deletions ( <nl> rocksdb_t * db , <nl> char * * errptr ) { <nl> mmm a / db / c_test . c <nl> ppp b / db / c_test . c <nl> int main ( int argc , char * * argv ) { <nl> rocksdb_put_cf ( db , woptions , handles [ 1 ] , " foo " , 3 , " hello " , 5 , & err ) ; <nl> CheckNoError ( err ) ; <nl> <nl> + rocksdb_flushoptions_t * flush_options = rocksdb_flushoptions_create ( ) ; <nl> + rocksdb_flushoptions_set_wait ( flush_options , 1 ) ; <nl> + rocksdb_flush_cf ( db , flush_options , handles [ 1 ] , & err ) ; <nl> + CheckNoError ( err ) <nl> + rocksdb_flushoptions_destroy ( flush_options ) ; <nl> + <nl> CheckGetCF ( db , roptions , handles [ 1 ] , " foo " , " hello " ) ; <nl> CheckPinGetCF ( db , roptions , handles [ 1 ] , " foo " , " hello " ) ; <nl> <nl> mmm a / include / rocksdb / c . h <nl> ppp b / include / rocksdb / c . h <nl> extern ROCKSDB_LIBRARY_API const rocksdb_livefiles_t * rocksdb_livefiles ( <nl> extern ROCKSDB_LIBRARY_API void rocksdb_flush ( <nl> rocksdb_t * db , const rocksdb_flushoptions_t * options , char * * errptr ) ; <nl> <nl> + extern ROCKSDB_LIBRARY_API void rocksdb_flush_cf ( <nl> + rocksdb_t * db , const rocksdb_flushoptions_t * options , <nl> + rocksdb_column_family_handle_t * column_family , char * * errptr ) ; <nl> + <nl> extern ROCKSDB_LIBRARY_API void rocksdb_disable_file_deletions ( rocksdb_t * db , <nl> char * * errptr ) ; <nl> <nl>
|
add missing rocksdb_flush_cf in c ( )
|
facebook/rocksdb
|
084a3c697c86d0075eae01226beb55612822da42
|
2019-04-25T18:25:43Z
|
mmm a / modules / core / include / opencv2 / core / cvstd . hpp <nl> ppp b / modules / core / include / opencv2 / core / cvstd . hpp <nl> template < typename _Tp > class Allocator <nl> size_type max_size ( ) const { return cv : : max ( static_cast < _Tp > ( - 1 ) / sizeof ( _Tp ) , 1 ) ; } <nl> } ; <nl> <nl> + namespace detail <nl> + { <nl> <nl> + / / Metafunction to avoid taking a reference to void . <nl> + template < typename T > <nl> + struct RefOrVoid { typedef T & type ; } ; <nl> <nl> - / / / / / / / / / / / / / / / / / / / / generic_type ref - counting pointer class for C / C + + objects / / / / / / / / / / / / / / / / / / / / / / / / <nl> + template < > <nl> + struct RefOrVoid < void > { typedef void type ; } ; <nl> <nl> - / * ! <nl> - Smart pointer to dynamically allocated objects . <nl> + template < > <nl> + struct RefOrVoid < const void > { typedef const void type ; } ; <nl> <nl> - This is template pointer - wrapping class that stores the associated reference counter along with the <nl> - object pointer . The class is similar to std : : smart_ptr < > from the recent addons to the C + + standard , <nl> - but is shorter to write : ) and self - contained ( i . e . does add any dependency on the compiler or an external library ) . <nl> + template < > <nl> + struct RefOrVoid < volatile void > { typedef volatile void type ; } ; <nl> <nl> - Basically , you can use " Ptr < MyObjectType > ptr " ( or faster " const Ptr < MyObjectType > & ptr " for read - only access ) <nl> - everywhere instead of " MyObjectType * ptr " , where MyObjectType is some C structure or a C + + class . <nl> - To make it all work , you need to specialize Ptr < > : : delete_obj ( ) , like : <nl> + template < > <nl> + struct RefOrVoid < const volatile void > { typedef const volatile void type ; } ; <nl> <nl> - \ code <nl> - template < > CV_EXPORTS void Ptr < MyObjectType > : : delete_obj ( ) { call_destructor_func ( obj ) ; } <nl> - \ endcode <nl> + / / This class would be private to Ptr , if it didn ' t have to be a non - template . <nl> + struct PtrOwner ; <nl> + <nl> + } <nl> + <nl> + template < typename Y > <nl> + struct DefaultDeleter <nl> + { <nl> + void operator ( ) ( Y * p ) const ; <nl> + } ; <nl> <nl> - \ note { if MyObjectType is a C + + class with a destructor , you do not need to specialize delete_obj ( ) , <nl> - since the default implementation calls " delete obj ; " } <nl> + / * <nl> + A smart shared pointer class with reference counting . <nl> <nl> - \ note { Another good property of the class is that the operations on the reference counter are atomic , <nl> - i . e . it is safe to use the class in multi - threaded applications } <nl> + A Ptr < T > stores a pointer and owns a ( potentially different ) pointer . <nl> + The stored pointer has type T and is the one returned by get ( ) et al , <nl> + while the owned pointer can have any type and is the one deleted <nl> + when there are no more Ptrs that own it . You can ' t directly obtain the <nl> + owned pointer . <nl> + <nl> + The interface of this class is mostly a subset of that of C + + 11 ' s <nl> + std : : shared_ptr . <nl> * / <nl> - template < typename _Tp > class Ptr <nl> + template < typename T > <nl> + struct Ptr <nl> { <nl> - public : <nl> - / / ! empty constructor <nl> + / * Generic programming support . * / <nl> + typedef T element_type ; <nl> + <nl> + / * Ptr that owns NULL and stores NULL . * / <nl> Ptr ( ) ; <nl> - / / ! take ownership of the pointer . The associated reference counter is allocated and set to 1 <nl> - Ptr ( _Tp * _obj ) ; <nl> - / / ! calls release ( ) <nl> + <nl> + / * Ptr that owns p and stores p . The owned pointer will be deleted with <nl> + DefaultDeleter < Y > . Y must be a complete type and Y * must be <nl> + convertible to T * . * / <nl> + template < typename Y > <nl> + explicit Ptr ( Y * p ) ; <nl> + <nl> + / * Ptr that owns p and stores p . The owned pointer will be deleted by <nl> + calling d ( p ) . Y * must be convertible to T * . * / <nl> + template < typename Y , typename D > <nl> + Ptr ( Y * p , D d ) ; <nl> + <nl> + / * Same as the constructor below ; it exists to suppress the generation <nl> + of the implicit copy constructor . * / <nl> + Ptr ( const Ptr & o ) ; <nl> + <nl> + / * Ptr that owns the same pointer as o and stores the same pointer as o , <nl> + converted to T * . Naturally , Y * must be convertible to T * . * / <nl> + template < typename Y > <nl> + Ptr ( const Ptr < Y > & o ) ; <nl> + <nl> + / * Ptr that owns same pointer as o , and stores p . Useful for casts and <nl> + creating non - owning Ptrs . * / <nl> + template < typename Y > <nl> + Ptr ( const Ptr < Y > & o , T * p ) ; <nl> + <nl> + / * Equivalent to release ( ) . * / <nl> ~ Ptr ( ) ; <nl> - / / ! copy constructor . Copies the members and calls addref ( ) <nl> - Ptr ( const Ptr & ptr ) ; <nl> - template < typename _Tp2 > Ptr ( const Ptr < _Tp2 > & ptr ) ; <nl> - / / ! copy operator . Calls ptr . addref ( ) and release ( ) before copying the members <nl> - Ptr & operator = ( const Ptr & ptr ) ; <nl> - / / ! increments the reference counter <nl> - void addref ( ) ; <nl> - / / ! decrements the reference counter . If it reaches 0 , delete_obj ( ) is called <nl> + <nl> + / * Same as assignment below ; exists to suppress the generation of the <nl> + implicit assignment operator . * / <nl> + Ptr & operator = ( const Ptr & o ) ; <nl> + <nl> + template < typename Y > <nl> + Ptr & operator = ( const Ptr < Y > & o ) ; <nl> + <nl> + / * Resets both the owned and stored pointers to NULL . Deletes the owned <nl> + pointer with the associated deleter if it ' s not owned by any other <nl> + Ptr and is non - zero . It ' s called reset ( ) in std : : shared_ptr ; here <nl> + it is release ( ) for compatibility with old OpenCV versions . * / <nl> void release ( ) ; <nl> - / / ! deletes the object . Override if needed <nl> - void delete_obj ( ) ; <nl> - / / ! returns true iff obj = = NULL <nl> + <nl> + / * Equivalent to assigning from Ptr < T > ( p ) . * / <nl> + template < typename Y > <nl> + void reset ( Y * p ) ; <nl> + <nl> + / * Equivalent to assigning from Ptr < T > ( p , d ) . * / <nl> + template < typename Y , typename D > <nl> + void reset ( Y * p , D d ) ; <nl> + <nl> + / * Swaps the stored and owned pointers of this and o . * / <nl> + void swap ( Ptr & o ) ; <nl> + <nl> + / * Returns the stored pointer . * / <nl> + T * get ( ) const ; <nl> + <nl> + / * Ordinary pointer emulation . * / <nl> + typename detail : : RefOrVoid < T > : : type operator * ( ) const ; <nl> + T * operator - > ( ) const ; <nl> + <nl> + / * Equivalent to get ( ) . * / <nl> + operator T * ( ) const ; <nl> + <nl> + / * Equivalent to ! * this . * / <nl> bool empty ( ) const ; <nl> <nl> - / / ! cast pointer to another type <nl> - template < typename _Tp2 > Ptr < _Tp2 > ptr ( ) ; <nl> - template < typename _Tp2 > const Ptr < _Tp2 > ptr ( ) const ; <nl> + / * Returns a Ptr that owns the same pointer as this , and stores the same <nl> + pointer as this , except converted via static_cast to Y * . * / <nl> + template < typename Y > <nl> + Ptr < Y > staticCast ( ) const ; <nl> + <nl> + / * Ditto for const_cast . * / <nl> + template < typename Y > <nl> + Ptr < Y > constCast ( ) const ; <nl> <nl> - / / ! helper operators making " Ptr < T > ptr " use very similar to " T * ptr " . <nl> - _Tp * operator - > ( ) ; <nl> - const _Tp * operator - > ( ) const ; <nl> + / * Ditto for dynamic_cast . * / <nl> + template < typename Y > <nl> + Ptr < Y > dynamicCast ( ) const ; <nl> <nl> - operator _Tp * ( ) ; <nl> - operator const _Tp * ( ) const ; <nl> + private : <nl> + detail : : PtrOwner * owner ; <nl> + T * stored ; <nl> <nl> - _Tp * obj ; / / < the object pointer . <nl> - int * refcount ; / / < the associated reference counter <nl> + template < typename Y > <nl> + friend struct Ptr ; / / have to do this for the cross - type copy constructor <nl> } ; <nl> <nl> + / * Overload of the generic swap . * / <nl> + template < typename T > <nl> + void swap ( Ptr < T > & ptr1 , Ptr < T > & ptr2 ) ; <nl> + <nl> + / * Obvious comparisons . * / <nl> + template < typename T > <nl> + bool operator = = ( const Ptr < T > & ptr1 , const Ptr < T > & ptr2 ) ; <nl> + template < typename T > <nl> + bool operator ! = ( const Ptr < T > & ptr1 , const Ptr < T > & ptr2 ) ; <nl> + <nl> + / * Convenience creation functions . In the far future , there may be variadic templates here . * / <nl> + template < typename T > <nl> + Ptr < T > makePtr ( ) ; <nl> + template < typename T , typename A1 > <nl> + Ptr < T > makePtr ( const A1 & a1 ) ; <nl> + template < typename T , typename A1 , typename A2 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 ) ; <nl> + template < typename T , typename A1 , typename A2 , typename A3 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 ) ; <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 ) ; <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 , const A5 & a5 ) ; <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 , const A5 & a5 , const A6 & a6 ) ; <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 , const A5 & a5 , const A6 & a6 , const A7 & a7 ) ; <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 , const A5 & a5 , const A6 & a6 , const A7 & a7 , const A8 & a8 ) ; <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 , const A5 & a5 , const A6 & a6 , const A7 & a7 , const A8 & a8 , const A9 & a9 ) ; <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 , const A5 & a5 , const A6 & a6 , const A7 & a7 , const A8 & a8 , const A9 & a9 , const A10 & a10 ) ; <nl> <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / string class / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> class CV_EXPORTS String <nl> } ; <nl> <nl> <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / cv : : Ptr implementation / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - template < typename _Tp > inline <nl> - Ptr < _Tp > : : Ptr ( ) <nl> - : obj ( 0 ) , refcount ( 0 ) { } <nl> - <nl> - template < typename _Tp > inline <nl> - Ptr < _Tp > : : Ptr ( _Tp * _obj ) <nl> - : obj ( _obj ) <nl> - { <nl> - if ( obj ) <nl> - { <nl> - refcount = ( int * ) fastMalloc ( sizeof ( * refcount ) ) ; <nl> - * refcount = 1 ; <nl> - } <nl> - else <nl> - refcount = 0 ; <nl> - } <nl> - <nl> - template < typename _Tp > template < typename _Tp2 > <nl> - Ptr < _Tp > : : Ptr ( const Ptr < _Tp2 > & p ) <nl> - : obj ( 0 ) , refcount ( 0 ) <nl> - { <nl> - if ( p . empty ( ) ) <nl> - return ; <nl> - <nl> - _Tp * p_casted = dynamic_cast < _Tp * > ( p . obj ) ; <nl> - if ( ! p_casted ) <nl> - return ; <nl> - <nl> - obj = p_casted ; <nl> - refcount = p . refcount ; <nl> - addref ( ) ; <nl> - } <nl> - <nl> - template < typename _Tp > inline <nl> - Ptr < _Tp > : : ~ Ptr ( ) <nl> - { <nl> - release ( ) ; <nl> - } <nl> - <nl> - template < typename _Tp > inline <nl> - void Ptr < _Tp > : : addref ( ) <nl> - { <nl> - if ( refcount ) <nl> - CV_XADD ( refcount , 1 ) ; <nl> - } <nl> - <nl> - template < typename _Tp > inline <nl> - void Ptr < _Tp > : : release ( ) <nl> - { <nl> - if ( refcount & & CV_XADD ( refcount , - 1 ) = = 1 ) <nl> - { <nl> - delete_obj ( ) ; <nl> - fastFree ( refcount ) ; <nl> - } <nl> - refcount = 0 ; <nl> - obj = 0 ; <nl> - } <nl> - <nl> - template < typename _Tp > inline <nl> - void Ptr < _Tp > : : delete_obj ( ) <nl> - { <nl> - if ( obj ) <nl> - delete obj ; <nl> - } <nl> - <nl> - template < typename _Tp > inline <nl> - Ptr < _Tp > : : Ptr ( const Ptr < _Tp > & _ptr ) <nl> - { <nl> - obj = _ptr . obj ; <nl> - refcount = _ptr . refcount ; <nl> - addref ( ) ; <nl> - } <nl> - <nl> - template < typename _Tp > inline <nl> - Ptr < _Tp > & Ptr < _Tp > : : operator = ( const Ptr < _Tp > & _ptr ) <nl> - { <nl> - int * _refcount = _ptr . refcount ; <nl> - if ( _refcount ) <nl> - CV_XADD ( _refcount , 1 ) ; <nl> - release ( ) ; <nl> - obj = _ptr . obj ; <nl> - refcount = _refcount ; <nl> - return * this ; <nl> - } <nl> - <nl> - template < typename _Tp > inline <nl> - _Tp * Ptr < _Tp > : : operator - > ( ) <nl> - { <nl> - return obj ; <nl> - } <nl> - <nl> - template < typename _Tp > inline <nl> - const _Tp * Ptr < _Tp > : : operator - > ( ) const <nl> - { <nl> - return obj ; <nl> - } <nl> - <nl> - template < typename _Tp > inline <nl> - Ptr < _Tp > : : operator _Tp * ( ) <nl> - { <nl> - return obj ; <nl> - } <nl> - <nl> - template < typename _Tp > inline <nl> - Ptr < _Tp > : : operator const _Tp * ( ) const <nl> - { <nl> - return obj ; <nl> - } <nl> - <nl> - template < typename _Tp > inline <nl> - bool Ptr < _Tp > : : empty ( ) const <nl> - { <nl> - return obj = = 0 ; <nl> - } <nl> - <nl> - template < typename _Tp > template < typename _Tp2 > inline <nl> - Ptr < _Tp2 > Ptr < _Tp > : : ptr ( ) <nl> - { <nl> - Ptr < _Tp2 > p ; <nl> - if ( ! obj ) <nl> - return p ; <nl> - <nl> - _Tp2 * obj_casted = dynamic_cast < _Tp2 * > ( obj ) ; <nl> - if ( ! obj_casted ) <nl> - return p ; <nl> - <nl> - if ( refcount ) <nl> - CV_XADD ( refcount , 1 ) ; <nl> - <nl> - p . obj = obj_casted ; <nl> - p . refcount = refcount ; <nl> - return p ; <nl> - } <nl> - <nl> - template < typename _Tp > template < typename _Tp2 > inline <nl> - const Ptr < _Tp2 > Ptr < _Tp > : : ptr ( ) const <nl> - { <nl> - Ptr < _Tp2 > p ; <nl> - if ( ! obj ) <nl> - return p ; <nl> - <nl> - _Tp2 * obj_casted = dynamic_cast < _Tp2 * > ( obj ) ; <nl> - if ( ! obj_casted ) <nl> - return p ; <nl> - <nl> - if ( refcount ) <nl> - CV_XADD ( refcount , 1 ) ; <nl> - <nl> - p . obj = obj_casted ; <nl> - p . refcount = refcount ; <nl> - return p ; <nl> - } <nl> - <nl> - template < class _Tp , class _Tp2 > static inline <nl> - bool operator = = ( const Ptr < _Tp > & a , const Ptr < _Tp2 > & b ) <nl> - { <nl> - return a . refcount = = b . refcount ; <nl> - } <nl> - <nl> - template < class _Tp , class _Tp2 > static inline <nl> - bool operator ! = ( const Ptr < _Tp > & a , const Ptr < _Tp2 > & b ) <nl> - { <nl> - return a . refcount ! = b . refcount ; <nl> - } <nl> - <nl> - <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / cv : : String implementation / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> inline <nl> namespace cv <nl> } <nl> } <nl> <nl> + # include " opencv2 / core / ptr . inl . hpp " <nl> + <nl> # endif / / __OPENCV_CORE_CVSTD_HPP__ <nl> new file mode 100644 <nl> index 00000000000 . . 989724281f0 <nl> mmm / dev / null <nl> ppp b / modules / core / include / opencv2 / core / ptr . inl . hpp <nl> <nl> + / * M / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / <nl> + / / IMPORTANT : READ BEFORE DOWNLOADING , COPYING , INSTALLING OR USING . <nl> + / / <nl> + / / By downloading , copying , installing or using the software you agree to this license . <nl> + / / If you do not agree to this license , do not download , install , <nl> + / / copy or use the software . <nl> + / / <nl> + / / <nl> + / / License Agreement <nl> + / / For Open Source Computer Vision Library <nl> + / / <nl> + / / Copyright ( C ) 2013 , NVIDIA Corporation , all rights reserved . <nl> + / / Third party copyrights are property of their respective owners . <nl> + / / <nl> + / / Redistribution and use in source and binary forms , with or without modification , <nl> + / / are permitted provided that the following conditions are met : <nl> + / / <nl> + / / * Redistribution ' s of source code must retain the above copyright notice , <nl> + / / this list of conditions and the following disclaimer . <nl> + / / <nl> + / / * Redistribution ' s in binary form must reproduce the above copyright notice , <nl> + / / this list of conditions and the following disclaimer in the documentation <nl> + / / and / or other materials provided with the distribution . <nl> + / / <nl> + / / * The name of the copyright holders may not be used to endorse or promote products <nl> + / / derived from this software without specific prior written permission . <nl> + / / <nl> + / / This software is provided by the copyright holders and contributors " as is " and <nl> + / / any express or implied warranties , including , but not limited to , the implied <nl> + / / warranties of merchantability and fitness for a particular purpose are disclaimed . <nl> + / / In no event shall the copyright holders or contributors be liable for any direct , <nl> + / / indirect , incidental , special , exemplary , or consequential damages <nl> + / / ( including , but not limited to , procurement of substitute goods or services ; <nl> + / / loss of use , data , or profits ; or business interruption ) however caused <nl> + / / and on any theory of liability , whether in contract , strict liability , <nl> + / / or tort ( including negligence or otherwise ) arising in any way out of <nl> + / / the use of this software , even if advised of the possibility of such damage . <nl> + / / <nl> + / / M * / <nl> + <nl> + # ifndef __OPENCV_CORE_PTR_INL_HPP__ <nl> + # define __OPENCV_CORE_PTR_INL_HPP__ <nl> + <nl> + # include < algorithm > <nl> + <nl> + namespace cv { <nl> + <nl> + template < typename Y > <nl> + void DefaultDeleter < Y > : : operator ( ) ( Y * p ) const <nl> + { <nl> + delete p ; <nl> + } <nl> + <nl> + namespace detail <nl> + { <nl> + <nl> + struct PtrOwner <nl> + { <nl> + PtrOwner ( ) : refCount ( 1 ) <nl> + { } <nl> + <nl> + void incRef ( ) <nl> + { <nl> + CV_XADD ( & refCount , 1 ) ; <nl> + } <nl> + <nl> + void decRef ( ) <nl> + { <nl> + if ( CV_XADD ( & refCount , - 1 ) = = 1 ) deleteSelf ( ) ; <nl> + } <nl> + <nl> + protected : <nl> + / * This doesn ' t really need to be virtual , since PtrOwner is never deleted <nl> + directly , but it doesn ' t hurt and it helps avoid warnings . * / <nl> + virtual ~ PtrOwner ( ) <nl> + { } <nl> + <nl> + virtual void deleteSelf ( ) = 0 ; <nl> + <nl> + private : <nl> + unsigned int refCount ; <nl> + <nl> + / / noncopyable <nl> + PtrOwner ( const PtrOwner & ) ; <nl> + PtrOwner & operator = ( const PtrOwner & ) ; <nl> + } ; <nl> + <nl> + template < typename Y , typename D > <nl> + struct PtrOwnerImpl : PtrOwner <nl> + { <nl> + PtrOwnerImpl ( Y * p , D d ) : owned ( p ) , deleter ( d ) <nl> + { } <nl> + <nl> + void deleteSelf ( ) <nl> + { <nl> + deleter ( owned ) ; <nl> + delete this ; <nl> + } <nl> + <nl> + private : <nl> + Y * owned ; <nl> + D deleter ; <nl> + } ; <nl> + <nl> + <nl> + } <nl> + <nl> + template < typename T > <nl> + Ptr < T > : : Ptr ( ) : owner ( NULL ) , stored ( NULL ) <nl> + { } <nl> + <nl> + template < typename T > <nl> + template < typename Y > <nl> + Ptr < T > : : Ptr ( Y * p ) <nl> + : owner ( p <nl> + ? new detail : : PtrOwnerImpl < Y , DefaultDeleter < Y > > ( p , DefaultDeleter < Y > ( ) ) <nl> + : NULL ) , <nl> + stored ( p ) <nl> + { } <nl> + <nl> + template < typename T > <nl> + template < typename Y , typename D > <nl> + Ptr < T > : : Ptr ( Y * p , D d ) <nl> + : owner ( p <nl> + ? new detail : : PtrOwnerImpl < Y , D > ( p , d ) <nl> + : NULL ) , <nl> + stored ( p ) <nl> + { } <nl> + <nl> + template < typename T > <nl> + Ptr < T > : : Ptr ( const Ptr & o ) : owner ( o . owner ) , stored ( o . stored ) <nl> + { <nl> + if ( owner ) owner - > incRef ( ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + template < typename Y > <nl> + Ptr < T > : : Ptr ( const Ptr < Y > & o ) : owner ( o . owner ) , stored ( o . stored ) <nl> + { <nl> + if ( owner ) owner - > incRef ( ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + template < typename Y > <nl> + Ptr < T > : : Ptr ( const Ptr < Y > & o , T * p ) : owner ( o . owner ) , stored ( p ) <nl> + { <nl> + if ( owner ) owner - > incRef ( ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + Ptr < T > : : ~ Ptr ( ) <nl> + { <nl> + release ( ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + Ptr < T > & Ptr < T > : : operator = ( const Ptr < T > & o ) <nl> + { <nl> + Ptr ( o ) . swap ( * this ) ; <nl> + return * this ; <nl> + } <nl> + <nl> + template < typename T > <nl> + template < typename Y > <nl> + Ptr < T > & Ptr < T > : : operator = ( const Ptr < Y > & o ) <nl> + { <nl> + Ptr ( o ) . swap ( * this ) ; <nl> + return * this ; <nl> + } <nl> + <nl> + template < typename T > <nl> + void Ptr < T > : : release ( ) <nl> + { <nl> + if ( owner ) owner - > decRef ( ) ; <nl> + owner = NULL ; <nl> + stored = NULL ; <nl> + } <nl> + <nl> + template < typename T > <nl> + template < typename Y > <nl> + void Ptr < T > : : reset ( Y * p ) <nl> + { <nl> + Ptr ( p ) . swap ( * this ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + template < typename Y , typename D > <nl> + void Ptr < T > : : reset ( Y * p , D d ) <nl> + { <nl> + Ptr ( p , d ) . swap ( * this ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + void Ptr < T > : : swap ( Ptr < T > & o ) <nl> + { <nl> + std : : swap ( owner , o . owner ) ; <nl> + std : : swap ( stored , o . stored ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + T * Ptr < T > : : get ( ) const <nl> + { <nl> + return stored ; <nl> + } <nl> + <nl> + template < typename T > <nl> + typename detail : : RefOrVoid < T > : : type Ptr < T > : : operator * ( ) const <nl> + { <nl> + return * stored ; <nl> + } <nl> + <nl> + template < typename T > <nl> + T * Ptr < T > : : operator - > ( ) const <nl> + { <nl> + return stored ; <nl> + } <nl> + <nl> + template < typename T > <nl> + Ptr < T > : : operator T * ( ) const <nl> + { <nl> + return stored ; <nl> + } <nl> + <nl> + <nl> + template < typename T > <nl> + bool Ptr < T > : : empty ( ) const <nl> + { <nl> + return ! stored ; <nl> + } <nl> + <nl> + template < typename T > <nl> + template < typename Y > <nl> + Ptr < Y > Ptr < T > : : staticCast ( ) const <nl> + { <nl> + return Ptr < Y > ( * this , static_cast < Y * > ( stored ) ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + template < typename Y > <nl> + Ptr < Y > Ptr < T > : : constCast ( ) const <nl> + { <nl> + return Ptr < Y > ( * this , const_cast < Y * > ( stored ) ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + template < typename Y > <nl> + Ptr < Y > Ptr < T > : : dynamicCast ( ) const <nl> + { <nl> + return Ptr < Y > ( * this , dynamic_cast < Y * > ( stored ) ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + void swap ( Ptr < T > & ptr1 , Ptr < T > & ptr2 ) { <nl> + ptr1 . swap ( ptr2 ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + bool operator = = ( const Ptr < T > & ptr1 , const Ptr < T > & ptr2 ) <nl> + { <nl> + return ptr1 . get ( ) = = ptr2 . get ( ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + bool operator ! = ( const Ptr < T > & ptr1 , const Ptr < T > & ptr2 ) <nl> + { <nl> + return ptr1 . get ( ) ! = ptr2 . get ( ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + Ptr < T > makePtr ( ) <nl> + { <nl> + return Ptr < T > ( new T ( ) ) ; <nl> + } <nl> + <nl> + template < typename T , typename A1 > <nl> + Ptr < T > makePtr ( const A1 & a1 ) <nl> + { <nl> + return Ptr < T > ( new T ( a1 ) ) ; <nl> + } <nl> + <nl> + template < typename T , typename A1 , typename A2 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 ) <nl> + { <nl> + return Ptr < T > ( new T ( a1 , a2 ) ) ; <nl> + } <nl> + <nl> + template < typename T , typename A1 , typename A2 , typename A3 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 ) <nl> + { <nl> + return Ptr < T > ( new T ( a1 , a2 , a3 ) ) ; <nl> + } <nl> + <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 ) <nl> + { <nl> + return Ptr < T > ( new T ( a1 , a2 , a3 , a4 ) ) ; <nl> + } <nl> + <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 , const A5 & a5 ) <nl> + { <nl> + return Ptr < T > ( new T ( a1 , a2 , a3 , a4 , a5 ) ) ; <nl> + } <nl> + <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 , const A5 & a5 , const A6 & a6 ) <nl> + { <nl> + return Ptr < T > ( new T ( a1 , a2 , a3 , a4 , a5 , a6 ) ) ; <nl> + } <nl> + <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 , const A5 & a5 , const A6 & a6 , const A7 & a7 ) <nl> + { <nl> + return Ptr < T > ( new T ( a1 , a2 , a3 , a4 , a5 , a6 , a7 ) ) ; <nl> + } <nl> + <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 , const A5 & a5 , const A6 & a6 , const A7 & a7 , const A8 & a8 ) <nl> + { <nl> + return Ptr < T > ( new T ( a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 ) ) ; <nl> + } <nl> + <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 , const A5 & a5 , const A6 & a6 , const A7 & a7 , const A8 & a8 , const A9 & a9 ) <nl> + { <nl> + return Ptr < T > ( new T ( a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 ) ) ; <nl> + } <nl> + <nl> + template < typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 > <nl> + Ptr < T > makePtr ( const A1 & a1 , const A2 & a2 , const A3 & a3 , const A4 & a4 , const A5 & a5 , const A6 & a6 , const A7 & a7 , const A8 & a8 , const A9 & a9 , const A10 & a10 ) <nl> + { <nl> + return Ptr < T > ( new T ( a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 ) ) ; <nl> + } <nl> + <nl> + } / / namespace cv <nl> + <nl> + # endif / / __OPENCV_CORE_PTR_INL_HPP__ <nl>
|
Replaced Ptr with my new implementation .
|
opencv/opencv
|
461c98fa86156a41249ed6c77e859f8d0093abc9
|
2013-09-05T10:54:20Z
|
mmm a / code / artificial_intelligence / decision_tree / Decision_Tree . py <nl> ppp b / code / artificial_intelligence / decision_tree / Decision_Tree . py <nl> def decision_tree ( train , test , max_depth , min_size ) : <nl> scores = evaluate_algorithm ( dataset , decision_tree , n_folds , max_depth , min_size ) <nl> print ( ' Scores : % s ' % scores ) <nl> print ( ' Mean Accuracy : % . 3f % % ' % ( sum ( scores ) / float ( len ( scores ) ) ) ) <nl> + <nl> + # Evaluate algorithm by computing ROC ( Receiver Operating Characteristic ) and AUC ( area the curve ) <nl> + from sklearn . metrics import roc_curve , auc <nl> + import matplotlib . pyplot as plt <nl> + false_positve_rate , true_positive_rate = roc_curve ( actual , predictions ) <nl> + roc_auc = auc ( false_positve_rate , true_positive_rate ) <nl> + plt . plot ( false_positve_rate , true_positive_rate , lw = 1 , <nl> + label = ' ROC curve ( area = % 0 . 2f ) ' % roc_auc [ 2 ] ) <nl> + plt . title ( ' Receiver operating characteristic example ' ) <nl> + plt . ylabel ( ' True Positive Rate ' ) <nl> + plt . xlabel ( ' False Positive Rate ' ) <nl> + plt . show ( ) <nl> + print ( ' AUC : % s ' % roc_auc ) <nl>
|
Add model evaluation method ROC
|
OpenGenus/cosmos
|
c509fd123824ab1f19e2f6e5ada247b50f9e6db3
|
2017-10-22T23:31:39Z
|
mmm a / toolsrc / src / vcpkg / help . cpp <nl> ppp b / toolsrc / src / vcpkg / help . cpp <nl> namespace vcpkg : : Help <nl> " - - vcpkg - root < path > Specify the vcpkg root directory \ n " <nl> " ( default : " ENVVAR ( VCPKG_ROOT ) " ) \ n " <nl> " \ n " <nl> + " @ response_file Specify a response file to provide additional parameters \ n " <nl> + " \ n " <nl> " For more help ( including examples ) see the accompanying README . md . " , <nl> Commands : : Integrate : : INTEGRATE_COMMAND_HELPSTRING ) ; <nl> } <nl> mmm a / toolsrc / src / vcpkg / vcpkgcmdarguments . cpp <nl> ppp b / toolsrc / src / vcpkg / vcpkgcmdarguments . cpp <nl> namespace vcpkg <nl> std : : vector < std : : string > v ; <nl> for ( int i = 1 ; i < argc ; + + i ) <nl> { <nl> + std : : string arg ; <nl> # if defined ( _WIN32 ) <nl> - v . push_back ( Strings : : to_utf8 ( argv [ i ] ) ) ; <nl> + arg = Strings : : to_utf8 ( argv [ i ] ) ; <nl> # else <nl> - v . push_back ( argv [ i ] ) ; <nl> + arg = argv [ i ] ; <nl> # endif <nl> + / / Response file ? <nl> + if ( arg . size ( ) > 0 & & arg [ 0 ] = = ' @ ' ) <nl> + { <nl> + arg . erase ( arg . begin ( ) ) ; <nl> + const auto & fs = Files : : get_real_filesystem ( ) ; <nl> + auto lines = fs . read_lines ( fs : : u8path ( arg ) ) ; <nl> + if ( ! lines . has_value ( ) ) <nl> + { <nl> + System : : println ( System : : Color : : error , " Error : Could not open response file % s " , arg ) ; <nl> + Checks : : exit_fail ( VCPKG_LINE_INFO ) ; <nl> + } <nl> + std : : copy ( lines . get ( ) - > begin ( ) , lines . get ( ) - > end ( ) , std : : back_inserter ( v ) ) ; <nl> + } <nl> + else <nl> + { <nl> + v . emplace_back ( std : : move ( arg ) ) ; <nl> + } <nl> } <nl> <nl> return VcpkgCmdArguments : : create_from_arg_sequence ( v . data ( ) , v . data ( ) + v . size ( ) ) ; <nl>
|
Add support for response files with vcpkg ( )
|
microsoft/vcpkg
|
dac6bba3f6681e5bd326c49d834fe024f54d5bac
|
2018-10-20T19:16:38Z
|
mmm a / jstests / noPassthroughWithMongod / index_retry . js <nl> ppp b / jstests / noPassthroughWithMongod / index_retry . js <nl> function abortDuringIndexBuild ( options ) { <nl> abortDuringIndexBuild ( ) ; <nl> <nl> conn = mongod . start ( / * reuseData * / true ) ; <nl> + test = conn . getDB ( " test " ) ; <nl> <nl> <nl> <nl> assert . soon ( <nl> printjson ( conn . getDB ( " test " ) . getCollection ( name ) . find ( { a : 42 } ) . hint ( { a : 1 } ) . next ( ) ) ; <nl> } catch ( e ) { <nl> print ( e ) ; <nl> + var inprog = test . currentOp ( ) . inprog ; <nl> + print ( " Index build not yet complete : " ) ; <nl> + debug ( inprog ) ; <nl> return false ; <nl> } <nl> return true ; <nl>
|
SERVER - 15036 log progress of background index build in index_retry . js
|
mongodb/mongo
|
ab45fd3e0c3ea06a5c093e826862618ae3b6205a
|
2014-08-26T15:08:10Z
|
mmm a / src / python / grpcio / grpc / _cython / _cygrpc / completion_queue . pxd . pxi <nl> ppp b / src / python / grpcio / grpc / _cython / _cygrpc / completion_queue . pxd . pxi <nl> <nl> cdef class CompletionQueue : <nl> <nl> cdef grpc_completion_queue * c_completion_queue <nl> - cdef object pluck_condition <nl> - cdef int num_plucking <nl> - cdef int num_polling <nl> cdef bint is_shutting_down <nl> cdef bint is_shutdown <nl> <nl> mmm a / src / python / grpcio / grpc / _cython / _cygrpc / completion_queue . pyx . pxi <nl> ppp b / src / python / grpcio / grpc / _cython / _cygrpc / completion_queue . pyx . pxi <nl> cimport cpython <nl> import threading <nl> import time <nl> <nl> + cdef int _INTERRUPT_CHECK_PERIOD_MS = 200 <nl> + <nl> <nl> cdef class CompletionQueue : <nl> <nl> cdef class CompletionQueue : <nl> self . c_completion_queue = grpc_completion_queue_create ( NULL ) <nl> self . is_shutting_down = False <nl> self . is_shutdown = False <nl> - self . pluck_condition = threading . Condition ( ) <nl> - self . num_plucking = 0 <nl> - self . num_polling = 0 <nl> <nl> cdef _interpret_event ( self , grpc_event event ) : <nl> cdef OperationTag tag = None <nl> cdef class CompletionQueue : <nl> def poll ( self , Timespec deadline = None ) : <nl> # We name this ' poll ' to avoid problems with CPython ' s expectations for <nl> # ' special ' methods ( like next and __next__ ) . <nl> + cdef gpr_timespec c_increment <nl> + cdef gpr_timespec c_timeout <nl> cdef gpr_timespec c_deadline <nl> with nogil : <nl> + c_increment = gpr_time_from_millis ( _INTERRUPT_CHECK_PERIOD_MS , GPR_TIMESPAN ) <nl> c_deadline = gpr_inf_future ( GPR_CLOCK_REALTIME ) <nl> - if deadline is not None : <nl> - c_deadline = deadline . c_time <nl> - cdef grpc_event event <nl> - <nl> - # Poll within a critical section to detect contention <nl> - with self . pluck_condition : <nl> - assert self . num_plucking = = 0 , ' cannot simultaneously pluck and poll ' <nl> - self . num_polling + = 1 <nl> - with nogil : <nl> - event = grpc_completion_queue_next ( <nl> - self . c_completion_queue , c_deadline , NULL ) <nl> - with self . pluck_condition : <nl> - self . num_polling - = 1 <nl> - return self . _interpret_event ( event ) <nl> - <nl> - def pluck ( self , OperationTag tag , Timespec deadline = None ) : <nl> - # Plucking a ' None ' tag is equivalent to passing control to GRPC core until <nl> - # the deadline . <nl> - cdef gpr_timespec c_deadline = gpr_inf_future ( <nl> - GPR_CLOCK_REALTIME ) <nl> - if deadline is not None : <nl> - c_deadline = deadline . c_time <nl> - cdef grpc_event event <nl> - <nl> - # Pluck within a critical section to detect contention <nl> - with self . pluck_condition : <nl> - assert self . num_polling = = 0 , ' cannot simultaneously pluck and poll ' <nl> - assert self . num_plucking < GRPC_MAX_COMPLETION_QUEUE_PLUCKERS , ( <nl> - ' cannot pluck more than { } times simultaneously ' . format ( <nl> - GRPC_MAX_COMPLETION_QUEUE_PLUCKERS ) ) <nl> - self . num_plucking + = 1 <nl> - with nogil : <nl> - event = grpc_completion_queue_pluck ( <nl> - self . c_completion_queue , < cpython . PyObject * > tag , c_deadline , NULL ) <nl> - with self . pluck_condition : <nl> - self . num_plucking - = 1 <nl> + if deadline is not None : <nl> + c_deadline = deadline . c_time <nl> + <nl> + while True : <nl> + c_timeout = gpr_time_add ( gpr_now ( GPR_CLOCK_REALTIME ) , c_increment ) <nl> + if gpr_time_cmp ( c_timeout , c_deadline ) > 0 : <nl> + c_timeout = c_deadline <nl> + event = grpc_completion_queue_next ( <nl> + self . c_completion_queue , c_timeout , NULL ) <nl> + if event . type ! = GRPC_QUEUE_TIMEOUT or gpr_time_cmp ( c_timeout , c_deadline ) = = 0 : <nl> + break ; <nl> + <nl> + # Handle any signals <nl> + with gil : <nl> + cpython . PyErr_CheckSignals ( ) <nl> return self . _interpret_event ( event ) <nl> <nl> def shutdown ( self ) : <nl> mmm a / src / python / grpcio / grpc / _cython / _cygrpc / grpc . pxi <nl> ppp b / src / python / grpcio / grpc / _cython / _cygrpc / grpc . pxi <nl> cdef extern from " grpc / _cython / loader . h " : <nl> gpr_timespec gpr_convert_clock_type ( gpr_timespec t , <nl> gpr_clock_type target_clock ) nogil <nl> <nl> + gpr_timespec gpr_time_from_millis ( int64_t ms , gpr_clock_type type ) nogil <nl> + <nl> + gpr_timespec gpr_time_add ( gpr_timespec a , gpr_timespec b ) nogil <nl> + <nl> + int gpr_time_cmp ( gpr_timespec a , gpr_timespec b ) nogil <nl> + <nl> ctypedef enum grpc_status_code : <nl> GRPC_STATUS_OK <nl> GRPC_STATUS_CANCELLED <nl> mmm a / src / python / grpcio / grpc / _cython / _cygrpc / server . pyx . pxi <nl> ppp b / src / python / grpcio / grpc / _cython / _cygrpc / server . pyx . pxi <nl> cdef class Server : <nl> with nogil : <nl> grpc_server_start ( self . c_server ) <nl> # Ensure the core has gotten a chance to do the start - up work <nl> - self . backup_shutdown_queue . pluck ( None , Timespec ( None ) ) <nl> + self . backup_shutdown_queue . poll ( Timespec ( None ) ) <nl> <nl> def add_http2_port ( self , address , <nl> ServerCredentials server_credentials = None ) : <nl>
|
Merge pull request from kpayson64 / python_signal_handling
|
grpc/grpc
|
fd1419a1761bd09931e014100d5d9737c4942bc8
|
2016-06-14T20:33:20Z
|
mmm a / test / fuzzer / testcfg . py <nl> ppp b / test / fuzzer / testcfg . py <nl> def test_dirs ( self ) : <nl> def _to_relpath ( self , abspath , _ ) : <nl> return os . path . relpath ( abspath , self . suite . root ) <nl> <nl> + def _should_filter_by_name ( self , _ ) : <nl> + return False <nl> <nl> class TestSuite ( testsuite . TestSuite ) : <nl> def _test_loader_class ( self ) : <nl>
|
[ test ] don ' t filter out the fuzzer tests
|
v8/v8
|
6ac90d55950aeb23d57c30578ac5b8247ac482bd
|
2020-08-04T19:50:28Z
|
mmm a / documentation / sphinx / source / tls . rst <nl> ppp b / documentation / sphinx / source / tls . rst <nl> A FoundationDB server or client will only communicate with peers that present a <nl> Certificate field verification <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> <nl> - With a peer verification string , FoundationDB servers and clients can adjust what is required of the certificate chain presented by a peer . These options can make the certificate requirements more rigorous or more lenient . You can specify multiple verification strings by providing additional tls_verify_peers command line arguments . <nl> + With a peer verification string , FoundationDB servers and clients can adjust what is required of the certificate chain presented by a peer . These options can make the certificate requirements more rigorous or more lenient . You can specify multiple verification strings by providing additional tls_verify_peers command line arguments or concatenating them with ` ` | ` ` . All ` ` , ` ` or ` ` | ` ` in the verify peers fields should be escaped with ` ` \ ` ` . <nl> <nl> Turning down the validation <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl>
|
Merge pull request from richardalow / additional - verify - peers - args
|
apple/foundationdb
|
67781e184ef65060e399ea618bde2f280892e161
|
2018-06-12T17:18:18Z
|
mmm a / docs / en / agg_functions / index . rst <nl> ppp b / docs / en / agg_functions / index . rst <nl> Example : <nl> <nl> . . code - block : : sql <nl> <nl> - CREATE TABLE sum_map ( <nl> - date Date , <nl> - timeslot DateTime , <nl> - statusMap Nested ( <nl> - status UInt16 , <nl> - requests UInt64 <nl> - ) <nl> - ) ENGINE = Log ; <nl> - INSERT INTO sum_map VALUES <nl> - ( ' 2000 - 01 - 01 ' , ' 2000 - 01 - 01 00 : 00 : 00 ' , [ 1 , 2 , 3 ] , [ 10 , 10 , 10 ] ) , <nl> - ( ' 2000 - 01 - 01 ' , ' 2000 - 01 - 01 00 : 00 : 00 ' , [ 3 , 4 , 5 ] , [ 10 , 10 , 10 ] ) , <nl> - ( ' 2000 - 01 - 01 ' , ' 2000 - 01 - 01 00 : 01 : 00 ' , [ 4 , 5 , 6 ] , [ 10 , 10 , 10 ] ) , <nl> - ( ' 2000 - 01 - 01 ' , ' 2000 - 01 - 01 00 : 01 : 00 ' , [ 6 , 7 , 8 ] , [ 10 , 10 , 10 ] ) ; <nl> - SELECT <nl> - timeslot , <nl> - sumMap ( statusMap . status , statusMap . requests ) <nl> - FROM sum_map <nl> - GROUP BY timeslot <nl> + CREATE TABLE sum_map ( <nl> + date Date , <nl> + timeslot DateTime , <nl> + statusMap Nested ( <nl> + status UInt16 , <nl> + requests UInt64 <nl> + ) <nl> + ) ENGINE = Log ; <nl> + INSERT INTO sum_map VALUES <nl> + ( ' 2000 - 01 - 01 ' , ' 2000 - 01 - 01 00 : 00 : 00 ' , [ 1 , 2 , 3 ] , [ 10 , 10 , 10 ] ) , <nl> + ( ' 2000 - 01 - 01 ' , ' 2000 - 01 - 01 00 : 00 : 00 ' , [ 3 , 4 , 5 ] , [ 10 , 10 , 10 ] ) , <nl> + ( ' 2000 - 01 - 01 ' , ' 2000 - 01 - 01 00 : 01 : 00 ' , [ 4 , 5 , 6 ] , [ 10 , 10 , 10 ] ) , <nl> + ( ' 2000 - 01 - 01 ' , ' 2000 - 01 - 01 00 : 01 : 00 ' , [ 6 , 7 , 8 ] , [ 10 , 10 , 10 ] ) ; <nl> + SELECT <nl> + timeslot , <nl> + sumMap ( statusMap . status , statusMap . requests ) <nl> + FROM sum_map <nl> + GROUP BY timeslot <nl> <nl> . . code - block : : text <nl> <nl> - ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ timeslot ─ ┬ ─ sumMap ( statusMap . status , statusMap . requests ) ─ ┐ <nl> - │ 2000 - 01 - 01 00 : 00 : 00 │ ( [ 1 , 2 , 3 , 4 , 5 ] , [ 10 , 10 , 20 , 10 , 10 ] ) │ <nl> - │ 2000 - 01 - 01 00 : 01 : 00 │ ( [ 4 , 5 , 6 , 7 , 8 ] , [ 10 , 10 , 20 , 10 , 10 ] ) │ <nl> - └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┴ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ <nl> + ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ timeslot ─ ┬ ─ sumMap ( statusMap . status , statusMap . requests ) ─ ┐ <nl> + │ 2000 - 01 - 01 00 : 00 : 00 │ ( [ 1 , 2 , 3 , 4 , 5 ] , [ 10 , 10 , 20 , 10 , 10 ] ) │ <nl> + │ 2000 - 01 - 01 00 : 01 : 00 │ ( [ 4 , 5 , 6 , 7 , 8 ] , [ 10 , 10 , 20 , 10 , 10 ] ) │ <nl> + └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┴ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ <nl> <nl> avg ( x ) <nl> mmmmmm <nl>
|
Merge pull request from sundy - li / patch - 1
|
ClickHouse/ClickHouse
|
4fe58ffffe88758b559b02a7831f890e63962de4
|
2017-11-01T23:00:48Z
|
mmm a / js / server / modules / org / arangodb / graph . js <nl> ppp b / js / server / modules / org / arangodb / graph . js <nl> Graph . prototype . getVertex = function ( id ) { <nl> <nl> Graph . prototype . getVertices = function ( ) { <nl> var all = this . _vertices . all ( ) , <nl> - graph = this , <nl> - wrapper = function ( object ) { <nl> - return graph . constructVertex ( object ) ; <nl> - } ; <nl> + graph = this , <nl> + wrapper = function ( object ) { <nl> + return graph . constructVertex ( object ) ; <nl> + } ; <nl> return new Iterator ( wrapper , graph . constructVertex , " [ edge iterator ] " ) ; <nl> } ; <nl> <nl> Graph . prototype . getEdge = function ( id ) { <nl> <nl> Graph . prototype . getEdges = function ( ) { <nl> var all = this . _edges . all ( ) , <nl> - graph = this , <nl> - wrapper = function ( object ) { <nl> - return graph . constructEdge ( object ) ; <nl> - } ; <nl> + graph = this , <nl> + wrapper = function ( object ) { <nl> + return graph . constructEdge ( object ) ; <nl> + } ; <nl> return new Iterator ( wrapper , all , " [ edge iterator ] " ) ; <nl> } ; <nl> <nl>
|
Whitespace .
|
arangodb/arangodb
|
ea097f61926d7a1b4837104c6c9bb7c523147d2e
|
2013-10-31T11:14:03Z
|
mmm a / hphp / runtime / base / datetime . cpp <nl> ppp b / hphp / runtime / base / datetime . cpp <nl> void DateTime : : fromTimeStamp ( int64_t timestamp , bool utc / * = false * / ) { <nl> if ( ! m_tz . get ( ) ) { <nl> m_tz = TimeZone : : Current ( ) ; <nl> } <nl> - t - > tz_info = m_tz - > get ( ) ; <nl> - if ( ! t - > tz_info ) { <nl> + <nl> + if ( ! m_tz - > isValid ( ) ) { <nl> raise_error ( " No tz info found for timezone check for tzdata package . " ) ; <nl> } <nl> - t - > zone_type = TIMELIB_ZONETYPE_ID ; <nl> + <nl> + / / We could get a correct result for this time stamp by just using <nl> + / / ZONETYPE_OFFSET and m_tz - > offset ( timestamp ) ; the problem is that <nl> + / / potentially breaks if we do another timezone - sensitive operation <nl> + / / on the result . <nl> + t - > zone_type = m_tz - > type ( ) ; <nl> + switch ( t - > zone_type ) { <nl> + case TIMELIB_ZONETYPE_OFFSET : <nl> + t - > z = m_tz - > offset ( timestamp ) ; <nl> + break ; <nl> + case TIMELIB_ZONETYPE_ABBR : <nl> + t - > z = m_tz - > offset ( timestamp ) ; <nl> + t - > dst = m_tz - > dst ( timestamp ) ; <nl> + t - > tz_abbr = strdup ( m_tz - > abbr ( ) . data ( ) ) ; <nl> + break ; <nl> + case TIMELIB_ZONETYPE_ID : <nl> + t - > tz_info = m_tz - > getTZInfo ( ) ; <nl> + break ; <nl> + } <nl> timelib_unixtime2local ( t , ( timelib_sll ) m_timestamp ) ; <nl> } <nl> m_time = TimePtr ( t , time_deleter ( ) ) ; <nl> int DateTime : : offset ( ) const { <nl> { <nl> bool error ; <nl> timelib_time_offset * offset = <nl> - timelib_get_time_zone_info ( toTimeStamp ( error ) , m_tz - > get ( ) ) ; <nl> + timelib_get_time_zone_info ( toTimeStamp ( error ) , m_tz - > getTZInfo ( ) ) ; <nl> int ret = offset - > offset ; <nl> timelib_time_offset_dtor ( offset ) ; <nl> return ret ; <nl> void DateTime : : update ( ) { <nl> if ( utc ( ) ) { <nl> timelib_update_ts ( m_time . get ( ) , nullptr ) ; <nl> } else { <nl> - timelib_update_ts ( m_time . get ( ) , m_tz - > get ( ) ) ; <nl> + timelib_update_ts ( m_time . get ( ) , m_tz - > getTZInfo ( ) ) ; <nl> } <nl> m_timestamp = 0 ; <nl> m_timestampSet = false ; <nl> void DateTime : : setTime ( int hour , int minute , int second ) { <nl> } <nl> <nl> void DateTime : : setTimezone ( req : : ptr < TimeZone > timezone ) { <nl> - if ( timezone ) { <nl> - m_tz = timezone - > cloneTimeZone ( ) ; <nl> - if ( m_tz . get ( ) ) { <nl> - timelib_set_timezone ( m_time . get ( ) , m_tz - > get ( ) ) ; <nl> - timelib_unixtime2local ( m_time . get ( ) , m_time - > sse ) ; <nl> + if ( ! timezone ) { <nl> + return ; <nl> + } <nl> + <nl> + m_tz = timezone - > cloneTimeZone ( ) ; <nl> + <nl> + if ( ! m_tz . get ( ) ) { <nl> + return ; <nl> + } <nl> + <nl> + assert ( m_tz - > isValid ( ) ) ; <nl> + <nl> + switch ( m_tz - > type ( ) ) { <nl> + case TIMELIB_ZONETYPE_ID : <nl> + timelib_set_timezone ( m_time . get ( ) , m_tz - > getTZInfo ( ) ) ; <nl> + break ; <nl> + case TIMELIB_ZONETYPE_OFFSET : <nl> + timelib_set_timezone_from_offset ( m_time . get ( ) , m_tz - > offset ( 0 ) ) ; <nl> + break ; <nl> + case TIMELIB_ZONETYPE_ABBR : { <nl> + timelib_abbr_info abbr ; <nl> + abbr . utc_offset = m_tz - > offset ( 0 ) ; <nl> + abbr . abbr = strdup ( m_tz - > abbr ( ) . data ( ) ) ; <nl> + abbr . dst = m_tz - > dst ( 0 ) ; <nl> + timelib_set_timezone_from_abbr ( m_time . get ( ) , abbr ) ; <nl> + break ; <nl> } <nl> } <nl> + timelib_unixtime2local ( m_time . get ( ) , m_time - > sse ) ; <nl> } <nl> <nl> bool DateTime : : modify ( const String & diff ) { <nl> bool DateTime : : fromString ( const String & input , req : : ptr < TimeZone > tz , <nl> if ( m_timestamp = = - 1 ) { <nl> fromTimeStamp ( 0 ) ; <nl> } <nl> - if ( tz . get ( ) & & ( input . size ( ) < = 0 | | input [ 0 ] ! = ' @ ' ) ) { <nl> + if ( tz . get ( ) & & tz - > isValid ( ) & & ( input . size ( ) < = 0 | | input [ 0 ] ! = ' @ ' ) ) { <nl> setTimezone ( tz ) ; <nl> } else { <nl> setTimezone ( TimeZone : : Current ( ) ) ; <nl> bool DateTime : : fromString ( const String & input , req : : ptr < TimeZone > tz , <nl> <nl> / / needed if any date part is missing <nl> timelib_fill_holes ( t , m_time . get ( ) , TIMELIB_NO_CLONE ) ; <nl> - timelib_update_ts ( t , m_tz - > get ( ) ) ; <nl> + timelib_update_ts ( t , m_tz - > getTZInfo ( ) ) ; <nl> timelib_update_from_sse ( t ) ; <nl> <nl> int error2 ; <nl> bool DateTime : : fromString ( const String & input , req : : ptr < TimeZone > tz , <nl> } <nl> <nl> m_time = TimePtr ( t , time_deleter ( ) ) ; <nl> - if ( t - > tz_info ! = m_tz - > get ( ) ) { <nl> + if ( t - > tz_info ! = m_tz - > getTZInfo ( ) ) { <nl> m_tz = req : : make < TimeZone > ( t - > tz_info ) ; <nl> } <nl> return true ; <nl> mmm a / hphp / runtime / base / timestamp . cpp <nl> ppp b / hphp / runtime / base / timestamp . cpp <nl> Array TimeStamp : : CurrentTime ( ) { <nl> gettimeofday ( & tp , nullptr ) ; <nl> <nl> timelib_time_offset * offset = <nl> - timelib_get_time_zone_info ( tp . tv_sec , TimeZone : : Current ( ) - > get ( ) ) ; <nl> + timelib_get_time_zone_info ( tp . tv_sec , TimeZone : : Current ( ) - > getTZInfo ( ) ) ; <nl> <nl> auto const ret = make_map_array ( <nl> s_sec , ( int ) tp . tv_sec , <nl> mmm a / hphp / runtime / base / timezone . cpp <nl> ppp b / hphp / runtime / base / timezone . cpp <nl> <nl> <nl> namespace HPHP { <nl> <nl> - IMPLEMENT_RESOURCE_ALLOCATION ( TimeZone ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> struct GuessedTimeZone { <nl> TimeZone : : TimeZone ( ) { <nl> } <nl> <nl> TimeZone : : TimeZone ( const String & name ) { <nl> - m_tzi = GetTimeZoneInfoRaw ( ( char * ) name . data ( ) , GetDatabase ( ) ) ; <nl> + / * We can ' t just use GetTimeZoneInfoRaw , as that requires a real timezone <nl> + * name ; we need to handle other cases like ` GMT + 2 ` . Quirks : <nl> + * <nl> + * - ` GMT + 2 ` is a ZONETYPE_OFFSET , but ` Etc / GMT + 2 ` is a ZONETYPE_ID <nl> + * - ` GMT + 0 ` is usually ( tzdb - dependent ) a ZONETYPE_ID <nl> + * - ` CET ` quirk below <nl> + * / <nl> + <nl> + char * tzname = ( char * ) name . data ( ) ; <nl> + / / Try an ID lookup first , so that ` CET ` is interpreted as an ID , not an <nl> + / / abbreviation . It ' s valid as either . PHP 5 . 5 + considers it an abbreviation , <nl> + / / HHVM currently intentionally considers it an ID for backwards <nl> + / / compatibility ( which matches PHP < = 5 . 4 ) <nl> + m_tzi = GetTimeZoneInfoRaw ( tzname , GetDatabase ( ) ) ; <nl> + if ( m_tzi ) { <nl> + m_tztype = TIMELIB_ZONETYPE_ID ; <nl> + return ; <nl> + } <nl> + <nl> + / / Not a timezone ID , try to parse it more generally . <nl> + <nl> + timelib_time * dummy = timelib_time_ctor ( ) ; <nl> + SCOPE_EXIT { timelib_time_dtor ( dummy ) ; } ; <nl> + int dst , not_found ; <nl> + dummy - > z = timelib_parse_zone ( & tzname , & dst , dummy , & not_found , GetDatabase ( ) , <nl> + GetTimeZoneInfoRaw ) ; <nl> + if ( not_found ) { <nl> + return ; <nl> + } <nl> + <nl> + m_tztype = dummy - > zone_type ; <nl> + switch ( dummy - > zone_type ) { <nl> + case TIMELIB_ZONETYPE_ID : { <nl> + always_assert ( false & & TIMELIB_ZONETYPE_ID ) ; <nl> + break ; <nl> + } <nl> + case TIMELIB_ZONETYPE_OFFSET : <nl> + m_offset = dummy - > z ; <nl> + break ; <nl> + case TIMELIB_ZONETYPE_ABBR : <nl> + m_offset = dummy - > z ; <nl> + m_dst = dummy - > dst ; <nl> + m_abbr = String ( dummy - > tz_abbr , CopyString ) ; <nl> + break ; <nl> + } <nl> } <nl> <nl> TimeZone : : TimeZone ( timelib_tzinfo * tzi ) { <nl> m_tzi = tzi ; <nl> + m_tztype = TIMELIB_ZONETYPE_ID ; <nl> } <nl> <nl> req : : ptr < TimeZone > TimeZone : : cloneTimeZone ( ) const { <nl> - return req : : make < TimeZone > ( m_tzi ) ; <nl> + auto tz = req : : make < TimeZone > ( ) ; <nl> + tz - > m_tztype = m_tztype ; <nl> + tz - > m_tzi = m_tzi ; <nl> + tz - > m_offset = m_offset ; <nl> + tz - > m_dst = m_dst ; <nl> + tz - > m_abbr = m_abbr ; <nl> + assert ( tz - > isValid ( ) = = isValid ( ) & & " incomplete TimeZone copy " ) ; <nl> + return tz ; <nl> } <nl> <nl> String TimeZone : : name ( ) const { <nl> - if ( ! m_tzi ) return String ( ) ; <nl> - return String ( m_tzi - > name , CopyString ) ; <nl> + switch ( m_tztype ) { <nl> + case TIMELIB_ZONETYPE_ID : <nl> + assertx ( m_tzi ) ; <nl> + return String ( m_tzi - > name , CopyString ) ; <nl> + case TIMELIB_ZONETYPE_ABBR : <nl> + return String ( m_abbr , CopyString ) ; <nl> + case TIMELIB_ZONETYPE_OFFSET : { <nl> + char buf [ sizeof ( " + 00 : 00 " ) ] ; <nl> + snprintf ( <nl> + buf , <nl> + sizeof ( " + 00 : 00 " ) , <nl> + " % c % 02d : % 02d " , <nl> + ( m_offset > 0 ? ' - ' : ' + ' ) , <nl> + abs ( m_offset / 60 ) , <nl> + abs ( m_offset % 60 ) <nl> + ) ; <nl> + return String ( buf , sizeof ( " + 00 : 00 " ) - 1 , CopyString ) ; <nl> + } <nl> + } <nl> + always_assert ( false & & " invalid tz type " ) ; <nl> } <nl> <nl> String TimeZone : : abbr ( int type / * = 0 * / ) const { <nl> + if ( m_tztype = = TIMELIB_ZONETYPE_ABBR ) { <nl> + return String ( m_abbr , CopyString ) ; <nl> + } <nl> + <nl> if ( ! m_tzi ) return String ( ) ; <nl> return String ( & m_tzi - > timezone_abbr [ m_tzi - > type [ type ] . abbr_idx ] , CopyString ) ; <nl> } <nl> <nl> + int TimeZone : : type ( ) const { <nl> + return m_tztype ; <nl> + } <nl> + <nl> int TimeZone : : offset ( int64_t timestamp ) const { <nl> - if ( ! m_tzi ) return 0 ; <nl> + if ( m_tztype = = TIMELIB_ZONETYPE_OFFSET <nl> + | | m_tztype = = TIMELIB_ZONETYPE_ABBR ) { <nl> + return m_offset ; <nl> + } <nl> + <nl> + assertx ( m_tzi & & m_tztype = = TIMELIB_ZONETYPE_ID ) ; <nl> <nl> timelib_time_offset * offset = <nl> timelib_get_time_zone_info ( timestamp , m_tzi ) ; <nl> int TimeZone : : offset ( int64_t timestamp ) const { <nl> } <nl> <nl> bool TimeZone : : dst ( int64_t timestamp ) const { <nl> + if ( m_tztype = = TIMELIB_ZONETYPE_ABBR ) { <nl> + return m_dst ; <nl> + } <nl> if ( ! m_tzi ) return false ; <nl> <nl> timelib_time_offset * offset = <nl> bool TimeZone : : dst ( int64_t timestamp ) const { <nl> Array TimeZone : : transitions ( int64_t timestamp_begin , / * = k_PHP_INT_MIN * / <nl> int64_t timestamp_end / * = k_PHP_INT_MAX * / ) const { <nl> Array ret ; <nl> - if ( m_tzi ) { <nl> - uint32_t timecnt ; <nl> - timecnt = m_tzi - > bit32 . timecnt ; <nl> - uint32_t lastBefore = 0 ; <nl> - for ( uint32_t i = 0 ; <nl> - i < timecnt & & m_tzi - > trans & & m_tzi - > trans [ i ] < = timestamp_begin ; <nl> - + + i ) { <nl> - lastBefore = i ; <nl> + <nl> + if ( m_tztype = = TIMELIB_ZONETYPE_ABBR ) { <nl> + / / PHP 5 . 5 + just returns ` false ` here , but we ' re probably depending on <nl> + / / on this working for some of the timezones that can be parsed either <nl> + / / as an ID ( old behavior ) or abbreviation ( new behavior ) , e . g . ' CDT ' <nl> + / / . . . BC is nice anyway : ) <nl> + auto name = timelib_timezone_id_from_abbr ( <nl> + m_abbr . data ( ) , <nl> + m_offset , <nl> + m_dst <nl> + ) ; <nl> + if ( name ) { <nl> + auto tz = req : : make < TimeZone > ( name ) ; <nl> + return tz - > transitions ( timestamp_begin , timestamp_end ) ; <nl> } <nl> - / / If explicitly provided a timestamp to the ret array <nl> - / / and always make sure there is at least one returned value <nl> - if ( ! m_tzi - > trans | | <nl> - timestamp_begin > = timestamp_end | | ( <nl> - ( timestamp_begin ! = k_PHP_INT_MIN | | timestamp_end ! = k_PHP_INT_MAX ) & & <nl> - timestamp_begin ! = m_tzi - > trans [ lastBefore ] ) ) { <nl> - auto dt = req : : make < DateTime > ( <nl> - timestamp_begin , req : : make < TimeZone > ( " UTC " ) ) ; <nl> - int index = m_tzi - > trans ? m_tzi - > trans_idx [ lastBefore ] : 0 ; <nl> + } <nl> + <nl> + if ( ! m_tzi ) { <nl> + return ret ; <nl> + } <nl> + <nl> + uint32_t timecnt ; <nl> + timecnt = m_tzi - > bit32 . timecnt ; <nl> + uint32_t lastBefore = 0 ; <nl> + for ( uint32_t i = 0 ; <nl> + i < timecnt & & m_tzi - > trans & & m_tzi - > trans [ i ] < = timestamp_begin ; <nl> + + + i ) { <nl> + lastBefore = i ; <nl> + } <nl> + / / If explicitly provided a timestamp to the ret array <nl> + / / and always make sure there is at least one returned value <nl> + if ( ! m_tzi - > trans | | <nl> + timestamp_begin > = timestamp_end | | ( <nl> + ( timestamp_begin ! = k_PHP_INT_MIN | | timestamp_end ! = k_PHP_INT_MAX ) & & <nl> + timestamp_begin ! = m_tzi - > trans [ lastBefore ] ) ) { <nl> + auto dt = req : : make < DateTime > ( <nl> + timestamp_begin , req : : make < TimeZone > ( " UTC " ) ) ; <nl> + int index = m_tzi - > trans ? m_tzi - > trans_idx [ lastBefore ] : 0 ; <nl> + ttinfo & offset = m_tzi - > type [ index ] ; <nl> + const char * abbr = m_tzi - > timezone_abbr + offset . abbr_idx ; <nl> + ret . append ( make_map_array ( <nl> + s_ts , timestamp_begin , <nl> + s_time , dt - > toString ( DateTime : : DateFormat : : ISO8601 ) , <nl> + s_offset , offset . offset , <nl> + s_isdst , ( bool ) offset . isdst , <nl> + s_abbr , String ( abbr , CopyString ) <nl> + ) ) ; <nl> + } <nl> + for ( uint32_t i = lastBefore ; <nl> + i < timecnt & & m_tzi - > trans & & m_tzi - > trans [ i ] < timestamp_end ; <nl> + + + i ) { <nl> + int timestamp = m_tzi - > trans [ i ] ; <nl> + if ( timestamp_begin < = timestamp ) { <nl> + int index = m_tzi - > trans_idx [ i ] ; <nl> + auto dt = req : : make < DateTime > ( timestamp , req : : make < TimeZone > ( " UTC " ) ) ; <nl> ttinfo & offset = m_tzi - > type [ index ] ; <nl> const char * abbr = m_tzi - > timezone_abbr + offset . abbr_idx ; <nl> + <nl> ret . append ( make_map_array ( <nl> - s_ts , timestamp_begin , <nl> + s_ts , timestamp , <nl> s_time , dt - > toString ( DateTime : : DateFormat : : ISO8601 ) , <nl> s_offset , offset . offset , <nl> s_isdst , ( bool ) offset . isdst , <nl> s_abbr , String ( abbr , CopyString ) <nl> ) ) ; <nl> } <nl> - for ( uint32_t i = lastBefore ; <nl> - i < timecnt & & m_tzi - > trans & & m_tzi - > trans [ i ] < timestamp_end ; <nl> - + + i ) { <nl> - int timestamp = m_tzi - > trans [ i ] ; <nl> - if ( timestamp_begin < = timestamp ) { <nl> - int index = m_tzi - > trans_idx [ i ] ; <nl> - auto dt = req : : make < DateTime > ( timestamp , req : : make < TimeZone > ( " UTC " ) ) ; <nl> - ttinfo & offset = m_tzi - > type [ index ] ; <nl> - const char * abbr = m_tzi - > timezone_abbr + offset . abbr_idx ; <nl> - <nl> - ret . append ( make_map_array ( <nl> - s_ts , timestamp , <nl> - s_time , dt - > toString ( DateTime : : DateFormat : : ISO8601 ) , <nl> - s_offset , offset . offset , <nl> - s_isdst , ( bool ) offset . isdst , <nl> - s_abbr , String ( abbr , CopyString ) <nl> - ) ) ; <nl> - } <nl> - } <nl> } <nl> return ret ; <nl> } <nl> Array TimeZone : : getLocation ( ) const { <nl> return ret ; <nl> } <nl> <nl> + void TimeZone : : sweep ( ) { <nl> + m_abbr . reset ( ) ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> } <nl> mmm a / hphp / runtime / base / timezone . h <nl> ppp b / hphp / runtime / base / timezone . h <nl> struct TimeZone : SweepableResourceData { <nl> / * * <nl> * Whether this represents a valid timezone . <nl> * / <nl> - bool isValid ( ) const { return get ( ) ; } <nl> + bool isValid ( ) const { <nl> + switch ( m_tztype ) { <nl> + case 0 : <nl> + return false ; <nl> + case TIMELIB_ZONETYPE_ID : <nl> + return getTZInfo ( ) ; <nl> + case TIMELIB_ZONETYPE_OFFSET : <nl> + case TIMELIB_ZONETYPE_ABBR : <nl> + return true ; <nl> + } <nl> + always_assert ( false & & " invalid tztype " ) ; <nl> + } <nl> <nl> / * * <nl> * Get timezone ' s name or abbreviation . <nl> * / <nl> String name ( ) const ; <nl> String abbr ( int type = 0 ) const ; <nl> + int type ( ) const ; <nl> <nl> / * * <nl> * Get offset from UTC at the specified timestamp under this timezone . <nl> struct TimeZone : SweepableResourceData { <nl> <nl> / * * <nl> * Returns raw pointer . For internal use only . <nl> + * <nl> + * If type ( ) ! = = TIMELIB_ZONETYPE_ID , this will definitely return nullptr , <nl> + * even if isValid ( ) . <nl> * / <nl> - timelib_tzinfo * get ( ) const { return m_tzi ; } <nl> + timelib_tzinfo * getTZInfo ( ) const { return m_tzi ; } <nl> <nl> private : <nl> static const timelib_tzdb * GetDatabase ( ) ; <nl> struct TimeZone : SweepableResourceData { <nl> * / <nl> static timelib_tzinfo * GetTimeZoneInfoRaw ( char * name , const timelib_tzdb * db ) ; <nl> <nl> - timelib_tzinfo * m_tzi ; <nl> + unsigned int m_tztype = 0 ; <nl> + timelib_tzinfo * m_tzi = nullptr ; <nl> + int m_offset ; <nl> + int m_dst ; <nl> + String m_abbr ; <nl> } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / hphp / runtime / ext / datetime / ext_datetime . cpp <nl> ppp b / hphp / runtime / ext / datetime / ext_datetime . cpp <nl> Variant HHVM_METHOD ( DateTimeZone , getOffset , <nl> return data - > m_tz - > offset ( ts ) ; <nl> } <nl> <nl> - Array HHVM_METHOD ( DateTimeZone , getTransitions , <nl> + TypedValue HHVM_METHOD ( DateTimeZone , getTransitions , <nl> int64_t timestamp_begin , / * = k_PHP_INT_MIN * / <nl> int64_t timestamp_end / * = k_PHP_INT_MAX * / ) { <nl> DateTimeZoneData * data = Native : : data < DateTimeZoneData > ( this_ ) ; <nl> - return data - > m_tz - > transitions ( timestamp_begin , timestamp_end ) ; <nl> + auto result = data - > m_tz - > transitions ( timestamp_begin , timestamp_end ) ; <nl> + if ( result . isNull ( ) ) { <nl> + return make_tv < KindOfBoolean > ( false ) ; <nl> + } <nl> + return tvReturn ( std : : move ( result ) ) ; <nl> } <nl> <nl> Array HHVM_STATIC_METHOD ( DateTimeZone , listAbbreviations ) { <nl> req : : ptr < TimeZone > DateTimeZoneData : : unwrap ( const Object & timezone ) { <nl> <nl> IMPLEMENT_GET_CLASS ( DateTimeZoneData ) <nl> <nl> + Array HHVM_METHOD ( DateTimeZone , __debuginfo ) { <nl> + DateTimeZoneData * data = Native : : data < DateTimeZoneData > ( this_ ) ; <nl> + return data - > getDebugInfo ( ) ; <nl> + } <nl> + <nl> + Array DateTimeZoneData : : getDebugInfo ( ) const { <nl> + return make_map_array ( <nl> + s_timezone_type , m_tz - > type ( ) , <nl> + s_timezone , m_tz - > name ( ) <nl> + ) ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / DateInterval <nl> <nl> static struct DateTimeExtension final : Extension { <nl> HHVM_RCC_INT ( DateTimeZone , PER_COUNTRY , DateTimeZoneData : : PER_COUNTRY ) ; <nl> <nl> HHVM_ME ( DateTimeZone , __construct ) ; <nl> + HHVM_ME ( DateTimeZone , __debuginfo ) ; <nl> HHVM_ME ( DateTimeZone , getLocation ) ; <nl> HHVM_ME ( DateTimeZone , getName ) ; <nl> HHVM_ME ( DateTimeZone , getOffset ) ; <nl> mmm a / hphp / runtime / ext / datetime / ext_datetime . h <nl> ppp b / hphp / runtime / ext / datetime / ext_datetime . h <nl> struct DateTimeZoneData { <nl> m_tz = other . m_tz - > cloneTimeZone ( ) ; <nl> return * this ; <nl> } <nl> + <nl> String getName ( ) const { <nl> return m_tz - > name ( ) ; <nl> } <nl> <nl> + Array getDebugInfo ( ) const ; <nl> + <nl> static Object wrap ( req : : ptr < TimeZone > tz ) ; <nl> static req : : ptr < TimeZone > unwrap ( const Object & timezone ) ; <nl> static Class * getClass ( ) ; <nl> void HHVM_METHOD ( DateTimeZone , __construct , <nl> const String & timezone ) ; <nl> Array HHVM_METHOD ( DateTimeZone , getLocation ) ; <nl> String HHVM_METHOD ( DateTimeZone , getName ) ; <nl> + Array HHVM_METHOD ( DateTimeZone , __debuginfo ) ; <nl> Variant HHVM_METHOD ( DateTimeZone , getOffset , <nl> const Object & datetime ) ; <nl> - Array HHVM_METHOD ( DateTimeZone , getTransitions , <nl> - int64_t timestamp_begin = k_PHP_INT_MIN , <nl> - int64_t timestamp_end = k_PHP_INT_MAX ) ; <nl> + TypedValue HHVM_METHOD ( DateTimeZone , getTransitions , <nl> + int64_t timestamp_begin = k_PHP_INT_MIN , <nl> + int64_t timestamp_end = k_PHP_INT_MAX ) ; <nl> Array HHVM_STATIC_METHOD ( DateTimeZone , listAbbreviations ) ; <nl> Variant HHVM_STATIC_METHOD ( DateTimeZone , listIdentifiers , <nl> int64_t what , <nl> mmm a / hphp / runtime / ext / datetime / ext_datetime . php <nl> ppp b / hphp / runtime / ext / datetime / ext_datetime . php <nl> function getOffset ( DateTimeInterface $ datetime ) : mixed ; <nl> * / <nl> < < __Native > > <nl> function getTransitions ( int $ timestamp_begin = PHP_INT_MIN , <nl> - int $ timestamp_end = PHP_INT_MAX ) : array ; <nl> + int $ timestamp_end = PHP_INT_MAX ) : mixed ; <nl> <nl> / * * <nl> * @ return array - Returns array on success or FALSE on failure . <nl> static function listAbbreviations ( ) : array ; <nl> < < __Native > > <nl> static function listIdentifiers ( int $ what = 2047 , <nl> string $ country = " " ) : mixed ; <nl> + <nl> + < < __Native > > <nl> + function __debugInfo ( ) : array ; <nl> } <nl> <nl> / * * <nl> function timezone_open ( string $ timezone ) : mixed { <nl> <nl> function timezone_transitions_get ( DateTimeZone $ timezone , <nl> int $ timestamp_begin = PHP_INT_MIN , <nl> - int $ timestamp_end = PHP_INT_MAX ) : array { <nl> + int $ timestamp_end = PHP_INT_MAX ) : mixed { <nl> return $ timezone - > getTransitions ( $ timestamp_begin , $ timestamp_end ) ; <nl> } <nl> <nl> mmm a / hphp / test / quick / builtin_extension_DateTimeZone . php . expectf <nl> ppp b / hphp / test / quick / builtin_extension_DateTimeZone . php . expectf <nl> <nl> DateTimeZone <nl> - object ( DateTimeZone ) # 1 ( 0 ) { <nl> + object ( DateTimeZone ) # 1 ( 2 ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 3 ) <nl> + [ " timezone " ] = > <nl> + string ( 3 ) " UTC " <nl> } <nl> <nl> Warning : Attempted to serialize unserializable builtin class DateTimeZone in % s / test / quick / builtin_extensions . inc on line 8 <nl> string ( 2 ) " N ; " <nl> NULL <nl> - array ( 7 ) { <nl> + array ( 8 ) { <nl> [ 0 ] = > <nl> string ( 11 ) " __construct " <nl> [ 1 ] = > <nl> array ( 7 ) { <nl> string ( 17 ) " listAbbreviations " <nl> [ 6 ] = > <nl> string ( 15 ) " listIdentifiers " <nl> + [ 7 ] = > <nl> + string ( 11 ) " __debugInfo " <nl> } <nl> = = = = = = = = = = = = = = = = <nl> A_DateTimeZone <nl> - object ( A_DateTimeZone ) # 2 ( 1 ) { <nl> - [ " ___x " ] = > <nl> - NULL <nl> + object ( A_DateTimeZone ) # 2 ( 2 ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 3 ) <nl> + [ " timezone " ] = > <nl> + string ( 3 ) " UTC " <nl> } <nl> <nl> Warning : Attempted to serialize unserializable builtin class A_DateTimeZone in % s / test / quick / builtin_extensions . inc on line 26 <nl> string ( 2 ) " N ; " <nl> NULL <nl> - array ( 7 ) { <nl> + array ( 8 ) { <nl> [ 0 ] = > <nl> string ( 11 ) " __construct " <nl> [ 1 ] = > <nl> array ( 7 ) { <nl> string ( 17 ) " listAbbreviations " <nl> [ 6 ] = > <nl> string ( 15 ) " listIdentifiers " <nl> + [ 7 ] = > <nl> + string ( 11 ) " __debugInfo " <nl> } <nl> \ No newline at end of file <nl> mmm a / hphp / test / slow / debugger / print - datetime . php . expectf <nl> ppp b / hphp / test / slow / debugger / print - datetime . php . expectf <nl> DateTime Object <nl> = function ( ) { return 4 ; } ; <nl> " Closure % s " <nl> p new DateTime ( ' @ ' . time ( ) , new DateTimeZone ( ' UTC ' ) ) <nl> - wire error : unserialize ( ) threw ' Exception ' with message ' DateTimeZone : : __construct ( ) : Unknown or bad timezone ( + 00 : 00 ) ' <nl> - null <nl> + DateTime Object <nl> + ( <nl> + [ date ] = > " % s " <nl> + [ timezone_type ] = > 1 <nl> + [ timezone ] = > " + 00 : 00 " <nl> + ) <nl> + <nl> c <nl> Break on line 2 of % s / print - datetime . php <nl> 1 < ? php <nl> 2 * hphpd_break ( ) ; <nl> 3 ( END ) <nl> <nl> - quit <nl> \ No newline at end of file <nl> + quit <nl> mmm a / hphp / test / slow / ext_datetime / date_timezone . php <nl> ppp b / hphp / test / slow / ext_datetime / date_timezone . php <nl> <nl> < ? php <nl> <nl> date_default_timezone_set ( " America / Los_Angeles " ) ; <nl> - <nl> var_dump ( date_default_timezone_get ( ) ) ; <nl> <nl> var_dump ( date_default_timezone_set ( " Asia / Shanghai " ) ) ; <nl> <nl> var_dump ( timezone_name_get ( $ tz ) ) ; <nl> $ tz = timezone_open ( " CHAST " ) ; <nl> var_dump ( timezone_name_get ( $ tz ) ) ; <nl> + $ tz = timezone_open ( " + 01 : 23 " ) ; <nl> + var_dump ( timezone_name_get ( $ tz ) ) ; <nl> <nl> var_dump ( ( bool ) timezone_version_get ( ) ) ; <nl> <nl> mmm a / hphp / test / slow / ext_datetime / date_timezone . php . expectf <nl> ppp b / hphp / test / slow / ext_datetime / date_timezone . php . expectf <nl> string ( 4 ) " CEST " <nl> string ( 16 ) " America / New_York " <nl> string ( 19 ) " America / Los_Angeles " <nl> string ( 15 ) " Pacific / Chatham " <nl> + string ( 6 ) " + 01 : 23 " <nl> bool ( true ) <nl> <nl> Warning : timezone_open ( ) : Unknown or bad timezone ( sdf ) in % s <nl> new file mode 100644 <nl> index 00000000000 . . a7abc4fc17e <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / ext_datetime / gmt_offsets . php <nl> <nl> + < ? php <nl> + <nl> + $ tzs = [ <nl> + ' GMT + 0 ' , <nl> + ' GMT - 1 ' , <nl> + ' GMT + 1 ' , <nl> + ' Etc / GMT + 0 ' , <nl> + ' Etc / GMT + 1 ' , <nl> + ' Etc / GMT - 1 ' , <nl> + ] ; <nl> + <nl> + foreach ( $ tzs as $ tz ) { <nl> + var_dump ( new DateTimeZone ( $ tz ) ) ; <nl> + } <nl> + <nl> + print ( " mmmRepeating to check cachingmmm \ n " ) ; <nl> + <nl> + foreach ( $ tzs as $ tz ) { <nl> + var_dump ( new DateTimeZone ( $ tz ) ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 924c593c4a1 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / ext_datetime / gmt_offsets . php . expectf <nl> <nl> + object ( DateTimeZone ) # % d ( % d ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 3 ) <nl> + [ " timezone " ] = > <nl> + string ( 5 ) " GMT + 0 " <nl> + } <nl> + object ( DateTimeZone ) # % d ( % d ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 1 ) <nl> + [ " timezone " ] = > <nl> + string ( 6 ) " - 01 : 00 " <nl> + } <nl> + object ( DateTimeZone ) # % d ( % d ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 1 ) <nl> + [ " timezone " ] = > <nl> + string ( 6 ) " + 01 : 00 " <nl> + } <nl> + object ( DateTimeZone ) # % d ( % d ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 3 ) <nl> + [ " timezone " ] = > <nl> + string ( 9 ) " Etc / GMT + 0 " <nl> + } <nl> + object ( DateTimeZone ) # % d ( % d ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 3 ) <nl> + [ " timezone " ] = > <nl> + string ( 9 ) " Etc / GMT + 1 " <nl> + } <nl> + object ( DateTimeZone ) # % d ( % d ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 3 ) <nl> + [ " timezone " ] = > <nl> + string ( 9 ) " Etc / GMT - 1 " <nl> + } <nl> + mmmRepeating to check cachingmmm <nl> + object ( DateTimeZone ) # % d ( % d ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 3 ) <nl> + [ " timezone " ] = > <nl> + string ( 5 ) " GMT + 0 " <nl> + } <nl> + object ( DateTimeZone ) # % d ( % d ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 1 ) <nl> + [ " timezone " ] = > <nl> + string ( 6 ) " - 01 : 00 " <nl> + } <nl> + object ( DateTimeZone ) # % d ( % d ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 1 ) <nl> + [ " timezone " ] = > <nl> + string ( 6 ) " + 01 : 00 " <nl> + } <nl> + object ( DateTimeZone ) # % d ( % d ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 3 ) <nl> + [ " timezone " ] = > <nl> + string ( 9 ) " Etc / GMT + 0 " <nl> + } <nl> + object ( DateTimeZone ) # % d ( % d ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 3 ) <nl> + [ " timezone " ] = > <nl> + string ( 9 ) " Etc / GMT + 1 " <nl> + } <nl> + object ( DateTimeZone ) # % d ( % d ) { <nl> + [ " timezone_type " ] = > <nl> + int ( 3 ) <nl> + [ " timezone " ] = > <nl> + string ( 9 ) " Etc / GMT - 1 " <nl> + } <nl>
|
Support ` DateTimeZone ` objects with offset or abbreviation - based TZs
|
facebook/hhvm
|
7d4edb2645b3db58413dc1385fbc1806c90eaa2f
|
2018-05-05T01:18:32Z
|
mmm a / plugins / COMMUNITY . md <nl> ppp b / plugins / COMMUNITY . md <nl> Third parties are encouraged to make pull requests to this file ( ` develop ` branc <nl> | Chintai ZMQ Watcher | https : / / github . com / acoutts / chintai - zeromq - watcher - plugin | <nl> | Mongo History API | https : / / github . com / CryptoLions / EOS - mongo - history - API | <nl> | State History API | https : / / github . com / acoutts / EOS - state - history - API | <nl> + | Hyperion History API | https : / / github . com / eosrio / Hyperion - History - API | <nl> <nl> # # DISCLAIMER : <nl> <nl>
|
Added EOS Rio ' s Hyperion History API
|
EOSIO/eos
|
34ce13df2fb81f49efabd565829d1245c8bef452
|
2019-03-13T11:34:15Z
|
mmm a / ios / sdk / WeexSDK / Sources / Utility / WXConvert . m <nl> ppp b / ios / sdk / WeexSDK / Sources / Utility / WXConvert . m <nl> + ( WXTextWeight ) WXTextWeight : ( id ) value <nl> if ( [ value isKindOfClass : [ NSString class ] ] ) { <nl> NSString * string = ( NSString * ) value ; <nl> if ( [ string isEqualToString : @ " normal " ] ) <nl> - return WXTextWeightNormal ; <nl> + return WXFontWeightRegular ; <nl> else if ( [ string isEqualToString : @ " bold " ] ) <nl> - return WXTextWeightBold ; <nl> + return WXFontWeightBold ; <nl> + else if ( [ string isEqualToString : @ " 100 " ] ) <nl> + return WXFontWeightUltraLight ; <nl> + else if ( [ string isEqualToString : @ " 200 " ] ) <nl> + return WXFontWeightThin ; <nl> + else if ( [ string isEqualToString : @ " 300 " ] ) <nl> + return WXFontWeightLight ; <nl> + else if ( [ string isEqualToString : @ " 400 " ] ) <nl> + return WXFontWeightRegular ; <nl> + else if ( [ string isEqualToString : @ " 500 " ] ) <nl> + return WXFontWeightMedium ; <nl> + else if ( [ string isEqualToString : @ " 600 " ] ) <nl> + return WXFontWeightSemibold ; <nl> + else if ( [ string isEqualToString : @ " 700 " ] ) <nl> + return WXFontWeightBold ; <nl> + else if ( [ string isEqualToString : @ " 800 " ] ) <nl> + return WXFontWeightHeavy ; <nl> + else if ( [ string isEqualToString : @ " 900 " ] ) <nl> + return WXFontWeightBlack ; <nl> + <nl> } <nl> - return WXTextWeightNormal ; <nl> + return WXFontWeightRegular ; <nl> } <nl> <nl> + ( WXTextDecoration ) WXTextDecoration : ( id ) value <nl> mmm a / ios / sdk / WeexSDK / Sources / Utility / WXType . h <nl> ppp b / ios / sdk / WeexSDK / Sources / Utility / WXType . h <nl> typedef NS_ENUM ( NSUInteger , WXTextStyle ) { <nl> } ; <nl> <nl> typedef NS_ENUM ( NSUInteger , WXTextWeight ) { <nl> - WXTextWeightNormal = 0 , <nl> - WXTextWeightBold , <nl> + WXFontWeightRegular = 0 , <nl> + WXFontWeightUltraLight , <nl> + WXFontWeightThin , <nl> + WXFontWeightLight , <nl> + WXFontWeightMedium , <nl> + WXFontWeightSemibold , <nl> + WXFontWeightBold , <nl> + WXFontWeightHeavy , <nl> + WXFontWeightBlack <nl> + <nl> } ; <nl> <nl> typedef NS_ENUM ( NSInteger , WXTextDecoration ) { <nl> mmm a / ios / sdk / WeexSDK / Sources / Utility / WXUtility . m <nl> ppp b / ios / sdk / WeexSDK / Sources / Utility / WXUtility . m <nl> + ( UIFont * ) fontWithSize : ( CGFloat ) size textWeight : ( WXTextWeight ) textWeight textS <nl> [ [ WXRuleManager sharedInstance ] removeRule : @ " fontFace " rule : @ { @ " fontFamily " : fontFamily } ] ; <nl> } <nl> } <nl> + CGFloat weight = WXFontWeightRegular ; <nl> + weight = [ WXUtility textWeight : textWeight ] ; <nl> if ( ! font ) { <nl> if ( fontFamily ) { <nl> font = [ UIFont fontWithName : fontFamily size : fontSize ] ; <nl> if ( ! font ) { <nl> WXLogWarning ( @ " Unknown fontFamily : % @ " , fontFamily ) ; <nl> - font = [ UIFont systemFontOfSize : fontSize ] ; <nl> + font = [ UIFont systemFontOfSize : fontSize weight : weight ] ; <nl> } <nl> } else { <nl> - font = [ UIFont systemFontOfSize : fontSize ] ; <nl> + font = [ UIFont systemFontOfSize : fontSize weight : weight ] ; <nl> } <nl> } <nl> - <nl> UIFontDescriptor * fontD = font . fontDescriptor ; <nl> UIFontDescriptorSymbolicTraits traits = 0 ; <nl> traits = ( textStyle = = WXTextStyleItalic ) ? ( traits | UIFontDescriptorTraitItalic ) : traits ; <nl> - traits = ( textWeight = = WXTextWeightBold ) ? ( traits | UIFontDescriptorTraitBold ) : traits ; <nl> + traits = ( textWeight = = WXFontWeightBold ) ? ( traits | UIFontDescriptorTraitBold ) : traits ; <nl> if ( traits ! = 0 ) { <nl> fontD = [ fontD fontDescriptorWithSymbolicTraits : traits ] ; <nl> UIFont * tempFont = [ UIFont fontWithDescriptor : fontD size : 0 ] ; <nl> + ( UIFont * ) fontWithSize : ( CGFloat ) size textWeight : ( WXTextWeight ) textWeight textS <nl> return font ; <nl> } <nl> <nl> + + ( CGFloat ) textWeight : ( WXTextWeight ) type <nl> + { <nl> + CGFloat weight = WXFontWeightRegular ; <nl> + switch ( type ) { <nl> + case WXFontWeightUltraLight : <nl> + weight = - 0 . 8 ; <nl> + break ; <nl> + case WXFontWeightThin : <nl> + weight = - 0 . 6 ; <nl> + break ; <nl> + case WXFontWeightLight : <nl> + weight = - 0 . 4 ; <nl> + break ; <nl> + case WXFontWeightRegular : <nl> + weight = 0 ; <nl> + break ; <nl> + case WXFontWeightMedium : <nl> + weight = 0 . 23 ; <nl> + break ; <nl> + case WXFontWeightSemibold : <nl> + weight = 0 . 3 ; <nl> + break ; <nl> + case WXFontWeightBold : <nl> + weight = 0 . 4 ; <nl> + break ; <nl> + case WXFontWeightHeavy : <nl> + weight = 0 . 56 ; <nl> + break ; <nl> + case WXFontWeightBlack : <nl> + weight = 0 . 62 ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + return weight ; <nl> + } <nl> + <nl> + ( void ) getIconfont : ( NSURL * ) url completion : ( void ( ^ ) ( NSURL * url , NSError * error ) ) completionBlock <nl> { <nl> if ( [ url isFileURL ] ) { <nl>
|
+ [ ios ] add font weight for iOS weex sdk , use the font value not macro , because font weight macro is only enable in os version 8 . 2
|
apache/incubator-weex
|
40244c16fddf17727e0f24e0f33116ed2e9d986f
|
2016-12-19T13:26:56Z
|
mmm a / modules / monitor / software / summary_monitor . cc <nl> ppp b / modules / monitor / software / summary_monitor . cc <nl> void SummaryMonitor : : SummarizeModules ( ) { <nl> for ( auto & module : * MonitorManager : : GetStatus ( ) - > mutable_modules ( ) ) { <nl> ModuleStatus * status = & ( module . second ) ; <nl> <nl> - if ( status - > has_process_status ( ) & & ! status - > process_status ( ) . running ( ) ) { <nl> - UpdateStatusSummary ( Summary : : FATAL , " No process " , status ) ; <nl> - continue ; <nl> + if ( status - > has_process_status ( ) ) { <nl> + if ( status - > process_status ( ) . running ( ) ) { <nl> + UpdateStatusSummary ( Summary : : OK , " " , status ) ; <nl> + } else { <nl> + UpdateStatusSummary ( Summary : : FATAL , " No process " , status ) ; <nl> + continue ; <nl> + } <nl> } <nl> <nl> if ( status - > has_topic_status ( ) ) { <nl>
|
Monitor : Fix missed OK status for process monitoring .
|
ApolloAuto/apollo
|
ba924b4d2439dc3a51c69476649a43e8dc5dc4f2
|
2017-12-23T23:00:44Z
|
mmm a / scene / 3d / mesh_instance_3d . cpp <nl> ppp b / scene / 3d / mesh_instance_3d . cpp <nl> Ref < Material > MeshInstance3D : : get_surface_material ( int p_surface ) const { <nl> <nl> Ref < Material > MeshInstance3D : : get_active_material ( int p_surface ) const { <nl> <nl> - if ( get_material_override ( ) ! = Ref < Material > ( ) ) { <nl> - return get_material_override ( ) ; <nl> - } else if ( p_surface < materials . size ( ) ) { <nl> - return materials [ p_surface ] ; <nl> - } else { <nl> - Ref < Mesh > mesh = get_mesh ( ) ; <nl> + Ref < Material > material_override = get_material_override ( ) ; <nl> + if ( material_override . is_valid ( ) ) { <nl> + return material_override ; <nl> + } <nl> <nl> - if ( mesh . is_null ( ) | | p_surface > = mesh - > get_surface_count ( ) ) { <nl> - return Ref < Material > ( ) ; <nl> - } <nl> + Ref < Material > surface_material = get_surface_material ( p_surface ) ; <nl> + if ( surface_material . is_valid ( ) ) { <nl> + return surface_material ; <nl> + } <nl> <nl> + Ref < Mesh > mesh = get_mesh ( ) ; <nl> + if ( mesh . is_valid ( ) ) { <nl> return mesh - > surface_get_material ( p_surface ) ; <nl> } <nl> + <nl> + return Ref < Material > ( ) ; <nl> } <nl> <nl> void MeshInstance3D : : _mesh_changed ( ) { <nl>
|
Fix get_active_material when a material is directly set on the mesh
|
godotengine/godot
|
72ee09082c693370ef7856eb7d7426c91c178cc1
|
2020-04-22T12:35:25Z
|
mmm a / cocos / ui / UIScrollView . cpp <nl> ppp b / cocos / ui / UIScrollView . cpp <nl> _childFocusCancelOffsetInInch ( MOVE_INCH ) , <nl> _touchMovePreviousTimestamp ( 0 ) , <nl> _autoScrolling ( false ) , <nl> _autoScrollAttenuate ( true ) , <nl> - _autoScrollDuration ( 0 ) , <nl> + _autoScrollTotalTime ( 0 ) , <nl> _autoScrollAccumulatedTime ( 0 ) , <nl> _autoScrollOutOfBoundaryAttenuating ( false ) , <nl> _inertiaScrollEnabled ( true ) , <nl> void ScrollView : : updateScrollBar ( const Vec2 & outOfBoundary ) <nl> <nl> Vec2 ScrollView : : calculateTouchMoveVelocity ( ) const <nl> { <nl> - float totalDuration = 0 ; <nl> + float totalTime = 0 ; <nl> for ( auto & timeDelta : _touchMoveTimeDeltas ) <nl> { <nl> - totalDuration + = timeDelta ; <nl> + totalTime + = timeDelta ; <nl> } <nl> - if ( totalDuration = = 0 | | totalDuration > = 0 . 1f ) <nl> + if ( totalTime = = 0 | | totalTime > = 0 . 1f ) <nl> { <nl> return Vec2 : : ZERO ; <nl> } <nl> Vec2 ScrollView : : calculateTouchMoveVelocity ( ) const <nl> { <nl> totalMovement + = displacement ; <nl> } <nl> - return totalMovement / totalDuration ; <nl> + return totalMovement / totalTime ; <nl> } <nl> <nl> void ScrollView : : startInertiaScroll ( const Vec2 & touchMoveVelocity ) <nl> bool ScrollView : : isOutOfBoundary ( ) const <nl> return isOutOfBoundaryTopOrBottom ( ) | | isOutOfBoundaryLeftOrRight ( ) ; <nl> } <nl> <nl> - void ScrollView : : startAutoScrollChildrenWithDestination ( const Vec2 & des , float second , bool attenuated ) <nl> + void ScrollView : : startAutoScrollToDestination ( const Vec2 & destination , float time , bool attenuated ) <nl> { <nl> - startAutoScroll ( des - _innerContainer - > getPosition ( ) , second , attenuated ) ; <nl> + startAutoScroll ( destination - _innerContainer - > getPosition ( ) , time , attenuated ) ; <nl> } <nl> <nl> - static float calculateAutoScrollDurationByInitialSpeed ( float initialSpeed ) <nl> + static float calculateAutoScrollTimeByInitialSpeed ( float initialSpeed ) <nl> { <nl> - / / Calculate the duration from the initial speed according to quintic polynomial . <nl> - float duration = sqrtf ( sqrtf ( initialSpeed / 5 ) ) ; <nl> - return duration ; <nl> + / / Calculate the time from the initial speed according to quintic polynomial . <nl> + float time = sqrtf ( sqrtf ( initialSpeed / 5 ) ) ; <nl> + return time ; <nl> } <nl> <nl> void ScrollView : : startAttenuatingAutoScroll ( const Vec2 & deltaMove , const Vec2 & initialVelocity ) <nl> { <nl> - float duration = calculateAutoScrollDurationByInitialSpeed ( initialVelocity . length ( ) ) ; <nl> - startAutoScroll ( deltaMove , duration , true ) ; <nl> + float time = calculateAutoScrollTimeByInitialSpeed ( initialVelocity . length ( ) ) ; <nl> + startAutoScroll ( deltaMove , time , true ) ; <nl> } <nl> <nl> - void ScrollView : : startAutoScroll ( const Vec2 & deltaMove , float duration , bool attenuated ) <nl> + void ScrollView : : startAutoScroll ( const Vec2 & deltaMove , float time , bool attenuated ) <nl> { <nl> Vec2 adjustedDeltaMove = deltaMove ; <nl> adjustedDeltaMove . x = ( _direction = = Direction : : VERTICAL ? 0 : adjustedDeltaMove . x ) ; <nl> void ScrollView : : startAutoScroll ( const Vec2 & deltaMove , float duration , bool att <nl> _autoScrollTargetDelta = adjustedDeltaMove ; <nl> _autoScrollAttenuate = attenuated ; <nl> _autoScrollStartPosition = _innerContainer - > getPosition ( ) ; <nl> - _autoScrollDuration = duration ; <nl> + _autoScrollTotalTime = time ; <nl> _autoScrollAccumulatedTime = 0 ; <nl> _autoScrollOutOfBoundaryAttenuating = false ; <nl> _autoScrollOutOfBoundaryPosAttenuating = Vec2 : : ZERO ; <nl> void ScrollView : : processAutoScrolling ( float deltaTime ) <nl> _autoScrollAccumulatedTime + = deltaTime * ( 1 / shortenFactor ) ; <nl> <nl> / / Calculate the progress percentage <nl> - float percentage = MIN ( 1 , _autoScrollAccumulatedTime / _autoScrollDuration ) ; <nl> + float percentage = MIN ( 1 , _autoScrollAccumulatedTime / _autoScrollTotalTime ) ; <nl> if ( _autoScrollAttenuate ) <nl> { <nl> / / Use quintic ( 5th degree ) polynomial <nl> bool ScrollView : : scrollChildren ( float touchOffsetX , float touchOffsetY ) <nl> return scrollEnabledUpDown | | scrollEnabledLeftRight ; <nl> } <nl> <nl> - void ScrollView : : scrollToBottom ( float second , bool attenuated ) <nl> + void ScrollView : : scrollToBottom ( float time , bool attenuated ) <nl> { <nl> - startAutoScrollChildrenWithDestination ( Vec2 ( _innerContainer - > getPosition ( ) . x , 0 . 0f ) , second , attenuated ) ; <nl> + startAutoScrollToDestination ( Vec2 ( _innerContainer - > getPosition ( ) . x , 0 . 0f ) , time , attenuated ) ; <nl> } <nl> <nl> - void ScrollView : : scrollToTop ( float second , bool attenuated ) <nl> + void ScrollView : : scrollToTop ( float time , bool attenuated ) <nl> { <nl> - startAutoScrollChildrenWithDestination ( Vec2 ( _innerContainer - > getPosition ( ) . x , <nl> - _contentSize . height - _innerContainer - > getContentSize ( ) . height ) , second , attenuated ) ; <nl> + startAutoScrollToDestination ( Vec2 ( _innerContainer - > getPosition ( ) . x , <nl> + _contentSize . height - _innerContainer - > getContentSize ( ) . height ) , time , attenuated ) ; <nl> } <nl> <nl> - void ScrollView : : scrollToLeft ( float second , bool attenuated ) <nl> + void ScrollView : : scrollToLeft ( float time , bool attenuated ) <nl> { <nl> - startAutoScrollChildrenWithDestination ( Vec2 ( 0 . 0f , _innerContainer - > getPosition ( ) . y ) , second , attenuated ) ; <nl> + startAutoScrollToDestination ( Vec2 ( 0 . 0f , _innerContainer - > getPosition ( ) . y ) , time , attenuated ) ; <nl> } <nl> <nl> - void ScrollView : : scrollToRight ( float second , bool attenuated ) <nl> + void ScrollView : : scrollToRight ( float time , bool attenuated ) <nl> { <nl> - startAutoScrollChildrenWithDestination ( Vec2 ( _contentSize . width - _innerContainer - > getContentSize ( ) . width , <nl> - _innerContainer - > getPosition ( ) . y ) , second , attenuated ) ; <nl> + startAutoScrollToDestination ( Vec2 ( _contentSize . width - _innerContainer - > getContentSize ( ) . width , <nl> + _innerContainer - > getPosition ( ) . y ) , time , attenuated ) ; <nl> } <nl> <nl> - void ScrollView : : scrollToTopLeft ( float second , bool attenuated ) <nl> + void ScrollView : : scrollToTopLeft ( float time , bool attenuated ) <nl> { <nl> if ( _direction ! = Direction : : BOTH ) <nl> { <nl> CCLOG ( " Scroll direction is not both ! " ) ; <nl> return ; <nl> } <nl> - startAutoScrollChildrenWithDestination ( Vec2 ( 0 . 0f , _contentSize . height - _innerContainer - > getContentSize ( ) . height ) , second , attenuated ) ; <nl> + startAutoScrollToDestination ( Vec2 ( 0 . 0f , _contentSize . height - _innerContainer - > getContentSize ( ) . height ) , time , attenuated ) ; <nl> } <nl> <nl> - void ScrollView : : scrollToTopRight ( float second , bool attenuated ) <nl> + void ScrollView : : scrollToTopRight ( float time , bool attenuated ) <nl> { <nl> if ( _direction ! = Direction : : BOTH ) <nl> { <nl> CCLOG ( " Scroll direction is not both ! " ) ; <nl> return ; <nl> } <nl> - startAutoScrollChildrenWithDestination ( Vec2 ( _contentSize . width - _innerContainer - > getContentSize ( ) . width , <nl> - _contentSize . height - _innerContainer - > getContentSize ( ) . height ) , second , attenuated ) ; <nl> + startAutoScrollToDestination ( Vec2 ( _contentSize . width - _innerContainer - > getContentSize ( ) . width , <nl> + _contentSize . height - _innerContainer - > getContentSize ( ) . height ) , time , attenuated ) ; <nl> } <nl> <nl> - void ScrollView : : scrollToBottomLeft ( float second , bool attenuated ) <nl> + void ScrollView : : scrollToBottomLeft ( float time , bool attenuated ) <nl> { <nl> if ( _direction ! = Direction : : BOTH ) <nl> { <nl> CCLOG ( " Scroll direction is not both ! " ) ; <nl> return ; <nl> } <nl> - startAutoScrollChildrenWithDestination ( Vec2 : : ZERO , second , attenuated ) ; <nl> + startAutoScrollToDestination ( Vec2 : : ZERO , time , attenuated ) ; <nl> } <nl> <nl> - void ScrollView : : scrollToBottomRight ( float second , bool attenuated ) <nl> + void ScrollView : : scrollToBottomRight ( float time , bool attenuated ) <nl> { <nl> if ( _direction ! = Direction : : BOTH ) <nl> { <nl> CCLOG ( " Scroll direction is not both ! " ) ; <nl> return ; <nl> } <nl> - startAutoScrollChildrenWithDestination ( Vec2 ( _contentSize . width - _innerContainer - > getContentSize ( ) . width , 0 . 0f ) , second , attenuated ) ; <nl> + startAutoScrollToDestination ( Vec2 ( _contentSize . width - _innerContainer - > getContentSize ( ) . width , 0 . 0f ) , time , attenuated ) ; <nl> } <nl> <nl> - void ScrollView : : scrollToPercentVertical ( float percent , float second , bool attenuated ) <nl> + void ScrollView : : scrollToPercentVertical ( float percent , float time , bool attenuated ) <nl> { <nl> float minY = _contentSize . height - _innerContainer - > getContentSize ( ) . height ; <nl> float h = - minY ; <nl> - startAutoScrollChildrenWithDestination ( Vec2 ( _innerContainer - > getPosition ( ) . x , minY + percent * h / 100 . 0f ) , second , attenuated ) ; <nl> + startAutoScrollToDestination ( Vec2 ( _innerContainer - > getPosition ( ) . x , minY + percent * h / 100 . 0f ) , time , attenuated ) ; <nl> } <nl> <nl> - void ScrollView : : scrollToPercentHorizontal ( float percent , float second , bool attenuated ) <nl> + void ScrollView : : scrollToPercentHorizontal ( float percent , float time , bool attenuated ) <nl> { <nl> float w = _innerContainer - > getContentSize ( ) . width - _contentSize . width ; <nl> - startAutoScrollChildrenWithDestination ( Vec2 ( - ( percent * w / 100 . 0f ) , _innerContainer - > getPosition ( ) . y ) , second , attenuated ) ; <nl> + startAutoScrollToDestination ( Vec2 ( - ( percent * w / 100 . 0f ) , _innerContainer - > getPosition ( ) . y ) , time , attenuated ) ; <nl> } <nl> <nl> - void ScrollView : : scrollToPercentBothDirection ( const Vec2 & percent , float second , bool attenuated ) <nl> + void ScrollView : : scrollToPercentBothDirection ( const Vec2 & percent , float time , bool attenuated ) <nl> { <nl> if ( _direction ! = Direction : : BOTH ) <nl> { <nl> void ScrollView : : scrollToPercentBothDirection ( const Vec2 & percent , float second , <nl> float minY = _contentSize . height - _innerContainer - > getContentSize ( ) . height ; <nl> float h = - minY ; <nl> float w = _innerContainer - > getContentSize ( ) . width - _contentSize . width ; <nl> - startAutoScrollChildrenWithDestination ( Vec2 ( - ( percent . x * w / 100 . 0f ) , minY + percent . y * h / 100 . 0f ) , second , attenuated ) ; <nl> + startAutoScrollToDestination ( Vec2 ( - ( percent . x * w / 100 . 0f ) , minY + percent . y * h / 100 . 0f ) , time , attenuated ) ; <nl> } <nl> <nl> void ScrollView : : jumpToBottom ( ) <nl> void ScrollView : : copySpecialProperties ( Widget * widget ) <nl> _autoScrollAttenuate = scrollView - > _autoScrollAttenuate ; <nl> _autoScrollStartPosition = scrollView - > _autoScrollStartPosition ; <nl> _autoScrollTargetDelta = scrollView - > _autoScrollTargetDelta ; <nl> - _autoScrollDuration = scrollView - > _autoScrollDuration ; <nl> + _autoScrollTotalTime = scrollView - > _autoScrollTotalTime ; <nl> _autoScrollAccumulatedTime = scrollView - > _autoScrollAccumulatedTime ; <nl> _autoScrollOutOfBoundaryAttenuating = scrollView - > _autoScrollOutOfBoundaryAttenuating ; <nl> _autoScrollOutOfBoundaryPosAttenuating = scrollView - > _autoScrollOutOfBoundaryPosAttenuating ; <nl> mmm a / cocos / ui / UIScrollView . h <nl> ppp b / cocos / ui / UIScrollView . h <nl> class CC_GUI_DLL ScrollView : public Layout <nl> <nl> / * * <nl> * Scroll inner container to bottom boundary of scrollview . <nl> - * @ param second Time in seconds . <nl> + * @ param time Time in seconds . <nl> * @ param attenuated Whether scroll speed attenuate or not . <nl> * / <nl> - void scrollToBottom ( float second , bool attenuated ) ; <nl> + void scrollToBottom ( float time , bool attenuated ) ; <nl> <nl> / * * <nl> * Scroll inner container to top boundary of scrollview . <nl> - * @ param second Time in seconds . <nl> + * @ param time Time in seconds . <nl> * @ param attenuated Whether scroll speed attenuate or not . <nl> * / <nl> - void scrollToTop ( float second , bool attenuated ) ; <nl> + void scrollToTop ( float time , bool attenuated ) ; <nl> <nl> / * * <nl> * Scroll inner container to left boundary of scrollview . <nl> - * @ param second Time in seconds . <nl> + * @ param time Time in seconds . <nl> * @ param attenuated Whether scroll speed attenuate or not . <nl> * / <nl> - void scrollToLeft ( float second , bool attenuated ) ; <nl> + void scrollToLeft ( float time , bool attenuated ) ; <nl> <nl> / * * <nl> * Scroll inner container to right boundary of scrollview . <nl> - * @ param second Time in seconds . <nl> + * @ param time Time in seconds . <nl> * @ param attenuated Whether scroll speed attenuate or not . <nl> * / <nl> void scrollToRight ( float time , bool attenuated ) ; <nl> <nl> / * * <nl> * Scroll inner container to top and left boundary of scrollview . <nl> - * @ param second Time in seconds . <nl> + * @ param time Time in seconds . <nl> * @ param attenuated Whether scroll speed attenuate or not . <nl> * / <nl> - void scrollToTopLeft ( float second , bool attenuated ) ; <nl> + void scrollToTopLeft ( float time , bool attenuated ) ; <nl> <nl> / * * <nl> * Scroll inner container to top and right boundary of scrollview . <nl> - * @ param second Time in seconds . <nl> + * @ param time Time in seconds . <nl> * @ param attenuated Whether scroll speed attenuate or not . <nl> * / <nl> void scrollToTopRight ( float time , bool attenuated ) ; <nl> <nl> / * * <nl> * Scroll inner container to bottom and left boundary of scrollview . <nl> - * @ param second Time in seconds . <nl> + * @ param time Time in seconds . <nl> * @ param attenuated Whether scroll speed attenuate or not . <nl> * / <nl> - void scrollToBottomLeft ( float second , bool attenuated ) ; <nl> + void scrollToBottomLeft ( float time , bool attenuated ) ; <nl> <nl> / * * <nl> * Scroll inner container to bottom and right boundary of scrollview . <nl> - * @ param second Time in seconds <nl> + * @ param time Time in seconds <nl> * @ param attenuated Whether scroll speed attenuate or not . <nl> * / <nl> void scrollToBottomRight ( float time , bool attenuated ) ; <nl> class CC_GUI_DLL ScrollView : public Layout <nl> / * * <nl> * Scroll inner container to vertical percent position of scrollview . <nl> * @ param percent A value between 0 and 100 . <nl> - * @ param second Time in seconds . <nl> + * @ param time Time in seconds . <nl> * @ param attenuated Whether scroll speed attenuate or not . <nl> * / <nl> - void scrollToPercentVertical ( float percent , float second , bool attenuated ) ; <nl> + void scrollToPercentVertical ( float percent , float time , bool attenuated ) ; <nl> <nl> / * * <nl> * Scroll inner container to horizontal percent position of scrollview . <nl> * @ param percent A value between 0 and 100 . <nl> - * @ param second Time in seconds . <nl> + * @ param time Time in seconds . <nl> * @ param attenuated Whether scroll speed attenuate or not . <nl> * / <nl> - void scrollToPercentHorizontal ( float percent , float second , bool attenuated ) ; <nl> + void scrollToPercentHorizontal ( float percent , float time , bool attenuated ) ; <nl> <nl> / * * <nl> * Scroll inner container to both direction percent position of scrollview . <nl> * @ param percent A value between 0 and 100 . <nl> - * @ param second Time in seconds . <nl> + * @ param time Time in seconds . <nl> * @ param attenuated Whether scroll speed attenuate or not . <nl> * / <nl> - void scrollToPercentBothDirection ( const Vec2 & percent , float second , bool attenuated ) ; <nl> + void scrollToPercentBothDirection ( const Vec2 & percent , float time , bool attenuated ) ; <nl> <nl> / * * <nl> * Move inner container to bottom boundary of scrollview . <nl> class CC_GUI_DLL ScrollView : public Layout <nl> Vec2 calculateTouchMoveVelocity ( ) const ; <nl> <nl> virtual void startAttenuatingAutoScroll ( const Vec2 & deltaMove , const Vec2 & initialVelocity ) ; <nl> - void startAutoScroll ( const Vec2 & deltaMove , float duration , bool attenuated ) ; <nl> - void startAutoScrollChildrenWithDestination ( const Vec2 & des , float second , bool attenuated ) ; <nl> + void startAutoScroll ( const Vec2 & deltaMove , float time , bool attenuated ) ; <nl> + void startAutoScrollToDestination ( const Vec2 & des , float time , bool attenuated ) ; <nl> void processAutoScrolling ( float deltaTime ) ; <nl> <nl> void startInertiaScroll ( const Vec2 & touchMoveVelocity ) ; <nl> class CC_GUI_DLL ScrollView : public Layout <nl> bool _autoScrollAttenuate ; <nl> Vec2 _autoScrollStartPosition ; <nl> Vec2 _autoScrollTargetDelta ; <nl> - float _autoScrollDuration ; <nl> + float _autoScrollTotalTime ; <nl> float _autoScrollAccumulatedTime ; <nl> bool _autoScrollOutOfBoundaryAttenuating ; <nl> Vec2 _autoScrollOutOfBoundaryPosAttenuating ; <nl>
|
ScrollView - Rename ' startAutoScrollChildrenWithDestination ( ) ' to ' startAutoScrollToDestination ' and ' duration ' to ' time ' .
|
cocos2d/cocos2d-x
|
7394b3f4670c158e377a417b4befb491e30a86bd
|
2015-09-09T01:28:46Z
|
mmm a / src / platform - win32 . cc <nl> ppp b / src / platform - win32 . cc <nl> bool VirtualMemory : : Uncommit ( void * address , size_t size ) { <nl> <nl> / / Definition of invalid thread handle and id . <nl> static const HANDLE kNoThread = INVALID_HANDLE_VALUE ; <nl> - static const DWORD kNoThreadId = 0 ; <nl> - <nl> - <nl> - class ThreadHandle : : PlatformData : public Malloced { <nl> - public : <nl> - explicit PlatformData ( ThreadHandle : : Kind kind ) { <nl> - Initialize ( kind ) ; <nl> - } <nl> - <nl> - void Initialize ( ThreadHandle : : Kind kind ) { <nl> - switch ( kind ) { <nl> - case ThreadHandle : : SELF : tid_ = GetCurrentThreadId ( ) ; break ; <nl> - case ThreadHandle : : INVALID : tid_ = kNoThreadId ; break ; <nl> - } <nl> - } <nl> - DWORD tid_ ; / / Win32 thread identifier . <nl> - } ; <nl> - <nl> <nl> / / Entry point for threads . The supplied argument is a pointer to the thread <nl> / / object . The entry function dispatches to the run method in the thread <nl> void Thread : : Start ( ) { <nl> ThreadEntry , <nl> this , <nl> 0 , <nl> - reinterpret_cast < unsigned int * > ( <nl> - & thread_handle_data ( ) - > tid_ ) ) ) ; <nl> + NULL ) ) ; <nl> ASSERT ( IsValid ( ) ) ; <nl> } <nl> <nl>
|
Fix build borkage due to r7575
|
v8/v8
|
097b09bff37ef981e198b601b3d8277d9f0a8a24
|
2011-04-12T00:42:27Z
|
mmm a / src / analysis / value_diff . cpp <nl> ppp b / src / analysis / value_diff . cpp <nl> class ValueDiff : public IRVisitor { <nl> : lane ( lane ) , input_stmt ( stmt ) , alloc ( alloc ) { <nl> } <nl> <nl> + void visit ( GlobalLoadStmt * stmt ) override { <nl> + results [ stmt - > instance_id ] = DiffRange ( false ) ; <nl> + } <nl> + <nl> void visit ( LocalLoadStmt * stmt ) override { <nl> if ( stmt - > ptr [ lane ] . var = = alloc ) { <nl> results [ stmt - > instance_id ] = DiffRange ( true , 0 ) ; <nl> class ValueDiff : public IRVisitor { <nl> } <nl> <nl> void visit ( RangeAssumptionStmt * stmt ) override { <nl> + stmt - > base - > accept ( this ) ; <nl> results [ stmt - > instance_id ] = results [ stmt - > base - > instance_id ] + <nl> DiffRange ( true , stmt - > low , stmt - > high ) ; <nl> } <nl> mmm a / src / scratch_pad . h <nl> ppp b / src / scratch_pad . h <nl> class ScratchPad { <nl> bounds [ 1 ] [ i ] = std : : max ( bounds [ 1 ] [ i ] , indices [ i ] + 1 ) ; <nl> pad_size [ i ] = bounds [ 1 ] [ i ] - bounds [ 0 ] [ i ] ; <nl> } <nl> - accesses . push_back ( std : : make_pair ( indices , flags ) ) ; <nl> + accesses . emplace_back ( indices , flags ) ; <nl> } <nl> <nl> void finalize ( ) { <nl> class ScratchPad { <nl> for ( int i = 0 ; i < dim ; i + + ) { <nl> block_size [ i ] = <nl> 1 < < snode - > extractors [ snode - > physical_index_position [ i ] ] . num_bits ; <nl> + TC_ASSERT ( bounds [ 0 ] [ i ] ! = std : : numeric_limits < int > : : max ( ) ) ; <nl> + TC_ASSERT ( bounds [ 1 ] [ i ] ! = std : : numeric_limits < int > : : min ( ) ) ; <nl> } <nl> <nl> - / / TC_ASSERT ( dim = = 1 ) ; <nl> - for ( int i = 0 ; i < pad_size [ 0 ] ; i + + ) { <nl> - } <nl> finalized = true ; <nl> flags = std : : vector < AccessFlag > ( linear_size ( ) , AccessFlag ( 0 ) ) ; <nl> <nl> mmm a / src / tests / mpm_full . cpp <nl> ppp b / src / tests / mpm_full . cpp <nl> auto mpm3d = [ ] ( ) { <nl> Declare ( p_ptr ) ; <nl> BlockDim ( 256 ) ; <nl> <nl> - / * <nl> Cache ( 0 , grid_v ( 0 ) ) ; <nl> Cache ( 0 , grid_v ( 1 ) ) ; <nl> Cache ( 0 , grid_v ( 2 ) ) ; <nl> Cache ( 0 , grid_m ) ; <nl> - * / <nl> For ( ( i , j , k , p_ptr ) , l , [ & ] { <nl> auto p = Eval ( l [ i , j , k , p_ptr ] ) ; <nl> / * <nl> auto mpm3d = [ ] ( ) { <nl> auto affine = Expr ( particle_mass ) * C + <nl> Expr ( - 4 * inv_dx * inv_dx * dt * vol ) * cauchy ; <nl> <nl> - auto base_coord_i = cast < int32 > ( base_coord ( 0 ) ) ; <nl> - auto base_coord_j = cast < int32 > ( base_coord ( 1 ) ) ; <nl> - auto base_coord_k = cast < int32 > ( base_coord ( 2 ) ) ; <nl> + int low = 0 , high = 1 ; / / grid_block_size ; <nl> + auto base_coord_i = AssumeInRange ( cast < int32 > ( base_coord ( 0 ) ) , i , low , high ) ; <nl> + auto base_coord_j = AssumeInRange ( cast < int32 > ( base_coord ( 1 ) ) , j , low , high ) ; <nl> + auto base_coord_k = AssumeInRange ( cast < int32 > ( base_coord ( 2 ) ) , k , low , high ) ; <nl> <nl> / / scatter <nl> for ( int a = 0 ; a < 3 ; a + + ) { <nl> mmm a / src / transforms / insert_scratch_pad . cpp <nl> ppp b / src / transforms / insert_scratch_pad . cpp <nl> class AccessAnalysis : public IRVisitor { <nl> allow_undefined_visitor = true ; <nl> invoke_default_visitor = false ; <nl> <nl> - generate_block_indices ( for_stmt - > snode - > parent , { } , 0 ) ; <nl> - <nl> - / * <nl> - TC_P ( block_indices . size ( ) ) ; <nl> - for ( int i = 0 ; i < block_indices . size ( ) ; i + + ) { <nl> - TC_P ( block_indices [ i ] ) ; <nl> - } <nl> - * / <nl> + generate_block_indices ( for_stmt - > scratch_opt [ 0 ] . second - > parent , { } , 0 ) ; <nl> <nl> const auto & block = for_stmt - > body ; <nl> <nl> class AccessAnalysis : public IRVisitor { <nl> for ( int l = 0 ; l < stmt - > width ( ) ; l + + ) { <nl> auto snode = ptr - > snodes [ l ] ; <nl> bool matching_indices = true ; <nl> - std : : vector < int > offsets ; / / TODO : change to offset_ranges <nl> + std : : vector < std : : pair < int , int > > offsets ; <nl> offsets . resize ( ptr - > indices . size ( ) ) ; <nl> int num_indices = ( int ) ptr - > indices . size ( ) ; <nl> for ( int i = 0 ; i < num_indices ; i + + ) { <nl> auto diff = <nl> analysis : : value_diff ( ptr - > indices [ i ] , l , for_stmt - > loop_vars [ i ] ) ; <nl> - if ( diff . related & & diff . certain ( ) ) { <nl> - offsets [ i ] = diff . low ; <nl> + if ( diff . related ) { <nl> + offsets [ i ] . first = diff . low ; <nl> + offsets [ i ] . second = diff . high ; <nl> } else { <nl> matching_indices = false ; <nl> } <nl> class AccessAnalysis : public IRVisitor { <nl> TC_P ( offsets [ i ] ) ; <nl> } <nl> for ( const auto & bind : block_indices ) { <nl> - auto access_ind = bind ; <nl> - for ( int d = 0 ; d < num_indices ; d + + ) { <nl> - access_ind [ d ] + = offsets [ d ] ; <nl> - } <nl> - / / TC_P ( access_ind ) ; <nl> - pads - > access ( snode , access_ind , flag ) ; <nl> + TC_P ( bind ) ; <nl> + std : : function < void ( std : : vector < int > , int ) > visit = <nl> + [ & ] ( std : : vector < int > ind , int depth ) { <nl> + if ( depth = = num_indices ) { <nl> + pads - > access ( snode , ind , flag ) ; <nl> + TC_P ( snode - > node_type_name ) ; <nl> + TC_P ( ind ) ; <nl> + return ; <nl> + } <nl> + for ( int i = offsets [ depth ] . first ; i < offsets [ depth ] . second ; <nl> + i + + ) { <nl> + ind [ depth ] = bind [ depth ] + i ; <nl> + visit ( ind , depth + 1 ) ; <nl> + } <nl> + } ; <nl> + visit ( bind , 0 ) ; <nl> } <nl> } <nl> } <nl> class InsertScratchPad : public IRVisitor { <nl> void visit ( StructForStmt * for_stmt ) override { <nl> / / do the work here . . . <nl> if ( ! for_stmt - > scratch_opt . empty ( ) ) { <nl> - for ( auto & opt : for_stmt - > scratch_opt ) { <nl> + for ( auto & opt : for_stmt - > scratch_opt ) { <nl> pads - > insert ( opt . second ) ; <nl> } <nl> AccessAnalysis _ ( for_stmt , pads . get ( ) ) ; <nl>
|
.
|
taichi-dev/taichi
|
5ae1eacc77cc16df490164100ad3daaf9bef3d9b
|
2019-04-10T19:56:15Z
|
mmm a / programs / obfuscator / Obfuscator . cpp <nl> ppp b / programs / obfuscator / Obfuscator . cpp <nl> <nl> # include < DataTypes / DataTypeArray . h > <nl> # include < DataTypes / DataTypeNullable . h > <nl> # include < DataTypes / DataTypeFactory . h > <nl> + # include < DataTypes / DataTypeUUID . h > <nl> # include < Interpreters / Context . h > <nl> # include < DataStreams / IBlockOutputStream . h > <nl> # include < DataStreams / LimitBlockInputStream . h > <nl>
|
added include
|
ClickHouse/ClickHouse
|
c32c83f6532c29108991570ce4687d4a84c8f51b
|
2020-09-02T11:20:20Z
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.