hexsha
stringlengths
40
40
size
int64
5
1.05M
ext
stringclasses
588 values
lang
stringclasses
305 values
max_stars_repo_path
stringlengths
3
363
max_stars_repo_name
stringlengths
5
118
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringdate
2015-01-01 00:00:35
2022-03-31 23:43:49
max_stars_repo_stars_event_max_datetime
stringdate
2015-01-01 12:37:38
2022-03-31 23:59:52
max_issues_repo_path
stringlengths
3
363
max_issues_repo_name
stringlengths
5
118
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
134k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
363
max_forks_repo_name
stringlengths
5
135
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringdate
2015-01-01 00:01:02
2022-03-31 23:27:27
max_forks_repo_forks_event_max_datetime
stringdate
2015-01-03 08:55:07
2022-03-31 23:59:24
content
stringlengths
5
1.05M
avg_line_length
float64
1.13
1.04M
max_line_length
int64
1
1.05M
alphanum_fraction
float64
0
1
82a3c2cc1c344e9bbc3835b461e0cede815d53e0
260
c
C
src/__tests__/simple-project/src/test_step_out.c
DLehenbauer/vscode-cc65-debugger
25431deda9be0c532655b24d4a1a530da98dff3e
[ "CC0-1.0" ]
18
2020-02-20T22:54:32.000Z
2021-07-03T04:34:56.000Z
src/__tests__/simple-project/src/test_step_out.c
DLehenbauer/vscode-cc65-debugger
25431deda9be0c532655b24d4a1a530da98dff3e
[ "CC0-1.0" ]
13
2021-11-16T23:00:13.000Z
2022-03-28T23:33:49.000Z
src/__tests__/simple-project/src/test_step_out.c
DLehenbauer/vscode-cc65-debugger
25431deda9be0c532655b24d4a1a530da98dff3e
[ "CC0-1.0" ]
2
2020-05-06T07:04:06.000Z
2020-09-19T13:02:13.000Z
#include <conio.h> void stepOut() { cputs("If you see this after step\n"); cputs("in, you failed\n"); } unsigned char test_step_out_main(void) { stepOut(); cputs("If you see this after step\n"); cputs("out, you failed\n"); return 0; }
20
42
0.619231
96567c99d4484dcebfac6cb45ad554dc158d23fa
3,625
h
C
src/SOS/extensions/extensions.h
ScriptBox99/dotnet-diagnostics
f7305f942efdb4ab9bc30025e9e0a646abd834a5
[ "MIT" ]
1
2022-02-10T10:10:43.000Z
2022-02-10T10:10:43.000Z
src/SOS/extensions/extensions.h
ScriptBox99/dotnet-diagnostics
f7305f942efdb4ab9bc30025e9e0a646abd834a5
[ "MIT" ]
1
2018-05-29T21:18:00.000Z
2018-05-29T21:18:00.000Z
src/SOS/extensions/extensions.h
ScriptBox99/dotnet-diagnostics
f7305f942efdb4ab9bc30025e9e0a646abd834a5
[ "MIT" ]
null
null
null
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #pragma once #include <corhdr.h> #include <string> #include "host.h" #include "hostservices.h" #include "debuggerservices.h" #include "symbolservice.h" interface IRuntime; enum HostRuntimeFlavor { None, NetCore, NetFx }; extern BOOL IsHostingInitialized(); extern HRESULT InitializeHosting(); extern LPCSTR GetHostRuntimeDirectory(); extern bool SetHostRuntimeDirectory(LPCSTR hostRuntimeDirectory); extern HostRuntimeFlavor GetHostRuntimeFlavor(); extern bool SetHostRuntimeFlavor(HostRuntimeFlavor flavor); extern bool GetAbsolutePath(const char* path, std::string& absolutePath); #ifdef __cplusplus extern "C" { #endif class Extensions { protected: static Extensions* s_extensions; IHost* m_pHost; ITarget* m_pTarget; IDebuggerServices* m_pDebuggerServices; IHostServices* m_pHostServices; ISymbolService* m_pSymbolService; public: Extensions(IDebuggerServices* pDebuggerServices); virtual ~Extensions(); /// <summary> /// Return the singleton extensions instance /// </summary> /// <returns></returns> static Extensions* GetInstance() { return s_extensions; } /// <summary> /// The extension host initialize callback function /// </summary> /// <param name="punk">IUnknown</param> /// <returns>error code</returns> HRESULT InitializeHostServices(IUnknown* punk); /// <summary> /// Returns the debugger services instance /// </summary> IDebuggerServices* GetDebuggerServices() { return m_pDebuggerServices; } /// <summary> /// Returns the host service provider or null /// </summary> virtual IHost* GetHost() = 0; /// <summary> /// Returns the extension service interface or null /// </summary> IHostServices* GetHostServices(); /// <summary> /// Returns the symbol service instance /// </summary> ISymbolService* GetSymbolService(); /// <summary> /// Create a new target with the extension services for /// </summary> /// <returns>error result</returns> HRESULT CreateTarget(); /// <summary> /// Creates and/or destroys the target based on the processId. /// </summary> /// <param name="processId">process id or 0 if none</param> /// <returns>error result</returns> HRESULT UpdateTarget(ULONG processId); /// <summary> /// Create a new target with the extension services for /// </summary> void DestroyTarget(); /// <summary> /// Returns the target instance /// </summary> ITarget* GetTarget(); /// <summary> /// Flush the target /// </summary> void FlushTarget(); /// <summary> /// Releases and clears the target /// </summary> void ReleaseTarget(); }; inline IHost* GetHost() { return Extensions::GetInstance()->GetHost(); } inline IDebuggerServices* GetDebuggerServices() { return Extensions::GetInstance()->GetDebuggerServices(); } inline ITarget* GetTarget() { return Extensions::GetInstance()->GetTarget(); } inline void ReleaseTarget() { Extensions::GetInstance()->ReleaseTarget(); } inline IHostServices* GetHostServices() { return Extensions::GetInstance()->GetHostServices(); } inline ISymbolService* GetSymbolService() { return Extensions::GetInstance()->GetSymbolService(); } extern HRESULT GetRuntime(IRuntime** ppRuntime); #ifdef __cplusplus } #endif
22.943038
73
0.676966
192f214d18b413b0d15d7b0b9f97de595d660c0b
821
h
C
MetalImage/MetalImage/Effects/MIKuwaharaFilter.h
feng1919/MetalImage
91bcbc4750bef4af3883755e3f397f4e280f5cc0
[ "MIT" ]
14
2017-12-06T02:12:52.000Z
2020-06-12T10:39:27.000Z
ThirdParts/MetalImage.framework/Headers/MIKuwaharaFilter.h
feng1919/MetalTensor
026e8ce85bbded6e41771d21316b380200183957
[ "MIT" ]
1
2019-10-03T08:28:14.000Z
2019-12-08T14:12:39.000Z
ThirdParts/MetalImage.framework/Headers/MIKuwaharaFilter.h
feng1919/MetalTensor
026e8ce85bbded6e41771d21316b380200183957
[ "MIT" ]
4
2017-11-22T02:15:42.000Z
2019-08-23T21:12:42.000Z
// // MIKuwaharaFilter.h // MetalImage // // Created by Feng Stone on 2017/10/12. // Copyright © 2017年 fengshi. All rights reserved. // #import "MetalImageFilter.h" NS_ASSUME_NONNULL_BEGIN /** Kuwahara image abstraction, drawn from the work of Kyprianidis, et. al. in their publication "Anisotropic Kuwahara Filtering on the GPU" within the GPU Pro collection. This produces an oil-painting-like image, but it is extremely computationally expensive, so it can take seconds to render a frame on an iPad 2. This might be best used for still images. */ @interface MIKuwaharaFilter : MetalImageFilter /// The radius to sample from when creating the brush-stroke effect, with a default of 3. The larger the radius, the slower the filter. @property(readwrite, nonatomic) NSUInteger radius; @end NS_ASSUME_NONNULL_END
37.318182
357
0.772229
c5df95d43c7eeb3ba6877a7008132f89be4ae0cb
5,011
h
C
src/chainmove.h
dualword/faunus
89f14398b960889cc74d0cceab96ef0e197088ae
[ "MIT" ]
55
2015-01-23T13:30:50.000Z
2022-01-27T10:04:29.000Z
src/chainmove.h
dualword/faunus
89f14398b960889cc74d0cceab96ef0e197088ae
[ "MIT" ]
128
2015-11-04T15:38:12.000Z
2022-03-24T20:25:58.000Z
src/chainmove.h
dualword/faunus
89f14398b960889cc74d0cceab96ef0e197088ae
[ "MIT" ]
33
2015-01-29T14:33:29.000Z
2022-03-24T10:32:07.000Z
#pragma once #include "move.h" #include "bonds.h" namespace Faunus { namespace Move { /** * @brief An abstract base class for rotational movements of a polymer chain */ class ChainRotationMoveBase : public MoveBase { protected: using MoveBase::spc; std::string molname; size_t molid; double dprot; //!< maximal angle of rotation, ±0.5*dprot double sqdispl; //!< center-of-mass displacement squared Average<double> msqdispl; //!< center-of-mass mean squared displacement bool permit_move = true; bool allow_small_box = false; int small_box_encountered = 0; //!< number of skipped moves due to too small container private: virtual size_t select_segment() = 0; //!< selects a chain segment and return the number of atoms in it virtual void rotate_segment(double angle) = 0; //!< rotates the selected chain segment virtual void store_change(Change &change) = 0; //!< stores changes made to atoms void _move(Change &change) override; void _accept(Change &change) override; void _reject(Change &change) override; protected: ChainRotationMoveBase(Space &spc, std::string name, std::string cite); void _from_json(const json &j) override; void _to_json(json &j) const override; public: double bias(Change &, double uold, double unew) override; }; /** * @brief An abstract class that rotates a selected segment of a polymer chain in the given simulation box. */ class ChainRotationMove : public ChainRotationMoveBase { using TBase = ChainRotationMoveBase; protected: using TBase::spc; typename Space::GroupVector::iterator molecule_iter; //! Indices of atoms in the spc.p vector that mark the origin and the direction of the axis of rotation. std::array<size_t, 2> axis_ndx; //! Indices of atoms in the spc.p vector that shall be rotated. std::vector<size_t> segment_ndx; ChainRotationMove(Space &spc, std::string name, std::string cite); void _from_json(const json &j) override; private: /** * @brief Rotates the chain segment around the axes by the given angle. * @param angle */ void rotate_segment(double angle) override; /** * Stores changes of atoms after the move attempt. * @param change */ void store_change(Change &change) override; /** In periodic systems (cuboid, slit, etc.) a chain rotational move can cause the molecule to be larger * than half the box length which we catch here. * @throws std::runtime_error */ bool box_big_enough(); }; /** * @brief Performs a crankshaft move of a random segment in a polymer chain. * * Two random atoms are select from a random polymer chain to be the joints of a crankshaft. * The chain segment between the joints is then rotated by a random angle around the axis * determined by the joints. The extend of the angle is limited by dprot. */ class CrankshaftMove : public ChainRotationMove { using TBase = ChainRotationMove; public: explicit CrankshaftMove(Space &spc); protected: CrankshaftMove(Space &spc, std::string name, std::string cite); void _from_json(const json &j) override; private: size_t joint_max; //!< maximum number of bonds between the joints of a crankshaft /** Randomly selects two atoms as joints in a random chain. The joints then determine the axis of rotation * of the chain segment between the joints. * The member vectors containing atoms' indices of the axis and the segment are populated accordingly. * Returns the segment size as atom count. * A non-branched chain is assumed having atom indices in a dense sequence. */ size_t select_segment() override; }; /** * @brief Performs a pivot move of a random tail part of a polymer chain. * * A random harmonic bond is selected from a random polymer chain. The bond determines the axes the rotation. * A part of the chain either before or after the bond (the selection has an equal probability ) * then constitutes a segment which is rotated by a random angle. The extend of the angle is limited by dprot. */ class PivotMove : public ChainRotationMove { using TBase = ChainRotationMove; private: BasePointerVector<Potential::HarmonicBond> bonds; public: explicit PivotMove(Space &spc); protected: PivotMove(Space &spc, std::string name, std::string cite); void _from_json(const json &j) override; /** Selects a random harmonic bond of a random polymer chain which atoms then create an axis of rotation. * Atoms between the randomly selected chain's end and the bond atom compose a segment to be rotated. * The member vectors containing atoms' indices of the axis and the segment are populated accordingly. * Returns the segment size as atom count. * A non-branched chain is assumed having atom indices in a dense sequence. */ size_t select_segment() override; }; } // namespace Move } // namespace Faunus
36.576642
116
0.708641
cf7ba41dd700b86f6cfffeaa088883b6e57e4fcc
11,770
h
C
SharedFrameworks/DVTKit/DVTLibraryController.h
cameroncooke/XcodeHeaders
be955d30b5fc62c4312b354045b4561d164ebd9c
[ "MIT" ]
1
2016-03-30T10:07:37.000Z
2016-03-30T10:07:37.000Z
SharedFrameworks/DVTKit/DVTLibraryController.h
cameroncooke/XcodeHeaders
be955d30b5fc62c4312b354045b4561d164ebd9c
[ "MIT" ]
null
null
null
SharedFrameworks/DVTKit/DVTLibraryController.h
cameroncooke/XcodeHeaders
be955d30b5fc62c4312b354045b4561d164ebd9c
[ "MIT" ]
null
null
null
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import <DVTKit/DVTViewController.h> #import "DVTLibraryGroupObserver.h" @class DVTBorderedView, DVTDelayedInvocation, DVTGroupedTileView, DVTLibrary, DVTLibraryDetailController, DVTLibraryDetailPopUpController, DVTNotificationToken, DVTObservingToken, DVTScrollView, DVTSearchField, NSArray, NSButton, NSDate, NSIndexSet, NSMutableSet, NSSearchField, NSSet, NSString, NSTreeController; @interface DVTLibraryController : DVTViewController <DVTLibraryGroupObserver> { DVTGroupedTileView *_assetTileView; DVTSearchField *_assetFilterField; DVTBorderedView *_filterBar; NSButton *_libraryViewToggleButton; DVTScrollView *_scrollView; DVTLibrary *_library; DVTLibraryDetailPopUpController *_detailPopUpController; long long _assetViewStyle; NSString *_filterString; NSArray *_filterComponents; id <DVTInvalidation> _rootGroupObservationToken; DVTObservingToken *_tileViewShowsFirstResponderKVOToken; DVTObservingToken *_tileViewIsFirstResponderKVOToken; DVTObservingToken *_tileViewSelectionIndexesKVOToken; NSIndexSet *_selectedLibraryGroupPairIndexes; id <DVTCancellable> _popUpTimerToken; NSMutableSet *_uniquedGroupSets; NSMutableSet *_uniquedAssetGroupSets; DVTNotificationToken *_detailPopUpControllerCloseToken; DVTNotificationToken *_assetScrollViewNotificationToken; DVTNotificationToken *_assetClipViewNotificationToken; struct CGSize _initialDraggingOffset; NSSet *_observedGroups; NSDate *_lastFilterDate; NSArray *_draggedGroups; NSArray *_draggedPairs; DVTDelayedInvocation *_iconValidationInvocation; struct { unsigned int synchronizingDetailViewContentViewWithAsset:1; unsigned int identifiesAssetsPerGroup:1; unsigned int filterCallbackIsPending:1; unsigned int acceptedDraggedAssets:1; unsigned int viewingLeafGroup:1; unsigned int inFilterMethod:1; } _flags; NSTreeController *_groupController; } + (struct CGSize)maximumThumbnailSize; + (id)defaultViewNibBundle; + (id)defaultViewNibName; @property(readonly) NSTreeController *groupController; // @synthesize groupController=_groupController; @property(readonly) DVTLibrary *library; // @synthesize library=_library; @property(readonly) NSString *filterString; // @synthesize filterString=_filterString; @property(retain) NSArray *draggedPairs; // @synthesize draggedPairs=_draggedPairs; @property(copy) NSArray *draggedGroups; // @synthesize draggedGroups=_draggedGroups; @property(nonatomic) long long assetViewStyle; // @synthesize assetViewStyle=_assetViewStyle; @property(readonly) NSSearchField *assetFilterField; // @synthesize assetFilterField=_assetFilterField; - (void).cxx_destruct; - (void)selectAssetFilterField; - (BOOL)control:(id)arg1 textView:(id)arg2 doCommandBySelector:(SEL)arg3; - (void)filterAssetsFromFilterField:(id)arg1; - (void)cancelFiltering; - (void)reallyFilter:(id)arg1; - (void)clearFilterString; - (void)beginFilteringWithString:(id)arg1; - (void)setFilterString:(id)arg1; - (id)filterComponents; - (id)tooltipForDetailControllerRepresentedObject:(id)arg1 forAsset:(id)arg2; - (id)titleForDetailControllerRepresentedObject:(id)arg1 forAsset:(id)arg2; - (id)representedObjectForDetailControllerIdentifier:(id)arg1 index:(unsigned long long)arg2 forAsset:(id)arg3; - (void)editSelectedAsset; - (struct CGSize)detailAreaSize; - (void)userDidPressEscapeInTileView:(id)arg1; - (void)userDidPressSpaceBarInTileView:(id)arg1; - (CDUnknownBlockType)tileView:(id)arg1 willProcessClick:(id)arg2; - (void)tileView:(id)arg1 didProcessKeyEvent:(id)arg2; - (double)popUpDelayForEvent:(id)arg1; - (void)stopTimerForShowingDetailPopUpController; - (void)startTimerForDelay:(double)arg1 showingDetailPopUpControllerForAssetAndGroupPair:(id)arg2; - (void)_openPopUpWithPair:(id)arg1; - (BOOL)_shouldImmediatelyOpenForEvent:(id)arg1; - (void)updatePositionOfDetailPopUp; - (BOOL)detailPopUpController:(id)arg1 canEditAsset:(id)arg2; - (id)detailPopUpController:(id)arg1 viewControllerForEditingAsset:(id)arg2; - (void)detailPopUpController:(id)arg1 dragAssetPairs:(id)arg2 withMouseDownEvent:(id)arg3 mouseDraggedEvent:(id)arg4 initialDraggedImageState:(id)arg5 allowedOperations:(unsigned long long)arg6 imageLocationOnScreen:(struct CGPoint)arg7; - (void)detailPopUpControllerHeaderWasDoubleClicked:(id)arg1; - (void)closeDetailPopUpController; - (void)openDetailPopUpController; - (void)cleanUpAfterClosingDetailPopUpController; - (void)faultIconForAsset:(id)arg1; - (void)refreshDetailView; - (BOOL)canOpenDetailPopUp; - (void)makeTileViewFirstResponder; - (BOOL)tileViewIsFirstResponder; @property(readonly) DVTLibraryDetailController *currentDetailController; - (id)detailPopUpContentController; - (id)draggedImageState:(id)arg1; - (void)draggingEnded:(id)arg1; - (void)concludeDragOperation:(id)arg1; - (BOOL)performDragOperation:(id)arg1; - (BOOL)prepareForDragOperation:(id)arg1; - (void)draggingExited:(id)arg1; - (unsigned long long)draggingUpdated:(id)arg1; - (unsigned long long)draggingEntered:(id)arg1; - (void)tileView:(id)arg1 didChangeContextClickedObjectFrom:(id)arg2; - (id)tileView:(id)arg1 typeCompletionStringForContentObject:(id)arg2; - (BOOL)groupedTileView:(id)arg1 shouldDragLayoutItem:(id)arg2 withMouseDownEvent:(id)arg3; - (id)groupedTileView:(id)arg1 layoutItemForRepresentedObject:(id)arg2; - (id)groupedTileView:(id)arg1 labelForGroup:(id)arg2; - (BOOL)groupedTileView:(id)arg1 shouldDrawAlternateHeaderColorForGroup:(id)arg2; - (void)groupedTileViewDeleteSelectedItems:(id)arg1; - (void)groupedTileViewUserPressedEnter:(id)arg1; - (void)groupedTileView:(id)arg1 wasDoubleClicked:(id)arg2; - (void)askDelegateToDepositeAssets:(id)arg1; - (BOOL)depositAssets:(id)arg1; - (BOOL)assetViewShouldAllowAssetDrops; - (void)resetIconContent; - (id)orderedAssetsForDisplayedAssets:(id)arg1; - (id)orderedAssetsForDisplayedAssets:(id)arg1 inGroup:(id)arg2; - (BOOL)assetPassesFilter:(id)arg1; - (void)applyAssetViewStyle; - (void)applyAssetViewStyleToAssetView:(id)arg1; - (BOOL)selectAsset:(id)arg1 inGroup:(id)arg2; @property(readonly) NSArray *selectedAssets; @property(readonly) NSArray *selectedAssetPairs; - (BOOL)shouldShowGridLines; - (void)makeItemForGroupVisible:(id)arg1 select:(BOOL)arg2 byExtendingSelection:(BOOL)arg3 edit:(BOOL)arg4; - (void)selectAssets:(id)arg1 inGroup:(id)arg2; - (id)assetTileViewContent; - (id)unsynchronizedAssetTileViewContent; - (id)imageForGroup:(id)arg1; - (id)assetViewSourceGroups; - (id)selectedGroups; - (void)selectLibrarySourceWithIdentifier:(id)arg1 subpath:(id)arg2 byExtendingSelection:(BOOL)arg3; - (id)currentTileViewUIState; - (void)applyTileViewUIState:(id)arg1; - (void)restoreUIState; - (void)saveUIState; - (id)libraryUIStateDefaultsKey; - (BOOL)validateUserInterfaceItem:(id)arg1; - (BOOL)canPerformRemoveSelectedAssetGroups; - (BOOL)canPerformRemoveSelectedAssetsFromGroup; - (BOOL)canPerformRemoveSelectedAssetsFromLibrary; - (void)performRemoveAssetsFromGroups:(id)arg1; - (void)performRemoveSelectedAssetGroups; - (BOOL)firstResponderHasSelectedAsset:(id)arg1; - (id)parentForNewGroup; - (id)groupedTileView:(id)arg1 draggedImageState:(id)arg2; - (void)groupedTileView:(id)arg1 concludeDragOperation:(id)arg2; - (BOOL)groupedTileView:(id)arg1 performDragOperation:(id)arg2; - (BOOL)groupedTileView:(id)arg1 prepareForDragOperation:(id)arg2; - (void)groupedTileView:(id)arg1 draggingExited:(id)arg2; - (unsigned long long)groupedTileView:(id)arg1 draggingEntered:(id)arg2; - (unsigned long long)groupedTileView:(id)arg1 draggingUpdated:(id)arg2; - (unsigned long long)calculateAssetViewDragOperation:(id)arg1 targetGroup:(id *)arg2 targetIndex:(long long *)arg3; - (unsigned long long)draggingOperationForDragInfo:(id)arg1 withTargetGroup:(id)arg2 targetCanBeMoveWithinGroup:(BOOL)arg3; - (BOOL)canCreateAssetsFromPasteboard:(id)arg1 targetingLibrarySourceIdentifier:(id *)arg2; - (void)addObjectsFromDraggingInfo:(id)arg1 toGroup:(id)arg2; - (void)insertObjectsFromDraggingInfo:(id)arg1 intoGroup:(id)arg2 atIndex:(long long)arg3; - (BOOL)createAsset:(id *)arg1 forLibrarySourceWithIdentifier:(id *)arg2 fromPasteboard:(id)arg3; - (id)addAssetsFromDraggingInfo:(id)arg1 toGroup:(id)arg2 copy:(BOOL)arg3; - (id)insertAssetsFromDraggingInfo:(id)arg1 intoGroup:(id)arg2 atIndex:(long long)arg3 copy:(BOOL)arg4; - (void)groupedTileViewDragSelectedItems:(id)arg1 withMouseDownEvent:(id)arg2 andMouseDraggedEvent:(id)arg3; - (id)draggedImageStateForAssetGroupPairs:(id)arg1 draggedPair:(id)arg2 referenceRectForClickedItem:(struct CGRect *)arg3; - (void)groupedTileViewCopySelectedItems:(id)arg1; - (void)dragDidUpdate:(id)arg1 operation:(unsigned long long)arg2 previousOperation:(unsigned long long)arg3; - (void)draggedImage:(id)arg1 endedAt:(struct CGPoint)arg2 operation:(unsigned long long)arg3 withException:(id)arg4 shouldSlideBack:(char *)arg5; - (void)didFinishDraggingAssets:(id)arg1 info:(id)arg2 shouldSlideBack:(char *)arg3; - (void)dragAssetPairs:(id)arg1 withMouseDownEvent:(id)arg2 mouseDraggedEvent:(id)arg3 initialDraggedImageState:(id)arg4 allowedOperations:(unsigned long long)arg5 imageLocationInWindow:(struct CGPoint)arg6; - (void)willBeginDraggingAssets:(id)arg1; - (void)populatePasteboard:(id)arg1 withAssetAndCategoryPairs:(id)arg2 defaultDraggedImageState:(id *)arg3 identifierMapTable:(id *)arg4; - (void)populatePasteboard:(id)arg1 withAssets:(id)arg2 defaultDraggedImageState:(id *)arg3 identifierMapTable:(id *)arg4; - (void)populatePasteboard:(id)arg1 withAssets:(id)arg2; - (id)defaultDragImageState:(id)arg1; - (id)initialDragImageState:(id)arg1; - (BOOL)transfersFirstResponderToDragDestination:(id)arg1; - (void)registerForDropTypes; - (id)draggedAssets; - (id)readableAssetPasteboardTypes; - (id)assetGroupPasteboardType; - (id)assetPasteboardType; - (void)userDidEditAsset:(id)arg1; - (void)applyAssetSelectionIndexes; - (void)toggleAssetViewStyle:(id)arg1; - (void)invalidateIconContent; - (void)batchedValidateIconContent:(id)arg1; - (void)setObservedGroups:(id)arg1; - (void)dropUnusedAssetAndGroupSets:(id)arg1; - (id)allAssetAndGroupSets; - (id)uniquedAssetAndGroupSetForAsset:(id)arg1 andGroups:(id)arg2; - (BOOL)removeAssets:(id)arg1 error:(id *)arg2; - (BOOL)canPerformRemoveAssetFromLibrary:(id)arg1; - (BOOL)canRemoveAsset:(id)arg1; - (id)editorViewControllerForAsset:(id)arg1; - (BOOL)canEditAsset:(id)arg1; - (id)searchStringsForAsset:(id)arg1; - (BOOL)isGroupDisplayedInAssetView:(id)arg1; - (void)libraryDidLoad; - (id)representedObjectWithString:(id)arg1 forAsset:(id)arg2; - (id)imageForLibraryAsset:(id)arg1; - (void)viewWillUninstall; - (void)viewDidInstall; - (void)setupScrollMonitoringAfterInstall; - (void)setupLibraryObservingAfterInstalling; - (void)libraryGroupDidChangeAssets:(id)arg1; - (void)libraryDidChangeAssets:(id)arg1; - (void)setupFilterBarAfterInstalling; - (void)setupAssetTileViewAfterInstalling; @property(readonly) BOOL searchFieldIsFirstResponder; @property(readonly, getter=isViewingLeafGroup) BOOL viewingLeafGroup; - (id)libraryWindow; @property BOOL identifiesAssetsPerGroup; - (id)assetScrollView; - (id)assetTileViewForceSynchronizedContent:(BOOL)arg1; - (void)loadView; - (void)setRepresentedExtension:(id)arg1; - (void)addObserver:(id)arg1 forKeyPath:(id)arg2 options:(unsigned long long)arg3 context:(void *)arg4; - (void)primitiveInvalidate; - (id)initWithNibName:(id)arg1 bundle:(id)arg2; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end
50.299145
313
0.802889
fda4a4dbbe3eb3df1f2a01ced8fa3536171f602e
20,841
c
C
xun/xnu-6153.81.5/pexpert/arm/pe_init.c
L-Zheng/AppleOpenSource
65fac74ce17dc97404f1aeb8c24625fe82b7d142
[ "MIT" ]
null
null
null
xun/xnu-6153.81.5/pexpert/arm/pe_init.c
L-Zheng/AppleOpenSource
65fac74ce17dc97404f1aeb8c24625fe82b7d142
[ "MIT" ]
null
null
null
xun/xnu-6153.81.5/pexpert/arm/pe_init.c
L-Zheng/AppleOpenSource
65fac74ce17dc97404f1aeb8c24625fe82b7d142
[ "MIT" ]
null
null
null
/* * Copyright (c) 2000-2017 Apple Inc. All rights reserved. * * arm platform expert initialization. */ #include <sys/types.h> #include <sys/kdebug.h> #include <mach/vm_param.h> #include <pexpert/protos.h> #include <pexpert/pexpert.h> #include <pexpert/boot.h> #include <pexpert/device_tree.h> #include <pexpert/pe_images.h> #include <kern/sched_prim.h> #include <machine/machine_routines.h> #include <arm/caches_internal.h> #include <kern/debug.h> #include <libkern/section_keywords.h> #if defined __arm__ #include <pexpert/arm/board_config.h> #elif defined __arm64__ #include <pexpert/arm64/board_config.h> #endif /* extern references */ extern void pe_identify_machine(boot_args *bootArgs); /* static references */ static void pe_prepare_images(void); /* private globals */ SECURITY_READ_ONLY_LATE(PE_state_t) PE_state; #define FW_VERS_LEN 128 char firmware_version[FW_VERS_LEN]; /* * This variable is only modified once, when the BSP starts executing. We put it in __TEXT * as page protections on kernel text early in startup are read-write. The kernel is * locked down later in start-up, said mappings become RO and thus this * variable becomes immutable. * * See osfmk/arm/arm_vm_init.c for more information. */ SECURITY_READ_ONLY_SPECIAL_SECTION(volatile uint32_t, "__TEXT,__const") debug_enabled = FALSE; uint8_t gPlatformECID[8]; uint32_t gPlatformMemoryID; static boolean_t vc_progress_initialized = FALSE; uint64_t last_hwaccess_thread = 0; char gTargetTypeBuffer[8]; char gModelTypeBuffer[32]; /* Clock Frequency Info */ clock_frequency_info_t gPEClockFrequencyInfo; vm_offset_t gPanicBase; unsigned int gPanicSize; struct embedded_panic_header *panic_info = NULL; #if (DEVELOPMENT || DEBUG) && defined(XNU_TARGET_OS_BRIDGE) /* * On DEVELOPMENT bridgeOS, we map the x86 panic region * so we can include this data in bridgeOS corefiles */ uint64_t macos_panic_base = 0; unsigned int macos_panic_size = 0; struct macos_panic_header *mac_panic_header = NULL; #endif /* Maximum size of panic log excluding headers, in bytes */ static unsigned int panic_text_len; /* Whether a console is standing by for panic logging */ static boolean_t panic_console_available = FALSE; extern uint32_t crc32(uint32_t crc, const void *buf, size_t size); void PE_slide_devicetree(vm_offset_t); static void check_for_panic_log(void) { #ifdef PLATFORM_PANIC_LOG_PADDR gPanicBase = ml_io_map_wcomb(PLATFORM_PANIC_LOG_PADDR, PLATFORM_PANIC_LOG_SIZE); panic_text_len = PLATFORM_PANIC_LOG_SIZE - sizeof(struct embedded_panic_header); gPanicSize = PLATFORM_PANIC_LOG_SIZE; #else DTEntry entry, chosen; unsigned int size; uintptr_t *reg_prop; uint32_t *panic_region_length; /* * DT properties for the panic region are populated by UpdateDeviceTree() in iBoot: * * chosen { * embedded-panic-log-size = <0x00080000>; * [a bunch of other stuff] * }; * * pram { * reg = <0x00000008_fbc48000 0x00000000_000b4000>; * }; * * reg[0] is the physical address * reg[1] is the size of iBoot's kMemoryRegion_Panic (not used) * embedded-panic-log-size is the maximum amount of data to store in the buffer */ if (kSuccess != DTLookupEntry(0, "pram", &entry)) { return; } if (kSuccess != DTGetProperty(entry, "reg", (void **)&reg_prop, &size)) { return; } if (kSuccess != DTLookupEntry(0, "/chosen", &chosen)) { return; } if (kSuccess != DTGetProperty(chosen, "embedded-panic-log-size", (void **) &panic_region_length, &size)) { return; } gPanicBase = ml_io_map_wcomb(reg_prop[0], panic_region_length[0]); /* Deduct the size of the panic header from the panic region size */ panic_text_len = panic_region_length[0] - sizeof(struct embedded_panic_header); gPanicSize = panic_region_length[0]; #if DEVELOPMENT && defined(XNU_TARGET_OS_BRIDGE) if (PE_consistent_debug_enabled()) { uint64_t macos_panic_physbase = 0; uint64_t macos_panic_physlen = 0; /* Populate the macOS panic region data if it's present in consistent debug */ if (PE_consistent_debug_lookup_entry(kDbgIdMacOSPanicRegion, &macos_panic_physbase, &macos_panic_physlen)) { macos_panic_base = ml_io_map_with_prot(macos_panic_physbase, macos_panic_physlen, VM_PROT_READ); mac_panic_header = (struct macos_panic_header *) ((void *) macos_panic_base); macos_panic_size = macos_panic_physlen; } } #endif /* DEVELOPMENT && defined(XNU_TARGET_OS_BRIDGE) */ #endif panic_info = (struct embedded_panic_header *)gPanicBase; /* Check if a shared memory console is running in the panic buffer */ if (panic_info->eph_magic == 'SHMC') { panic_console_available = TRUE; return; } /* Check if there's a boot profile in the panic buffer */ if (panic_info->eph_magic == 'BTRC') { return; } /* * Check to see if a panic (FUNK) is in VRAM from the last time */ if (panic_info->eph_magic == EMBEDDED_PANIC_MAGIC) { printf("iBoot didn't extract panic log from previous session crash, this is bad\n"); } /* Clear panic region */ bzero((void *)gPanicBase, gPanicSize); } int PE_initialize_console(PE_Video * info, int op) { static int last_console = -1; if (info && (info != &PE_state.video)) { info->v_scale = PE_state.video.v_scale; } switch (op) { case kPEDisableScreen: initialize_screen(info, op); last_console = switch_to_serial_console(); kprintf("kPEDisableScreen %d\n", last_console); break; case kPEEnableScreen: initialize_screen(info, op); if (info) { PE_state.video = *info; } kprintf("kPEEnableScreen %d\n", last_console); if (last_console != -1) { switch_to_old_console(last_console); } break; case kPEReleaseScreen: /* * we don't show the progress indicator on boot, but want to * show it afterwards. */ if (!vc_progress_initialized) { default_progress.dx = 0; default_progress.dy = 0; vc_progress_initialize(&default_progress, default_progress_data1x, default_progress_data2x, default_progress_data3x, (unsigned char *) appleClut8); vc_progress_initialized = TRUE; } initialize_screen(info, op); break; default: initialize_screen(info, op); break; } return 0; } void PE_init_iokit(void) { DTEntry entry; unsigned int size, scale; unsigned long display_size; void **map; unsigned int show_progress; int *delta, image_size, flip; uint32_t start_time_value = 0; uint32_t debug_wait_start_value = 0; uint32_t load_kernel_start_value = 0; uint32_t populate_registry_time_value = 0; PE_init_kprintf(TRUE); PE_init_printf(TRUE); printf("iBoot version: %s\n", firmware_version); if (kSuccess == DTLookupEntry(0, "/chosen/memory-map", &entry)) { boot_progress_element *bootPict; if (kSuccess == DTGetProperty(entry, "BootCLUT", (void **) &map, &size)) { bcopy(map[0], appleClut8, sizeof(appleClut8)); } if (kSuccess == DTGetProperty(entry, "Pict-FailedBoot", (void **) &map, &size)) { bootPict = (boot_progress_element *) map[0]; default_noroot.width = bootPict->width; default_noroot.height = bootPict->height; default_noroot.dx = 0; default_noroot.dy = bootPict->yOffset; default_noroot_data = &bootPict->data[0]; } } pe_prepare_images(); scale = PE_state.video.v_scale; flip = 1; if (PE_parse_boot_argn("-progress", &show_progress, sizeof(show_progress)) && show_progress) { /* Rotation: 0:normal, 1:right 90, 2:left 180, 3:left 90 */ switch (PE_state.video.v_rotate) { case 2: flip = -1; /* fall through */ case 0: display_size = PE_state.video.v_height; image_size = default_progress.height; delta = &default_progress.dy; break; case 1: flip = -1; /* fall through */ case 3: default: display_size = PE_state.video.v_width; image_size = default_progress.width; delta = &default_progress.dx; } assert(*delta >= 0); while (((unsigned)(*delta + image_size)) >= (display_size / 2)) { *delta -= 50 * scale; assert(*delta >= 0); } *delta *= flip; /* Check for DT-defined progress y delta */ PE_get_default("progress-dy", &default_progress.dy, sizeof(default_progress.dy)); vc_progress_initialize(&default_progress, default_progress_data1x, default_progress_data2x, default_progress_data3x, (unsigned char *) appleClut8); vc_progress_initialized = TRUE; } if (kdebug_enable && kdebug_debugid_enabled(IOKDBG_CODE(DBG_BOOTER, 0))) { /* Trace iBoot-provided timing information. */ if (kSuccess == DTLookupEntry(0, "/chosen/iBoot", &entry)) { uint32_t * value_ptr; if (kSuccess == DTGetProperty(entry, "start-time", (void **)&value_ptr, &size)) { if (size == sizeof(start_time_value)) { start_time_value = *value_ptr; } } if (kSuccess == DTGetProperty(entry, "debug-wait-start", (void **)&value_ptr, &size)) { if (size == sizeof(debug_wait_start_value)) { debug_wait_start_value = *value_ptr; } } if (kSuccess == DTGetProperty(entry, "load-kernel-start", (void **)&value_ptr, &size)) { if (size == sizeof(load_kernel_start_value)) { load_kernel_start_value = *value_ptr; } } if (kSuccess == DTGetProperty(entry, "populate-registry-time", (void **)&value_ptr, &size)) { if (size == sizeof(populate_registry_time_value)) { populate_registry_time_value = *value_ptr; } } } KDBG_RELEASE(IOKDBG_CODE(DBG_BOOTER, 0), start_time_value, debug_wait_start_value, load_kernel_start_value, populate_registry_time_value); } StartIOKit(PE_state.deviceTreeHead, PE_state.bootArgs, (void *) 0, (void *) 0); } void PE_slide_devicetree(vm_offset_t slide) { assert(PE_state.initialized); PE_state.deviceTreeHead += slide; DTInit(PE_state.deviceTreeHead); } void PE_init_platform(boolean_t vm_initialized, void *args) { DTEntry entry; unsigned int size; void **prop; boot_args *boot_args_ptr = (boot_args *) args; if (PE_state.initialized == FALSE) { PE_state.initialized = TRUE; PE_state.bootArgs = boot_args_ptr; PE_state.deviceTreeHead = boot_args_ptr->deviceTreeP; PE_state.video.v_baseAddr = boot_args_ptr->Video.v_baseAddr; PE_state.video.v_rowBytes = boot_args_ptr->Video.v_rowBytes; PE_state.video.v_width = boot_args_ptr->Video.v_width; PE_state.video.v_height = boot_args_ptr->Video.v_height; PE_state.video.v_depth = (boot_args_ptr->Video.v_depth >> kBootVideoDepthDepthShift) & kBootVideoDepthMask; PE_state.video.v_rotate = (boot_args_ptr->Video.v_depth >> kBootVideoDepthRotateShift) & kBootVideoDepthMask; PE_state.video.v_scale = ((boot_args_ptr->Video.v_depth >> kBootVideoDepthScaleShift) & kBootVideoDepthMask) + 1; PE_state.video.v_display = boot_args_ptr->Video.v_display; strlcpy(PE_state.video.v_pixelFormat, "BBBBBBBBGGGGGGGGRRRRRRRR", sizeof(PE_state.video.v_pixelFormat)); } if (!vm_initialized) { /* * Setup the Device Tree routines * so the console can be found and the right I/O space * can be used.. */ DTInit(PE_state.deviceTreeHead); pe_identify_machine(boot_args_ptr); } else { pe_arm_init_interrupts(args); pe_arm_init_debug(args); } if (!vm_initialized) { if (kSuccess == (DTFindEntry("name", "device-tree", &entry))) { if (kSuccess == DTGetProperty(entry, "target-type", (void **)&prop, &size)) { if (size > sizeof(gTargetTypeBuffer)) { size = sizeof(gTargetTypeBuffer); } bcopy(prop, gTargetTypeBuffer, size); gTargetTypeBuffer[size - 1] = '\0'; } } if (kSuccess == (DTFindEntry("name", "device-tree", &entry))) { if (kSuccess == DTGetProperty(entry, "model", (void **)&prop, &size)) { if (size > sizeof(gModelTypeBuffer)) { size = sizeof(gModelTypeBuffer); } bcopy(prop, gModelTypeBuffer, size); gModelTypeBuffer[size - 1] = '\0'; } } if (kSuccess == DTLookupEntry(NULL, "/chosen", &entry)) { if (kSuccess == DTGetProperty(entry, "debug-enabled", (void **) &prop, &size)) { /* * We purposefully modify a constified variable as * it will get locked down by a trusted monitor or * via page table mappings. We don't want people easily * modifying this variable... */ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wcast-qual" boolean_t *modify_debug_enabled = (boolean_t *) &debug_enabled; if (size > sizeof(uint32_t)) { size = sizeof(uint32_t); } bcopy(prop, modify_debug_enabled, size); #pragma clang diagnostic pop } if (kSuccess == DTGetProperty(entry, "firmware-version", (void **) &prop, &size)) { if (size > sizeof(firmware_version)) { size = sizeof(firmware_version); } bcopy(prop, firmware_version, size); firmware_version[size - 1] = '\0'; } if (kSuccess == DTGetProperty(entry, "unique-chip-id", (void **) &prop, &size)) { if (size > sizeof(gPlatformECID)) { size = sizeof(gPlatformECID); } bcopy(prop, gPlatformECID, size); } if (kSuccess == DTGetProperty(entry, "dram-vendor-id", (void **) &prop, &size)) { if (size > sizeof(gPlatformMemoryID)) { size = sizeof(gPlatformMemoryID); } bcopy(prop, &gPlatformMemoryID, size); } } pe_init_debug(); } } void PE_create_console(void) { /* * Check the head of VRAM for a panic log saved on last panic. * Do this before the VRAM is trashed. */ check_for_panic_log(); if (PE_state.video.v_display) { PE_initialize_console(&PE_state.video, kPEGraphicsMode); } else { PE_initialize_console(&PE_state.video, kPETextMode); } } int PE_current_console(PE_Video * info) { *info = PE_state.video; return 0; } void PE_display_icon(__unused unsigned int flags, __unused const char *name) { if (default_noroot_data) { vc_display_icon(&default_noroot, default_noroot_data); } } extern boolean_t PE_get_hotkey(__unused unsigned char key) { return FALSE; } static timebase_callback_func gTimebaseCallback; void PE_register_timebase_callback(timebase_callback_func callback) { gTimebaseCallback = callback; PE_call_timebase_callback(); } void PE_call_timebase_callback(void) { struct timebase_freq_t timebase_freq; timebase_freq.timebase_num = gPEClockFrequencyInfo.timebase_frequency_hz; timebase_freq.timebase_den = 1; if (gTimebaseCallback) { gTimebaseCallback(&timebase_freq); } } /* * The default PE_poll_input handler. */ int PE_stub_poll_input(__unused unsigned int options, char *c) { *c = uart_getc(); return 0; /* 0 for success, 1 for unsupported */ } /* * This routine will return 1 if you are running on a device with a variant * of iBoot that allows debugging. This is typically not the case on production * fused parts (even when running development variants of iBoot). * * The routine takes an optional argument of the flags passed to debug="" so * kexts don't have to parse the boot arg themselves. */ uint32_t PE_i_can_has_debugger(uint32_t *debug_flags) { if (debug_flags) { #if DEVELOPMENT || DEBUG assert(debug_boot_arg_inited); #endif if (debug_enabled) { *debug_flags = debug_boot_arg; } else { *debug_flags = 0; } } return debug_enabled; } /* * This routine returns TRUE if the device is configured * with panic debugging enabled. */ boolean_t PE_panic_debugging_enabled() { return panicDebugging; } void PE_save_buffer_to_vram(unsigned char *buf, unsigned int *size) { if (!panic_info || !size) { return; } if (!buf) { *size = panic_text_len; return; } if (*size == 0) { return; } *size = *size > panic_text_len ? panic_text_len : *size; if (panic_info->eph_magic != EMBEDDED_PANIC_MAGIC) { printf("Error!! Current Magic 0x%X, expected value 0x%x", panic_info->eph_magic, EMBEDDED_PANIC_MAGIC); } /* CRC everything after the CRC itself - starting with the panic header version */ panic_info->eph_crc = crc32(0L, &panic_info->eph_version, (panic_text_len + sizeof(struct embedded_panic_header) - offsetof(struct embedded_panic_header, eph_version))); } uint32_t PE_get_offset_into_panic_region(char *location) { assert(panic_info != NULL); assert(location > (char *) panic_info); assert((unsigned int)(location - (char *) panic_info) < panic_text_len); return (uint32_t) (location - gPanicBase); } void PE_init_panicheader() { if (!panic_info) { return; } bzero(panic_info, sizeof(struct embedded_panic_header)); /* * The panic log begins immediately after the panic header -- debugger synchronization and other functions * may log into this region before we've become the exclusive panicking CPU and initialize the header here. */ panic_info->eph_panic_log_offset = PE_get_offset_into_panic_region(debug_buf_base); panic_info->eph_magic = EMBEDDED_PANIC_MAGIC; panic_info->eph_version = EMBEDDED_PANIC_HEADER_CURRENT_VERSION; return; } /* * Tries to update the panic header to keep it consistent on nested panics. * * NOTE: The purpose of this function is NOT to detect/correct corruption in the panic region, * it is to update the panic header to make it consistent when we nest panics. */ void PE_update_panicheader_nestedpanic() { if (!panic_info) { return; } /* * If the panic log offset is not set, re-init the panic header */ if (panic_info->eph_panic_log_offset == 0) { PE_init_panicheader(); panic_info->eph_panic_flags |= EMBEDDED_PANIC_HEADER_FLAG_NESTED_PANIC; return; } panic_info->eph_panic_flags |= EMBEDDED_PANIC_HEADER_FLAG_NESTED_PANIC; /* * If the panic log length is not set, set the end to * the current location of the debug_buf_ptr to close it. */ if (panic_info->eph_panic_log_len == 0) { panic_info->eph_panic_log_len = PE_get_offset_into_panic_region(debug_buf_ptr); /* If this assert fires, it's indicative of corruption in the panic region */ assert(panic_info->eph_other_log_offset == panic_info->eph_other_log_len == 0); } /* If this assert fires, it's likely indicative of corruption in the panic region */ assert(((panic_info->eph_stackshot_offset == 0) && (panic_info->eph_stackshot_len == 0)) || ((panic_info->eph_stackshot_offset != 0) && (panic_info->eph_stackshot_len != 0))); /* * If we haven't set up the other log yet, set the beginning of the other log * to the current location of the debug_buf_ptr */ if (panic_info->eph_other_log_offset == 0) { panic_info->eph_other_log_offset = PE_get_offset_into_panic_region(debug_buf_ptr); /* If this assert fires, it's indicative of corruption in the panic region */ assert(panic_info->eph_other_log_len == 0); } return; } boolean_t PE_reboot_on_panic(void) { uint32_t debug_flags; if (PE_i_can_has_debugger(&debug_flags) && (debug_flags & DB_NMI)) { /* kernel debugging is active */ return FALSE; } else { return TRUE; } } void PE_sync_panic_buffers(void) { /* * rdar://problem/26453070: * The iBoot panic region is write-combined on arm64. We must flush dirty lines * from L1/L2 as late as possible before reset, with no further reads of the panic * region between the flush and the reset. Some targets have an additional memcache (L3), * and a read may bring dirty lines out of L3 and back into L1/L2, causing the lines to * be discarded on reset. If we can make sure the lines are flushed to L3/DRAM, * the platform reset handler will flush any L3. */ if (gPanicBase) { CleanPoC_DcacheRegion_Force(gPanicBase, gPanicSize); } } static void pe_prepare_images(void) { if ((1 & PE_state.video.v_rotate) != 0) { // Only square square images with radial symmetry are supported // No need to actually rotate the data // Swap the dx and dy offsets uint32_t tmp = default_progress.dx; default_progress.dx = default_progress.dy; default_progress.dy = tmp; } #if 0 uint32_t cnt, cnt2, cnt3, cnt4; uint32_t tmp, width, height; uint8_t data, *new_data; const uint8_t *old_data; width = default_progress.width; height = default_progress.height * default_progress.count; // Scale images if the UI is being scaled if (PE_state.video.v_scale > 1) { new_data = kalloc(width * height * scale * scale); if (new_data != 0) { old_data = default_progress_data; default_progress_data = new_data; for (cnt = 0; cnt < height; cnt++) { for (cnt2 = 0; cnt2 < width; cnt2++) { data = *(old_data++); for (cnt3 = 0; cnt3 < scale; cnt3++) { for (cnt4 = 0; cnt4 < scale; cnt4++) { new_data[width * scale * cnt3 + cnt4] = data; } } new_data += scale; } new_data += width * scale * (scale - 1); } default_progress.width *= scale; default_progress.height *= scale; default_progress.dx *= scale; default_progress.dy *= scale; } } #endif } void PE_mark_hwaccess(uint64_t thread) { last_hwaccess_thread = thread; asm volatile ("dmb ish"); }
27.862299
140
0.708507
65521488158a632b0a76da4777283c5b934cab5c
4,337
h
C
src/mongo/db/pipeline/document_source_sample_from_random_cursor.h
benety/mongo
203430ac9559f82ca01e3cbb3b0e09149fec0835
[ "Apache-2.0" ]
null
null
null
src/mongo/db/pipeline/document_source_sample_from_random_cursor.h
benety/mongo
203430ac9559f82ca01e3cbb3b0e09149fec0835
[ "Apache-2.0" ]
null
null
null
src/mongo/db/pipeline/document_source_sample_from_random_cursor.h
benety/mongo
203430ac9559f82ca01e3cbb3b0e09149fec0835
[ "Apache-2.0" ]
null
null
null
/** * Copyright (C) 2018-present MongoDB, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the Server Side Public License, version 1, * as published by MongoDB, Inc. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * Server Side Public License for more details. * * You should have received a copy of the Server Side Public License * along with this program. If not, see * <http://www.mongodb.com/licensing/server-side-public-license>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the Server Side Public License in all respects for * all of the code used other than as permitted herein. If you modify file(s) * with this exception, you may extend this exception to your version of the * file(s), but you are not obligated to do so. If you do not wish to do so, * delete this exception statement from your version. If you delete this * exception statement from all source files in the program, then also delete * it in the license file. */ #pragma once #include "mongo/db/exec/document_value/value_comparator.h" #include "mongo/db/pipeline/document_source.h" namespace mongo { /** * This class is not a registered stage, it is only used as an optimized replacement for $sample * when the storage engine allows us to use a random cursor. */ class DocumentSourceSampleFromRandomCursor final : public DocumentSource { public: static constexpr StringData kStageName = "$sampleFromRandomCursor"_sd; const char* getSourceName() const final; Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; DepsTracker::State getDependencies(DepsTracker* deps) const final; StageConstraints constraints(Pipeline::SplitState pipeState) const final { return {StreamType::kStreaming, PositionRequirement::kFirst, HostTypeRequirement::kAnyShard, DiskUseRequirement::kNoDiskUse, FacetRequirement::kNotAllowed, TransactionRequirement::kAllowed, LookupRequirement::kAllowed, UnionRequirement::kAllowed}; } boost::optional<DistributedPlanLogic> distributedPlanLogic() final { return boost::none; } static boost::intrusive_ptr<DocumentSourceSampleFromRandomCursor> create( const boost::intrusive_ptr<ExpressionContext>& expCtx, long long size, std::string idField, long long collectionSize); private: DocumentSourceSampleFromRandomCursor(const boost::intrusive_ptr<ExpressionContext>& expCtx, long long size, std::string idField, long long collectionSize); GetNextResult doGetNext() final; /** * Keep asking for documents from the random cursor until it yields a new document. Errors if a * a document is encountered without a value for '_idField', or if the random cursor keeps * returning duplicate elements. */ GetNextResult getNextNonDuplicateDocument(); long long _size; // The field to use as the id of a document. Usually '_id', but 'ts' for the oplog. std::string _idField; // Keeps track of the documents that have been returned, since a random cursor is allowed to // return duplicates. ValueUnorderedSet _seenDocs; // The approximate number of documents in the collection (includes orphans). const long long _nDocsInColl; // The value to be assigned to the randMetaField of outcoming documents. Each call to getNext() // will decrement this value by an amount scaled by _nDocsInColl as an attempt to appear as if // the documents were produced by a top-k random sort. double _randMetaFieldVal = 1.0; }; } // namespace mongo
42.106796
99
0.697256
456c4589564a79d54a7ad37c5f637b45272b43fb
2,681
h
C
Projects/S2E_App/src/Serial_to_Ethernet/seg.h
kbenyous/WIZ750SR
6754ca34ccabc27a2f736754748a06dc0b2c6dd4
[ "Apache-2.0" ]
14
2016-05-25T15:07:03.000Z
2022-03-15T12:37:25.000Z
Projects/S2E_App/src/Serial_to_Ethernet/seg.h
kbenyous/WIZ750SR
6754ca34ccabc27a2f736754748a06dc0b2c6dd4
[ "Apache-2.0" ]
5
2018-04-10T05:35:33.000Z
2020-06-23T04:40:12.000Z
Projects/S2E_App/src/Serial_to_Ethernet/seg.h
kbenyous/WIZ750SR
6754ca34ccabc27a2f736754748a06dc0b2c6dd4
[ "Apache-2.0" ]
18
2016-10-10T01:49:46.000Z
2022-02-20T13:18:04.000Z
#ifndef SEG_H_ #define SEG_H_ #include <stdint.h> #include "common.h" //#define _SEG_DEBUG_ /////////////////////////////////////////////////////////////////////////////////////////////////////// #define SEG_DATA_UART 0 // S2E Data UART selector, [0] UART0 or [1] UART1 #define SEG_DEBUG_UART 2 // S2E Debug UART, fixed //#define SEG_DATA_BUF_SIZE 2048 // UART Ring buffer size #define SEG_DATA_BUF_SIZE 4096 // UART Ring buffer size /////////////////////////////////////////////////////////////////////////////////////////////////////// #define DEFAULT_MODESWITCH_INTER_GAP 500 // 500ms (0.5sec) //#define MIXED_CLIENT_INFINITY_CONNECT #ifndef MIXED_CLIENT_INFINITY_CONNECT #define MIXED_CLIENT_LIMITED_CONNECT // TCP_MIXED_MODE: TCP CLIENT - limited count of connection retries #define MAX_RECONNECTION_COUNT 10 #endif #define MAX_CONNECTION_AUTH_TIME 5000 // 5000ms (5sec) /////////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef DATA_BUF_SIZE #define DATA_BUF_SIZE 2048 #endif #define SEG_DISABLE 0 #define SEG_ENABLE 1 extern uint8_t opmode; extern uint8_t flag_s2e_application_running; extern uint8_t flag_process_dhcp_success; extern uint8_t flag_process_ip_success; extern uint8_t flag_process_dns_success; extern char * str_working[]; typedef enum{SEG_UART_RX, SEG_UART_TX, SEG_ETHER_RX, SEG_ETHER_TX, SEG_ALL} teDATADIR; typedef enum{ SEG_DEBUG_DISABLED = 0, SEG_DEBUG_ENABLED = 1, SEG_DEBUG_S2E = 2, SEG_DEBUG_E2S = 3, SEG_DEBUG_ALL = 4 } teDEBUGTYPE; // Serial to Ethernet function handler; call by main loop void do_seg(uint8_t sock); // Timer for S2E core operations void seg_timer_sec(void); void seg_timer_msec(void); void init_trigger_modeswitch(uint8_t mode); void set_device_status(teDEVSTATUS status); uint8_t get_device_status(void); uint8_t process_socket_termination(uint8_t socket); // Send Keep-alive packet manually (once) void send_keepalive_packet_manual(uint8_t sock); //These functions must be located in UART Rx IRQ Handler. uint8_t check_serial_store_permitted(uint8_t ch); uint8_t check_modeswitch_trigger(uint8_t ch); // Serial command mode switch trigger code (3-bytes) checker void init_time_delimiter_timer(void); // Serial data packing option [Time]: Timer enalble function for Time delimiter // UART tx/rx and Ethernet tx/rx data transfer bytes counter void clear_data_transfer_bytecount(teDATADIR dir); uint32_t get_data_transfer_bytecount(teDATADIR dir); #endif /* SEG_H_ */
33.5125
121
0.657217
4e56d256e5272c508b4896d24867a573e131699c
97
h
C
samples/SampleApp/ios/Pods/Headers/Public/React-RCTText/React/RCTBaseTextShadowView.h
devapro/react-native-web-image
d673493166a27fc5bac202f34409b735a9a0769f
[ "MIT" ]
156
2016-12-14T07:54:55.000Z
2021-08-06T10:16:27.000Z
samples/SampleApp/ios/Pods/Headers/Public/React-RCTText/React/RCTBaseTextShadowView.h
devapro/react-native-web-image
d673493166a27fc5bac202f34409b735a9a0769f
[ "MIT" ]
24
2017-01-05T08:06:41.000Z
2021-05-06T17:31:45.000Z
samples/SampleApp/ios/Pods/Headers/Public/React-RCTText/React/RCTBaseTextShadowView.h
devapro/react-native-web-image
d673493166a27fc5bac202f34409b735a9a0769f
[ "MIT" ]
35
2016-11-25T14:39:33.000Z
2020-05-15T11:06:57.000Z
../../../../../../../../node_modules/react-native/Libraries/Text/BaseText/RCTBaseTextShadowView.h
97
97
0.680412
648f476d1008c6c4ee3b28bc94049ee60cd8f5c6
5,577
c
C
benchmarks/dftc/source/copy_descriptor.c
proywm/CCProf
20c43042142909dc782064e4250a5167767f7314
[ "MIT" ]
21
2018-01-20T14:01:13.000Z
2021-11-03T03:17:39.000Z
benchmarks/dftc/source/copy_descriptor.c
proywm/CCProf
20c43042142909dc782064e4250a5167767f7314
[ "MIT" ]
2
2021-08-14T14:06:32.000Z
2021-11-11T10:38:03.000Z
benchmarks/dftc/source/copy_descriptor.c
proywm/CCProf
20c43042142909dc782064e4250a5167767f7314
[ "MIT" ]
1
2018-07-05T06:36:30.000Z
2018-07-05T06:36:30.000Z
/******************************************************************************* * Copyright 2011-2016 Intel Corporation All Rights Reserved. * * The source code, information and material ("Material") contained herein is * owned by Intel Corporation or its suppliers or licensors, and title to such * Material remains with Intel Corporation or its suppliers or licensors. The * Material contains proprietary information of Intel or its suppliers and * licensors. The Material is protected by worldwide copyright laws and treaty * provisions. No part of the Material may be used, copied, reproduced, * modified, published, uploaded, posted, transmitted, distributed or disclosed * in any way without Intel's prior express written permission. No license under * any patent, copyright or other intellectual property rights in the Material * is granted to or conferred upon you, either expressly, by implication, * inducement, estoppel or otherwise. Any license under such intellectual * property rights must be express and approved by Intel in writing. * * Unless otherwise agreed by Intel in writing, you may not remove or alter this * notice or any other notice embedded in Materials by Intel or Intel's * suppliers or licensors in any way. *******************************************************************************/ /* ! Content: ! An example of using DftiCopyDescriptor function. ! !****************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <float.h> #include "mkl_service.h" #include "mkl_dfti.h" static void init(MKL_Complex16 *x, MKL_LONG N, MKL_LONG H); static int verify(MKL_Complex16 *x, MKL_LONG N, MKL_LONG H); /* Define the format to printf MKL_LONG values */ #if !defined(MKL_ILP64) #define LI "%li" #else #define LI "%lli" #endif int main(void) { /* Size of 1D transform */ MKL_LONG N = 1024; /* Arbitrary harmonic used to verify FFT */ MKL_LONG H = -N/2; /* Pointer to input/output data */ MKL_Complex16 *x = 0; /* Execution status */ MKL_LONG status = 0; DFTI_DESCRIPTOR_HANDLE h1 = 0; DFTI_DESCRIPTOR_HANDLE h2 = 0; char version[DFTI_VERSION_LENGTH]; DftiGetValue(0, DFTI_VERSION, version); printf("%s\n", version); printf("Example copy_descriptor\n"); printf("Forward FFT by using a copy of a descriptor\n"); printf("Configuration parameters:\n"); printf(" DFTI_PRECISION = DFTI_DOUBLE\n"); printf(" DFTI_FORWARD_DOMAIN = DFTI_COMPLEX\n"); printf(" DFTI_DIMENSION = 1\n"); printf(" DFTI_LENGTHS = "LI"\n", N); printf("Create DFTI descriptor h1\n"); status = DftiCreateDescriptor(&h1, DFTI_DOUBLE, DFTI_COMPLEX, 1, N); if (0 != status) goto failed; printf("Commit DFTI descriptor h1\n"); status = DftiCommitDescriptor(h1); if (0 != status) goto failed; printf("Copy descriptor h1 to h2\n"); status = DftiCopyDescriptor( h1, &h2 ); if (0 != status) goto failed; printf("Free descriptor h1\n"); DftiFreeDescriptor( &h1 ); printf("Allocate input/output array\n"); x = (MKL_Complex16*)mkl_malloc(N*sizeof(MKL_Complex16), 64); if (0 == x) goto failed; printf("Initialize input for forward transform\n"); init(x, N, H); printf("Compute forward transform using descriptor h2\n"); status = DftiComputeForward(h2, x); if (0 != status) goto failed; printf("Verify the result of forward FFT\n"); status = verify(x, N, H); if (0 != status) goto failed; cleanup: printf("Release the DFTI descriptors\n"); DftiFreeDescriptor( &h1 ); /* ok, h1 should be NULL */ DftiFreeDescriptor( &h2 ); printf("Free data array\n"); mkl_free(x); printf("TEST %s\n",0==status ? "PASSED" : "FAILED"); return status; failed: printf(" ERROR, status = "LI"\n", status); status = 1; goto cleanup; } /* Compute (K*L)%M accurately */ static double moda(MKL_LONG K, MKL_LONG L, MKL_LONG M) { return (double)(((long long)K * L) % M); } /* Initialize array with harmonic H */ static void init(MKL_Complex16 *x, MKL_LONG N, MKL_LONG H) { double TWOPI = 6.2831853071795864769, phase; MKL_LONG n; for (n = 0; n < N; n++) { phase = moda(n,H,N) / N; x[n].real = cos( TWOPI * phase ) / N; x[n].imag = sin( TWOPI * phase ) / N; } } /* Verify that x has unit peak at H */ static int verify(MKL_Complex16 *x, MKL_LONG N, MKL_LONG H) { double err, errthr, maxerr; MKL_LONG n; /* * Note, this simple error bound doesn't take into account error of * input data */ errthr = 5.0 * log( (double)N ) / log(2.0) * DBL_EPSILON; printf(" Verify the result, errthr = %.3lg\n", errthr); maxerr = 0; for (n = 0; n < N; n++) { double re_exp = 0.0, im_exp = 0.0, re_got, im_got; if ((n-H)%N==0) { re_exp = 1; } re_got = x[n].real; im_got = x[n].imag; err = fabs(re_got - re_exp) + fabs(im_got - im_exp); if (err > maxerr) maxerr = err; if (!(err < errthr)) { printf(" x["LI"]: ",n); printf(" expected (%.17lg,%.17lg), ",re_exp,im_exp); printf(" got (%.17lg,%.17lg), ",re_got,im_got); printf(" err %.3lg\n", err); printf(" Verification FAILED\n"); return 100; } } printf(" Verified, maximum error was %.3lg\n", maxerr); return 0; }
30.47541
80
0.60355
c16a7bc732ad7968d4bcfec9aef9ae3da95c3cd7
1,515
c
C
queve.c/main.c
Harshpathakjnp/CCodings
b9873c4341b01bba54f5af5a1f18bc02a9c12ec9
[ "MIT" ]
null
null
null
queve.c/main.c
Harshpathakjnp/CCodings
b9873c4341b01bba54f5af5a1f18bc02a9c12ec9
[ "MIT" ]
null
null
null
queve.c/main.c
Harshpathakjnp/CCodings
b9873c4341b01bba54f5af5a1f18bc02a9c12ec9
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #define size 10 typedef struct{ int front; int back; int data[size] ; int count; } queue; void init(queue* q); void enque(queue* q ,int data); int deque(queue* q); int isEmpty(queue q); void display(); int main() { queue q1,q2; int i,x,choice; init(&q1); /* while(1) { printf("\n0- Exit\n1- Enque\n2- Deque\n3- Printall\n\nEnter your Choice :"); scanf("%d",&choice); switch(choice) { case 0: { return 0; } case 1: { printf("Enter a number \n"); scanf("%d",&x); enque(&q1,x); break; } case 2: { x= deque(&q1); printf("\n%d\n",x); break; } case 3: { } } } */ enque(&q1,1); enque(&q1,2); enque(&q1,3); enque(&q1,4); while(!isEmpty(q1)) { printf("%d,",deque(&q1)); } return 0; } void enque(queue* q,int data) { if(q->count>=size) { printf("Queue is Full "); return; } q->data[q->back]=data; q->back=(q->back + 1) % size; q->count++; } int deque(queue* q) { int x; if(q->count<=0) { printf("Queue is empty\n"); return -1; } x=q->data[q->front]; q->front=(q->front + 1) % size; q->count--; return x; } int isEmpty(queue q) { if(q.count<=0) return 1; else return 0; } void init(queue* q) { q->back=0; q->count=0; q->front=0; } void display() { /* int i; for(i = (q->front); i <= q->back; i++) printf("%d ", data[i]); printf("n"); */ }
12.625
80
0.49835
1eb7ed5d0da297eb0762453c6d5206e03ea7320d
5,006
h
C
chrome/browser/views/password_manager_view.h
bluebellzhy/chromium
008c4fef2676506869a0404239da31e83fd6ccc7
[ "BSD-3-Clause" ]
1
2016-05-08T15:35:17.000Z
2016-05-08T15:35:17.000Z
chrome/browser/views/password_manager_view.h
bluebellzhy/chromium
008c4fef2676506869a0404239da31e83fd6ccc7
[ "BSD-3-Clause" ]
null
null
null
chrome/browser/views/password_manager_view.h
bluebellzhy/chromium
008c4fef2676506869a0404239da31e83fd6ccc7
[ "BSD-3-Clause" ]
null
null
null
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_PASSWORD_MANAGER_VIEW_H__ #define CHROME_BROWSER_PASSWORD_MANAGER_VIEW_H__ #include <vector> #include "chrome/browser/webdata/web_data_service.h" #include "chrome/common/gfx/url_elider.h" #include "chrome/views/dialog_delegate.h" #include "chrome/views/label.h" #include "chrome/views/native_button.h" #include "chrome/views/table_view.h" #include "chrome/views/window.h" class Profile; struct PasswordForm; class PasswordManagerTableModel : public views::TableModel, public WebDataServiceConsumer { public: explicit PasswordManagerTableModel(Profile* profile); virtual ~PasswordManagerTableModel(); // TableModel methods. virtual int RowCount(); virtual std::wstring GetText(int row, int column); virtual int CompareValues(int row1, int row2, int column_id); virtual void SetObserver(views::TableModelObserver* observer); // Delete the PasswordForm at specified row from the database (and remove // from view). void ForgetAndRemoveSignon(int row); // Delete all saved signons for the active profile (via web data service), // and clear the view. void ForgetAndRemoveAllSignons(); // WebDataServiceConsumer implementation. virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, const WDTypedResult* result); // Request saved logins data. void GetAllSavedLoginsForProfile(); // Return the PasswordForm at the specified index. PasswordForm* GetPasswordFormAt(int row); private: // Wraps the PasswordForm from the database and caches the display URL for // quick sorting. struct PasswordRow { ~PasswordRow(); // Contains the URL that is displayed along with the gfx::SortedDisplayURL display_url; // The underlying PasswordForm. We own this. PasswordForm* form; }; // Cancel any pending login query involving a callback. void CancelLoginsQuery(); // The web data service associated with the currently active profile. WebDataService* web_data_service() { return profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); } // The TableView observing this model. views::TableModelObserver* observer_; // Handle to any pending WebDataService::GetLogins query. WebDataService::Handle pending_login_query_; // The set of passwords we're showing. typedef std::vector<PasswordRow> PasswordRows; PasswordRows saved_signons_; Profile* profile_; DISALLOW_EVIL_CONSTRUCTORS(PasswordManagerTableModel); }; // A button that can have 2 different labels set on it and for which the // preferred size is the size of the widest string. class MultiLabelButtons : public views::NativeButton { public: MultiLabelButtons(const std::wstring& label, const std::wstring& alt_label); virtual gfx::Size GetPreferredSize(); private: std::wstring label_; std::wstring alt_label_; gfx::Size pref_size_; DISALLOW_EVIL_CONSTRUCTORS(MultiLabelButtons); }; class PasswordManagerView : public views::View, public views::DialogDelegate, public views::TableViewObserver, public views::NativeButton::Listener { public: explicit PasswordManagerView(Profile* profile); virtual ~PasswordManagerView(); // Show the PasswordManagerContentView for the given profile. static void Show(Profile* profile); // View methods. virtual void Layout(); virtual gfx::Size GetPreferredSize(); virtual void ViewHierarchyChanged(bool is_add, views::View* parent, views::View* child); // views::TableViewObserver implementation. virtual void OnSelectionChanged(); // NativeButton::Listener implementation. virtual void ButtonPressed(views::NativeButton* sender); // views::DialogDelegate methods: virtual int GetDialogButtons() const; virtual bool CanResize() const; virtual bool CanMaximize() const; virtual bool IsAlwaysOnTop() const; virtual bool HasAlwaysOnTopMenu() const; virtual std::wstring GetWindowTitle() const; virtual void WindowClosing(); virtual views::View* GetContentsView(); private: // Wire up buttons, the model, and the table view, and query the DB for // saved login data tied to the given profile. void Init(); // Helper to configure our buttons and labels. void SetupButtonsAndLabels(); // Helper to configure our table view. void SetupTable(); // Components in this view. PasswordManagerTableModel table_model_; views::TableView* table_view_; // The buttons and labels. MultiLabelButtons show_button_; views::NativeButton remove_button_; views::NativeButton remove_all_button_; views::Label password_label_; DISALLOW_EVIL_CONSTRUCTORS(PasswordManagerView); }; #endif // CHROME_BROWSER_PASSWORD_MANAGER_VIEW_H__
31.2875
78
0.734918
9b38765580ee17d01e3d45f032d764ab97bc0b16
880
h
C
src/HemeraCore/hemeraoperation_p.h
hemeraos/hemera-qt5-sdk
cb8c2a3fa692e5c3234bb9e1f1ae01b9e1d54771
[ "Apache-2.0" ]
null
null
null
src/HemeraCore/hemeraoperation_p.h
hemeraos/hemera-qt5-sdk
cb8c2a3fa692e5c3234bb9e1f1ae01b9e1d54771
[ "Apache-2.0" ]
null
null
null
src/HemeraCore/hemeraoperation_p.h
hemeraos/hemera-qt5-sdk
cb8c2a3fa692e5c3234bb9e1f1ae01b9e1d54771
[ "Apache-2.0" ]
1
2021-02-08T15:25:46.000Z
2021-02-08T15:25:46.000Z
#ifndef HEMERA_OPERATION_P_H #define HEMERA_OPERATION_P_H #include <HemeraCore/hemeraoperation.h> #include <QtCore/QDebug> namespace Hemera { class OperationPrivate { public: enum class PrivateExecutionOption { NoOptions = 0, SetStartedExplicitly = 1 }; Q_DECLARE_FLAGS(PrivateExecutionOptions, PrivateExecutionOption) Q_FLAGS(PrivateExecutionOptions) OperationPrivate(Operation *q, PrivateExecutionOptions pO = PrivateExecutionOption::NoOptions) : q_ptr(q), privateOptions(pO), started(false), finished(false) {} Q_DECLARE_PUBLIC(Operation) Operation * const q_ptr; QString errorName; QString errorMessage; Operation::ExecutionOptions options; PrivateExecutionOptions privateOptions; bool started : 1; bool finished : 1; // Private slots void emitFinished(); void setStarted(); }; } #endif
22.564103
165
0.735227
88d73be84b940cc3729a16cd1f5422751502eb30
6,119
h
C
samples/include/dt-bindings/clock/omap4.h
yehudahs/silver-leaves
c3945f36466455dd1c54594f45d15026587b701b
[ "MIT" ]
44
2022-03-16T08:32:31.000Z
2022-03-31T16:02:35.000Z
samples/include/dt-bindings/clock/omap4.h
yehudahs/silver-leaves
c3945f36466455dd1c54594f45d15026587b701b
[ "MIT" ]
13
2021-07-10T04:36:17.000Z
2022-03-03T10:50:05.000Z
samples/include/dt-bindings/clock/omap4.h
yehudahs/silver-leaves
c3945f36466455dd1c54594f45d15026587b701b
[ "MIT" ]
18
2022-03-19T04:41:04.000Z
2022-03-31T03:32:12.000Z
/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright 2017 Texas Instruments, Inc. */ #ifndef __DT_BINDINGS_CLK_OMAP4_H #define __DT_BINDINGS_CLK_OMAP4_H #define OMAP4_CLKCTRL_OFFSET 0x20 #define OMAP4_CLKCTRL_INDEX(offset) ((offset) - OMAP4_CLKCTRL_OFFSET) /* mpuss clocks */ #define OMAP4_MPU_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) /* tesla clocks */ #define OMAP4_DSP_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) /* abe clocks */ #define OMAP4_L4_ABE_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) #define OMAP4_AESS_CLKCTRL OMAP4_CLKCTRL_INDEX(0x28) #define OMAP4_MCPDM_CLKCTRL OMAP4_CLKCTRL_INDEX(0x30) #define OMAP4_DMIC_CLKCTRL OMAP4_CLKCTRL_INDEX(0x38) #define OMAP4_MCASP_CLKCTRL OMAP4_CLKCTRL_INDEX(0x40) #define OMAP4_MCBSP1_CLKCTRL OMAP4_CLKCTRL_INDEX(0x48) #define OMAP4_MCBSP2_CLKCTRL OMAP4_CLKCTRL_INDEX(0x50) #define OMAP4_MCBSP3_CLKCTRL OMAP4_CLKCTRL_INDEX(0x58) #define OMAP4_SLIMBUS1_CLKCTRL OMAP4_CLKCTRL_INDEX(0x60) #define OMAP4_TIMER5_CLKCTRL OMAP4_CLKCTRL_INDEX(0x68) #define OMAP4_TIMER6_CLKCTRL OMAP4_CLKCTRL_INDEX(0x70) #define OMAP4_TIMER7_CLKCTRL OMAP4_CLKCTRL_INDEX(0x78) #define OMAP4_TIMER8_CLKCTRL OMAP4_CLKCTRL_INDEX(0x80) #define OMAP4_WD_TIMER3_CLKCTRL OMAP4_CLKCTRL_INDEX(0x88) /* l4_ao clocks */ #define OMAP4_SMARTREFLEX_MPU_CLKCTRL OMAP4_CLKCTRL_INDEX(0x28) #define OMAP4_SMARTREFLEX_IVA_CLKCTRL OMAP4_CLKCTRL_INDEX(0x30) #define OMAP4_SMARTREFLEX_CORE_CLKCTRL OMAP4_CLKCTRL_INDEX(0x38) /* l3_1 clocks */ #define OMAP4_L3_MAIN_1_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) /* l3_2 clocks */ #define OMAP4_L3_MAIN_2_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) #define OMAP4_GPMC_CLKCTRL OMAP4_CLKCTRL_INDEX(0x28) #define OMAP4_OCMC_RAM_CLKCTRL OMAP4_CLKCTRL_INDEX(0x30) /* ducati clocks */ #define OMAP4_IPU_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) /* l3_dma clocks */ #define OMAP4_DMA_SYSTEM_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) /* l3_emif clocks */ #define OMAP4_DMM_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) #define OMAP4_EMIF1_CLKCTRL OMAP4_CLKCTRL_INDEX(0x30) #define OMAP4_EMIF2_CLKCTRL OMAP4_CLKCTRL_INDEX(0x38) /* d2d clocks */ #define OMAP4_C2C_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) /* l4_cfg clocks */ #define OMAP4_L4_CFG_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) #define OMAP4_SPINLOCK_CLKCTRL OMAP4_CLKCTRL_INDEX(0x28) #define OMAP4_MAILBOX_CLKCTRL OMAP4_CLKCTRL_INDEX(0x30) /* l3_instr clocks */ #define OMAP4_L3_MAIN_3_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) #define OMAP4_L3_INSTR_CLKCTRL OMAP4_CLKCTRL_INDEX(0x28) #define OMAP4_OCP_WP_NOC_CLKCTRL OMAP4_CLKCTRL_INDEX(0x40) /* ivahd clocks */ #define OMAP4_IVA_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) #define OMAP4_SL2IF_CLKCTRL OMAP4_CLKCTRL_INDEX(0x28) /* iss clocks */ #define OMAP4_ISS_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) #define OMAP4_FDIF_CLKCTRL OMAP4_CLKCTRL_INDEX(0x28) /* l3_dss clocks */ #define OMAP4_DSS_CORE_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) /* l3_gfx clocks */ #define OMAP4_GPU_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) /* l3_init clocks */ #define OMAP4_MMC1_CLKCTRL OMAP4_CLKCTRL_INDEX(0x28) #define OMAP4_MMC2_CLKCTRL OMAP4_CLKCTRL_INDEX(0x30) #define OMAP4_HSI_CLKCTRL OMAP4_CLKCTRL_INDEX(0x38) #define OMAP4_USB_HOST_HS_CLKCTRL OMAP4_CLKCTRL_INDEX(0x58) #define OMAP4_USB_OTG_HS_CLKCTRL OMAP4_CLKCTRL_INDEX(0x60) #define OMAP4_USB_TLL_HS_CLKCTRL OMAP4_CLKCTRL_INDEX(0x68) #define OMAP4_USB_HOST_FS_CLKCTRL OMAP4_CLKCTRL_INDEX(0xd0) #define OMAP4_OCP2SCP_USB_PHY_CLKCTRL OMAP4_CLKCTRL_INDEX(0xe0) /* l4_per clocks */ #define OMAP4_TIMER10_CLKCTRL OMAP4_CLKCTRL_INDEX(0x28) #define OMAP4_TIMER11_CLKCTRL OMAP4_CLKCTRL_INDEX(0x30) #define OMAP4_TIMER2_CLKCTRL OMAP4_CLKCTRL_INDEX(0x38) #define OMAP4_TIMER3_CLKCTRL OMAP4_CLKCTRL_INDEX(0x40) #define OMAP4_TIMER4_CLKCTRL OMAP4_CLKCTRL_INDEX(0x48) #define OMAP4_TIMER9_CLKCTRL OMAP4_CLKCTRL_INDEX(0x50) #define OMAP4_ELM_CLKCTRL OMAP4_CLKCTRL_INDEX(0x58) #define OMAP4_GPIO2_CLKCTRL OMAP4_CLKCTRL_INDEX(0x60) #define OMAP4_GPIO3_CLKCTRL OMAP4_CLKCTRL_INDEX(0x68) #define OMAP4_GPIO4_CLKCTRL OMAP4_CLKCTRL_INDEX(0x70) #define OMAP4_GPIO5_CLKCTRL OMAP4_CLKCTRL_INDEX(0x78) #define OMAP4_GPIO6_CLKCTRL OMAP4_CLKCTRL_INDEX(0x80) #define OMAP4_HDQ1W_CLKCTRL OMAP4_CLKCTRL_INDEX(0x88) #define OMAP4_I2C1_CLKCTRL OMAP4_CLKCTRL_INDEX(0xa0) #define OMAP4_I2C2_CLKCTRL OMAP4_CLKCTRL_INDEX(0xa8) #define OMAP4_I2C3_CLKCTRL OMAP4_CLKCTRL_INDEX(0xb0) #define OMAP4_I2C4_CLKCTRL OMAP4_CLKCTRL_INDEX(0xb8) #define OMAP4_L4_PER_CLKCTRL OMAP4_CLKCTRL_INDEX(0xc0) #define OMAP4_MCBSP4_CLKCTRL OMAP4_CLKCTRL_INDEX(0xe0) #define OMAP4_MCSPI1_CLKCTRL OMAP4_CLKCTRL_INDEX(0xf0) #define OMAP4_MCSPI2_CLKCTRL OMAP4_CLKCTRL_INDEX(0xf8) #define OMAP4_MCSPI3_CLKCTRL OMAP4_CLKCTRL_INDEX(0x100) #define OMAP4_MCSPI4_CLKCTRL OMAP4_CLKCTRL_INDEX(0x108) #define OMAP4_MMC3_CLKCTRL OMAP4_CLKCTRL_INDEX(0x120) #define OMAP4_MMC4_CLKCTRL OMAP4_CLKCTRL_INDEX(0x128) #define OMAP4_SLIMBUS2_CLKCTRL OMAP4_CLKCTRL_INDEX(0x138) #define OMAP4_UART1_CLKCTRL OMAP4_CLKCTRL_INDEX(0x140) #define OMAP4_UART2_CLKCTRL OMAP4_CLKCTRL_INDEX(0x148) #define OMAP4_UART3_CLKCTRL OMAP4_CLKCTRL_INDEX(0x150) #define OMAP4_UART4_CLKCTRL OMAP4_CLKCTRL_INDEX(0x158) #define OMAP4_MMC5_CLKCTRL OMAP4_CLKCTRL_INDEX(0x160) /* l4_secure clocks */ #define OMAP4_L4_SECURE_CLKCTRL_OFFSET 0x1a0 #define OMAP4_L4_SECURE_CLKCTRL_INDEX(offset) ((offset) - OMAP4_L4_SECURE_CLKCTRL_OFFSET) #define OMAP4_AES1_CLKCTRL OMAP4_L4_SECURE_CLKCTRL_INDEX(0x1a0) #define OMAP4_AES2_CLKCTRL OMAP4_L4_SECURE_CLKCTRL_INDEX(0x1a8) #define OMAP4_DES3DES_CLKCTRL OMAP4_L4_SECURE_CLKCTRL_INDEX(0x1b0) #define OMAP4_PKA_CLKCTRL OMAP4_L4_SECURE_CLKCTRL_INDEX(0x1b8) #define OMAP4_RNG_CLKCTRL OMAP4_L4_SECURE_CLKCTRL_INDEX(0x1c0) #define OMAP4_SHA2MD5_CLKCTRL OMAP4_L4_SECURE_CLKCTRL_INDEX(0x1c8) #define OMAP4_CRYPTODMA_CLKCTRL OMAP4_L4_SECURE_CLKCTRL_INDEX(0x1d8) /* l4_wkup clocks */ #define OMAP4_L4_WKUP_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) #define OMAP4_WD_TIMER2_CLKCTRL OMAP4_CLKCTRL_INDEX(0x30) #define OMAP4_GPIO1_CLKCTRL OMAP4_CLKCTRL_INDEX(0x38) #define OMAP4_TIMER1_CLKCTRL OMAP4_CLKCTRL_INDEX(0x40) #define OMAP4_COUNTER_32K_CLKCTRL OMAP4_CLKCTRL_INDEX(0x50) #define OMAP4_KBD_CLKCTRL OMAP4_CLKCTRL_INDEX(0x78) /* emu_sys clocks */ #define OMAP4_DEBUGSS_CLKCTRL OMAP4_CLKCTRL_INDEX(0x20) #endif
40.793333
89
0.864684
004257a50af82a509462dd75ed0b7d5f6fa73166
1,088
c
C
rtc/rtc_generic.c
FreeRTOSHAL/driver
7aeafca1aa7370e4d521ca76a2cd8f71f70fa51e
[ "MIT" ]
7
2018-10-27T17:02:17.000Z
2022-03-02T00:48:50.000Z
rtc/rtc_generic.c
FreeRTOSHAL/driver
7aeafca1aa7370e4d521ca76a2cd8f71f70fa51e
[ "MIT" ]
null
null
null
rtc/rtc_generic.c
FreeRTOSHAL/driver
7aeafca1aa7370e4d521ca76a2cd8f71f70fa51e
[ "MIT" ]
6
2016-11-09T16:22:54.000Z
2020-12-24T17:28:09.000Z
/* SPDX-License-Identifier: MIT */ /* * Author: Andreas Werner <kernel@andy89.org> * Date: 2016 */ #include <rtc.h> #define RTC_PRV #include <rtc_prv.h> int32_t rtc_genericInit(struct rtc *t) { struct rtc_generic *rtc = (struct rtc_generic *) t; if (hal_isInit(rtc)) { return RTC_ALREDY_INITED; } #ifdef CONFIG_RTC_THREAD_SAFE { int32_t ret = hal_init(rtc); if (ret < 0) { goto rtc_generic_init_error0; } } #endif rtc->init = true; return 0; #ifdef CONFIG_RTC_THREAD_SAFE rtc_generic_init_error0: return -1; #endif } #ifdef CONFIG_RTC_MULTI struct rtc *rtc_init(uint32_t index); int32_t rtc_deinit(struct rtc *rtc); int32_t rtc_adjust(struct rtc *rtc, struct timespec *offset, TickType_t waittime); int32_t rtc_getTime(struct rtc *rtc, struct timespec *time, TickType_t waittime); int32_t rtc_setTime(struct rtc *rtc, struct timespec *time, TickType_t waittime); int32_t rtc_adjustISR(struct rtc *rtc, struct timespec *offset); int32_t rtc_getTimeISR(struct rtc *rtc, struct timespec *time); int32_t rtc_setTimeISR(struct rtc *rtc, struct timespec *time); #endif
25.904762
82
0.750919
5381416b1e72ff639e10f73f13b99084c429d562
2,718
h
C
rtbkit/plugins/bidder_interface/http_bidder_interface.h
ashwin711/rtbkit
d2d168e14f51222254ac8e4d850427623bafb524
[ "Apache-2.0" ]
1
2017-05-29T14:15:15.000Z
2017-05-29T14:15:15.000Z
rtbkit/plugins/bidder_interface/http_bidder_interface.h
ashwin711/rtbkit
d2d168e14f51222254ac8e4d850427623bafb524
[ "Apache-2.0" ]
null
null
null
rtbkit/plugins/bidder_interface/http_bidder_interface.h
ashwin711/rtbkit
d2d168e14f51222254ac8e4d850427623bafb524
[ "Apache-2.0" ]
null
null
null
/* http_bidder_interface.h Eric Robert, 2 April 2014 Copyright (c) 2011 Datacratic. All rights reserved. */ #pragma once #include "rtbkit/common/bidder_interface.h" #include "soa/service/http_client.h" namespace RTBKIT { struct Bids; struct HttpBidderInterface : public BidderInterface { HttpBidderInterface(std::string name = "bidder", std::shared_ptr<ServiceProxies> proxies = std::make_shared<ServiceProxies>(), Json::Value const & json = Json::Value()); void sendAuctionMessage(std::shared_ptr<Auction> const & auction, double timeLeftMs, std::map<std::string, BidInfo> const & bidders); void sendWinLossMessage(MatchedWinLoss const & event); void sendLossMessage(std::string const & agent, std::string const & id); void sendCampaignEventMessage(std::string const & agent, MatchedCampaignEvent const & event); void sendBidLostMessage(std::string const & agent, std::shared_ptr<Auction> const & auction); void sendBidDroppedMessage(std::string const & agent, std::shared_ptr<Auction> const & auction); void sendBidInvalidMessage(std::string const & agent, std::string const & reason, std::shared_ptr<Auction> const & auction); void sendNoBudgetMessage(std::string const & agent, std::shared_ptr<Auction> const & auction); void sendTooLateMessage(std::string const & agent, std::shared_ptr<Auction> const & auction); void sendMessage(std::string const & agent, std::string const & message); void sendErrorMessage(std::string const & agent, std::string const & error, std::vector<std::string> const & payload); void sendPingMessage(std::string const & agent, int ping); void send(std::shared_ptr<PostAuctionEvent> const & event); virtual void tagRequest(OpenRTB::BidRequest &request, const std::map<std::string, BidInfo> &bidders) const; private: bool prepareRequest(OpenRTB::BidRequest &request, const RTBKIT::BidRequest &originalRequest, const std::map<std::string, BidInfo> &bidders) const; void submitBids(const std::string &agent, Id auctionId, const Bids &bids, WinCostModel wcm); std::shared_ptr<HttpClient> httpClient; std::string host; std::string path; }; }
35.298701
101
0.589772
bb0600ba6501cb609f2558865e66831f6e3b41e1
1,609
h
C
ColorRangeEdit.h
GeorgRottensteiner/Painter
ab57f5d022c8b4ce8f9713cd7533fc87e5fafa3b
[ "Unlicense" ]
null
null
null
ColorRangeEdit.h
GeorgRottensteiner/Painter
ab57f5d022c8b4ce8f9713cd7533fc87e5fafa3b
[ "Unlicense" ]
null
null
null
ColorRangeEdit.h
GeorgRottensteiner/Painter
ab57f5d022c8b4ce8f9713cd7533fc87e5fafa3b
[ "Unlicense" ]
1
2021-11-21T13:17:20.000Z
2021-11-21T13:17:20.000Z
#if !defined(AFX_COLORRANGEEDIT_H__E7AA1AE5_845C_4A53_8EF4_92F8C235D722__INCLUDED_) #define AFX_COLORRANGEEDIT_H__E7AA1AE5_845C_4A53_8EF4_92F8C235D722__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // ColorRangeEdit.h : header file // #include <MFC/RangeEdit.h> ///////////////////////////////////////////////////////////////////////////// // CColorRangeEdit window class CColorRangeEdit : public CRangeEdit { // Construction public: CColorRangeEdit(); protected: HBITMAP m_hbmColorBar; COLORREF GetColor( int iPos ); // Operations public: virtual void SetRange( int iMin, int iMax, int iStep = 1 ); virtual void SetRange( float fMin, float fMax, float fStep = 0.02f, int iVorKomma = -1, int iNachKomma = 2 ); virtual void SetPosition( float fPos ); virtual void DrawPopup( HDC hdc, const RECT& rcTarget ); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CColorRangeEdit) //}}AFX_VIRTUAL // Implementation public: virtual ~CColorRangeEdit(); // Generated message map functions protected: //{{AFX_MSG(CColorRangeEdit) // NOTE - the ClassWizard will add and remove member functions here. //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_COLORRANGEEDIT_H__E7AA1AE5_845C_4A53_8EF4_92F8C235D722__INCLUDED_)
26.816667
117
0.646986
184dddb4566c6b3d89e66703b5401167b7fe12cd
2,711
h
C
hphp/runtime/ext/ext_icu_uspoof.h
abhishekgahlot/hiphop-php
5b367ac44a7a9a6e4c777ae0786d1c872d3ae0a9
[ "PHP-3.01", "Zend-2.0" ]
1
2015-11-05T19:26:02.000Z
2015-11-05T19:26:02.000Z
hphp/runtime/ext/ext_icu_uspoof.h
abhishekgahlot/hiphop-php
5b367ac44a7a9a6e4c777ae0786d1c872d3ae0a9
[ "PHP-3.01", "Zend-2.0" ]
null
null
null
hphp/runtime/ext/ext_icu_uspoof.h
abhishekgahlot/hiphop-php
5b367ac44a7a9a6e4c777ae0786d1c872d3ae0a9
[ "PHP-3.01", "Zend-2.0" ]
null
null
null
/* +----------------------------------------------------------------------+ | HipHop for PHP | +----------------------------------------------------------------------+ | Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) | | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ */ #ifndef EXT_ICU_USPOOF_H #define EXT_ICU_USPOOF_H // >>>>>> Generated by idl.php. Do NOT modify. <<<<<< #include "hphp/runtime/base/base_includes.h" // Avoid dragging in the icu namespace. #ifndef U_USING_ICU_NAMESPACE #define U_USING_ICU_NAMESPACE 0 #endif #include "unicode/uspoof.h" #include "unicode/utypes.h" namespace HPHP { /////////////////////////////////////////////////////////////////////////////// extern const int64_t q_SpoofChecker$$SINGLE_SCRIPT_CONFUSABLE; extern const int64_t q_SpoofChecker$$MIXED_SCRIPT_CONFUSABLE; extern const int64_t q_SpoofChecker$$WHOLE_SCRIPT_CONFUSABLE; extern const int64_t q_SpoofChecker$$ANY_CASE; extern const int64_t q_SpoofChecker$$SINGLE_SCRIPT; extern const int64_t q_SpoofChecker$$INVISIBLE; extern const int64_t q_SpoofChecker$$CHAR_LIMIT; /////////////////////////////////////////////////////////////////////////////// // class SpoofChecker FORWARD_DECLARE_CLASS_BUILTIN(SpoofChecker); class c_SpoofChecker : public ExtObjectData { public: DECLARE_CLASS(SpoofChecker, SpoofChecker, ObjectData) // need to implement public: c_SpoofChecker(Class* cls = c_SpoofChecker::s_cls); public: ~c_SpoofChecker(); public: void t___construct(); public: bool t_issuspicious(CStrRef text, VRefParam issuesFound = uninit_null()); public: bool t_areconfusable(CStrRef s1, CStrRef s2, VRefParam issuesFound = uninit_null()); public: void t_setallowedlocales(CStrRef localesList); public: void t_setchecks(int checks); private: USpoofChecker *m_spoof_checker; }; /////////////////////////////////////////////////////////////////////////////// } #endif // EXT_ICU_USPOOF_H
40.462687
94
0.559941
1851e00a07f5a36cc78c34148405f4e9ca0deb8f
363
h
C
src/theme_p.h
ctrlz-kid/hotpot
3ad5cfa7bd0c684c68dcd1b58c9faadce64a72d4
[ "Apache-2.0" ]
null
null
null
src/theme_p.h
ctrlz-kid/hotpot
3ad5cfa7bd0c684c68dcd1b58c9faadce64a72d4
[ "Apache-2.0" ]
1
2021-01-08T14:24:08.000Z
2021-01-08T14:45:28.000Z
src/theme_p.h
ctrlz-kid/hotpot
3ad5cfa7bd0c684c68dcd1b58c9faadce64a72d4
[ "Apache-2.0" ]
null
null
null
#ifndef THEMEPRIVATE_H #define THEMEPRIVATE_H #include <QVector> #include <QPair> #include <QColor> #include <QMap> namespace Extras { class ThemePrivate { public: ThemePrivate(); QString id; QString fileName; QString displayName; QVector<QPair<QColor, QString> > colors; QMap<QString, QColor> palette; }; } #endif // THEMEPRIVATE_H
14.52
44
0.705234
eb7718811f34da44743981e3afc4ec4fe2eb7975
1,176
h
C
iree/compiler/Dialect/HAL/Target/WebGPU/WebGPUTarget.h
smit-hinsu/iree
a385d311b701cdc06cb825000ddb34c8a11c6eef
[ "Apache-2.0" ]
1
2022-02-13T15:27:08.000Z
2022-02-13T15:27:08.000Z
iree/compiler/Dialect/HAL/Target/WebGPU/WebGPUTarget.h
iree-github-actions-bot/iree
9982f10090527a1a86cd280b4beff9a579b96b38
[ "Apache-2.0" ]
1
2022-01-27T18:10:51.000Z
2022-01-27T18:10:51.000Z
iree/compiler/Dialect/HAL/Target/WebGPU/WebGPUTarget.h
iree-github-actions-bot/iree
9982f10090527a1a86cd280b4beff9a579b96b38
[ "Apache-2.0" ]
null
null
null
// Copyright 2021 The IREE Authors // // Licensed under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #ifndef IREE_COMPILER_DIALECT_HAL_TARGET_WEBGPU_WEBGPUTARGET_H_ #define IREE_COMPILER_DIALECT_HAL_TARGET_WEBGPU_WEBGPUTARGET_H_ #include <functional> #include <string> namespace mlir { namespace iree_compiler { namespace IREE { namespace HAL { // Options controlling the WebGPU/WGSL translation. struct WebGPUTargetOptions { // Include debug information like variable names in outputs. bool debugSymbols = true; // True to keep shader modules for debugging. bool keepShaderModules = false; }; // Returns a WebGPUTargetOptions struct initialized with WebGPU/WGSL related // command-line flags. WebGPUTargetOptions getWebGPUTargetOptionsFromFlags(); // Registers the WebGPU/WGSL backends. void registerWebGPUTargetBackends( std::function<WebGPUTargetOptions()> queryOptions); } // namespace HAL } // namespace IREE } // namespace iree_compiler } // namespace mlir #endif // IREE_COMPILER_DIALECT_HAL_TARGET_WEBGPU_WEBGPUTARGET_H_
28.682927
76
0.793367
a0ddefb24725299cb883bd7f8028974d24c702d2
105
h
C
crypto_stream/salsa20/e/amd64-3/api.h
iadgov/simon-speck-supercop
5bba85c3094029eb73b7077441e5c6ea2f2cb1c6
[ "CC0-1.0" ]
21
2016-12-03T14:19:01.000Z
2018-03-09T14:52:25.000Z
crypto_stream/salsa20/e/amd64-3/api.h
iadgov/simon-speck-supercop
5bba85c3094029eb73b7077441e5c6ea2f2cb1c6
[ "CC0-1.0" ]
null
null
null
crypto_stream/salsa20/e/amd64-3/api.h
iadgov/simon-speck-supercop
5bba85c3094029eb73b7077441e5c6ea2f2cb1c6
[ "CC0-1.0" ]
11
2017-03-06T17:21:42.000Z
2018-03-18T03:52:58.000Z
#define crypto_stream_salsa20_e_amd64_3_KEYBYTES 32 #define crypto_stream_salsa20_e_amd64_3_NONCEBYTES 8
35
52
0.92381
6f13c01b49f29ab388cf6c78f503cd1f25e0027f
740
h
C
include/RE/B/BGSLensFlare.h
tossaponk/CommonLibSSE
18c724dbc1128f11a581de16a9d372988ea0c8ce
[ "MIT" ]
1
2022-02-21T21:31:27.000Z
2022-02-21T21:31:27.000Z
include/RE/B/BGSLensFlare.h
tossaponk/CommonLibSSE
18c724dbc1128f11a581de16a9d372988ea0c8ce
[ "MIT" ]
null
null
null
include/RE/B/BGSLensFlare.h
tossaponk/CommonLibSSE
18c724dbc1128f11a581de16a9d372988ea0c8ce
[ "MIT" ]
1
2022-02-21T21:31:29.000Z
2022-02-21T21:31:29.000Z
#pragma once #include "RE/B/BSLensFlareRenderData.h" #include "RE/F/FormTypes.h" #include "RE/T/TESForm.h" namespace RE { class BGSLensFlare : public TESForm, // 00 public BSLensFlareRenderData // 20 { public: inline static constexpr auto RTTI = RTTI_BGSLensFlare; inline static constexpr auto VTABLE = VTABLE_BGSLensFlare; inline static constexpr auto FORMTYPE = FormType::LensFlare; struct RecordFlags { enum RecordFlag : std::uint32_t { }; }; ~BGSLensFlare() override; // 00 // override (TESForm) void ClearData() override; // 05 bool Load(TESFile* a_mod) override; // 06 void InitItemImpl() override; // 13 }; static_assert(sizeof(BGSLensFlare) == 0x40); }
21.764706
62
0.671622
6fb86323aaa7264651d82a5dcfcfb6c2d265a69f
1,679
c
C
mbed-cloud-client/update-client-hub/modules/common/source/arm_uc_hw_plat.c
darkopancev517/pelion-client
215136e5e71cb316dd9684bd008adf8cd1a99ca4
[ "Apache-2.0" ]
null
null
null
mbed-cloud-client/update-client-hub/modules/common/source/arm_uc_hw_plat.c
darkopancev517/pelion-client
215136e5e71cb316dd9684bd008adf8cd1a99ca4
[ "Apache-2.0" ]
null
null
null
mbed-cloud-client/update-client-hub/modules/common/source/arm_uc_hw_plat.c
darkopancev517/pelion-client
215136e5e71cb316dd9684bd008adf8cd1a99ca4
[ "Apache-2.0" ]
null
null
null
// ---------------------------------------------------------------------------- // Copyright 2016-2017 ARM Ltd. // // SPDX-License-Identifier: Apache-2.0 // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ---------------------------------------------------------------------------- #include "update-client-common/arm_uc_hw_plat.h" #include "update-client-common/arm_uc_utilities.h" #include "update-client-common/arm_uc_error.h" #include "update-client-common/arm_uc_config.h" #include <string.h> #include <stdlib.h> #include <stdio.h> #ifdef __linux__ #include <sys/reboot.h> #endif #if defined(TARGET_LIKE_MBED) #define RESET_MASK_FOR_CORTEX_M_SERIES 0x5fa0004 volatile unsigned int *AIRCR_REG = (volatile unsigned int *)( 0xE000ED0C); //This register address is true for the Cortex M family #endif /** * @brief Issue a platform-specific Hard-reboot * */ void arm_uc_plat_reboot(void) { #if defined(TARGET_LIKE_MBED) *AIRCR_REG = RESET_MASK_FOR_CORTEX_M_SERIES; while (1); /* wait until reset */ #elif __linux__ // Reboot the device reboot(RB_AUTOBOOT); while (1); /* wait until reset */ #endif }
31.679245
109
0.653365
175040a02cd4db328342c035e03c04d776fb107d
2,957
c
C
bundles/remote_services/examples/calculator_shell/src/sqrt_command.c
reiform/celix
c1e900ea53d6ac65388bcbfc70e06d132d1df7c0
[ "Apache-2.0" ]
113
2015-03-12T12:47:40.000Z
2022-03-28T08:47:11.000Z
bundles/remote_services/examples/calculator_shell/src/sqrt_command.c
reiform/celix
c1e900ea53d6ac65388bcbfc70e06d132d1df7c0
[ "Apache-2.0" ]
295
2015-10-16T12:32:07.000Z
2022-03-26T14:48:11.000Z
bundles/remote_services/examples/calculator_shell/src/sqrt_command.c
reiform/celix
c1e900ea53d6ac65388bcbfc70e06d132d1df7c0
[ "Apache-2.0" ]
93
2015-09-13T14:02:04.000Z
2022-02-14T02:19:56.000Z
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #include <stdlib.h> #include <ctype.h> #include <string.h> #include "celix_api.h" #include "celix_utils.h" #include "sqrt_command.h" #include "calculator_service.h" static celix_status_t sqrtCommand_isNumeric(char *number, bool *ret); struct calc_callback_data { double a; double result; int rc; }; static void calcCallback(void *handle, void *svc) { struct calc_callback_data *data = handle; calculator_service_t *calc = svc; data->rc = calc->sqrt(calc->handle, data->a, &data->result); } bool sqrtCommand_execute(void *handle, const char *const_line, FILE *out, FILE *err) { celix_bundle_context_t *context = handle; bool ok = true; char *line = celix_utils_strdup(const_line); char *token = line; strtok_r(line, " ", &token); char *aStr = strtok_r(NULL, " ", &token); if(aStr != NULL) { bool numeric; sqrtCommand_isNumeric(aStr, &numeric); if (numeric) { struct calc_callback_data data; data.a = atof(aStr); data.result = 0; data.rc = 0; bool called = celix_bundleContext_useService(context, CALCULATOR_SERVICE, &data, calcCallback); if (called && data.rc == 0) { fprintf(out, "CALCULATOR_SHELL: Sqrt: %f = %f\n", data.a, data.result); } else if (!called) { fprintf(err, "ADD: calculator service not available\n"); ok = false; } else { fprintf(err, "ADD: Unexpected exception in Calc service\n"); ok = false; } } else { fprintf(err, "SQRT: Requires 1 numerical parameter\n"); ok = false; } } else { fprintf(err, "SQRT: Requires 1 numerical parameter\n"); ok = false; } free(line); return ok; } static celix_status_t sqrtCommand_isNumeric(char *number, bool *ret) { celix_status_t status = CELIX_SUCCESS; *ret = true; while(*number) { if(!isdigit(*number) && *number != '.') { *ret = false; break; } number++; } return status; }
30.173469
107
0.623605
17a5f438cfd4d9a53b31ecefc3880475d27d3e0f
126
c
C
src/libs6dns/s6dns_engine_here.c
matya/s6-dns
cc9b534a06add57598b53578ba9ba8460fd61e0b
[ "0BSD" ]
36
2015-02-28T12:14:47.000Z
2022-01-03T21:46:08.000Z
src/libs6dns/s6dns_engine_here.c
s6-debs/s6-dns
ffed76f91e3623f40d1ebffffc0bc728722c84f5
[ "0BSD" ]
1
2021-05-04T12:01:00.000Z
2021-05-04T12:24:21.000Z
src/libs6dns/s6dns_engine_here.c
s6-debs/s6-dns
ffed76f91e3623f40d1ebffffc0bc728722c84f5
[ "0BSD" ]
7
2017-07-19T05:18:16.000Z
2021-05-14T18:51:01.000Z
/* ISC license. */ /* MT-unsafe */ #include <s6-dns/s6dns-engine.h> s6dns_engine_t s6dns_engine_here = S6DNS_ENGINE_ZERO ;
15.75
54
0.714286
a5dd2e5ecb62a8b1d98dfaca1f7cea8b3a239ec0
2,664
c
C
src/dft/mkunroll.c
malfet/sleef
fbb3d36e0b8a63eefde5bc194d919a94fabf1a81
[ "BSL-1.0" ]
null
null
null
src/dft/mkunroll.c
malfet/sleef
fbb3d36e0b8a63eefde5bc194d919a94fabf1a81
[ "BSL-1.0" ]
null
null
null
src/dft/mkunroll.c
malfet/sleef
fbb3d36e0b8a63eefde5bc194d919a94fabf1a81
[ "BSL-1.0" ]
null
null
null
// Copyright Naoki Shibata and contributors 2010 - 2020. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #define CONFIGMAX 4 char *replaceAll(const char *in, const char *pat, const char *replace) { const int replaceLen = strlen(replace); const int patLen = strlen(pat); char *str = malloc(strlen(in)+1); strcpy(str, in); for(;;) { char *p = strstr(str, pat); if (p == NULL) return str; int replace_pos = p - str; int tail_len = strlen(p + patLen); char *newstr = malloc(strlen(str) + (replaceLen - patLen) + 1); memcpy(newstr, str, replace_pos); memcpy(newstr + replace_pos, replace, replaceLen); memcpy(newstr + replace_pos + replaceLen, str + replace_pos + patLen, tail_len+1); free(str); str = newstr; } return str; } #define LEN 1024 char line[LEN+10]; int main(int argc, char **argv) { if (argc < 2) { fprintf(stderr, "Usage : %s <Base type> <ISA> ...\n", argv[0]); exit(-1); } const char *baseType = argv[1]; const int isastart = 2; const int isamax = argc - isastart; const int maxbutwidth = 6; for(int config=0;config<CONFIGMAX;config++) { #if ENABLE_STREAM == 0 if ((config & 1) != 0) continue; #endif for(int isa=isastart;isa<argc;isa++) { char *isaString = argv[isa]; char configString[100]; sprintf(configString, "%d", config); FILE *fpin = fopen("unroll0.org", "r"); sprintf(line, "unroll_%d_%s.c", config, isaString); FILE *fpout = fopen(line, "w"); fputs("#include \"vectortype.h\"\n\n", fpout); fprintf(fpout, "extern %s ctbl_%s[];\n", baseType, baseType); fprintf(fpout, "#define ctbl ctbl_%s\n\n", baseType); for(;;) { if (fgets(line, LEN, fpin) == NULL) break; char *s; if ((config & 1) == 0) { char *s0 = replaceAll(line, "%ISA%", isaString); s = replaceAll(s0, "%CONFIG%", configString); free(s0); } else { char *s0 = replaceAll(line, "%ISA%", isaString); char *s1 = replaceAll(s0, "%CONFIG%", configString); char *s2 = replaceAll(s1, "store(", "stream("); s = replaceAll(s2, "scatter(", "scstream("); free(s0); free(s1); free(s2); } if ((config & 2) == 0) { char *s0 = replaceAll(s, "#pragma", "//"); free(s); s = s0; } if (config == 0) { char *s0 = replaceAll(s, "#undef EMITREALSUB", "#define EMITREALSUB"); free(s); s = s0; } fputs(s, fpout); free(s); } fclose(fpin); fclose(fpout); } } }
24.897196
86
0.594595
85bca6e4decda8810958cac44be703e8223e9ff4
3,118
h
C
Source/MainComponent.h
SilvinWillemsen/TrombaMarina
3e839ba187a89bb59da314aa0c0f901107db6e04
[ "MIT" ]
null
null
null
Source/MainComponent.h
SilvinWillemsen/TrombaMarina
3e839ba187a89bb59da314aa0c0f901107db6e04
[ "MIT" ]
null
null
null
Source/MainComponent.h
SilvinWillemsen/TrombaMarina
3e839ba187a89bb59da314aa0c0f901107db6e04
[ "MIT" ]
null
null
null
/* ============================================================================== This file was auto-generated! ============================================================================== */ #pragma once #include "../JuceLibraryCode/JuceHeader.h" #include "../SenselWrapper/SenselWrapper.h" #include "Tromba.h" #include <iostream> #include <fstream> //============================================================================== /* This component lives inside our window, and this is where you should put all your controls and content. */ class MainComponent : public AudioAppComponent, public Timer, public Button::Listener, public Slider::Listener, public HighResolutionTimer { public: //============================================================================== MainComponent(); ~MainComponent(); //============================================================================== void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override; void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill) override; void releaseResources() override; //============================================================================== void paint (Graphics& g) override; void resized() override; void timerCallback() override; void hiResTimerCallback() override; void buttonClicked (Button* button) override; void sliderValueChanged (Slider* slider) override; private: //============================================================================== double fs; std::unique_ptr<Tromba> tromba; std::shared_ptr<TrombaString> trombaString; std::shared_ptr<Bridge> bridge; std::shared_ptr<Body> body; // Debug things std::unique_ptr<TextButton> continueButton; std::unique_ptr<Label> stateLabel; std::unique_ptr<Label> currentSampleLabel; std::atomic<bool> continueFlag; double offset; unsigned long curSample = 0; // first sample is index 1 (like Matlab) // Create c code std::unique_ptr<TextButton> createCButton; double bridgeLocRatio; double outputStringRatio; // Sensel Stuff OwnedArray<Sensel> sensels; int amountOfSensels = 1; std::unique_ptr<TextButton> resetButton; std::unique_ptr<ToggleButton> graphicsButton; OwnedArray<Slider> mixSliders; std::vector<float> mixVals; std::vector<float> prevMixVals; float aG = 0.99; // Parameter Sliders OwnedArray<Slider> parameterSliders; std::vector<float> initParams; // Sensel-interaction-to-parameter-maximums double maxVb = 0.5; double maxFb = 0.1; double maxFn = 0.7; double maxNoise = 0.5; bool quantisePitch = false; bool easyControl = true; bool graphicsToggle = false; std::ofstream outputSound; std::ofstream stringState, bridgeState, bodyState; std::ofstream sampleNumber; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent) };
31.816327
141
0.548749
124affd587d8bdbc89a258b67299047f7b13ea39
4,582
c
C
tools/peview/previewprp.c
fangshun2004/processhacker
c6844b50e3a4375eee94157f24de689d341de6ba
[ "MIT" ]
null
null
null
tools/peview/previewprp.c
fangshun2004/processhacker
c6844b50e3a4375eee94157f24de689d341de6ba
[ "MIT" ]
null
null
null
tools/peview/previewprp.c
fangshun2004/processhacker
c6844b50e3a4375eee94157f24de689d341de6ba
[ "MIT" ]
null
null
null
/* * Copyright (c) 2022 Winsider Seminars & Solutions, Inc. All rights reserved. * * This file is part of System Informer. * * Authors: * * dmex 2019-2022 * */ #include <peview.h> typedef struct _PV_PE_PREVIEW_CONTEXT { HWND WindowHandle; HWND EditWindow; HIMAGELIST ListViewImageList; PH_LAYOUT_MANAGER LayoutManager; PPV_PROPPAGECONTEXT PropSheetContext; } PV_PE_PREVIEW_CONTEXT, *PPV_PE_PREVIEW_CONTEXT; VOID PvpSetRichEditText( _In_ HWND WindowHandle, _In_ PWSTR Text ) { //SetFocus(WindowHandle); SendMessage(WindowHandle, WM_SETREDRAW, FALSE, 0); //SendMessage(WindowHandle, EM_SETSEL, 0, -1); // -2 SendMessage(WindowHandle, WM_SETTEXT, FALSE, (LPARAM)Text); //SendMessage(WindowHandle, WM_VSCROLL, SB_TOP, 0); // requires SetFocus() SendMessage(WindowHandle, WM_SETREDRAW, TRUE, 0); //PostMessage(WindowHandle, EM_SETSEL, -1, 0); //InvalidateRect(WindowHandle, NULL, FALSE); } VOID PvpShowFilePreview( _In_ HWND WindowHandle ) { PPH_STRING fileText; PH_STRING_BUILDER sb; if (fileText = PhFileReadAllText(PvFileName->Buffer, TRUE)) { PhInitializeStringBuilder(&sb, 0x1000); for (SIZE_T i = 0; i < fileText->Length / sizeof(WCHAR); i++) { if (iswprint(fileText->Buffer[i])) { PhAppendCharStringBuilder(&sb, fileText->Buffer[i]); } else { PhAppendCharStringBuilder(&sb, L' '); } } PhMoveReference(&fileText, PhFinalStringBuilderString(&sb)); PvpSetRichEditText(GetDlgItem(WindowHandle, IDC_PREVIEW), fileText->Buffer); PhDereferenceObject(fileText); } } INT_PTR CALLBACK PvpPePreviewDlgProc( _In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) { PPV_PE_PREVIEW_CONTEXT context; if (uMsg == WM_INITDIALOG) { context = PhAllocateZero(sizeof(PV_PE_PREVIEW_CONTEXT)); PhSetWindowContext(hwndDlg, PH_WINDOW_CONTEXT_DEFAULT, context); if (lParam) { LPPROPSHEETPAGE propSheetPage = (LPPROPSHEETPAGE)lParam; context->PropSheetContext = (PPV_PROPPAGECONTEXT)propSheetPage->lParam; } } else { context = PhGetWindowContext(hwndDlg, PH_WINDOW_CONTEXT_DEFAULT); } if (!context) return FALSE; switch (uMsg) { case WM_INITDIALOG: { context->WindowHandle = hwndDlg; context->EditWindow = GetDlgItem(hwndDlg, IDC_PREVIEW); SendMessage(context->EditWindow, EM_SETLIMITTEXT, ULONG_MAX, 0); PvConfigTreeBorders(context->EditWindow); PhInitializeLayoutManager(&context->LayoutManager, hwndDlg); PhAddLayoutItem(&context->LayoutManager, context->EditWindow, NULL, PH_ANCHOR_ALL); PvpShowFilePreview(hwndDlg); PhInitializeWindowTheme(hwndDlg, PeEnableThemeSupport); } break; case WM_DESTROY: { PhDeleteLayoutManager(&context->LayoutManager); PhFree(context); } break; case WM_SHOWWINDOW: { if (context->PropSheetContext && !context->PropSheetContext->LayoutInitialized) { PvAddPropPageLayoutItem(hwndDlg, hwndDlg, PH_PROP_PAGE_TAB_CONTROL_PARENT, PH_ANCHOR_ALL); PvDoPropPageLayout(hwndDlg); context->PropSheetContext->LayoutInitialized = TRUE; } } break; case WM_SIZE: { PhLayoutManagerLayout(&context->LayoutManager); } break; case WM_NOTIFY: { LPNMHDR header = (LPNMHDR)lParam; switch (header->code) { case PSN_QUERYINITIALFOCUS: SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)context->EditWindow); return TRUE; } } break; case WM_CTLCOLORBTN: case WM_CTLCOLORDLG: case WM_CTLCOLORSTATIC: case WM_CTLCOLORLISTBOX: { SetBkMode((HDC)wParam, TRANSPARENT); SetTextColor((HDC)wParam, RGB(0, 0, 0)); SetDCBrushColor((HDC)wParam, RGB(255, 255, 255)); return (INT_PTR)GetStockBrush(DC_BRUSH); } break; } return FALSE; }
27.769697
107
0.589917
c4189463bd64e795121b728ad4e6123d2a00c2b3
728
h
C
include/XWeb.h
sitara-systems/Cinder-XUI
ecccbe8677535700a52e0122dab59fa0800d3411
[ "MIT" ]
null
null
null
include/XWeb.h
sitara-systems/Cinder-XUI
ecccbe8677535700a52e0122dab59fa0800d3411
[ "MIT" ]
null
null
null
include/XWeb.h
sitara-systems/Cinder-XUI
ecccbe8677535700a52e0122dab59fa0800d3411
[ "MIT" ]
null
null
null
#pragma once #include "XRect.h" #include "cinder/Vector.h" #include "cinder/Color.h" #include "cinder/gl/Texture.h" // forward declarations for Awesomium namespace Awesomium { class WebView; class WebSession; } namespace xui { typedef std::shared_ptr<class XWeb> XWebRef; class XWeb : public XRect { Awesomium::WebSession* mWebSessionPtr; Awesomium::WebView* mWebViewPtr; public: ~XWeb(); static XWebRef create(); static XWebRef create( ci::XmlTree &xml ); virtual XNode::NodeType getType() { return XNode::NodeTypeWeb; } void update(double elapsedSeconds); void draw(float opacity = 1.0f); void loadXml( ci::XmlTree &xml ); protected: XWeb(); ci::gl::TextureRef mWebTexture; }; }
17.756098
65
0.703297
3fb5132d588b7b0b2f1c027756caaab01fa20411
5,585
c
C
xun/xnu-6153.81.5/security/mac_vfs_subr.c
L-Zheng/AppleOpenSource
65fac74ce17dc97404f1aeb8c24625fe82b7d142
[ "MIT" ]
null
null
null
xun/xnu-6153.81.5/security/mac_vfs_subr.c
L-Zheng/AppleOpenSource
65fac74ce17dc97404f1aeb8c24625fe82b7d142
[ "MIT" ]
null
null
null
xun/xnu-6153.81.5/security/mac_vfs_subr.c
L-Zheng/AppleOpenSource
65fac74ce17dc97404f1aeb8c24625fe82b7d142
[ "MIT" ]
null
null
null
/* * Copyright (c) 2007 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. The rights granted to you under the License * may not be used to create, or enable the creation or redistribution of, * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ #include <sys/param.h> #include <sys/vnode.h> #include <sys/vnode_internal.h> #include <sys/kauth.h> #include <sys/namei.h> #include <sys/mount.h> #include <sys/mount_internal.h> #include <sys/uio_internal.h> #include <sys/xattr.h> #include "../bsd/sys/fsevents.h" #include <security/mac_internal.h> /* * Caller holds I/O reference on vnode */ int vnode_label(struct mount *mp, struct vnode *dvp, struct vnode *vp, struct componentname *cnp, int flags, vfs_context_t ctx) { int error = 0; bool exit_fast; /* fast path checks... */ /* are we labeling vnodes? If not still notify of create */ #if CONFIG_MACF_LAZY_VNODE_LABELS exit_fast = true; #else exit_fast = (mac_label_vnodes == 0); #endif if (exit_fast) { if (flags & VNODE_LABEL_CREATE) { error = mac_vnode_notify_create(ctx, mp, dvp, vp, cnp); } return 0; } /* if already VL_LABELED */ if (vp->v_lflag & VL_LABELED) { return 0; } vnode_lock_spin(vp); /* * must revalidate state once we hold the lock * since we could have blocked and someone else * has since labeled this vnode */ if (vp->v_lflag & VL_LABELED) { vnode_unlock(vp); return 0; } if ((vp->v_lflag & VL_LABEL) == 0) { vp->v_lflag |= VL_LABEL; /* Could sleep on disk I/O, drop lock. */ vnode_unlock(vp); if (vp->v_label == NULL) { vp->v_label = mac_vnode_label_alloc(); } if (flags & VNODE_LABEL_CREATE) { error = mac_vnode_notify_create(ctx, mp, dvp, vp, cnp); } else { error = mac_vnode_label_associate(mp, vp, ctx); } vnode_lock_spin(vp); if ((error == 0) && (vp->v_flag & VNCACHEABLE)) { vp->v_lflag |= VL_LABELED; } vp->v_lflag &= ~VL_LABEL; if (vp->v_lflag & VL_LABELWAIT) { vp->v_lflag &= ~VL_LABELWAIT; wakeup(&vp->v_label); } } else { struct timespec ts; ts.tv_sec = 10; ts.tv_nsec = 0; while (vp->v_lflag & VL_LABEL) { vp->v_lflag |= VL_LABELWAIT; error = msleep(&vp->v_label, &vp->v_lock, PVFS | PDROP, "vnode_label", &ts); vnode_lock_spin(vp); if (error == EWOULDBLOCK) { vprint("vnode label timeout", vp); break; } } /* XXX: what should be done if labeling failed (above)? */ } vnode_unlock(vp); return error; } /* * Clear the "labeled" flag on a VNODE. * VNODE will have label re-associated upon * next call to lookup(). * * Caller verifies vfs_flags(vnode_mount(vp)) & MNT_MULTILABEL * Caller holds vnode lock. */ void vnode_relabel(struct vnode *vp) { /* Wait for any other labeling to complete. */ while (vp->v_lflag & VL_LABEL) { vp->v_lflag |= VL_LABELWAIT; (void)msleep(&vp->v_label, &vp->v_lock, PVFS, "vnode_relabel", 0); } /* Clear labeled flag */ vp->v_lflag &= ~VL_LABELED; return; } /* * VFS XATTR helpers. */ int mac_vnop_setxattr(struct vnode *vp, const char *name, char *buf, size_t len) { vfs_context_t ctx; int options = XATTR_NOSECURITY; char uio_buf[UIO_SIZEOF(1)]; uio_t auio; int error; if (vfs_isrdonly(vp->v_mount)) { return EROFS; } ctx = vfs_context_current(); auio = uio_createwithbuffer(1, 0, UIO_SYSSPACE, UIO_WRITE, &uio_buf[0], sizeof(uio_buf)); uio_addiov(auio, CAST_USER_ADDR_T(buf), len); error = vn_setxattr(vp, name, auio, options, ctx); #if CONFIG_FSE if (error == 0) { add_fsevent(FSE_XATTR_MODIFIED, ctx, FSE_ARG_VNODE, vp, FSE_ARG_DONE); } #endif return error; } int mac_vnop_getxattr(struct vnode *vp, const char *name, char *buf, size_t len, size_t *attrlen) { vfs_context_t ctx = vfs_context_current(); int options = XATTR_NOSECURITY; char uio_buf[UIO_SIZEOF(1)]; uio_t auio; int error; auio = uio_createwithbuffer(1, 0, UIO_SYSSPACE, UIO_READ, &uio_buf[0], sizeof(uio_buf)); uio_addiov(auio, CAST_USER_ADDR_T(buf), len); error = vn_getxattr(vp, name, auio, attrlen, options, ctx); *attrlen = len - uio_resid(auio); return error; } int mac_vnop_removexattr(struct vnode *vp, const char *name) { vfs_context_t ctx = vfs_context_current(); int options = XATTR_NOSECURITY; int error; if (vfs_isrdonly(vp->v_mount)) { return EROFS; } error = vn_removexattr(vp, name, options, ctx); #if CONFIG_FSE if (error == 0) { add_fsevent(FSE_XATTR_REMOVED, ctx, FSE_ARG_VNODE, vp, FSE_ARG_DONE); } #endif return error; }
23.565401
76
0.691495
3f11babef68c075c8a61b2d82c4f8d4dd02d4d0e
2,494
h
C
reader/Reader.h
vsapiens/memory-management-virtualization
9ff9b701548229e6357f714b8361f4f5c75a4f18
[ "Apache-2.0" ]
1
2019-11-14T17:51:53.000Z
2019-11-14T17:51:53.000Z
reader/Reader.h
vsapiens/memory-management-virtualization
9ff9b701548229e6357f714b8361f4f5c75a4f18
[ "Apache-2.0" ]
null
null
null
reader/Reader.h
vsapiens/memory-management-virtualization
9ff9b701548229e6357f714b8361f4f5c75a4f18
[ "Apache-2.0" ]
1
2019-12-03T02:15:58.000Z
2019-12-03T02:15:58.000Z
#pragma once #include <vector> #include <string> #include <tuple> #include <fstream> #include "Token.h" #include "Scanner.h" #include "Parser.h" namespace sisops{ namespace { /* Function: Parser::ltrim This function trims the characters Parameters: std::string& str, const std::string& chars = "\t\n\v\f\r " Return: std::string& */ std::string& ltrim(std::string& str, const std::string& chars = "\t\n\v\f\r ") { str.erase(0, str.find_first_not_of(chars)); return str; } /* Function: Parser::rtrim This function trims the characters Parameters: std::string& str, const std::string& chars = "\t\n\v\f\r " Return: std::string& */ std::string& rtrim(std::string& str, const std::string& chars = "\t\n\v\f\r ") { str.erase(str.find_last_not_of(chars) + 1); return str; } /* Function: Parser::trim This function trims the characters Parameters: std::string& str, const std::string& chars = "\t\n\v\f\r " Return: std::string& */ std::string& trim(std::string& str, const std::string& chars = "\t\n\v\f\r ") { return ltrim(rtrim(str, chars), chars); } /* Function: Parser::readFile This function reads the file Parameters: std::string file Return: std::vector<std::string> */ std::vector<std::string> readFile(std::string file){ std::ifstream input; input.open(file); std::vector<std::string> ins; std::string buffer; while (std::getline(input, buffer)) { trim(buffer); ins.push_back(buffer); } return ins; } } struct Error { std::string message; int line; Error(int l, std::string m) { line = l; message = m; } }; /* Function: readAndParseInputFile This functions reads and parses the file Parameters: std::string file Return: std::tuple<std::vector<std::vector<Token>>, std::vector<Error>> */ std::tuple<std::vector<std::vector<Token>>, std::vector<Error>> readAndParseInputFile(std::string file) { std::vector<std::string> instructions = readFile(file); Parser parser; Scanner scanner; std::vector<std::vector<Token>> token_list; std::vector<Error> errors; for (int i = 0; i < instructions.size(); i++) { std::vector<Token> tokens = scanner.scan(instructions[i]); ParseStatus status = parser.parseIns(tokens); if (!status.correct) { Error e(i, status.message); errors.push_back(e); } token_list.push_back(tokens); } return std::make_tuple(token_list, errors); } }
23.308411
105
0.641941
3f2ef2f88875dd5a6849fec431aaeb4aaf0eb9fa
3,965
h
C
libminifi/include/core/state/UpdatePolicy.h
msharee9/nifi-minifi-cpp
7143121ff87dfb67f9234daab330b1df996bce11
[ "Apache-2.0" ]
3
2018-01-11T19:48:07.000Z
2019-06-11T09:39:05.000Z
libminifi/include/core/state/UpdatePolicy.h
msharee9/nifi-minifi-cpp
7143121ff87dfb67f9234daab330b1df996bce11
[ "Apache-2.0" ]
1
2021-01-12T14:00:12.000Z
2021-01-12T14:00:12.000Z
libminifi/include/core/state/UpdatePolicy.h
msharee9/nifi-minifi-cpp
7143121ff87dfb67f9234daab330b1df996bce11
[ "Apache-2.0" ]
1
2020-07-28T08:50:50.000Z
2020-07-28T08:50:50.000Z
/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef LIBMINIFI_INCLUDE_CORE_STATE_UPDATEPOLICY_H_ #define LIBMINIFI_INCLUDE_CORE_STATE_UPDATEPOLICY_H_ #include <unordered_map> namespace org { namespace apache { namespace nifi { namespace minifi { namespace state { enum UPDATE_POLICY { PERM_ALLOWED, PERM_DISALLOWED, IMPLICIT_DISALLOWED, TEMP_ALLOWED }; class UpdatePolicyBuilder; /** * Purpose: Defines an immutable policy map. * Defines what can and cannot be updated during runtime. */ class UpdatePolicy { public: explicit UpdatePolicy(bool enable_all) : enable_all_(enable_all) { } bool canUpdate(const std::string &property) const { auto p = properties_.find(property); if (p != std::end(properties_)) { switch (p->second) { case PERM_ALLOWED: case TEMP_ALLOWED: return true; default: return false; } } return enable_all_; } UpdatePolicy &operator=(const UpdatePolicy &&other) { enable_all_ = std::move(other.enable_all_); properties_ = std::move(other.properties_); return *this; } protected: explicit UpdatePolicy(const UpdatePolicy &other) : enable_all_(other.enable_all_), properties_(other.properties_) { } explicit UpdatePolicy(const UpdatePolicy &&other) : enable_all_(std::move(other.enable_all_)), properties_(std::move(other.properties_)) { } UpdatePolicy() = delete; friend class UpdatePolicyBuilder; void setEnableAll(bool enable_all) { enable_all_ = enable_all; } void setProperty(const std::string &property, UPDATE_POLICY policy) { properties_.emplace(property, policy); } bool enable_all_; std::unordered_map<std::string, UPDATE_POLICY> properties_; }; /** * Purpose: Defines a builder for UpdatePolicy definitions. Since policies are made * to be immutable defining an object as const isn't sufficient as const can be casted * away. The builder helps add a layer to avoiding this by design. */ class UpdatePolicyBuilder { public: static std::unique_ptr<UpdatePolicyBuilder> newBuilder(bool enable_all = false) { std::unique_ptr<UpdatePolicyBuilder> policy = std::unique_ptr<UpdatePolicyBuilder>( new UpdatePolicyBuilder(enable_all)); return policy; } void allowPropertyUpdate(const std::string &property) { current_policy_->setProperty(property, PERM_ALLOWED); } void disallowPropertyUpdate(const std::string &property) { current_policy_->setProperty(property, PERM_DISALLOWED); } std::unique_ptr<UpdatePolicy> build() { std::unique_ptr<UpdatePolicy> new_policy = std::unique_ptr<UpdatePolicy>(new UpdatePolicy(*(current_policy_.get()))); return new_policy; } protected: explicit UpdatePolicyBuilder(const UpdatePolicyBuilder &other) : current_policy_(other.current_policy_) { } explicit UpdatePolicyBuilder(bool enable_all) { current_policy_ = std::make_shared<UpdatePolicy>(enable_all); } std::shared_ptr<UpdatePolicy> current_policy_; }; } /* namespace state */ } /* namespace minifi */ } /* namespace nifi */ } /* namespace apache */ } /* namespace org */ #endif /* LIBMINIFI_INCLUDE_CORE_STATE_UPDATEPOLICY_H_ */
27.344828
125
0.728878
5597a454f0b8dd79d9b153c1f932c557d0a5b73f
2,953
h
C
L1Trigger/L1TGlobal/interface/PrescalesVetosHelper.h
nistefan/cmssw
ea13af97f7f2117a4f590a5e654e06ecd9825a5b
[ "Apache-2.0" ]
3
2018-08-24T19:10:26.000Z
2019-02-19T11:45:32.000Z
L1Trigger/L1TGlobal/interface/PrescalesVetosHelper.h
nistefan/cmssw
ea13af97f7f2117a4f590a5e654e06ecd9825a5b
[ "Apache-2.0" ]
3
2018-08-23T13:40:24.000Z
2019-12-05T21:16:03.000Z
L1Trigger/L1TGlobal/interface/PrescalesVetosHelper.h
nistefan/cmssw
ea13af97f7f2117a4f590a5e654e06ecd9825a5b
[ "Apache-2.0" ]
5
2018-08-21T16:37:52.000Z
2020-01-09T13:33:17.000Z
#ifndef PRESCALESVETOSHELPERS_H__ #define PRESCALESVETOSHELPERS_H__ #include <cassert> #include "CondFormats/L1TObjects/interface/L1TGlobalPrescalesVetos.h" // If you want to create a new object that you can read and write, use this constructor: // // l1t::PrescalesVetosHelper x(new L1TPrescalesVetors()); // // If you wish to read the table from the EventSetup, and will only read, use this: // // const PrescalesVetosHelper * x = PrescalesVetosHelper::readFromEventSetup(...) // //... // delete x; // // If you wish to read the table from the EventSetup, but then be able to edit the values locally, use this: // // PrescalesVetorsHelper * x = PrescalesVetosHelper::readAndWriteFromEventSetup(...) // //... /// delete x; // // but there's a performance penalty as a copy is made. // // This class does not take over responsibility for deleting the pointers it is // initialized with. That is responsibility of the calling code. // namespace l1t { class PrescalesVetosHelper { public: enum {VERSION_ = 1}; ~PrescalesVetosHelper(); //ctor if creating a new table (e.g. from XML or python file) PrescalesVetosHelper(L1TGlobalPrescalesVetos * w); //create for reading only, from the EventSetup: static const PrescalesVetosHelper * readFromEventSetup(const L1TGlobalPrescalesVetos * es); // create for reading and writing, starting from the EventSetup: static PrescalesVetosHelper * readAndWriteFromEventSetup(const L1TGlobalPrescalesVetos * es); int bxMaskDefault() const { return read_->bxmask_default_; }; void setBxMaskDefault(int value) { check_write(); write_->bxmask_default_ = value; }; inline const std::vector<std::vector<int> >& prescaleTable() const { return read_->prescale_table_; }; void setPrescaleFactorTable(std::vector<std::vector<int> > value){ check_write(); write_->prescale_table_ = value; }; inline const std::vector<int>& triggerMaskVeto() const { return read_->veto_; }; void setTriggerMaskVeto(std::vector<int> value){ check_write(); write_->veto_ = value; }; inline const std::map<int, std::vector<int> >& triggerAlgoBxMask() const { return read_->bxmask_map_; }; void setTriggerAlgoBxMask(std::map<int, std::vector<int> > value){ check_write(); write_->bxmask_map_ = value; }; // access to underlying pointers, mainly for ESProducer: const L1TGlobalPrescalesVetos * getReadInstance() const {return read_;} L1TGlobalPrescalesVetos * getWriteInstance(){return write_; } private: PrescalesVetosHelper(const L1TGlobalPrescalesVetos * es); void useCopy(); void check_write() { assert(write_); } // separating read from write allows for a high-performance read-only mode (as no copy is made): const L1TGlobalPrescalesVetos * read_; // when reading/getting, use this. L1TGlobalPrescalesVetos * write_; // when writing/setting, use this. bool we_own_write_; }; } #endif
39.905405
121
0.720284
1d23160185fd5f83b95282532f4609e89d60382a
355
h
C
LegacySemanticColors/TOCollectionHeaderView.h
TimOliver/UIColor-LegacySemanticColors
4d292b2f4b2c21e3248f30c2abeedb8a9588c46a
[ "MIT" ]
3
2020-04-25T22:58:38.000Z
2020-08-26T06:27:21.000Z
LegacySemanticColors/TOCollectionHeaderView.h
TimOliver/UIColor-LegacySemanticColors
4d292b2f4b2c21e3248f30c2abeedb8a9588c46a
[ "MIT" ]
null
null
null
LegacySemanticColors/TOCollectionHeaderView.h
TimOliver/UIColor-LegacySemanticColors
4d292b2f4b2c21e3248f30c2abeedb8a9588c46a
[ "MIT" ]
null
null
null
// // TOCollectionHeaderView.h // LegacySemanticColors // // Created by Tim Oliver on 24/4/20. // Copyright © 2020 Tim Oliver. All rights reserved. // #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @interface TOCollectionHeaderView : UICollectionReusableView @property (nonatomic, weak) IBOutlet UILabel *titleLabel; @end NS_ASSUME_NONNULL_END
17.75
60
0.766197
5928466170dbac204c327fe0ec3b7767d58b745d
528
c
C
src/agumon.c
Yavuz7/VulkanProjectGF3D
4ec4570ee1a018b479b4dffab30897621dad5a6d
[ "MIT" ]
null
null
null
src/agumon.c
Yavuz7/VulkanProjectGF3D
4ec4570ee1a018b479b4dffab30897621dad5a6d
[ "MIT" ]
null
null
null
src/agumon.c
Yavuz7/VulkanProjectGF3D
4ec4570ee1a018b479b4dffab30897621dad5a6d
[ "MIT" ]
null
null
null
#include "simple_logger.h" #include "agumon.h" void agumon_think(Entity *self); Entity *agumon_new(Vector3D position) { Entity *ent = NULL; ent = entity_new(); if (!ent) { slog("UGH OHHHH, no agumon for you!"); return NULL; } ent->model = gf3d_model_load_plus("dino","tile1"); ent->think = agumon_think; vector3d_copy(ent->position,position); return ent; } void agumon_think(Entity *self) { if (!self)return; self->rotation.x += -0.002; } /*eol@eof*/
16
54
0.604167
d9f1e27ceb208f084e282ad6e4aa71cdafbaaca4
1,549
c
C
uhk/acm2846 .c
Hyyyyyyyyyy/acm
d7101755b2c2868d51bb056f094e024d0333b56f
[ "MIT" ]
null
null
null
uhk/acm2846 .c
Hyyyyyyyyyy/acm
d7101755b2c2868d51bb056f094e024d0333b56f
[ "MIT" ]
null
null
null
uhk/acm2846 .c
Hyyyyyyyyyy/acm
d7101755b2c2868d51bb056f094e024d0333b56f
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <string.h> struct goods { int sta; int num; int id; struct goods *next[26]; }; void insert(struct goods *root, char *s, int n); int search(struct goods *root, char *s); void del(struct goods *root); int main() { int i, j, n, m, k, u, L, count; char ar[30], sa[30]; struct goods *root; root = (struct goods *)malloc(sizeof(struct goods)); root->sta = 0; root->num = 0; root->id = -1; for (i = 0; i<26; i++) root->next[i] = NULL; scanf("%d", &n); for (m = 0; m < n; m++) { scanf("%s", ar); L = strlen(ar); for(i = 0; i < L; i++) insert(root, &ar[i], m); } scanf("%d", &k); for (u = 0; u < k; u++) { scanf("%s", sa); printf("%d\n", search(root, sa)); } del(root); return 0; } void del(struct goods *root) { int i; for (i = 0; i < 26; i++) if (root->next[i] != NULL) del(root->next[i]); free(root); } void insert(struct goods *root, char *s, int n) { int i; struct goods *p = root, *temp; while (*s != '\0') { if (p->next[*s - 'a'] == NULL) { temp = (struct goods *)malloc(sizeof(struct goods)); temp->sta = 0; temp->num = 1; temp->id = n; for (i = 0; i < 26; i++) temp->next[i] = NULL; p->next[*s - 'a'] = temp; } p = p->next[*s - 'a']; if (p->id != n) { p->num++; p->id = n; } s++; } p->sta = 1; } int search(struct goods *root, char *s) { int i, count = 0; struct goods *p = root; while (*s != '\0' && p != NULL) { p = p->next[*s - 'a']; s++; } if (p != NULL) return p->num; return 0; }
16.655914
55
0.506133
8a788f5333db22679f745082bc543be49521583b
1,658
c
C
src/bl/base/hex_string.c
RafaGago/base_library
3d08c1ccbecc4ab26495999fc6692978b490e40f
[ "BSD-3-Clause" ]
5
2016-08-05T07:25:51.000Z
2021-10-02T22:09:27.000Z
src/bl/base/hex_string.c
RafaGago/base_library
3d08c1ccbecc4ab26495999fc6692978b490e40f
[ "BSD-3-Clause" ]
null
null
null
src/bl/base/hex_string.c
RafaGago/base_library
3d08c1ccbecc4ab26495999fc6692978b490e40f
[ "BSD-3-Clause" ]
null
null
null
#include <bl/base/assert.h> #include <bl/base/hex_string.h> /*---------------------------------------------------------------------------*/ BL_EXPORT bl_word bl_hex_string_to_bytes( bl_u8* bytes, bl_uword bytes_capacity, char const* str ) { bl_word char_count = 0; bl_assert (str && bytes); bl_assert (bytes_capacity > 0); while (*str != '\0') { char c = *str; bl_u8 nibble; if (c >= '0' && c <= '9') { nibble = c - '0'; } else if (c >= 'a' && c <= 'f') { nibble = c - 'a' + 10; } else if (c >= 'A' && c <= 'F') { nibble = c - 'A' + 10; } else { return -1; } ++char_count; ++str; if ((char_count & 1) == 1) { if (char_count > (bl_word) bytes_capacity * 2) { return -1; } *bytes = nibble << 4; } else { *bytes |= nibble; ++bytes; } } return (char_count / 2) + (char_count & 1); } /*---------------------------------------------------------------------------*/ BL_EXPORT bl_word bl_bytes_to_hex_string( char* str, bl_uword str_capacity, bl_u8 const* bytes, bl_uword bytes_size ) { static const bl_u8 hex_lut[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; bl_assert (str && bytes); if ((str_capacity == 0 && bytes_size > 0) || str_capacity - 1 < bytes_size * 2) { return -1; } bl_uword i; for (i = 0; i < bytes_size; ++i, ++bytes, str += 2) { str[0] = hex_lut[*bytes >> 4]; str[1] = hex_lut[*bytes & 15]; } *str = '\0'; return (bl_word) (i * 2); } /*---------------------------------------------------------------------------*/
25.121212
79
0.425814
8dcef6b59e00c02ffdb77a6cea11d0b1ba85c340
121
c
C
01_PassingArrays/sum.c
Planeshifter/emscripten-examples
08ff39d4a2b96ea8cb18603c6086da0ba8ebbb41
[ "MIT" ]
28
2015-03-01T19:21:42.000Z
2021-02-26T07:01:02.000Z
01_PassingArrays/sum.c
Planeshifter/emscripten-examples
08ff39d4a2b96ea8cb18603c6086da0ba8ebbb41
[ "MIT" ]
null
null
null
01_PassingArrays/sum.c
Planeshifter/emscripten-examples
08ff39d4a2b96ea8cb18603c6086da0ba8ebbb41
[ "MIT" ]
3
2017-04-26T18:53:11.000Z
2018-08-16T15:07:42.000Z
int sum(int *arr, int length){ int ret = 0; for (int i = 0; i < length; i++){ ret += arr[i]; } return ret; }
15.125
35
0.495868
ce85a51f51b3beabc35745eb5854fcbaf7947f39
5,367
h
C
src/core/hw/gfxip/gfx9/gfx9PipelineChunkHs.h
crystalJinamd/pal
78939ef3d83b3b18969d0459e8f316d1401fb692
[ "MIT" ]
null
null
null
src/core/hw/gfxip/gfx9/gfx9PipelineChunkHs.h
crystalJinamd/pal
78939ef3d83b3b18969d0459e8f316d1401fb692
[ "MIT" ]
null
null
null
src/core/hw/gfxip/gfx9/gfx9PipelineChunkHs.h
crystalJinamd/pal
78939ef3d83b3b18969d0459e8f316d1401fb692
[ "MIT" ]
null
null
null
/* *********************************************************************************************************************** * * Copyright (c) 2015-2018 Advanced Micro Devices, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * **********************************************************************************************************************/ #pragma once #include "core/hw/gfxip/pipeline.h" #include "core/hw/gfxip/gfx9/gfx9Chip.h" #include "palPipelineAbiProcessor.h" namespace Pal { class Platform; namespace Gfx9 { class CmdStream; class Device; class PrefetchMgr; // Initialization parameters. struct HsParams { gpusize codeGpuVirtAddr; gpusize dataGpuVirtAddr; const PerfDataInfo* pHsPerfDataInfo; Util::MetroHash64* pHasher; }; // ===================================================================================================================== // Represents the chunk of a graphics pipeline object which contains all of the registers which setup the hardware LS // and HS stages. This is sort of a PM4 "image" of the commands which write these registers, but with some intelligence // so that the code used to setup the commands can be reused. // // These register values depend on the API-VS, and the API-HS. class PipelineChunkHs { public: explicit PipelineChunkHs(const Device& device); ~PipelineChunkHs() { } void Init( const AbiProcessor& abiProcessor, const HsParams& params); uint32* WriteShCommands( CmdStream* pCmdStream, uint32* pCmdSpace, const DynamicStageInfo& hsStageInfo) const; uint32* WriteContextCommands( CmdStream* pCmdStream, uint32* pCmdSpace) const; gpusize LsProgramGpuVa() const { return GetOriginalAddress(m_pm4ImageSh.spiShaderPgmLoLs.bits.MEM_BASE, m_pm4ImageSh.spiShaderPgmHiLs.bits.MEM_BASE); } const ShaderStageInfo& StageInfo() const { return m_stageInfo; } private: void BuildPm4Headers(); struct Pm4ImageSh { PM4_ME_SET_SH_REG hdrSpiShaderUserData; regSPI_SHADER_USER_DATA_LS_1 spiShaderUserDataLoHs; PM4_ME_SET_SH_REG hdrSpiShaderPgm; regSPI_SHADER_PGM_RSRC1_HS spiShaderPgmRsrc1Hs; regSPI_SHADER_PGM_RSRC2_HS spiShaderPgmRsrc2Hs; PM4_ME_SET_SH_REG hdrSpiShaderPgmLs; regSPI_SHADER_PGM_LO_LS spiShaderPgmLoLs; regSPI_SHADER_PGM_HI_LS spiShaderPgmHiLs; // Command space needed, in DWORDs. This field must always be last in the structure to not interfere w/ the // actual commands contained within. size_t spaceNeeded; }; // This is only for register writes determined during Pipeline Bind. struct Pm4ImageShDynamic { PM4_ME_SET_SH_REG_INDEX hdrPgmRsrc3Hs; regSPI_SHADER_PGM_RSRC3_HS spiShaderPgmRsrc3Hs; // Command space needed, in DWORDs. This field must always be last in the structure to not interfere w/ the // actual commands contained within. size_t spaceNeeded; }; struct Pm4ImageContext { PM4_PFP_SET_CONTEXT_REG hdrvVgtHosTessLevel; regVGT_HOS_MAX_TESS_LEVEL vgtHosMaxTessLevel; regVGT_HOS_MIN_TESS_LEVEL vgtHosMinTessLevel; // Command space needed, in DWORDs. This field must always be last in the structure to not interfere w/ the // actual commands contained within. size_t spaceNeeded; }; const Device& m_device; Pm4ImageSh m_pm4ImageSh; // HS sh commands to be written when the associated pipeline is bound. Pm4ImageShDynamic m_pm4ImageShDynamic; // HS sh commands to be calculated and written when the associated pipeline // is bound. Pm4ImageContext m_pm4ImageContext; // HS context commands to be written when the associated pipeline is bound. const PerfDataInfo* m_pHsPerfDataInfo; // HS performance data information. ShaderStageInfo m_stageInfo; PAL_DISALLOW_DEFAULT_CTOR(PipelineChunkHs); PAL_DISALLOW_COPY_AND_ASSIGN(PipelineChunkHs); }; } // Gfx9 } // Pal
37.013793
120
0.648407
c03245c25adae5227935d5aa1b2373abdd3d2961
260
h
C
Drupal Create/DGCustomMySitesButton.h
agiza/drupal-create
3acc125b880ba72c72da6fe91362bba8f6c34c27
[ "MIT" ]
9
2015-01-15T21:12:30.000Z
2020-06-15T19:23:08.000Z
Drupal Create/DGCustomMySitesButton.h
agiza/drupal-create
3acc125b880ba72c72da6fe91362bba8f6c34c27
[ "MIT" ]
1
2015-01-11T13:43:40.000Z
2015-07-20T03:21:50.000Z
Drupal Create/DGCustomMySitesButton.h
agiza/drupal-create
3acc125b880ba72c72da6fe91362bba8f6c34c27
[ "MIT" ]
4
2015-01-06T03:16:09.000Z
2021-03-13T16:59:04.000Z
// // DGCustomMySitesButton.h // Drupal Create // // Created by Kyle Browning on 7/18/12. // Copyright (c) 2012 Acquia. All rights reserved. // #import <UIKit/UIKit.h> @interface DGCustomMySitesButton : UIButton - (id)initWithText:(NSString *)text; @end
18.571429
51
0.703846
dbaeeb9e557beb93e6bedf8ad1e2bec6bc97d915
17,452
h
C
Firmware/Inverter_firmware/mfs/source/include/mfs.h
gingazov2010/Indemsys-Frequency_Inverter
58ecce428a9cda0c2694979b16f98862bd3b0c65
[ "MIT" ]
30
2022-01-04T12:10:33.000Z
2022-03-30T09:03:48.000Z
Firmware/Inverter_firmware/mfs/source/include/mfs.h
nelveroi/Frequency_Inverter
db9ab280ef096efce4c367bf71676b2da668031d
[ "MIT" ]
1
2022-01-05T08:44:01.000Z
2022-01-05T08:44:01.000Z
Firmware/Inverter_firmware/mfs/source/include/mfs.h
nelveroi/Frequency_Inverter
db9ab280ef096efce4c367bf71676b2da668031d
[ "MIT" ]
9
2022-01-04T11:44:25.000Z
2022-03-15T04:03:05.000Z
#ifndef __mfs_h__ #define __mfs_h__ /**HEADER******************************************************************** * * Copyright (c) 2008 Freescale Semiconductor; * All Rights Reserved * * Copyright (c) 2004-2008 Embedded Access Inc.; * All Rights Reserved * * Copyright (c) 1989-2008 ARC International; * All Rights Reserved * *************************************************************************** * * THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * ************************************************************************** * * $FileName: mfs.h$ * $Version : 3.8.24.0$ * $Date : Jul-25-2012$ * * Comments: * * This file contains the structure definitions and constants for a * user who will be compiling programs that will use the Embedded MS-DOS * File System (MFS) * *END************************************************************************/ #include <mqx.h> #include <bsp.h> #include "mfs_rev.h" #include "mfs_cnfg.h" #include "ioctl.h" /* ** Defines specific to MFS */ #define MFS_VERSION (0x00030000 | MFS_REVISION) /* search attributes */ #define MFS_SEARCH_NORMAL 0x00 #define MFS_SEARCH_READ_ONLY 0x01 #define MFS_SEARCH_HIDDEN 0x02 #define MFS_SEARCH_SYSTEM 0x04 #define MFS_SEARCH_VOLUME 0x08 #define MFS_SEARCH_SUBDIR 0x10 #define MFS_SEARCH_ARCHIVE 0x20 #define MFS_SEARCH_EXCLUSIVE 0x40 #define MFS_SEARCH_ANY 0x80 /* file open access modes */ #define MFS_ACCESS_READ_ONLY 0x00 #define MFS_ACCESS_WRITE_ONLY 0x01 #define MFS_ACCESS_READ_WRITE 0x02 /* file entry attributes */ #define MFS_ATTR_READ_ONLY 0x01 #define MFS_ATTR_HIDDEN_FILE 0x02 #define MFS_ATTR_SYSTEM_FILE 0x04 #define MFS_ATTR_VOLUME_NAME 0x08 #define MFS_ATTR_DIR_NAME 0x10 #define MFS_ATTR_ARCHIVE 0x20 #define MFS_ATTR_LFN 0x0F /* mask values for the date and time as recorded in the ** file entries */ #define MFS_MASK_DAY 0x001F #define MFS_MASK_MONTH 0x01E0 #define MFS_MASK_YEAR 0xFE00 #define MFS_MASK_SECONDS 0x001F #define MFS_MASK_MINUTES 0x07E0 #define MFS_MASK_HOURS 0xF800 /* ** shift for the above date and time masks */ #define MFS_SHIFT_DAY 0 #define MFS_SHIFT_MONTH 5 #define MFS_SHIFT_YEAR 9 #define MFS_SHIFT_SECONDS 0 #define MFS_SHIFT_MINUTES 5 #define MFS_SHIFT_HOURS 11 /* ** control for the write cache */ #define MFS_WRCACHE_OFF 0 #define MFS_WRCACHE_ON 1 #define MFS_WRCACHE_FLUSH 2 #define MFS_DEFAULT_SECTOR_SIZE 512 /* ** Sector boundries that determine the cluster size, the root dir size ** and the FAT type */ #define SECTOR_BOUND1 2048 /* TYPE: FAT12, Root dir: 7 * 32 root entries, CLUSTER SIZE: 1 sector */ #define SECTOR_BOUND2 4096 /* TYPE: FAT12, Root dir: 14 * 32 root entries, CLUSTER SIZE: 1 sector */ #define SECTOR_BOUND3 8192 /* TYPE: FAT12, Root dir: 32 * 32 root entries, CLUSTER SIZE: 2 sectors */ #define SECTOR_BOUND4 16384 /* TYPE: FAT12, Root dir: 32 * 32 root entries, CLUSTER SIZE: 4 sectors */ #define SECTOR_BOUND5 32768 /* TYPE: FAT12, Root dir: 32 * 32 root entries, CLUSTER SIZE: 2 sectors */ #define SECTOR_BOUND6 524288 /* TYPE: FAT16, Root dir: 32 * 32 root entries, CLUSTER SIZE: 8 sectors */ #define SECTOR_BOUND7 1048576 /* TYPE: FAT16, Root dir: 32 * 32 root entries, CLUSTER SIZE: 16 sectors */ #define SECTOR_BOUND8 16777216 /* TYPE: FAT32, Root dir: 64k entries, CLUSTER SIZE: 8 sectors */ #define SECTOR_BOUND9 33554432 /* TYPE: FAT32, Root dir: 64k entries, CLUSTER SIZE: 16 sectors */ #define SECTOR_BOUND10 67108864 /* TYPE: FAT32, Root dir: 64k entries, CLUSTER SIZE: 32 sectors */ #define SECTOR_BOUND11 2097152 /* TYPE: FAT16, Root dir: 32 * 32 root entries, CLUSTER SIZE: 32 sectors */ #define MFS_FAT12 0x01 #define MFS_FAT16 0x06 #define MFS_FAT32 0x0C /* ** FILENAME LENGTH CONSTANTS */ #define PATHNAME_SIZE 260 #define FILENAME_SIZE 255 #define SFILENAME_SIZE 12 /* ** error codes */ #define MFS_NO_ERROR FS_NO_ERROR #define MFS_INVALID_FUNCTION_CODE FS_INVALID_FUNCTION_CODE #define MFS_FILE_NOT_FOUND FS_FILE_NOT_FOUND #define MFS_PATH_NOT_FOUND FS_PATH_NOT_FOUND #define MFS_ACCESS_DENIED FS_ACCESS_DENIED #define MFS_INVALID_HANDLE FS_INVALID_HANDLE #define MFS_INSUFFICIENT_MEMORY FS_INSUFFICIENT_MEMORY #define MFS_INVALID_MEMORY_BLOCK_ADDRESS FS_INVALID_MEMORY_BLOCK_ADDRESS #define MFS_ATTEMPT_TO_REMOVE_CURRENT_DIR FS_ATTEMPT_TO_REMOVE_CURRENT_DIR #define MFS_DISK_IS_WRITE_PROTECTED FS_DISK_IS_WRITE_PROTECTED #define MFS_BAD_DISK_UNIT FS_BAD_DISK_UNIT #define MFS_INVALID_LENGTH_IN_DISK_OPERATION FS_INVALID_LENGTH_IN_DISK_OPERATION #define MFS_NOT_A_DOS_DISK FS_NOT_A_DOS_DISK #define MFS_SECTOR_NOT_FOUND FS_SECTOR_NOT_FOUND #define MFS_WRITE_FAULT FS_WRITE_FAULT #define MFS_READ_FAULT FS_READ_FAULT #define MFS_SHARING_VIOLATION FS_SHARING_VIOLATION #define MFS_FILE_EXISTS FS_FILE_EXISTS #define MFS_ALREADY_ASSIGNED FS_ALREADY_ASSIGNED #define MFS_INVALID_PARAMETER FS_INVALID_PARAMETER #define MFS_DISK_FULL FS_DISK_FULL #define MFS_ROOT_DIR_FULL FS_ROOT_DIR_FULL #define MFS_EOF FS_EOF #define MFS_CANNOT_CREATE_DIRECTORY FS_CANNOT_CREATE_DIRECTORY #define MFS_NOT_INITIALIZED FS_NOT_INITIALIZED #define MFS_OPERATION_NOT_ALLOWED FS_OPERATION_NOT_ALLOWED #define MFS_ERROR_INVALID_DRIVE_HANDLE FS_ERROR_INVALID_DRIVE_HANDLE #define MFS_ERROR_INVALID_FILE_HANDLE FS_ERROR_INVALID_FILE_HANDLE #define MFS_ERROR_UNKNOWN_FS_VERSION FS_ERROR_UNKNOWN_FS_VERSION #define MFS_LOST_CHAIN FS_LOST_CHAIN #define MFS_INVALID_DEVICE FS_INVALID_DEVICE #define MFS_INVALID_CLUSTER_NUMBER FS_INVALID_CLUSTER_NUMBER #define MFS_FAILED_TO_DELETE_LFN FS_FAILED_TO_DELETE_LFN #define MFS_BAD_LFN_ENTRY FS_BAD_LFN_ENTRY #define PMGR_INVALID_PARTITION FS_PMGR_INVALID_PARTITION #define PMGR_INSUF_MEMORY FS_PMGR_INSUF_MEMORY #define PMGR_UNKNOWN_PARTITION FS_PMGR_UNKNOWN_PARTITION #define PMGR_INVALID_PARTTABLE FS_PMGR_INVALID_PARTTABLE /* ** Extra IO_IOCTL codes */ #define IO_IOCTL_DELETE_FILE _IO(IO_TYPE_MFS,0x02) #define IO_IOCTL_BAD_CLUSTERS _IO(IO_TYPE_MFS,0x03) #define IO_IOCTL_FREE_SPACE _IO(IO_TYPE_MFS,0x04) #define IO_IOCTL_TEST_UNUSED_CLUSTERS _IO(IO_TYPE_MFS,0x05) #define IO_IOCTL_CREATE_SUBDIR _IO(IO_TYPE_MFS,0x06) #define IO_IOCTL_REMOVE_SUBDIR _IO(IO_TYPE_MFS,0x07) #define IO_IOCTL_GET_CURRENT_DIR _IO(IO_TYPE_MFS,0x08) #define IO_IOCTL_CHANGE_CURRENT_DIR _IO(IO_TYPE_MFS,0x09) #define IO_IOCTL_WRITE_CACHE_ON _IO(IO_TYPE_MFS,0x0A) #define IO_IOCTL_WRITE_CACHE_OFF _IO(IO_TYPE_MFS,0x0B) #define IO_IOCTL_FORMAT _IO(IO_TYPE_MFS,0x0C) #define IO_IOCTL_FORMAT_TEST _IO(IO_TYPE_MFS,0x0D) #define IO_IOCTL_FIND_FIRST_FILE _IO(IO_TYPE_MFS,0x0E) #define IO_IOCTL_FIND_NEXT_FILE _IO(IO_TYPE_MFS,0x0F) #define IO_IOCTL_RENAME_FILE _IO(IO_TYPE_MFS,0x10) #define IO_IOCTL_GET_FILE_ATTR _IO(IO_TYPE_MFS,0x11) #define IO_IOCTL_SET_FILE_ATTR _IO(IO_TYPE_MFS,0x12) #define IO_IOCTL_GET_DATE_TIME _IO(IO_TYPE_MFS,0x13) #define IO_IOCTL_SET_DATE_TIME _IO(IO_TYPE_MFS,0x14) #define IO_IOCTL_FLUSH_FAT _IO(IO_TYPE_MFS,0x15) #define IO_IOCTL_FAT_CACHE_ON _IO(IO_TYPE_MFS,0x16) #define IO_IOCTL_FAT_CACHE_OFF _IO(IO_TYPE_MFS,0x17) #define IO_IOCTL_SET_VOLUME _IO(IO_TYPE_MFS,0x18) #define IO_IOCTL_GET_VOLUME _IO(IO_TYPE_MFS,0x19) #define IO_IOCTL_GET_LFN _IO(IO_TYPE_MFS,0x1A) #define IO_IOCTL_FREE_CLUSTERS _IO(IO_TYPE_MFS,0x1B) #define IO_IOCTL_GET_CLUSTER_SIZE _IO(IO_TYPE_MFS,0x1C) #define IO_IOCTL_LAST_CLUSTER _IO(IO_TYPE_MFS,0x20) #define IO_IOCTL_SEL_PART _IO(IO_TYPE_MFS,0x21) #define IO_IOCTL_USE_PARTITION _IO(IO_TYPE_MFS,0x22) #define IO_IOCTL_VAL_PART _IO(IO_TYPE_MFS,0x23) #define IO_IOCTL_SET_PARTITION _IO(IO_TYPE_MFS,0x24) #define IO_IOCTL_GET_PARTITION _IO(IO_TYPE_MFS,0x25) #define IO_IOCTL_CLEAR_PARTITION _IO(IO_TYPE_MFS,0x26) #define IO_IOCTL_GET_DEVICE_HANDLE _IO(IO_TYPE_MFS,0x27) #define IO_IOCTL_GET_FAT_CACHE_MODE _IO(IO_TYPE_MFS,0x28) #define IO_IOCTL_SET_FAT_CACHE_MODE _IO(IO_TYPE_MFS,0x29) #define IO_IOCTL_GET_WRITE_CACHE_MODE _IO(IO_TYPE_MFS,0x30) #define IO_IOCTL_SET_WRITE_CACHE_MODE _IO(IO_TYPE_MFS,0x31) #define IO_IOCTL_DEFAULT_FORMAT _IO(IO_TYPE_MFS,0x32) #define IO_IOCTL_VERIFY_WRITES _IO(IO_TYPE_MFS,0x33) #define IO_IOCTL_CHECK_DIR_EXIST _IO(IO_TYPE_MFS,0x34) /* Following IOCTL codes are obsolete. No device locking is necessary anymore as partition manager may be open multiple times to allow for concurrent access to multiple partitions. #define IO_IOCTL_DEV_LOCK #define IO_IOCTL_DEV_UNLOCK */ #define MFS_MEM_TYPE_BASE ( (IO_MFS_COMPONENT) << (MEM_TYPE_COMPONENT_SHIFT)) #define MEM_TYPE_MFS_DRIVE_STRUCT (MFS_MEM_TYPE_BASE+1) #define MEM_TYPE_MFS_DIR_STRUCT (MFS_MEM_TYPE_BASE+2) #define MEM_TYPE_MFS_DATA_SECTOR (MFS_MEM_TYPE_BASE+3) #define MEM_TYPE_MFS_DIRECTORY_SECTOR (MFS_MEM_TYPE_BASE+4) #define MEM_TYPE_MFS_FAT_BUFFER (MFS_MEM_TYPE_BASE+5) #define MEM_TYPE_MFS_FILESYSTEM_INFO_DISK (MFS_MEM_TYPE_BASE+6) #define MEM_TYPE_MFS_CLUSTER (MFS_MEM_TYPE_BASE+7) #define MEM_TYPE_MFS_PATHNAME (MFS_MEM_TYPE_BASE+8) #define MEM_TYPE_PART_MGR_STRUCT (MFS_MEM_TYPE_BASE+9) #define MEM_TYPE_PART_MGR_SECTOR (MFS_MEM_TYPE_BASE+10) /* ** INDEX_TO_OFFSET converts a directory index to the offset within the right ** sector. */ #define INDEX_TO_OFFSET(x) ((x) & (drive_ptr->ENTRIES_PER_SECTOR-1)) #define PACK_TIME(x) ((x.HOUR << MFS_SHIFT_HOURS) |\ (x.MINUTE << MFS_SHIFT_MINUTES) |\ (clk_time.SECOND >>1)) #define PACK_DATE(x) (((x.YEAR -1980)<< MFS_SHIFT_YEAR) |\ (x.MONTH << MFS_SHIFT_MONTH) |\ (x.DAY << MFS_SHIFT_DAY)) #define CAPITALIZE(c) (c&((c>='a'&&c<='z')?(~0x20):~0)) /* ** Data Structures specific to MFS */ typedef uint_32 _mfs_error; typedef uint_32_ptr _mfs_error_ptr; typedef enum { MFS_WRITE_THROUGH_CACHE=0, // No write caching (only read caching) MFS_MIXED_MODE_CACHE=1, // Write Caching allowed on file write only MFS_WRITE_BACK_CACHE=2 // Write Caching fully enabled } _mfs_cache_policy; /* ** Information required for high-level format */ typedef struct mfs_format_data { uchar PHYSICAL_DRIVE; uchar MEDIA_DESCRIPTOR; uint_16 BYTES_PER_SECTOR; uint_16 SECTORS_PER_TRACK; uint_16 NUMBER_OF_HEADS; uint_32 NUMBER_OF_SECTORS; uint_32 HIDDEN_SECTORS; uint_16 RESERVED_SECTORS; } MFS_FORMAT_DATA, _PTR_ MFS_FORMAT_DATA_PTR; /* ** Format information for ioctl calls involving format operations */ typedef struct mfs_ioctl_format { MFS_FORMAT_DATA_PTR FORMAT_PTR; uint_32_ptr COUNT_PTR; /* To count the bad clusters */ } MFS_IOCTL_FORMAT_PARAM, _PTR_ MFS_IOCTL_FORMAT_PARAM_PTR; typedef struct mfs_internal_search { char_ptr FULLNAME; // 0..3 char_ptr SRC_PTR; // 4..7 char FILENAME[8]; // 8..15 char EXTENSION[3]; // 16..18 char ATTRIBUTE; // 19 uint_32 CURRENT_CLUSTER; // 20..23 uint_32 DIR_ENTRY_INDEX; // 24..27 uint_32 PREV_CLUSTER; // 28..31 } MFS_INTERNAL_SEARCH, _PTR_ MFS_INTERNAL_SEARCH_PTR; /* ** search data block, used for Find_first and Find_next */ typedef struct mfs_search_data { pointer DRIVE_PTR; MFS_INTERNAL_SEARCH INTERNAL_SEARCH_DATA; uchar ATTRIBUTE; char _UNUSED[3]; uint_16 TIME; uint_16 DATE; uint_16 RESERVED2; uint_32 FILE_SIZE; char NAME[13]; } MFS_SEARCH_DATA, _PTR_ MFS_SEARCH_DATA_PTR; /* ** Search information for ioctl find file first search calls */ typedef struct mfs_search_param { uchar ATTRIBUTE; uchar RESERVED[3]; char_ptr WILDCARD; MFS_SEARCH_DATA_PTR SEARCH_DATA_PTR; } MFS_SEARCH_PARAM, _PTR_ MFS_SEARCH_PARAM_PTR; /* ** Pathname information for the rename_file ioctl call */ typedef struct mfs_rename_param { char_ptr OLD_PATHNAME; char_ptr NEW_PATHNAME; } MFS_RENAME_PARAM, _PTR_ MFS_RENAME_PARAM_PTR; /* ** Paramater information for get and set file attribute ioctl calls */ typedef struct mfs_file_attr_param { char_ptr PATHNAME; uchar_ptr ATTRIBUTE_PTR; } MFS_FILE_ATTR_PARAM, _PTR_ MFS_FILE_ATTR_PARAM_PTR; typedef struct mfs_get_lfn_struct { char_ptr PATHNAME; char_ptr LONG_FILENAME; MFS_SEARCH_DATA_PTR SEARCH_DATA_PTR; } MFS_GET_LFN_STRUCT, _PTR_ MFS_GET_LFN_STRUCT_PTR; /* ** Parameter information for get/set date time ioctl calls */ typedef struct mfs_date_time_param { uint_16_ptr DATE_PTR; uint_16_ptr TIME_PTR; } MFS_DATE_TIME_PARAM, _PTR_ MFS_DATE_TIME_PARAM_PTR; /* ** Data Structures specific to MFS */ /* structure of entries in the file system directory */ typedef struct mfs_dir_entry { char NAME[8]; char TYPE[3]; uchar ATTRIBUTE[1]; char RESERVED[8]; uchar HFIRST_CLUSTER[2]; uchar TIME[2]; uchar DATE[2]; uchar LFIRST_CLUSTER[2]; uchar FILE_SIZE[4]; } MFS_DIR_ENTRY, _PTR_ MFS_DIR_ENTRY_PTR; /* ** file handle as defined by MFS */ typedef struct mfs_handle { QUEUE_ELEMENT_STRUCT HEADER_PTR; uint_32 VALID; MFS_DIR_ENTRY DIR_ENTRY; uint_16 ACCESS; uint_16 TOUCHED; uint_32 CURRENT_CLUSTER; uint_32 PREVIOUS_CLUSTER; uint_32 SAVED_POSITION; uint_32 DIR_CLUSTER; uint_32 DIR_INDEX; } MFS_HANDLE, _PTR_ MFS_HANDLE_PTR; /* ** extern statements for MFS */ extern _mem_pool_id _MFS_pool_id; extern uint_32 _MFS_handle_pool_init; extern uint_32 _MFS_handle_pool_grow; extern uint_32 _MFS_handle_pool_max; #ifdef __cplusplus extern "C" { #endif extern uint_32 _io_mfs_install(MQX_FILE_PTR dev_fd,char_ptr identifier, uint_32 part_num); extern uint_32 _io_mfs_uninstall(char_ptr identifier); extern int_32 _io_mfs_open(MQX_FILE_PTR fd_ptr,char_ptr, char_ptr flags_str); extern int_32 _io_mfs_close(MQX_FILE_PTR fd_ptr); extern int_32 _io_mfs_read(MQX_FILE_PTR file_ptr,char_ptr data_ptr,int_32 num); extern int_32 _io_mfs_write(MQX_FILE_PTR file_ptr,char_ptr data_ptr,int_32 num); extern int_32 _io_mfs_ioctl(MQX_FILE_PTR file_ptr,uint_32 cmd,uint_32_ptr param_ptr); extern pointer _io_mfs_dir_open(MQX_FILE_PTR fs_ptr, char_ptr wildcard_ptr, char_ptr mode_ptr); extern int_32 _io_mfs_dir_read(pointer dir, char_ptr buffer, uint_32 size); extern int_32 _io_mfs_dir_close(pointer dir); extern boolean MFS_is_autogenerated_name(char_ptr s_fname); extern char_ptr MFS_Error_text(uint_32 error_code); extern pointer MFS_mem_alloc(_mem_size size); extern pointer MFS_mem_alloc_zero(_mem_size size); extern pointer MFS_mem_alloc_system(_mem_size size); extern pointer MFS_mem_alloc_system_zero(_mem_size size); extern _mfs_error MFS_alloc_path(char_ptr * path_ptr_ptr); extern _mfs_error MFS_alloc_2paths(char_ptr * path1_ptr_ptr,char_ptr * path2_ptr_ptr); extern boolean MFS_free_path(char_ptr path_ptr); #ifdef __cplusplus } #endif #if (MFSCFG_NUM_OF_FATS == 0) #error "Illegal number of FATS" #endif #endif /* EOF */
38.696231
141
0.684334
0d581078e0b6802688f0a263f4a49fe0ecea6895
445
h
C
include/person.h
RicardoPetronilho98/data-structs
66f78aab373906a138c4dbd7f5f3d56c88e246c9
[ "Unlicense" ]
1
2019-03-06T11:27:56.000Z
2019-03-06T11:27:56.000Z
include/person.h
RicardoPetronilho98/data-structs
66f78aab373906a138c4dbd7f5f3d56c88e246c9
[ "Unlicense" ]
null
null
null
include/person.h
RicardoPetronilho98/data-structs
66f78aab373906a138c4dbd7f5f3d56c88e246c9
[ "Unlicense" ]
null
null
null
#ifndef PERSON_H #define PERSON_H typedef struct TCD_PERSON* TAD_PERSON; // CONSTRUTOR TAD_PERSON PERSON(int id, char* name, int age); // GETTERS int getId(TAD_PERSON p); char* getName(TAD_PERSON p); int getAge(TAD_PERSON p); // SETTERS void setId(TAD_PERSON p, int id); void setName(TAD_PERSON p, char* name); void setAge(TAD_PERSON p, int age); // FREE void freePERSON(TAD_PERSON p); // toString() void printPERSON(TAD_PERSON p); #endif
17.8
47
0.74382
b4c986d9b02d9d79e0ed7b59a63b500a92f5769d
8,867
c
C
11-dec/72.c/main.c
kasiriveni/c-examples
79f1c302d8069e17dae342739420602bb58315f8
[ "MIT" ]
4
2017-12-10T02:56:28.000Z
2021-06-03T03:38:19.000Z
11-dec/72.c/main.c
kasiriveni/c-examples
79f1c302d8069e17dae342739420602bb58315f8
[ "MIT" ]
null
null
null
11-dec/72.c/main.c
kasiriveni/c-examples
79f1c302d8069e17dae342739420602bb58315f8
[ "MIT" ]
null
null
null
/* * C Program to Implement Circular Doubly Linked List */ #include <stdio.h> #include <stdlib.h> struct node { int val; struct node *next; struct node *prev; }; typedef struct node n; n* create_node(int); void add_node(); void insert_at_first(); void insert_at_end(); void insert_at_position(); void delete_node_position(); void sort_list(); void update(); void search(); void display_from_beg(); void display_in_rev(); n *new, *ptr, *prev; n *first = NULL, *last = NULL; int number = 0; void main() { int ch; printf("\n linked list\n"); printf("1.insert at beginning \n 2.insert at end\n 3.insert at position\n4.sort linked list\n 5.delete node at position\n 6.updatenodevalue\n7.search element \n8.displaylist from beginning\n9.display list from end\n10.exit "); while (1) { printf("\n enter your choice:"); scanf("%d", &ch); switch (ch) { case 1 : insert_at_first(); break; case 2 : insert_at_end(); break; case 3 : insert_at_position(); break; case 4 : sort_list(); break; case 5 : delete_node_position(); break; case 6 : update(); break; case 7 : search(); break; case 8 : display_from_beg(); break; case 9 : display_in_rev(); break; case 10 : exit(0); case 11 : add_node(); break; default: printf("\ninvalid choice"); } } } /* *MEMORY ALLOCATED FOR NODE DYNAMICALLY */ n* create_node(int info) { number++; new = (n *)malloc(sizeof(n)); new->val = info; new->next = NULL; new->prev = NULL; return new; } /* *ADDS NEW NODE */ void add_node() { int info; printf("\nenter the value you would like to add:"); scanf("%d", &info); new = create_node(info); if (first == last && first == NULL) { first = last = new; first->next = last->next = NULL; first->prev = last->prev = NULL; } else { last->next = new; new->prev = last; last = new; last->next = first; first->prev = last; } } /* *INSERTS ELEMENT AT FIRST */ void insert_at_first() { int info; printf("\nenter the value to be inserted at first:"); scanf("%d",&info); new = create_node(info); if (first == last && first == NULL) { printf("\ninitially it is empty linked list later insertion is done"); first = last = new; first->next = last->next = NULL; first->prev = last->prev = NULL; } else { new->next = first; first->prev = new; first = new; first->prev = last; last->next = first; printf("\n the value is inserted at begining"); } } /* *INSERTS ELEMNET AT END */ void insert_at_end() { int info; printf("\nenter the value that has to be inserted at last:"); scanf("%d", &info); new = create_node(info); if (first == last && first == NULL) { printf("\ninitially the list is empty and now new node is inserted but at first"); first = last = new; first->next = last->next = NULL; first->prev = last->prev = NULL; } else { last->next = new; new->prev = last; last = new; first->prev = last; last->next = first; } } /* *INSERTS THE ELEMENT AT GIVEN POSITION */ void insert_at_position() { int info, pos, len = 0, i; n *prevnode; printf("\n enter the value that you would like to insert:"); scanf("%d", &info); printf("\n enter the position where you have to enter:"); scanf("%d", &pos); new = create_node(info); if (first == last && first == NULL) { if (pos == 1) { first = last = new; first->next = last->next = NULL; first->prev = last->prev = NULL; } else printf("\n empty linked list you cant insert at that particular position"); } else { if (number < pos) printf("\n node cant be inserted as position is exceeding the linkedlist length"); else { for (ptr = first, i = 1;i <= number;i++) { prevnode = ptr; ptr = ptr->next; if (i == pos-1) { prevnode->next = new; new->prev = prevnode; new->next = ptr; ptr->prev = new; printf("\ninserted at position %d succesfully", pos); break; } } } } } /* *SORTING IS DONE OF ONLY NUMBERS NOT LINKS */ void sort_list() { n *temp; int tempval, i, j; if (first == last && first == NULL) printf("\nlinked list is empty no elements to sort"); else { for (ptr = first,i = 0;i < number;ptr = ptr->next,i++) { for (temp = ptr->next,j=i;j<number;j++) { if (ptr->val > temp->val) { tempval = ptr->val; ptr->val = temp->val; temp->val = tempval; } } } for (ptr = first, i = 0;i < number;ptr = ptr->next,i++) printf("\n%d", ptr->val); } } /* *DELETION IS DONE */ void delete_node_position() { int pos, count = 0, i; n *temp, *prevnode; printf("\n enter the position which u wanted to delete:"); scanf("%d", &pos); if (first == last && first == NULL) printf("\n empty linked list you cant delete"); else { if (number < pos) printf("\n node cant be deleted at position as it is exceeding the linkedlist length"); else { for (ptr = first,i = 1;i <= number;i++) { prevnode = ptr; ptr = ptr->next; if (pos == 1) { number--; last->next = prevnode->next; ptr->prev = prevnode->prev; first = ptr; printf("%d is deleted", prevnode->val); free(prevnode); break; } else if (i == pos - 1) { number--; prevnode->next = ptr->next; ptr->next->prev = prevnode; printf("%d is deleted", ptr->val); free(ptr); break; } } } } } /* *UPDATION IS DONE FRO GIVEN OLD VAL */ void update() { int oldval, newval, i, f = 0; printf("\n enter the value old value:"); scanf("%d", &oldval); printf("\n enter the value new value:"); scanf("%d", &newval); if (first == last && first == NULL) printf("\n list is empty no elemnts for updation"); else { for (ptr = first, i = 0;i < number;ptr = ptr->next,i++) { if (ptr->val == oldval) { ptr->val = newval; printf("value is updated to %d", ptr->val); f = 1; } } if (f == 0) printf("\n no such old value to be get updated"); } } /* *SEARCHING USING SINGLE KEY */ void search() { int count = 0, key, i, f = 0; printf("\nenter the value to be searched:"); scanf("%d", &key); if (first == last && first == NULL) printf("\nlist is empty no elemnets in list to search"); else { for (ptr = first,i = 0;i < number;i++,ptr = ptr->next) { count++; if (ptr->val == key) { printf("\n the value is found at position at %d", count); f = 1; } } if (f == 0) printf("\n the value is not found in linkedlist"); } } /* *DISPLAYING IN BEGINNING */ void display_from_beg() { int i; if (first == last && first == NULL) printf("\nlist is empty no elemnts to print"); else { printf("\n%d number of nodes are there", number); for (ptr = first, i = 0;i < number;i++,ptr = ptr->next) printf("\n %d", ptr->val); } } /* * DISPLAYING IN REVERSE */ void display_in_rev() { int i; if (first == last && first == NULL) printf("\nlist is empty there are no elments"); else { for (ptr = last, i = 0;i < number;i++,ptr = ptr->prev) { printf("\n%d", ptr->val); } } }
22.794344
230
0.467802
89082ba89c1f20de56eb69b59a346f0d8c8e75bb
16,371
h
C
iPhoneOS13.7.sdk/System/Library/Frameworks/HealthKit.framework/Headers/HKQuery.h
bakedpotato191/sdks
7b5c8c299a8afcb6d68b356668b4949a946734d9
[ "MIT" ]
10
2019-04-09T19:28:16.000Z
2021-08-11T19:23:00.000Z
iPhoneOS13.7.sdk/System/Library/Frameworks/HealthKit.framework/Headers/HKQuery.h
bakedpotato191/sdks
7b5c8c299a8afcb6d68b356668b4949a946734d9
[ "MIT" ]
null
null
null
iPhoneOS13.7.sdk/System/Library/Frameworks/HealthKit.framework/Headers/HKQuery.h
bakedpotato191/sdks
7b5c8c299a8afcb6d68b356668b4949a946734d9
[ "MIT" ]
4
2020-06-08T04:40:28.000Z
2021-04-06T13:39:20.000Z
// // HKQuery.h // HealthKit // // Copyright (c) 2013-2014 Apple Inc. All rights reserved. // #import <Foundation/Foundation.h> #import <HealthKit/HKDefines.h> #import <HealthKit/HKFHIRResource.h> #import <HealthKit/HKWorkout.h> NS_ASSUME_NONNULL_BEGIN @class HKObjectType; @class HKQuantity; @class HKSampleType; @class HKSource; HK_EXTERN API_AVAILABLE(ios(8.0), watchos(2.0)) @interface HKQuery : NSObject @property (readonly, strong, nullable) HKObjectType *objectType API_AVAILABLE(ios(9.3), watchos(2.2)); @property (readonly, strong, nullable) HKSampleType *sampleType API_DEPRECATED_WITH_REPLACEMENT("objectType", ios(8.0, 9.3), watchos(2.0, 2.2)); @property (readonly, strong, nullable) NSPredicate *predicate; - (instancetype)init NS_UNAVAILABLE; @end /** @enum HKQueryOptions @abstract Time interval options are used to describe how an HKSample's time period overlaps with a given time period. @constant HKQueryOptionNone The sample's time period must overlap with the predicate's time period. @constant HKQueryOptionStrictStartDate The sample's start date must fall in the time period (>= startDate, < endDate) @constant HKQueryOptionStrictEndDate The sample's end date must fall in the time period (>= startDate, < endDate) */ typedef NS_OPTIONS(NSUInteger, HKQueryOptions) { HKQueryOptionNone = 0, HKQueryOptionStrictStartDate = 1 << 0, HKQueryOptionStrictEndDate = 1 << 1, } API_AVAILABLE(ios(8.0), watchos(2.0)); @interface HKQuery (HKObjectPredicates) /*! @method predicateForObjectsWithMetadataKey: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches objects with metadata that contains a given key. @param key The metadata key. */ + (NSPredicate *)predicateForObjectsWithMetadataKey:(NSString *)key; /*! @method predicateForObjectsWithMetadataKey:allowedValues: @abstract Creates a predicate for use with HKQuery subclasses @discussion Creates a query predicate that matches objects with metadata containing a value the matches one of the given values for the given key. @param key The metadata key. @param allowedValues The list of values that the metadata value can be equal to. */ + (NSPredicate *)predicateForObjectsWithMetadataKey:(NSString *)key allowedValues:(NSArray *)allowedValues; /*! @method predicateForObjectsWithMetadataKey:operatorType:value: @abstract Creates a predicate for use with HKQuery subclasses @discussion Creates a query predicate that matches objects with a value for a given metadata key matches the given operator type and value. @param key The metadata key. @param operatorType The comparison operator type for the expression. @param value The value to be compared against. */ + (NSPredicate *)predicateForObjectsWithMetadataKey:(NSString *)key operatorType:(NSPredicateOperatorType)operatorType value:(id)value; /*! @method predicateForObjectsFromSource: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches objects saved by a given source. @param source The source. */ + (NSPredicate *)predicateForObjectsFromSource:(HKSource *)source; /*! @method predicateForObjectsFromSources: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches objects saved by any of the given sources. @param sources The list of sources. */ + (NSPredicate *)predicateForObjectsFromSources:(NSSet<HKSource *> *)sources; /*! @method predicateForObjectsFromSourceRevisions: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches objects saved by any of the specified HKSourceRevisions. @param sourceRevisions The list of source revisions. */ + (NSPredicate *)predicateForObjectsFromSourceRevisions:(NSSet<HKSourceRevision *> *)sourceRevisions API_AVAILABLE(ios(9.0), watchos(2.0)); /*! @method predicateForObjectsFromDevices: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches objects associated with any of the given devices. All properties of each HKDevice are considered in the query and must match exactly, including nil values. To perform searches based on specific device properties, use predicateForObjectsWithDeviceProperty:allowedValues:. @param devices The set of devices that generated data. */ + (NSPredicate *)predicateForObjectsFromDevices:(NSSet<HKDevice *> *)devices API_AVAILABLE(ios(9.0), watchos(2.0)); /*! @method predicateForObjectsWithDeviceProperty:allowedValues: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches objects associated with an HKDevice with the specified device property matching any value included in allowedValues. To query for samples with devices that match all the properties of an HKDevice, use predicateForObjectsFromDevices. @param key The device property key. (See HKDevice.h) @param allowedValues The set of values for which the device property can match. An empty set will match all devices whose property value is nil. */ + (NSPredicate *)predicateForObjectsWithDeviceProperty:(NSString *)key allowedValues:(NSSet<NSString *> *)allowedValues API_AVAILABLE(ios(9.0), watchos(2.0)); /*! @method predicateForObjectWithUUID: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches the object saved with a particular UUID. @param UUID The UUID of the object. */ + (NSPredicate *)predicateForObjectWithUUID:(NSUUID *)UUID; /*! @method predicateForObjectsWithUUIDs: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches the objects saved with one of the given UUIDs. @param UUIDs The set of NSUUIDs. */ + (NSPredicate *)predicateForObjectsWithUUIDs:(NSSet<NSUUID *> *)UUIDs; /*! @method predicateForObjectsNoCorrelation @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches the objects that are not associated with an HKCorrelation. */ + (NSPredicate *)predicateForObjectsWithNoCorrelation; /*! @method predicateForObjectsFromWorkout: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches the objects that have been added to the given workout. @param workout The HKWorkout that the object was added to. */ + (NSPredicate *)predicateForObjectsFromWorkout:(HKWorkout *)workout; @end @interface HKQuery (HKSamplePredicates) /*! @method predicateForSamplesWithStartDate:endDate:options: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches samples with a startDate and an endDate that lie inside of a given time interval. @param startDate The start date of the predicate's time interval. @param endDate The end date of the predicate's time interval. @param options The rules for how a sample's time interval overlaps with the predicate's time interval. */ + (NSPredicate *)predicateForSamplesWithStartDate:(nullable NSDate *)startDate endDate:(nullable NSDate *)endDate options:(HKQueryOptions)options; @end @interface HKQuery (HKQuantitySamplePredicates) /*! @method predicateForQuantitySamplesWithOperatorType:quantity: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches quantity samples with values that match the expression formed by the given operator and quantity. @param operatorType The operator type for the expression. @param quantity The quantity that the sample's quantity is being compared to. It is the right hand side of the expression. */ + (NSPredicate *)predicateForQuantitySamplesWithOperatorType:(NSPredicateOperatorType)operatorType quantity:(HKQuantity *)quantity; @end @interface HKQuery (HKCategorySamplePredicates) /*! @method predicateForCategorySamplesWithOperatorType:value: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches category samples with values that match the expression formed by the given operator and value. @param operatorType The operator type for the expression. @param value The value that the sample's value is being compared to. It is the right hand side of the expression. */ + (NSPredicate *)predicateForCategorySamplesWithOperatorType:(NSPredicateOperatorType)operatorType value:(NSInteger)value; @end @interface HKQuery (HKWorkoutPredicates) /*! @method predicateForWorkoutsWithWorkoutActivityType: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches HKWorkouts with the given HKWorkoutActivityType. @param workoutActivityType The HKWorkoutActivity type of the workout */ + (NSPredicate *)predicateForWorkoutsWithWorkoutActivityType:(HKWorkoutActivityType)workoutActivityType; /*! @method predicateForWorkoutsWithOperatorType:duration: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches HKWorkouts by the given operator type and duration @param operatorType The operator type for the expression. @param duration The value that the workout's duration is being compared to. It is the right hand side of the expression. */ + (NSPredicate *)predicateForWorkoutsWithOperatorType:(NSPredicateOperatorType)operatorType duration:(NSTimeInterval)duration; /*! @method predicateForWorkoutsWithOperatorType:totalEnergyBurned: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches HKWorkouts by the given operator type and totalEnergyBurned @param operatorType The operator type for the expression. @param totalEnergyBurned The value that the workout's totalEnergyBurned is being compared to. It is the right hand side of the expression. The unit for this value should be of type Energy. */ + (NSPredicate *)predicateForWorkoutsWithOperatorType:(NSPredicateOperatorType)operatorType totalEnergyBurned:(HKQuantity *)totalEnergyBurned; /*! @method predicateForWorkoutsWithOperatorType:totalDistance: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches HKWorkouts by the given operator type and totalEnergyBurned @param operatorType The operator type for the expression. @param totalDistance The value that the workout's totalEnergyBurned is being compared to. It is the right hand side of the expression. The unit for this value should be of type Distance. */ + (NSPredicate *)predicateForWorkoutsWithOperatorType:(NSPredicateOperatorType)operatorType totalDistance:(HKQuantity *)totalDistance; /*! @method predicateForWorkoutsWithOperatorType:totalSwimmingStrokeCount: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches HKWorkouts by the given operator type and totalSwimmingStrokeCount @param operatorType The operator type for the expression. @param totalSwimmingStrokeCount The value that the workout's totalSwimmingStrokeCount is being compared to. It is the right hand side of the expression. The unit for this value should be of type Count. */ + (NSPredicate *)predicateForWorkoutsWithOperatorType:(NSPredicateOperatorType)operatorType totalSwimmingStrokeCount:(HKQuantity *)totalSwimmingStrokeCount; /*! @method predicateForWorkoutsWithOperatorType:totalFlightsClimbed: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches HKWorkouts by the given operator type and totalFlightsClimbed @param operatorType The operator type for the expression. @param totalFlightsClimbed The value that the workout's totalFlightsClimbed is being compared to. It is the right hand side of the expression. The unit for this value should be of type Count. */ + (NSPredicate *)predicateForWorkoutsWithOperatorType:(NSPredicateOperatorType)operatorType totalFlightsClimbed:(HKQuantity *)totalFlightsClimbed API_AVAILABLE(ios(11.0), watchos(4.0)); @end @interface HKQuery (HKActivitySummaryPredicates) /*! @method predicateForActivitySummaryWithDateComponents: @abstract Creates a predicate for use with HKActivitySummaryQuery @discussion Creates a query predicate that matches HKActivitySummaries with the given date components. @param dateComponents The date components of the activity summary. These date components should contain era, year, month, and day components in the gregorian calendar. */ + (NSPredicate *)predicateForActivitySummaryWithDateComponents:(NSDateComponents *)dateComponents API_AVAILABLE(ios(9.3), watchos(2.2)); /*! @method predicateForActivitySummariesBetweenStartDateComponents:endDateComponents: @abstract Creates a predicate for use with HKActivitySummaryQuery @discussion Creates a query predicate that matches HKActivitySummaries that fall between the given date components. @param startDateComponents The date components that define the beginning of the range. These date components should contain era, year, month, and day components in the gregorian calendar. @param endDateComponents The date components that define the end of the range. These date components should contain era, year, month, and day components in the gregorian calendar. */ + (NSPredicate *)predicateForActivitySummariesBetweenStartDateComponents:(NSDateComponents *)startDateComponents endDateComponents:(NSDateComponents *)endDateComponents API_AVAILABLE(ios(9.3), watchos(2.2)); @end @interface HKQuery (HKClinicalRecordPredicates) /*! @method predicateForClinicalRecordsWithFHIRResourceType: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches HKClinicalRecords with a specific FHIR resource type. @param resourceType The FHIR resource type. */ + (NSPredicate *)predicateForClinicalRecordsWithFHIRResourceType:(HKFHIRResourceType)resourceType API_AVAILABLE(ios(12.0)) API_UNAVAILABLE(watchos); /*! @method predicateForClinicalRecordsFromSource:withFHIRResourceType:identifier: @abstract Creates a predicate for use with HKQuery subclasses. @discussion Creates a query predicate that matches HKClinicalRecords for a given source, FHIR resource type, and FHIR identifier. @param source The source. @param resourceType The FHIR resource type. @param identifier The FHIR identifier. */ + (NSPredicate *)predicateForClinicalRecordsFromSource:(HKSource *)source FHIRResourceType:(HKFHIRResourceType)resourceType identifier:(NSString *)identifier API_AVAILABLE(ios(12.0)) API_UNAVAILABLE(watchos); @end NS_ASSUME_NONNULL_END
47.868421
207
0.730682
53d76c489553f516c9e5293491ac30e10ad85898
3,940
c
C
sources/libs/cc/trans/type.c
StallmanTerminator/brutal
f854a9c109625468d9dc9ef1c4028c36768c605e
[ "MIT" ]
null
null
null
sources/libs/cc/trans/type.c
StallmanTerminator/brutal
f854a9c109625468d9dc9ef1c4028c36768c605e
[ "MIT" ]
null
null
null
sources/libs/cc/trans/type.c
StallmanTerminator/brutal
f854a9c109625468d9dc9ef1c4028c36768c605e
[ "MIT" ]
null
null
null
#include <cc/trans.h> static void cc_trans_member(Emit *emit, CTypeMember type) { cc_trans_type_start(emit, type.type); emit_fmt(emit, " {}", type.name); cc_trans_type_end(emit, type.type); } static void cc_trans_constant(Emit *emit, CTypeConstant member) { emit_fmt(emit, "{}", member.name); if (member.value.type != CVAL_INVALID) { emit_fmt(emit, " = "); cc_trans_value(emit, member.value); } } static void cc_trans_type_attr(Emit *emit, CTypeAttr attr) { if (attr & CTYPE_CONST) { emit_fmt(emit, " const"); } if (attr & CTYPE_RESTRICT) { emit_fmt(emit, " restrict"); } if (attr & CTYPE_VOLATILE) { emit_fmt(emit, " volatile"); } } void cc_trans_type(Emit *emit, CType type) { cc_trans_type_start(emit, type); cc_trans_type_end(emit, type); } void cc_trans_type_start(Emit *emit, CType type) { if (type.type == CTYPE_NAME) { emit_fmt(emit, type.name); cc_trans_type_attr(emit, type.attr); } else if (type.type == CTYPE_PTR) { cc_trans_type_start(emit, *type.ptr_.subtype); emit_fmt(emit, "*"); cc_trans_type_attr(emit, type.attr); } else if (type.type == CTYPE_PARENT) { cc_trans_type_start(emit, *type.ptr_.subtype); emit_fmt(emit, "("); } else if (type.type == CTYPE_FUNC) { cc_trans_type(emit, *type.func_.ret); // return } else if ((type.type == CTYPE_STRUCT || type.type == CTYPE_UNION) && type.struct_.members.len != 0) { if (type.type == CTYPE_STRUCT) { emit_fmt(emit, "struct"); } else { emit_fmt(emit, "union"); } if (str_any(type.name)) { emit_fmt(emit, " {}", type.name); } cc_trans_type_attr(emit, type.attr); emit_fmt(emit, "\n{{\n"); emit_ident(emit); vec_foreach_v(v, &type.struct_.members) { cc_trans_member(emit, v); emit_fmt(emit, ";\n"); } emit_deident(emit); emit_fmt(emit, "}}"); } else if (type.type == CTYPE_ENUM) { emit_fmt(emit, "enum", type.name); if (str_any(type.name)) { emit_fmt(emit, " {}", type.name); } emit_fmt(emit, "\n{{\n"); emit_ident(emit); vec_foreach_v(v, &type.enum_.constants) { cc_trans_constant(emit, v); emit_fmt(emit, ",\n"); } emit_deident(emit); emit_fmt(emit, "}}"); cc_trans_type_attr(emit, type.attr); } else if (type.type == CTYPE_ARRAY) { cc_trans_type_attr(emit, type.attr); cc_trans_type_start(emit, *type.array_.subtype); } else { emit_fmt(emit, ctype_to_str(type.type)); } } void cc_trans_func_params(Emit *emit, CType type) { emit_fmt(emit, "("); bool first = true; vec_foreach_v(v, &type.func_.params) { if (!first) { emit_fmt(emit, ", "); } first = false; cc_trans_member(emit, v); } emit_fmt(emit, ")"); } void cc_trans_type_end(Emit *emit, CType type) { if (type.type == CTYPE_PTR) { cc_trans_type_end(emit, *type.ptr_.subtype); } else if (type.type == CTYPE_PARENT) { emit_fmt(emit, ")"); cc_trans_type_end(emit, *type.ptr_.subtype); } else if (type.type == CTYPE_FUNC) { cc_trans_func_params(emit, type); cc_trans_type_attr(emit, type.attr); } else if (type.type == CTYPE_ARRAY) { if (type.array_.size == CTYPE_ARRAY_UNBOUNDED) { emit_fmt(emit, "[]", type.array_.size); } else { emit_fmt(emit, "[{}]", type.array_.size); } cc_trans_type_end(emit, *type.ptr_.subtype); } }
22.259887
71
0.540609
acb6e60afc6acd52f56983469815bbc1aa30d934
1,395
c
C
Engine/extlibs/IosLibs/mono-2.6.7/mcs/tools/cilc/demo.c
zlxy/Genesis-3D
44bbe50b00118c9fee60e4e3b414371411411317
[ "MIT" ]
null
null
null
Engine/extlibs/IosLibs/mono-2.6.7/mcs/tools/cilc/demo.c
zlxy/Genesis-3D
44bbe50b00118c9fee60e4e3b414371411411317
[ "MIT" ]
null
null
null
Engine/extlibs/IosLibs/mono-2.6.7/mcs/tools/cilc/demo.c
zlxy/Genesis-3D
44bbe50b00118c9fee60e4e3b414371411411317
[ "MIT" ]
1
2018-09-30T23:46:57.000Z
2018-09-30T23:46:57.000Z
#include <glib.h> #include <glib/gprintf.h> #include "demo.h" int main () { DemoTest *my_test; const gchar *mystr; int num; gdouble num_dbl; DemoDrink drink; //GEnumClass *enum_class; //run a static method demo_test_static_method (); //create an object instance my_test = demo_test_new (); //run an instance method demo_test_increment (my_test); //run an instance method with arguments demo_test_add_number (my_test, 2); //run an instance method with arguments demo_test_echo (my_test, "hello from c"); //run an instance method with arguments and a return string mystr = demo_test_make_upper (my_test, "lower to upper"); g_printf ("Lower to upper: %s\n", mystr); //run a property set accessor demo_test_set_title (my_test, "set property from c"); //run a property get accessor mystr = demo_test_get_title (my_test); g_printf ("Title property: %s\n", mystr); num = demo_test_get_value (my_test); g_printf ("The counter's value is %d\n", num); num_dbl = demo_test_get_double_value (my_test); g_printf ("The counter's double value is %.16f\n", num_dbl); drink = demo_test_pick_drink (); //enum_class = g_type_class_peek (demo_drink_get_type ()); //g_enum_get_value (enum_class, drink); //g_printf ("%d\n", drink); //TODO: return value //g_printf ("returned string: %s\n", demo_test_get_title (my_test)); return 0; }
25.363636
70
0.703226
b1b8cdf1d0eb9ac2c1c1546b0585f3e075a0ecd2
8,375
h
C
copasi/utilities/CProcessReport.h
tobiaselsaesser/COPASI
7e61c1b1667b0f4acf8f3865fe557603f221c472
[ "Artistic-2.0" ]
null
null
null
copasi/utilities/CProcessReport.h
tobiaselsaesser/COPASI
7e61c1b1667b0f4acf8f3865fe557603f221c472
[ "Artistic-2.0" ]
null
null
null
copasi/utilities/CProcessReport.h
tobiaselsaesser/COPASI
7e61c1b1667b0f4acf8f3865fe557603f221c472
[ "Artistic-2.0" ]
null
null
null
// Copyright (C) 2017 by Pedro Mendes, Virginia Tech Intellectual // Properties, Inc., University of Heidelberg, and University of // of Connecticut School of Medicine. // All rights reserved. // Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual // Properties, Inc., University of Heidelberg, and The University // of Manchester. // All rights reserved. // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual // Properties, Inc., EML Research, gGmbH, University of Heidelberg, // and The University of Manchester. // All rights reserved. // Copyright (C) 2005 - 2007 by Pedro Mendes, Virginia Tech Intellectual // Properties, Inc. and EML Research, gGmbH. // All rights reserved. #ifndef COPASI_CProcessReport #define COPASI_CProcessReport #include <string> #include <map> #include "copasi/core/CVector.h" #include "utilities/CCopasiParameter.h" class CCopasiTimeVariable; class CProcessReportItem: public CCopasiParameter { // Operations private: CProcessReportItem(); public: /** * Specific constructor * @param const string & name * @param const CCopasiParameter::Type & type * @param const void * pValue * @param const void * pEndValue (default: NULL) */ CProcessReportItem(const std::string & name, const CCopasiParameter::Type & type, const void * pValue, const void * pEndValue = NULL); /** * Copy Constructor * @param const CProcessReportItem & src */ CProcessReportItem(const CProcessReportItem & src); /** * Destructor */ ~CProcessReportItem(); /** * Retrieve the private end value of the parameter. This method * returns NULL if no end value has been set. * @return const CCopasiParameter::Value & endValue */ template < class CType > const CType & getEndValue() const {return static_cast< const CType >(mpEndValue);} /** * Retrieve the private end value of the parameter. * @return CCopasiParameter::Value & endValue */ template < class CType > CType & getEndValue() {return static_cast< CType >(mpEndValue);} /** * Retrieve the raw pointer to the end value */ void * getEndValuePointer(); /** * Retrieve whether the item has an end value. * @return const bool & hasEndValue */ const bool & hasEndValue() const; // Attributes private: /** * A pointer to the value of the parameter. */ void * mpEndValue; /** * Indicator whether an endvalue has been provided */ bool mHasEndValue; }; class CProcessReport { // Operations public: /** * Default Constructor * @param const unsigned int & maxTime (Default: 0) */ CProcessReport(const unsigned int & maxTime = 0); /** * Destructor */ virtual ~CProcessReport(); /** * Report process on all items. If the return value is false the calling * process must halt execution and return. * @param bool continue */ virtual bool progress(); /** * Report process on item handle. If the return value is false the calling * process must halt execution and return. * @param const size_t & handle * @param bool continue */ virtual bool progressItem(const size_t & handle); /** * Check whether processing shall proceed. If the return value is false * the calling process must halt execution and return. This method is * provided so that lengthy processing without advances in any of the * reporting items can check whether continuation is requested. * @param bool continue */ virtual bool proceed(); /** * Reset all item handle. This means that the values of the items have changed * but not as part of a continuous process. If you run multiple processes * call reset between them. If the return value is false the calling * process must halt execution and return. * @param bool continue */ virtual bool reset(); /** * Reset item handle. This means that the value of the item has changed * but not as part of a continuous process. If you run multiple processes * call reset between them. If the return value is false the calling * process must halt execution and return. * @param const size_t & handle * @param bool continue */ virtual bool resetItem(const size_t & handle); /** * Indicate that all items are finished reporting. All item handles loose * their validity. If the return value is false the calling * process must halt execution and return. * @param bool continue */ virtual bool finish(); /** * Add a process report item to to the list of reporting items. * The return value is the handle of the item and can be used to * indicate process, finish, or reset the item. If the method fails * C_INVALID_INDEX is returned. * @param const std::string & name * @param const std::string & value * @param const std::string * pEndValue = NULL * @return size_t handle */ virtual size_t addItem(const std::string & name, const std::string & value, const std::string * pEndValue = NULL); /** * Add a process report item to to the list of reporting items. * The return value is the handle of the item and can be used to * indicate process, finish, or reset the item. If the method fails * C_INVALID_INDEX is returned. * @param const std::string & name * @param const C_INT32 & value * @param const C_INT32 * pEndValue = NULL * @return size_t handle */ size_t addItem(const std::string & name, const C_INT32 & value, const C_INT32 * pEndValue = NULL); /** * Add a process report item to to the list of reporting items. * The return value is the handle of the item and can be used to * indicate process, finish, or reset the item. If the method fails * C_INVALID_INDEX is returned. * @param const std::string & name * @param const unsigned C_INT32 & value * @param const unsigned C_INT32 * pEndValue = NULL * @return size_t handle */ size_t addItem(const std::string & name, const unsigned C_INT32 & value, const unsigned C_INT32 * pEndValue = NULL); /** * Add a process report item to to the list of reporting items. * The return value is the handle of the item and can be used to * indicate process, finish, or reset the item. If the method fails * C_INVALID_INDEX is returned. * @param const std::string & name * @param const C_FLOAT64 & value * @param const C_FLOAT64 * pEndValue = NULL * @return size_t handle */ size_t addItem(const std::string & name, const C_FLOAT64 & value, const C_FLOAT64 * pEndValue = NULL); protected: #ifndef SWIG /** * Add a process report item to to the list of reporting items. * The return value is the handle of the item and can be used to * indicate process, finish, or reset the item. If the method fails * C_INVALID_INDEX is returned. * @param const std::string & name * @param const CCopasiParameter::Type & type * @param const void * pValue * @param const void * pEndValue = NULL * @return size_t handle */ virtual size_t addItem(const std::string & name, const CCopasiParameter::Type & type, const void * pValue, const void * pEndValue = NULL); #endif public: /** * Indicate that item handle is finished reporting. The handle of that * item is no longer valid after the call. If the return value is false * the calling process must halt execution and return. * @param const size_t & handle * @param bool continue */ virtual bool finishItem(const size_t & handle); /** * Check whether the handle is valid, i.e., usable in progress, reset and finish. */ virtual bool isValidHandle(const size_t handle) const; /** * Set the name of the process. * @param const std::string & name * @return success */ virtual bool setName(const std::string & name); // Attributes protected: /** * The list process report items. */ CVector< CProcessReportItem * > mProcessReportItemList; /** * The name of the process. */ std::string mName; /** * The time the process should stop. */ CCopasiTimeVariable * mpEndTime; }; #endif // COPASI_CProcessReport
29.283217
83
0.668299
df888da04ee1301b98a2e6bc0653c70aefe15aa8
6,589
h
C
linux-4.14.90-dev/linux-4.14.90/drivers/md/persistent-data/dm-bitset.h
bingchunjin/1806_SDK
d5ed0258fc22f60e00ec025b802d175f33da6e41
[ "MIT" ]
44
2022-03-16T08:32:31.000Z
2022-03-31T16:02:35.000Z
linux-4.14.90-dev/linux-4.14.90/drivers/md/persistent-data/dm-bitset.h
bingchunjin/1806_SDK
d5ed0258fc22f60e00ec025b802d175f33da6e41
[ "MIT" ]
13
2021-07-10T04:36:17.000Z
2022-03-03T10:50:05.000Z
linux-4.14.90-dev/linux-4.14.90/drivers/md/persistent-data/dm-bitset.h
bingchunjin/1806_SDK
d5ed0258fc22f60e00ec025b802d175f33da6e41
[ "MIT" ]
30
2018-05-02T08:43:27.000Z
2022-01-23T03:25:54.000Z
/* * Copyright (C) 2012 Red Hat, Inc. * * This file is released under the GPL. */ #ifndef _LINUX_DM_BITSET_H #define _LINUX_DM_BITSET_H #include "dm-array.h" /*----------------------------------------------------------------*/ /* * This bitset type is a thin wrapper round a dm_array of 64bit words. It * uses a tiny, one word cache to reduce the number of array lookups and so * increase performance. * * Like the dm-array that it's based on, the caller needs to keep track of * the size of the bitset separately. The underlying dm-array implicitly * knows how many words it's storing and will return -ENODATA if you try * and access an out of bounds word. However, an out of bounds bit in the * final word will _not_ be detected, you have been warned. * * Bits are indexed from zero. * Typical use: * * a) Initialise a dm_disk_bitset structure with dm_disk_bitset_init(). * This describes the bitset and includes the cache. It's not called it * dm_bitset_info in line with other data structures because it does * include instance data. * * b) Get yourself a root. The root is the index of a block of data on the * disk that holds a particular instance of an bitset. You may have a * pre existing root in your metadata that you wish to use, or you may * want to create a brand new, empty bitset with dm_bitset_empty(). * * Like the other data structures in this library, dm_bitset objects are * immutable between transactions. Update functions will return you the * root for a _new_ array. If you've incremented the old root, via * dm_tm_inc(), before calling the update function you may continue to use * it in parallel with the new root. * * Even read operations may trigger the cache to be flushed and as such * return a root for a new, updated bitset. * * c) resize a bitset with dm_bitset_resize(). * * d) Set a bit with dm_bitset_set_bit(). * * e) Clear a bit with dm_bitset_clear_bit(). * * f) Test a bit with dm_bitset_test_bit(). * * g) Flush all updates from the cache with dm_bitset_flush(). * * h) Destroy the bitset with dm_bitset_del(). This tells the transaction * manager that you're no longer using this data structure so it can * recycle it's blocks. (dm_bitset_dec() would be a better name for it, * but del is in keeping with dm_btree_del()). */ /* * Opaque object. Unlike dm_array_info, you should have one of these per * bitset. Initialise with dm_disk_bitset_init(). */ struct dm_disk_bitset { struct dm_array_info array_info; uint32_t current_index; uint64_t current_bits; bool current_index_set:1; bool dirty:1; }; /* * Sets up a dm_disk_bitset structure. You don't need to do anything with * this structure when you finish using it. * * tm - the transaction manager that should supervise this structure * info - the structure being initialised */ void dm_disk_bitset_init(struct dm_transaction_manager *tm, struct dm_disk_bitset *info); /* * Create an empty, zero length bitset. * * info - describes the bitset * new_root - on success, points to the new root block */ int dm_bitset_empty(struct dm_disk_bitset *info, dm_block_t *new_root); /* * Creates a new bitset populated with values provided by a callback * function. This is more efficient than creating an empty bitset, * resizing, and then setting values since that process incurs a lot of * copying. * * info - describes the array * root - the root block of the array on disk * size - the number of entries in the array * fn - the callback * context - passed to the callback */ typedef int (*bit_value_fn)(uint32_t index, bool *value, void *context); int dm_bitset_new(struct dm_disk_bitset *info, dm_block_t *root, uint32_t size, bit_value_fn fn, void *context); /* * Resize the bitset. * * info - describes the bitset * old_root - the root block of the array on disk * old_nr_entries - the number of bits in the old bitset * new_nr_entries - the number of bits you want in the new bitset * default_value - the value for any new bits * new_root - on success, points to the new root block */ int dm_bitset_resize(struct dm_disk_bitset *info, dm_block_t old_root, uint32_t old_nr_entries, uint32_t new_nr_entries, bool default_value, dm_block_t *new_root); /* * Frees the bitset. */ int dm_bitset_del(struct dm_disk_bitset *info, dm_block_t root); /* * Set a bit. * * info - describes the bitset * root - the root block of the bitset * index - the bit index * new_root - on success, points to the new root block * * -ENODATA will be returned if the index is out of bounds. */ int dm_bitset_set_bit(struct dm_disk_bitset *info, dm_block_t root, uint32_t index, dm_block_t *new_root); /* * Clears a bit. * * info - describes the bitset * root - the root block of the bitset * index - the bit index * new_root - on success, points to the new root block * * -ENODATA will be returned if the index is out of bounds. */ int dm_bitset_clear_bit(struct dm_disk_bitset *info, dm_block_t root, uint32_t index, dm_block_t *new_root); /* * Tests a bit. * * info - describes the bitset * root - the root block of the bitset * index - the bit index * new_root - on success, points to the new root block (cached values may have been written) * result - the bit value you're after * * -ENODATA will be returned if the index is out of bounds. */ int dm_bitset_test_bit(struct dm_disk_bitset *info, dm_block_t root, uint32_t index, dm_block_t *new_root, bool *result); /* * Flush any cached changes to disk. * * info - describes the bitset * root - the root block of the bitset * new_root - on success, points to the new root block */ int dm_bitset_flush(struct dm_disk_bitset *info, dm_block_t root, dm_block_t *new_root); struct dm_bitset_cursor { struct dm_disk_bitset *info; struct dm_array_cursor cursor; uint32_t entries_remaining; uint32_t array_index; uint32_t bit_index; uint64_t current_bits; }; /* * Make sure you've flush any dm_disk_bitset and updated the root before * using this. */ int dm_bitset_cursor_begin(struct dm_disk_bitset *info, dm_block_t root, uint32_t nr_entries, struct dm_bitset_cursor *c); void dm_bitset_cursor_end(struct dm_bitset_cursor *c); int dm_bitset_cursor_next(struct dm_bitset_cursor *c); int dm_bitset_cursor_skip(struct dm_bitset_cursor *c, uint32_t count); bool dm_bitset_cursor_get_value(struct dm_bitset_cursor *c); /*----------------------------------------------------------------*/ #endif /* _LINUX_DM_BITSET_H */
31.985437
92
0.715738
be04c8a6c7acdc67fcc49148f567999757582fd3
522
h
C
include/config.h
cgnerds/SlamAR
9c6d3a1086cf1c8cd731277d3662019071e72aa8
[ "Apache-2.0" ]
8
2017-06-23T17:07:24.000Z
2021-04-23T08:04:31.000Z
include/config.h
cgnerds/SlamAR
9c6d3a1086cf1c8cd731277d3662019071e72aa8
[ "Apache-2.0" ]
1
2020-03-08T14:41:47.000Z
2020-03-08T14:41:47.000Z
include/config.h
peitaosu/SlamAR-macOS
e63b3415d014b40cce2dc097e6f84b42055ba3f2
[ "Apache-2.0" ]
4
2017-07-03T05:32:49.000Z
2020-03-07T14:15:02.000Z
#ifndef CONFIG_H #include "common_include.h" namespace slamar { class Config { private: static std::shared_ptr<Config> config_; cv::FileStorage file_; Config() {} // private constructor makes a singleton public: ~Config(); // close the file when deconstructing // set a new config file static void setParameterFile(const std::string& filename); // access the parameter values template< typename T> static T get(const std::string& key) { return T(Config::config_->file_[key]); } }; } #endif // !CONFIG_H
17.4
59
0.716475
0eb7422e1eec35a539fb23727b56b1c5663ce437
2,055
h
C
Libraries/VtkVgModelView/vtkVgEventModelCollection.h
judajake/vivia
ac0bad0dc200b5af25911513edb0ca6fd6e9f622
[ "BSD-3-Clause" ]
1
2017-07-31T07:08:05.000Z
2017-07-31T07:08:05.000Z
Libraries/VtkVgModelView/vtkVgEventModelCollection.h
judajake/vivia
ac0bad0dc200b5af25911513edb0ca6fd6e9f622
[ "BSD-3-Clause" ]
null
null
null
Libraries/VtkVgModelView/vtkVgEventModelCollection.h
judajake/vivia
ac0bad0dc200b5af25911513edb0ca6fd6e9f622
[ "BSD-3-Clause" ]
null
null
null
/*ckwg +5 * Copyright 2013 by Kitware, Inc. All Rights Reserved. Please refer to * KITWARE_LICENSE.TXT for licensing information, or contact General Counsel, * Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065. */ #ifndef __vtkVgEventModelCollection_h #define __vtkVgEventModelCollection_h // VisGUI includes. #include <vtkVgMacros.h> // VTK includes. #include <vtkObject.h> #include <vgExport.h> // Forward declarations. class vtkVgEvent; class vtkVgEventBase; class vtkVgEventModel; class VTKVG_MODELVIEW_EXPORT vtkVgEventModelCollection : public vtkObject { public: // Description: // Macro defined for SmartPtr. vtkVgClassMacro(vtkVgEventModelCollection); // Description: // Macro defined for object hierarchy and internal management. vtkTypeMacro(vtkVgEventModelCollection, vtkObject); // Description: // Print information about data members. virtual void PrintSelf(ostream& os, vtkIndent indent); // Description: // Create a new instance of this class. static vtkVgEventModelCollection* New(); // Description: // Update modified time on contained models virtual void Modified(); // Description: // Add/Remove \c vtkVgEventBase to/from known event models. vtkVgEvent* AddEvent(vtkVgEventBase* event); void RemoveEvent(vtkIdType id); // Description: // Get a event give a event id. vtkVgEvent* GetEvent(vtkIdType id); // Description: // Provide access to the internal model. vtkVgEventModel* GetInternalEventModel(); // Description: // Add/Remove \c vtkVgEventModel to/from internal store of event models. void AddEventModel(vtkVgEventModel* eventModel); void RemoveEventModel(vtkVgEventModel* eventModel); protected: vtkVgEventModelCollection(); virtual ~vtkVgEventModelCollection(); private: class Internal; Internal* Implementation; vtkVgEventModelCollection(const vtkVgEventModelCollection&); // Not implemented. void operator= (const vtkVgEventModelCollection&); // Not implemented. }; #endif // __vtkVgEventModelCollection_h
25.6875
82
0.754258
ce70506bb29ec6f8f135edef0057a6098d9ca4bc
346
h
C
Web browser iPad/Web browser iPad/CBBookmarks.h
AnandEmbold/Objective-C-Examples-CPP
1dc8bd9dcead4e2a548c938405105c9a77155549
[ "MIT" ]
5
2017-12-29T14:46:35.000Z
2019-08-07T11:43:13.000Z
Web browser iPad/Web browser iPad/CBBookmarks.h
AnandEmbold/Objective-C-Examples-CPP
1dc8bd9dcead4e2a548c938405105c9a77155549
[ "MIT" ]
null
null
null
Web browser iPad/Web browser iPad/CBBookmarks.h
AnandEmbold/Objective-C-Examples-CPP
1dc8bd9dcead4e2a548c938405105c9a77155549
[ "MIT" ]
10
2017-11-28T22:56:41.000Z
2019-08-07T11:43:19.000Z
// // CBMarcador.h // Navegador iPad // // Created by Carlos on 07/05/14. // Copyright (c) 2014 Carlos Butron. All rights reserved. // #import <Foundation/Foundation.h> @interface CBBookmarks : NSObject @property (strong) NSString *title; @property (strong) NSString *url; - (id)initWithTitle:(NSString *)title URL:(NSString *)url; @end
18.210526
58
0.699422
07d4864fffc734b6add728e45b78f896c85404ca
721
h
C
headers/3rdparty/UIImageView-HighlightedWebCache.h
Tatsh-archive/tynder
bbbf0a2b7480d1a1519483ddcead6736d9ba6501
[ "MIT" ]
1
2015-03-03T13:37:47.000Z
2015-03-03T13:37:47.000Z
headers/3rdparty/UIImageView-HighlightedWebCache.h
Tatsh/tynder
bbbf0a2b7480d1a1519483ddcead6736d9ba6501
[ "MIT" ]
null
null
null
headers/3rdparty/UIImageView-HighlightedWebCache.h
Tatsh/tynder
bbbf0a2b7480d1a1519483ddcead6736d9ba6501
[ "MIT" ]
null
null
null
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "UIImageView.h" @interface UIImageView (HighlightedWebCache) - (void)sd_cancelCurrentHighlightedImageLoad; - (void)sd_setHighlightedImageWithURL:(id)arg1; - (void)sd_setHighlightedImageWithURL:(id)arg1 completed:(CDUnknownBlockType)arg2; - (void)sd_setHighlightedImageWithURL:(id)arg1 options:(unsigned int)arg2; - (void)sd_setHighlightedImageWithURL:(id)arg1 options:(unsigned int)arg2 completed:(CDUnknownBlockType)arg3; - (void)sd_setHighlightedImageWithURL:(id)arg1 options:(unsigned int)arg2 progress:(CDUnknownBlockType)arg3 completed:(CDUnknownBlockType)arg4; @end
40.055556
143
0.789182
dcd55e9694cced33ad31c88918aaad9e77209fd7
347
h
C
Example/Pods/TCFoundation/TCFoundation/Frameworks/TCFoundation.framework/Versions/A/Headers/TCSqliteORMModel+List.h
flatads/iOSMoPubAdapter
10a8e6b6d0b3a540844e4ffd20bd85dae0b871f6
[ "MIT" ]
null
null
null
Example/Pods/TCFoundation/TCFoundation/Frameworks/TCFoundation.framework/Versions/A/Headers/TCSqliteORMModel+List.h
flatads/iOSMoPubAdapter
10a8e6b6d0b3a540844e4ffd20bd85dae0b871f6
[ "MIT" ]
null
null
null
Example/Pods/TCFoundation/TCFoundation/Frameworks/TCFoundation.framework/Versions/A/Headers/TCSqliteORMModel+List.h
flatads/iOSMoPubAdapter
10a8e6b6d0b3a540844e4ffd20bd85dae0b871f6
[ "MIT" ]
null
null
null
// // TCSqliteORMModel+List.h // TCFoundation // // Created by EkoHu on 2021/3/16. // #import "TCSqliteORMModel.h" #import "TCSqliteORMModelProtocol.h" #import "TCSqliteORMSessionProtocol.h" NS_ASSUME_NONNULL_BEGIN @interface TCSqliteORMModel (List)<TCSqliteORMModelListProtocol, TCSqliteORMSessionListProtocol> @end NS_ASSUME_NONNULL_END
18.263158
96
0.798271
470501d161a198bbc402ea489704cb9b90236a38
148
h
C
userspace/libraries/libc/src/include/unistd.h
fengjixuchui/lilith
f53647da065394550159191756329932972246f6
[ "MIT" ]
1,185
2019-07-16T00:17:50.000Z
2022-03-28T19:43:44.000Z
userspace/libraries/libc/src/include/unistd.h
fengjixuchui/lilith
f53647da065394550159191756329932972246f6
[ "MIT" ]
30
2019-08-30T01:43:02.000Z
2021-08-24T12:16:48.000Z
userspace/libraries/libc/src/include/unistd.h
fengjixuchui/lilith
f53647da065394550159191756329932972246f6
[ "MIT" ]
35
2019-08-29T21:17:51.000Z
2022-03-07T12:26:08.000Z
#pragma once #include <syscalls.h> #include <termios.h> #define ENOTTY 0 #define ENOENT 0 int atexit(void (*function)(void)); int isatty(int fd);
14.8
35
0.716216
81284dc1118282fbb75c93aed43af1fd428b7084
2,927
h
C
PhotosPlayer.framework/ISLivePhotoUIView.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
4
2021-10-06T12:15:26.000Z
2022-02-21T02:26:00.000Z
PhotosPlayer.framework/ISLivePhotoUIView.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
null
null
null
PhotosPlayer.framework/ISLivePhotoUIView.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
1
2021-10-08T07:40:53.000Z
2021-10-08T07:40:53.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/PhotosPlayer.framework/PhotosPlayer */ @interface ISLivePhotoUIView : ISBasePlayerUIView <ISChangeObserver, UIGestureRecognizerDelegate, UIInteractionProgressObserver> { UIPreviewForceInteractionProgress * __interactionProgress; long long __overlayDismissalID; UILabel * __overlayLabel; ISLivePhotoPlaybackFilter * __playbackFilter; bool __playingVitality; bool __useForceTouch; UIImpactFeedbackGenerator * _feedbackGenerator; UIGestureRecognizer * _playbackGestureRecognizer; } @property (nonatomic, readonly) UIPreviewForceInteractionProgress *_interactionProgress; @property (setter=_setOverlayDismissalID:, nonatomic) long long _overlayDismissalID; @property (nonatomic, readonly) UILabel *_overlayLabel; @property (setter=_setPlaybackFilter:, nonatomic, retain) ISLivePhotoPlaybackFilter *_playbackFilter; @property (setter=_setPlayingVitality:, nonatomic) bool _playingVitality; @property (setter=_setUseForceTouch:, nonatomic) bool _useForceTouch; @property (readonly, copy) NSString *debugDescription; @property (readonly, copy) NSString *description; @property (readonly) unsigned long long hash; @property (nonatomic, readonly) UIGestureRecognizer *playbackGestureRecognizer; @property (nonatomic, retain) ISLivePhotoPlayer *player; @property (readonly) Class superclass; - (void).cxx_destruct; - (void)_ISLivePhotoUIViewCommonInitialization; - (void)_dismissOverlayLabel:(long long)arg1; - (void)_handlePlaybackRecognizer:(id)arg1; - (id)_interactionProgress; - (long long)_overlayDismissalID; - (id)_overlayLabel; - (id)_playbackFilter; - (Class)_playbackFilterClass; - (void)_playerDidChangeHinting; - (void)_playerDidChangePlaybackStyle; - (bool)_playingVitality; - (void)_setOverlayDismissalID:(long long)arg1; - (void)_setPlaybackFilter:(id)arg1; - (void)_setPlayingVitality:(bool)arg1; - (void)_setUseForceTouch:(bool)arg1; - (void)_showOverlayLabel; - (void)_updateForceInteractionProgress; - (void)_updateGestureRecognizerParameters; - (void)_updatePlaybackFilter; - (void)_updatePlaybackFilterInput; - (bool)_useForceTouch; - (void)audioSessionDidChange; - (void)contentDidChange; - (void)dealloc; - (bool)gestureRecognizer:(id)arg1 shouldRecognizeSimultaneouslyWithGestureRecognizer:(id)arg2; - (id)initWithCoder:(id)arg1; - (id)initWithFrame:(struct CGRect { struct CGPoint { double x_1_1_1; double x_1_1_2; } x1; struct CGSize { double x_2_1_1; double x_2_1_2; } x2; })arg1; - (void)interactionProgress:(id)arg1 didEnd:(bool)arg2; - (void)interactionProgressDidUpdate:(id)arg1; - (id)livePhotoPlayer; - (void)observable:(id)arg1 didChange:(unsigned long long)arg2 context:(void*)arg3; - (void)observeValueForKeyPath:(id)arg1 ofObject:(id)arg2 change:(id)arg3 context:(void*)arg4; - (id)playbackGestureRecognizer; - (void)setPlayer:(id)arg1; - (void)traitCollectionDidChange:(id)arg1; @end
43.686567
153
0.801503
5480583e5ba0dacd1efed5cad967288e704a67ed
775
h
C
src/RIOT/pkg/emb6/include/board_conf.h
ARte-team/ARte
19f17f57522e1b18ba390718fc94be246451837b
[ "MIT" ]
2
2020-04-30T08:17:45.000Z
2020-05-23T08:46:54.000Z
src/RIOT/pkg/emb6/include/board_conf.h
ARte-team/ARte
19f17f57522e1b18ba390718fc94be246451837b
[ "MIT" ]
null
null
null
src/RIOT/pkg/emb6/include/board_conf.h
ARte-team/ARte
19f17f57522e1b18ba390718fc94be246451837b
[ "MIT" ]
null
null
null
/* * Copyright (C) 2016 Freie Universität Berlin * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level * directory for more details. */ /** * @addtogroup pkg_emb6 * @brief * @{ * * @file * @brief "Board" configuration for emb6 * * @author Martine Lenders <mlenders@inf.fu-berlin.de> */ #ifndef BOARD_CONF_H #define BOARD_CONF_H #ifdef __cplusplus extern "C" { #endif #include "emb6.h" /** * @brief emb6 board configuration function * * @param[in] ps_nStack pointer to global netstack struct * * @return success 1 * @return failure 0 */ uint8_t board_conf(s_ns_t *ps_nStack); #ifdef __cplusplus } #endif #endif /* BOARD_CONF_H */ /** @} */ /** @} */
16.847826
69
0.668387
607189bec58c427d261aed4c8a9a997bbd2db5de
33,448
h
C
rosplan_knowledge_base/src/VALfiles/TimSupport.h
kvnptl/ROSPlan
6db87e3c84d5e568c1679074266c15b6a36941e6
[ "BSD-2-Clause" ]
278
2015-03-21T00:28:14.000Z
2022-03-28T05:34:14.000Z
rosplan_knowledge_base/src/VALfiles/TimSupport.h
kvnptl/ROSPlan
6db87e3c84d5e568c1679074266c15b6a36941e6
[ "BSD-2-Clause" ]
205
2015-05-08T10:58:36.000Z
2022-03-24T16:32:42.000Z
rosplan_knowledge_base/src/VALfiles/TimSupport.h
kvnptl/ROSPlan
6db87e3c84d5e568c1679074266c15b6a36941e6
[ "BSD-2-Clause" ]
156
2015-05-15T10:12:49.000Z
2022-02-17T17:41:20.000Z
/************************************************************************ * Copyright 2008, Strathclyde Planning Group, * Department of Computer and Information Sciences, * University of Strathclyde, Glasgow, UK * http://planning.cis.strath.ac.uk/ * * Maria Fox, Richard Howey and Derek Long - VAL * Stephen Cresswell - PDDL Parser * * This file is part of VAL, the PDDL validator. * * VAL is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * VAL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VAL. If not, see <http://www.gnu.org/licenses/>. * ************************************************************************/ #ifndef __TIMSUPPORT_1_2 #define __TIMSUPPORT_1_2 #include <algorithm> #include <iostream> #include <set> #include <memory> #include <iterator> #include <string.h> #include "TIMUtilities.h" #include "TypedAnalyser.h" #define OUTPUT if(getenv("TIMOUT")) #define OUTPUT1 if(getenv("TIMOUT") && !strcmp(getenv("TIMOUT"),"Hi")) using std::multiset; using std::make_pair; using std::max; using std::min; using std::for_each; using std::bind2nd; using std::not1; using std::mem_fun; namespace TIM { class PropertySpace; class TIMobjectSymbol; class TIMAnalyser; class Property { private: VAL::pred_symbol * predicate; int posn; vector<PropertySpace*> belongTo; vector<TIMobjectSymbol*> exhibitors; bool isSV; bool isReq; public: Property() : predicate(0), isSV(false), isReq(false) {}; Property(VAL::pred_symbol * p,int a) : predicate(p), posn(a), isSV(false), isReq(false) {}; void setSV(bool sv,bool rq) { isSV = sv; isReq = rq; }; bool isSingleValued() const {return isSV;}; bool isRequired() const {return isReq;}; void write(ostream & o) const { o << predicate->getName() << "_" << posn; /* o << "["; for(vector<pddl_type *>::iterator i = EPS(predicate)->tBegin(); i != EPS(predicate)->tEnd();++i) { o << (*i)->getName() << " "; }; o << "]"; */ }; void addIn(PropertySpace * p) { belongTo.push_back(p); }; typedef vector<PropertySpace *>::iterator SpaceIt; SpaceIt begin() {return belongTo.begin();}; SpaceIt end() {return belongTo.end();}; void add(TIMobjectSymbol * t) { exhibitors.push_back(t); }; typedef vector<TIMobjectSymbol *>::iterator ObjectIt; ObjectIt oBegin() {return exhibitors.begin();}; ObjectIt oEnd() {return exhibitors.end();}; Property * getBaseProperty(const VAL::pddl_type * pt) const; vector<Property *> matchers(); bool matches(const VAL::extended_pred_symbol * prop,VAL::pddl_type * pt); bool applicableTo(VAL::TypeChecker & tc,const VAL::pddl_type * tp) const; int familySize() const {return EPS(predicate)->arity();}; int aPosn() const {return posn;}; const VAL::extended_pred_symbol * root() const {return EPS(predicate);}; bool equivalent(const Property * p) const; }; ostream & operator<<(ostream & o, const Property & p); struct setUpProps { unsigned int a; VAL::pred_symbol * pred; setUpProps(VAL::pred_symbol * p) : a(0), pred(p) {}; void operator()(Property & p) { p = Property(pred,a); ++a; }; }; class TIMpredSymbol : public VAL::extended_pred_symbol { private: vector<Property> props; typedef map<TIMpredSymbol *,vector<pair<int,int> > > MutexRecords; MutexRecords mutexes; public: TIMpredSymbol(VAL::pred_symbol * p,VAL::proposition * q) : extended_pred_symbol(p,q), props(q->args->size()) { for_each(props.begin(),props.end(),setUpProps(this)); }; template<class TI> TIMpredSymbol(pred_symbol * p,TI s,TI e) : extended_pred_symbol(p,s,e), props(e-s) { for_each(props.begin(),props.end(),setUpProps(this)); EPS(p)->getParent()->add(this); }; Property * property(int a) {return &(props[a]);}; void setMutex(int p1,TIMpredSymbol * tps,int p2) { mutexes[tps].push_back(make_pair(p1,p2)); }; template<typename TI> bool checkMutex(TI sa,TI ea,TIMpredSymbol * pb,TI sb,TI eb) { MutexRecords::iterator i = mutexes.find(pb); if(i == mutexes.end()) return false; if(pb == this) { for(vector<pair<int,int> >::const_iterator p = i->second.begin(); p != i->second.end();++p) { OUTPUT cout << "Examining " << p->first << " " << p->second << "\n"; if(*(sa+p->first) == *(sb+p->second)) { // Same object has two copies of the same property. // Now check whether they are identical propositions. for(;sa != ea;++sa,++sb) { if(*sa != *sb) return true; }; }; }; } else { for(vector<pair<int,int> >::const_iterator p = i->second.begin(); p != i->second.end();++p) { OUTPUT cout << "Examining " << p->first << " " << p->second << "\n"; // Same value has two mutex properties... if(*(sa+p->first) == *(sb+p->second)) return true; }; }; return false; }; }; #define TPS(x) static_cast<TIMpredSymbol*>(x) #define cTPS(x) const_cast<TIMpredSymbol *>(static_cast<const TIMpredSymbol*>(x)) class TIMobjectSymbol : public VAL::const_symbol { private: vector<Property*> initial; vector<VAL::proposition *> initialps; vector<Property*> final; vector<PropertySpace *> spaces; public: TIMobjectSymbol(const string & s) : const_symbol(s) {}; void addInitial(Property*p,VAL::proposition * prp) { initial.push_back(p); initialps.push_back(prp); }; void addFinal(Property*p) {final.push_back(p);}; void addIn(PropertySpace * p) {spaces.push_back(p);}; void distributeStates(TIMAnalyser * tan); void write(ostream & o) const { o << getName(); }; const vector<VAL::proposition*> & getInits() const {return initialps;}; VAL::proposition * find(const Property * p) const { for(vector<Property*>::const_iterator i = initial.begin();i != initial.end();++i) { if(p && p->equivalent(*i)) { return initialps[i-initial.begin()]; }; }; return 0; /* vector<Property*>::const_iterator i = std::find(initial.begin(),initial.end(),p); if(i == initial.end()) { for(vector<Property*>::const_iterator ii = initial.begin();ii != initial.end();++ii) { vector<Property*> ps = (*ii)->matchers(); vector<Property*>::const_iterator j = std::find(ps.begin(),ps.end(),p); if(j != ps.end()) { return initialps[ii-initial.begin()]; }; }; return 0; }; return initialps[i-initial.begin()]; */ }; }; ostream & operator <<(ostream & o,const TIMobjectSymbol & t); #define TOB(x) static_cast<TIM::TIMobjectSymbol*>(x) class PropertyState { private: typedef multiset<Property *> Properties; typedef CascadeMap<Property *,PropertyState> PMap; static PMap pmap; TIMAnalyser * tan; Properties properties; template<class TI> PropertyState(TIMAnalyser * t,TI s,TI e) : tan(t), properties(s,e) {}; template<class TI> static PropertyState * retrieve(TIMAnalyser * tan,TI s,TI e) { PropertyState * & ps = pmap.forceGet(s,e); if(ps==0) { ps = new PropertyState(tan,s,e); }; return ps; }; public: template<class TI> static PropertyState * getPS(TIMAnalyser * tan,const VAL::pddl_type * pt,TI s,TI e) { vector<Property *> props; transform(s,e,inserter(props,props.begin()), bind2nd(mem_fun(&Property::getBaseProperty),pt)); return retrieve(tan,props.begin(),props.end()); }; void write(ostream & o) const { o << "{"; for_each(properties.begin(),properties.end(), ptrwriter<Property>(o," ")); o << "}"; }; int count(Property * p) const { return std::count(properties.begin(),properties.end(),p); }; bool contains(Property * p) const { return std::find(properties.begin(),properties.end(),p) != properties.end(); }; bool empty() const { return properties.empty(); }; size_t size() const { return properties.size(); }; typedef Properties::const_iterator PSIterator; PSIterator begin() const {return properties.begin();}; PSIterator end() const {return properties.end();}; PropertyState * adjust(const PropertyState * del,const PropertyState * add) { // Simple implementation is to remove del from this and then check that the result // found all entries in del. If so, union add and return a new PropertyState, else // return 0. // // There is probably an issue over types though. For example, if dels are for a more // specialised type than the entries in this what should happen? vector<Property *> ps; set_difference(properties.begin(),properties.end(), del->properties.begin(),del->properties.end(), inserter(ps,ps.begin())); if(ps.size() + del->properties.size() == properties.size()) { vector<Property *> qs; merge(ps.begin(),ps.end(),add->properties.begin(),add->properties.end(), inserter(qs,qs.begin())); return retrieve(tan,qs.begin(),qs.end()); } else { return 0; }; }; pair<PropertyState *,PropertyState *> split(Property *); template<class TI> PropertyState * add(TI s,TI e) { if(s==e) return this; vector<Property *> qs; merge(properties.begin(),properties.end(),s,e,inserter(qs,qs.begin())); return retrieve(tan,qs.begin(),qs.end()); }; }; ostream & operator<<(ostream & o,const PropertyState & p); class TransitionRule; class mRec; struct recordIn { PropertySpace * ps; recordIn(PropertySpace * p) : ps(p) {}; void operator()(Property * p) { p->addIn(ps); }; }; struct countInState { Property * prop; countInState(Property * p) : prop(p) {}; int operator()(PropertyState* ps) { return ps->count(prop); }; }; struct recordSV { PropertySpace * ps; vector<Property *> & sv; recordSV(PropertySpace * p,vector<Property *> & s) : ps(p), sv(s) {}; void operator()(Property * p); }; // Two facts will be mutex if they define properties that appear in different // states of the same (SV) property space, or if they define properties that are // different instantiations for the same object when only one instance of the // property appears in a state in a (SV) property space. class PropertySpace { private: set<PropertyState *> states; set<TransitionRule *> rules; vector<Property *> properties; vector<TIMobjectSymbol *> objects; bool isStateValued; bool isLS; bool LSchecked; public: PropertySpace(Property * p,TransitionRule * t); PropertySpace(Property * p) : states(), rules(), properties(1,p), objects(), isStateValued(true) {}; void checkStateValued(); void merge(PropertySpace * ps) { copy(ps->states.begin(),ps->states.end(), inserter(states,states.end())); copy(ps->rules.begin(),ps->rules.end(), inserter(rules,rules.end())); copy(ps->properties.begin(),ps->properties.end(), inserter(properties,properties.end())); copy(ps->objects.begin(),ps->objects.end(), inserter(objects,objects.end())); isStateValued &= ps->isStateValued; delete ps; }; vector<int> countsFor(Property * p) { vector<int> cs; transform(states.begin(),states.end(),inserter(cs,cs.begin()),countInState(p)); return cs; }; void checkSV(vector<Property *> & sv) { for_each(properties.begin(),properties.end(),recordSV(this,sv)); }; void add(TransitionRule * t); PropertySpace * finalise() { for_each(properties.begin(),properties.end(),recordIn(this)); return this; }; void assembleMutexes(); void assembleMutexes(TransitionRule *); // void assembleMutexes(TransitionRule *,Property *); void assembleMutexes(Property *); void assembleMutexes(Property *,Property *); void assembleMutexes(VAL::operator_ *,const mRec &); void recordRulesInActions(); void add(PropertyState * ps) {states.insert(ps);}; void add(TIMobjectSymbol * t) {objects.push_back(t);}; void write(ostream & o) const; bool isState() const {return isStateValued;}; bool isStatic() const {return rules.empty();}; void sortObjects() {sort(objects.begin(),objects.end());}; bool contains(TIMobjectSymbol * to) const; typedef vector<TIMobjectSymbol *>::const_iterator OIterator; OIterator obegin() const {return objects.begin();}; OIterator oend() const {return objects.end();}; bool extend(); bool examine(vector<PropertySpace*> &); PropertySpace * slice(Property * p); bool applicableTo(VAL::TypeChecker & tc,const VAL::pddl_type * tp) const; typedef set<PropertyState*>::const_iterator SIterator; SIterator begin() const {return states.begin();}; SIterator end() const {return states.end();}; int numStates() const {return states.size();}; bool isLockingSpace(); }; ostream & operator<<(ostream & o,const PropertySpace & p); class rulePartitioner; class RuleObjectIterator; enum opType {INSTANT = 0,START = 1,MIDDLE = 2,END = 3}; class TransitionRule { private: TIMAnalyser * tan; VAL::operator_ * op; VAL::derivation_rule * drv; opType opt; int var; PropertyState * enablers; PropertyState * lhs; PropertyState * rhs; vector<VAL::const_symbol*> objects; friend class rulePartitioner; friend class RuleObjectIterator; TransitionRule(TransitionRule * t,PropertyState * e,PropertyState * l,PropertyState * r); public: TransitionRule(TIMAnalyser * t,VAL::operator_ * o,int v, PropertyState * e,PropertyState * l,PropertyState * r, opType ty = INSTANT); TransitionRule(TIMAnalyser * t,VAL::derivation_rule * o,int v, PropertyState * e,PropertyState * l,PropertyState * r, opType ty = INSTANT); bool isTrivial() const { return lhs->empty() && rhs->empty(); }; bool isAttribute() const { return lhs->empty() || rhs->empty(); }; bool isIncreasing() const { return lhs->empty() && !rhs->empty(); }; bool isDecreasing() const { return rhs->empty() && !lhs->empty(); }; void distributeEnablers(); void write(ostream & o) const { o << (*enablers) << " => " << (*lhs) << " -> " << (*rhs) << (isAttribute()?" attribute rule: ":"") << (isIncreasing()?"increasing":"") << (isDecreasing()?"decreasing":""); }; RuleObjectIterator beginEnabledObjects(); RuleObjectIterator endEnabledObjects(); PropertyState * tryRule(PropertyState * p) { return p->adjust(lhs,rhs); }; void assembleMutex(TransitionRule *); void assembleMutex(VAL::operator_*,const mRec & pr); Property * candidateSplit(); void recordInAction(PropertySpace * p); int paramNum() const {return var;}; TransitionRule * splitRule(Property * p); const PropertyState * getLHS() const {return lhs;}; const PropertyState * getRHS() const {return rhs;}; const PropertyState * getEnablers() const {return enablers;}; const VAL::operator_ * byWhat() const {return op;}; bool applicableIn(const PropertyState * p) const; }; ostream & operator<<(ostream & o,const TransitionRule & tr); typedef vector<TransitionRule *> TRules; struct ProtoRule { TIMAnalyser * tan; VAL::operator_ * op; VAL::derivation_rule * drv; opType opt; int var; vector<Property *> enablers; vector<Property *> adds; vector<Property *> dels; ProtoRule(TIMAnalyser * t,VAL::operator_ * o,int v,opType ty = INSTANT) : tan(t), op(o), drv(0), opt(ty), var(v) {}; ProtoRule(TIMAnalyser * t,VAL::derivation_rule * o,int v,opType ty = INSTANT) : tan(t), op(0), drv(o), opt(ty), var(v) {}; void insertPre(Property * p) { enablers.push_back(p); }; void insertAdd(Property * p) { adds.push_back(p); }; void insertDel(Property * p) { dels.push_back(p); }; void addRules(TRules & trules); }; struct processRule { TRules & trules; processRule(TRules & tr) : trules(tr) {}; void operator()(ProtoRule * pr) { if(!pr) return; pr->addRules(trules); delete pr; }; }; struct doExtension { bool again; doExtension() : again(false) {}; void operator()(PropertySpace * p) { again |= p->extend(); }; operator bool() {return again;}; }; struct doExamine { TIMAnalyser * tan; vector<PropertySpace *> newas; doExamine(TIMAnalyser * t) : tan(t) {}; void operator()(PropertySpace * p); operator vector<PropertySpace *>() {return newas;}; }; // Need this because mem_fun won't work with non-const methods like sortObjects. inline void sortObjects(PropertySpace * p) { p->sortObjects(); }; class TIMpred_decl : public VAL::pred_decl { public: TIMpred_decl() : pred_decl(0,0,0) {}; TIMpred_decl(VAL::pred_symbol * h,VAL::var_symbol_list * a,VAL::var_symbol_table * vt) : pred_decl(h,a,vt) {}; ~TIMpred_decl() { args = 0; var_tab = 0; }; }; class DurativeActionPredicateBuilder : public VAL::VisitController { private: bool inserting; vector<VAL::pred_symbol *> toIgnore; VAL::durative_action * replacePreconditionsOf; public: DurativeActionPredicateBuilder() : VisitController(), inserting(true) {}; const vector<VAL::pred_symbol *> & getIgnores() const {return toIgnore;}; void reverse() {inserting = false;}; virtual void visit_conj_goal(VAL::conj_goal * cg) { using namespace VAL1_2; replacePreconditionsOf->precondition = cg->getGoals()->front(); const_cast<goal_list*>(cg->getGoals())->pop_front(); } virtual void visit_timed_goal(VAL::timed_goal* ) { replacePreconditionsOf->precondition = 0; } virtual void visit_durative_action(VAL::durative_action * p) { using namespace VAL1_2; // cout << "Treating " << p->name->getName() << "\n"; if(inserting) { pred_symbol * nm = current_analysis->pred_tab.symbol_put(p->name->getName()); toIgnore.push_back(nm); pred_decl * pd = new TIMpred_decl(nm,p->parameters,p->symtab); current_analysis->the_domain->predicates->push_front(pd); effect_lists * es = new effect_lists; effect_lists * ee = new effect_lists; timed_effect * ts = new timed_effect(es,E_AT_START); es->add_effects.push_front(new simple_effect(new proposition(nm,p->parameters))); timed_effect * te = new timed_effect(ee,E_AT_END); ee->del_effects.push_front(new simple_effect(new proposition(nm,p->parameters))); p->effects->timed_effects.push_front(ts); p->effects->timed_effects.push_front(te); timed_goal * tg = new timed_goal(new simple_goal(new proposition(nm,p->parameters),E_POS),E_OVER_ALL); if(p->precondition) { goal_list * gs = new goal_list; gs->push_front(tg); gs->push_front(p->precondition); conj_goal * cg = new conj_goal(gs); p->precondition = cg; } else { p->precondition = tg; } } else { timed_effect * t = p->effects->timed_effects.front(); p->effects->timed_effects.pop_front(); delete t; t = p->effects->timed_effects.front(); p->effects->timed_effects.pop_front(); delete t; replacePreconditionsOf = p; goal * oldprecondition = p->precondition; p->precondition->visit(this); delete oldprecondition; }; }; virtual void visit_domain(VAL::domain * p) { visit_operator_list(p->ops); }; }; struct CheckSV { vector<Property *> & sv; CheckSV(vector<Property*> & s) : sv(s) {}; void operator()(PropertySpace * ps) { ps->checkSV(sv); }; }; class TIMactionSymbol : public VAL::operator_symbol { private: vector<PropertySpace*> stateChanger; vector<TransitionRule*> rules; bool fixedDuration; public: TIMactionSymbol(const string & nm) : operator_symbol(nm), fixedDuration(false) {}; void addStateChanger(PropertySpace * ps,TransitionRule * tr) { stateChanger.push_back(ps); rules.push_back(tr); }; void write(ostream & o) const { o << name; if(fixedDuration) o << "!"; }; typedef vector<TransitionRule*>::const_iterator RCiterator; RCiterator begin() const {return rules.begin();}; RCiterator end() const {return rules.end();}; bool hasRuleFor(int prm) const; bool isFixedDuration() const { return fixedDuration; }; void assertFixedDuration() { fixedDuration = true; }; }; inline ostream & operator<<(ostream & o,const TIMactionSymbol & a) { a.write(o); return o; }; #define TAS(x) static_cast<TIM::TIMactionSymbol*>(x) #define TASc(x) static_cast<const TIM::TIMactionSymbol* const>(x) class TIMAnalyser : public VAL::VisitController { private: VAL::TypeChecker & tcheck; VAL::analysis * an; VAL::FuncAnalysis fan; bool adding; bool initially; bool finally; bool isDurative; bool atStart; bool overall; VAL::operator_ * op; VAL::derivation_rule * drv; vector<ProtoRule *> rules; TRules trules; vector<PropertySpace *> propspaces; vector<PropertySpace *> attrspaces; vector<PropertySpace *> staticspaces; vector<Property*> singleValued; void setUpSpaces(); static void assembleMutexes(PropertySpace *); static void recordRulesInActions(PropertySpace *); friend class doExamine; public: TIMAnalyser(VAL::TypeChecker & tc,VAL::analysis * a) : tcheck(tc), an(a), fan(a->func_tab), adding(true), initially(false), finally(false), isDurative(false), overall(false), op(0) ,drv(0) {}; VAL::TypeChecker & getTC() {return tcheck;}; void insertPre(int v,Property * p); void insertEff(int v,Property * p); void insertGoal(VAL::parameter_symbol * c,Property * p); void insertInitial(VAL::parameter_symbol * c,Property * p,VAL::proposition * prp); virtual void visit_simple_goal(VAL::simple_goal * p); virtual void visit_qfied_goal(VAL::qfied_goal * p) {OUTPUT cout << "Quantified goal\n";}; virtual void visit_conj_goal(VAL::conj_goal * p) {p->getGoals()->visit(this);}; virtual void visit_disj_goal(VAL::disj_goal * p) {OUTPUT cout << "Disjunctive goal\n";}; virtual void visit_timed_goal(VAL::timed_goal * p) { using namespace VAL1_2; if(p->getTime() == (atStart?E_AT_START:E_AT_END) || (overall && p->getTime()==E_OVER_ALL)) p->getGoal()->visit(this); }; virtual void visit_imply_goal(VAL::imply_goal * p) { OUTPUT cout << "Implication goal\n"; }; virtual void visit_neg_goal(VAL::neg_goal * p) { OUTPUT cout << "Negative goal\n"; }; virtual void visit_simple_effect(VAL::simple_effect * p); virtual void visit_simple_derivation_effect(VAL::derivation_rule * p); virtual void visit_forall_effect(VAL::forall_effect * p) { OUTPUT cout << "Quantified effect\n"; }; virtual void visit_cond_effect(VAL::cond_effect * p) { OUTPUT cout << "Conditional effect\n"; }; virtual void visit_timed_effect(VAL::timed_effect * p) { using namespace VAL1_2; if(p->ts==(atStart?E_AT_START:E_AT_END)) p->effs->visit(this); }; virtual void visit_effect_lists(VAL::effect_lists * p) { using namespace VAL1_2; p->add_effects.pc_list<simple_effect*>::visit(this); p->forall_effects.pc_list<forall_effect*>::visit(this); p->cond_effects.pc_list<cond_effect*>::visit(this); p->timed_effects.pc_list<timed_effect*>::visit(this); bool whatwas = adding; adding = !adding; p->del_effects.pc_list<simple_effect*>::visit(this); adding = whatwas; }; virtual void visit_derivation_rule(VAL::derivation_rule * p) { drv = p; adding = true; rules = vector<ProtoRule*>(p->get_head()->args->size(),0); p->get_body()->visit(this); visit_simple_derivation_effect(p); for_each(rules.begin(),rules.end(),processRule(trules)); drv = 0; }; virtual void visit_operator_(VAL::operator_ * p) { op = p; adding = true; rules = vector<ProtoRule*>(p->parameters->size(),0); p->precondition->visit(this); p->effects->visit(this); for_each(rules.begin(),rules.end(),processRule(trules)); op = 0; }; virtual void visit_action(VAL::action * p) { visit_operator_(p); } virtual void visit_durative_action(VAL::durative_action * p) { // I think that we can do this in two stages - the at start and the at end. // We can have a filter on timed goals and effects that decides whether it // is relevant. Might need to store an optype flag with op, so that we can // tell whether we generated from a start or end point. // // The tricky bit is the linkage: we need record invariants and we also need // to ensure that we don't lose state change across durative actions. Toni's // idea is to have a dummy add effect at start that is preconditioned and deleted // at the end. That should work, but needs a couple of tweaks: // 1: If the action has several state change effects then this technique will leave // them linked together in one state space. Not entirely clear how these could be // split, but maybe we can use a technique that generalises the state splitting // idea (ab->c, c->ab becomes a->c, c->a and b->c', c'->b). // 2: The mechanism artificially creates increasing/decreasing effects if there was // actually no property that was unlinked before introducing the dummies. We can // filter these cases out, I think. // isDurative = true; atStart = true; overall = false; visit_operator_(p); atStart = false; visit_operator_(p); overall = true; visit_operator_(p); overall = false; isDurative = false; }; virtual void visit_domain(VAL::domain * p) { visit_operator_list(p->ops); if (p->drvs) visit_derivations_list(p->drvs); setUpSpaces(); }; virtual void visit_problem(VAL::problem * p) { initially = true; p->initial_state->visit(this); initially = false; finally = true; if(p->the_goal) p->the_goal->visit(this); finally = false; if(p->objects) p->objects->visit(this); for_each(propspaces.begin(),propspaces.end(),&sortObjects); vector<PropertySpace*>::iterator a = partition(propspaces.begin(),propspaces.end(), mem_fun(&PropertySpace::isState)); copy(a,propspaces.end(),inserter(attrspaces,attrspaces.begin())); propspaces.erase(a,propspaces.end()); a = partition(propspaces.begin(),propspaces.end(), not1(mem_fun(&PropertySpace::isStatic))); copy(a,propspaces.end(),inserter(staticspaces,staticspaces.end())); propspaces.erase(a,propspaces.end()); while(for_each(attrspaces.begin(),attrspaces.end(),doExtension())); while(for_each(propspaces.begin(),propspaces.end(),doExtension())); OUTPUT1 { for_each(trules.begin(),trules.end(),ptrwriter<TransitionRule>(cout,"\n")); for_each(propspaces.begin(),propspaces.end(), ptrwriter<PropertySpace>(cout,"\n")); }; for_each(propspaces.begin(),propspaces.end(),assembleMutexes); for_each(propspaces.begin(),propspaces.end(),recordRulesInActions); attrspaces = for_each(attrspaces.begin(),attrspaces.end(),doExamine(this)); OUTPUT1 { cout << "Spaces now look like this:\n"; for_each(propspaces.begin(),propspaces.end(), ptrwriter<PropertySpace>(cout,"\n")); }; }; virtual void visit_const_symbol(VAL::const_symbol * p) { TIMobjectSymbol * t = dynamic_cast<TIMobjectSymbol*>(p); t->distributeStates(this); }; void checkSV() { for_each(propspaces.begin(),propspaces.end(),CheckSV(singleValued)); }; set<PropertySpace *> relevant(VAL::pddl_type * tp); void close(set<Property*> & seed,const VAL::pddl_type * pt); typedef vector<PropertySpace *>::const_iterator const_iterator; const_iterator pbegin() const {return propspaces.begin();}; const_iterator pend() const {return propspaces.end();}; const_iterator abegin() const {return attrspaces.begin();}; const_iterator aend() const {return attrspaces.end();}; const_iterator sbegin() const {return staticspaces.begin();}; const_iterator send() const {return staticspaces.end();}; }; class mutex; struct mRec { Property * first; int second; opType opt; mRec(Property * x,int y,opType z) : first(x), second(y), opt(z) {}; bool operator<(const mRec & m) const { return (first < m.first || (first == m.first && second < m.second) || opt < m.opt); }; }; struct pairWith { int v; opType oo; pairWith(int x,opType o) : v(x), oo(o) {}; mRec operator() (Property * o) { return mRec(o,v,oo); }; }; class MutexStore { private: typedef map<VAL::operator_ *,mutex *> MutexRecord; MutexRecord mutexes; // These are the enablers set<mRec> enablers; set<mRec> conditions; // These are the invariants set<mRec> invariants; public: virtual ~MutexStore() {}; mutex * getMutex(VAL::operator_ * o); void showMutexes(); template<class TI> void add(TI s,TI e,int v,opType o) { transform(s,e,inserter(enablers,enablers.begin()),pairWith(v,o)); }; void addCondition(Property * p,int v,opType o) { conditions.insert(mRec(p,v,o)); }; void addInvariant(Property * p,int v) { invariants.insert(mRec(p,v,MIDDLE)); }; void additionalMutexes(); }; #define MEX(x) dynamic_cast<TIM::MutexStore *>(x) class TIMaction : public VAL::action, public MutexStore { public: TIMaction(VAL::operator_symbol* nm, VAL::var_symbol_list* ps, VAL::goal* pre, VAL::effect_lists* effs, VAL::var_symbol_table* st) : action(nm,ps,pre,effs,st) {}; }; #define TAc(x) static_cast<TIM::TIMaction*>(x) class TIMdurativeAction : public VAL::durative_action, public MutexStore { public: bool isFixedDuration() const { return static_cast<TIMactionSymbol*>(name)->isFixedDuration(); }; }; #define TDA(x) dynamic_cast<TIM::TIMdurativeAction*>(x) void showMutex(VAL::operator_ * op); void completeMutexes(VAL::operator_ * op); /* MUTEX RELATIONSHIPS: * * As, Am, Ae, Bs, Bm, Be: * * AsxBs, AsxBm, AsxBe 1 2 3 * AmxBs, AmxBm, AmxBe 4 5 6 * AexBs, AexBm, AexBe 7 8 9 * */ enum MutexTypes { NONE = 0,START_START = 1, START_MID = 2, START_END = 4, MID_START = 8, MID_MID = 16, MID_END = 32, END_START = 64, END_MID = 128, END_END = 256}; struct mutRec { int first; int second; opType one; opType other; mutRec(int a,int b,opType x = INSTANT,opType y = INSTANT) : first(a), second(b), one(x), other(y) {}; bool operator==(const mutRec & m) const { return first == m.first && second == m.second && one == m.one && other == m.other; }; bool operator!=(const mutRec & m) const { return !(*this == m); }; bool operator<(const mutRec & m) const { return (first < m.first || (first == m.first && (second < m.second || (second == m.second && (one < m.one || (one == m.one && other < m.other)))))); }; }; template<class TI> TI getIx(TI s,int x) { while(x > 0) { ++s; --x; }; return s; }; class mutex { private: VAL::operator_ * op1; VAL::operator_ * op2; set<mutRec> argPairs; public: mutex(VAL::operator_ * o1,VAL::operator_ * o2) : op1(o1), op2(o2) {}; static void constructMutex(VAL::operator_ * o1,int a1,VAL::operator_ * o2,int a2, opType t1 = INSTANT,opType t2 = INSTANT) { OUTPUT cout << "Adding a mutex between " << o1->name->getName() << ":" << a1 << " and " << o2->name->getName() << ":" << a2 << "\n"; mutex * m = MEX(o1)->getMutex(o2); // This condition ensures that we don't store the same mutex pair in both orders // when they are arguments for the same operator. This is good if we are going to // use the pairs for checking, but it could be less good if we want to check whether // a specific pair of op-args are mutex. if(o1==o2) { int a = min(a1,a2); if(a2 == a) { opType t3 = t1; t1 = t2; t2 = t3; }; a2 = max(a1,a2); a1 = a; } else if(m->op2==o1) { int a = a1; a1 = a2; a2 = a; opType t = t1; t1 = t2; t2 = t; }; if(m->argPairs.find(mutRec(a1,a2,t1,t2)) == m->argPairs.end()) { // cout << "Inserting " << a1 << ":" << a2 << "\n"; m->argPairs.insert(mutRec(a1,a2,t1,t2)); }; }; void write(ostream & o) const; template<class TI> unsigned int getMutexes(VAL::operator_* A,TI sa,TI ea,TI sb,TI eb) { unsigned int ms = NONE; if(A==op2) { TI x = sa; sa = sb; sb = x; x = ea; ea = eb; eb = x; }; for(set<mutRec>::const_iterator i = argPairs.begin();i != argPairs.end();++i) { if(*(getIx(sa,i->first))==*(getIx(sb,i->second))) { // cout << "Mutex for " << i->first << " " << **(getIx(sa,i->first)) << " and " << i->second // << " " << **(getIx(sb,i->second)) << " " << i->one << " " << i->other << " " << 3*(i->one?i->one:1)+(i->other?i->other:1) // << "\n"; ms |= 1 << 3*(i->one?i->one-1:0)+(i->other?i->other-1:0); }; }; return ms; }; template<class TI> bool selfMutex(TI sa,TI ea) { for(set<mutRec>::const_iterator i = argPairs.begin();i != argPairs.end();++i) { if(i->first != i->second && *(getIx(sa,i->first))==*(getIx(sa,i->second))) { return true; }; }; return false; }; }; inline ostream & operator<<(ostream & o,const mutex & m) { m.write(o); return o; }; template<class TI> unsigned int getMutexes(VAL::operator_ * A,TI sa,TI ea,VAL::operator_ * B,TI sb,TI eb) { return MEX(A)->getMutex(B)->getMutexes(A,sa,ea,sb,eb); }; template<class TI> bool isMutex(const VAL::pred_symbol * pa,TI sa,TI ea,const VAL::pred_symbol * pb,TI sb,TI eb) { return cTPS(pa)->checkMutex(sa,ea,cTPS(pb),sb,eb); }; template<class TI> bool selfMutex(const VAL::operator_ * op,TI sa,TI ea) { TIM::MutexStore * tm = MEX(const_cast<VAL::operator_ *>(op)); if(tm) { return tm->getMutex(const_cast<VAL::operator_*>(op))->selfMutex(sa,ea); } else { return false; }; }; class TIMfactory : public VAL::StructureFactory { public: virtual VAL::action * buildAction(VAL::operator_symbol* nm, VAL::var_symbol_list* ps, VAL::goal* pre, VAL::effect_lists* effs, VAL::var_symbol_table* st) {return new TIMaction(nm,ps,pre,effs,st);}; virtual VAL::durative_action * buildDurativeAction() { return new TIMdurativeAction(); }; }; }; #endif
26.13125
128
0.665391
b0a60accdab96b8102bc1dcff727e1e34b3417d9
1,243
h
C
samples/client/petstore/c/api/UserAPI.h
MalcolmScoffable/openapi-generator
73605a0c0e0c825286c95123c63678ba75b44d5c
[ "Apache-2.0" ]
11,868
2018-05-12T02:58:07.000Z
2022-03-31T21:19:39.000Z
samples/client/petstore/c/api/UserAPI.h
MalcolmScoffable/openapi-generator
73605a0c0e0c825286c95123c63678ba75b44d5c
[ "Apache-2.0" ]
9,672
2018-05-12T14:25:43.000Z
2022-03-31T23:59:30.000Z
samples/client/petstore/c/api/UserAPI.h
MalcolmScoffable/openapi-generator
73605a0c0e0c825286c95123c63678ba75b44d5c
[ "Apache-2.0" ]
4,776
2018-05-12T12:06:08.000Z
2022-03-31T19:52:51.000Z
#include <stdlib.h> #include <stdio.h> #include "../include/apiClient.h" #include "../include/list.h" #include "../external/cJSON.h" #include "../include/keyValuePair.h" #include "../include/binary.h" #include "../model/user.h" // Create user // // This can only be done by the logged in user. // void UserAPI_createUser(apiClient_t *apiClient, user_t * body ); // Creates list of users with given input array // void UserAPI_createUsersWithArrayInput(apiClient_t *apiClient, list_t * body ); // Creates list of users with given input array // void UserAPI_createUsersWithListInput(apiClient_t *apiClient, list_t * body ); // Delete user // // This can only be done by the logged in user. // void UserAPI_deleteUser(apiClient_t *apiClient, char * username ); // Get user by user name // user_t* UserAPI_getUserByName(apiClient_t *apiClient, char * username ); // Logs user into the system // char* UserAPI_loginUser(apiClient_t *apiClient, char * username , char * password ); // Logs out current logged in user session // void UserAPI_logoutUser(apiClient_t *apiClient); // Updated user // // This can only be done by the logged in user. // void UserAPI_updateUser(apiClient_t *apiClient, char * username , user_t * body );
19.123077
78
0.726468
e6dd657b4e760785bd28560224a92caad7eee5fd
4,887
h
C
c3/lib_funcs/monitoring.h
goroda/Compressed-Continuous-Computation
ecfa401306457b9476c0252dc9cc086ec3fdacfb
[ "BSD-3-Clause" ]
45
2017-03-01T18:53:31.000Z
2022-03-12T21:08:03.000Z
c3/lib_funcs/monitoring.h
goroda/Compressed-Continuous-Computation
ecfa401306457b9476c0252dc9cc086ec3fdacfb
[ "BSD-3-Clause" ]
10
2015-12-18T15:50:09.000Z
2022-02-22T23:49:15.000Z
c3/lib_funcs/monitoring.h
goroda/Compressed-Continuous-Computation
ecfa401306457b9476c0252dc9cc086ec3fdacfb
[ "BSD-3-Clause" ]
10
2016-09-18T19:46:27.000Z
2021-11-24T01:58:02.000Z
// Copyright (c) 2015-2016, Massachusetts Institute of Technology // Copyright (c) 2016-2017 Sandia Corporation // Copyright (c) 2017 NTESS, LLC. // This file is part of the Compressed Continuous Computation (C3) Library // Author: Alex A. Gorodetsky // Contact: alex@alexgorodetsky.com // All rights reserved. // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // 3. Neither the name of the copyright holder nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //Code /** \file monitoring.h * Provides header files and structure definitions for functions in monitoring.c */ #ifndef MONITORING_H #define MONITORING_H #include <stdlib.h> #include <stdio.h> /////////////////////////////////////// /** \struct FunctionMonitor * \brief Utility to store / recall function evaluations * \var FunctionMonitor::ftype * 0 for multidimensional functions, 1 for one dimensional functions, 2 for two * dimensional functions * \var FunctionMonitor::dim * dimension of function * \var FunctionMonitor::f * function to monitor * \var FunctionMonitor::args * function arguments * \var FunctionMonitor::evals * hashmap which stores evaluations */ struct FunctionMonitor { int ftype; size_t dim; union ff { double (*fnd)(const double *, void *); //ftype = 0 double (*f1d)(double, void *);// ftype = 1 double (*f2d)(double, double, void *); // ftype = 2 } f; void * args; struct HashtableCpair * evals; }; struct FunctionMonitor * function_monitor_initnd( double (*)(const double *, void *), void *, size_t, size_t); void function_monitor_free(struct FunctionMonitor *); double function_monitor_eval(const double *, void *); void function_monitor_print_to_file(struct FunctionMonitor *, FILE *); struct storevals_main { int nEvals; struct storevals * head; }; struct storevals { size_t dim; double * x; double f; struct storevals * next; }; void PushVal(struct storevals **, size_t , double *, double); void PrintVals2d(FILE *, struct storevals *); void DeleteStoredVals(struct storevals **); /** \struct Cpair * \brief A pair of chars * \var Cpair::a * first char * \var Cpair::b * second char */ struct Cpair { char * a; char * b; }; struct Cpair * cpair_create(char *, char *); struct Cpair * copy_cpair(struct Cpair *); void print_cpair(struct Cpair *); void cpair_free(struct Cpair *); int cpair_isequal(struct Cpair *, struct Cpair *); /** \struct PairList * \brief A linked-list of Cpair * \var PairList::data * a Cpair * \var PairList::next * pointer to next list item */ struct PairList { struct Cpair * data; struct PairList * next; }; void pair_push(struct PairList **, struct Cpair *); void print_pair_list(struct PairList *); void pair_list_delete(struct PairList **); size_t pair_list_len(struct PairList *); size_t pair_list_index(struct PairList *, struct Cpair *); /** \struct HashtableCpair * \brief a hashmap of Cpairs where the keys are strings and the valrs are Cpairs * \var HashtableCpair::size * size of the table * \var HashtableCpair::table * stored values */ struct HashtableCpair { size_t size; struct PairList ** table; }; struct HashtableCpair * create_hashtable_cp(size_t); char * lookup_key(struct HashtableCpair *, char *); int add_cpair(struct HashtableCpair *, struct Cpair *); void free_hashtable_cp(struct HashtableCpair *); size_t nstored_hashtable_cp(struct HashtableCpair *); size_t hashsimple(size_t, char *); #endif
29.089286
85
0.718232
52f67a1e43cb404734644aed93891a4e4e7dd6b1
5,177
c
C
csci4061/111620_breakout/program.c
RosstheRoss/TestingFun
7a73162607544204032aa66cce755daf21edebda
[ "0BSD" ]
null
null
null
csci4061/111620_breakout/program.c
RosstheRoss/TestingFun
7a73162607544204032aa66cce755daf21edebda
[ "0BSD" ]
null
null
null
csci4061/111620_breakout/program.c
RosstheRoss/TestingFun
7a73162607544204032aa66cce755daf21edebda
[ "0BSD" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <pthread.h> #define MATSIZE 5000 int mat1[MATSIZE][MATSIZE]; int mat2[MATSIZE][MATSIZE]; typedef struct argstruct { int x_start; int x_end; int y_start; int y_end; int** res_mat; } args_t; int getX_start(int i) { return (i % 2) * MATSIZE / 2; } int getY_start(int i) { return ((i < 2) ? 0 : 1) * MATSIZE / 2; } //TODO: Complete this function (to be accessed by a thread) which will // perform matrix addition on a portion of a matrix, dictated by // the input parameter 'args' void * partial_matrix_add(void * args) { int **dest; args_t *input = (struct argstruct *) args; // params can be accessed using input pointer dest = input->res_mat; //can be accessed as dest[][] now // Todo: Your code goes here (for reference checkout the pseudo code in the slides) for (int i=input->x_start; i<input->x_end; i++) { for (int j=input->y_start; j<input->y_end; j++) { dest[i][j] = mat1[i][j]*mat2[i][j]; } } return NULL; } int main() { // to store mulitple dispatcher threads pthread_t m_threads[4]; // to store single default thread pthread_t s_thread; // variable to pass values to multiple thread multiplication args_t m_args[4]; //variable to pass values to single thread muliplication args_t s_args; /** * initializing matrices for sinlge and multiple matrix multiplication */ int i, j, k, c; struct timeval t_multi_start, t_multi_end, t_single_start, t_single_end; int ** res_mat_multi = malloc(MATSIZE * sizeof(int *)); int ** res_mat_single = malloc(MATSIZE * sizeof(int *)); for(i = 0; i < MATSIZE; i++) { res_mat_multi[i] = malloc(MATSIZE * sizeof(int)); res_mat_single[i] = malloc(MATSIZE * sizeof(int)); } //Populate base matrices with random integers //Initialize result matrices with -1 for(j = 0; j < MATSIZE; j++) { for(k = 0; k < MATSIZE; k++) { mat1[j][k] = rand() % 1000 + 1; mat2[j][k] = rand() % 1000 + 1; res_mat_multi[j][k] = -1; res_mat_single[j][k] = -1; } } //Version 1 ************************************************************************** //Measure time for multiple thread addition gettimeofday(&t_multi_start, NULL); //Todo: create attribute for detached threads //Create mulitple threads to populate res_mat_multi with the result // of performing matrix addition mat1 + mat2 for(i = 0; i < 4; i++) { int x_start = getX_start(i); int y_start = getY_start(i); int x_end = x_start + MATSIZE/2; int y_end = y_start + MATSIZE/2; m_args[i].res_mat = res_mat_multi; //your code goes here //Todo:Create m_agrs using x_start, x_end, y_start, y_end, and create detached threads m_args[i].x_start = x_start; m_args[i].x_end = x_end; m_args[i].y_start = y_start; m_args[i].y_end = y_end; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&m_threads[i], &attr, partial_matrix_add, (void *) &m_args[i]); } gettimeofday(&t_multi_end, NULL); //Version 2 ************************************************************************* //Measure time for single thread addition gettimeofday(&t_single_start, NULL); // Create single thread to populate res_mat_multi with the result // of performing matrix addition mat1 + mat2 int x_start = 0; int x_end = MATSIZE; int y_start = 0; int y_end = MATSIZE; s_args.res_mat = res_mat_single; //your code goes here //Todo: Assign values to s_args using x_start, y_start etc. s_args.x_start = x_start; s_args.y_start = y_start; s_args.x_end = x_end; s_args.y_end = y_end; //Todo:Create thread pthread_create(&s_thread, NULL, partial_matrix_add, (void *) &s_args); //Todo:join thread pthread_join(s_thread, NULL); gettimeofday(&t_single_end, NULL); // ********************************************************************************** //Don't change anything from here //Test to ensure that both methods produce the same result c = 0; for(j = 0; j < MATSIZE; j++) { for(k = 0; k < MATSIZE; k++) { if(res_mat_multi[j][k] == res_mat_single[j][k] && res_mat_multi[j][k] != -1) { c++; } } } printf("Verification: %d out of %d entries matched.\n", c, MATSIZE * MATSIZE); //Display time for each version double time_taken; time_taken = (t_multi_end.tv_sec - t_multi_start.tv_sec) * 1e6; time_taken = (time_taken + (t_multi_end.tv_usec - t_multi_start.tv_usec)) * 1e-6; printf("Time for multiple threads: %f seconds\n", time_taken); time_taken = (t_single_end.tv_sec - t_single_start.tv_sec) * 1e6; time_taken = (time_taken + (t_single_end.tv_usec - t_single_start.tv_usec)) * 1e-6; printf("Time for single thread: %f seconds\n", time_taken); return 0; }
33.185897
95
0.597257
74cb5cffbfedd4bf4ce4793b3aa7c28d766bab33
804
h
C
System/Library/PrivateFrameworks/ShazamInsights.framework/ShazamInsights.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
5
2021-04-29T04:31:43.000Z
2021-08-19T18:59:58.000Z
System/Library/PrivateFrameworks/ShazamInsights.framework/ShazamInsights.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/ShazamInsights.framework/ShazamInsights.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
1
2022-03-19T11:16:23.000Z
2022-03-19T11:16:23.000Z
#import <ShazamInsights/SHInsightsBag.h> #import <ShazamInsights/SHDataStoreMetadata.h> #import <ShazamInsights/SHRegion.h> #import <ShazamInsights/SHAffinityGroupQuery.h> #import <ShazamInsights/SHNetworkRequester.h> #import <ShazamInsights/SHFileReader.h> #import <ShazamInsights/SHLouvainClusterImport.h> #import <ShazamInsights/SHInsightsPersistenceController.h> #import <ShazamInsights/SHCDNDataFetcher.h> #import <ShazamInsights/SHDateGeohashServerResponseParser.h> #import <ShazamInsights/SHRegionAffinityGroup.h> #import <ShazamInsights/SHAffinityGroup.h> #import <ShazamInsights/SHLouvainClusterDataStore.h> #import <ShazamInsights/SHInsightsError.h> #import <ShazamInsights/SHLouvainClusterQuery.h> #import <ShazamInsights/SHTargetingMetadataMO.h> #import <ShazamInsights/SHTargetingTrackMO.h>
44.666667
60
0.85199
50ef658c8452d40f5b62dc2db92fd17dd5c07baf
1,262
c
C
codes/ch6/ex04/table.c
RyanJeong/C_KNR
4b0676b362c82c05e4d94decaa15f59a435c2f72
[ "MIT" ]
null
null
null
codes/ch6/ex04/table.c
RyanJeong/C_KNR
4b0676b362c82c05e4d94decaa15f59a435c2f72
[ "MIT" ]
9
2020-03-14T08:29:23.000Z
2021-11-29T10:53:01.000Z
codes/ch6/ex04/table.c
RyanJeong/C_KNR
4b0676b362c82c05e4d94decaa15f59a435c2f72
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "table.h" char *strdup(char *s); struct nlist *hashtab[HASHSIZE]; /* pointer table */ /* hash: form hash value for string s */ unsigned hash(char *s) { unsigned hashval; for (hashval = 0; *s != '\0'; s++) { hashval = *s + 31 * hashval; } return hashval % HASHSIZE; } /* lookup: look for s in hashtab */ struct nlist *lookup(char *s) { struct nlist *np; for (np = hashtab[hash(s)]; np != NULL; np = np->next) { if (!strcmp(s, np->name)) { return np; /* found */ } } return NULL; /* not found */ } /* install: put (name, defn) in hashtab */ struct nlist *install(char *name, char *defn) { struct nlist *np; unsigned hashval; if (!(np = lookup(name))) { /* not found */ np = (struct nlist *) malloc(sizeof(*np)); if (!np || !(np->name = strdup(name))) { return NULL; } hashval = hash(name); np->next = hashtab[hashval]; hashtab[hashval] = np; } else { /* already there */ free((void *) np->defn); /* free previous defn */ } if (!(np->defn = strdup(defn))) { return NULL; } return np; }
20.688525
60
0.518225
c1f718dcfede0d15082b08c57e25a09a01051aa3
8,633
h
C
src/lib/taskscheduler/Task.h
jmarten/hyrise
795d8c1c55ed6cbd313d88cee40610006fa85669
[ "MIT" ]
null
null
null
src/lib/taskscheduler/Task.h
jmarten/hyrise
795d8c1c55ed6cbd313d88cee40610006fa85669
[ "MIT" ]
null
null
null
src/lib/taskscheduler/Task.h
jmarten/hyrise
795d8c1c55ed6cbd313d88cee40610006fa85669
[ "MIT" ]
null
null
null
// Copyright (c) 2012 Hasso-Plattner-Institut fuer Softwaresystemtechnik GmbH. All rights reserved. /* * Task.h * * Created on: Feb 14, 2012 * Author: jwust */ #pragma once #include <vector> #include <memory> #include <condition_variable> #include <string> #include "helper/locking.h" #include "helper/types.h" #include "taskscheduler/AbstractTaskScheduler.h" namespace hyrise { namespace taskscheduler { class Task; class AbstractTaskScheduler; class TaskReadyObserver { /* * notify that task has changed state */ public: virtual void notifyReady(const task_ptr_t& task) = 0; virtual ~TaskReadyObserver() {}; }; class TaskDoneObserver { /* * notify that task has changed state */ public: virtual void notifyDone(const task_ptr_t& task) = 0; virtual ~TaskDoneObserver() {}; }; /* * a task that can be scheduled by a Task Scheduler */ class Task : public TaskDoneObserver, public std::enable_shared_from_this<Task> { public: static const int DEFAULT_PRIORITY = 999; static const int HIGH_PRIORITY = 1; static const int NO_PREFERRED_CORE = -1; static const int NO_PREFERRED_NODE = -1; static const int SESSION_ID_NOT_SET = 0; // split up the operator in as many instances as indicated by dynamicCount virtual std::vector<task_ptr_t> applyDynamicParallelization(size_t dynamicCount); // determine the number of instances necessary to adhere to a max task size. // should be overridden in operators // currently all implementing operators are fine-tuned for server gaza. virtual size_t determineDynamicCount(size_t maxTaskRunTime) { return 1; } protected: std::vector<task_ptr_t> _dependencies; std::vector<std::weak_ptr<TaskReadyObserver>> _readyObservers; std::vector<std::weak_ptr<TaskDoneObserver>> _doneObservers; int _dependencyWaitCount; // mutex for dependencyCount and dependency vector mutable hyrise::locking::Spinlock _depMutex; // mutex for observer vector and _notifiedDoneObservers. mutable hyrise::locking::Spinlock _observerMutex; // indicates if notification of done observers already took place --> task is finised. bool _notifiedDoneObservers = false; // mutex to stop notifications, while task is being scheduled to wait set in SimpleTaskScheduler // hyrise::locking::Spinlock _notifyMutex; // indicates on which core the task should run int _preferredCore; // indicates on which node the task should run int _preferredNode; // indicates on which node the task should run int _actualNode; // priority int _priority; // sessionId int _sessionId; // id - equals transaction id int _id; // if true, the DynamicPriorityScheduler will determine the number of instances. bool _dynamic = false; std::shared_ptr<AbstractTaskScheduler> _scheduler; public: Task(); virtual ~Task() {}; virtual void operator()() {}; /* * currently, only Response Task overrides this function; */ virtual double getQueryDuration() const { return 0; } /* Workaround that allows to retrieve the name of a task during runtime, since there is no way to call the static member function name() that we use for the plan op factory. name is assumed to be unique */ virtual const std::string vname() = 0; /* * if tasks rae waiting for this task to finish */ bool hasSuccessors(); /* * adds dependency; the task is ready to run if all tasks this tasks depends on are finished * If dependency is done, it will not increase the dependencyWaitCount. * This fixes the problem of tasks waiting for their final done notification indefinitely. */ void addDependency(const task_ptr_t& dependency); /* * adds dependency, but do not increase dependencyWaitCount or register as DoneObserver, as dependency is known to be * done */ void addDoneDependency(const task_ptr_t& dependency); /* * removes dependency; */ void removeDependency(const task_ptr_t& dependency); /* * change dependency; */ void changeDependency(const task_ptr_t& from, const task_ptr_t& to); /* * gets the number of dependencies */ int getDependencyCount(); /* * check if the supplied task is a direct dependency of this task. */ bool isDependency(const task_ptr_t& task); /* * adds an observer that gets notified if this task is ready to run */ void addReadyObserver(const std::shared_ptr<TaskReadyObserver>& observer); /* * adds an observer that gets notified if this task is done * returns true, if done observer was added since the task was not finished. * returns false, if done observer was not added since the task has already been finished. */ bool addDoneObserver(const std::shared_ptr<TaskDoneObserver>& observer); /* * Returns all successors of the specified type T. */ template <typename T> const std::vector<std::shared_ptr<T>> getAllSuccessorsOf() const { std::vector<std::weak_ptr<TaskDoneObserver>> targets; { std::lock_guard<decltype(_observerMutex)> lk(_observerMutex); targets = _doneObservers; } std::vector<std::shared_ptr<T>> result; for (auto& target : targets) { if (auto successor = target.lock()) { if (auto typedSuccessor = std::dynamic_pointer_cast<T>(successor)) { result.push_back(typedSuccessor); } } } return result; } /* * Get first predecessor of type T. Throws exception if none is found. */ template <typename T> std::shared_ptr<T> getFirstPredecessorOf() const { std::vector<std::shared_ptr<Task>> targets; { std::lock_guard<decltype(this->_depMutex)> lk(_depMutex); targets = _dependencies; } for (auto target : targets) { if (auto typed_target = std::dynamic_pointer_cast<T>(target)) { return typed_target; } } throw std::runtime_error("Could not find any predecessor of requested type."); } /* * whether this task is ready to run / has open dependencies */ bool isReady(); /* * notify that task is done */ void notifyDone(const task_ptr_t& task); /* * notify all ready observers that task is ready */ void notifyReadyObservers(); /* * notify all done observers that task is done */ void notifyDoneObservers(); /* * specify preferred core for task */ void setPreferredCore(int core); /* * get preferred core for this task */ int getPreferredCore(); /* * block task for notifications -> used e.g., when task is moved into wait set of scheduler */ void lockForNotifications(); void unlockForNotifications(); int getActualNode() const { return _actualNode; } void setActualNode(int actualNode) { _actualNode = actualNode; } int getPreferredNode() const { return _preferredNode; } void setPreferredNode(int preferredNode) { _preferredNode = preferredNode; } int getPriority() const { return _priority; } void setPriority(int priority) { this->_priority = priority; } int getId() const { return _id; } void setId(int id) { this->_id = id; } int getSessionId() const { return _sessionId; } void setSessionId(int sessionId) { _sessionId = sessionId; } // used in the DynamicPriorityScheduler // if true and task is ParallizablePlanOperation the number of instances is determined // by an operators determineDynamicCount operation. void setDynamic(bool dynamic) { _dynamic = dynamic; } bool isDynamic() { return _dynamic; } void setScheduler(std::shared_ptr<AbstractTaskScheduler> scheduler) { _scheduler = scheduler; } }; class CompareTaskPtr { public: bool operator()(const task_ptr_t& t1, const task_ptr_t& t2) // Returns true if t1 is lower priority than t2 { if (t1->getPriority() > t2->getPriority()) return true; else if ((t1->getPriority() == t2->getPriority()) && t1->getId() > t2->getId()) return true; else return false; }; }; class WaitTask : public Task { private: bool _finished; hyrise::locking::Spinlock _mut; std::condition_variable_any _cond; public: WaitTask(); virtual ~WaitTask() {}; virtual void operator()(); void wait(); const std::string vname() { return "WaitTask"; }; }; class SleepTask : public Task { private: int _microseconds; public: explicit SleepTask(int microseconds); virtual ~SleepTask() {}; virtual void operator()(); const std::string vname() { return "SleepTask"; }; }; class SyncTask : public Task { public: SyncTask() {}; virtual ~SyncTask() {}; virtual void operator()(); const std::string vname() { return "SyncTask"; }; }; } } // namespace hyrise::taskscheduler
28.398026
119
0.700799
ee4e874c815388ca6257919816d7966b239fe204
745
c
C
SORTING/TUGASdiKelas/selection/main.c
RandyDz/ASD
f3704eadbc0bae26c72f117827381053b8e00eb1
[ "MIT" ]
null
null
null
SORTING/TUGASdiKelas/selection/main.c
RandyDz/ASD
f3704eadbc0bae26c72f117827381053b8e00eb1
[ "MIT" ]
null
null
null
SORTING/TUGASdiKelas/selection/main.c
RandyDz/ASD
f3704eadbc0bae26c72f117827381053b8e00eb1
[ "MIT" ]
null
null
null
#include <stdio.h> //SELECTION void tukar(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } void selection_sort(int array[], int size){ for(int step=0; step < size-1; step++){ int min_idx = step; for (int i = step+1; i<size; i++){ if(array[i]<array[min_idx]) min_idx = i; } tukar(&array[min_idx],&array[step]); } } void cetakArray(int array[], int size){ for(int i=0; i<size; ++i){ printf("%d ",array[i]); } printf("\n"); } int main(){ int data[]= {23, 67, 89, 5, 45, 20, 15, 27}; int size = sizeof(data)/sizeof(data[0]); selection_sort(data, size); printf("Data setelah diurutkan (selection) :\n"); cetakArray(data,size); }
21.911765
53
0.527517
679719051df5bdfa70569ead1291e9206604ce6a
1,171
h
C
arch/arm/mach-omap2/common-board-devices.h
tuxafgmur/OLD_Dhollmen_Kernel
90ed4e2e3e6321de246fa193705ae40ede4e2d8e
[ "BSD-Source-Code" ]
4
2016-07-01T04:50:02.000Z
2021-11-14T21:29:42.000Z
arch/arm/mach-omap2/common-board-devices.h
tuxafgmur/OLD_Dhollmen_Kernel
90ed4e2e3e6321de246fa193705ae40ede4e2d8e
[ "BSD-Source-Code" ]
null
null
null
arch/arm/mach-omap2/common-board-devices.h
tuxafgmur/OLD_Dhollmen_Kernel
90ed4e2e3e6321de246fa193705ae40ede4e2d8e
[ "BSD-Source-Code" ]
1
2020-04-03T14:00:39.000Z
2020-04-03T14:00:39.000Z
#ifndef __OMAP_COMMON_BOARD_DEVICES__ #define __OMAP_COMMON_BOARD_DEVICES__ #define NAND_BLOCK_SIZE SZ_128K struct twl4030_platform_data; struct mtd_partition; void omap_pmic_init(int bus, u32 clkrate, const char *pmic_type, int pmic_irq, struct twl4030_platform_data *pmic_data); static inline void omap2_pmic_init(const char *pmic_type, struct twl4030_platform_data *pmic_data) { omap_pmic_init(2, 2600, pmic_type, INT_24XX_SYS_NIRQ, pmic_data); } static inline void omap3_pmic_init(const char *pmic_type, struct twl4030_platform_data *pmic_data) { omap_pmic_init(1, 2600, pmic_type, INT_34XX_SYS_NIRQ, pmic_data); } static inline void omap4_pmic_init(const char *pmic_type, struct twl4030_platform_data *pmic_data) { /* Phoenix Audio IC needs I2C1 to start with 400 KHz or less */ omap_pmic_init(1, 400, pmic_type, OMAP44XX_IRQ_SYS_1N, pmic_data); } struct ads7846_platform_data; void omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce, struct ads7846_platform_data *board_pdata); void omap_nand_flash_init(int opts, struct mtd_partition *parts, int n_parts); #endif /* __OMAP_COMMON_BOARD_DEVICES__ */
30.815789
78
0.796755
e5ac461839f04cd15117b1fccaa198275be9a97d
7,498
h
C
headers/libxml2/libxml/xpath.h
mwichmann/lsb-buildenv
7a7eb64b5960172e0032e7202aeb454e076880fa
[ "BSD-3-Clause" ]
null
null
null
headers/libxml2/libxml/xpath.h
mwichmann/lsb-buildenv
7a7eb64b5960172e0032e7202aeb454e076880fa
[ "BSD-3-Clause" ]
null
null
null
headers/libxml2/libxml/xpath.h
mwichmann/lsb-buildenv
7a7eb64b5960172e0032e7202aeb454e076880fa
[ "BSD-3-Clause" ]
null
null
null
#if (__LSB_VERSION__ >= 31 ) #ifndef _LIBXML2_LIBXML_XPATH_H_ #define _LIBXML2_LIBXML_XPATH_H_ #include <libxml2/libxml/xmlstring.h> #include <libxml2/libxml/tree.h> #include <libxml2/libxml/xmlerror.h> #include <libxml2/libxml/dict.h> #include <libxml2/libxml/entities.h> #include <libxml2/libxml/hash.h> #include <libxml2/libxml/xmlIO.h> #ifdef __cplusplus extern "C" { #endif #define xmlXPathNodeSetItem(ns,index) \ ((((ns) != NULL) && ((index) >= 0) && ((index) < (ns)->nodeNr)) ? \ (ns)->nodeTab[(index)] : NULL) #define xmlXPathNodeSetIsEmpty(ns) \ (((ns) == NULL) || ((ns)->nodeNr == 0) || ((ns)->nodeTab == NULL)) #define xmlXPathNodeSetGetLength(ns) ((ns) ? (ns)->nodeNr : 0) #define XML_XPATH_CHECKNS (1<<0) #define XML_XPATH_NOVAR (1<<1) typedef struct _xmlXPathCompExpr xmlXPathCompExpr; typedef xmlXPathCompExpr *xmlXPathCompExprPtr; typedef enum { XPATH_UNDEFINED = 0, XPATH_NODESET = 1, XPATH_BOOLEAN = 2, XPATH_NUMBER = 3, XPATH_STRING = 4, XPATH_POINT = 5, XPATH_RANGE = 6, XPATH_LOCATIONSET = 7, XPATH_USERS = 8, XPATH_XSLT_TREE = 9 } xmlXPathObjectType; typedef struct _xmlNodeSet xmlNodeSet; typedef xmlNodeSet *xmlNodeSetPtr; typedef struct _xmlXPathObject xmlXPathObject; typedef xmlXPathObject *xmlXPathObjectPtr; typedef int (*xmlXPathConvertFunc) (xmlXPathObjectPtr, int); typedef struct _xmlXPathType xmlXPathType; typedef xmlXPathType *xmlXPathTypePtr; typedef struct _xmlXPathContext xmlXPathContext; typedef xmlXPathContext *xmlXPathContextPtr; typedef struct _xmlXPathParserContext xmlXPathParserContext; typedef xmlXPathParserContext *xmlXPathParserContextPtr; typedef xmlXPathObjectPtr(*xmlXPathAxisFunc) (xmlXPathParserContextPtr, xmlXPathObjectPtr); typedef struct _xmlXPathAxis xmlXPathAxis; typedef xmlXPathAxis *xmlXPathAxisPtr; typedef xmlXPathObjectPtr(*xmlXPathVariableLookupFunc) (void *, const xmlChar *, const xmlChar *); typedef void (*xmlXPathFunction) (xmlXPathParserContextPtr, int); typedef xmlXPathFunction(*xmlXPathFuncLookupFunc) (void *, const xmlChar *, const xmlChar *); typedef enum { XPATH_EXPRESSION_OK = 0, XPATH_NUMBER_ERROR, XPATH_UNFINISHED_LITERAL_ERROR, XPATH_START_LITERAL_ERROR, XPATH_VARIABLE_REF_ERROR, XPATH_UNDEF_VARIABLE_ERROR, XPATH_INVALID_PREDICATE_ERROR, XPATH_EXPR_ERROR, XPATH_UNCLOSED_ERROR, XPATH_UNKNOWN_FUNC_ERROR, XPATH_INVALID_OPERAND, XPATH_INVALID_TYPE, XPATH_INVALID_ARITY, XPATH_INVALID_CTXT_SIZE, XPATH_INVALID_CTXT_POSITION, XPATH_MEMORY_ERROR, XPTR_SYNTAX_ERROR, XPTR_RESOURCE_ERROR, XPTR_SUB_RESOURCE_ERROR, XPATH_UNDEF_PREFIX_ERROR, XPATH_ENCODING_ERROR, XPATH_INVALID_CHAR_ERROR, XPATH_INVALID_CTXT } xmlXPathError; typedef void (*xmlXPathEvalFunc) (xmlXPathParserContextPtr, int); typedef struct _xmlXPathFunct xmlXPathFunct; typedef struct _xmlXPathVariable xmlXPathVariable; typedef xmlXPathVariable *xmlXPathVariablePtr; typedef xmlXPathFunct *xmlXPathFuncPtr; struct _xmlNodeSet { int nodeNr; int nodeMax; xmlNodePtr *nodeTab; }; struct _xmlXPathObject { xmlXPathObjectType type; xmlNodeSetPtr nodesetval; int boolval; double floatval; xmlChar *stringval; void *user; int index; void *user2; int index2; }; struct _xmlXPathType { const xmlChar *name; xmlXPathConvertFunc func; }; struct _xmlXPathContext { xmlDocPtr doc; xmlNodePtr node; int nb_variables_unused; int max_variables_unused; xmlHashTablePtr varHash; int nb_types; int max_types; xmlXPathTypePtr types; int nb_funcs_unused; int max_funcs_unused; xmlHashTablePtr funcHash; int nb_axis; int max_axis; xmlXPathAxisPtr axis; xmlNsPtr *namespaces; int nsNr; void *user; int contextSize; int proximityPosition; int xptr; xmlNodePtr here; xmlNodePtr origin; xmlHashTablePtr nsHash; xmlXPathVariableLookupFunc varLookupFunc; void *varLookupData; void *extra; const xmlChar *function; const xmlChar *functionURI; xmlXPathFuncLookupFunc funcLookupFunc; void *funcLookupData; xmlNsPtr *tmpNsList; int tmpNsNr; void *userData; xmlStructuredErrorFunc error; xmlError lastError; xmlNodePtr debugNode; xmlDictPtr dict; int flags; }; struct _xmlXPathParserContext { const xmlChar *cur; const xmlChar *base; int error; xmlXPathContextPtr context; xmlXPathObjectPtr value; int valueNr; int valueMax; xmlXPathObjectPtr *valueTab; xmlXPathCompExprPtr comp; int xptr; xmlNodePtr ancestor; }; struct _xmlXPathAxis { const xmlChar *name; xmlXPathAxisFunc func; }; struct _xmlXPathFunct { const xmlChar *name; xmlXPathEvalFunc func; }; struct _xmlXPathVariable { const xmlChar *name; xmlXPathObjectPtr value; }; /* Function prototypes */ extern double xmlXPathCastBooleanToNumber(int val); extern xmlChar *xmlXPathCastBooleanToString(int val); extern int xmlXPathCastNodeSetToBoolean(xmlNodeSetPtr ns); extern double xmlXPathCastNodeSetToNumber(xmlNodeSetPtr ns); extern xmlChar *xmlXPathCastNodeSetToString(xmlNodeSetPtr ns); extern double xmlXPathCastNodeToNumber(xmlNodePtr node); extern xmlChar *xmlXPathCastNodeToString(xmlNodePtr node); extern int xmlXPathCastNumberToBoolean(double val); extern xmlChar *xmlXPathCastNumberToString(double val); extern int xmlXPathCastStringToBoolean(const xmlChar * val); extern double xmlXPathCastStringToNumber(const xmlChar * val); extern int xmlXPathCastToBoolean(xmlXPathObjectPtr val); extern double xmlXPathCastToNumber(xmlXPathObjectPtr val); extern xmlChar *xmlXPathCastToString(xmlXPathObjectPtr val); extern int xmlXPathCmpNodes(xmlNodePtr node1, xmlNodePtr node2); extern xmlXPathCompExprPtr xmlXPathCompile(const xmlChar * str); extern xmlXPathObjectPtr xmlXPathCompiledEval(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctx); extern xmlXPathObjectPtr xmlXPathConvertBoolean(xmlXPathObjectPtr val); extern xmlXPathObjectPtr xmlXPathConvertNumber(xmlXPathObjectPtr val); extern xmlXPathObjectPtr xmlXPathConvertString(xmlXPathObjectPtr val); extern xmlXPathCompExprPtr xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar * str); extern xmlXPathObjectPtr xmlXPathEval(const xmlChar * str, xmlXPathContextPtr ctx); extern xmlXPathObjectPtr xmlXPathEvalExpression(const xmlChar * str, xmlXPathContextPtr ctxt); extern int xmlXPathEvalPredicate(xmlXPathContextPtr ctxt, xmlXPathObjectPtr res); extern void xmlXPathFreeCompExpr(xmlXPathCompExprPtr comp); extern void xmlXPathFreeContext(xmlXPathContextPtr ctxt); extern void xmlXPathFreeNodeSet(xmlNodeSetPtr obj); extern void xmlXPathFreeNodeSetList(xmlXPathObjectPtr obj); extern void xmlXPathFreeObject(xmlXPathObjectPtr obj); extern void xmlXPathInit(void); extern int xmlXPathIsInf(double val); extern int xmlXPathIsNaN(double val); extern double xmlXPathNAN; extern double xmlXPathNINF; extern xmlXPathContextPtr xmlXPathNewContext(xmlDocPtr doc); extern xmlNodeSetPtr xmlXPathNodeSetCreate(xmlNodePtr val); extern xmlXPathObjectPtr xmlXPathObjectCopy(xmlXPathObjectPtr val); extern long int xmlXPathOrderDocElems(xmlDocPtr doc); extern double xmlXPathPINF; #ifdef __cplusplus } #endif #endif /* protection */ #endif /* LSB version */
27.977612
75
0.76407
7bc0a16346be24938ba2a5022ab079f08dc38763
1,203
h
C
System/Library/Frameworks/MobileCoreServices.framework/_LSPendingOpenOperation.h
lechium/tvOS10Headers
f0c99993da6cc502d36fdc5cb4ff90d94b12bf67
[ "MIT" ]
4
2017-03-23T00:01:54.000Z
2018-08-04T20:16:32.000Z
System/Library/Frameworks/MobileCoreServices.framework/_LSPendingOpenOperation.h
lechium/tvOS10Headers
f0c99993da6cc502d36fdc5cb4ff90d94b12bf67
[ "MIT" ]
null
null
null
System/Library/Frameworks/MobileCoreServices.framework/_LSPendingOpenOperation.h
lechium/tvOS10Headers
f0c99993da6cc502d36fdc5cb4ff90d94b12bf67
[ "MIT" ]
4
2017-05-14T16:23:26.000Z
2019-12-21T15:07:59.000Z
/* * This header is generated by classdump-dyld 1.0 * on Wednesday, March 22, 2017 at 9:01:18 AM Mountain Standard Time * Operating System: Version 10.1 (Build 14U593) * Image Source: /System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ @class NSString, NSURL, NSDictionary; @interface _LSPendingOpenOperation : NSObject { NSString* _applicationIdentifier; NSURL* _resourceURL; NSDictionary* _userInfo; } @property (nonatomic,copy) NSString * applicationIdentifier; //@synthesize applicationIdentifier=_applicationIdentifier - In the implementation block @property (nonatomic,retain) NSURL * resourceURL; //@synthesize resourceURL=_resourceURL - In the implementation block @property (nonatomic,retain) NSDictionary * userInfo; //@synthesize userInfo=_userInfo - In the implementation block -(void)setResourceURL:(NSURL *)arg1 ; -(void)dealloc; -(NSDictionary *)userInfo; -(void)setUserInfo:(NSDictionary *)arg1 ; -(void)setApplicationIdentifier:(NSString *)arg1 ; -(NSString *)applicationIdentifier; -(NSURL *)resourceURL; @end
37.59375
162
0.74813
3c5550dde29481258a2a52d13d3312c751389d3c
1,017
c
C
gurba/lib/cmds/player/unlock.c
DEFCON-MUD/defcon-28-mud-source
b25b5bd15fee6a4acda5119ea864bde4dff62714
[ "Unlicense" ]
4
2021-07-21T17:49:01.000Z
2022-03-11T20:50:59.000Z
gurba/lib/cmds/player/unlock.c
DEFCON-MUD/defcon-28-mud-source
b25b5bd15fee6a4acda5119ea864bde4dff62714
[ "Unlicense" ]
null
null
null
gurba/lib/cmds/player/unlock.c
DEFCON-MUD/defcon-28-mud-source
b25b5bd15fee6a4acda5119ea864bde4dff62714
[ "Unlicense" ]
1
2021-12-31T00:55:05.000Z
2021-12-31T00:55:05.000Z
inherit M_COMMAND; string *usage(void) { string *lines; lines = ({ "Usage: unlock [-h] OBJECT" }); lines += ({ "" }); lines += ({ "Unlock the specified object. You need the appropriate key." }); lines += ({ "" }); lines += ({ "Options:" }); lines += ({ "\t-h\tHelp, this usage message." }); lines += ({ "Examples:" }); lines += ({ "\tunlock door" }); lines += get_alsos(); return lines; } void setup_alsos() { add_also("player", "close"); add_also("player", "lock"); add_also("player", "open"); } static void main(string str) { object obj; if (!alsos) { setup_alsos(); } if (empty_str(str) || sscanf(str, "-%s", str)) { this_player()->more(usage()); return; } obj = this_player()->present(str); if (!obj) { obj = this_player()->query_environment()->present(str); if (!obj) { write("Unlock what?"); return; } } if (!obj->do_unlock(this_player())) { write("Unlock what?"); } }
19.941176
79
0.522124
714c844b87b15782d7789c7b5e21a054155925da
1,595
c
C
thirdparty/wnlib/cc/low/wni2.c
rbarzic/MAGICAL
0510550b263913f8c62f46662a9dfa2ae94d2386
[ "BSD-3-Clause" ]
null
null
null
thirdparty/wnlib/cc/low/wni2.c
rbarzic/MAGICAL
0510550b263913f8c62f46662a9dfa2ae94d2386
[ "BSD-3-Clause" ]
null
null
null
thirdparty/wnlib/cc/low/wni2.c
rbarzic/MAGICAL
0510550b263913f8c62f46662a9dfa2ae94d2386
[ "BSD-3-Clause" ]
null
null
null
/************************************************************************* int wn_ilog2(num) bool wn_is_iexp2(num) *************************************************************************/ /**************************************************************************** COPYRIGHT NOTICE: The source code in this directory is provided free of charge to anyone who wants it. It is in the public domain and therefore may be used by anybody for any purpose. It is provided "AS IS" with no warranty of any kind whatsoever. For further details see the README files in the wnlib parent directory. AUTHOR: Will Naylor ****************************************************************************/ #include "wnlib.h" int wn_ilog2(num) unsigned int num; { unsigned int exp,count; count = 0; for(exp=2;exp > 0;exp=exp<<1) { if(num < exp) { return(count); } count++; } return(count); } bool wn_is_iexp2(num) int num; { switch(num) { case(0): return(FALSE); case(1): case(1<<1): case(1<<2): case(1<<3): case(1<<4): case(1<<5): case(1<<6): case(1<<7): case(1<<8): case(1<<9): case(1<<10): case(1<<11): case(1<<12): case(1<<13): case(1<<14): case(1<<15): case(1<<16): case(1<<17): case(1<<18): case(1<<19): case(1<<20): case(1<<21): case(1<<22): case(1<<23): case(1<<24): case(1<<25): case(1<<26): case(1<<27): case(1<<28): case(1<<29): case(1<<30): return(TRUE); } return(FALSE); }
15.95
77
0.437618
73d6fafb6774949069f99cc27b0fa5ff5494d10f
11,877
h
C
src/vm/process.h
URUSCG-LLC/fletch
35967b56cecce8fd5ae96a0d85ca318272ee69a0
[ "BSD-3-Clause" ]
null
null
null
src/vm/process.h
URUSCG-LLC/fletch
35967b56cecce8fd5ae96a0d85ca318272ee69a0
[ "BSD-3-Clause" ]
null
null
null
src/vm/process.h
URUSCG-LLC/fletch
35967b56cecce8fd5ae96a0d85ca318272ee69a0
[ "BSD-3-Clause" ]
null
null
null
// Copyright (c) 2014, the Fletch project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE.md file. #ifndef SRC_VM_PROCESS_H_ #define SRC_VM_PROCESS_H_ #include "src/shared/atomic.h" #include "src/shared/random.h" #include "src/vm/debug_info.h" #include "src/vm/heap.h" #include "src/vm/lookup_cache.h" #include "src/vm/program.h" #include "src/vm/storebuffer.h" #include "src/vm/thread.h" namespace fletch { class Engine; class Interpreter; class ImmutableHeap; class Port; class PortQueue; class ProcessQueue; class ProcessVisitor; class ThreadState { public: ThreadState(); ~ThreadState(); int thread_id() const { return thread_id_; } void set_thread_id(int thread_id) { ASSERT(thread_id_ == -1); thread_id_ = thread_id; } const ThreadIdentifier* thread() const { return &thread_; } // Update the thread field to point to the current thread. void AttachToCurrentThread(); ProcessQueue* queue() { return queue_; } LookupCache* cache() const { return cache_; } LookupCache* EnsureCache(); Monitor* idle_monitor() const { return idle_monitor_; } ThreadState* next_idle_thread() const { return next_idle_thread_; } void set_next_idle_thread(ThreadState* value) { next_idle_thread_ = value; } private: int thread_id_; ThreadIdentifier thread_; ProcessQueue* const queue_; LookupCache* cache_; Monitor* idle_monitor_; Atomic<ThreadState*> next_idle_thread_; }; class Process { public: enum State { kSleeping, kReady, kRunning, kYielding, kBreakPoint, kCompileTimeError, kUncaughtException, kTerminated, }; enum ProgramGCState { kUnknown, kFound, kProcessed, }; enum StackCheckResult { kStackCheckContinue, kStackCheckInterrupt, kStackCheckOverflow }; Function* entry() { return program_->entry(); } int main_arity() { return program_->main_arity(); } Program* program() { return program_; } Array* statics() const { return statics_; } Heap* heap() { return &heap_; } Heap* immutable_heap() { return immutable_heap_; } void set_immutable_heap(Heap* heap) { immutable_heap_ = heap; } Coroutine* coroutine() const { return coroutine_; } void UpdateCoroutine(Coroutine* coroutine); Stack* stack() const { return coroutine_->stack(); } Object** stack_limit() const { return stack_limit_.load(); } Port* ports() const { return ports_; } void set_ports(Port* port) { ports_ = port; } void SetupExecutionStack(); StackCheckResult HandleStackOverflow(int addition); inline LookupCache::Entry* LookupEntry(Object* receiver, int selector); // Lookup and update the primary cache entry. LookupCache::Entry* LookupEntrySlow(LookupCache::Entry* primary, Class* clazz, int selector); Object* NewArray(int length); Object* NewDouble(fletch_double value); Object* NewInteger(int64 value); // Attempt to deallocate the large integer object. If the large integer // was the last allocated object the allocation top is moved back so // the memory can be reused. void TryDeallocInteger(LargeInteger* object); // NewString allocates a string of the given length and fills the payload // with zeroes. Object* NewOneByteString(int length); Object* NewTwoByteString(int length); // New[One/Two]ByteStringUninitialized allocates a string of the given length // and leaves the payload uninitialized. The payload contains whatever // was in that heap space before. Only use this if you intend to // immediately overwrite the payload with something else. Object* NewOneByteStringUninitialized(int length); Object* NewTwoByteStringUninitialized(int length); Object* NewStringFromAscii(List<const char> value); Object* NewBoxed(Object* value); Object* NewStack(int length); Object* NewInstance(Class* klass, bool immutable = false); // Returns either a Smi or a LargeInteger. Object* ToInteger(int64 value); void CollectMutableGarbage(); // Perform garbage collection and chain all stack objects. Additionally, // locate all processes in ports in the heap that are not yet known // by the program GC and link them in the argument list. Returns the // number of stacks found in the heap. int CollectMutableGarbageAndChainStacks(); int CollectGarbageAndChainStacks(); void ValidateHeaps(ImmutableHeap* immutable_heap); void PrintMemoryInfo(); // Iterate all pointers reachable from this process object. void IterateRoots(PointerVisitor* visitor); // Iterate all pointers in the process heap and stack. Used for // program garbage collection. void IterateProgramPointers(PointerVisitor* visitor); // Iterate over, and find pointers in the port queue. void IteratePortQueuesPointers(PointerVisitor* visitor); void Preempt(); void Profile(); // Debugging support. void AttachDebugger(); int PrepareStepOver(); int PrepareStepOut(); DebugInfo* debug_info() { return debug_info_; } bool is_debugging() const { return debug_info_ != NULL; } Process* next() const { return next_; } void set_next(Process* process) { next_ = process; } void TakeLookupCache(); void ReleaseLookupCache() { primary_lookup_cache_ = NULL; } // Program GC support. Cook the stack to rewrite bytecode pointers // to a pair of a function pointer and a delta. Uncook the stack to // rewriting the (now potentially moved) function pointer and the // delta into a direct bytecode pointer again. void CookStacks(int number_of_stacks); void UncookAndUnchainStacks(); bool stacks_are_cooked() { return !cooked_stack_deltas_.is_empty(); } // Program GC support. Update breakpoints after having moved function. // Bytecode pointers need to be updated. void UpdateBreakpoints(); // Change the state from 'from' to 'to. Return 'true' if the operation was // successful. inline bool ChangeState(State from, State to); State state() const { return state_; } ThreadState* thread_state() const { return thread_state_; } void set_thread_state(ThreadState* thread_state) { ASSERT(thread_state == NULL || thread_state_ == NULL); thread_state_ = thread_state; } // Thread-safe way of adding a 'message' at the end of the process' // message queue. Returns false if the object is of wrong type. bool Enqueue(Port* port, Object* message); bool EnqueueForeign(Port* port, void* foreign, int size, bool finalized); void EnqueueExit(Process* sender, Port* port, Object* message); // Determine if it's possible to enqueue the given 'object' in the // message queue of some process. If it's valid for this process, it's valid // for all processes. bool IsValidForEnqueue(Object* message); // Thread-safe way of asking if the message queue of [this] process is empty. bool IsQueueEmpty() const { return last_message_ == NULL; } // Queue iteration. These methods should only be called from the thread // currently owning the process. void TakeQueue(); PortQueue* CurrentMessage(); void AdvanceCurrentMessage(); void TakeChildHeaps(); void RegisterFinalizer(HeapObject* object, WeakPointerCallback callback); void UnregisterFinalizer(HeapObject* object); static void FinalizeForeign(HeapObject* foreign); // This is used in order to return a retry after gc failure on every other // call to the GC native that is used for testing only. bool TrueThenFalse(); ProcessQueue* process_queue() const { return queue_; } void StoreErrno(); void RestoreErrno(); RandomXorShift* random() { return &random_; } StoreBuffer* store_buffer() { return &store_buffer_; } void RecordStore(HeapObject* object, Object* value) { if (value->IsHeapObject() && value->IsImmutable()) { ASSERT(!program()->heap()->space()->Includes( object->address())); ASSERT(heap()->space()->Includes( object->address())); store_buffer_.Insert(object); } } // If you add an offset here, remember to add the corresponding static_assert // in process.cc. static const uword kCoroutineOffset = 0; static const uword kStackLimitOffset = kCoroutineOffset + sizeof(void*); static const uword kProgramOffset = kStackLimitOffset + sizeof(void*); static const uword kStaticsOffset = kProgramOffset + sizeof(void*); static const uword kPrimaryLookupCacheOffset = kStaticsOffset + sizeof(void*); private: friend class Interpreter; friend class Engine; friend class Program; // Creation and deletion of processes is managed by a [Program]. explicit Process(Program* program); ~Process(); void UpdateStackLimit(); // Put 'entry' at the end of the port's queue. This function is thread safe. void EnqueueEntry(PortQueue* entry); void set_process_list_next(Process* process) { process_list_next_ = process; } Process* process_list_next() { return process_list_next_; } void set_process_list_prev(Process* process) { process_list_prev_ = process; } Process* process_list_prev() { return process_list_prev_; } // Put these first so they can be accessed from the interpreter without // issues around object layout. Coroutine* coroutine_; Atomic<Object**> stack_limit_; Program* program_; Array* statics_; // We need extremely fast access to the primary lookup cache, so we // store a reference to it in the process whenever we're interpreting // code in this process. LookupCache::Entry* primary_lookup_cache_; RandomXorShift random_; Heap heap_; Heap* immutable_heap_; StoreBuffer store_buffer_; Atomic<State> state_; Atomic<ThreadState*> thread_state_; List<List<int> > cooked_stack_deltas_; // Next pointer used by the Scheduler. Process* next_; // Fields used by ProcessQueue, when holding the Process. friend class ProcessQueue; Atomic<ProcessQueue*> queue_; // While the ProcessQueue is lock-free, we have an 'atomic lock' on the // head_ element. That will ensure we have the right memory order on // queue_next_/queue_previous_, as they are always read/modified while // head_ is 'locked'. Process* queue_next_; Process* queue_previous_; // Linked list of ports owned by this process. Port* ports_; // Pointer to the last PortQueue element of this process. Atomic<PortQueue*> last_message_; // Process-local list of PortQueue elements currently being processed. PortQueue* current_message_; // Used for chaining all processes of a program. It is protected by a lock // in the program. Process* process_list_next_; Process* process_list_prev_; int errno_cache_; DebugInfo* debug_info_; #ifdef DEBUG bool true_then_false_; #endif }; inline LookupCache::Entry* Process::LookupEntry(Object* receiver, int selector) { ASSERT(!program()->is_compact()); Class* clazz = receiver->IsSmi() ? program()->smi_class() : HeapObject::cast(receiver)->get_class(); ASSERT(primary_lookup_cache_ != NULL); uword index = LookupCache::ComputePrimaryIndex(clazz, selector); LookupCache::Entry* primary = &(primary_lookup_cache_[index]); return (primary->clazz == clazz && primary->selector == selector) ? primary : LookupEntrySlow(primary, clazz, selector); } inline bool Process::ChangeState(State from, State to) { if (from == kRunning || from == kYielding) { ASSERT(thread_state_ == NULL); ASSERT(state_ == from); state_ = to; return true; } State value = state_; while (true) { if (value == kYielding) { value = state_; continue; } if (value != from) break; if (state_.compare_exchange_weak(value, to)) return true; } return false; } } // namespace fletch #endif // SRC_VM_PROCESS_H_
30.929688
80
0.71769
95154646c28d0e77cefa723efb041659f378c936
3,658
h
C
chromium/third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.h
wedataintelligence/vivaldi-source
22a46f2c969f6a0b7ca239a05575d1ea2738768c
[ "BSD-3-Clause" ]
null
null
null
chromium/third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.h
wedataintelligence/vivaldi-source
22a46f2c969f6a0b7ca239a05575d1ea2738768c
[ "BSD-3-Clause" ]
null
null
null
chromium/third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.h
wedataintelligence/vivaldi-source
22a46f2c969f6a0b7ca239a05575d1ea2738768c
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MatrixTransformComponent_h #define MatrixTransformComponent_h #include "core/css/cssom/TransformComponent.h" namespace blink { class CORE_EXPORT MatrixTransformComponent final : public TransformComponent { WTF_MAKE_NONCOPYABLE(MatrixTransformComponent); DEFINE_WRAPPERTYPEINFO(); public: static MatrixTransformComponent* create(double a, double b, double c, double d, double e, double f) { return new MatrixTransformComponent(a, b, c, d, e, f); } static MatrixTransformComponent* create(double m11, double m12, double m13, double m14, double m21, double m22, double m23, double m24, double m31, double m32, double m33, double m34, double m41, double m42, double m43, double m44) { return new MatrixTransformComponent(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44); } // 2D matrix attributes double a() const { return m_m11; } double b() const { return m_m12; } double c() const { return m_m21; } double d() const { return m_m22; } double e() const { return m_m41; } double f() const { return m_m42; } // 3D matrix attributes double m11() const { return m_m11; } double m12() const { return m_m12; } double m13() const { return m_m13; } double m14() const { return m_m14; } double m21() const { return m_m21; } double m22() const { return m_m22; } double m23() const { return m_m23; } double m24() const { return m_m24; } double m31() const { return m_m31; } double m32() const { return m_m32; } double m33() const { return m_m33; } double m34() const { return m_m34; } double m41() const { return m_m41; } double m42() const { return m_m42; } double m43() const { return m_m43; } double m44() const { return m_m44; } TransformComponentType type() const override { return m_is2D ? MatrixType : Matrix3DType; } String cssString() const override; PassRefPtrWillBeRawPtr<CSSFunctionValue> toCSSValue() const override; private: MatrixTransformComponent(double a, double b, double c, double d, double e, double f) : TransformComponent() , m_m11(a) , m_m12(b) , m_m13(0) , m_m14(0) , m_m21(c) , m_m22(d) , m_m23(0) , m_m24(0) , m_m31(0) , m_m32(0) , m_m33(1) , m_m34(0) , m_m41(e) , m_m42(f) , m_m43(0) , m_m44(1) , m_is2D(true) { } MatrixTransformComponent(double m11, double m12, double m13, double m14, double m21, double m22, double m23, double m24, double m31, double m32, double m33, double m34, double m41, double m42, double m43, double m44) : TransformComponent() , m_m11(m11) , m_m12(m12) , m_m13(m13) , m_m14(m14) , m_m21(m21) , m_m22(m22) , m_m23(m23) , m_m24(m24) , m_m31(m31) , m_m32(m32) , m_m33(m33) , m_m34(m34) , m_m41(m41) , m_m42(m42) , m_m43(m43) , m_m44(m44) , m_is2D(false) { } double m_m11; double m_m12; double m_m13; double m_m14; double m_m21; double m_m22; double m_m23; double m_m24; double m_m31; double m_m32; double m_m33; double m_m34; double m_m41; double m_m42; double m_m43; double m_m44; bool m_is2D; }; } // namespace blink #endif
28.578125
124
0.607709
4ebbd254252ea657482c425b8a49e9b09c9a4c70
317
h
C
iOSOpenDev/frameworks/Symbolication.framework/Headers/VMUIDDyLibLoadCommand.h
bzxy/cydia
f8c838cdbd86e49dddf15792e7aa56e2af80548d
[ "MIT" ]
678
2017-11-17T08:33:19.000Z
2022-03-26T10:40:20.000Z
iOSOpenDev/frameworks/Symbolication.framework/Headers/VMUIDDyLibLoadCommand.h
chenfanfang/Cydia
5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0
[ "MIT" ]
22
2019-04-16T05:51:53.000Z
2021-11-08T06:18:45.000Z
iOSOpenDev/frameworks/Symbolication.framework/Headers/VMUIDDyLibLoadCommand.h
chenfanfang/Cydia
5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0
[ "MIT" ]
170
2018-06-10T07:59:20.000Z
2022-03-22T16:19:33.000Z
/** * This header is generated by class-dump-z 0.2b. * * Source: /System/Library/PrivateFrameworks/Symbolication.framework/Symbolication */ #import <Symbolication/VMUDyLibLoadCommand.h> @interface VMUIDDyLibLoadCommand : VMUDyLibLoadCommand { } - (BOOL)isIDDyLib; // 0x4247c - (id)description; // 0x42484 @end
21.133333
82
0.750789
66393df56f54539828dff97e080b2d3060f0948e
66
h
C
include/main.h
weshmek/raspberry-pi-os
e5327f3fb9148e3846f8d382ba864b1594df1722
[ "MIT" ]
1
2015-04-26T01:19:09.000Z
2015-04-26T01:19:09.000Z
include/main.h
weshmek/raspberry-pi-os
e5327f3fb9148e3846f8d382ba864b1594df1722
[ "MIT" ]
null
null
null
include/main.h
weshmek/raspberry-pi-os
e5327f3fb9148e3846f8d382ba864b1594df1722
[ "MIT" ]
null
null
null
#ifndef __MAIN_H__ #define __MAIN_H__ void loop$(void); #endif
8.25
18
0.742424
791ca3cf7e57d7a10ac8bef55f9494c32a5951db
593
h
C
Headers/FBAdContentContainerDelegate-Protocol.h
chuiizeet/stickers-daily-headers
d779869a384b0334e709ea24830bee5b063276a9
[ "MIT" ]
null
null
null
Headers/FBAdContentContainerDelegate-Protocol.h
chuiizeet/stickers-daily-headers
d779869a384b0334e709ea24830bee5b063276a9
[ "MIT" ]
null
null
null
Headers/FBAdContentContainerDelegate-Protocol.h
chuiizeet/stickers-daily-headers
d779869a384b0334e709ea24830bee5b063276a9
[ "MIT" ]
null
null
null
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import "NSObject-Protocol.h" @class FBAdViewabilityValidator, NSError; @protocol FBAdContentContainerDelegate <NSObject> - (void)adDidFailToLoadWithError:(NSError *)arg1; - (void)adWillLogImpression; - (void)adDidLoad; @optional - (FBAdViewabilityValidator *)contentContainerViewabilityValidator; - (void)adDidTerminate; - (void)adDidFinishHandlingClick; - (void)adDidLogClick; - (void)adCTAClick; @end
24.708333
90
0.752108
588d10ad80e761230d06e0b1ec1aa1c70a2a05cb
2,397
c
C
multiplers/8x3_unsigned/pareto_pwr_mae/mul8x3u_0SF.c
mrazekv/approxlib
813e065b6427a61e342fe05c35a47887115530a6
[ "MIT" ]
25
2019-05-17T12:08:29.000Z
2022-03-11T07:50:24.000Z
multiplers/8x3_unsigned/pareto_pwr_mae/mul8x3u_0SF.c
Somayehkiany/evoapproxlib
813e065b6427a61e342fe05c35a47887115530a6
[ "MIT" ]
null
null
null
multiplers/8x3_unsigned/pareto_pwr_mae/mul8x3u_0SF.c
Somayehkiany/evoapproxlib
813e065b6427a61e342fe05c35a47887115530a6
[ "MIT" ]
14
2019-04-03T09:53:26.000Z
2022-02-25T09:38:54.000Z
/*** * This code is a part of EvoApproxLib library (ehw.fit.vutbr.cz/approxlib) distributed under The MIT License. * When used, please cite the following article(s): V. Mrazek, L. Sekanina, Z. Vasicek "Libraries of Approximate Circuits: Automated Design and Application in CNN Accelerators" IEEE Journal on Emerging and Selected Topics in Circuits and Systems, Vol 10, No 4, 2020 * This file contains a circuit from a sub-set of pareto optimal circuits with respect to the pwr and mae parameters ***/ // MAE% = 1.34 % // MAE = 28 // WCE% = 5.22 % // WCE = 107 // WCRE% = 100.00 % // EP% = 85.69 % // MRE% = 18.70 % // MSE = 1309 // PDK45_PWR = 0.027 mW // PDK45_AREA = 101.4 um2 // PDK45_DELAY = 0.46 ns #include <stdint.h> #include <stdlib.h> uint64_t mul8x3u_0SF(const uint64_t A,const uint64_t B) { uint64_t dout_17, dout_18, dout_24, dout_25, dout_26, dout_49, dout_50, dout_54, dout_55, dout_57, dout_58, dout_60, dout_65, dout_66, dout_67, dout_68, dout_91, dout_92, dout_93, dout_94, dout_95, dout_96, dout_97, dout_98, dout_99, dout_100, dout_101, dout_102, dout_103, dout_104, dout_105; uint64_t O; dout_17=((A >> 6)&1)&((B >> 0)&1); dout_18=((A >> 7)&1)&((B >> 0)&1); dout_24=((A >> 5)&1)&((B >> 1)&1); dout_25=((A >> 6)&1)&((B >> 1)&1); dout_26=((A >> 7)&1)&((B >> 1)&1); dout_49=dout_17|dout_24; dout_50=dout_17&dout_24; dout_54=dout_18^dout_25; dout_55=dout_18&dout_25; dout_57=dout_54^dout_50; dout_58=dout_55|dout_50; dout_60=dout_58^dout_26; dout_65=((A >> 4)&1)&((B >> 2)&1); dout_66=((A >> 5)&1)&((B >> 2)&1); dout_67=((A >> 6)&1)&((B >> 2)&1); dout_68=((A >> 7)&1)&((B >> 2)&1); dout_91=dout_57^dout_66; dout_92=dout_57&dout_66; dout_93=dout_91&dout_65; dout_94=dout_91^dout_65; dout_95=dout_92|dout_93; dout_96=dout_60^dout_67; dout_97=dout_60&dout_67; dout_98=dout_96&dout_95; dout_99=dout_96^dout_95; dout_100=dout_97|dout_98; dout_101=dout_55^dout_68; dout_102=dout_58&dout_68; dout_103=((A >> 7)&1)&dout_100; dout_104=dout_101^dout_100; dout_105=dout_102|dout_103; O = 0; O |= (0&1) << 0; O |= (dout_49&1) << 1; O |= (0&1) << 2; O |= (dout_49&1) << 3; O |= (dout_99&1) << 4; O |= (dout_49&1) << 5; O |= (dout_49&1) << 6; O |= (dout_94&1) << 7; O |= (dout_99&1) << 8; O |= (dout_104&1) << 9; O |= (dout_105&1) << 10; return O; }
33.760563
296
0.625365
95cfd5b93fa366ab3557d879176bdf170fa5f15a
16,530
c
C
streaming_libs/flvmeta/src/dump_yaml.c
HellicarAndLewis/Caravideo
bba46ae7b049d5cb6382ca111050441d5b6ddcdf
[ "MIT" ]
7
2015-04-18T19:52:02.000Z
2020-04-29T21:45:45.000Z
streaming_libs/flvmeta/src/dump_yaml.c
HellicarAndLewis/Caravideo
bba46ae7b049d5cb6382ca111050441d5b6ddcdf
[ "MIT" ]
null
null
null
streaming_libs/flvmeta/src/dump_yaml.c
HellicarAndLewis/Caravideo
bba46ae7b049d5cb6382ca111050441d5b6ddcdf
[ "MIT" ]
null
null
null
/* $Id: dump_yaml.c 231 2011-06-27 13:46:19Z marc.noirot $ FLV Metadata updater Copyright (C) 2007-2012 Marc Noirot <marc.noirot AT gmail.com> This file is part of FLVMeta. FLVMeta is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. FLVMeta is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with FLVMeta; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "dump.h" #include "dump_yaml.h" #include "yaml.h" #include <stdio.h> #include <string.h> /* YAML metadata dumping */ static void amf_data_yaml_dump(const amf_data * data, yaml_emitter_t * emitter) { if (data != NULL) { amf_node * node; yaml_event_t event; time_t time; struct tm * t; char str[128]; switch (data->type) { case AMF_TYPE_NUMBER: sprintf(str, "%.12g", data->number_data); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)str, (int)strlen(str), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); break; case AMF_TYPE_BOOLEAN: sprintf(str, (data->boolean_data) ? "true" : "false"); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)str, (int)strlen(str), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); break; case AMF_TYPE_STRING: yaml_scalar_event_initialize(&event, NULL, NULL, amf_string_get_bytes(data), (int)amf_string_get_size(data), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); break; case AMF_TYPE_OBJECT: yaml_mapping_start_event_initialize(&event, NULL, NULL, 1, YAML_ANY_MAPPING_STYLE); yaml_emitter_emit(emitter, &event); node = amf_object_first(data); while (node != NULL) { amf_data * name; name = amf_object_get_name(node); /* if this fails, we skip the current entry */ if (yaml_scalar_event_initialize(&event, NULL, NULL, amf_string_get_bytes(name), amf_string_get_size(name), 1, 1, YAML_ANY_SCALAR_STYLE)) { yaml_emitter_emit(emitter, &event); amf_data_yaml_dump(amf_object_get_data(node), emitter); } node = amf_object_next(node); } yaml_mapping_end_event_initialize(&event); yaml_emitter_emit(emitter, &event); break; case AMF_TYPE_NULL: case AMF_TYPE_UNDEFINED: yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"null", 4, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); break; case AMF_TYPE_ASSOCIATIVE_ARRAY: yaml_mapping_start_event_initialize(&event, NULL, NULL, 1, YAML_ANY_MAPPING_STYLE); yaml_emitter_emit(emitter, &event); node = amf_associative_array_first(data); while (node != NULL) { amf_data * name; name = amf_associative_array_get_name(node); /* if this fails, we skip the current entry */ if (yaml_scalar_event_initialize(&event, NULL, NULL, amf_string_get_bytes(name), amf_string_get_size(name), 1, 1, YAML_ANY_SCALAR_STYLE)) { yaml_emitter_emit(emitter, &event); amf_data_yaml_dump(amf_associative_array_get_data(node), emitter); } node = amf_associative_array_next(node); } yaml_mapping_end_event_initialize(&event); yaml_emitter_emit(emitter, &event); break; case AMF_TYPE_ARRAY: yaml_sequence_start_event_initialize(&event, NULL, NULL, 1, YAML_ANY_SEQUENCE_STYLE); yaml_emitter_emit(emitter, &event); node = amf_array_first(data); while (node != NULL) { amf_data_yaml_dump(amf_array_get(node), emitter); node = amf_array_next(node); } yaml_sequence_end_event_initialize(&event); yaml_emitter_emit(emitter, &event); break; case AMF_TYPE_DATE: time = amf_date_to_time_t(data); tzset(); t = localtime(&time); strftime(str, sizeof(str), "%Y-%m-%dT%H:%M:%S", t); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)str, (int)strlen(str), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); break; case AMF_TYPE_XML: break; case AMF_TYPE_CLASS: break; default: break; } } } /* YAML FLV file full dump callbacks */ static int yaml_on_header(flv_header * header, flv_parser * parser) { yaml_emitter_t * emitter; yaml_event_t event; char buffer[20]; emitter = (yaml_emitter_t *)parser->user_data; yaml_mapping_start_event_initialize(&event, NULL, NULL, 1, YAML_ANY_MAPPING_STYLE); yaml_emitter_emit(emitter, &event); /* magic */ yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"magic", 5, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); sprintf(buffer, "%.3s", header->signature); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)buffer, (int)strlen(buffer), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); /* hasVideo */ yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"hasVideo", 8, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); sprintf(buffer, "%s", flv_header_has_video(*header) ? "true" : "false"); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)buffer, (int)strlen(buffer), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); /* hasAudio */ yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"hasAudio", 8, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); sprintf(buffer, "%s", flv_header_has_audio(*header) ? "true" : "false"); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)buffer, (int)strlen(buffer), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); /* version */ yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"version", 7, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); sprintf(buffer, "%i", header->version); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)buffer, (int)strlen(buffer), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); /* start of tags array */ yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"tags", 4, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); yaml_sequence_start_event_initialize(&event, NULL, NULL, 1, YAML_ANY_SEQUENCE_STYLE); yaml_emitter_emit(emitter, &event); return OK; } static int yaml_on_tag(flv_tag * tag, flv_parser * parser) { const char * str; yaml_emitter_t * emitter; yaml_event_t event; char buffer[20]; emitter = (yaml_emitter_t *)parser->user_data; str = dump_string_get_tag_type(tag); yaml_mapping_start_event_initialize(&event, NULL, NULL, 1, YAML_ANY_MAPPING_STYLE); yaml_emitter_emit(emitter, &event); /* type */ yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"type", 4, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)str, (int)strlen(str), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); /* timestamp */ yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"timestamp", 9, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); sprintf(buffer, "%i", flv_tag_get_timestamp(*tag)); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)buffer, (int)strlen(buffer), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); /* data size */ yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"dataSize", 8, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); sprintf(buffer, "%i", flv_tag_get_body_length(*tag)); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)buffer, (int)strlen(buffer), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); /* offset */ yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"offset", 6, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); sprintf(buffer, "%" FILE_OFFSET_PRINTF_FORMAT "i", parser->stream->current_tag_offset); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)buffer, (int)strlen(buffer), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); return OK; } static int yaml_on_video_tag(flv_tag * tag, flv_video_tag vt, flv_parser * parser) { const char * str; yaml_emitter_t * emitter; yaml_event_t event; emitter = (yaml_emitter_t *)parser->user_data; yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"videoData", 9, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); yaml_mapping_start_event_initialize(&event, NULL, NULL, 1, YAML_ANY_MAPPING_STYLE); yaml_emitter_emit(emitter, &event); str = dump_string_get_video_codec(vt); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"codecID", 7, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)str, (int)strlen(str), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); str = dump_string_get_video_frame_type(vt); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"frameType", 9, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)str, (int)strlen(str), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); yaml_mapping_end_event_initialize(&event); yaml_emitter_emit(emitter, &event); return OK; } static int yaml_on_audio_tag(flv_tag * tag, flv_audio_tag at, flv_parser * parser) { const char * str; yaml_emitter_t * emitter; yaml_event_t event; emitter = (yaml_emitter_t *)parser->user_data; yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"audioData", 9, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); yaml_mapping_start_event_initialize(&event, NULL, NULL, 1, YAML_ANY_MAPPING_STYLE); yaml_emitter_emit(emitter, &event); str = dump_string_get_sound_type(at); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"type", 4, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)str, (int)strlen(str), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); str = dump_string_get_sound_size(at); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"size", 4, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)str, (int)strlen(str), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); str = dump_string_get_sound_rate(at); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"rate", 4, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)str, (int)strlen(str), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); str = dump_string_get_sound_format(at); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"format", 6, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)str, (int)strlen(str), 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); yaml_mapping_end_event_initialize(&event); yaml_emitter_emit(emitter, &event); return OK; } static int yaml_on_metadata_tag(flv_tag * tag, amf_data * name, amf_data * data, flv_parser * parser) { yaml_emitter_t * emitter; yaml_event_t event; emitter = (yaml_emitter_t *)parser->user_data; yaml_scalar_event_initialize(&event, NULL, NULL, (yaml_char_t*)"scriptDataObject", 16, 1, 1, YAML_ANY_SCALAR_STYLE); yaml_emitter_emit(emitter, &event); amf_data_yaml_dump(data, emitter); return OK; } static int yaml_on_prev_tag_size(uint32 size, flv_parser * parser) { yaml_emitter_t * emitter; yaml_event_t event; emitter = (yaml_emitter_t *)parser->user_data; yaml_mapping_end_event_initialize(&event); yaml_emitter_emit(emitter, &event); return OK; } static int yaml_on_stream_end(flv_parser * parser) { yaml_emitter_t * emitter; yaml_event_t event; emitter = (yaml_emitter_t *)parser->user_data; yaml_sequence_end_event_initialize(&event); yaml_emitter_emit(emitter, &event); yaml_mapping_end_event_initialize(&event); yaml_emitter_emit(emitter, &event); return OK; } /* YAML FLV file metadata dump callbacks */ static int yaml_on_metadata_tag_only(flv_tag * tag, amf_data * name, amf_data * data, flv_parser * parser) { flvmeta_opts * options = (flvmeta_opts*) parser->user_data; if (options->metadata_event == NULL) { if (!strcmp((char*)amf_string_get_bytes(name), "onMetaData")) { dump_yaml_amf_data(data); return FLVMETA_DUMP_STOP_OK; } } else { if (!strcmp((char*)amf_string_get_bytes(name), options->metadata_event)) { dump_yaml_amf_data(data); } } return OK; } /* dumping functions */ void dump_yaml_setup_metadata_dump(flv_parser * parser) { if (parser != NULL) { parser->on_metadata_tag = yaml_on_metadata_tag_only; } } int dump_yaml_file(flv_parser * parser, const flvmeta_opts * options) { yaml_emitter_t emitter; yaml_event_t event; int ret; parser->on_header = yaml_on_header; parser->on_tag = yaml_on_tag; parser->on_audio_tag = yaml_on_audio_tag; parser->on_video_tag = yaml_on_video_tag; parser->on_metadata_tag = yaml_on_metadata_tag; parser->on_prev_tag_size = yaml_on_prev_tag_size; parser->on_stream_end = yaml_on_stream_end; yaml_emitter_initialize(&emitter); yaml_emitter_set_output_file(&emitter, stdout); yaml_emitter_open(&emitter); yaml_document_start_event_initialize(&event, NULL, NULL, NULL, 0); yaml_emitter_emit(&emitter, &event); parser->user_data = &emitter; ret = flv_parse(options->input_file, parser); yaml_document_end_event_initialize(&event, 1); yaml_emitter_emit(&emitter, &event); yaml_emitter_flush(&emitter); yaml_emitter_close(&emitter); yaml_emitter_delete(&emitter); return ret; } int dump_yaml_amf_data(const amf_data * data) { yaml_emitter_t emitter; yaml_event_t event; yaml_emitter_initialize(&emitter); yaml_emitter_set_output_file(&emitter, stdout); yaml_emitter_open(&emitter); yaml_document_start_event_initialize(&event, NULL, NULL, NULL, 0); yaml_emitter_emit(&emitter, &event); /* dump AMF into YAML */ amf_data_yaml_dump(data, &emitter); yaml_document_end_event_initialize(&event, 1); yaml_emitter_emit(&emitter, &event); yaml_emitter_flush(&emitter); yaml_emitter_close(&emitter); yaml_emitter_delete(&emitter); return OK; }
38.44186
159
0.674773
bf7c9be1e08c25f1a5c1cdff81cb5f7321c54faf
26,230
h
C
include/gauge_field_order.h
silky/quda
20e12cbe15349efcfa6de4f785228aa8398fe6b6
[ "MIT" ]
1
2019-06-27T11:33:50.000Z
2019-06-27T11:33:50.000Z
include/gauge_field_order.h
silky/quda
20e12cbe15349efcfa6de4f785228aa8398fe6b6
[ "MIT" ]
null
null
null
include/gauge_field_order.h
silky/quda
20e12cbe15349efcfa6de4f785228aa8398fe6b6
[ "MIT" ]
null
null
null
#include <tune_quda.h> #include <assert.h> #include <register_traits.h> namespace quda { // a += b*c template <typename Float> __device__ __host__ inline void accumulateComplexProduct(Float *a, const Float *b, const Float *c, Float sign) { a[0] += sign*(b[0]*c[0] - b[1]*c[1]); a[1] += sign*(b[0]*c[1] + b[1]*c[0]); } // a = b*c template <typename Float> __device__ __host__ inline void complexProduct(Float *a, const Float *b, const Float *c) { a[0] = b[0]*c[0] - b[1]*c[1]; a[1] = b[0]*c[1] + b[1]*c[0]; } // a = conj(b)*c template <typename Float> __device__ __host__ inline void complexDotProduct(Float *a, const Float *b, const Float *c) { a[0] = b[0]*c[0] + b[1]*c[1]; a[1] = b[0]*c[1] - b[1]*c[0]; } // a = b/c template <typename Float> __device__ __host__ inline void complexQuotient(Float *a, const Float *b, const Float *c){ complexDotProduct(a, c, b); Float denom = c[0]*c[0] + c[1]*c[1]; a[0] /= denom; a[1] /= denom; } // a += conj(b) * conj(c) template <typename Float> __device__ __host__ inline void accumulateConjugateProduct(Float *a, const Float *b, const Float *c, int sign) { a[0] += sign * (b[0]*c[0] - b[1]*c[1]); a[1] -= sign * (b[0]*c[1] + b[1]*c[0]); } // a = conj(b)*conj(c) template <typename Float> __device__ __host__ inline void complexConjugateProduct(Float *a, const Float *b, const Float *c) { a[0] = b[0]*c[0] - b[1]*c[1]; a[1] = -b[0]*c[1] - b[1]*c[0]; } /** Generic reconstruction is no reconstruction */ template <int N, typename Float> struct Reconstruct { typedef typename mapper<Float>::type RegType; Reconstruct(const GaugeField &u) { ; } __device__ __host__ inline void Pack(RegType out[N], const RegType in[N], int idx ) const { for (int i=0; i<N; i++) out[i] = in[i]; } __device__ __host__ inline void Unpack(RegType out[N], const RegType in[N], int idx, int dir, const RegType phase) const { for (int i=0; i<N; i++) out[i] = in[i]; } __device__ __host__ inline void getPhase(RegType *phase, const RegType in[18]) const { *phase = 0; } }; /** No reconstruction but we scale the result. This is used for half-precision non-unitary fields, e.g., staggered fat link */ template <typename Float> struct Reconstruct<19,Float> { typedef typename mapper<Float>::type RegType; RegType scale; Reconstruct(const GaugeField &u) : scale(u.LinkMax()) { ; } __device__ __host__ inline void Pack(RegType out[18], const RegType in[18], int idx) const { for (int i=0; i<18; i++) out[i] = in[i] / scale; } __device__ __host__ inline void Unpack(RegType out[18], const RegType in[18], int idx, int dir, const RegType phase) const { for (int i=0; i<18; i++) out[i] = scale * in[i]; } __device__ __host__ inline void getPhase(RegType* phase, const RegType in[18]) const { *phase=0; return; } }; template <typename Float> struct Reconstruct<12,Float> { typedef typename mapper<Float>::type RegType; int X[QUDA_MAX_DIM]; const RegType anisotropy; const QudaTboundary tBoundary; Reconstruct(const GaugeField &u) : anisotropy(u.Anisotropy()), tBoundary(u.TBoundary()) { for (int i=0; i<QUDA_MAX_DIM; i++) X[i] = u.X()[i]; } __device__ __host__ inline void Pack(RegType out[12], const RegType in[18], int idx) const { for (int i=0; i<12; i++) out[i] = in[i]; } __device__ __host__ inline void Unpack(RegType out[18], const RegType in[12], int idx, int dir, const RegType phase) const { for (int i=0; i<12; i++) out[i] = in[i]; for (int i=12; i<18; i++) out[i] = 0.0; accumulateConjugateProduct(&out[12], &out[2], &out[10], +1); accumulateConjugateProduct(&out[12], &out[4], &out[8], -1); accumulateConjugateProduct(&out[14], &out[4], &out[6], +1); accumulateConjugateProduct(&out[14], &out[0], &out[10], -1); accumulateConjugateProduct(&out[16], &out[0], &out[8], +1); accumulateConjugateProduct(&out[16], &out[2], &out[6], -1); RegType u0 = (dir < 3 ? anisotropy : (idx >= (X[3]-1)*X[0]*X[1]*X[2]/2 ? tBoundary : 1)); for (int i=12; i<18; i++) out[i]*=u0; } __device__ __host__ inline void getPhase(RegType* phase, const RegType in[18]){ *phase=0; return; } }; template <typename Float> struct Reconstruct<13,Float> { typedef typename mapper<Float>::type RegType; const Reconstruct<12,Float> reconstruct_12; const RegType scale; Reconstruct(const GaugeField &u) : reconstruct_12(u), scale(u.Scale()) {} __device__ __host__ inline void Pack(RegType out[12], const RegType in[18], int idx) const { reconstruct_12.Pack(out, in, idx); } __device__ __host__ inline void Unpack(RegType out[18], const RegType in[12], int idx, int dir, const RegType phase) const { for(int i=0; i<12; ++i) out[i] = in[i]; for(int i=12; i<18; ++i) out[i] = 0.0; const RegType coeff = 1./scale; accumulateConjugateProduct(&out[12], &out[2], &out[10], +coeff); accumulateConjugateProduct(&out[12], &out[4], &out[8], -coeff); accumulateConjugateProduct(&out[14], &out[4], &out[6], +coeff); accumulateConjugateProduct(&out[14], &out[0], &out[10], -coeff); accumulateConjugateProduct(&out[16], &out[0], &out[8], +coeff); accumulateConjugateProduct(&out[16], &out[2], &out[6], -coeff); // Multiply the third row by exp(I*3*phase) RegType cos_sin[2]; Trig<isHalf<RegType>::value>::SinCos(static_cast<RegType>(3.*phase), &cos_sin[1], &cos_sin[0]); RegType tmp[2]; complexProduct(tmp, cos_sin, &out[12]); out[12] = tmp[0]; out[13] = tmp[1]; complexProduct(tmp, cos_sin, &out[14]); out[14] = tmp[0]; out[15] = tmp[1]; complexProduct(tmp, cos_sin, &out[16]); out[16] = tmp[0]; out[17] = tmp[1]; } __device__ __host__ inline void getPhase(RegType *phase, const RegType in[18]) const { RegType denom[2]; // denominator = (U[0][0]*U[1][1] - U[0][1]*U[1][0])* complexProduct(denom, in, in+8); accumulateComplexProduct(denom, in+2, in+6, static_cast<RegType>(-1.0)); denom[0] /= scale; denom[1] /= (-scale); // complex conjugate RegType expI3Phase[2]; // numerator = U[2][2] complexQuotient(expI3Phase, in+16, denom); *phase = Trig<isHalf<RegType>::value>::Atan2(expI3Phase[1], expI3Phase[0])/3.; return; } }; template <typename Float> struct Reconstruct<8,Float> { typedef typename mapper<Float>::type RegType; int X[QUDA_MAX_DIM]; const RegType anisotropy; const QudaTboundary tBoundary; Reconstruct(const GaugeField &u) : anisotropy(u.Anisotropy()), tBoundary(u.TBoundary()) { for (int i=0; i<QUDA_MAX_DIM; i++) X[i] = u.X()[i]; } __device__ __host__ inline void Pack(RegType out[8], const RegType in[18], int idx) const { out[0] = Trig<isHalf<Float>::value>::Atan2(in[1], in[0]); out[1] = Trig<isHalf<Float>::value>::Atan2(in[13], in[12]); for (int i=2; i<8; i++) out[i] = in[i]; } __device__ __host__ inline void Unpack(RegType out[18], const RegType in[8], int idx, int dir, const RegType phase) const { // First reconstruct first row RegType row_sum = 0.0; for (int i=2; i<6; i++) { out[i] = in[i]; row_sum += in[i]*in[i]; } RegType u0 = (dir < 3 ? anisotropy : (idx >= (X[3]-1)*X[0]*X[1]*X[2]/2 ? tBoundary : 1)); RegType diff = 1.0/(u0*u0) - row_sum; RegType U00_mag = sqrt(diff >= 0 ? diff : 0.0); out[0] = U00_mag * Trig<isHalf<Float>::value>::Cos(in[0]); out[1] = U00_mag * Trig<isHalf<Float>::value>::Sin(in[0]); // Now reconstruct first column RegType column_sum = 0.0; for (int i=0; i<2; i++) column_sum += out[i]*out[i]; for (int i=6; i<8; i++) { out[i] = in[i]; column_sum += in[i]*in[i]; } diff = 1.f/(u0*u0) - column_sum; RegType U20_mag = sqrt(diff >= 0 ? diff : 0.0); out[12] = U20_mag * Trig<isHalf<Float>::value>::Cos(in[1]); out[13] = U20_mag * Trig<isHalf<Float>::value>::Sin(in[1]); // First column now restored // finally reconstruct last elements from SU(2) rotation RegType r_inv2 = 1.0/(u0*row_sum); // U11 RegType A[2]; complexDotProduct(A, out+0, out+6); complexConjugateProduct(out+8, out+12, out+4); accumulateComplexProduct(out+8, A, out+2, u0); out[8] *= -r_inv2; out[9] *= -r_inv2; // U12 complexConjugateProduct(out+10, out+12, out+2); accumulateComplexProduct(out+10, A, out+4, -u0); out[10] *= r_inv2; out[11] *= r_inv2; // U21 complexDotProduct(A, out+0, out+12); complexConjugateProduct(out+14, out+6, out+4); accumulateComplexProduct(out+14, A, out+2, -u0); out[14] *= r_inv2; out[15] *= r_inv2; // U12 complexConjugateProduct(out+16, out+6, out+2); accumulateComplexProduct(out+16, A, out+4, u0); out[16] *= -r_inv2; out[17] *= -r_inv2; } __device__ __host__ inline void getPhase(RegType* phase, const RegType in[18]){ *phase=0; return; } }; template <typename Float> struct Reconstruct<9,Float> { typedef typename mapper<Float>::type RegType; const Reconstruct<8,Float> reconstruct_8; const RegType scale; Reconstruct(const GaugeField &u) : reconstruct_8(u), scale(u.Scale()) {} __device__ __host__ inline void getPhase(RegType *phase, const RegType in[18]) const { RegType denom[2]; // denominator = (U[0][0]*U[1][1] - U[0][1]*U[1][0])* complexProduct(denom, in, in+8); accumulateComplexProduct(denom, in+2, in+6, static_cast<RegType>(-1.0)); denom[0] /= scale; denom[1] /= (-scale); // complex conjugate RegType expI3Phase[2]; // numerator = U[2][2] complexQuotient(expI3Phase, in+16, denom); *phase = Trig<isHalf<RegType>::value>::Atan2(expI3Phase[1], expI3Phase[0])/3.; } __device__ __host__ inline void Pack(RegType out[8], const RegType in[18], int idx) const { RegType phase; getPhase(&phase,in); RegType cos_sin[2]; sincos(-phase, &cos_sin[1], &cos_sin[0]); // Rescale the U3 input matrix by exp(-I*phase) to obtain an SU3 matrix multiplied by a real scale factor, // which the macros in read_gauge.h can handle. // NB: Only 5 complex matrix elements are used in the reconstruct 8 packing routine, // so only need to rescale those elements. RegType su3[18]; for(int i=0; i<4; ++i){ complexProduct(su3 + 2*i, cos_sin, in + 2*i); } complexProduct(&su3[12], cos_sin, &in[12]); reconstruct_8.Pack(out, su3, idx); } __device__ __host__ inline void Unpack(RegType out[18], const RegType in[8], int idx, int dir, const RegType phase) const { reconstruct_8.Unpack(out, in, idx, dir, phase); RegType cos_sin[2]; Trig<isHalf<RegType>::value>::SinCos(phase, &cos_sin[1], &cos_sin[0]); RegType tmp[2]; cos_sin[0] *= scale; cos_sin[1] *= scale; // rescale the matrix by exp(I*phase)*scale complexProduct(tmp, cos_sin, &out[0]); out[0] = tmp[0]; out[1] = tmp[1]; complexProduct(tmp, cos_sin, &out[2]); out[2] = tmp[0]; out[3] = tmp[1]; complexProduct(tmp, cos_sin, &out[4]); out[4] = tmp[0]; out[5] = tmp[1]; complexProduct(tmp, cos_sin, &out[6]); out[6] = tmp[0]; out[7] = tmp[1]; complexProduct(tmp, cos_sin, &out[8]); out[8] = tmp[0]; out[9] = tmp[1]; complexProduct(tmp, cos_sin, &out[10]); out[10] = tmp[0]; out[11] = tmp[1]; complexProduct(tmp, cos_sin, &out[12]); out[12] = tmp[0]; out[13] = tmp[1]; complexProduct(tmp, cos_sin, &out[14]); out[14] = tmp[0]; out[15] = tmp[1]; complexProduct(tmp, cos_sin, &out[16]); out[16] = tmp[0]; out[17] = tmp[1]; } }; template <typename Float, int length, int N, int reconLen> struct FloatNOrder { typedef typename mapper<Float>::type RegType; Reconstruct<reconLen,Float> reconstruct; Float *gauge[2]; Float *ghost[4]; int faceVolumeCB[QUDA_MAX_DIM]; const int volumeCB; const int stride; #if __COMPUTE_CAPABILITY__ >= 200 const int hasPhase; const size_t phaseOffset; #endif FloatNOrder(const GaugeField &u, Float *gauge_=0, Float **ghost_=0) : reconstruct(u), volumeCB(u.VolumeCB()), stride(u.Stride()) #if __COMPUTE_CAPABILITY__ >= 200 , hasPhase((u.Reconstruct() == QUDA_RECONSTRUCT_9 || u.Reconstruct() == QUDA_RECONSTRUCT_13) ? 1 : 0), phaseOffset(u.PhaseOffset()) #endif { if (gauge_) { gauge[0] = gauge_; gauge[1] = (Float*)((char*)gauge_ + u.Bytes()/2); } else { gauge[0] = (Float*)u.Gauge_p(); gauge[1] = (Float*)((char*)u.Gauge_p() + u.Bytes()/2); } for (int i=0; i<4; i++) { ghost[i] = ghost_ ? ghost_[i] : 0; faceVolumeCB[i] = u.SurfaceCB(i)*u.Nface(); // face volume equals surface * depth } } FloatNOrder(const FloatNOrder &order) : reconstruct(order.reconstruct), volumeCB(order.volumeCB), stride(order.stride) #if __COMPUTE_CAPABILITY__ >= 200 , hasPhase(order.hasPhase), phaseOffset(order.phaseOffset) #endif { gauge[0] = order.gauge[0]; gauge[1] = order.gauge[1]; for (int i=0; i<4; i++) { ghost[i] = order.ghost[i]; faceVolumeCB[i] = order.faceVolumeCB[i]; } } virtual ~FloatNOrder() { ; } __device__ __host__ inline void load(RegType v[length], int x, int dir, int parity) const { const int M = reconLen / N; RegType tmp[reconLen]; for (int i=0; i<M; i++) { for (int j=0; j<N; j++) { int intIdx = i*N + j; // internal dof index int padIdx = intIdx / N; copy(tmp[i*N+j], gauge[parity][dir*stride*M*N + (padIdx*stride + x)*N + intIdx%N]); } } RegType phase = 0.; #if __COMPUTE_CAPABILITY__ >= 200 if(hasPhase) copy(phase, gauge[parity][phaseOffset/sizeof(Float) + stride*dir + x]); // The phases come after the ghost matrices #endif reconstruct.Unpack(v, tmp, x, dir, 2.*M_PI*phase); } __device__ __host__ inline void save(const RegType v[length], int x, int dir, int parity) { const int M = reconLen / N; RegType tmp[reconLen]; reconstruct.Pack(tmp, v, x); for (int i=0; i<M; i++) { for (int j=0; j<N; j++) { int intIdx = i*N + j; int padIdx = intIdx / N; copy(gauge[parity][dir*stride*M*N + (padIdx*stride + x)*N + intIdx%N], tmp[i*N+j]); } } #if __COMPUTE_CAPABILITY__ >= 200 if(hasPhase){ RegType phase; reconstruct.getPhase(&phase,v); copy(gauge[parity][phaseOffset/sizeof(Float) + dir*stride + x], static_cast<RegType>(phase/(2.*M_PI))); } #endif } __device__ __host__ inline void loadGhost(RegType v[length], int x, int dir, int parity) const { if (!ghost[dir]) { // load from main field not separate array load(v, volumeCB+x, dir, parity); // an offset of size volumeCB puts us at the padded region // This also works perfectly when phases are stored. No need to change this. } else { const int M = reconLen / N; RegType tmp[reconLen]; for (int i=0; i<M; i++) { for (int j=0; j<N; j++) { int intIdx = i*N + j; // internal dof index int padIdx = intIdx / N; #if __COMPUTE_CAPABILITY__ < 200 const int hasPhase = 0; #endif copy(tmp[i*N+j], ghost[dir][parity*faceVolumeCB[dir]*(M*N + hasPhase) + (padIdx*faceVolumeCB[dir]+x)*N + intIdx%N]); } } RegType phase=0.; #if __COMPUTE_CAPABILITY__ >= 200 if(hasPhase) copy(phase, ghost[dir][parity*faceVolumeCB[dir]*(M*N + 1) + faceVolumeCB[dir]*M*N + x]); #endif reconstruct.Unpack(v, tmp, x, dir, 2.*M_PI*phase); } } __device__ __host__ inline void saveGhost(const RegType v[length], int x, int dir, int parity) { if (!ghost[dir]) { // store in main field not separate array save(v, volumeCB+x, dir, parity); // an offset of size volumeCB puts us at the padded region } else { const int M = reconLen / N; RegType tmp[reconLen]; reconstruct.Pack(tmp, v, x); for (int i=0; i<M; i++) { for (int j=0; j<N; j++) { int intIdx = i*N + j; int padIdx = intIdx / N; //copy(ghost[dir][(parity*faceVolumeCB[dir]*M + padIdx*faceVolumeCB[dir]+x)*N + intIdx%N], tmp[i*N+j]); #if __COMPUTE_CAPABILITY__ < 200 const int hasPhase = 0; #endif copy(ghost[dir][parity*faceVolumeCB[dir]*(M*N + hasPhase) + (padIdx*faceVolumeCB[dir]+x)*N + intIdx%N], tmp[i*N+j]); } } #if __COMPUTE_CAPABILITY__ >= 200 if(hasPhase){ RegType phase=0.; reconstruct.getPhase(&phase, v); copy(ghost[dir][parity*faceVolumeCB[dir]*(M*N + 1) + faceVolumeCB[dir]*M*N + x], static_cast<RegType>(phase/(2.*M_PI))); } #endif } } size_t Bytes() const { return reconLen * sizeof(Float); } }; /** The LegacyOrder defines the ghost zone storage and ordering for all cpuGaugeFields, which use the same ghost zone storage. */ template <typename Float, int length> struct LegacyOrder { typedef typename mapper<Float>::type RegType; Float *ghost[QUDA_MAX_DIM]; int faceVolumeCB[QUDA_MAX_DIM]; const int volumeCB; const int stride; const int hasPhase; LegacyOrder(const GaugeField &u, Float **ghost_) : volumeCB(u.VolumeCB()), stride(u.Stride()), hasPhase(0) { for (int i=0; i<4; i++) { ghost[i] = (ghost_) ? ghost_[i] : (Float*)(u.Ghost()[i]); faceVolumeCB[i] = u.SurfaceCB(i)*u.Nface(); // face volume equals surface * depth } } LegacyOrder(const LegacyOrder &order) : volumeCB(order.volumeCB), stride(order.stride), hasPhase(0) { for (int i=0; i<4; i++) { ghost[i] = order.ghost[i]; faceVolumeCB[i] = order.faceVolumeCB[i]; } } virtual ~LegacyOrder() { ; } __device__ __host__ inline void loadGhost(RegType v[length], int x, int dir, int parity) const { for (int i=0; i<length; i++) v[i] = ghost[dir][(parity*faceVolumeCB[dir] + x)*length + i]; } __device__ __host__ inline void saveGhost(const RegType v[length], int x, int dir, int parity) { for (int i=0; i<length; i++) ghost[dir][(parity*faceVolumeCB[dir] + x)*length + i] = v[i]; } }; /** struct to define QDP ordered gauge fields: [[dim]] [[parity][volumecb][row][col]] */ template <typename Float, int length> struct QDPOrder : public LegacyOrder<Float,length> { typedef typename mapper<Float>::type RegType; Float *gauge[QUDA_MAX_DIM]; const int volumeCB; QDPOrder(const GaugeField &u, Float *gauge_=0, Float **ghost_=0) : LegacyOrder<Float,length>(u, ghost_), volumeCB(u.VolumeCB()) { for (int i=0; i<4; i++) gauge[i] = gauge_ ? ((Float**)gauge_)[i] : ((Float**)u.Gauge_p())[i]; } QDPOrder(const QDPOrder &order) : LegacyOrder<Float,length>(order), volumeCB(order.volumeCB) { for(int i=0; i<4; i++) gauge[i] = order.gauge[i]; } virtual ~QDPOrder() { ; } __device__ __host__ inline void load(RegType v[length], int x, int dir, int parity) const { for (int i=0; i<length; i++) { v[i] = (RegType)gauge[dir][(parity*volumeCB + x)*length + i]; } } __device__ __host__ inline void save(const RegType v[length], int x, int dir, int parity) { for (int i=0; i<length; i++) { gauge[dir][(parity*volumeCB + x)*length + i] = (Float)v[i]; } } size_t Bytes() const { return length * sizeof(Float); } }; /** struct to define QDPJIT ordered gauge fields: [[dim]] [[parity][complex][row][col][volumecb]] */ template <typename Float, int length> struct QDPJITOrder : public LegacyOrder<Float,length> { typedef typename mapper<Float>::type RegType; Float *gauge[QUDA_MAX_DIM]; const int volumeCB; QDPJITOrder(const GaugeField &u, Float *gauge_=0, Float **ghost_=0) : LegacyOrder<Float,length>(u, ghost_), volumeCB(u.VolumeCB()) { for (int i=0; i<4; i++) gauge[i] = gauge_ ? ((Float**)gauge_)[i] : ((Float**)u.Gauge_p())[i]; } QDPJITOrder(const QDPJITOrder &order) : LegacyOrder<Float,length>(order), volumeCB(order.volumeCB) { for(int i=0; i<4; i++) gauge[i] = order.gauge[i]; } virtual ~QDPJITOrder() { ; } __device__ __host__ inline void load(RegType v[length], int x, int dir, int parity) const { for (int i=0; i<length; i++) { int z = i%2; int rolcol = i/2; v[i] = (RegType)gauge[dir][((z*(length/2) + rolcol)*2 + parity)*volumeCB + x]; } } __device__ __host__ inline void save(const RegType v[length], int x, int dir, int parity) { for (int i=0; i<length; i++) { int z = i%2; int rolcol = i/2; gauge[dir][((z*(length/2) + rolcol)*2 + parity)*volumeCB + x] = (Float)v[i]; } } size_t Bytes() const { return length * sizeof(Float); } }; /** struct to define MILC ordered gauge fields: [parity][dim][volumecb][row][col] */ template <typename Float, int length> struct MILCOrder : public LegacyOrder<Float,length> { typedef typename mapper<Float>::type RegType; Float *gauge; const int volumeCB; MILCOrder(const GaugeField &u, Float *gauge_=0, Float **ghost_=0) : LegacyOrder<Float,length>(u, ghost_), gauge(gauge_ ? gauge_ : (Float*)u.Gauge_p()), volumeCB(u.VolumeCB()) { ; } MILCOrder(const MILCOrder &order) : LegacyOrder<Float,length>(order), gauge(order.gauge), volumeCB(order.volumeCB) { ; } virtual ~MILCOrder() { ; } __device__ __host__ inline void load(RegType v[length], int x, int dir, int parity) const { for (int i=0; i<length; i++) { v[i] = (RegType)gauge[((parity*volumeCB+x)*4 + dir)*length + i]; } } __device__ __host__ inline void save(const RegType v[length], int x, int dir, int parity) { for (int i=0; i<length; i++) { gauge[((parity*volumeCB+x)*4 + dir)*length + i] = (Float)v[i]; } } size_t Bytes() const { return length * sizeof(Float); } }; /** struct to define CPS ordered gauge fields: [parity][dim][volumecb][col][row] */ template <typename Float, int length> struct CPSOrder : LegacyOrder<Float,length> { typedef typename mapper<Float>::type RegType; Float *gauge; const int volumeCB; const Float anisotropy; const int Nc; CPSOrder(const GaugeField &u, Float *gauge_=0, Float **ghost_=0) : LegacyOrder<Float,length>(u, ghost_), gauge(gauge_ ? gauge_ : (Float*)u.Gauge_p()), volumeCB(u.VolumeCB()), anisotropy(u.Anisotropy()), Nc(3) { if (length != 18) errorQuda("Gauge length %d not supported", length); } CPSOrder(const CPSOrder &order) : LegacyOrder<Float,length>(order), gauge(order.gauge), volumeCB(order.volumeCB), anisotropy(order.anisotropy), Nc(3) { ; } virtual ~CPSOrder() { ; } // we need to transpose and scale for CPS ordering __device__ __host__ inline void load(RegType v[18], int x, int dir, int parity) const { for (int i=0; i<Nc; i++) { for (int j=0; j<Nc; j++) { for (int z=0; z<2; z++) { v[(i*Nc+j)*2+z] = (RegType)(gauge[((((parity*volumeCB+x)*4 + dir)*Nc + j)*Nc + i)*2 + z] / anisotropy); } } } } __device__ __host__ inline void save(const RegType v[18], int x, int dir, int parity) { for (int i=0; i<Nc; i++) { for (int j=0; j<Nc; j++) { for (int z=0; z<2; z++) { gauge[((((parity*volumeCB+x)*4 + dir)*Nc + j)*Nc + i)*2 + z] = (Float)(anisotropy * v[(i*Nc+j)*2+z]); } } } } size_t Bytes() const { return Nc * Nc * 2 * sizeof(Float); } }; /** struct to define BQCD ordered gauge fields: [mu][parity][volumecb+halos][col][row] */ template <typename Float, int length> struct BQCDOrder : LegacyOrder<Float,length> { typedef typename mapper<Float>::type RegType; Float *gauge; const int volumeCB; int exVolumeCB; // extended checkerboard volume const int Nc; BQCDOrder(const GaugeField &u, Float *gauge_=0, Float **ghost_=0) : LegacyOrder<Float,length>(u, ghost_), gauge(gauge_ ? gauge_ : (Float*)u.Gauge_p()), volumeCB(u.VolumeCB()), Nc(3) { if (length != 18) errorQuda("Gauge length %d not supported", length); // compute volumeCB + halo region exVolumeCB = u.X()[0]/2 + 2; for (int i=1; i<4; i++) exVolumeCB *= u.X()[i] + 2; } BQCDOrder(const BQCDOrder &order) : LegacyOrder<Float,length>(order), gauge(order.gauge), volumeCB(order.volumeCB), exVolumeCB(order.exVolumeCB), Nc(3) { if (length != 18) errorQuda("Gauge length %d not supported", length); } virtual ~BQCDOrder() { ; } // we need to transpose for BQCD ordering __device__ __host__ inline void load(RegType v[18], int x, int dir, int parity) const { for (int i=0; i<Nc; i++) { for (int j=0; j<Nc; j++) { for (int z=0; z<2; z++) { v[(i*Nc+j)*2+z] = (RegType)gauge[((((dir*2+parity)*exVolumeCB + x)*Nc + j)*Nc + i)*2 + z]; } } } } __device__ __host__ inline void save(const RegType v[18], int x, int dir, int parity) { for (int i=0; i<Nc; i++) { for (int j=0; j<Nc; j++) { for (int z=0; z<2; z++) { gauge[((((dir*2+parity)*exVolumeCB + x)*Nc + j)*Nc + i)*2 + z] = (Float)v[(i*Nc+j)*2+z]; } } } } size_t Bytes() const { return Nc * Nc * 2 * sizeof(Float); } }; }
37.795389
148
0.589249
3af49153f14a5f1e32643110c361ad975e23d3c3
1,827
c
C
src/pkix/c/struct/CertificateSet.c
player999/cryptonite
d6ad2a0c79d9914bf1ac535f47425eaad56f5be2
[ "BSD-2-Clause" ]
33
2019-05-04T19:22:25.000Z
2022-02-21T14:01:29.000Z
src/pkix/c/struct/CertificateSet.c
player999/cryptonite
d6ad2a0c79d9914bf1ac535f47425eaad56f5be2
[ "BSD-2-Clause" ]
10
2019-05-14T08:33:28.000Z
2022-01-23T16:31:54.000Z
src/pkix/c/struct/CertificateSet.c
player999/cryptonite
d6ad2a0c79d9914bf1ac535f47425eaad56f5be2
[ "BSD-2-Clause" ]
17
2019-05-04T20:11:36.000Z
2022-01-23T14:59:56.000Z
/* * Copyright (c) 2016 PrivatBank IT <acsk@privatbank.ua>. All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ #include "CertificateSet.h" #include "asn_internal.h" #include "CertificateChoices.h" #undef FILE_MARKER #define FILE_MARKER "pkix/struct/CertificateSet.c" static asn_TYPE_member_t asn_MBR_CertificateSet_1[] = { { ATF_POINTER, 0, 0, -1 /* Ambiguous tag (CHOICE?) */, 0, &CertificateChoices_desc, 0, /* Defer constraints checking to the member type */ 0, /* PER is not compiled, use -gen-PER */ 0, "" }, }; static const ber_tlv_tag_t CertificateSet_desc_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_CertificateSet_specs_1 = { sizeof(struct CertificateSet), offsetof(struct CertificateSet, _asn_ctx), 2, /* XER encoding is XMLValueList */ }; asn_TYPE_descriptor_t CertificateSet_desc = { "CertificateSet", "CertificateSet", SET_OF_free, SET_OF_print, SET_OF_constraint, SET_OF_decode_ber, SET_OF_encode_der, SET_OF_decode_xer, SET_OF_encode_xer, 0, 0, /* No PER support, use "-gen-PER" to enable */ 0, /* Use generic outmost tag fetcher */ CertificateSet_desc_tags_1, sizeof(CertificateSet_desc_tags_1) / sizeof(CertificateSet_desc_tags_1[0]), /* 1 */ CertificateSet_desc_tags_1, /* Same as above */ sizeof(CertificateSet_desc_tags_1) / sizeof(CertificateSet_desc_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_CertificateSet_1, 1, /* Single element */ &asn_SPC_CertificateSet_specs_1 /* Additional specs */ }; asn_TYPE_descriptor_t *get_CertificateSet_desc(void) { return &CertificateSet_desc; }
29.467742
78
0.683087
b547b227d8737dffb8fc182356c15af9f19c3cd0
1,525
h
C
XDBannerDemoApp/XDBannerDemoApp/XDBannerView/view/XDBannerView.h
1xd/XdBannerView
6c99d393bdbc1d119a84fe580ff9b7abeceeeac0
[ "MIT" ]
null
null
null
XDBannerDemoApp/XDBannerDemoApp/XDBannerView/view/XDBannerView.h
1xd/XdBannerView
6c99d393bdbc1d119a84fe580ff9b7abeceeeac0
[ "MIT" ]
null
null
null
XDBannerDemoApp/XDBannerDemoApp/XDBannerView/view/XDBannerView.h
1xd/XdBannerView
6c99d393bdbc1d119a84fe580ff9b7abeceeeac0
[ "MIT" ]
null
null
null
// // XDBannerView.h // XDBannerDemoApp // // Created by 1xd' mac on 2020/3/20. // Copyright © 2020 1xd' mac. All rights reserved. // #import <UIKit/UIKit.h> #import "XDBannerPictureModel.h" NS_ASSUME_NONNULL_BEGIN @interface XDBannerView : UIView #pragma mark - Normal initial function with complex initail type of picture and offer click callback /// use array of XDBannerPictureModel - instaces and frame to initialize a banner instance /// @param picModelArr array of XDBannerPictureModel - instaces /// @param bannerFrame frame of this banner - (instancetype)initWithPicModel:(NSArray<XDBannerPictureModel *> *)picModelArr frame:(CGRect)bannerFrame; #pragma mark - Simple initial function without function of clicking picture /// use array of link and frame to initialize a banner instance /// @param picLinks picture url for downloading /// @param bannerFrame frame of this banner - (instancetype)initWithPictureLinks:(NSArray<NSString *> *)picLinks frame:(CGRect)bannerFrame; /// use array of UIImage instance and frame to initialize a banner instance /// @param imgs array of UIImage instance /// @param bannerFrame frame of this banner - (instancetype)initWithImages:(NSArray<UIImage *> *)imgs frame:(CGRect)bannerFrame; /// use array of NSData instance and frame to initialize a banner instance /// @param dataArr array of NSData instance /// @param bannerFrame frame of this banner - (instancetype)initWithDataArray:(NSArray<NSData *> *)dataArr frame:(CGRect)bannerFrame; @end NS_ASSUME_NONNULL_END
35.465116
106
0.773115
beb76742d40a9c3d0bc71cb892b22ca2f11e4d1e
1,932
c
C
backup/vivado_prj/u96_demo/u96_demo.sdk/core0/src/Overlays/stream_ip_bsp/circ_buff_write_128_jump/xcirc_buff_write_128_jump.c
icgrp/estream4fccm2021
1fca4c2108b52bda32262bb016f26fcc7334cb18
[ "MIT" ]
1
2021-04-12T19:22:01.000Z
2021-04-12T19:22:01.000Z
backup/vivado_prj/u96_demo/u96_demo.sdk/core3/src/Overlays/stream_ip_bsp/circ_buff_write_128_jump/xcirc_buff_write_128_jump.c
icgrp/estream4fccm2021
1fca4c2108b52bda32262bb016f26fcc7334cb18
[ "MIT" ]
null
null
null
backup/vivado_prj/u96_demo/u96_demo.sdk/core3/src/Overlays/stream_ip_bsp/circ_buff_write_128_jump/xcirc_buff_write_128_jump.c
icgrp/estream4fccm2021
1fca4c2108b52bda32262bb016f26fcc7334cb18
[ "MIT" ]
null
null
null
#include "../../user_configs.h" #include "../bsp_jump_table.h" #include <stdint.h> #include <stdlib.h> #ifdef CIRCULAR_BUFF_128_IP #include "xcirc_buff_write_128.h" #include "../bsp_jump_table.h" #include <stdint.h> #include <stdlib.h> static int32_t is_circ_buff_write_128_done(void* config) { return -1; } static void start_circ_buff_write_128(void* config) { // XCirc_buff_write_128_Set_reset((XCirc_buff_write_128*)config,0); XCirc_buff_write_128_EnableAutoRestart( (XCirc_buff_write_128*)config ); XCirc_buff_write_128_Start( (XCirc_buff_write_128*)config ); } static int32_t init_circ_buff_write_128(void* config,void* data) { int32_t rval; uint8_t* word_ptr; u32 bram_buff; meta_data_t* ip_data = (meta_data_t*)data; rval = XCirc_buff_write_128_Initialize( (XCirc_buff_write_128*)config, ip_data->bsp_id ); // enable auto restart turning IP into while 1 loop. XCirc_buff_write_128_EnableAutoRestart( (XCirc_buff_write_128*)config ); XCirc_buff_write_128_Set_output_V( (XCirc_buff_write_128*)config, ip_data->offset ); return rval; } static int32_t set_circ_buff_write_128_ptrs( void* config, void* data ) { } static void stop_circ_buff_write_128( void* config ) { // XCirc_buff_write_128_Set_reset((XCirc_buff_write_128*)config,1); // XCirc_buff_write_128_DisableAutoRestart( (XCirc_buff_write_128*)config ); // while(XCirc_buff_write_128_IsDone( (XCirc_buff_write_128*)config )) { } } pr_flow::bsp_device_t circ_buff_write_128_table = { .is_done = is_circ_buff_write_128_done, .start = start_circ_buff_write_128, .init = init_circ_buff_write_128, .set_ptrs = set_circ_buff_write_128_ptrs, .stop = stop_circ_buff_write_128, .debug = NULL }; #else pr_flow::bsp_device_t circ_buff_write_128_table = { .is_done = NULL, .start = NULL, .init = NULL, .set_ptrs = NULL, .stop = NULL, .debug = NULL }; #endif
22.206897
90
0.743271
5dfed493242a948904b994f7f08d4025b4674faa
257
h
C
TTKit/Tools/ZTProgressHUD.h
ShangZhengtao/TTKit
67caadbfa062b70af44616325db897702c56dfec
[ "MIT" ]
null
null
null
TTKit/Tools/ZTProgressHUD.h
ShangZhengtao/TTKit
67caadbfa062b70af44616325db897702c56dfec
[ "MIT" ]
null
null
null
TTKit/Tools/ZTProgressHUD.h
ShangZhengtao/TTKit
67caadbfa062b70af44616325db897702c56dfec
[ "MIT" ]
null
null
null
// // ZTProgressHUD.h // GoldLiving // // Created by apple on 2017/9/26. // Copyright © 2017年 lhb. All rights reserved. // #import <UIKit/UIKit.h> @interface ZTProgressHUD : NSObject +(void)show; +(void)dismiss; +(void)showInfo:(NSString *)text; @end
16.0625
47
0.677043
572d34c0d64499fb5849ef689307802aa754ebdf
23,336
h
C
cpvmm/vmm/include/hw/vtd_hw_layer.h
jlmucb/cloudproxy
b5aa0b619bc454ba4dd183ab1c6c8298a3b9d8c1
[ "Apache-2.0" ]
34
2015-03-10T09:58:23.000Z
2021-08-12T21:42:28.000Z
cpvmm/vmm/include/hw/vtd_hw_layer.h
virginwidow/cloudproxy
b5aa0b619bc454ba4dd183ab1c6c8298a3b9d8c1
[ "Apache-2.0" ]
53
2015-06-09T21:07:41.000Z
2016-12-15T00:14:53.000Z
cpvmm/vmm/include/hw/vtd_hw_layer.h
jethrogb/cloudproxy
fcf90a62bf09c4ecc9812117d065954be8a08da5
[ "Apache-2.0" ]
17
2015-06-09T21:29:23.000Z
2021-03-26T15:35:18.000Z
/* * Copyright (c) 2013 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _VTD_HW_LAYER #define _VTD_HW_LAYER #include "vtd.h" #include "hw_utils.h" #pragma warning(push) #pragma warning(disable:4214) typedef union _DMA_REMAPPING_ROOT_ENTRY_LOW { struct { UINT32 present:1, reserved:11, context_entry_table_ptr_low:20; UINT32 context_entry_table_ptr_high; } bits; UINT64 uint64; } DMA_REMAPPING_ROOT_ENTRY_LOW; typedef union _DMA_REMAPPING_ROOT_ENTRY_HIGH { struct { UINT64 reserved; } bits; UINT64 uint64; } DMA_REMAPPING_ROOT_ENTRY_HIGH; typedef struct _DMA_REMAPPING_ROOT_ENTRY { DMA_REMAPPING_ROOT_ENTRY_LOW low; DMA_REMAPPING_ROOT_ENTRY_HIGH high; } DMA_REMAPPING_ROOT_ENTRY; typedef enum { TRANSLATION_TYPE_UNTRANSLATED_ADDRESS_ONLY = 0, TRANSLATION_TYPE_ALL, TRANSLATION_TYPE_PASSTHROUGH_UNTRANSLATED_ADDRESS } DMA_REMAPPING_TRANSLATION_TYPE; typedef enum { DMA_REMAPPING_GAW_30 = 0, DMA_REMAPPING_GAW_39, DMA_REMAPPING_GAW_48, DMA_REMAPPING_GAW_57, DMA_REMAPPING_GAW_64 } DMA_REMAPPING_GUEST_ADDRESS_WIDTH; typedef union _DMA_REMAPPING_CONTEXT_ENTRY_LOW { struct { UINT32 present:1, fault_processing_disable:1, translation_type:2, eviction_hint:1, // 0 = default, 1 = eager eviction adress_locality_hint:1, // 0 = default, 1 = requests have spatial locality reserved:6, address_space_root_low:20; UINT32 address_space_root_high; } bits; UINT64 uint64; } DMA_REMAPPING_CONTEXT_ENTRY_LOW; typedef union _DMA_REMAPPING_CONTEXT_ENTRY_HIGH { struct { UINT32 address_width:3, available:4, reserved0:1, domain_id:16, reserved1:8; UINT32 reserved; } bits; UINT64 uint64; } DMA_REMAPPING_CONTEXT_ENTRY_HIGH; typedef struct _DMA_REMAPPING_CONTEXT_ENTRY { DMA_REMAPPING_CONTEXT_ENTRY_LOW low; DMA_REMAPPING_CONTEXT_ENTRY_HIGH high; } DMA_REMAPPING_CONTEXT_ENTRY; typedef union _DMA_REMAPPING_PAGE_TABLE_ENTRY { struct { UINT32 read:1, write:1, available0:5, super_page:1, available:3, snoop_behavior:1, // 0 = default, 1 = treat as snooped address_low:20; UINT32 address_high:30, transient_mapping:1, available1:1; } bits; UINT64 uint64; } DMA_REMAPPING_PAGE_TABLE_ENTRY; typedef union _DMA_REMAPPING_FAULT_RECORD_LOW { struct { UINT32 reserved:12, fault_information_low:20; UINT32 fault_information_high; } bits; UINT64 uint64; } DMA_REMAPPING_FAULT_RECORD_LOW; typedef union _DMA_REMAPPING_FAULT_RECORD_HIGH { struct { UINT32 source_id:16, reserved0:16; UINT32 fault_reason:8, reserved1:20, address_type:2, access_type:1, // 0 = write, 1 = read reserved2:1; } bits; UINT64 uint64; } DMA_REMAPPING_FAULT_RECORD_HIGH; typedef struct _DMA_REMAPPING_FAULT_RECORD { DMA_REMAPPING_FAULT_RECORD_LOW low; DMA_REMAPPING_FAULT_RECORD_HIGH high; } DMA_REMAPPING_FAULT_RECORD; typedef enum { SOURCE_ID_QUALIFIER_ALL = 0, SOURCE_ID_QUALIFIER_IGNORE_FUNCTION_MSB, SOURCE_ID_QUALIFIER_IGNORE_2_FUNCTION_MSB, SOURCE_ID_QUALIFIER_IGNORE_FUNCTION } INTERRUPT_REMAPPING_SOURCE_ID_QUALIFIER; typedef enum { SOURCE_ID_VALIDATION_NONE, SOURCE_ID_VALIDATION_AS_BDF, SOURCE_ID_VALIDATION_BUS_IN_RANGE } INTERRUPT_REMAPPING_SOURCE_ID_VALIDATION_TYPE; typedef union _INTERRUPT_REMAPPING_TABLE_ENTRY_LOW { struct { UINT32 present:1, fault_processing_disable:1, destination_mode:1, // 0 = physical APIC ID, 1 = logical APIC ID redirection_hint:1, // 0 = direct to CPU in destination id field, 1 = direct to one CPU from the group trigger_mode:1, // 0 = edge, 1 = level delivery_mode:1, available:4, reserved:4; UINT32 destination_id; } bits; UINT64 uint64; } INTERRUPT_REMAPPING_TABLE_ENTRY_LOW; typedef union _INTERRUPT_REMAPPING_TABLE_ENTRY_HIGH { struct { UINT32 source_id:16, source_id_qualifier:2, source_validation_type:2, reserved0:12; UINT32 reserved1; } bits; UINT64 uint64; } INTERRUPT_REMAPPING_TABLE_ENTRY_HIGH; typedef struct _INTERRUPT_REMAPPING_TABLE_ENTRY { INTERRUPT_REMAPPING_TABLE_ENTRY_LOW low; INTERRUPT_REMAPPING_TABLE_ENTRY_HIGH high; } INTERRUPT_REMAPPING_TABLE_ENTRY; // vtd registers #define VTD_VERSION_REGISTER_OFFSET 0x0000 #define VTD_CAPABILITY_REGISTER_OFFSET 0x0008 #define VTD_EXTENDED_CAPABILITY_REGISTER_OFFSET 0x0010 #define VTD_GLOBAL_COMMAND_REGISTER_OFFSET 0x0018 #define VTD_GLOBAL_STATUS_REGISTER_OFFSET 0x001C #define VTD_ROOT_ENTRY_TABLE_ADDRESS_REGISTER_OFFSET 0x0020 #define VTD_CONTEXT_COMMAND_REGISTER_OFFSET 0x0028 #define VTD_FAULT_STATUS_REGISTER_OFFSET 0x0034 #define VTD_FAULT_EVENT_CONTROL_REGISTER_OFFSET 0x0038 #define VTD_FAULT_EVENT_DATA_REGISTER_OFFSET 0x003C #define VTD_FAULT_EVENT_ADDRESS_REGISTER_OFFSET 0x0040 #define VTD_FAULT_EVENT_ADDRESS_HIGH_REGISTER_OFFSET 0x0044 #define VTD_ADVANCED_FAULT_LOG_REGISTER_OFFSET 0x0058 #define VTD_PROTECTED_MEMORY_ENABLE_REGISTER_OFFSET 0x0064 #define VTD_PROTECTED_LOW_MEMORY_BASE_REGISTER_OFFSET 0x0068 #define VTD_PROTECTED_LOW_MEMORY_LIMIT_REGISTER_OFFSET 0x006C #define VTD_PROTECTED_HIGH_MEMORY_BASE_REGISTER_OFFSET 0x0070 #define VTD_PROTECTED_HIGH_MEMORY_LIMIT_REGISTER_OFFSET 0x0078 #define VTD_INVALIDATION_QUEUE_HEAD_REGISTER_OFFSET 0x0080 #define VTD_INVALIDATION_QUEUE_TAIL_REGISTER_OFFSET 0x0088 #define VTD_INVALIDATION_QUEUE_ADDRESS_REGISTER_OFFSET 0x0090 #define VTD_INVALIDATION_COMPLETION_STATUS_REGISTER_OFFSET 0x009C #define VTD_INVALIDATION_COMPLETION_EVENT_CONTROL_REGISTER_OFFSET 0x00A0 #define VTD_INVALIDATION_COMPLETION_EVENT_DATA_REGISTER_OFFSET 0x00A4 #define VTD_INVALIDATION_COMPLETION_EVENT_ADDRESS_REGISTER_OFFSET 0x00A8 #define VTD_INVALIDATION_COMPLETION_EVENT_ADDRESS_HIGH_REGISTER_OFFSET 0x00AC #define VTD_INTERRUPT_REMAPPING_TABLE_ADDRESS_REGISTER_OFFSET 0x00A0 // definition for "Snoop Behavior" and "Transient Mapping" filds in VT-d page tables #define VTD_SNPB_SNOOPED 1 #define VTD_NON_SNPB_SNOOPED 0 #define VTD_TRANSIENT_MAPPING 1 #define VTD_NON_TRANSIENT_MAPPING 0 typedef union { struct { UINT32 minor:4; UINT32 major:4; UINT32 reserved:24; } bits; UINT32 uint32; } VTD_VERSION_REGISTER; typedef enum { VTD_NUMBER_OF_SUPPORTED_DOMAINS_16 = 0, VTD_NUMBER_OF_SUPPORTED_DOMAINS_64, VTD_NUMBER_OF_SUPPORTED_DOMAINS_256, VTD_NUMBER_OF_SUPPORTED_DOMAINS_1024, VTD_NUMBER_OF_SUPPORTED_DOMAINS_4K, VTD_NUMBER_OF_SUPPORTED_DOMAINS_16K, VTD_NUMBER_OF_SUPPORTED_DOMAINS_64K } VTD_NUMBER_OF_SUPPORTED_DOMAINS; #define VTD_SUPER_PAGE_SUPPORT_21(sp_support) ((sp_support) & 0x0001) #define VTD_SUPER_PAGE_SUPPORT_30(sp_support) ((sp_support) & 0x0010) #define VTD_SUPER_PAGE_SUPPORT_39(sp_support) ((sp_support) & 0x0100) #define VTD_SUPER_PAGE_SUPPORT_48(sp_support) ((sp_support) & 0x1000) typedef union { struct { UINT32 number_of_domains:3, advanced_fault_log:1, required_write_buffer_flush:1, protected_low_memory_region:1, // 0 = not supported, 1 = supported protected_high_memory_region:1, // 0 = not supported, 1 = supported caching_mode:1, adjusted_guest_address_width:5, reserved0:3, max_guest_address_width:6, zero_length_read:1, isochrony:1, fault_recording_register_offset_low:8; UINT32 fault_recording_register_offset_high:2, super_page_support:4, reserved1:1, page_selective_invalidation:1, // 0 = not supported (only global and domain), 1 = supported number_of_fault_recording_registers:8, max_address_mask_value:6, dma_write_draining:1, // 0 = not supported, 1 = supported dma_read_draining:1, // 0 = not supported, 1 = supported reserved2:8; } bits; UINT64 uint64; } VTD_CAPABILITY_REGISTER; typedef union { struct { UINT32 coherency:1, // 0 = not-snooped, 1 = snooped queued_invalidation:1, // 0 = not-supported, 1 = supported device_iotlb:1, interrupt_remapping:1, extended_interrupt_mode:1, // 0 = 8-bit APIC id, 1 = 16-bit (x2APIC) caching_hints:1, pass_through:1, snoop_control:1, iotlb_register_offset:10, reserved0:2, max_handle_mask_value:4, reserved1:8; UINT32 reserved2; } bits; UINT64 uint64; } VTD_EXTENDED_CAPABILITY_REGISTER; typedef union { struct { UINT32 reserved0:23; UINT32 compatibility_format_interrupt:1; // 0 = block; 1 = pass-through UINT32 set_interrupt_remap_table_ptr:1; UINT32 interrupt_remap_enable:1; UINT32 queued_invalidation_enable:1; UINT32 write_buffer_flush:1; UINT32 advanced_fault_log_enable:1; UINT32 set_advanced_fault_log_ptr:1; UINT32 set_root_table_ptr:1; UINT32 translation_enable:1; } bits; UINT32 uint32; } VTD_GLOBAL_COMMAND_REGISTER; typedef union { struct { UINT32 reserved0:23; UINT32 compatibility_format_interrupt_status:1; UINT32 interrupt_remap_table_ptr_status:1; UINT32 interrupt_remap_enable_status:1; UINT32 queued_invalidation_enable_status:1; UINT32 write_buffer_flush_status:1; UINT32 advanced_fault_log_enable_status:1; UINT32 advanced_fault_log_ptr_status:1; UINT32 root_table_ptr_status:1; UINT32 translation_enable_status:1; } bits; UINT32 uint32; } VTD_GLOBAL_STATUS_REGISTER; typedef union { struct { UINT32 reserved:12, address_low:20; UINT32 address_high; } bits; UINT64 uint64; } VTD_ROOT_ENTRY_TABLE_ADDRESS_REGISTER; typedef enum { VTD_CONTEXT_INV_GRANULARITY_GLOBAL = 0x1, VTD_CONTEXT_INV_GRANULARITY_DOMAIN = 0x2, VTD_CONTEXT_INV_GRANULARITY_DEVICE = 0x3 } VTD_CONTEXT_INV_GRANULARITY; typedef union { struct { UINT32 domain_id:16, source_id:16; UINT32 function_mask:2, reserved:25, context_actual_invld_granularity:2, context_invld_request_granularity:2, invalidate_context_cache:1; } bits; UINT64 uint64; } VTD_CONTEXT_COMMAND_REGISTER; typedef enum { VTD_IOTLB_INV_GRANULARITY_GLOBAL = 0x1, VTD_IOTLB_INV_GRANULARITY_DOMAIN = 0x2, VTD_IOTLB_INV_GRANULARITY_PAGE = 0x3 } VTD_IOTLB_INV_GRANULARITY; typedef union { struct { UINT32 reserved0; UINT32 domain_id:16, drain_writes:1, drain_reads:1, reserved1:7, iotlb_actual_invld_granularity:3, iotlb_invld_request_granularity:3, invalidate_iotlb:1; } bits; UINT64 uint64; } VTD_IOTLB_INVALIDATE_REGISTER; typedef union { struct { UINT32 address_mask:6, invalidation_hint:1, reserved:5, address_low:20; UINT32 address_high; } bits; UINT64 uint64; } VTD_INVALIDATE_ADDRESS_REGISTER; typedef union { struct { UINT32 fault_overflow:1; UINT32 primary_pending_fault:1; UINT32 advanced_fault_overflow:1; UINT32 advanced_pending_fault:1; UINT32 invalidation_queue_error:1; UINT32 invalidation_completion_error:1; UINT32 invalidation_timeout_error:1; UINT32 reserved0:1; UINT32 fault_record_index:8; UINT32 reserved1:16; } bits; UINT32 uint32; } VTD_FAULT_STATUS_REGISTER; typedef union { struct { UINT32 reserved:30; UINT32 interrupt_pending:1; UINT32 interrupt_mask:1; } bits; UINT32 uint32; } VTD_FAULT_EVENT_CONTROL_REGISTER; typedef union { struct { UINT32 vector:8; UINT32 delivery_mode:3; // 0 = fixed; 1=lowest priority UINT32 reserved:3; UINT32 trigger_mode_level:1; UINT32 trigger_mode:1; UINT32 reserved1:18; } bits; UINT32 uint32; } VTD_FAULT_EVENT_DATA_REGISTER; typedef union { struct { UINT32 reserved0:2; UINT32 destination_mode:1; UINT32 redirection_hint:1; UINT32 reserved1:8; UINT32 destination_id:8; UINT32 reserved2:12; // reserved to 0xfee } bits; UINT32 uint32; } VTD_FAULT_EVENT_ADDRESS_REGISTER; typedef struct { UINT32 reserved; } VTD_FAULT_EVENT_UPPER_ADDRESS_REGISTER; typedef union { struct { UINT32 reserved:12, fault_info_low:20; UINT32 fault_info_high; } bits; UINT64 uint64; } VTD_FAULT_RECORDING_REGISTER_LOW; typedef union { struct { UINT32 source_id:16, reserved0:16; UINT32 fault_reason:8, reserved1:20, address_type:2, request_type:1, // 0 = write; 1 = read fault:1; } bits; UINT64 uint64; } VTD_FAULT_RECORDING_REGISTER_HIGH; typedef struct { VTD_FAULT_RECORDING_REGISTER_LOW low; VTD_FAULT_RECORDING_REGISTER_HIGH high; } VTD_FAULT_RECORDING_REGISTER; typedef union { struct { UINT32 reserved:9, fault_log_size:3, fault_log_address_low:20; UINT32 fault_log_address_high; } bits; UINT64 uint64; } VTD_ADVANCED_FAULT_LOG_REGISTER; typedef union { struct { UINT32 protected_region_status:1; UINT32 reserved_p:30; UINT32 enable_protected_memory:1; } bits; UINT32 uint32; } VTD_PROTECTED_MEMORY_ENABLE_REGISTER; typedef union { struct { UINT32 reserved0:4, queue_head:15, // 128-bit aligned reserved1:13; UINT32 reserved2; } bits; UINT64 uint64; } VTD_INVALIDATION_QUEUE_HEAD_REGISTER; typedef union { struct { UINT32 reserved0:4, queue_tail:15, // 128-bit aligned reserved1:13; UINT32 reserved2; } bits; UINT64 uint64; } VTD_INVALIDATION_QUEUE_TAIL_REGISTER; typedef union { struct { UINT32 queue_size:3, reserved:9, queue_base_low:20; UINT32 queue_base_high; } bits; UINT64 uint64; } VTD_INVALIDATION_QUEUE_ADDRESS_REGISTER; typedef union { struct { UINT32 wait_descriptor_complete:1; UINT32 reserved:31; } bits; UINT32 uint32; } VTD_INVALIDATION_COMPLETION_STATUS_REGISTER; typedef union { struct { UINT32 reserved:30; UINT32 interrupt_pending:1; UINT32 interrupt_mask:1; } bits; UINT32 uint32; } VTD_INVALIDATION_EVENT_CONTROL_REGISTER; typedef union { struct { UINT32 interrupt_message_data:16; UINT32 extended_interrupt_message_data:16; } bits; UINT32 uint32; } VTD_INVALIDATION_EVENT_DATA_REGISTER; typedef union { struct { UINT32 reserved:2; UINT32 message_address:30; } bits; UINT32 uint32; } VTD_INVALIDATION_EVENT_ADDRESS_REGISTER; typedef struct { UINT32 message_upper_address; } VTD_INVALIDATION_EVENT_UPPER_ADDRESS_REGISTER; typedef union { struct { UINT32 size:4, reserved:7, extended_interrupt_mode_enable:1, address_low:20; UINT32 address_high; } bits; UINT64 uint64; } VTD_INTERRUPT_REMAPPING_TABLE_ADDRESS_REGISTER; #pragma warning(pop) typedef enum { VTD_POWER_ACTIVE, VTD_POWER_SUSPEND, VTD_POWER_RESUME } VTD_POWER_STATE; typedef struct _VTD_DMA_REMAPPING_HW_UNIT { UINT32 id; VTD_DOMAIN_ID avail_domain_id; LIST_ELEMENT domain_list; UINT64 register_base; UINT32 num_devices; VMM_LOCK hw_lock; VTD_POWER_STATE power_state; VTD_CAPABILITY_REGISTER capability; VTD_EXTENDED_CAPABILITY_REGISTER extended_capability; DMAR_DEVICE *devices; DMA_REMAPPING_ROOT_ENTRY *root_entry_table; } VTD_DMA_REMAPPING_HW_UNIT; BOOLEAN vtd_hw_set_root_entry_table(VTD_DMA_REMAPPING_HW_UNIT *dmar, DMA_REMAPPING_ROOT_ENTRY *root_entry_table); BOOLEAN vtd_hw_enable_translation(VTD_DMA_REMAPPING_HW_UNIT *dmar); void vtd_hw_disable_translation(VTD_DMA_REMAPPING_HW_UNIT *dmar); BOOLEAN vtd_hw_enable_interrupt_remapping(VTD_DMA_REMAPPING_HW_UNIT *dmar); void vtd_hw_disable_interrupt_remapping(VTD_DMA_REMAPPING_HW_UNIT *dmar); void vtd_hw_inv_context_cache_global(VTD_DMA_REMAPPING_HW_UNIT *dmar); void vtd_hw_flush_write_buffers(VTD_DMA_REMAPPING_HW_UNIT *dmar); void vtd_hw_inv_iotlb_global(VTD_DMA_REMAPPING_HW_UNIT *dmar); void vtd_hw_inv_iotlb_page(VTD_DMA_REMAPPING_HW_UNIT *dmar, ADDRESS addr, size_t size, VTD_DOMAIN_ID domain_id); UINT32 vtd_hw_get_protected_low_memory_base_alignment(VTD_DMA_REMAPPING_HW_UNIT *dmar); UINT32 vtd_hw_get_protected_low_memory_limit_alignment(VTD_DMA_REMAPPING_HW_UNIT *dmar); UINT64 vtd_hw_get_protected_high_memory_base_alignment(VTD_DMA_REMAPPING_HW_UNIT *dmar); UINT64 vtd_hw_get_protected_high_memory_limit_alignment(VTD_DMA_REMAPPING_HW_UNIT *dmar); BOOLEAN vtd_hw_setup_protected_low_memory(VTD_DMA_REMAPPING_HW_UNIT *dmar, UINT32 base, UINT32 limit); BOOLEAN vtd_hw_setup_protected_high_memory(VTD_DMA_REMAPPING_HW_UNIT *dmar, UINT64 base, UINT64 limit); BOOLEAN vtd_hw_enable_protected_memory(VTD_DMA_REMAPPING_HW_UNIT *dmar); void vtd_hw_disable_protected_memory(VTD_DMA_REMAPPING_HW_UNIT *dmar); BOOLEAN vtd_hw_is_protected_memory_enabled(VTD_DMA_REMAPPING_HW_UNIT *dmar); // hw read/write UINT32 vtd_hw_read_reg32(VTD_DMA_REMAPPING_HW_UNIT *dmar, UINT64 reg); void vtd_hw_write_reg32(VTD_DMA_REMAPPING_HW_UNIT *dmar, UINT64 reg, UINT32 value); UINT64 vtd_hw_read_reg64(VTD_DMA_REMAPPING_HW_UNIT *dmar, UINT64 reg); void vtd_hw_write_reg64(VTD_DMA_REMAPPING_HW_UNIT *dmar, UINT64 reg, UINT64 value); // capabilities INLINE UINT32 vtd_hw_get_super_page_support(VTD_DMA_REMAPPING_HW_UNIT *dmar) { return (UINT32) dmar->capability.bits.super_page_support; } INLINE UINT32 vtd_hw_get_supported_ajusted_guest_address_width(VTD_DMA_REMAPPING_HW_UNIT *dmar) { return (UINT32) dmar->capability.bits.adjusted_guest_address_width; } INLINE UINT32 vtd_hw_get_max_guest_address_width(VTD_DMA_REMAPPING_HW_UNIT *dmar) { return (UINT32) dmar->capability.bits.max_guest_address_width; } INLINE UINT32 vtd_hw_get_number_of_domains(VTD_DMA_REMAPPING_HW_UNIT *dmar) { return (UINT32) dmar->capability.bits.number_of_domains; } INLINE UINT32 vtd_hw_get_caching_mode(VTD_DMA_REMAPPING_HW_UNIT *dmar) { return (UINT32) dmar->capability.bits.caching_mode; } INLINE UINT32 vtd_hw_get_required_write_buffer_flush(VTD_DMA_REMAPPING_HW_UNIT *dmar) { return (UINT32) dmar->capability.bits.required_write_buffer_flush; } INLINE UINT32 vtd_hw_get_coherency(VTD_DMA_REMAPPING_HW_UNIT *dmar) { return (UINT32) dmar->extended_capability.bits.coherency; } INLINE UINT32 vtd_hw_get_protected_low_memory_support(VTD_DMA_REMAPPING_HW_UNIT *dmar) { return (UINT32) dmar->capability.bits.protected_low_memory_region; } INLINE UINT32 vtd_hw_get_protected_high_memory_support(VTD_DMA_REMAPPING_HW_UNIT *dmar) { return (UINT32) dmar->capability.bits.protected_high_memory_region; } // fault handling INLINE UINT32 vtd_hw_get_number_of_fault_recording_regs(VTD_DMA_REMAPPING_HW_UNIT *dmar) { return (UINT32) dmar->capability.bits.number_of_fault_recording_registers; } INLINE UINT64 vtd_hw_get_fault_recording_reg_offset(VTD_DMA_REMAPPING_HW_UNIT *dmar, UINT32 fault_record_index) { UINT32 fault_recording_register_offset = dmar->capability.bits.fault_recording_register_offset_high << 8 | dmar->capability.bits.fault_recording_register_offset_low; return (16 * fault_recording_register_offset) + (sizeof(VTD_FAULT_RECORDING_REGISTER) * fault_record_index); } void vtd_hw_mask_fault_interrupt(VTD_DMA_REMAPPING_HW_UNIT *dmar); void vtd_hw_unmask_fault_interrupt(VTD_DMA_REMAPPING_HW_UNIT *dmar); UINT32 vtd_hw_get_fault_overflow(VTD_DMA_REMAPPING_HW_UNIT *dmar); UINT32 vtd_hw_get_primary_fault_pending(VTD_DMA_REMAPPING_HW_UNIT *dmar); UINT32 vtd_hw_get_fault_record_index(VTD_DMA_REMAPPING_HW_UNIT *dmar); void vtd_hw_set_fault_event_data(VTD_DMA_REMAPPING_HW_UNIT *dmar, UINT8 vector, UINT8 delivery_mode, UINT32 trigger_mode_level, UINT32 trigger_mode); void vtd_hw_set_fault_event_addr(VTD_DMA_REMAPPING_HW_UNIT *dmar, UINT8 dest_mode, UINT8 dest_id); void vtd_hw_clear_fault_overflow(VTD_DMA_REMAPPING_HW_UNIT *dmar); UINT64 vtd_hw_read_fault_register(VTD_DMA_REMAPPING_HW_UNIT *dmar, UINT32 fault_record_index); UINT64 vtd_hw_read_fault_register_high(VTD_DMA_REMAPPING_HW_UNIT *dmar, UINT32 fault_record_index); void vtd_hw_clear_fault_register(VTD_DMA_REMAPPING_HW_UNIT *dmar, UINT32 fault_record_index); void vtd_hw_print_capabilities(VTD_DMA_REMAPPING_HW_UNIT *dmar); void vtd_print_hw_status(VTD_DMA_REMAPPING_HW_UNIT *dmar); #endif
28.809877
114
0.690093
461605bb74f39a8c5e94d45b97c3cc4698e7c726
1,893
h
C
ELITPCdcs/server/include/TPG362.h
m-fila/ELITPCdcs
5c6fdc09fb4c3c63139f8adc3e303ba74a3ad94e
[ "MIT" ]
null
null
null
ELITPCdcs/server/include/TPG362.h
m-fila/ELITPCdcs
5c6fdc09fb4c3c63139f8adc3e303ba74a3ad94e
[ "MIT" ]
null
null
null
ELITPCdcs/server/include/TPG362.h
m-fila/ELITPCdcs
5c6fdc09fb4c3c63139f8adc3e303ba74a3ad94e
[ "MIT" ]
null
null
null
#ifndef TPG362_H #define TPG362_H #include "DCSGenericDevice.h" class TPG362 : public DCSGenericDevice { public: TPG362(); enum class CH { ALL, CH1, CH2 }; enum class UNIT { mbar, torr, pascal, micron, hpascal, Volt }; enum class FORMAT { floating, scientific }; enum class STATUS { nochange, off, on }; enum class SWITCHING_FUNCTION { F1 = 1, F2, F3, F4 }; enum class SWITCHING_STATUS { off, on, CH1, CH2 }; enum class FILTER { off, fast, normal, slow }; // device specific commands std::string getGaugesData(CH ch = CH::ALL); std::string getGaugesIdentification(); std::string getUnits(); // returns a,b,c,d -- 0 (OFF), 1 (ON) status std::string getSwitchingFunctionStatus(); // returns a,x.xxxxEsxx,y.yyyyEsyy -- assignment, setpoint,hysteresis, std::string getSwitchingFunction(SWITCHING_FUNCTION f); std::string getFilter(); std::string setFormat(FORMAT format); std::string setGaugesStatus(STATUS s1 = STATUS::nochange, STATUS s2 = STATUS::nochange); std::string setUnits(UNIT unit); std::string setDisplayResolution(int r1 = 0, int r2 = 0); std::string setSwitchingFunction(SWITCHING_FUNCTION f, SWITCHING_STATUS s, double lowThreshold, double highThreshold); std::string setFilter(FILTER f1, FILTER f2); void Reset() {} std::string getTemperature(); std::string getVendor() override { return "Pfeiffer"; } std::string getModel() override; std::string getSerialNumber() override; std::string getPartNumber() override; std::string getFirmwareVersion() override; std::string getHardwareVersion() override; private: const std::string enq = std::string(1, 5); std::string sendWithEnquiry(std::string command); std::string parseIdentifier(size_t n); }; #endif // TPG362_H
35.716981
80
0.662969
04514a693028122f32da13a47a41f7ed22c482ec
709
h
C
gvideoapp/GVVideoCameraViewController.h
gauravk92/GVideoApp
ca6b03839fe54fc2645ae77b2291e96c8be830b5
[ "BSD-2-Clause" ]
null
null
null
gvideoapp/GVVideoCameraViewController.h
gauravk92/GVideoApp
ca6b03839fe54fc2645ae77b2291e96c8be830b5
[ "BSD-2-Clause" ]
null
null
null
gvideoapp/GVVideoCameraViewController.h
gauravk92/GVideoApp
ca6b03839fe54fc2645ae77b2291e96c8be830b5
[ "BSD-2-Clause" ]
null
null
null
// // GVVideoCameraViewController.h // gvideoapp // // Created by Gaurav Khanna on 5/31/14. // Copyright (c) 2014 Gapps. All rights reserved. // #import <UIKit/UIKit.h> #import "GVProgressNavigationBar.h" extern NSString * const GVVideoCameraViewControllerFillProgressBarAnimation; extern NSString * const GVVideoCameraViewControllerFinishProgressBarAnimation; extern NSString * const GVVideoCameraViewControllerFlipCameraDeviceAnimation; extern NSString * const GVVideoCameraViewControllerFinishSavingVideo; extern NSString * const GVVideoCameraViewControllerSendVideoNotification; @interface GVVideoCameraViewController : UINavigationController @property (nonatomic, copy) NSString *threadId; @end
30.826087
78
0.830748
a42c7beb3075d171433c2effb27023c72f2f2733
1,247
h
C
lib_log.h
jackkum/stm8_libs
d8f2d0b954a6be6de83983180a2ba26343953e42
[ "MIT" ]
25
2018-10-21T05:07:01.000Z
2021-12-09T17:15:44.000Z
lib_log.h
chiakistar/stm8_libs
faed946d0db57dad194440cc8413bdb1b2a3427f
[ "MIT" ]
2
2019-08-03T13:50:47.000Z
2019-08-08T00:03:59.000Z
lib_log.h
chiakistar/stm8_libs
faed946d0db57dad194440cc8413bdb1b2a3427f
[ "MIT" ]
10
2019-03-07T09:14:23.000Z
2022-03-25T00:50:16.000Z
/* * File name: lib_log.h * Date first: 03/26/2018 * Date last: 08/21/2018 * * Description: Library for maintaining a many entry system log * * Author: Richard Hodges * * Copyright (C) 2018 Richard Hodges. All rights reserved. * Permission is hereby granted for any use. * ****************************************************************************** * * Log entry */ typedef struct { unsigned long stamp; /* non-zero, unique timestamp */ char type; /* entry type */ char clock_h; /* clock hour */ char clock_m; /* clock minute */ char clock_s; /* clock second */ } LOG_ENTRY; /* * Initialize the log library * in: base address, number of entries */ void log_init(char *, short); /* * Advance log timestamp * (call every second) */ void log_second(void); /* * Erase all log entries */ void log_erase(void); /* * Write new log entry * in: event type * out: zero = success */ char log_write(char); /* * Scan all log entries * in: callback function for each entry */ void log_scan(void (*callback)(LOG_ENTRY *)); /* * Get count of valid log entries */ short log_valid(void); /* * Write word to EEPROM * in: source, dest */ void eeprom_word(char *, char *);
18.338235
79
0.592622
a4e2cfcd53dbdc05153ef7c6db12a6bb9fc1ec52
21,144
h
C
MSVC/14.24.28314/crt/src/concrt/ThreadProxyFactory.h
825126369/UCRT
8853304fdc2a5c216658d08b6dbbe716aa2a7b1f
[ "MIT" ]
2
2021-01-27T10:19:30.000Z
2021-02-09T06:24:30.000Z
MSVC/14.24.28314/crt/src/concrt/ThreadProxyFactory.h
825126369/UCRT
8853304fdc2a5c216658d08b6dbbe716aa2a7b1f
[ "MIT" ]
null
null
null
MSVC/14.24.28314/crt/src/concrt/ThreadProxyFactory.h
825126369/UCRT
8853304fdc2a5c216658d08b6dbbe716aa2a7b1f
[ "MIT" ]
1
2021-01-27T10:19:36.000Z
2021-01-27T10:19:36.000Z
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // ThreadProxyFactory.h // // Factory for creating thread proxies. // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- namespace Concurrency { namespace details { struct IThreadProxyFactory { virtual ::Concurrency::IThreadProxy* RequestProxy(unsigned int stackSize, int contextPriority) =0; virtual void ReclaimProxy(::Concurrency::IThreadProxy* pThreadProxy) =0; virtual LONG Reference() =0; virtual LONG Release() =0; virtual DWORD GetExecutionResourceTls() =0; virtual ~IThreadProxyFactory() {} }; class ThreadProxyFactoryManager; #pragma warning (push) #pragma warning (disable : 4702) // unreachable code template <typename threadProxy> class ThreadProxyFactory : public IThreadProxyFactory { public: /// <summary> /// Returns a thread proxy from a pool of proxies, creating a new one, if needed. /// </summary> /// <param name = stackSize"> /// The required minimum stack size for the thread proxy. /// </param> /// <param name = contextPriority"> /// The required thread priority for the thread proxy. /// </param> virtual ::Concurrency::IThreadProxy* RequestProxy(unsigned int stackSize, int contextPriority) { // Based on the requested stack size of the proxy, find the index into the pool array. threadProxy * pProxy = NULL; for (int i = 0; i < s_numBuckets; ++i) { if (stackSize <= s_proxyStackSize[i]) { pProxy = m_proxyPool[i].Pop(); if (pProxy != NULL) break; } } if (pProxy == NULL) { // Either we couldn't find a proxy in one of the pools, or we received a stack size // larger than the largest size we pool. pProxy = Create(stackSize); } if (pProxy != NULL) { Prepare(pProxy, contextPriority); } return pProxy; } /// <summary> /// Returns a proxy back to the idle pool for reuse. /// </summary> /// <param name="pThreadProxy"> /// The thread proxy being returned. /// </param> virtual void ReclaimProxy(::Concurrency::IThreadProxy* pThreadProxy) { threadProxy * pProxy = static_cast<threadProxy *>(pThreadProxy); for (int i = 0; i < s_numBuckets; ++i) { if (pProxy->GetStackSize() == s_proxyStackSize[i]) { // If the pool is close to full, cancel the proxy and allow the thread to exit. if (m_proxyPool[i].Count() < s_bucketSize) { m_proxyPool[i].Push(pProxy); pProxy = NULL; } break; } } if (pProxy != NULL) { Retire(pProxy); } } /// <summary> /// Destroys a thread proxy factory. /// </summary> virtual ~ThreadProxyFactory() { } /// <summary> /// Retires the proxies that are present in the free pools of a thread proxy factory, causing them to run to /// completion, and exit. /// </summary> void RetireThreadProxies() { for (int i = 0; i < s_numBuckets; ++i) { threadProxy *pProxy = m_proxyPool[i].Flush(); while (pProxy != NULL) { threadProxy *pNextProxy = LockFreeStack<threadProxy>::Next(pProxy); // Retiring the proxy will cause it to perform any necessary cleanup, and exit its dispatch loop. Retire(pProxy); pProxy = pNextProxy; } } } /// <summary> /// Initiates shutdown of the factory, and deletes it if shutdown can be completed inline. /// </summary> virtual void ShutdownFactory() =0; /// <summary> /// Returns a TLS index used by thread proxies and subscribed threads to store per-thread data. /// </summary> virtual DWORD GetExecutionResourceTls() { return m_executionResourceTlsIndex; } protected: /// <summary> /// Protected constructor. All construction must go through the CreateFactory API. /// </summary> ThreadProxyFactory(ThreadProxyFactoryManager * pManager); /// <summary> /// Initialize static data /// </summary> static void StaticInitialize() { if (s_bucketSize == 0) { s_bucketSize = 4*::Concurrency::GetProcessorCount(); } ASSERT(s_bucketSize >= 4); } protected: /// <summary> /// Creates a new thread proxy. /// </summary> /// <param name="stackSize"> /// The stack size for the thread proxy. /// </param> virtual threadProxy* Create(unsigned int stackSize) =0; /// <summary> /// Retires a thread proxy. /// </summary> virtual void Retire(threadProxy *pProxy) =0; /// <summary> /// Prepares a thread proxy for use. /// </summary> /// <param name="pProxy"> /// The proxy to prepare. /// </param> /// <param name="contextPriority"> /// The required thread priority for the thread proxy. /// <param> virtual void Prepare(threadProxy *pProxy, int contextPriority) { // // Adjust the thread priority if necessary. // if (pProxy->GetPriority() != contextPriority) { pProxy->SetPriority(contextPriority); } } // Each factory supports a small number of pools of specific stack sizes. // Currently supported stack sizes are the default process stack size, 64KB, 256KB and 1024KB (1MB) static const int s_numBuckets = 4; static int s_bucketSize; static const unsigned int s_proxyStackSize[s_numBuckets]; // Cached copy of the execution resource TLS index that was created by the factory manager. DWORD m_executionResourceTlsIndex; // A list that will hold thread proxies. LockFreeStack<threadProxy> m_proxyPool[s_numBuckets]; }; #pragma warning (pop) template <typename threadProxy> int ThreadProxyFactory<threadProxy>::s_bucketSize = 0; template <typename threadProxy> const unsigned int ThreadProxyFactory<threadProxy>::s_proxyStackSize[s_numBuckets] = { 0, 64, 256, 1024 }; /// <summary> /// A factory that creates thread proxies for thread schedulers. /// </summary> #pragma warning(push) #pragma warning(disable: 4324) // structure was padded due to alignment specifier class FreeThreadProxyFactory : public ThreadProxyFactory<FreeThreadProxy> { public: /// <summary> /// Creates a singleton thread proxy factory. /// </summary> static FreeThreadProxyFactory * CreateFactory(ThreadProxyFactoryManager * pManager) { StaticInitialize(); return _concrt_new FreeThreadProxyFactory(pManager); } /// <summary> /// Destroys a free thread proxy factory. /// </summary> virtual ~FreeThreadProxyFactory() { } /// <summary> /// Adds a reference to the thread proxy factory. /// </summary> LONG Reference() { return InterlockedIncrement(&m_referenceCount); } /// <summary> /// Releases a reference on the thread proxy factory. /// </summary> LONG Release() { LONG refCount = InterlockedDecrement(&m_referenceCount); if (refCount == 0) delete this; return refCount; } /// <summary> /// Returns a proxy back to the idle pool, for reuse. /// </summary> /// <param name="pThreadProxy"> /// The thread proxy being returned. /// </param> virtual void ReclaimProxy(::Concurrency::IThreadProxy* pThreadProxy) { FreeThreadProxy * pProxy = static_cast<FreeThreadProxy *>(pThreadProxy); // If the factory has been shut down, we should retire the proxy right away. if (!m_fShutdown) { for (int i = 0; i < s_numBuckets; ++i) { if (pProxy->GetStackSize() == s_proxyStackSize[i]) { // If the pool is close to full, cancel the proxy and allow the thread to exit. if (m_proxyPool[i].Count() < s_bucketSize) { m_proxyPool[i].Push(pProxy); // After adding the thread proxy to the pool, check if the factory has been shut down. // At shutdown, the flag is set to true before the shutdown routine goes through // and retires all the thread proxies. However, if we've added this proxy after // that point, there is a good chance that the shutdown routine missed us. We // need to make sure the bucket is empty and all proxies are retired, in this case. if (m_fShutdown) { pProxy = m_proxyPool[i].Flush(); while (pProxy != NULL) { FreeThreadProxy *pNextProxy = LockFreeStack<FreeThreadProxy>::Next(pProxy); // Retiring the proxy will cause it to perform any necessary cleanup, and exit its dispatch loop. Retire(pProxy); pProxy = pNextProxy; } } pProxy = NULL; } break; } } } if (pProxy != NULL) { Retire(pProxy); } } /// <summary> /// Initiates shutdown of the factory, and deletes it if shutdown can be completed inline. /// </summary> virtual void ShutdownFactory() { m_fShutdown = true; RetireThreadProxies(); Release(); } protected: /// <summary> /// Creates a new Win32 free thread proxy factory. /// Protected constructor. All construction must go through the CreateFactory API. /// </summary> FreeThreadProxyFactory(ThreadProxyFactoryManager * pManager) : ThreadProxyFactory(pManager), m_referenceCount(1), m_fShutdown(false) { } private: /// <summary> /// Creates a new thread proxy. /// </summary> virtual FreeThreadProxy* Create(unsigned int stackSize) { return _concrt_new FreeThreadProxy(this, stackSize); } /// <summary> /// Retires a thread proxy. /// </summary> virtual void Retire(FreeThreadProxy *pProxy) { // Canceling the proxy will cause it to perform any necessary cleanup, and exit its dispatch loop. pProxy->Cancel(); } // Reference count for the thread proxy factory. For details, see comments in the constructor of ThreadProxy. volatile LONG m_referenceCount; // Flag that is set to true if shutdown has been initiated on the thread proxy factory. volatile bool m_fShutdown; }; #pragma warning(pop) #ifndef _UMS_DISABLED /// <summary> /// A factory that creates UMS thread proxies for UMS thread schedulers. /// </summary> class UMSFreeThreadProxyFactory : public ThreadProxyFactory<UMSFreeThreadProxy> { public: /// <summary> /// Creates a singleton thread proxy factory. /// </summary> static UMSFreeThreadProxyFactory * CreateFactory(ThreadProxyFactoryManager * pManager) { StaticInitialize(); return _concrt_new UMSFreeThreadProxyFactory(pManager); } /// <summary> /// Destroys a UMS thread proxy factory. /// </summary> virtual ~UMSFreeThreadProxyFactory() { } /// <summary> /// Initiates shutdown of the factory, and deletes it if shutdown can be completed inline. /// </summary> virtual void ShutdownFactory() { RetireThreadProxies(); m_pUmsThreadEngine->Shutdown(); if (m_pCompletionList != NULL) UMS::DeleteUmsCompletionList(m_pCompletionList); // A UMS thread proxy factory can be deleted inline. This is because it is guaranteed that all thread proxies // that were loaned out to UMS scheduler proxies were added back to the idle pool before it is possible for // the factory to be shutdown. (The factory is shutdown by the RM only after all scheduler proxies have shutdown). delete this; } /// <summary> /// UMS thread proxy factories do not support reference counting. /// </summary> LONG Reference() { return 0; } /// <summary> /// UMS thread proxy factories do not support reference counting. /// </summary> LONG Release() { return 0; } /// <summary> /// Returns an instance of the UMS background poller thread. /// </summary> UMSBackgroundPoller *GetUMSBackgroundPoller() { return m_pUmsThreadEngine->GetUMSBackgroundPoller(); } /// <summary> /// Returns an instance of transmogrificator. /// </summary> Transmogrificator *GetTransmogrificator() { return &m_transmogrificator; } protected: /// <summary> /// Creates a new UMS thread proxy factory. /// Protected constructor. All construction must go through the CreateFactory API. /// </summary> UMSFreeThreadProxyFactory(ThreadProxyFactoryManager * pManager) : ThreadProxyFactory(pManager), m_pCompletionList(NULL), m_hCompletionEvent(NULL) { if (!UMS::CreateUmsCompletionList(&m_pCompletionList)) throw scheduler_resource_allocation_error(HRESULT_FROM_WIN32(GetLastError())); if (!UMS::GetUmsCompletionListEvent(m_pCompletionList, &m_hCompletionEvent)) throw scheduler_resource_allocation_error(HRESULT_FROM_WIN32(GetLastError())); m_pUmsThreadEngine = _concrt_new TransmogrifiedPrimary(); } private: /// <summary> /// Creates a new thread proxy. /// </summary> virtual UMSFreeThreadProxy * Create(unsigned int stackSize) { HANDLE hObjects[2]; UMSFreeThreadProxy *pProxy = _concrt_new UMSFreeThreadProxy(this, m_pCompletionList, stackSize); hObjects[0] = pProxy->m_hBlock; hObjects[1] = m_hCompletionEvent; // // Make *ABSOLUTELY CERTAIN* that the thread has come back on a completion list prior to returning from Create. This will ensure that a primary // can execute it right away (which is the likely use for creating one of these to begin with). // for(;;) { DWORD result = WaitForMultipleObjectsEx(2, hObjects, FALSE, INFINITE, FALSE); if (result == WAIT_OBJECT_0) { return pProxy; } PUMS_CONTEXT pUMSContext; if (!UMS::DequeueUmsCompletionListItems(m_pCompletionList, 0, &pUMSContext)) { delete pProxy; throw scheduler_resource_allocation_error(HRESULT_FROM_WIN32(GetLastError())); } while (pUMSContext != NULL) { UMSFreeThreadProxy* pReturnedProxy = static_cast<UMSFreeThreadProxy*>(UMSFreeThreadProxy::FromUMSContext(pUMSContext)); RPMTRACE(MTRACE_EVT_ORIGINALCOMPLETION, pReturnedProxy, NULL, pUMSContext); pUMSContext = UMS::GetNextUmsListItem(pUMSContext); // Let the thread engine run it to ThreadMain m_pUmsThreadEngine->QueueToCompletion(pReturnedProxy); } } } /// <summary> /// Prepares a thread proxy for use. /// </summary> /// <param name="pProxy"> /// The proxy to prepare. /// </param> /// <param name="contextPriority"> /// The required thread priority for the thread proxy. /// <param> virtual void Prepare(UMSFreeThreadProxy *pProxy, int contextPriority) { ThreadProxyFactory::Prepare(pProxy, contextPriority); pProxy->ClearCriticalRegion(); } /// <summary> /// Retires a thread proxy. /// </summary> virtual void Retire(UMSFreeThreadProxy *pProxy) { RPMTRACE(MTRACE_EVT_RETIRE, pProxy, NULL, NULL); // Canceling the proxy will cause it to perform any necessary cleanup, and exit its dispatch loop. pProxy->Cancel(); m_pUmsThreadEngine->QueueToCompletion(pProxy); } // The primary responsible for retiring UTs. TransmogrifiedPrimary *m_pUmsThreadEngine; // A background thread responsible for creating UMS primary for nesting Transmogrificator m_transmogrificator; // The initial completion list upon which threads created from this factory will be placed. No UMS thread can be scheduled by any primary // until it appears on an initial UMS completion list. We will block Create until this is done. PUMS_COMPLETION_LIST m_pCompletionList; // The UMS completion list event. HANDLE m_hCompletionEvent; }; #endif // _UMS_DISABLED // // A class that holds a collection of thread proxy factories, one for each type of thread proxy. // class ThreadProxyFactoryManager { public: /// <summary> /// Creates a thread proxy factory manager. /// </summary> ThreadProxyFactoryManager(); /// <summary> /// Destroys a thread proxy factory manager. /// </summary> ~ThreadProxyFactoryManager(); /// <summary> /// Returns a Win32 thread proxy factory. /// </summary> FreeThreadProxyFactory * GetFreeThreadProxyFactory(); #ifndef _UMS_DISABLED /// <summary> /// Returns a UMS thread proxy factory. /// </summary> UMSFreeThreadProxyFactory * GetUMSFreeThreadProxyFactory(); #endif // _UMS_DISABLED /// <summary> /// Returns the TLS index used to store execution resource information by subscribed threads and thread proxies. /// </summary> DWORD GetExecutionResourceTls() const { return m_dwExecutionResourceTlsIndex; } private: // A thread proxy factory for Win32 thread proxies. FreeThreadProxyFactory * m_pFreeThreadProxyFactory; #ifndef _UMS_DISABLED // A thread proxy factory for UMS thread proxies. UMSFreeThreadProxyFactory * m_pUMSFreeThreadProxyFactory; #else void * m_pUMSFreeThreadProxyFactory; #endif // _UMS_DISABLED // An index to a TLS slot where execution resource pointers are stored. DWORD m_dwExecutionResourceTlsIndex; // A lock that guards creation of the thread proxy factories. _NonReentrantBlockingLock m_proxyFactoryCreationLock; }; template <typename threadProxy> ThreadProxyFactory<threadProxy>::ThreadProxyFactory(ThreadProxyFactoryManager * pManager) : m_executionResourceTlsIndex(pManager->GetExecutionResourceTls()) { } } // namespace details } // namespace Concurrency
34.891089
156
0.549801
623d55d59870026126f3a5ee73c90eb42c90148e
7,730
c
C
app/bluetooth/example_host/uart_dfu/app.c
lmnotran/gecko_sdk
2e82050dc8823c9fe0e8908c1b2666fb83056230
[ "Zlib" ]
82
2016-06-29T17:24:43.000Z
2021-04-16T06:49:17.000Z
app/bluetooth/example_host/uart_dfu/app.c
lmnotran/gecko_sdk
2e82050dc8823c9fe0e8908c1b2666fb83056230
[ "Zlib" ]
2
2017-02-13T10:07:17.000Z
2017-03-22T21:28:26.000Z
app/bluetooth/example_host/uart_dfu/app.c
lmnotran/gecko_sdk
2e82050dc8823c9fe0e8908c1b2666fb83056230
[ "Zlib" ]
56
2016-08-02T10:50:50.000Z
2021-07-19T08:57:34.000Z
/***************************************************************************//** * @file * @brief Application ******************************************************************************* * # License * <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b> ******************************************************************************* * * SPDX-License-Identifier: Zlib * * The licensor of this software is Silicon Laboratories Inc. * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * ******************************************************************************/ /** * This an example application that demonstrates Bluetooth Device Firmware Update (DFU) * over UART interface. * * To use this application you must have a WSTK configured into NCP mode connected to your * PC. * */ #include <stdlib.h> #include <stdio.h> #include <stdint.h> #include <stdbool.h> #include <time.h> #include <errno.h> #include <string.h> #include <unistd.h> #include "sl_bt_api.h" #include "sl_bt_ncp_host.h" #include "uart.h" #include "app_log.h" #include "app_assert.h" #ifndef POSIX #include <windows.h> #endif static void on_message_send(uint32_t msg_len, uint8_t* msg_data); static int32_t uart_rx_wrapper(uint32_t len, uint8_t* data); static int32_t uart_peek_wrapper(void); /** * Configurable parameters that can be modified to match the test setup. */ /** The serial port to use for BGAPI communication. */ static char* uart_port = NULL; /** The baud rate to use. */ static uint32_t baud_rate = 0; /** Usage string */ #define USAGE "Usage: %s [serial port] [baud rate] [dfu file] \n\n" /** dfu file to upload*/ FILE *dfu_file = NULL; #define MAX_DFU_PACKET 48 uint8_t dfu_data[MAX_DFU_PACKET]; size_t dfu_toload = 0; size_t dfu_total = 0; size_t current_pos = 0; #ifdef POSIX int32_t handle = -1; void *handle_ptr = &handle; #else HANDLE serial_handle; void *handle_ptr = &serial_handle; #endif static int dfu_read_size() { if (fseek(dfu_file, 0L, SEEK_END)) { return 1; } dfu_total = dfu_toload = ftell(dfu_file); if (fseek(dfu_file, 0L, SEEK_SET)) { return 1; } app_log("Bytes to send:%lu\n", dfu_toload); return 0; } /** * Function called when a message needs to be written to the serial port. * @param msg_len Length of the message. * @param msg_data Message data, including the header. * @param data_len Optional variable data length. * @param data Optional variable data. */ static void on_message_send(uint32_t msg_len, uint8_t* msg_data) { /** Variable for storing function return values. */ int ret; #if DEBUG app_log("on_message_send()\n"); #endif /* DEBUG */ ret = uartTx(handle_ptr, msg_len, msg_data); if (ret < 0) { app_log("on_message_send() - failed to write to serial port %s, ret: %d, errno: %d\n", uart_port, ret, errno); exit(EXIT_FAILURE); } } static int hw_init(int argc, char* argv[]) { int ret = 0; if (argc < 4) { app_log(USAGE, argv[0]); exit(EXIT_FAILURE); } /** * Handle the command-line arguments. */ //filename dfu_file = fopen(argv[3], "rb"); if (dfu_file == NULL) { app_log("cannot open file %s\n", argv[3]); exit(-1); } baud_rate = atoi(argv[2]); uart_port = argv[1]; if (!uart_port || !baud_rate || !dfu_file) { app_log(USAGE, argv[0]); exit(EXIT_FAILURE); } /** * Initialise the serial port. */ ret = uartOpen(handle_ptr, (int8_t*)uart_port, baud_rate, 1, 100); if (ret >= 0) { uartFlush(handle_ptr); } return ret; } static void sync_dfu_boot() { sl_bt_msg_t evt = { 0 }; uint8_t ret; app_log("Syncing"); do { app_log("."); ret = sl_bt_pop_event(&evt); if (0 == ret) { switch (SL_BT_MSG_ID(evt.header)) { case sl_bt_evt_dfu_boot_id: app_log("DFU OK\nBootloader version: %u (0x%x)\n", evt.data.evt_dfu_boot.version, evt.data.evt_dfu_boot.version); return; default: app_log("ID:%08x\n", SL_BT_MSG_ID(evt.header)); break; } } else { sl_bt_system_reset(sl_bt_system_boot_mode_uart_dfu); sleep(1); } } while (1); } void upload_dfu_file() { uint16_t result; size_t dfu_size; current_pos = 0; /** get dfu file size*/ if (dfu_read_size()) { app_log("Error, DFU file read failed\n"); exit(EXIT_FAILURE); } /** move target to dfu mode*/ sync_dfu_boot(); /** update firmware*/ sl_bt_dfu_flash_set_address(0); app_log("DFU packet size:%lu\n", dfu_toload); while (dfu_toload > 0) { dfu_size = dfu_toload > sizeof(dfu_data) ? sizeof(dfu_data) : dfu_toload; if (fread(dfu_data, 1, dfu_size, dfu_file) != dfu_size) { app_log("%lu:%lu:%lu\n", current_pos, dfu_size, dfu_total); app_log("File read failure\n"); exit(EXIT_FAILURE); } app_log("\r%d%%", (int)(100 * current_pos / dfu_total)); result = sl_bt_dfu_flash_upload(dfu_size, dfu_data); if (result) {//error app_log("\nError in upload 0x%.4x\n", result); exit(EXIT_FAILURE); } current_pos += dfu_size; dfu_toload -= dfu_size; } result = sl_bt_dfu_flash_upload_finish(); if (result) { app_log("\nError in dfu 0x%.4x", result); } else { app_log("\nfinish\n"); } fclose(dfu_file); sl_bt_system_reset(sl_bt_system_boot_mode_normal); } /***************************************************************************//** * Application initialisation. ******************************************************************************/ void app_init(int argc, char* argv[]) { sl_status_t sc = sl_bt_api_initialize_nonblock(on_message_send, uart_rx_wrapper, uart_peek_wrapper); app_assert(sc == SL_STATUS_OK, "[E: 0x%04x] Failed to init Bluetooth NCP\n", (int)sc); ////////////////////////////////////////// // Add your application init code here! // ////////////////////////////////////////// if (hw_init(argc, argv) < 0) { app_log("HW init failure\n"); exit(EXIT_FAILURE); } } /***************************************************************************//** * Application process actions. ******************************************************************************/ void app_process_action(void) { ////////////////////////////////////////// // Add your application tick code here! // ////////////////////////////////////////// } static inline int32_t uart_rx_wrapper(uint32_t len, uint8_t* data) { return uartRx(handle_ptr, len, data); } static inline int32_t uart_peek_wrapper(void) { int32_t sc; static bool log_first = false; sc = uartRxPeek(handle_ptr); if (sc < 0) { sc = 0; if (!log_first) { log_first = true; app_log("\nPeek is not supported in your environment, the program will hang.\n"); app_log("Please try other OS, or environment (preferred: MingW, Cygwin)\n\n"); } } return sc; }
26.933798
123
0.595472
2bdf74947008bdef2eec3a50b96344bff6657f4f
1,598
h
C
modules/ti.UI/TrayItem.h
Gussy/titanium_desktop
37dbaab5664e595115e2fcdc348ed125cd50b48d
[ "Apache-2.0" ]
3
2020-01-31T03:40:26.000Z
2022-02-06T12:20:52.000Z
modules/ti.UI/TrayItem.h
appcelerator-archive/titanium_desktop
37dbaab5664e595115e2fcdc348ed125cd50b48d
[ "Apache-2.0" ]
null
null
null
modules/ti.UI/TrayItem.h
appcelerator-archive/titanium_desktop
37dbaab5664e595115e2fcdc348ed125cd50b48d
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2009-2010 Appcelerator, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef TrayItem_h #define TrayItem_h #include <kroll/kroll.h> namespace Titanium { class Menu; class TrayItem : public KEventObject { public: TrayItem(std::string& iconURL); ~TrayItem(); virtual void SetIcon(std::string& iconPath) = 0; virtual void SetMenu(AutoPtr<Menu> menu) = 0; virtual void SetHint(std::string& hint) = 0; virtual void Remove() = 0; void _SetIcon(const ValueList& args, KValueRef result); void _SetMenu(const ValueList& args, KValueRef result); void _SetHint(const ValueList& args, KValueRef result); void _GetIcon(const ValueList& args, KValueRef result); void _GetMenu(const ValueList& args, KValueRef result); void _GetHint(const ValueList& args, KValueRef result); void _Remove(const ValueList& args, KValueRef result); protected: AutoPtr<Menu> menu; std::string iconURL; std::string iconPath; std::string hint; bool removed; }; } // namespace Titanium #endif
29.054545
75
0.718398
93bb43af986cfc664de17310866d83267fb49c7d
1,575
h
C
lab0011_pplcount_pjt/radarDemo/chains/RadarReceiverPeopleCounting/mmw_PCDemo/gtrack/include/gtrack_listlib.h
ZUHXS/EECS149-Proj
47d7da59bfc384929bdedbda9295c577cb354b37
[ "MIT" ]
4
2019-10-08T01:36:31.000Z
2021-03-25T02:30:11.000Z
lab0011_pplcount_pjt/radarDemo/chains/RadarReceiverPeopleCounting/mmw_PCDemo/gtrack/include/gtrack_listlib.h
ZUHXS/EECS149-Proj
47d7da59bfc384929bdedbda9295c577cb354b37
[ "MIT" ]
1
2019-11-19T03:31:54.000Z
2019-11-19T03:31:54.000Z
lab0011_pplcount_pjt/radarDemo/chains/RadarReceiverPeopleCounting/mmw_PCDemo/gtrack/include/gtrack_listlib.h
ZUHXS/EECS149-Proj
47d7da59bfc384929bdedbda9295c577cb354b37
[ "MIT" ]
7
2018-11-29T23:46:59.000Z
2021-12-09T13:31:31.000Z
/** * @file gtrack_listlib.h * * @brief * Header file for a double linked list * implementation. * * \par * NOTE: * (C) Copyright 2009 Texas Instruments, Inc. * \par */ #ifndef GTRACK_LIST_LIB_H__ #define GTRACK_LIST_LIB_H__ /** * @brief * GTrack ListElement * * @details * The structure describes a list node which has links to the previous * and next element in the list. */ typedef struct GTrack_ListElem_t { uint32_t data; struct GTrack_ListElem_t *prev; struct GTrack_ListElem_t *next; } GTrack_ListElem; /** * @brief * GTrack List Object * * @details * The structure describes the list object */ typedef struct { uint32_t count; GTrack_ListElem *begin; GTrack_ListElem *end; } GTrack_ListObj; /********************************************************************** **************************** EXPORTED API **************************** **********************************************************************/ extern void gtrack_listInit (GTrack_ListObj *list); extern int32_t gtrack_isListEmpty (GTrack_ListObj *list); extern void gtrack_listEnqueue (GTrack_ListObj *list, GTrack_ListElem *elem); extern GTrack_ListElem *gtrack_listDequeue (GTrack_ListObj *list); extern GTrack_ListElem* gtrack_listGetFirst (GTrack_ListObj *list); extern GTrack_ListElem* gtrack_listGetNext (GTrack_ListElem *elem); extern uint32_t gtrack_listGetCount (GTrack_ListObj *list); extern int32_t gtrack_listRemoveElement (GTrack_ListObj *list, GTrack_ListElem *elem); #endif /* GTRACK_LIST_LIB_H__ */
26.25
86
0.64127
f3c061ec254405d8b5e0d5bb182700d95c7508f6
1,708
h
C
Code/Adapter/vtkPolyDataToitkMesh.h
Piyusha23/IAFEMesh
e91b34c9eaa9c8ecc4ebb5d16f4c13f330d75c9f
[ "BSD-4-Clause-UC" ]
null
null
null
Code/Adapter/vtkPolyDataToitkMesh.h
Piyusha23/IAFEMesh
e91b34c9eaa9c8ecc4ebb5d16f4c13f330d75c9f
[ "BSD-4-Clause-UC" ]
null
null
null
Code/Adapter/vtkPolyDataToitkMesh.h
Piyusha23/IAFEMesh
e91b34c9eaa9c8ecc4ebb5d16f4c13f330d75c9f
[ "BSD-4-Clause-UC" ]
null
null
null
/*========================================================================= Program: MIMX Meshing Toolkit Module: $RCSfile: vtkPolyDataToitkMesh.h,v $ Language: C++ Date: $Date: 2012/12/07 19:08:58 $ Version: $Revision: 1.1.1.1 $ Musculoskeletal Imaging, Modelling and Experimentation (MIMX) Center for Computer Aided Design The University of Iowa Iowa City, IA 52242 http://www.ccad.uiowa.edu/mimx/ Copyright (c) The University of Iowa. All rights reserved. See MIMXCopyright.txt or http://www.ccad.uiowa.edu/mimx/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __vtkPolyDataToitkMesh_h__ #define __vtkPolyDataToitkMesh_h__ #include "vtkPoints.h" #include "vtkCellArray.h" #include "vtkPolyData.h" #include "itkDefaultDynamicMeshTraits.h" #include "itkMesh.h" #include "itkTriangleCell.h" #include "itkPoint.h" /** \class vtkPolyDataToitkMesh \brief \warning \sa */ class vtkPolyDataToitkMesh { public: vtkPolyDataToitkMesh( void ); virtual ~vtkPolyDataToitkMesh( void ); typedef itk::DefaultDynamicMeshTraits<double, 3, 3,double,double> TriangleMeshTraits; typedef itk::Mesh<double,3, TriangleMeshTraits> TriangleMeshType; /** The SetInput method provides pointer to the vtkPolyData */ void SetInput( vtkPolyData * polydata); TriangleMeshType * GetOutput(); void ConvertvtkToitk(); TriangleMeshType::Pointer m_itkMesh; vtkPolyData * m_PolyData; }; #endif
25.117647
87
0.68267
7ab8183b3dce2037a0742e386d0144dedb4fa43c
637
h
C
src/xoshiro256.h
DSCF-1224/xoshiro-c
67b23eda6cd5a867bb912e7a9c028dcd9d4745a7
[ "CC0-1.0" ]
null
null
null
src/xoshiro256.h
DSCF-1224/xoshiro-c
67b23eda6cd5a867bb912e7a9c028dcd9d4745a7
[ "CC0-1.0" ]
null
null
null
src/xoshiro256.h
DSCF-1224/xoshiro-c
67b23eda6cd5a867bb912e7a9c028dcd9d4745a7
[ "CC0-1.0" ]
null
null
null
#ifndef XOSHIRO_0256_H #define XOSHIRO_0256_H #include <stdint.h> #include "rotl.h" #include "xoshiro.h" const static uint64_t XOSHIRO_0256_JUMP [] = { 0x180ec6d33cfd0aba, 0xd5a61266f0c9392c, 0xa9582618e03fc9aa, 0x39abdc4529b1661c }; const static uint64_t XOSHIRO_0256_JUMP_LONG [] = { 0x76e15d3efefdcbbf, 0xc5004e441c522fb3, 0x77710069854ee241, 0x39109bb02acbe635 }; /* function prototype */ void jump_state_core_xoshiro256 ( const size_t state_size , uint64_t *const state_value , const uint64_t *const jump_parameter ); void update_state_xoshiro256 ( uint64_t *const state_value ); #endif /* XOSHIRO_0256_H */ /* EOF */
33.526316
133
0.783359
ffe9f337491f2dfcddc905df1a8f0060771e10b5
2,203
h
C
LTL_SAT_solver/Aalta_v2.0/formula/olg_formula.h
reactive-systems/eahyper
32660b55e12296df772b835add3248034ce0f70f
[ "0BSD" ]
1
2019-10-08T10:17:11.000Z
2019-10-08T10:17:11.000Z
LTL_SAT_solver/Aalta_v2.0/formula/olg_formula.h
reactive-systems/eahyper
32660b55e12296df772b835add3248034ce0f70f
[ "0BSD" ]
null
null
null
LTL_SAT_solver/Aalta_v2.0/formula/olg_formula.h
reactive-systems/eahyper
32660b55e12296df772b835add3248034ce0f70f
[ "0BSD" ]
1
2021-03-01T14:26:05.000Z
2021-03-01T14:26:05.000Z
/* * File: olg_formula.h * Author: yaoyinbo * * φ = p: ofp(φ) = ⟨p,1,−⟩; * φ = φ1 ∧ φ2: ofp(φ) = ofp(φ1) ∧ ofp(φ2); * φ = φ1 ∨ φ2: ofp(φ) = ofp(φ1) ∨ ofp(φ2); * φ = X φ1: ofp(φ) = Pos(ofp(φ1), X ); * φ = Gφ1: ofp(φ) = Pos(ofp(φ1),G); * φ = φ1Uφ2: ofp(φ) = Pos(ofp(φ2), U); * φ = φ1Rφ2 (φ1 != ff): ofp(φ) = Pos(ofp(φ2), R); * * Created on October 25, 2013, 10:38 PM */ #ifndef OLG_FORMULA_H #define OLG_FORMULA_H #include "olg_item.h" #include <stdlib.h> class olg_formula { private: //////////// //成员变量// ////////////////////////////////////////////////// olg_item *_root; // olg_formula根节点 int *_pos_arr; int _pos_size; int *_id_arr; int _id_size; /* 以下成员用于处理 φi ∧ G (Ai | F Bi) 类型公式 */ std::list<olg_item *> _ALLG; // Ai | F Bi 节点 std::list<olg_item *> _GF; // G(Ai | F Bi) formulas std::list<olg_item *> _NG; // Not G formulas formulas std::list<olg_item *> _G; // G formulas std::list<olg_item *> _GR; // G release formulas std::list<olg_item *> _GU; //G until formulas std::list<olg_item *> _GX; //G X formulas std::list<olg_item *> _GP; //G P formulas std::list<olg_item *> _NR; //not release contained formulas std::list<olg_item *> _R; //release contained formulas std::list<aalta_formula *> _FGX; // G X aalta formulas ////////////////////////////////////////////////// public: olg_formula (aalta_formula *af); virtual ~olg_formula (); bool sat (); bool unsat (); std::string to_string() const; std::string to_olg_string ()const; //added by Jianwen Li std::vector<aalta_formula*> _GX_loop; olg_item* GX_imply (); olg_item* G_be_implied (); void GX_loop (); aalta_formula* build_from_set (hash_set<aalta_formula*>); bool find_in_GX_loop (aalta_formula*); std::pair<aalta_formula*, aalta_formula*> split_GX (aalta_formula*); int get_pos (aalta_formula*); //added by Jianwen Li private: void classify (aalta_formula *af); olg_item *build (const aalta_formula *af); void col_info(olg_item *root); void destroy (olg_item *root); public: hash_map<int, bool> _evidence; //for evidence }; #endif /* OLG_FORMULA_H */
24.208791
70
0.586019
d1d394ab53f415d40da0be19d9f4a627a97d4379
627
h
C
LBNewsComing/LBNewsComing/Classes/view/videoView/LBNCVideoCell.h
lb2281075105/LBNewsComing
3b5ad1ade1c49655a4b3d56059e2c722301af4e9
[ "Apache-2.0" ]
46
2017-11-29T13:19:51.000Z
2021-11-07T20:29:45.000Z
LBNewsComing/LBNewsComing/Classes/view/videoView/LBNCVideoCell.h
lb2281075105/LBNewsComing
3b5ad1ade1c49655a4b3d56059e2c722301af4e9
[ "Apache-2.0" ]
null
null
null
LBNewsComing/LBNewsComing/Classes/view/videoView/LBNCVideoCell.h
lb2281075105/LBNewsComing
3b5ad1ade1c49655a4b3d56059e2c722301af4e9
[ "Apache-2.0" ]
11
2017-12-01T06:13:44.000Z
2020-04-29T06:59:27.000Z
// // LBNCVideoCell.h // LBNewsComing // // Created by yunmei on 2017/8/18. // Copyright © 2017年 刘博. All rights reserved. // #import <UIKit/UIKit.h> #import "LBNCVideoModel.h" #import "LBNCImageView.h" #import "LBNCVideoModel.h" @interface LBNCVideoCell : UITableViewCell + (instancetype)cellWithTableView:(UITableView *)tableView; // 新闻列表模型 @property (nonatomic, strong)VideoVideolistModel *videoListModel; @property (strong, nonatomic) LBNCImageView *iconIV; @property (strong, nonatomic) UILabel *titleLabel; @property (strong, nonatomic) UILabel *subtitleLabel; @property (strong, nonatomic) UILabel *timeLabel; @end
27.26087
65
0.760766
7f78f91048de2431db727648f3a1ec50a02dc4d0
2,709
h
C
sp/src/public/togl/linuxwin/glmdisplaydb.h
tingtom/Fodder
3250572dbc56547709f564ba68e451b21660cdb4
[ "Unlicense" ]
5
2015-09-29T23:14:26.000Z
2021-04-01T05:28:52.000Z
sp/src/public/togl/linuxwin/glmdisplaydb.h
tingtom/Fodder
3250572dbc56547709f564ba68e451b21660cdb4
[ "Unlicense" ]
null
null
null
sp/src/public/togl/linuxwin/glmdisplaydb.h
tingtom/Fodder
3250572dbc56547709f564ba68e451b21660cdb4
[ "Unlicense" ]
6
2015-02-20T06:11:13.000Z
2018-11-15T08:22:01.000Z
//========= Copyright Valve Corporation, All rights reserved. ============// #ifndef GLMDISPLAYDB_H #define GLMDISPLAYDB_H #include "tier1/utlvector.h" //=============================================================================== // modes, displays, and renderers //=============================================================================== // GLMDisplayModeInfoFields is in glmdisplay.h class GLMDisplayMode { public: GLMDisplayModeInfoFields m_info; GLMDisplayMode( uint width, uint height, uint refreshHz ); GLMDisplayMode() { }; ~GLMDisplayMode( void ); void Init( uint width, uint height, uint refreshHz ); void Dump( int which ); }; //=============================================================================== // GLMDisplayInfoFields is in glmdisplay.h class GLMDisplayInfo { public: GLMDisplayInfoFields m_info; CUtlVector< GLMDisplayMode* > *m_modes; // starts out NULL, set by PopulateModes GLMDisplayInfo( void ); ~GLMDisplayInfo( void ); void PopulateModes( void ); void Dump( int which ); }; //=============================================================================== // GLMRendererInfoFields is in glmdisplay.h class GLMRendererInfo { public: GLMRendererInfoFields m_info; GLMDisplayInfo *m_display; GLMRendererInfo (); ~GLMRendererInfo ( void ); void Init( GLMRendererInfoFields *info ); void PopulateDisplays(); void Dump( int which ); }; //=============================================================================== class GLMDisplayDB { public: GLMRendererInfo m_renderer; GLMDisplayDB ( void ); ~GLMDisplayDB ( void ); virtual void PopulateRenderers( void ); virtual void PopulateFakeAdapters( uint realRendererIndex ); // fake adapters = one real adapter times however many displays are on it virtual void Populate( void ); // The info-get functions return false on success. virtual int GetFakeAdapterCount( void ); virtual bool GetFakeAdapterInfo( int fakeAdapterIndex, int *rendererOut, int *displayOut, GLMRendererInfoFields *rendererInfoOut, GLMDisplayInfoFields *displayInfoOut ); virtual int GetRendererCount( void ); virtual bool GetRendererInfo( int rendererIndex, GLMRendererInfoFields *infoOut ); virtual int GetDisplayCount( int rendererIndex ); virtual bool GetDisplayInfo( int rendererIndex, int displayIndex, GLMDisplayInfoFields *infoOut ); virtual int GetModeCount( int rendererIndex, int displayIndex ); virtual bool GetModeInfo( int rendererIndex, int displayIndex, int modeIndex, GLMDisplayModeInfoFields *infoOut ); virtual void Dump( void ); }; #endif // GLMDISPLAYDB_H
29.129032
171
0.614618
3d1d7187d74b9b02d104c1c1686d675b54303a5c
36,830
c
C
tls/s2n_prf.c
hongxu-jia/s2n-tls
5d785357ce3a74205d8330b6daf214980762f0a6
[ "Apache-2.0" ]
4,256
2015-06-30T11:37:38.000Z
2021-02-17T10:46:30.000Z
tls/s2n_prf.c
hongxu-jia/s2n-tls
5d785357ce3a74205d8330b6daf214980762f0a6
[ "Apache-2.0" ]
2,088
2015-06-30T12:12:51.000Z
2021-02-17T22:27:43.000Z
tls/s2n_prf.c
hongxu-jia/s2n-tls
5d785357ce3a74205d8330b6daf214980762f0a6
[ "Apache-2.0" ]
676
2015-06-30T11:11:51.000Z
2021-02-15T20:07:16.000Z
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #include <sys/param.h> #include <openssl/hmac.h> #include <openssl/md5.h> #include <openssl/sha.h> #include <string.h> #include "error/s2n_errno.h" #include "tls/s2n_cipher_suites.h" #include "tls/s2n_connection.h" #include "tls/s2n_prf.h" #include "tls/s2n_tls.h" #include "stuffer/s2n_stuffer.h" #include "crypto/s2n_hmac.h" #include "crypto/s2n_hash.h" #include "crypto/s2n_openssl.h" #include "crypto/s2n_fips.h" #include "utils/s2n_safety.h" #include "utils/s2n_blob.h" #include "utils/s2n_mem.h" static int s2n_sslv3_prf(struct s2n_connection *conn, struct s2n_blob *secret, struct s2n_blob *seed_a, struct s2n_blob *seed_b, struct s2n_blob *seed_c, struct s2n_blob *out) { POSIX_ENSURE_REF(conn); POSIX_ENSURE_REF(conn->handshake.hashes); struct s2n_hash_state *workspace = &conn->handshake.hashes->hash_workspace; uint32_t outputlen = out->size; uint8_t *output = out->data; uint8_t iteration = 1; uint8_t md5_digest[MD5_DIGEST_LENGTH] = { 0 }, sha_digest[SHA_DIGEST_LENGTH] = { 0 }; uint8_t A = 'A'; while (outputlen) { struct s2n_hash_state *sha1 = workspace; POSIX_GUARD(s2n_hash_reset(sha1)); POSIX_GUARD(s2n_hash_init(sha1, S2N_HASH_SHA1)); for (int i = 0; i < iteration; i++) { POSIX_GUARD(s2n_hash_update(sha1, &A, 1)); } POSIX_GUARD(s2n_hash_update(sha1, secret->data, secret->size)); POSIX_GUARD(s2n_hash_update(sha1, seed_a->data, seed_a->size)); if (seed_b) { POSIX_GUARD(s2n_hash_update(sha1, seed_b->data, seed_b->size)); if (seed_c) { POSIX_GUARD(s2n_hash_update(sha1, seed_c->data, seed_c->size)); } } POSIX_GUARD(s2n_hash_digest(sha1, sha_digest, sizeof(sha_digest))); struct s2n_hash_state *md5 = workspace; POSIX_GUARD(s2n_hash_reset(md5)); POSIX_GUARD(s2n_hash_init(md5, S2N_HASH_MD5)); POSIX_GUARD(s2n_hash_update(md5, secret->data, secret->size)); POSIX_GUARD(s2n_hash_update(md5, sha_digest, sizeof(sha_digest))); POSIX_GUARD(s2n_hash_digest(md5, md5_digest, sizeof(md5_digest))); uint32_t bytes_to_copy = MIN(outputlen, sizeof(md5_digest)); POSIX_CHECKED_MEMCPY(output, md5_digest, bytes_to_copy); outputlen -= bytes_to_copy; output += bytes_to_copy; /* Increment the letter */ A++; iteration++; } return 0; } static int s2n_init_md_from_hmac_alg(struct s2n_prf_working_space *ws, s2n_hmac_algorithm alg){ switch (alg) { case S2N_HMAC_SSLv3_MD5: case S2N_HMAC_MD5: ws->p_hash.evp_hmac.evp_digest.md = EVP_md5(); break; case S2N_HMAC_SSLv3_SHA1: case S2N_HMAC_SHA1: ws->p_hash.evp_hmac.evp_digest.md = EVP_sha1(); break; case S2N_HMAC_SHA224: ws->p_hash.evp_hmac.evp_digest.md = EVP_sha224(); break; case S2N_HMAC_SHA256: ws->p_hash.evp_hmac.evp_digest.md = EVP_sha256(); break; case S2N_HMAC_SHA384: ws->p_hash.evp_hmac.evp_digest.md = EVP_sha384(); break; case S2N_HMAC_SHA512: ws->p_hash.evp_hmac.evp_digest.md = EVP_sha512(); break; default: POSIX_BAIL(S2N_ERR_P_HASH_INVALID_ALGORITHM); } return S2N_SUCCESS; } #if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC) static int s2n_evp_pkey_p_hash_alloc(struct s2n_prf_working_space *ws) { POSIX_ENSURE_REF(ws->p_hash.evp_hmac.evp_digest.ctx = S2N_EVP_MD_CTX_NEW()); return 0; } static int s2n_evp_pkey_p_hash_digest_init(struct s2n_prf_working_space *ws) { POSIX_ENSURE_REF(ws->p_hash.evp_hmac.evp_digest.md); POSIX_ENSURE_REF(ws->p_hash.evp_hmac.evp_digest.ctx); POSIX_ENSURE_REF(ws->p_hash.evp_hmac.ctx.evp_pkey); /* Ignore the MD5 check when in FIPS mode to comply with the TLS 1.0 RFC */ if (s2n_is_in_fips_mode()) { POSIX_GUARD(s2n_digest_allow_md5_for_fips(&ws->p_hash.evp_hmac.evp_digest)); } POSIX_GUARD_OSSL(EVP_DigestSignInit(ws->p_hash.evp_hmac.evp_digest.ctx, NULL, ws->p_hash.evp_hmac.evp_digest.md, NULL, ws->p_hash.evp_hmac.ctx.evp_pkey), S2N_ERR_P_HASH_INIT_FAILED); return 0; } static int s2n_evp_pkey_p_hash_init(struct s2n_prf_working_space *ws, s2n_hmac_algorithm alg, struct s2n_blob *secret) { /* Initialize the message digest */ POSIX_GUARD(s2n_init_md_from_hmac_alg(ws, alg)); /* Initialize the mac key using the provided secret */ POSIX_ENSURE_REF(ws->p_hash.evp_hmac.ctx.evp_pkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, secret->data, secret->size)); /* Initialize the message digest context with the above message digest and mac key */ return s2n_evp_pkey_p_hash_digest_init(ws); } static int s2n_evp_pkey_p_hash_update(struct s2n_prf_working_space *ws, const void *data, uint32_t size) { POSIX_GUARD_OSSL(EVP_DigestSignUpdate(ws->p_hash.evp_hmac.evp_digest.ctx, data, (size_t)size), S2N_ERR_P_HASH_UPDATE_FAILED); return 0; } static int s2n_evp_pkey_p_hash_final(struct s2n_prf_working_space *ws, void *digest, uint32_t size) { /* EVP_DigestSign API's require size_t data structures */ size_t digest_size = size; POSIX_GUARD_OSSL(EVP_DigestSignFinal(ws->p_hash.evp_hmac.evp_digest.ctx, (unsigned char *)digest, &digest_size), S2N_ERR_P_HASH_FINAL_FAILED); return 0; } static int s2n_evp_pkey_p_hash_wipe(struct s2n_prf_working_space *ws) { POSIX_GUARD_OSSL(S2N_EVP_MD_CTX_RESET(ws->p_hash.evp_hmac.evp_digest.ctx), S2N_ERR_P_HASH_WIPE_FAILED); return 0; } static int s2n_evp_pkey_p_hash_reset(struct s2n_prf_working_space *ws) { POSIX_GUARD(s2n_evp_pkey_p_hash_wipe(ws)); /* * On some cleanup paths s2n_evp_pkey_p_hash_reset can be called before s2n_evp_pkey_p_hash_init so there is nothing * to reset. */ if (ws->p_hash.evp_hmac.ctx.evp_pkey == NULL) { return S2N_SUCCESS; } return s2n_evp_pkey_p_hash_digest_init(ws); } static int s2n_evp_pkey_p_hash_cleanup(struct s2n_prf_working_space *ws) { /* Prepare the workspace md_ctx for the next p_hash */ POSIX_GUARD(s2n_evp_pkey_p_hash_wipe(ws)); /* Free mac key - PKEYs cannot be reused */ POSIX_ENSURE_REF(ws->p_hash.evp_hmac.ctx.evp_pkey); EVP_PKEY_free(ws->p_hash.evp_hmac.ctx.evp_pkey); ws->p_hash.evp_hmac.ctx.evp_pkey = NULL; return 0; } static int s2n_evp_pkey_p_hash_free(struct s2n_prf_working_space *ws) { POSIX_ENSURE_REF(ws->p_hash.evp_hmac.evp_digest.ctx); S2N_EVP_MD_CTX_FREE(ws->p_hash.evp_hmac.evp_digest.ctx); ws->p_hash.evp_hmac.evp_digest.ctx = NULL; return 0; } static const struct s2n_p_hash_hmac s2n_evp_pkey_p_hash_hmac = { .alloc = &s2n_evp_pkey_p_hash_alloc, .init = &s2n_evp_pkey_p_hash_init, .update = &s2n_evp_pkey_p_hash_update, .final = &s2n_evp_pkey_p_hash_final, .reset = &s2n_evp_pkey_p_hash_reset, .cleanup = &s2n_evp_pkey_p_hash_cleanup, .free = &s2n_evp_pkey_p_hash_free, }; #else static int s2n_evp_hmac_p_hash_alloc(struct s2n_prf_working_space *ws) { POSIX_ENSURE_REF(ws->p_hash.evp_hmac.ctx.hmac_ctx = HMAC_CTX_new()); return S2N_SUCCESS; } static int s2n_evp_hmac_p_hash_init(struct s2n_prf_working_space *ws, s2n_hmac_algorithm alg, struct s2n_blob *secret) { /* Figure out the correct EVP_MD from s2n_hmac_algorithm */ POSIX_GUARD(s2n_init_md_from_hmac_alg(ws, alg)); /* Initialize the mac and digest */ POSIX_GUARD_OSSL(HMAC_Init_ex(ws->p_hash.evp_hmac.ctx.hmac_ctx, secret->data, secret->size, ws->p_hash.evp_hmac.evp_digest.md, NULL), S2N_ERR_P_HASH_INIT_FAILED); return S2N_SUCCESS; } static int s2n_evp_hmac_p_hash_update(struct s2n_prf_working_space *ws, const void *data, uint32_t size) { POSIX_GUARD_OSSL(HMAC_Update(ws->p_hash.evp_hmac.ctx.hmac_ctx, data, (size_t)size), S2N_ERR_P_HASH_UPDATE_FAILED); return S2N_SUCCESS; } static int s2n_evp_hmac_p_hash_final(struct s2n_prf_working_space *ws, void *digest, uint32_t size) { /* HMAC_Final API's require size_t data structures */ unsigned int digest_size = size; POSIX_GUARD_OSSL(HMAC_Final(ws->p_hash.evp_hmac.ctx.hmac_ctx, (unsigned char *)digest, &digest_size), S2N_ERR_P_HASH_FINAL_FAILED); return S2N_SUCCESS; } static int s2n_evp_hmac_p_hash_reset(struct s2n_prf_working_space *ws) { POSIX_ENSURE_REF(ws); if (ws->p_hash.evp_hmac.evp_digest.md == NULL) { return S2N_SUCCESS; } POSIX_GUARD_OSSL(HMAC_Init_ex(ws->p_hash.evp_hmac.ctx.hmac_ctx, NULL, 0, ws->p_hash.evp_hmac.evp_digest.md, NULL), S2N_ERR_P_HASH_INIT_FAILED); return S2N_SUCCESS; } static int s2n_evp_hmac_p_hash_cleanup(struct s2n_prf_working_space *ws) { /* Prepare the workspace md_ctx for the next p_hash */ HMAC_CTX_reset(ws->p_hash.evp_hmac.ctx.hmac_ctx); return S2N_SUCCESS; } static int s2n_evp_hmac_p_hash_free(struct s2n_prf_working_space *ws) { HMAC_CTX_free(ws->p_hash.evp_hmac.ctx.hmac_ctx); return S2N_SUCCESS; } static const struct s2n_p_hash_hmac s2n_evp_hmac_p_hash_hmac = { .alloc = &s2n_evp_hmac_p_hash_alloc, .init = &s2n_evp_hmac_p_hash_init, .update = &s2n_evp_hmac_p_hash_update, .final = &s2n_evp_hmac_p_hash_final, .reset = &s2n_evp_hmac_p_hash_reset, .cleanup = &s2n_evp_hmac_p_hash_cleanup, .free = &s2n_evp_hmac_p_hash_free, }; #endif /* !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC) */ static int s2n_hmac_p_hash_new(struct s2n_prf_working_space *ws) { POSIX_GUARD(s2n_hmac_new(&ws->p_hash.s2n_hmac)); return s2n_hmac_init(&ws->p_hash.s2n_hmac, S2N_HMAC_NONE, NULL, 0); } static int s2n_hmac_p_hash_init(struct s2n_prf_working_space *ws, s2n_hmac_algorithm alg, struct s2n_blob *secret) { return s2n_hmac_init(&ws->p_hash.s2n_hmac, alg, secret->data, secret->size); } static int s2n_hmac_p_hash_update(struct s2n_prf_working_space *ws, const void *data, uint32_t size) { return s2n_hmac_update(&ws->p_hash.s2n_hmac, data, size); } static int s2n_hmac_p_hash_digest(struct s2n_prf_working_space *ws, void *digest, uint32_t size) { return s2n_hmac_digest(&ws->p_hash.s2n_hmac, digest, size); } static int s2n_hmac_p_hash_reset(struct s2n_prf_working_space *ws) { /* If we actually initialized s2n_hmac, wipe it. * A valid, initialized s2n_hmac_state will have a valid block size. */ if (ws->p_hash.s2n_hmac.hash_block_size != 0) { return s2n_hmac_reset(&ws->p_hash.s2n_hmac); } return S2N_SUCCESS; } static int s2n_hmac_p_hash_cleanup(struct s2n_prf_working_space *ws) { return s2n_hmac_p_hash_reset(ws); } static int s2n_hmac_p_hash_free(struct s2n_prf_working_space *ws) { return s2n_hmac_free(&ws->p_hash.s2n_hmac); } static const struct s2n_p_hash_hmac s2n_internal_p_hash_hmac = { .alloc = &s2n_hmac_p_hash_new, .init = &s2n_hmac_p_hash_init, .update = &s2n_hmac_p_hash_update, .final = &s2n_hmac_p_hash_digest, .reset = &s2n_hmac_p_hash_reset, .cleanup = &s2n_hmac_p_hash_cleanup, .free = &s2n_hmac_p_hash_free, }; const struct s2n_p_hash_hmac *s2n_get_hmac_implementation() { #if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC) return s2n_is_in_fips_mode() ? &s2n_evp_hmac_p_hash_hmac : &s2n_internal_p_hash_hmac; #else return s2n_is_in_fips_mode() ? &s2n_evp_pkey_p_hash_hmac : &s2n_internal_p_hash_hmac; #endif } static int s2n_p_hash(struct s2n_prf_working_space *ws, s2n_hmac_algorithm alg, struct s2n_blob *secret, struct s2n_blob *label, struct s2n_blob *seed_a, struct s2n_blob *seed_b, struct s2n_blob *seed_c, struct s2n_blob *out) { uint8_t digest_size; POSIX_GUARD(s2n_hmac_digest_size(alg, &digest_size)); const struct s2n_p_hash_hmac *hmac = s2n_get_hmac_implementation(); /* First compute hmac(secret + A(0)) */ POSIX_GUARD(hmac->init(ws, alg, secret)); POSIX_GUARD(hmac->update(ws, label->data, label->size)); POSIX_GUARD(hmac->update(ws, seed_a->data, seed_a->size)); if (seed_b) { POSIX_GUARD(hmac->update(ws, seed_b->data, seed_b->size)); if (seed_c) { POSIX_GUARD(hmac->update(ws, seed_c->data, seed_c->size)); } } POSIX_GUARD(hmac->final(ws, ws->digest0, digest_size)); uint32_t outputlen = out->size; uint8_t *output = out->data; while (outputlen) { /* Now compute hmac(secret + A(N - 1) + seed) */ POSIX_GUARD(hmac->reset(ws)); POSIX_GUARD(hmac->update(ws, ws->digest0, digest_size)); /* Add the label + seed and compute this round's A */ POSIX_GUARD(hmac->update(ws, label->data, label->size)); POSIX_GUARD(hmac->update(ws, seed_a->data, seed_a->size)); if (seed_b) { POSIX_GUARD(hmac->update(ws, seed_b->data, seed_b->size)); if (seed_c) { POSIX_GUARD(hmac->update(ws, seed_c->data, seed_c->size)); } } POSIX_GUARD(hmac->final(ws, ws->digest1, digest_size)); uint32_t bytes_to_xor = MIN(outputlen, digest_size); for (uint32_t i = 0; i < bytes_to_xor; i++) { *output ^= ws->digest1[i]; output++; outputlen--; } /* Stash a digest of A(N), in A(N), for the next round */ POSIX_GUARD(hmac->reset(ws)); POSIX_GUARD(hmac->update(ws, ws->digest0, digest_size)); POSIX_GUARD(hmac->final(ws, ws->digest0, digest_size)); } POSIX_GUARD(hmac->cleanup(ws)); return 0; } S2N_RESULT s2n_prf_new(struct s2n_connection *conn) { RESULT_ENSURE_REF(conn); RESULT_ENSURE_EQ(conn->prf_space, NULL); DEFER_CLEANUP(struct s2n_blob mem = { 0 }, s2n_free); RESULT_GUARD_POSIX(s2n_realloc(&mem, sizeof(struct s2n_prf_working_space))); RESULT_GUARD_POSIX(s2n_blob_zero(&mem)); conn->prf_space = (struct s2n_prf_working_space*)(void*) mem.data; ZERO_TO_DISABLE_DEFER_CLEANUP(mem); /* Allocate the hmac state */ const struct s2n_p_hash_hmac *hmac_impl = s2n_get_hmac_implementation(); RESULT_GUARD_POSIX(hmac_impl->alloc(conn->prf_space)); return S2N_RESULT_OK; } S2N_RESULT s2n_prf_wipe(struct s2n_connection *conn) { RESULT_ENSURE_REF(conn); RESULT_ENSURE_REF(conn->prf_space); const struct s2n_p_hash_hmac *hmac_impl = s2n_get_hmac_implementation(); RESULT_GUARD_POSIX(hmac_impl->reset(conn->prf_space)); return S2N_RESULT_OK; } S2N_RESULT s2n_prf_free(struct s2n_connection *conn) { RESULT_ENSURE_REF(conn); if (conn->prf_space == NULL) { return S2N_RESULT_OK; } const struct s2n_p_hash_hmac *hmac_impl = s2n_get_hmac_implementation(); RESULT_GUARD_POSIX(hmac_impl->free(conn->prf_space)); RESULT_GUARD_POSIX(s2n_free_object((uint8_t **) &conn->prf_space, sizeof(struct s2n_prf_working_space))); return S2N_RESULT_OK; } static int s2n_prf(struct s2n_connection *conn, struct s2n_blob *secret, struct s2n_blob *label, struct s2n_blob *seed_a, struct s2n_blob *seed_b, struct s2n_blob *seed_c, struct s2n_blob *out) { POSIX_ENSURE_REF(conn); POSIX_ENSURE_REF(secret); POSIX_ENSURE_REF(conn->prf_space); /* seed_a is always required, seed_b is optional, if seed_c is provided seed_b must also be provided */ S2N_ERROR_IF(seed_a == NULL, S2N_ERR_PRF_INVALID_SEED); S2N_ERROR_IF(seed_b == NULL && seed_c != NULL, S2N_ERR_PRF_INVALID_SEED); if (conn->actual_protocol_version == S2N_SSLv3) { return s2n_sslv3_prf(conn, secret, seed_a, seed_b, seed_c, out); } /* We zero the out blob because p_hash works by XOR'ing with the existing * buffer. This is a little convoluted but means we can avoid dynamic memory * allocation. When we call p_hash once (in the TLS1.2 case) it will produce * the right values. When we call it twice in the regular case, the two * outputs will be XORd just ass the TLS 1.0 and 1.1 RFCs require. */ POSIX_GUARD(s2n_blob_zero(out)); if (conn->actual_protocol_version == S2N_TLS12) { return s2n_p_hash(conn->prf_space, conn->secure.cipher_suite->prf_alg, secret, label, seed_a, seed_b, seed_c, out); } struct s2n_blob half_secret = {.data = secret->data,.size = (secret->size + 1) / 2 }; POSIX_GUARD(s2n_p_hash(conn->prf_space, S2N_HMAC_MD5, &half_secret, label, seed_a, seed_b, seed_c, out)); half_secret.data += secret->size - half_secret.size; POSIX_GUARD(s2n_p_hash(conn->prf_space, S2N_HMAC_SHA1, &half_secret, label, seed_a, seed_b, seed_c, out)); return 0; } int s2n_tls_prf_master_secret(struct s2n_connection *conn, struct s2n_blob *premaster_secret) { struct s2n_blob client_random = {.size = sizeof(conn->handshake_params.client_random), .data = conn->handshake_params.client_random}; struct s2n_blob server_random = {.size = sizeof(conn->handshake_params.server_random), .data = conn->handshake_params.server_random}; struct s2n_blob master_secret = {.size = sizeof(conn->secrets.tls12.master_secret), .data = conn->secrets.tls12.master_secret}; uint8_t master_secret_label[] = "master secret"; struct s2n_blob label = {.size = sizeof(master_secret_label) - 1, .data = master_secret_label}; return s2n_prf(conn, premaster_secret, &label, &client_random, &server_random, NULL, &master_secret); } int s2n_hybrid_prf_master_secret(struct s2n_connection *conn, struct s2n_blob *premaster_secret) { struct s2n_blob client_random = {.size = sizeof(conn->handshake_params.client_random), .data = conn->handshake_params.client_random}; struct s2n_blob server_random = {.size = sizeof(conn->handshake_params.server_random), .data = conn->handshake_params.server_random}; struct s2n_blob master_secret = {.size = sizeof(conn->secrets.tls12.master_secret), .data = conn->secrets.tls12.master_secret}; uint8_t master_secret_label[] = "hybrid master secret"; struct s2n_blob label = {.size = sizeof(master_secret_label) - 1, .data = master_secret_label}; return s2n_prf(conn, premaster_secret, &label, &client_random, &server_random, &conn->kex_params.client_key_exchange_message, &master_secret); } int s2n_prf_calculate_master_secret(struct s2n_connection *conn, struct s2n_blob *premaster_secret) { POSIX_ENSURE_REF(conn); POSIX_ENSURE_EQ(s2n_conn_get_current_message_type(conn), CLIENT_KEY); if(!conn->ems_negotiated) { POSIX_GUARD(s2n_tls_prf_master_secret(conn, premaster_secret)); return S2N_SUCCESS; } /* Only the client writes the Client Key Exchange message */ if (conn->mode == S2N_CLIENT) { POSIX_GUARD(s2n_handshake_finish_header(&conn->handshake.io)); } struct s2n_stuffer client_key_message = conn->handshake.io; POSIX_GUARD(s2n_stuffer_reread(&client_key_message)); uint32_t client_key_message_size = s2n_stuffer_data_available(&client_key_message); struct s2n_blob client_key_blob = { 0 }; POSIX_GUARD(s2n_blob_init(&client_key_blob, client_key_message.blob.data, client_key_message_size)); uint8_t data[S2N_MAX_DIGEST_LEN] = { 0 }; struct s2n_blob digest = { 0 }; POSIX_GUARD(s2n_blob_init(&digest, data, sizeof(data))); if (conn->actual_protocol_version < S2N_TLS12) { uint8_t sha1_data[S2N_MAX_DIGEST_LEN] = { 0 }; struct s2n_blob sha1_digest = { 0 }; POSIX_GUARD(s2n_blob_init(&sha1_digest, sha1_data, sizeof(sha1_data))); POSIX_GUARD_RESULT(s2n_prf_get_digest_for_ems(conn, &client_key_blob, S2N_HASH_MD5, &digest)); POSIX_GUARD_RESULT(s2n_prf_get_digest_for_ems(conn, &client_key_blob, S2N_HASH_SHA1, &sha1_digest)); POSIX_GUARD_RESULT(s2n_tls_prf_extended_master_secret(conn, premaster_secret, &digest, &sha1_digest)); } else { s2n_hmac_algorithm prf_alg = conn->secure.cipher_suite->prf_alg; s2n_hash_algorithm hash_alg = 0; POSIX_GUARD(s2n_hmac_hash_alg(prf_alg, &hash_alg)); POSIX_GUARD_RESULT(s2n_prf_get_digest_for_ems(conn, &client_key_blob, hash_alg, &digest)); POSIX_GUARD_RESULT(s2n_tls_prf_extended_master_secret(conn, premaster_secret, &digest, NULL)); } return S2N_SUCCESS; } /** *= https://tools.ietf.org/rfc/rfc7627#section-4 *# When the extended master secret extension is negotiated in a full *# handshake, the "master_secret" is computed as *# *# master_secret = PRF(pre_master_secret, "extended master secret", *# session_hash) *# [0..47]; */ S2N_RESULT s2n_tls_prf_extended_master_secret(struct s2n_connection *conn, struct s2n_blob *premaster_secret, struct s2n_blob *session_hash, struct s2n_blob *sha1_hash) { struct s2n_blob extended_master_secret = {.size = sizeof(conn->secrets.tls12.master_secret), .data = conn->secrets.tls12.master_secret}; uint8_t extended_master_secret_label[] = "extended master secret"; /* Subtract one from the label size to remove the "\0" */ struct s2n_blob label = {.size = sizeof(extended_master_secret_label) - 1, .data = extended_master_secret_label}; RESULT_GUARD_POSIX(s2n_prf(conn, premaster_secret, &label, session_hash, sha1_hash, NULL, &extended_master_secret)); return S2N_RESULT_OK; } S2N_RESULT s2n_prf_get_digest_for_ems(struct s2n_connection *conn, struct s2n_blob *message, s2n_hash_algorithm hash_alg, struct s2n_blob *output) { RESULT_ENSURE_REF(conn); RESULT_ENSURE_REF(conn->handshake.hashes); RESULT_ENSURE_REF(output); struct s2n_hash_state hash_state = { 0 }; RESULT_GUARD_POSIX(s2n_handshake_get_hash_state(conn, hash_alg, &hash_state)); RESULT_GUARD_POSIX(s2n_hash_copy(&conn->handshake.hashes->hash_workspace, &hash_state)); RESULT_GUARD_POSIX(s2n_hash_update(&conn->handshake.hashes->hash_workspace, message->data, message->size)); uint8_t digest_size = 0; RESULT_GUARD_POSIX(s2n_hash_digest_size(conn->handshake.hashes->hash_workspace.alg, &digest_size)); RESULT_ENSURE_GTE(output->size, digest_size); RESULT_GUARD_POSIX(s2n_hash_digest(&conn->handshake.hashes->hash_workspace, output->data, digest_size)); output->size = digest_size; return S2N_RESULT_OK; } static int s2n_sslv3_finished(struct s2n_connection *conn, uint8_t prefix[4], struct s2n_hash_state *hash_workspace, uint8_t * out) { POSIX_ENSURE_REF(conn); POSIX_ENSURE_REF(conn->handshake.hashes); uint8_t xorpad1[48] = { 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 }; uint8_t xorpad2[48] = { 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c }; uint8_t *md5_digest = out; uint8_t *sha_digest = out + MD5_DIGEST_LENGTH; POSIX_ENSURE_LTE(MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, sizeof(conn->handshake.client_finished)); struct s2n_hash_state *md5 = hash_workspace; POSIX_GUARD(s2n_hash_copy(md5, &conn->handshake.hashes->md5)); POSIX_GUARD(s2n_hash_update(md5, prefix, 4)); POSIX_GUARD(s2n_hash_update(md5, conn->secrets.tls12.master_secret, sizeof(conn->secrets.tls12.master_secret))); POSIX_GUARD(s2n_hash_update(md5, xorpad1, 48)); POSIX_GUARD(s2n_hash_digest(md5, md5_digest, MD5_DIGEST_LENGTH)); POSIX_GUARD(s2n_hash_reset(md5)); POSIX_GUARD(s2n_hash_update(md5, conn->secrets.tls12.master_secret, sizeof(conn->secrets.tls12.master_secret))); POSIX_GUARD(s2n_hash_update(md5, xorpad2, 48)); POSIX_GUARD(s2n_hash_update(md5, md5_digest, MD5_DIGEST_LENGTH)); POSIX_GUARD(s2n_hash_digest(md5, md5_digest, MD5_DIGEST_LENGTH)); POSIX_GUARD(s2n_hash_reset(md5)); struct s2n_hash_state *sha1 = hash_workspace; POSIX_GUARD(s2n_hash_copy(sha1, &conn->handshake.hashes->sha1)); POSIX_GUARD(s2n_hash_update(sha1, prefix, 4)); POSIX_GUARD(s2n_hash_update(sha1, conn->secrets.tls12.master_secret, sizeof(conn->secrets.tls12.master_secret))); POSIX_GUARD(s2n_hash_update(sha1, xorpad1, 40)); POSIX_GUARD(s2n_hash_digest(sha1, sha_digest, SHA_DIGEST_LENGTH)); POSIX_GUARD(s2n_hash_reset(sha1)); POSIX_GUARD(s2n_hash_update(sha1, conn->secrets.tls12.master_secret, sizeof(conn->secrets.tls12.master_secret))); POSIX_GUARD(s2n_hash_update(sha1, xorpad2, 40)); POSIX_GUARD(s2n_hash_update(sha1, sha_digest, SHA_DIGEST_LENGTH)); POSIX_GUARD(s2n_hash_digest(sha1, sha_digest, SHA_DIGEST_LENGTH)); POSIX_GUARD(s2n_hash_reset(sha1)); return 0; } static int s2n_sslv3_client_finished(struct s2n_connection *conn) { POSIX_ENSURE_REF(conn); POSIX_ENSURE_REF(conn->handshake.hashes); uint8_t prefix[4] = { 0x43, 0x4c, 0x4e, 0x54 }; POSIX_ENSURE_LTE(MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, sizeof(conn->handshake.client_finished)); return s2n_sslv3_finished(conn, prefix, &conn->handshake.hashes->hash_workspace, conn->handshake.client_finished); } static int s2n_sslv3_server_finished(struct s2n_connection *conn) { POSIX_ENSURE_REF(conn); POSIX_ENSURE_REF(conn->handshake.hashes); uint8_t prefix[4] = { 0x53, 0x52, 0x56, 0x52 }; POSIX_ENSURE_LTE(MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, sizeof(conn->handshake.server_finished)); return s2n_sslv3_finished(conn, prefix, &conn->handshake.hashes->hash_workspace, conn->handshake.server_finished); } int s2n_prf_client_finished(struct s2n_connection *conn) { POSIX_ENSURE_REF(conn); POSIX_ENSURE_REF(conn->handshake.hashes); struct s2n_blob master_secret, md5, sha; uint8_t md5_digest[MD5_DIGEST_LENGTH]; uint8_t sha_digest[SHA384_DIGEST_LENGTH]; uint8_t client_finished_label[] = "client finished"; struct s2n_blob client_finished = {0}; struct s2n_blob label = {0}; if (conn->actual_protocol_version == S2N_SSLv3) { return s2n_sslv3_client_finished(conn); } client_finished.data = conn->handshake.client_finished; client_finished.size = S2N_TLS_FINISHED_LEN; label.data = client_finished_label; label.size = sizeof(client_finished_label) - 1; master_secret.data = conn->secrets.tls12.master_secret; master_secret.size = sizeof(conn->secrets.tls12.master_secret); if (conn->actual_protocol_version == S2N_TLS12) { switch (conn->secure.cipher_suite->prf_alg) { case S2N_HMAC_SHA256: POSIX_GUARD(s2n_hash_copy(&conn->handshake.hashes->hash_workspace, &conn->handshake.hashes->sha256)); POSIX_GUARD(s2n_hash_digest(&conn->handshake.hashes->hash_workspace, sha_digest, SHA256_DIGEST_LENGTH)); sha.size = SHA256_DIGEST_LENGTH; break; case S2N_HMAC_SHA384: POSIX_GUARD(s2n_hash_copy(&conn->handshake.hashes->hash_workspace, &conn->handshake.hashes->sha384)); POSIX_GUARD(s2n_hash_digest(&conn->handshake.hashes->hash_workspace, sha_digest, SHA384_DIGEST_LENGTH)); sha.size = SHA384_DIGEST_LENGTH; break; default: POSIX_BAIL(S2N_ERR_PRF_INVALID_ALGORITHM); } sha.data = sha_digest; return s2n_prf(conn, &master_secret, &label, &sha, NULL, NULL, &client_finished); } POSIX_GUARD(s2n_hash_copy(&conn->handshake.hashes->hash_workspace, &conn->handshake.hashes->md5)); POSIX_GUARD(s2n_hash_digest(&conn->handshake.hashes->hash_workspace, md5_digest, MD5_DIGEST_LENGTH)); md5.data = md5_digest; md5.size = MD5_DIGEST_LENGTH; POSIX_GUARD(s2n_hash_copy(&conn->handshake.hashes->hash_workspace, &conn->handshake.hashes->sha1)); POSIX_GUARD(s2n_hash_digest(&conn->handshake.hashes->hash_workspace, sha_digest, SHA_DIGEST_LENGTH)); sha.data = sha_digest; sha.size = SHA_DIGEST_LENGTH; return s2n_prf(conn, &master_secret, &label, &md5, &sha, NULL, &client_finished); } int s2n_prf_server_finished(struct s2n_connection *conn) { POSIX_ENSURE_REF(conn); POSIX_ENSURE_REF(conn->handshake.hashes); struct s2n_blob master_secret, md5, sha; uint8_t md5_digest[MD5_DIGEST_LENGTH]; uint8_t sha_digest[SHA384_DIGEST_LENGTH]; uint8_t server_finished_label[] = "server finished"; struct s2n_blob server_finished = {0}; struct s2n_blob label = {0}; if (conn->actual_protocol_version == S2N_SSLv3) { return s2n_sslv3_server_finished(conn); } server_finished.data = conn->handshake.server_finished; server_finished.size = S2N_TLS_FINISHED_LEN; label.data = server_finished_label; label.size = sizeof(server_finished_label) - 1; master_secret.data = conn->secrets.tls12.master_secret; master_secret.size = sizeof(conn->secrets.tls12.master_secret); if (conn->actual_protocol_version == S2N_TLS12) { switch (conn->secure.cipher_suite->prf_alg) { case S2N_HMAC_SHA256: POSIX_GUARD(s2n_hash_copy(&conn->handshake.hashes->hash_workspace, &conn->handshake.hashes->sha256)); POSIX_GUARD(s2n_hash_digest(&conn->handshake.hashes->hash_workspace, sha_digest, SHA256_DIGEST_LENGTH)); sha.size = SHA256_DIGEST_LENGTH; break; case S2N_HMAC_SHA384: POSIX_GUARD(s2n_hash_copy(&conn->handshake.hashes->hash_workspace, &conn->handshake.hashes->sha384)); POSIX_GUARD(s2n_hash_digest(&conn->handshake.hashes->hash_workspace, sha_digest, SHA384_DIGEST_LENGTH)); sha.size = SHA384_DIGEST_LENGTH; break; default: POSIX_BAIL(S2N_ERR_PRF_INVALID_ALGORITHM); } sha.data = sha_digest; return s2n_prf(conn, &master_secret, &label, &sha, NULL, NULL, &server_finished); } POSIX_GUARD(s2n_hash_copy(&conn->handshake.hashes->hash_workspace, &conn->handshake.hashes->md5)); POSIX_GUARD(s2n_hash_digest(&conn->handshake.hashes->hash_workspace, md5_digest, MD5_DIGEST_LENGTH)); md5.data = md5_digest; md5.size = MD5_DIGEST_LENGTH; POSIX_GUARD(s2n_hash_copy(&conn->handshake.hashes->hash_workspace, &conn->handshake.hashes->sha1)); POSIX_GUARD(s2n_hash_digest(&conn->handshake.hashes->hash_workspace, sha_digest, SHA_DIGEST_LENGTH)); sha.data = sha_digest; sha.size = SHA_DIGEST_LENGTH; return s2n_prf(conn, &master_secret, &label, &md5, &sha, NULL, &server_finished); } static int s2n_prf_make_client_key(struct s2n_connection *conn, struct s2n_stuffer *key_material) { struct s2n_blob client_key = {0}; client_key.size = conn->secure.cipher_suite->record_alg->cipher->key_material_size; client_key.data = s2n_stuffer_raw_read(key_material, client_key.size); POSIX_ENSURE_REF(client_key.data); if (conn->mode == S2N_CLIENT) { POSIX_GUARD(conn->secure.cipher_suite->record_alg->cipher->set_encryption_key(&conn->secure.client_key, &client_key)); } else { POSIX_GUARD(conn->secure.cipher_suite->record_alg->cipher->set_decryption_key(&conn->secure.client_key, &client_key)); } return 0; } static int s2n_prf_make_server_key(struct s2n_connection *conn, struct s2n_stuffer *key_material) { struct s2n_blob server_key = {0}; server_key.size = conn->secure.cipher_suite->record_alg->cipher->key_material_size; server_key.data = s2n_stuffer_raw_read(key_material, server_key.size); POSIX_ENSURE_REF(server_key.data); if (conn->mode == S2N_SERVER) { POSIX_GUARD(conn->secure.cipher_suite->record_alg->cipher->set_encryption_key(&conn->secure.server_key, &server_key)); } else { POSIX_GUARD(conn->secure.cipher_suite->record_alg->cipher->set_decryption_key(&conn->secure.server_key, &server_key)); } return 0; } int s2n_prf_key_expansion(struct s2n_connection *conn) { struct s2n_blob client_random = {.data = conn->handshake_params.client_random,.size = sizeof(conn->handshake_params.client_random) }; struct s2n_blob server_random = {.data = conn->handshake_params.server_random,.size = sizeof(conn->handshake_params.server_random) }; struct s2n_blob master_secret = {.data = conn->secrets.tls12.master_secret,.size = sizeof(conn->secrets.tls12.master_secret) }; struct s2n_blob label, out; uint8_t key_expansion_label[] = "key expansion"; uint8_t key_block[S2N_MAX_KEY_BLOCK_LEN]; label.data = key_expansion_label; label.size = sizeof(key_expansion_label) - 1; POSIX_GUARD(s2n_blob_init(&out, key_block, sizeof(key_block))); struct s2n_stuffer key_material = {0}; POSIX_GUARD(s2n_prf(conn, &master_secret, &label, &server_random, &client_random, NULL, &out)); POSIX_GUARD(s2n_stuffer_init(&key_material, &out)); POSIX_GUARD(s2n_stuffer_write(&key_material, &out)); POSIX_ENSURE(conn->secure.cipher_suite->available, S2N_ERR_PRF_INVALID_ALGORITHM); POSIX_GUARD(conn->secure.cipher_suite->record_alg->cipher->init(&conn->secure.client_key)); POSIX_GUARD(conn->secure.cipher_suite->record_alg->cipher->init(&conn->secure.server_key)); /* Check that we have a valid MAC and key size */ uint8_t mac_size; if (conn->secure.cipher_suite->record_alg->cipher->type == S2N_COMPOSITE) { mac_size = conn->secure.cipher_suite->record_alg->cipher->io.comp.mac_key_size; } else { POSIX_GUARD(s2n_hmac_digest_size(conn->secure.cipher_suite->record_alg->hmac_alg, &mac_size)); } /* Seed the client MAC */ uint8_t *client_mac_write_key = s2n_stuffer_raw_read(&key_material, mac_size); POSIX_ENSURE_REF(client_mac_write_key); POSIX_GUARD(s2n_hmac_reset(&conn->secure.client_record_mac)); POSIX_GUARD(s2n_hmac_init(&conn->secure.client_record_mac, conn->secure.cipher_suite->record_alg->hmac_alg, client_mac_write_key, mac_size)); /* Seed the server MAC */ uint8_t *server_mac_write_key = s2n_stuffer_raw_read(&key_material, mac_size); POSIX_ENSURE_REF(server_mac_write_key); POSIX_GUARD(s2n_hmac_reset(&conn->secure.server_record_mac)); POSIX_GUARD(s2n_hmac_init(&conn->secure.server_record_mac, conn->secure.cipher_suite->record_alg->hmac_alg, server_mac_write_key, mac_size)); /* Make the client key */ POSIX_GUARD(s2n_prf_make_client_key(conn, &key_material)); /* Make the server key */ POSIX_GUARD(s2n_prf_make_server_key(conn, &key_material)); /* Composite CBC does MAC inside the cipher, pass it the MAC key. * Must happen after setting encryption/decryption keys. */ if (conn->secure.cipher_suite->record_alg->cipher->type == S2N_COMPOSITE) { POSIX_GUARD(conn->secure.cipher_suite->record_alg->cipher->io.comp.set_mac_write_key(&conn->secure.server_key, server_mac_write_key, mac_size)); POSIX_GUARD(conn->secure.cipher_suite->record_alg->cipher->io.comp.set_mac_write_key(&conn->secure.client_key, client_mac_write_key, mac_size)); } /* TLS >= 1.1 has no implicit IVs for non AEAD ciphers */ if (conn->actual_protocol_version > S2N_TLS10 && conn->secure.cipher_suite->record_alg->cipher->type != S2N_AEAD) { return 0; } uint32_t implicit_iv_size = 0; switch (conn->secure.cipher_suite->record_alg->cipher->type) { case S2N_AEAD: implicit_iv_size = conn->secure.cipher_suite->record_alg->cipher->io.aead.fixed_iv_size; break; case S2N_CBC: implicit_iv_size = conn->secure.cipher_suite->record_alg->cipher->io.cbc.block_size; break; case S2N_COMPOSITE: implicit_iv_size = conn->secure.cipher_suite->record_alg->cipher->io.comp.block_size; break; /* No-op for stream ciphers */ default: break; } struct s2n_blob client_implicit_iv = {.data = conn->secure.client_implicit_iv,.size = implicit_iv_size }; struct s2n_blob server_implicit_iv = {.data = conn->secure.server_implicit_iv,.size = implicit_iv_size }; POSIX_GUARD(s2n_stuffer_read(&key_material, &client_implicit_iv)); POSIX_GUARD(s2n_stuffer_read(&key_material, &server_implicit_iv)); return 0; }
40.967742
177
0.723052
fa41adfb49a76755c9f31daa7bff179b6a2a4146
4,608
h
C
code/wxWidgets/utils/emulator/src/emulator.h
Bloodknight/NeuTorsion
a5890e9ca145a8c1b6bec7b70047a43d9b1c29ea
[ "MIT" ]
38
2016-02-20T02:46:28.000Z
2021-11-17T11:39:57.000Z
code/wxWidgets/utils/emulator/src/emulator.h
Dwarf-King/TorsionEditor
e6887d1661ebaf4ccbf1d09f2690e2bf805fbb50
[ "MIT" ]
17
2016-02-20T02:19:55.000Z
2021-02-08T15:15:17.000Z
code/wxWidgets/utils/emulator/src/emulator.h
Dwarf-King/TorsionEditor
e6887d1661ebaf4ccbf1d09f2690e2bf805fbb50
[ "MIT" ]
46
2016-02-20T02:47:33.000Z
2021-01-31T15:46:05.000Z
/////////////////////////////////////////////////////////////////////////////// // Name: emulator.h // Purpose: wxX11-based PDA emulator classes // Author: Julian Smart // Modified by: // Created: 2002-03-10 // RCS-ID: $Id: emulator.h,v 1.8 2005/02/01 20:36:10 ABX Exp $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// #ifndef _WX_EMULATOR_H_ #define _WX_EMULATOR_H_ #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma interface "emulator.h" #endif #define wxEMULATOR_VERSION 0.1 // Information about the emulator decorations class wxEmulatorInfo: public wxObject { public: wxEmulatorInfo() { Init(); } wxEmulatorInfo(const wxEmulatorInfo& info) : wxObject() { Init(); Copy(info); } void operator= (const wxEmulatorInfo& info) { Copy(info); } void Copy(const wxEmulatorInfo& info); // Initialisation void Init(); // Loads bitmaps bool Load(const wxString& appDir); // Emulator config filename wxString m_emulatorFilename; // Emulator title wxString m_emulatorTitle; // Emulator description wxString m_emulatorDescription; // The offset from the top-left of the main emulator // bitmap and the virtual screen (where Xnest is // positioned) wxPoint m_emulatorScreenPosition; // The emulated screen size, e.g. 320x240 wxSize m_emulatorScreenSize; // The emulated device size. This is ignored // if there is a background bitmap wxSize m_emulatorDeviceSize; // The bitmap used for drawing the main emulator // decorations wxBitmap m_emulatorBackgroundBitmap; wxString m_emulatorBackgroundBitmapName; // The intended background colour (for filling in // areas of the window not covered by the bitmap) wxColour m_emulatorBackgroundColour; // TODO: an array of bitmaps and ids for custom buttons }; // Emulator app class class wxEmulatorContainer; class wxEmulatorApp : public wxApp { public: wxEmulatorApp(); virtual bool OnInit(); // Load the specified emulator bool LoadEmulator(const wxString& appDir); // Get app dir wxString GetAppDir() const { return m_appDir; } // Prepend the current app program directory to the name wxString GetFullAppPath(const wxString& filename) const; public: wxEmulatorInfo m_emulatorInfo; #ifdef __WXX11__ wxAdoptedWindow* m_xnestWindow; #else wxWindow* m_xnestWindow; #endif wxEmulatorContainer* m_containerWindow; wxString m_appDir; wxString m_displayNumber; long m_xnestPID; }; // The container for the Xnest window. The decorations // will be drawn on this window. class wxEmulatorContainer: public wxWindow { public: wxEmulatorContainer(wxWindow* parent, wxWindowID id); void DoResize(); void OnSize(wxSizeEvent& event); void OnPaint(wxPaintEvent& event); void OnEraseBackground(wxEraseEvent& event); DECLARE_CLASS(wxEmulatorContainer) DECLARE_EVENT_TABLE() }; // Frame class class wxEmulatorFrame : public wxFrame { public: // ctor(s) wxEmulatorFrame(const wxString& title, const wxPoint& pos, const wxSize& size); // event handlers void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); void OnCloseWindow(wxCloseEvent& event); private: // any class wishing to process wxWidgets events must use this macro DECLARE_EVENT_TABLE() }; // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- // IDs for the controls and the menu commands enum { // menu items Emulator_Quit = 1, // it is important for the id corresponding to the "About" command to have // this standard value as otherwise it won't be handled properly under Mac // (where it is special and put into the "Apple" menu) Emulator_About = wxID_ABOUT }; // Returns the image type, or -1, determined from the extension. wxBitmapType wxDetermineImageType(const wxString& filename); // Convert a colour to a 6-digit hex string wxString wxColourToHexString(const wxColour& col); // Convert 6-digit hex string to a colour wxColour wxHexStringToColour(const wxString& hex); // Find the absolute path where this application has been run from. wxString wxFindAppPath(const wxString& argv0, const wxString& cwd, const wxString& appVariableName); #endif // _WX_EMULATOR_H_
27.266272
100
0.656901
d259780c86a31363f8f2006fcb674091b927fd28
229
h
C
HospitalBible-new/HospitalBible/MircroClass/ViewController/MircoClassViewController.h
xiaowei19891014/hospitalbible
0d8c4188698e6c21b600d7451e8a782f1610ef50
[ "Apache-2.0" ]
null
null
null
HospitalBible-new/HospitalBible/MircroClass/ViewController/MircoClassViewController.h
xiaowei19891014/hospitalbible
0d8c4188698e6c21b600d7451e8a782f1610ef50
[ "Apache-2.0" ]
null
null
null
HospitalBible-new/HospitalBible/MircroClass/ViewController/MircoClassViewController.h
xiaowei19891014/hospitalbible
0d8c4188698e6c21b600d7451e8a782f1610ef50
[ "Apache-2.0" ]
null
null
null
// // MircoClassViewController.h // HospitalBible // // Created by me on 17/5/13. // Copyright © 2017年 com.hao. All rights reserved. // #import "WMPageController.h" @interface MircoClassViewController :WMPageController @end
19.083333
53
0.733624
8288da02496373e876187976bc8fc314c281d63d
1,109
h
C
code/addons/attic/physics/physicsutil.h
gscept/nebula-trifid
e7c0a0acb05eedad9ed37a72c1bdf2d658511b42
[ "BSD-2-Clause" ]
67
2015-03-30T19:56:16.000Z
2022-03-11T13:52:17.000Z
code/addons/attic/physics/physicsutil.h
gscept/nebula-trifid
e7c0a0acb05eedad9ed37a72c1bdf2d658511b42
[ "BSD-2-Clause" ]
5
2015-04-15T17:17:33.000Z
2016-02-11T00:40:17.000Z
code/addons/attic/physics/physicsutil.h
gscept/nebula-trifid
e7c0a0acb05eedad9ed37a72c1bdf2d658511b42
[ "BSD-2-Clause" ]
34
2015-03-30T15:08:00.000Z
2021-09-23T05:55:10.000Z
#ifndef PHYSICS_PHYSICSUTIL_H #define PHYSICS_PHYSICSUTIL_H //------------------------------------------------------------------------------ /** @class Physics::PhysicsUtil Implements some static physics utility methods. (C) 2004 RadonLabs GmbH */ #include "core/types.h" #include "math/vector.h" #include "physics/filterset.h" //------------------------------------------------------------------------------ namespace Physics { class ContactPoint; class PhysicsUtil { public: /// do a normal stabbing test and return closest contact static bool RayCheck(const Math::vector& from, const Math::vector& to, const FilterSet& excludeSet, ContactPoint& outContact); /// do a stabbing test into the world with a ray bundle, return distance to intersection static bool RayBundleCheck(const Math::vector& from, const Math::vector& to, const Math::vector& upVec, const Math::vector& leftVec, float bundleRadius, const FilterSet& excludeSet, float& outContactDist); }; }; // namespace Physics //------------------------------------------------------------------------------ #endif
33.606061
209
0.582507
30646d1e3e9bf271301f684278ccfe91e284899c
623
h
C
raygame/Player.h
BryceDeso/BattleArena-Collaberation
3bb395fa444b1545e9c8285885734e932bc1caaf
[ "MIT" ]
null
null
null
raygame/Player.h
BryceDeso/BattleArena-Collaberation
3bb395fa444b1545e9c8285885734e932bc1caaf
[ "MIT" ]
null
null
null
raygame/Player.h
BryceDeso/BattleArena-Collaberation
3bb395fa444b1545e9c8285885734e932bc1caaf
[ "MIT" ]
null
null
null
#pragma once #include "Actor.h" class Player : public Actor { public: Player(); Player(float health, float x, float y, float collisionRadius, char icon, float maxSpeed); void SetPlayerInput(KeyboardKey up, KeyboardKey down, KeyboardKey left, KeyboardKey right, KeyboardKey brake, KeyboardKey shoot); bool getIsAlive(); //Gets player's current health. float getHealth() { return m_health; } void update(float deltatime) override; private: KeyboardKey m_moveUp; KeyboardKey m_moveDown; KeyboardKey m_moveLeft; KeyboardKey m_moveRight; KeyboardKey m_brake; KeyboardKey m_shoot; float m_health; int m_ID; };
23.074074
130
0.770465
cf96a498135074c16ce59151e84cac67726c306b
1,663
h
C
include/irrklang/ik_ISoundDeviceList.h
Meridian59Kor/Meridian59
ab6d271c0e686250c104bd5c0886c91ec7cfa2b5
[ "FSFAP" ]
619
2016-06-17T02:09:44.000Z
2022-03-28T08:56:40.000Z
libraries/include/irrKlang/ik_ISoundDeviceList.h
chrissjay/noteForOpenGL
d982d2969e53f2b3a98b0de95a729bfddcd4488b
[ "MIT" ]
120
2015-01-01T13:02:04.000Z
2015-08-14T20:06:27.000Z
libraries/include/irrKlang/ik_ISoundDeviceList.h
chrissjay/noteForOpenGL
d982d2969e53f2b3a98b0de95a729bfddcd4488b
[ "MIT" ]
494
2016-06-14T05:57:52.000Z
2022-03-27T01:39:36.000Z
// Copyright (C) 2002-2014 Nikolaus Gebhardt // This file is part of the "irrKlang" library. // For conditions of distribution and use, see copyright notice in irrKlang.h #ifndef __I_IRRKLANG_SOUND_DEVICE_LIST_H_INCLUDED__ #define __I_IRRKLANG_SOUND_DEVICE_LIST_H_INCLUDED__ #include "ik_IRefCounted.h" namespace irrklang { //! A list of sound devices for a sound driver. Use irrklang::createSoundDeviceList() to create this list. /** The function createIrrKlangDevice() has a parameter 'deviceID' which takes the value returned by ISoundDeviceList::getDeviceID() and uses that device then. The list of devices in ISoundDeviceList usually also includes the default device which is the first entry and has an empty deviceID string ("") and the description "default device". There is some example code on how to use the ISoundDeviceList in @ref enumeratingDevices.*/ class ISoundDeviceList : public IRefCounted { public: //! Returns amount of enumerated devices in the list. virtual ik_s32 getDeviceCount() = 0; //! Returns the ID of the device. Use this string to identify this device in createIrrKlangDevice(). /** \param index Index of the device, a value between 0 and ISoundDeviceList::getDeviceCount()-1. \return Returns a pointer to a string identifying the device. The string will only as long valid as long as the ISoundDeviceList exists. */ virtual const char* getDeviceID(ik_s32 index) = 0; //! Returns description of the device. /** \param index Index of the device, a value between 0 and ISoundDeviceList::getDeviceCount()-1. */ virtual const char* getDeviceDescription(ik_s32 index) = 0; }; } // end namespace irrklang #endif
39.595238
106
0.774504