blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
b2d972c3962ddde35d720fc041011a8a19582f16
601e9f409ec1c5de2d5a56331979db3bcb41dc8f
/Code/ProtoTowers/Components/TowerInfo.cpp
281193d8775d6f304c3b694af459f465d0bebce2
[]
no_license
bmclaine/ProtoTowers
1f12cd6e299be6771188e8b0738db5e6f8301b50
c9bbe2896591f456c5fde6595d7d76f9031fd2f4
refs/heads/master
2020-04-17T07:10:05.522159
2016-08-31T01:07:14
2016-08-31T01:07:14
66,881,935
0
0
null
null
null
null
UTF-8
C++
false
false
4,575
cpp
#include "stdafx.h" #include "TowerInfo.h" #include "../InfernoUI.h" #include "BaseTower.h" // ===== Constructor / Destructor ===== // TowerInfo::TowerInfo(UIElement* _owner) : UIComponent(_owner), m_fcTowerInfoFlags((unsigned int)TI_MAX_FLAGS) { m_eType = TowerTypes::TT_UNKNOWN; m_fNameXOffset = 0.0f; m_fNameYOffset = -30.0f; m_fUnavailXOffset = m_fUnavailYOffset = 0.0f; m_fPriceXOffset = 0.0f; m_fPriceYOffset = 70.0f; m_fcTowerInfoFlags.SetFlag((unsigned int)TI_CanBuy_Flag, (unsigned int)true); m_pUnavailableTexture = new Texture(); m_pUnavailableTexture->SetImage(Inferno::GetImage(L"UI_xOut_Img.dds")); // === Name Element RectTransform* transform; UIElement* nameElement = new UIElement(); transform = nameElement->GetTransform(); transform->SetParent(GetTransform()); transform->SetPosition(0.0f, m_fNameYOffset); transform->SetBounds(Vector2(120.0f, 25.0f)); //// Components m_pName = nameElement->AddComponent<UIText>(); m_pName->SetLayer(6); m_pName->SetAlignment(TextAlignment::CENTER); // === Unavailable Element UIElement* unavailElement = new UIElement(); transform = unavailElement->GetTransform(); transform->SetParent(GetTransform()); transform->SetPosition(m_fUnavailXOffset, m_fUnavailYOffset); transform->SetBounds(Vector2(64.0f, 64.0f)); //// Components m_pUnavailableImg = unavailElement->AddComponent<UIRenderer>(); m_pUnavailableImg->SetLayer(5); m_pUnavailableImg->SetTexture(m_pUnavailableTexture); m_pUnavailableImg->SetEnabled(false); // === Price Element UIElement* priceElement = new UIElement(); transform = priceElement->GetTransform(); transform->SetParent(GetTransform()); transform->SetPosition(0.0f, m_fPriceYOffset); transform->SetBounds(Vector2(100.0f, 25.0f)); //// Components m_pPrice = priceElement->AddComponent<UIText>(); m_pPrice->SetLayer(6); m_pPrice->SetAlignment(TextAlignment::CENTER); } TowerInfo::~TowerInfo() { delete m_pUnavailableTexture; } // ==================================== // // ===== Interface ===== // void TowerInfo::OnEnable() { m_uiTowerCost = BaseTower::GetPriceOfTower(m_eType); m_pName->GetTransform()->SetPosition(m_fNameXOffset, m_fNameYOffset); m_pName->SetText(BaseTower::GetNameOfTower(m_eType)); m_pName->SetColor(Color(0.0f, 1.0f, 0.0f, 1.0f)); m_pName->SetFontSize(18.0f); m_pUnavailableImg->GetTransform()->SetPosition(m_fUnavailXOffset, m_fUnavailYOffset); m_pPrice->GetTransform()->SetPosition(m_fPriceXOffset, m_fPriceYOffset); m_pPrice->SetText(std::to_string(m_uiTowerCost)); m_pPrice->SetColor(Color(1.0f, 1.0f, 1.0f, 1.0f)); m_pPrice->SetFontSize(22.0f); Player::AddForResourceTracking(this, BindForResourceTracking(&TowerInfo::OnResourceUpdate, this)); if (!m_fcTowerInfoFlags.GetFlag((unsigned int)TI_Unavailable_Flag)) { m_fcTowerInfoFlags.SetFlag((unsigned int)TI_CanBuy_Flag, (unsigned int)true); m_pUnavailableImg->SetEnabled(false); } OnResourceUpdate(Player::GetResources()); } void TowerInfo::OnDisable() { Player::RemoveFromResourceTracking(this); } // ===================== // // ===== Private Interface ===== // void TowerInfo::OnResourceUpdate(unsigned int _newAmount) { if (m_fcTowerInfoFlags.GetFlag((unsigned int)TI_Unavailable_Flag)) { return; } if (_newAmount < m_uiTowerCost && m_fcTowerInfoFlags.GetFlag((unsigned int)TI_CanBuy_Flag)) { // === Not Enough Resources m_pPrice->SetColor(Color(1.0f, 0.0f, 0.0f, 1.0f)); m_pUnavailableImg->SetEnabled(true); m_fcTowerInfoFlags.SetFlag((unsigned int)TI_CanBuy_Flag, (unsigned int)false); } else if (_newAmount >= m_uiTowerCost && !m_fcTowerInfoFlags.GetFlag((unsigned int)TI_CanBuy_Flag)) { // === Has Enough Resources m_pPrice->SetColor(Color(1.0f, 1.0f, 1.0f, 1.0f)); m_pUnavailableImg->SetEnabled(false); m_fcTowerInfoFlags.SetFlag((unsigned int)TI_CanBuy_Flag, (unsigned int)true); } } // ============================= // // ===== Mutators ===== // void TowerInfo::SetType(TowerTypes _type) { m_eType = _type; } void TowerInfo::SetNameOffset(float _xOffset, float _yOffset) { m_fNameXOffset = _xOffset; m_fNameYOffset = _yOffset; } void TowerInfo::SetUnavailableOffset(float _xOffset, float _yOffset) { m_fUnavailXOffset = _xOffset; m_fUnavailYOffset = _yOffset; } void TowerInfo::SetPriceOffset(float _xOffset, float _yOffset) { m_fPriceXOffset = _xOffset; m_fPriceYOffset = _yOffset; } void TowerInfo::SetAsUnavailable(bool _value) { m_pUnavailableImg->SetEnabled(_value); m_fcTowerInfoFlags.SetFlag((unsigned int)TI_Unavailable_Flag, (unsigned int)_value); } // ==================== //
[ "bizzy18@gmail.com" ]
bizzy18@gmail.com
2454a5cae2ca670a69bd9e73862f53dea6e0fd62
14ce01a6f9199d39e28d036e066d99cfb3e3f211
/Cpp/SDK/BP_AssaultRifle_Tier1_classes.h
049937cfe60d7a1b51a0609932225597e2c6201f
[]
no_license
zH4x-SDK/zManEater-SDK
73f14dd8f758bb7eac649f0c66ce29f9974189b7
d040c05a93c0935d8052dd3827c2ef91c128bce7
refs/heads/main
2023-07-19T04:54:51.672951
2021-08-27T13:47:27
2021-08-27T13:47:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
759
h
#pragma once // Name: ManEater, Version: 1.0.0 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass BP_AssaultRifle_Tier1.BP_AssaultRifle_Tier1_C // 0x0000 (FullSize[0x06E0] - InheritedSize[0x06E0]) class UBP_AssaultRifle_Tier1_C : public UBP_AssaultRifle_Base_C { public: static UClass* StaticClass() { static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_AssaultRifle_Tier1.BP_AssaultRifle_Tier1_C"); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "zp2kshield@gmail.com" ]
zp2kshield@gmail.com
782df21a269096eb4cbf63f0ba45a9a4264e7ef1
283a5cc41be5c4a3334fb1c2070aacd50c5a32cf
/Asteroids/Source/Private/window.cpp
4c5b385fab469fb901e58d5b2371b335c3b2dc2d
[]
no_license
josmgood/Asteroids
c7af1bd0a8035bf4ce587d39c11097a095878175
ed8898b9ec0d3102635fb0941d4ad4655c3b6bf1
refs/heads/master
2021-05-30T18:43:44.858609
2016-03-07T03:40:00
2016-03-07T03:40:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,937
cpp
#include "..\Public\window.h" /* ===================================== WINDOW ===================================== */ Window::Window(void) : _window(nullptr), _size(), _title(), _isOpen(false) { } Window::Window(glm::uvec2 size, const std::string& title) : _window(nullptr), _size(), _title(), _isOpen(false) { create(size, title); } Window::Window(GLuint width, GLuint height, const std::string& title) : _window(nullptr), _size(), _title(title), _isOpen(false) { create(width, height, title); } Window::~Window() { close(); } bool Window::create(glm::uvec2 size, const std::string& title) { _window = glfwCreateWindow(size.x, size.y, title.c_str(), nullptr, nullptr); if (_window) { _isOpen = true; _size = size; _title = title; glfwMakeContextCurrent(_window); return true; } else { return false; } } bool Window::create(GLuint width, GLuint height, const std::string& title) { _window = glfwCreateWindow(width, height, title.c_str(), nullptr, nullptr); if (_window) { _isOpen = true; _size = glm::uvec2(width, height); _title = title; glfwMakeContextCurrent(_window); return true; } else { return false; } } void Window::close(void) { if (_window) { glfwDestroyWindow(_window); _isOpen = false; } } void Window::draw(Drawable& entity) { entity.draw(); } void Window::draw(Sprite& sprite) { sprite.draw(); } void Window::pollEvents(void) { glfwPollEvents(); } void Window::swapBuffers(void) { glfwSwapBuffers(_window); } void Window::setClearColour(float red, float green, float blue, float alpha) { glClearColor(red, green, blue, alpha); } void Window::setClearColour(Colour colour) { glClearColor ( colour.components.red, colour.components.green, colour.components.blue, colour.components.alpha ); } GLFWwindow* Window::getRawWindow(void) const { return _window; } bool Window::isOpen(void) const { return !glfwWindowShouldClose(_window); }
[ "deltaplaythroughs65@gmail.com" ]
deltaplaythroughs65@gmail.com
73ae2a552477953a17a76ab789377ce656089fb7
77f0d87779f5ef0b9902cf1884c8140f580d01cf
/Searching & Sorting/MergeSort.cpp
af6bb267d8f62083361c786b97560ff295741f33
[]
no_license
Projects-stack/100DaysOfCoding
c590d274698f427c43086ec48dc03d3816df0a0e
bbb747113eeec458eed2c56f9fae372c46bc14b7
refs/heads/master
2023-06-09T21:51:53.394757
2021-07-03T16:41:07
2021-07-03T16:41:07
368,577,741
0
0
null
null
null
null
UTF-8
C++
false
false
1,959
cpp
#include<iostream> using namespace std; // Merge Sort : /* Merge Sort is one of the most popular sorting algorithms that is based on the principle of Divide & Conquer stratergy */ //swap the content of a and b void swapping(int &a, int &b) { int temp; temp = a; a = b; b = temp; } // Merge two sub-arrays L and M into arr // First sub-array is arr[begin..mid] // Second sub-array is arr[mid+1..end] void merge(int *array, int l, int m, int r) { int i, j, k, nl, nr; //size of left and right sub-arrays nl = m-l+1; nr = r-m; int larr[nl], rarr[nr]; //fill left and right sub-arrays for(i = 0; i<nl; i++) larr[i] = array[l+i]; for(j = 0; j<nr; j++) rarr[j] = array[m+1+j]; i = 0; j = 0; k = l; //marge temp arrays to real array while(i < nl && j<nr) { if(larr[i] <= rarr[j]) { array[k] = larr[i]; i++; }else{ array[k] = rarr[j]; j++; } k++; } while(i<nl) { //extra element in left array array[k] = larr[i]; i++; k++; } while(j<nr) { //extra element in right array array[k] = rarr[j]; j++; k++; } } void mergeSort(int *array, int l, int r) { int m; if(l < r) { int m = l+(r-l)/2; // Sort first and second arrays mergeSort(array, l, m); mergeSort(array, m+1, r); merge(array, l, m, r); } } void display(int *array, int size) { for(int i = 0; i<size; i++) cout << array[i] << " "; cout << endl; } int main() { int n; cout << "Enter the number of elements: "; cin >> n; int arr[n]; //create an array with given number of elements cout << "Enter elements:" << endl; for(int i = 0; i<n; i++) { cin >> arr[i]; } cout << "Array before Sorting: "; display(arr, n); mergeSort(arr, 0, n-1); //(n-1) for last index cout << "Array after Sorting: "; display(arr, n); return 0; }
[ "sanket.mhetre@techprimelab.com" ]
sanket.mhetre@techprimelab.com
2eceba09e5ca9571704e7499ee3d953ff4b52e03
2b45998c5472e30ea7058603bca3a77700b86b70
/10468번 숫자뽑기게임.cpp
fe2946804ad993a4dc9ac8e2149773495df9501f
[]
no_license
forybm/CodeMountain
c6b5e404bc5947f2a41df76331bb1ba078dcbe41
7a3c8bc76db7f57ad68638f800513d0ea0a7c5a2
refs/heads/master
2021-06-21T15:05:30.653346
2017-07-27T06:03:55
2017-07-27T06:03:55
98,499,311
0
0
null
null
null
null
UTF-8
C++
false
false
194
cpp
#include <stdio.h> #include <algorithm> using namespace std; int N; int arr[222]; int main() { while (N) { scanf("%d",&N); for (int i = 1;i <= N;i++) { scanf("%d", &arr[i]); } } }
[ "forybm1@naver.com" ]
forybm1@naver.com
2a21cc04d0c6546bfb94dbef11ec57785cd6fcdc
cfeac52f970e8901871bd02d9acb7de66b9fb6b4
/generated/src/aws-cpp-sdk-budgets/source/model/DescribeBudgetActionsForAccountRequest.cpp
6596e471ba4324f5ff601738923c073d8d8f03c2
[ "Apache-2.0", "MIT", "JSON" ]
permissive
aws/aws-sdk-cpp
aff116ddf9ca2b41e45c47dba1c2b7754935c585
9a7606a6c98e13c759032c2e920c7c64a6a35264
refs/heads/main
2023-08-25T11:16:55.982089
2023-08-24T18:14:53
2023-08-24T18:14:53
35,440,404
1,681
1,133
Apache-2.0
2023-09-12T15:59:33
2015-05-11T17:57:32
null
UTF-8
C++
false
false
1,282
cpp
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/budgets/model/DescribeBudgetActionsForAccountRequest.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::Budgets::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; DescribeBudgetActionsForAccountRequest::DescribeBudgetActionsForAccountRequest() : m_accountIdHasBeenSet(false), m_maxResults(0), m_maxResultsHasBeenSet(false), m_nextTokenHasBeenSet(false) { } Aws::String DescribeBudgetActionsForAccountRequest::SerializePayload() const { JsonValue payload; if(m_accountIdHasBeenSet) { payload.WithString("AccountId", m_accountId); } if(m_maxResultsHasBeenSet) { payload.WithInteger("MaxResults", m_maxResults); } if(m_nextTokenHasBeenSet) { payload.WithString("NextToken", m_nextToken); } return payload.View().WriteReadable(); } Aws::Http::HeaderValueCollection DescribeBudgetActionsForAccountRequest::GetRequestSpecificHeaders() const { Aws::Http::HeaderValueCollection headers; headers.insert(Aws::Http::HeaderValuePair("X-Amz-Target", "AWSBudgetServiceGateway.DescribeBudgetActionsForAccount")); return headers; }
[ "sdavtaker@users.noreply.github.com" ]
sdavtaker@users.noreply.github.com
2fa9abfb8104ebb4e07ce4b0152d9e5ed92e4ac3
89ae869293632359fd16ab150019fc05827eb335
/accompany_human_tracker/src/DataAssociation.h
64bcc199345fe0c71d396cd60e3c5135d2e0a7ec
[]
no_license
ipa320/accompany
f4546b6cc848d580f815f59d47cb09c43a8f5b2a
ac62484b035a0f9ebce888e840c27beaca038f13
refs/heads/master
2021-05-02T05:51:24.052693
2017-07-31T12:15:07
2017-07-31T12:15:07
3,283,388
0
1
null
2017-07-31T12:19:31
2012-01-27T15:05:55
Python
UTF-8
C++
false
false
654
h
#ifndef DataAssociation_INCLUDED #define DataAssociation_INCLUDED #include <vector> #include <iostream> /** * Associate detections with tracks */ class DataAssociation { public: DataAssociation(); void clear(unsigned s1,unsigned s2); void set(unsigned d1,unsigned d2,double association); std::vector<int> associate(double threshold,int order=1); friend std::ostream& operator<<(std::ostream& out,const DataAssociation& dataAssociation); private: std::vector<std::vector<double> > associations; unsigned size1,size2; std::vector<int> assign1,assign2; std::pair<int,int> getMax(double threshold,int order); }; #endif
[ "B.Terwijn@uva.nl" ]
B.Terwijn@uva.nl
cda9f96e0db8eee98bdeebd74cfbd716c0f5ce3f
9ab6ea1e33723827c192f0ce8e17e18f28a38254
/process.h
3798c9840c5f339980aa01f12d688b384f82633a
[]
no_license
truelentyay/Calculator
3bfa80b7bbc544d9d2fd59164cf93da76f2fe76a
6ba1d229471b6da015b1783280968e38987eb89d
refs/heads/master
2021-01-17T17:24:26.674406
2016-06-22T12:37:47
2016-06-22T12:37:47
62,325,409
0
0
null
null
null
null
UTF-8
C++
false
false
116
h
#ifndef PROCESS_H #define PROCESS_H class Process { public: Process(); int run(); }; #endif // PROCESS_H
[ "elenami@cqg.com" ]
elenami@cqg.com
0e1e8179fa250e1142ddaa71252c6150bac17871
5e80d390ab8d6df33378a76c6403e93b610c4e74
/compiler/src/parser/tx_scanner_adapter.cpp
9d9ba451630193bd89ee3e3b8566efa29938431f
[ "Apache-2.0" ]
permissive
TuplexLanguage/tuplex
0cb45590b0f2fe000ec87ec0c8eddb2dd984afe6
fc436c78224522663e40e09d36f83570fd76ba2d
refs/heads/master
2021-08-17T11:41:36.107974
2021-01-17T20:28:15
2021-01-17T20:28:15
29,855,523
17
1
Apache-2.0
2020-11-24T19:32:36
2015-01-26T10:08:07
C++
UTF-8
C++
false
false
4,096
cpp
// an adapter between Bison parser and Tx scanner #include "tx_options.hpp" #include "bison_parser.hpp" #include "driver.hpp" #include "txparser/scanner.hpp" static TxToken inner_yylex( yy::TxParser::semantic_type* yylval, yy::TxParser::location_type* yylloc, TxParserContext* parserCtx ) { // TODO: Make reentrant static TxTokenId lastTokenId = TxTokenId::END; static uint32_t lastTokenLine = 0; do { yylloc->step(); ASSERT( yylloc->begin.line == parserCtx->scanCtx->current_cursor().line, "Mismatching lines: " << yylloc->begin.line << " != " << parserCtx->scanCtx->current_cursor().line ); ASSERT( yylloc->begin.column == parserCtx->scanCtx->current_cursor().column, "Mismatching columns: " << yylloc->begin.column << " != " << parserCtx->scanCtx->current_cursor().column ); auto& token = parserCtx->scanCtx->next_token(); switch ( token.id ) { // translate / filter certain tokens case TxTokenId::WHITESPACE: yylloc->columns( token.getSourceText().length()); break; case TxTokenId::COMMENT: if ( token.end.line > token.begin.line ) { yylloc->lines( token.end.line - token.begin.line ); if ( token.end.column > 1 ) yylloc->columns( token.end.column - 1 ); } else yylloc->columns( token.getSourceText().length()); break; case TxTokenId::NEWLINE: yylloc->lines( token.getSourceText().length()); // NEWLINE, INDENT, and DEDENT represent significant whitespace tokens. // These tokens are only passed on if: // not in a paren / bracket / brace block // not on the same line as certain other non-whitespace tokens if ( parserCtx->scanCtx->scopeStack.back().closingToken != TxTokenId::RPAREN && parserCtx->scanCtx->scopeStack.back().closingToken != TxTokenId::RBRACKET && parserCtx->scanCtx->scopeStack.back().closingToken != TxTokenId::RBRACE ) { if ( lastTokenLine == token.begin.line ) { switch ( lastTokenId ) { case TxTokenId::COMMA: case TxTokenId::SEMICOLON: break; default: lastTokenId = token.id; // NEWLINE return token; } } } break; default: // non-empty token yylloc->columns( token.getSourceText().length()); yylval->emplace<std::string>( token.getSourceText()); lastTokenId = token.id; lastTokenLine = token.end.line; return token; } } while ( true ); } yy::TxParser::token_type yylex( yy::TxParser::semantic_type* yylval, yy::TxParser::location_type* yylloc, TxParserContext* parserCtx ) { auto token = inner_yylex( yylval, yylloc, parserCtx ); if ( parserCtx->driver().get_options().debug_scanner && parserCtx->is_user_source() ) { std::cerr << "Returned token: " << token.str().c_str() << std::endl; switch ( token.id ) { case TxTokenId::LBRACE: case TxTokenId::LBRACKET: case TxTokenId::LPAREN: case TxTokenId::RBRACE: case TxTokenId::RBRACKET: case TxTokenId::RPAREN: std::cerr << parserCtx->scanCtx->indent_str() << token.getSourceText() << std::endl; break; case TxTokenId::INDENT: case TxTokenId::DEDENT: std::cerr << parserCtx->scanCtx->indent_str() << "|" << std::endl; break; default: break; } } return token.id; }
[ "christer@chervil.se" ]
christer@chervil.se
53002a8892b6d90ca1538fe711e25bf2d780b616
f7bcf8ad90fd9705897561a8264086d897ba54db
/Executable/WorkloadProcessor.cpp
8811f1898ba07f92849d3c8a1bab465073d13e86
[]
no_license
DevVault/DayZServicePipeline
1570f848b803f67ab41ba84efb849e95f44999fc
bb565eea6de35b1079caddbe5c29cb27f0bc9e4f
refs/heads/master
2023-03-17T03:52:14.749104
2018-09-11T09:37:21
2018-09-11T09:37:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,283
cpp
/**********************************************************************************************************************\ DESCRIPTION: Process workloads and load the dynamic libraries if needed ------------------------------------------------------------------------------------------------------------------------ CREATION DATE: 05.09.2018 ------------------------------------------------------------------------------------------------------------------------ Copyright © 2018 Paul L. (Arkensor) All rights reserved! \**********************************************************************************************************************/ #include "WorkloadProcessor.hpp" #include <iostream> #include <filesystem> typedef void( __stdcall *DayZServiceCall ) ( char *output, int outputSize, const char *data ); typedef void( __stdcall *DayZServiceVersion )( char *output, int outputSize ); typedef void( __stdcall *RVExtension ) ( char *output, int outputSize, const char *function ); typedef void( __stdcall *RVExtensionVersion )( char *output, int outputSize ); typedef int( __stdcall *RVExtensionArgs ) ( char *output, int outputSize, const char *function, const char **args, int argCnt ); WorkloadProcessor::WorkloadProcessor( std::filesystem::path& libDir ) : m_poLoader( new LibraryLoader( libDir ) ) { } WorkloadProcessor::~WorkloadProcessor() { } void WorkloadProcessor::Process( Workload *oWorkload ) { // std::cout << "m_strServiceName:" << oWorkload->m_strServiceName << std::endl; // std::cout << "m_strFunctionName:" << oWorkload->m_strFunctionName << std::endl; // // for ( auto & m_oFunctionArgument : oWorkload->m_oFunctionArguments ) // std::cout << "m_oFunctionArgument: " << m_oFunctionArgument << std::endl; if( oWorkload->m_strFunctionName == "DayZServiceInterface" ) { auto func = reinterpret_cast< DayZServiceCall >( GetServiceFunction( oWorkload->m_strServiceName, "DayZServiceCall" ) ); if( func ) { const int bufferSize = 100 * 1024; //Output data size char buffer[ bufferSize ] = { 0 }; func( buffer, bufferSize, oWorkload->m_oFunctionArguments.front().c_str() ); std::string result( buffer ); std::cout << "Input: " << oWorkload->m_oFunctionArguments.front() << " - Result: " << result << std::endl; oWorkload->m_strResult = result; } } else { //Todo handle RVExtensions } } void *WorkloadProcessor::GetServiceInstance( std::string strServiceName ) { //Do we have the service loaded? if( m_oLoadedServices.find( strServiceName ) == std::end( m_oLoadedServices ) ) { auto pointer = m_poLoader->LoadDynamicLibrary( strServiceName ); m_oLoadedServices[ strServiceName ] = pointer; //First time calling the service -> give feedback to the user that it has been loaded auto func = reinterpret_cast< DayZServiceVersion >( GetServiceFunction( strServiceName, "DayZServiceVersion" ) ); if( func ) { const int bufferSize = 512; //Output data size char buffer[ bufferSize ] = { 0 }; func( buffer, bufferSize ); std::string result( buffer ); std::cout << "[INFO] Service '" << strServiceName << "' version " << result << " loaded." << std::endl; } } return m_oLoadedServices[ strServiceName ]; } void* WorkloadProcessor::GetServiceFunction( std::string& strServiceName, const char *strFunctionName ) { bool bLoaded = true; //Do we have the service loaded? if( m_oLoadedServiceFunctions.find( strServiceName ) == std::end( m_oLoadedServiceFunctions ) ) { bLoaded = false; } else { //Do we have the function loaded? if( m_oLoadedServiceFunctions[ strServiceName ].find( strFunctionName ) == std::end( m_oLoadedServiceFunctions[ strServiceName ] ) ) { bLoaded = false; } } if( !bLoaded ) { m_oLoadedServiceFunctions[ strServiceName ][ strFunctionName ] = m_poLoader->GetFunctionPointer( GetServiceInstance( strServiceName ), strFunctionName ); } return m_oLoadedServiceFunctions[ strServiceName ][ strFunctionName ]; }
[ "arkensor@gmail.com" ]
arkensor@gmail.com
3c0e1a4f6162e5c2b605a9aec4af0fffcc7415d6
bb6ebff7a7f6140903d37905c350954ff6599091
/ui/views/controls/resize_area.h
12ec310026e3218fb67a1a0ec9020199863a9282
[ "BSD-3-Clause" ]
permissive
PDi-Communication-Systems-Inc/lollipop_external_chromium_org
faa6602bd6bfd9b9b6277ce3cd16df0bd26e7f2f
ccadf4e63dd34be157281f53fe213d09a8c66d2c
refs/heads/master
2022-12-23T18:07:04.568931
2016-04-11T16:03:36
2016-04-11T16:03:36
53,677,925
0
1
BSD-3-Clause
2022-12-09T23:46:46
2016-03-11T15:49:07
C++
UTF-8
C++
false
false
1,682
h
// Copyright (c) 2011 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 UI_VIEWS_CONTROLS_RESIZE_AREA_H_ #define UI_VIEWS_CONTROLS_RESIZE_AREA_H_ #include <string> #include "ui/views/view.h" namespace views { class ResizeAreaDelegate; //////////////////////////////////////////////////////////////////////////////// // // An invisible area that acts like a horizontal resizer. // //////////////////////////////////////////////////////////////////////////////// class VIEWS_EXPORT ResizeArea : public View { public: static const char kViewClassName[]; explicit ResizeArea(ResizeAreaDelegate* delegate); virtual ~ResizeArea(); // Overridden from views::View: virtual const char* GetClassName() const OVERRIDE; virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) OVERRIDE; virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; virtual void OnMouseCaptureLost() OVERRIDE; virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; private: // Report the amount the user resized by to the delegate, accounting for // directionality. void ReportResizeAmount(int resize_amount, bool last_update); // The delegate to notify when we have updates. ResizeAreaDelegate* delegate_; // The mouse position at start (in screen coordinates). int initial_position_; DISALLOW_COPY_AND_ASSIGN(ResizeArea); }; } // namespace views #endif // UI_VIEWS_CONTROLS_RESIZE_AREA_H_
[ "mrobbeloth@pdiarm.com" ]
mrobbeloth@pdiarm.com
7293a4228cb60e5dbb4e541204bd30580bb92456
8567438779e6af0754620a25d379c348e4cd5a5d
/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
1a1b9ffd8818de1d596c9996a0a26f6f746aab2c
[ "BSD-3-Clause" ]
permissive
thngkaiyuan/chromium
c389ac4b50ccba28ee077cbf6115c41b547955ae
dab56a4a71f87f64ecc0044e97b4a8f247787a68
refs/heads/master
2022-11-10T02:50:29.326119
2017-04-08T12:28:57
2017-04-08T12:28:57
84,073,924
0
1
BSD-3-Clause
2022-10-25T19:47:15
2017-03-06T13:04:15
null
UTF-8
C++
false
false
62,621
cc
// 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. #include <stddef.h> #include "base/command_line.h" #include "base/files/file_util.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/strings/string16.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/test/scoped_feature_list.h" #include "build/build_config.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/find_bar/find_bar.h" #include "chrome/browser/ui/find_bar/find_bar_controller.h" #include "chrome/browser/ui/find_bar/find_bar_host_unittest_util.h" #include "chrome/browser/ui/find_bar/find_notification_details.h" #include "chrome/browser/ui/find_bar/find_tab_helper.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/webui/md_history_ui.h" #include "chrome/common/chrome_features.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/find_in_page_observer.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "components/history/core/browser/history_service.h" #include "components/prefs/pref_service.h" #include "content/public/browser/download_manager.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/test/browser_test_utils.h" #include "net/base/filename_util.h" #include "ui/base/accelerators/accelerator.h" #include "ui/events/keycodes/keyboard_codes.h" #if defined(OS_WIN) #include "ui/aura/window.h" #include "ui/aura/window_tree_host.h" #endif using base::ASCIIToUTF16; using base::WideToUTF16; using content::NavigationController; using content::WebContents; namespace { const char kAnchorPage[] = "anchor.html"; const char kAnchor[] = "#chapter2"; const char kFramePage[] = "frames.html"; const char kFrameData[] = "framedata_general.html"; const char kUserSelectPage[] = "user-select.html"; const char kCrashPage[] = "crash_1341577.html"; const char kTooFewMatchesPage[] = "bug_1155639.html"; const char kLongTextareaPage[] = "large_textarea.html"; const char kPrematureEnd[] = "premature_end.html"; const char kMoveIfOver[] = "move_if_obscuring.html"; const char kBitstackCrash[] = "crash_14491.html"; const char kSelectChangesOrdinal[] = "select_changes_ordinal.html"; const char kStartAfterSelection[] = "start_after_selection.html"; const char kSimple[] = "simple.html"; const char kLinkPage[] = "link.html"; const bool kBack = false; const bool kFwd = true; const bool kIgnoreCase = false; const bool kCaseSensitive = true; const int kMoveIterations = 30; } // namespace class FindInPageControllerTest : public InProcessBrowserTest { public: FindInPageControllerTest() { chrome::DisableFindBarAnimationsDuringTesting(true); } protected: bool GetFindBarWindowInfoForBrowser( Browser* browser, gfx::Point* position, bool* fully_visible) { FindBarTesting* find_bar = browser->GetFindBarController()->find_bar()->GetFindBarTesting(); return find_bar->GetFindBarWindowInfo(position, fully_visible); } bool GetFindBarWindowInfo(gfx::Point* position, bool* fully_visible) { return GetFindBarWindowInfoForBrowser(browser(), position, fully_visible); } base::string16 GetFindBarTextForBrowser(Browser* browser) { FindBar* find_bar = browser->GetFindBarController()->find_bar(); return find_bar->GetFindText(); } base::string16 GetFindBarText() { return GetFindBarTextForBrowser(browser()); } base::string16 GetFindBarMatchCountTextForBrowser(Browser* browser) { FindBarTesting* find_bar = browser->GetFindBarController()->find_bar()->GetFindBarTesting(); return find_bar->GetMatchCountText(); } base::string16 GetMatchCountText() { return GetFindBarMatchCountTextForBrowser(browser()); } int GetFindBarWidthForBrowser(Browser* browser) { FindBarTesting* find_bar = browser->GetFindBarController()->find_bar()->GetFindBarTesting(); return find_bar->GetWidth(); } void EnsureFindBoxOpenForBrowser(Browser* browser) { chrome::ShowFindBar(browser); gfx::Point position; bool fully_visible = false; EXPECT_TRUE(GetFindBarWindowInfoForBrowser( browser, &position, &fully_visible)); EXPECT_TRUE(fully_visible); } void EnsureFindBoxOpen() { EnsureFindBoxOpenForBrowser(browser()); } int FindInPage16(WebContents* web_contents, const base::string16& search_str, bool forward, bool case_sensitive, int* ordinal) { Browser* browser = chrome::FindBrowserWithWebContents(web_contents); browser->GetFindBarController()->find_bar()->SetFindTextAndSelectedRange( search_str, gfx::Range()); return ui_test_utils::FindInPage( web_contents, search_str, forward, case_sensitive, ordinal, NULL); } int FindInPageASCII(WebContents* web_contents, const std::string& search_str, bool forward, bool case_sensitive, int* ordinal) { return FindInPage16(web_contents, ASCIIToUTF16(search_str), forward, case_sensitive, ordinal); } // Calls FindInPageASCII till the find box's x position != |start_x_position|. // Return |start_x_position| if the find box has not moved after iterating // through all matches of |search_str|. int FindInPageTillBoxMoves(WebContents* web_contents, int start_x_position, const std::string& search_str, int expected_matches) { // Search for |search_str| which the Find box is obscuring. for (int index = 0; index < expected_matches; ++index) { int ordinal = 0; EXPECT_EQ(expected_matches, FindInPageASCII(web_contents, search_str, kFwd, kIgnoreCase, &ordinal)); // Check the position. bool fully_visible; gfx::Point position; EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); EXPECT_TRUE(fully_visible); // If the Find box has moved then we are done. if (position.x() != start_x_position) return position.x(); } return start_x_position; } GURL GetURL(const std::string& filename) { return ui_test_utils::GetTestUrl( base::FilePath().AppendASCII("find_in_page"), base::FilePath().AppendASCII(filename)); } void FlushHistoryService() { HistoryServiceFactory::GetForProfile(browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) ->FlushForTest(base::Bind( &base::MessageLoop::QuitWhenIdle, base::Unretained(base::MessageLoop::current()->current()))); content::RunMessageLoop(); } }; // This test loads a page with frames and starts FindInPage requests. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageFrames) { // First we navigate to our frames page. GURL url = GetURL(kFramePage); ui_test_utils::NavigateToURL(browser(), url); // Try incremental search (mimicking user typing in). int ordinal = 0; WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(18, FindInPageASCII(web_contents, "g", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); EXPECT_EQ(11, FindInPageASCII(web_contents, "go", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); EXPECT_EQ(4, FindInPageASCII(web_contents, "goo", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); EXPECT_EQ(3, FindInPageASCII(web_contents, "goog", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); EXPECT_EQ(2, FindInPageASCII(web_contents, "googl", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); EXPECT_EQ(1, FindInPageASCII(web_contents, "google", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); EXPECT_EQ(0, FindInPageASCII(web_contents, "google!", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(0, ordinal); // Negative test (no matches should be found). EXPECT_EQ(0, FindInPageASCII(web_contents, "Non-existing string", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(0, ordinal); // 'horse' only exists in the three right frames. EXPECT_EQ(3, FindInPageASCII(web_contents, "horse", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); // 'cat' only exists in the first frame. EXPECT_EQ(1, FindInPageASCII(web_contents, "cat", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); // Try searching again, should still come up with 1 match. EXPECT_EQ(1, FindInPageASCII(web_contents, "cat", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); // Try searching backwards, ignoring case, should still come up with 1 match. EXPECT_EQ(1, FindInPageASCII(web_contents, "CAT", kBack, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); // Try case sensitive, should NOT find it. EXPECT_EQ(0, FindInPageASCII(web_contents, "CAT", kFwd, kCaseSensitive, &ordinal)); EXPECT_EQ(0, ordinal); // Try again case sensitive, but this time with right case. EXPECT_EQ(1, FindInPageASCII(web_contents, "dog", kFwd, kCaseSensitive, &ordinal)); EXPECT_EQ(1, ordinal); // Try non-Latin characters ('Hreggvidur' with 'eth' for 'd' in left frame). EXPECT_EQ(1, FindInPage16(web_contents, WideToUTF16(L"Hreggvi\u00F0ur"), kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); EXPECT_EQ(1, FindInPage16(web_contents, WideToUTF16(L"Hreggvi\u00F0ur"), kFwd, kCaseSensitive, &ordinal)); EXPECT_EQ(1, ordinal); EXPECT_EQ(0, FindInPage16(web_contents, WideToUTF16(L"hreggvi\u00F0ur"), kFwd, kCaseSensitive, &ordinal)); EXPECT_EQ(0, ordinal); } // Verify search for text within various forms and text areas. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageFormsTextAreas) { std::vector<GURL> urls; urls.push_back(GetURL("textintextarea.html")); urls.push_back(GetURL("smalltextarea.html")); urls.push_back(GetURL("populatedform.html")); WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); for (size_t i = 0; i < urls.size(); ++i) { ui_test_utils::NavigateToURL(browser(), urls[i]); EXPECT_EQ(1, FindInPageASCII(web_contents, "cat", kFwd, kIgnoreCase, NULL)); EXPECT_EQ(0, FindInPageASCII(web_contents, "bat", kFwd, kIgnoreCase, NULL)); } } // Verify search for text within special URLs such as chrome:history, // chrome://downloads, data directory #if defined(OS_MACOSX) || defined(OS_WIN) // Disabled on Mac due to http://crbug.com/419987 // Disabled on Win due to http://crbug.com/661013 #define MAYBE_SearchWithinSpecialURL \ DISABLED_SearchWithinSpecialURL #else #define MAYBE_SearchWithinSpecialURL \ SearchWithinSpecialURL #endif IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_SearchWithinSpecialURL) { // TODO(tsergeant): Get this test working on MD History, which loads very // asynchronously and causes this test to fail. base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitAndDisableFeature(features::kMaterialDesignHistory); WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); base::FilePath data_dir = ui_test_utils::GetTestFilePath(base::FilePath(), base::FilePath()); ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(data_dir)); EXPECT_EQ(1, FindInPageASCII(web_contents, "downloads", kFwd, kIgnoreCase, NULL)); ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL)); // The history page does an async request to the history service and then // updates the renderer. So we make a query as well, and by the time it comes // back we know the data is on its way to the renderer. FlushHistoryService(); base::string16 query(data_dir.LossyDisplayName()); EXPECT_EQ(1, ui_test_utils::FindInPage(web_contents, query, kFwd, kIgnoreCase, NULL, NULL)); GURL download_url = ui_test_utils::GetTestUrl( base::FilePath().AppendASCII("downloads"), base::FilePath().AppendASCII("a_zip_file.zip")); ui_test_utils::DownloadURL(browser(), download_url); ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL)); FlushHistoryService(); ASSERT_TRUE(content::ExecuteScript(web_contents, "Polymer.dom.flush();")); EXPECT_EQ(1, FindInPageASCII(web_contents, download_url.spec(), kFwd, kIgnoreCase, NULL)); } // Verify search selection coordinates. The data file used is set-up such that // the text occurs on the same line, and we verify their positions by verifying // their relative positions. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageSpecialURLs) { const std::wstring search_string(L"\u5728\u897f\u660c\u536b\u661f\u53d1"); gfx::Rect first, second, first_reverse; WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); ui_test_utils::NavigateToURL(browser(), GetURL("specialchar.html")); ui_test_utils::FindInPage(web_contents, WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, &first); ui_test_utils::FindInPage(web_contents, WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, &second); // We have search occurrence in the same row, so top-bottom coordinates should // be the same even for second search. ASSERT_EQ(first.y(), second.y()); ASSERT_EQ(first.bottom(), second.bottom()); ASSERT_LT(first.x(), second.x()); ASSERT_LT(first.right(), second.right()); ui_test_utils::FindInPage( web_contents, WideToUTF16(search_string), kBack, kIgnoreCase, NULL, &first_reverse); // We find next and we go back so find coordinates should be the same as // previous ones. ASSERT_EQ(first, first_reverse); } // Verifies that comments and meta data are not searchable. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, CommentsAndMetaDataNotSearchable) { WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); ui_test_utils::NavigateToURL(browser(), GetURL("specialchar.html")); const std::wstring search_string = L"\u4e2d\u65b0\u793e\u8bb0\u8005\u5b8b\u5409\u6cb3\u6444\u4e2d\u65b0\u7f51"; EXPECT_EQ(0, ui_test_utils::FindInPage( web_contents, WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, NULL)); } // Verifies that span and lists are searchable. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, SpanAndListsSearchable) { WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); ui_test_utils::NavigateToURL(browser(), GetURL("FindRandomTests.html")); std::string search_string = "has light blue eyes and my father has dark"; EXPECT_EQ(1, ui_test_utils::FindInPage(web_contents, ASCIIToUTF16(search_string), kFwd, kIgnoreCase, NULL, NULL)); search_string = "Google\nApple\nandroid"; EXPECT_EQ(1, ui_test_utils::FindInPage(web_contents, ASCIIToUTF16(search_string), kFwd, kIgnoreCase, NULL, NULL)); } #if defined(OS_WIN) #define MAYBE_LargePage DISABLED_LargePage #else #define MAYBE_LargePage LargePage #endif // Find in a very large page. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_LargePage) { WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); ui_test_utils::NavigateToURL(browser(), GetURL("largepage.html")); EXPECT_EQ(373, FindInPageASCII(web_contents, "daughter of Prince", kFwd, kIgnoreCase, NULL)); } // Find a very long string in a large page. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindLongString) { WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); ui_test_utils::NavigateToURL(browser(), GetURL("largepage.html")); base::FilePath path = ui_test_utils::GetTestFilePath( base::FilePath().AppendASCII("find_in_page"), base::FilePath().AppendASCII("LongFind.txt")); std::string query; base::ReadFileToString(path, &query); EXPECT_EQ(1, FindInPage16(web_contents, base::UTF8ToUTF16(query), kFwd, kIgnoreCase, NULL)); } // Find a big font string in a page. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, BigString) { WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); ui_test_utils::NavigateToURL(browser(), GetURL("BigText.html")); EXPECT_EQ(1, FindInPageASCII(web_contents, "SomeLargeString", kFwd, kIgnoreCase, NULL)); } // http://crbug.com/369169 #if defined(OS_CHROMEOS) #define MAYBE_SingleOccurrence DISABLED_SingleOccurrence #else #define MAYBE_SingleOccurrence SingleOccurrence #endif // Search Back and Forward on a single occurrence. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_SingleOccurrence) { WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); ui_test_utils::NavigateToURL(browser(), GetURL("FindRandomTests.html")); gfx::Rect first_rect; EXPECT_EQ(1, ui_test_utils::FindInPage(web_contents, ASCIIToUTF16("2010 Pro Bowl"), kFwd, kIgnoreCase, NULL, &first_rect)); gfx::Rect second_rect; EXPECT_EQ(1, ui_test_utils::FindInPage(web_contents, ASCIIToUTF16("2010 Pro Bowl"), kFwd, kIgnoreCase, NULL, &second_rect)); // Doing a fake find so we have no previous search. ui_test_utils::FindInPage(web_contents, ASCIIToUTF16("ghgfjgfh201232rere"), kFwd, kIgnoreCase, NULL, NULL); ASSERT_EQ(first_rect, second_rect); EXPECT_EQ(1, ui_test_utils::FindInPage(web_contents, ASCIIToUTF16("2010 Pro Bowl"), kFwd, kIgnoreCase, NULL, &first_rect)); EXPECT_EQ(1, ui_test_utils::FindInPage(web_contents, ASCIIToUTF16("2010 Pro Bowl"), kBack, kIgnoreCase, NULL, &second_rect)); ASSERT_EQ(first_rect, second_rect); } // Find the whole text file page and find count should be 1. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindWholeFileContent) { WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); base::FilePath path = ui_test_utils::GetTestFilePath( base::FilePath().AppendASCII("find_in_page"), base::FilePath().AppendASCII("find_test.txt")); ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(path)); std::string query; base::ReadFileToString(path, &query); EXPECT_EQ(1, FindInPage16(web_contents, base::UTF8ToUTF16(query), false, false, NULL)); } // This test loads a single-frame page and makes sure the ordinal returned makes // sense as we FindNext over all the items. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageOrdinal) { // First we navigate to our page. GURL url = GetURL(kFrameData); ui_test_utils::NavigateToURL(browser(), url); // Search for 'o', which should make the first item active and return // '1 in 3' (1st ordinal of a total of 3 matches). WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); int ordinal = 0; EXPECT_EQ(3, FindInPageASCII(web_contents, "o", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); EXPECT_EQ(3, FindInPageASCII(web_contents, "o", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(2, ordinal); EXPECT_EQ(3, FindInPageASCII(web_contents, "o", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(3, ordinal); // Go back one match. EXPECT_EQ(3, FindInPageASCII(web_contents, "o", kBack, kIgnoreCase, &ordinal)); EXPECT_EQ(2, ordinal); EXPECT_EQ(3, FindInPageASCII(web_contents, "o", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(3, ordinal); // This should wrap to the top. EXPECT_EQ(3, FindInPageASCII(web_contents, "o", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); // This should go back to the end. EXPECT_EQ(3, FindInPageASCII(web_contents, "o", kBack, kIgnoreCase, &ordinal)); EXPECT_EQ(3, ordinal); } // This tests that the ordinal is correctly adjusted after a selection IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, SelectChangesOrdinal_Issue20883) { // First we navigate to our test content. GURL url = GetURL(kSelectChangesOrdinal); ui_test_utils::NavigateToURL(browser(), url); // Search for a text that exists within a link on the page. WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(NULL != web_contents); FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(web_contents); int ordinal = 0; EXPECT_EQ(4, FindInPageASCII(web_contents, "google", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); // Move the selection to link 1, after searching. std::string result; ASSERT_TRUE(content::ExecuteScriptAndExtractString( web_contents, "window.domAutomationController.send(selectLink1());", &result)); // Do a find-next after the selection. This should move forward // from there to the 3rd instance of 'google'. EXPECT_EQ(4, FindInPageASCII(web_contents, "google", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(3, ordinal); // End the find session. find_tab_helper->StopFinding(FindBarController::kKeepSelectionOnPage); } // This tests that we start searching after selected text. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, StartSearchAfterSelection) { // First we navigate to our test content. ui_test_utils::NavigateToURL(browser(), GetURL(kStartAfterSelection)); WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(web_contents != NULL); int ordinal = 0; // Move the selection to the text span. std::string result; ASSERT_TRUE(content::ExecuteScriptAndExtractString( web_contents, "window.domAutomationController.send(selectSpan());", &result)); // Do a find-next after the selection. This should select the 2nd occurrence // of the word 'find'. EXPECT_EQ(4, FindInPageASCII(web_contents, "fi", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(2, ordinal); // Refine the search, current active match should not change. EXPECT_EQ(4, FindInPageASCII(web_contents, "find", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(2, ordinal); // Refine the search to 'findMe'. The first new match is before the current // active match, the second one is after it. This verifies that refining a // search doesn't reset it. EXPECT_EQ(2, FindInPageASCII(web_contents, "findMe", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(2, ordinal); } // This test loads a page with frames and makes sure the ordinal returned makes // sense. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageMultiFramesOrdinal) { // First we navigate to our page. GURL url = GetURL(kFramePage); ui_test_utils::NavigateToURL(browser(), url); // Search for 'a', which should make the first item active and return // '1 in 7' (1st ordinal of a total of 7 matches). WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); int ordinal = 0; EXPECT_EQ(7, FindInPageASCII(web_contents, "a", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); EXPECT_EQ(7, FindInPageASCII(web_contents, "a", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(2, ordinal); EXPECT_EQ(7, FindInPageASCII(web_contents, "a", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(3, ordinal); EXPECT_EQ(7, FindInPageASCII(web_contents, "a", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(4, ordinal); // Go back one, which should go back one frame. EXPECT_EQ(7, FindInPageASCII(web_contents, "a", kBack, kIgnoreCase, &ordinal)); EXPECT_EQ(3, ordinal); EXPECT_EQ(7, FindInPageASCII(web_contents, "a", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(4, ordinal); EXPECT_EQ(7, FindInPageASCII(web_contents, "a", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(5, ordinal); EXPECT_EQ(7, FindInPageASCII(web_contents, "a", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(6, ordinal); EXPECT_EQ(7, FindInPageASCII(web_contents, "a", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(7, ordinal); // Now we should wrap back to frame 1. EXPECT_EQ(7, FindInPageASCII(web_contents, "a", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); // Now we should wrap back to frame last frame. EXPECT_EQ(7, FindInPageASCII(web_contents, "a", kBack, kIgnoreCase, &ordinal)); EXPECT_EQ(7, ordinal); } // We could get ordinals out of whack when restarting search in subframes. // See http://crbug.com/5132. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPage_Issue5132) { // First we navigate to our page. GURL url = GetURL(kFramePage); ui_test_utils::NavigateToURL(browser(), url); // Search for 'goa' three times (6 matches on page). int ordinal = 0; WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(6, FindInPageASCII(web_contents, "goa", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); EXPECT_EQ(6, FindInPageASCII(web_contents, "goa", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(2, ordinal); EXPECT_EQ(6, FindInPageASCII(web_contents, "goa", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(3, ordinal); // Add space to search (should result in no matches). EXPECT_EQ(0, FindInPageASCII(web_contents, "goa ", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(0, ordinal); // Remove the space, should be back to '3 out of 6') EXPECT_EQ(6, FindInPageASCII(web_contents, "goa", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(3, ordinal); } // This tests that the ordinal and match count is cleared after a navigation, // as reported in issue http://crbug.com/126468. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, NavigateClearsOrdinal) { // First we navigate to our test content. GURL url = GetURL(kSimple); ui_test_utils::NavigateToURL(browser(), url); // Open the Find box. In most tests we can just search without opening the // box first, but in this case we are testing functionality triggered by // NOTIFICATION_NAV_ENTRY_COMMITTED in the FindBarController and the observer // for that event isn't setup unless the box is open. EnsureFindBoxOpen(); // Search for a text that exists within a link on the page. WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(NULL != web_contents); int ordinal = 0; EXPECT_EQ(8, FindInPageASCII(web_contents, "e", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); // Then navigate away (to any page). url = GetURL(kLinkPage); ui_test_utils::NavigateToURL(browser(), url); // Open the Find box again. EnsureFindBoxOpen(); EXPECT_EQ(ASCIIToUTF16("e"), GetFindBarText()); EXPECT_TRUE(GetMatchCountText().empty()); } // Load a page with no selectable text and make sure we don't crash. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindUnselectableText) { // First we navigate to our page. GURL url = GetURL(kUserSelectPage); ui_test_utils::NavigateToURL(browser(), url); int ordinal = 0; WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(1, FindInPageASCII(web_contents, "text", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); } // Try to reproduce the crash seen in issue 1341577. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindCrash_Issue1341577) { // First we navigate to our page. GURL url = GetURL(kCrashPage); ui_test_utils::NavigateToURL(browser(), url); // This would crash the tab. These must be the first two find requests issued // against the frame, otherwise an active frame pointer is set and it wont // produce the crash. // We used to check the return value and |ordinal|. With ICU 4.2, FiP does // not find a stand-alone dependent vowel sign of Indic scripts. So, the // exptected values are all 0. To make this test pass regardless of // ICU version, we just call FiP and see if there's any crash. // TODO(jungshik): According to a native Malayalam speaker, it's ok not // to find U+0D4C. Still need to investigate further this issue. int ordinal = 0; WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); const base::string16 search_str = WideToUTF16(L"\u0D4C"); FindInPage16(web_contents, search_str, kFwd, kIgnoreCase, &ordinal); FindInPage16(web_contents, search_str, kFwd, kIgnoreCase, &ordinal); // This should work fine. EXPECT_EQ(1, FindInPage16(web_contents, WideToUTF16(L"\u0D24\u0D46"), kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); EXPECT_EQ(0, FindInPageASCII(web_contents, "nostring", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(0, ordinal); } // Try to reproduce the crash seen in http://crbug.com/14491, where an assert // hits in the BitStack size comparison in WebKit. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindCrash_Issue14491) { // First we navigate to our page. GURL url = GetURL(kBitstackCrash); ui_test_utils::NavigateToURL(browser(), url); // This used to crash the tab. int ordinal = 0; EXPECT_EQ(0, FindInPageASCII(browser()->tab_strip_model()-> GetActiveWebContents(), "s", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(0, ordinal); } // Test to make sure Find does the right thing when restarting from a timeout. // We used to have a problem where we'd stop finding matches when all of the // following conditions were true: // 1) The page has a lot of text to search. // 2) The page contains more than one match. // 3) It takes longer than the time-slice given to each Find operation (100 // ms) to find one or more of those matches (so Find times out and has to try // again from where it left off). IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindRestarts_Issue1155639) { // First we navigate to our page. GURL url = GetURL(kTooFewMatchesPage); ui_test_utils::NavigateToURL(browser(), url); // This string appears 5 times at the bottom of a long page. If Find restarts // properly after a timeout, it will find 5 matches, not just 1. int ordinal = 0; EXPECT_EQ(5, FindInPageASCII(browser()->tab_strip_model()-> GetActiveWebContents(), "008.xml", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); } // Make sure we don't get into an infinite loop when text box contains very // large amount of text. // Disable the test as it started being flaky, see http://crbug/367701. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, DISABLED_FindRestarts_Issue70505) { // First we navigate to our page. GURL url = GetURL(kLongTextareaPage); ui_test_utils::NavigateToURL(browser(), url); // If this test hangs on the FindInPage call, then it might be a regression // such as the one found in issue http://crbug.com/70505. int ordinal = 0; FindInPageASCII(browser()->tab_strip_model()->GetActiveWebContents(), "a", kFwd, kIgnoreCase, &ordinal); EXPECT_EQ(1, ordinal); // TODO(finnur): We cannot reliably get the matchcount for this Find call // until we fix issue http://crbug.com/71176. } // This tests bug 11761: FindInPage terminates search prematurely. // This test is not expected to pass until bug 11761 is fixed. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, DISABLED_FindInPagePrematureEnd) { // First we navigate to our special focus tracking page. GURL url = GetURL(kPrematureEnd); ui_test_utils::NavigateToURL(browser(), url); WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(NULL != web_contents); // Search for a text that exists within a link on the page. int ordinal = 0; EXPECT_EQ(2, FindInPageASCII(web_contents, "html ", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); } // Verify that the find bar is hidden on reload and navigation. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, HideFindBarOnNavigateAndReload) { // First we navigate to our special focus tracking page. GURL url = GetURL(kSimple); GURL url2 = GetURL(kFramePage); ui_test_utils::NavigateToURL(browser(), url); chrome::ShowFindBar(browser()); gfx::Point position; bool fully_visible = false; // Make sure it is open. EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); EXPECT_TRUE(fully_visible); // Reload and make sure the find window goes away. content::WindowedNotificationObserver observer( content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>( &browser()->tab_strip_model()->GetActiveWebContents()-> GetController())); chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); observer.Wait(); EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); EXPECT_FALSE(fully_visible); // Open the find bar again. chrome::ShowFindBar(browser()); // Make sure it is open. EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); EXPECT_TRUE(fully_visible); // Navigate and make sure the find window goes away. ui_test_utils::NavigateToURL(browser(), url2); EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); EXPECT_FALSE(fully_visible); } IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindStayVisibleOnAnchorLoad) { // First we navigate to our special focus tracking page. GURL url = GetURL(kAnchorPage); ui_test_utils::NavigateToURL(browser(), url); chrome::ShowFindBar(browser()); gfx::Point position; bool fully_visible = false; // Make sure it is open. EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); EXPECT_TRUE(fully_visible); // Navigate to the same page (but add an anchor/ref/fragment/whatever the kids // are calling it these days). GURL url_with_anchor = url.Resolve(kAnchor); ui_test_utils::NavigateToURL(browser(), url_with_anchor); // Make sure it is still open. EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); EXPECT_TRUE(fully_visible); } // FindDisappearOnNewTabAndHistory is flaky, at least on Mac. // See http://crbug.com/43072 #if defined(OS_MACOSX) #define MAYBE_FindDisappearOnNewTabAndHistory DISABLED_FindDisappearOnNewTabAndHistory #else #define MAYBE_FindDisappearOnNewTabAndHistory FindDisappearOnNewTabAndHistory #endif // Make sure Find box disappears when History/Downloads page is opened, and // when a New Tab is opened. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_FindDisappearOnNewTabAndHistory) { // First we navigate to our special focus tracking page. GURL url = GetURL(kSimple); ui_test_utils::NavigateToURL(browser(), url); chrome::ShowFindBar(browser()); gfx::Point position; bool fully_visible = false; // Make sure it is open. EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); EXPECT_TRUE(fully_visible); // Open another tab (tab B). chrome::NewTab(browser()); ui_test_utils::NavigateToURL(browser(), url); // Make sure Find box is closed. EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); EXPECT_FALSE(fully_visible); // Close tab B. chrome::CloseTab(browser()); // Make sure Find window appears again. EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); EXPECT_TRUE(fully_visible); chrome::ShowHistory(browser()); // Make sure Find box is closed. EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); EXPECT_FALSE(fully_visible); } // Make sure Find box moves out of the way if it is obscuring the active match. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindMovesWhenObscuring) { GURL url = GetURL(kMoveIfOver); ui_test_utils::NavigateToURL(browser(), url); chrome::ShowFindBar(browser()); // This is needed on GTK because the reposition operation is asynchronous. base::RunLoop().RunUntilIdle(); gfx::Point start_position; gfx::Point position; bool fully_visible = false; int ordinal = 0; // Make sure it is open. EXPECT_TRUE(GetFindBarWindowInfo(&start_position, &fully_visible)); EXPECT_TRUE(fully_visible); WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); int moved_x_coord = FindInPageTillBoxMoves(web_contents, start_position.x(), "Chromium", kMoveIterations); // The find box should have moved. EXPECT_TRUE(moved_x_coord != start_position.x()); // Search for something guaranteed not to be obscured by the Find box. EXPECT_EQ(1, FindInPageASCII(web_contents, "Done", kFwd, kIgnoreCase, &ordinal)); // Check the position. EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); EXPECT_TRUE(fully_visible); // Make sure Find box has moved back to its original location. EXPECT_EQ(position.x(), start_position.x()); // Move the find box again. moved_x_coord = FindInPageTillBoxMoves(web_contents, start_position.x(), "Chromium", kMoveIterations); EXPECT_TRUE(moved_x_coord != start_position.x()); // Search for an invalid string. EXPECT_EQ(0, FindInPageASCII(web_contents, "WeirdSearchString", kFwd, kIgnoreCase, &ordinal)); // Check the position. EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); EXPECT_TRUE(fully_visible); // Make sure Find box has moved back to its original location. EXPECT_EQ(position.x(), start_position.x()); } // FindNextInNewTabUsesPrepopulate times-out on Mac and Aura. // See http://crbug.com/43070 #if defined(OS_MACOSX) || defined(USE_AURA) #define MAYBE_FindNextInNewTabUsesPrepopulate \ DISABLED_FindNextInNewTabUsesPrepopulate #else #define MAYBE_FindNextInNewTabUsesPrepopulate FindNextInNewTabUsesPrepopulate #endif // Make sure F3 in a new tab works if Find has previous string to search for. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_FindNextInNewTabUsesPrepopulate) { // First we navigate to any page. GURL url = GetURL(kSimple); ui_test_utils::NavigateToURL(browser(), url); // Search for 'no_match'. No matches should be found. int ordinal = 0; WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(0, FindInPageASCII(web_contents, "no_match", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(0, ordinal); // Open another tab (tab B). chrome::NewTab(browser()); ui_test_utils::NavigateToURL(browser(), url); // Simulate what happens when you press F3 for FindNext. We should get a // response here (a hang means search was aborted). EXPECT_EQ(0, ui_test_utils::FindInPage(web_contents, base::string16(), kFwd, kIgnoreCase, &ordinal, NULL)); EXPECT_EQ(0, ordinal); // Open another tab (tab C). chrome::NewTab(browser()); ui_test_utils::NavigateToURL(browser(), url); // Simulate what happens when you press F3 for FindNext. We should get a // response here (a hang means search was aborted). EXPECT_EQ(0, ui_test_utils::FindInPage(web_contents, base::string16(), kFwd, kIgnoreCase, &ordinal, NULL)); EXPECT_EQ(0, ordinal); } // Make sure Find box does not become UI-inactive when no text is in the box as // we switch to a tab contents with an empty find string. See issue 13570. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, StayActive) { // First we navigate to any page. GURL url = GetURL(kSimple); ui_test_utils::NavigateToURL(browser(), url); chrome::ShowFindBar(browser()); // Simulate a user clearing the search string. Ideally, we should be // simulating keypresses here for searching for something and pressing // backspace, but that's been proven flaky in the past, so we go straight to // web_contents. FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents( browser()->tab_strip_model()->GetActiveWebContents()); // Stop the (non-existing) find operation, and clear the selection (which // signals the UI is still active). find_tab_helper->StopFinding(FindBarController::kClearSelectionOnPage); // Make sure the Find UI flag hasn't been cleared, it must be so that the UI // still responds to browser window resizing. ASSERT_TRUE(find_tab_helper->find_ui_active()); } // Make sure F3 works after you FindNext a couple of times and end the Find // session. See issue http://crbug.com/28306. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, RestartSearchFromF3) { // First we navigate to a simple page. GURL url = GetURL(kSimple); ui_test_utils::NavigateToURL(browser(), url); // Search for 'page'. Should have 1 match. int ordinal = 0; WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(1, FindInPageASCII(web_contents, "page", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); // Simulate what happens when you press F3 for FindNext. Still should show // one match. This cleared the pre-populate string at one point (see bug). EXPECT_EQ(1, ui_test_utils::FindInPage(web_contents, base::string16(), kFwd, kIgnoreCase, &ordinal, NULL)); EXPECT_EQ(1, ordinal); // End the Find session, thereby making the next F3 start afresh. browser()->GetFindBarController()->EndFindSession( FindBarController::kKeepSelectionOnPage, FindBarController::kKeepResultsInFindBox); // Simulate F3 while Find box is closed. Should have 1 match. EXPECT_EQ(1, FindInPageASCII(web_contents, "", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(1, ordinal); } // When re-opening the find bar with F3, the find bar should be re-populated // with the last search from the same tab rather than the last overall search. // The only exception is if there is a global pasteboard (for example on Mac). // http://crbug.com/30006 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PreferPreviousSearch) { // First we navigate to any page. GURL url = GetURL(kSimple); ui_test_utils::NavigateToURL(browser(), url); // Find "Default". int ordinal = 0; WebContents* web_contents_1 = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(1, FindInPageASCII(web_contents_1, "text", kFwd, kIgnoreCase, &ordinal)); // Create a second tab. // For some reason we can't use AddSelectedTabWithURL here on ChromeOS. It // could be some delicate assumption about the tab starting off unselected or // something relating to user gesture. chrome::AddTabAt(browser(), GURL(), -1, true); ui_test_utils::NavigateToURL(browser(), url); WebContents* web_contents_2 = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_NE(web_contents_1, web_contents_2); // Find "given". FindInPageASCII(web_contents_2, "given", kFwd, kIgnoreCase, &ordinal); // Switch back to first tab. browser()->tab_strip_model()->ActivateTabAt(0, false); browser()->GetFindBarController()->EndFindSession( FindBarController::kKeepSelectionOnPage, FindBarController::kKeepResultsInFindBox); // Simulate F3. ui_test_utils::FindInPage(web_contents_1, base::string16(), kFwd, kIgnoreCase, &ordinal, NULL); FindBar* find_bar = browser()->GetFindBarController()->find_bar(); if (find_bar->HasGlobalFindPasteboard()) { EXPECT_EQ(FindTabHelper::FromWebContents(web_contents_1)->find_text(), ASCIIToUTF16("given")); } else { EXPECT_EQ(FindTabHelper::FromWebContents(web_contents_1)->find_text(), ASCIIToUTF16("text")); } } // This tests that whenever you close and reopen the Find bar, it should show // the last search entered in that tab. http://crbug.com/40121. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateSameTab) { // First we navigate to any page. GURL url = GetURL(kSimple); ui_test_utils::NavigateToURL(browser(), url); // Search for the word "page". int ordinal = 0; WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(1, FindInPageASCII(web_contents, "page", kFwd, kIgnoreCase, &ordinal)); // Open the Find box. EnsureFindBoxOpen(); EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarText()); EXPECT_EQ(ASCIIToUTF16("1 of 1"), GetMatchCountText()); // Close the Find box. browser()->GetFindBarController()->EndFindSession( FindBarController::kKeepSelectionOnPage, FindBarController::kKeepResultsInFindBox); // Open the Find box again. EnsureFindBoxOpen(); // After the Find box has been reopened, it should have been prepopulated with // the word "page" again. EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarText()); EXPECT_EQ(ASCIIToUTF16("1 of 1"), GetMatchCountText()); } // This tests that whenever you open Find in a new tab it should prepopulate // with a previous search term (in any tab), if a search has not been issued in // this tab before. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateInNewTab) { // First we navigate to any page. GURL url = GetURL(kSimple); ui_test_utils::NavigateToURL(browser(), url); // Search for the word "page". int ordinal = 0; WebContents* web_contents_1 = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(1, FindInPageASCII(web_contents_1, "page", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(ASCIIToUTF16("1 of 1"), GetMatchCountText()); // Now create a second tab and load the same page. chrome::AddSelectedTabWithURL(browser(), url, ui::PAGE_TRANSITION_TYPED); WebContents* web_contents_2 = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_NE(web_contents_1, web_contents_2); // Open the Find box. EnsureFindBoxOpen(); // The new tab should have "page" prepopulated, since that was the last search // in the first tab. EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarText()); // But it should not seem like a search has been issued. EXPECT_EQ(base::string16(), GetMatchCountText()); } // This makes sure that we can search for A in tabA, then for B in tabB and // when we come back to tabA we should still see A (because that was the last // search in that tab). IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulatePreserveLast) { FindBar* find_bar = browser()->GetFindBarController()->find_bar(); if (find_bar->HasGlobalFindPasteboard()) return; // First we navigate to any page. GURL url = GetURL(kSimple); ui_test_utils::NavigateToURL(browser(), url); // Search for the word "page". int ordinal = 0; WebContents* web_contents_1 = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(1, FindInPageASCII(web_contents_1, "page", kFwd, kIgnoreCase, &ordinal)); // Open the Find box. EnsureFindBoxOpen(); EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarText()); // Close the Find box. browser()->GetFindBarController()->EndFindSession( FindBarController::kKeepSelectionOnPage, FindBarController::kKeepResultsInFindBox); // Now create a second tab and load the same page. chrome::AddTabAt(browser(), GURL(), -1, true); ui_test_utils::NavigateToURL(browser(), url); WebContents* web_contents_2 = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_NE(web_contents_1, web_contents_2); // Search for the word "text". FindInPageASCII(web_contents_2, "text", kFwd, kIgnoreCase, &ordinal); // Go back to the first tab and make sure we have NOT switched the prepopulate // text to "text". browser()->tab_strip_model()->ActivateTabAt(0, false); // Open the Find box. EnsureFindBoxOpen(); // After the Find box has been reopened, it should have been prepopulated with // the word "page" again, since that was the last search in that tab. EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarText()); // Close the Find box. browser()->GetFindBarController()->EndFindSession( FindBarController::kKeepSelectionOnPage, FindBarController::kKeepResultsInFindBox); // Re-open the Find box. // This is a special case: previous search in WebContents used to get cleared // if you opened and closed the FindBox, which would cause the global // prepopulate value to show instead of last search in this tab. EnsureFindBoxOpen(); // After the Find box has been reopened, it should have been prepopulated with // the word "page" again, since that was the last search in that tab. EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarText()); } // TODO(rohitrao): Searching in incognito tabs does not work in browser tests in // Linux views. Investigate and fix. http://crbug.com/40948 #if defined(OS_LINUX) && defined(TOOLKIT_VIEWS) #define MAYBE_NoIncognitoPrepopulate DISABLED_NoIncognitoPrepopulate #else #define MAYBE_NoIncognitoPrepopulate NoIncognitoPrepopulate #endif // This tests that search terms entered into an incognito find bar are not used // as prepopulate terms for non-incognito windows. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_NoIncognitoPrepopulate) { FindBar* find_bar = browser()->GetFindBarController()->find_bar(); if (find_bar->HasGlobalFindPasteboard()) return; // First we navigate to the "simple" test page. GURL url = GetURL(kSimple); ui_test_utils::NavigateToURL(browser(), url); // Search for the word "page" in the normal browser tab. int ordinal = 0; WebContents* web_contents_1 = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(1, FindInPageASCII(web_contents_1, "page", kFwd, kIgnoreCase, &ordinal)); // Open the Find box. EnsureFindBoxOpenForBrowser(browser()); EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser())); // Close the Find box. browser()->GetFindBarController()->EndFindSession( FindBarController::kKeepSelectionOnPage, FindBarController::kKeepResultsInFindBox); // Open a new incognito window and navigate to the same page. Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); Browser* incognito_browser = new Browser(Browser::CreateParams(incognito_profile, true)); content::WindowedNotificationObserver observer( content::NOTIFICATION_LOAD_STOP, content::NotificationService::AllSources()); chrome::AddSelectedTabWithURL(incognito_browser, url, ui::PAGE_TRANSITION_AUTO_TOPLEVEL); observer.Wait(); incognito_browser->window()->Show(); // Open the find box and make sure that it is prepopulated with "page". EnsureFindBoxOpenForBrowser(incognito_browser); EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(incognito_browser)); // Search for the word "text" in the incognito tab. WebContents* incognito_tab = incognito_browser->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(1, FindInPageASCII(incognito_tab, "text", kFwd, kIgnoreCase, &ordinal)); EXPECT_EQ(ASCIIToUTF16("text"), GetFindBarTextForBrowser(incognito_browser)); // Close the Find box. incognito_browser->GetFindBarController()->EndFindSession( FindBarController::kKeepSelectionOnPage, FindBarController::kKeepResultsInFindBox); // Now open a new tab in the original (non-incognito) browser. chrome::AddSelectedTabWithURL(browser(), url, ui::PAGE_TRANSITION_TYPED); WebContents* web_contents_2 = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_NE(web_contents_1, web_contents_2); // Open the Find box and make sure it is prepopulated with the search term // from the original browser, not the search term from the incognito window. EnsureFindBoxOpenForBrowser(browser()); EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser())); } // This makes sure that dismissing the find bar with kActivateSelection works. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, ActivateLinkNavigatesPage) { // First we navigate to our test content. GURL url = GetURL(kLinkPage); ui_test_utils::NavigateToURL(browser(), url); WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(web_contents); int ordinal = 0; FindInPageASCII(web_contents, "link", kFwd, kIgnoreCase, &ordinal); EXPECT_EQ(ordinal, 1); // End the find session, click on the link. content::WindowedNotificationObserver observer( content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>(&web_contents->GetController())); find_tab_helper->StopFinding(FindBarController::kActivateSelectionOnPage); observer.Wait(); } IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) { Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile(), true); params.initial_bounds = gfx::Rect(0, 0, 250, 500); Browser* popup = new Browser(params); content::WindowedNotificationObserver observer( content::NOTIFICATION_LOAD_STOP, content::NotificationService::AllSources()); chrome::AddSelectedTabWithURL( popup, GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_LINK); // Wait for the page to finish loading. observer.Wait(); popup->window()->Show(); // On GTK, bounds change is asynchronous. base::RunLoop().RunUntilIdle(); EnsureFindBoxOpenForBrowser(popup); // GTK adjusts FindBar size asynchronously. base::RunLoop().RunUntilIdle(); ASSERT_LE(GetFindBarWidthForBrowser(popup), popup->window()->GetBounds().width()); } IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindMovesOnTabClose_Issue1343052) { EnsureFindBoxOpen(); content::RunAllPendingInMessageLoop(); // Needed on Linux. gfx::Point position; EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL)); // Open another tab. GURL url = GetURL(kSimple); ui_test_utils::NavigateToURLWithDisposition( browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); // Close it. chrome::CloseTab(browser()); // See if the Find window has moved. gfx::Point position2; EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL)); EXPECT_EQ(position, position2); // Toggle the bookmark bar state. Note that this starts an animation, and // there isn't a good way other than looping and polling to see when it's // done. So instead we change the state and open a new tab, since the new tab // animation doesn't happen on tab change. chrome::ToggleBookmarkBar(browser()); ui_test_utils::NavigateToURLWithDisposition( browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); EnsureFindBoxOpen(); content::RunAllPendingInMessageLoop(); // Needed on Linux. EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL)); ui_test_utils::NavigateToURLWithDisposition( browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); chrome::CloseTab(browser()); EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL)); EXPECT_EQ(position, position2); } // Verify that if there's a global pasteboard (for example on Mac) then doing // a search on one tab will clear the matches label on the other tabs. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, GlobalPasteBoardClearMatches) { FindBar* find_bar = browser()->GetFindBarController()->find_bar(); if (!find_bar->HasGlobalFindPasteboard()) return; // First we navigate to any page. GURL url = GetURL(kSimple); ui_test_utils::NavigateToURL(browser(), url); // Change the match count on the first tab to "1 of 1". int ordinal = 0; WebContents* web_contents_1 = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_EQ(1, FindInPageASCII(web_contents_1, "page", kFwd, kIgnoreCase, &ordinal)); EnsureFindBoxOpen(); EXPECT_EQ(ASCIIToUTF16("1 of 1"), GetMatchCountText()); // Next, do a search in a second tab. chrome::AddTabAt(browser(), GURL(), -1, true); ui_test_utils::NavigateToURL(browser(), url); WebContents* web_contents_2 = browser()->tab_strip_model()->GetActiveWebContents(); FindInPageASCII(web_contents_2, "text", kFwd, kIgnoreCase, &ordinal); EXPECT_EQ(ASCIIToUTF16("1 of 1"), GetMatchCountText()); // Go back to the first tab and verify that the match text is cleared. // text to "text". browser()->tab_strip_model()->ActivateTabAt(0, false); EXPECT_TRUE(GetMatchCountText().empty()); } // Verify that Incognito window doesn't propagate find string to other widows. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, GlobalPasteboardIncognito) { Browser* browser_incognito = CreateIncognitoBrowser(); WebContents* web_contents_1 = browser()->tab_strip_model()->GetActiveWebContents(); FindInPageASCII(web_contents_1, "page", kFwd, kIgnoreCase, NULL); EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarText()); WebContents* web_contents_2 = browser_incognito->tab_strip_model()->GetActiveWebContents(); FindInPageASCII(web_contents_2, "Incognito", kFwd, kIgnoreCase, NULL); EXPECT_EQ(ASCIIToUTF16("Incognito"), GetFindBarTextForBrowser(browser_incognito)); EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarText()); } // Find text in regular window, find different text in incognito, send // IDC_FIND_NEXT to incognito. It should search for the second phrase. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, IncognitoFindNextSecret) { WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); // On Mac this updates the find pboard. FindInPageASCII(web_contents, "bar", kFwd, kIgnoreCase, NULL); Browser* browser_incognito = CreateIncognitoBrowser(); ui_test_utils::NavigateToURL(browser_incognito, GURL("data:text/plain,barfoofoo")); WebContents* web_contents_incognito = browser_incognito->tab_strip_model()->GetActiveWebContents(); FindInPageASCII(web_contents_incognito, "foo", true, kIgnoreCase, NULL); EXPECT_EQ(ASCIIToUTF16("foo"), GetFindBarTextForBrowser(browser_incognito)); EXPECT_EQ(ASCIIToUTF16("1 of 2"), GetFindBarMatchCountTextForBrowser(browser_incognito)); // Close the find bar. FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(web_contents_incognito); find_tab_helper->StopFinding(FindBarController::kActivateSelectionOnPage); // Cmd + G triggers IDC_FIND_NEXT command. Thus we test FindInPage() // method from browser_commands.cc. FindInPage16() bypasses it. EXPECT_TRUE(chrome::ExecuteCommand(browser_incognito, IDC_FIND_NEXT)); ui_test_utils::FindInPageNotificationObserver observer( web_contents_incognito); observer.Wait(); EXPECT_EQ(ASCIIToUTF16("foo"), GetFindBarTextForBrowser(browser_incognito)); EXPECT_EQ(ASCIIToUTF16("2 of 2"), GetFindBarMatchCountTextForBrowser(browser_incognito)); } // Find text in regular window, send IDC_FIND_NEXT to incognito. It should // search for the first phrase. IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, IncognitoFindNextShared) { WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); // On Mac this updates the find pboard. FindInPageASCII(web_contents, "bar", kFwd, kIgnoreCase, NULL); Browser* browser_incognito = CreateIncognitoBrowser(); ui_test_utils::NavigateToURL(browser_incognito, GURL("data:text/plain,bar")); EXPECT_TRUE(chrome::ExecuteCommand(browser_incognito, IDC_FIND_NEXT)); WebContents* web_contents_incognito = browser_incognito->tab_strip_model()->GetActiveWebContents(); ui_test_utils::FindInPageNotificationObserver observer( web_contents_incognito); observer.Wait(); EXPECT_EQ(ASCIIToUTF16("bar"), GetFindBarTextForBrowser(browser_incognito)); }
[ "hedonist.ky@gmail.com" ]
hedonist.ky@gmail.com
5d14ff634b7744e13547dbe502a42d822b4b6d3e
158f088480d629fd925897715c1e6a5388a22497
/pp/pp/main.cpp
11ad1bfcd2e08159cd187b8179905f6e94cff71e
[]
no_license
danielmonr/Estructura-de-datos
d80e0dc01ba59022901f73f590c4fca62aa0e451
ea5ea8999a071f9ed043a0bf83bca14413b1f258
refs/heads/master
2016-09-06T07:51:12.704534
2015-09-03T02:28:18
2015-09-03T02:28:18
41,838,038
0
1
null
null
null
null
UTF-8
C++
false
false
261
cpp
// // main.cpp // pp // // Created by Daniel on 04/09/14. // Copyright (c) 2014 Gotomo. All rights reserved. // #include <iostream> int main(int argc, const char * argv[]) { // insert code here... std::cout << "Hello, World!\n"; return 0; }
[ "danielmonr@gmail.com" ]
danielmonr@gmail.com
f2399fb25a31382d1ed34223c6a1505e7ce938b8
d4cb7c0dea0078d02dd6b2a423e6caa61bbfc831
/iOS/TestCardAnaly/dukpt/Des.cpp
7ad80beb41ba0a5a4684805d0e9ea8476d0d5151
[ "MIT" ]
permissive
camcima/chinese-dukpt
95ff74e3c776d8318a9cfe6450538d9fd3843c01
48b3acc3682cbbddb9284ca26460bd8245bae796
refs/heads/master
2021-01-25T08:38:24.714438
2014-08-19T18:21:31
2014-08-19T18:21:31
7,212,464
0
1
null
null
null
null
UTF-8
C++
false
false
8,582
cpp
//#include <alllink.h> #include <string.h> #include "DUKPT_DES.h" unsigned char aip[64] = { 58,50,42,34,26,18,10,2, 60,52,44,36,28,20,12,4, 62,54,46,38,30,22,14,6, 64,56,48,40,32,24,16,8, 57,49,41,33,25,17,9,1, 59,51,43,35,27,19,11,3, 61,53,45,37,29,21,13,5, 63,55,47,39,31,23,15,7 }; unsigned char aipinv[64]= { 40,8,48,16,56,24,64,32, 39,7,47,15,55,23,63,31, 38,6,46,14,54,22,62,30, 37,5,45,13,53,21,61,29, 36,4,44,12,52,20,60,28, 35,3,43,11,51,19,59,27, 34,2,42,10,50,18,58,26, 33,1,41,9,49,17,57,25 }; unsigned char E[48]= { 32,1,2,3,4,5, 4,5,6,7,8,9, 8,9,10,11,12,13, 12,13,14,15,16,17, 16,17,18,19,20,21, 20,21,22,23,24,25, 24,25,26,27,28,29, 28,29,30,31,32,1 }; unsigned char S1[64]= { 14,4,13,1,2,15,11,8,3,10,6,12,5,9,0,7, 0,15,7,4,14,2,13,1,10,6,12,11,9,5,3,8, 4,1,14,8,13,6,2,11,15,12,9,7,3,10,5,0, 15,12,8,2,4,9,1,7,5,11,3,14,10,0,6,13 }; unsigned char S2[64]= { 15,1,8,14,6,11,3,4,9,7,2,13,12,0,5,10, 3,13,4,7,15,2,8,14,12,0,1,10,6,9,11,5, 0,14,7,11,10,4,13,1,5,8,12,6,9,3,2,15, 13,8,10,1,3,15,4,2,11,6,7,12,0,5,14,9 }; unsigned char S3[64]= { 10,0,9,14,6,3,15,5,1,13,12,7,11,4,2,8, 13,7,0,9,3,4,6,10,2,8,5,14,12,11,15,1, 13,6,4,9,8,15,3,0,11,1,2,12,5,10,14,7, 1,10,13,0,6,9,8,7,4,15,14,3,11,5,2,12 }; unsigned char S4[64]= { 7,13,14,3,0,6,9,10,1,2,8,5,11,12,4,15, 13,8,11,5,6,15,0,3,4,7,2,12,1,10,14,9, 10,6,9,0,12,11,7,13,15,1,3,14,5,2,8,4, 3,15,0,6,10,1,13,8,9,4,5,11,12,7,2,14 }; unsigned char S5[64]= { 2,12,4,1,7,10,11,6,8,5,3,15,13,0,14,9, 14,11,2,12,4,7,13,1,5,0,15,10,3,9,8,6, 4,2,1,11,10,13,7,8,15,9,12,5,6,3,0,14, 11,8,12,7,1,14,2,13,6,15,0,9,10,4,5,3 }; unsigned char S6[64]= { 12,1,10,15,9,2,6,8,0,13,3,4,14,7,5,11, 10,15,4,2,7,12,9,5,6,1,13,14,0,11,3,8, 9,14,15,5,2,8,12,3,7,0,4,10,1,13,11,6, 4,3,2,12,9,5,15,10,11,14,1,7,6,0,8,13 }; unsigned char S7[64]= { 4,11,2,14,15,0,8,13,3,12,9,7,5,10,6,1, 13,0,11,7,4,9,1,10,14,3,5,12,2,15,8,6, 1,4,11,13,12,3,7,14,10,15,6,8,0,5,9,2, 6,11,13,8,1,4,10,7,9,5,0,15,14,2,3,12 }; unsigned char S8[64]= { 13,2,8,4,6,15,11,1,10,9,3,14,5,0,12,7, 1,15,13,8,10,3,7,4,12,5,6,11,0,14,9,2, 7,11,4,1,9,12,14,2,0,6,10,13,15,3,5,8, 2,1,14,7,4,10,8,13,15,12,9,0,3,5,6,11 }; unsigned char ap[32]= { 16,7,20,21, 29,12,28,17, 1,15,23,26, 5,18,31,10, 2,8,24,14, 32,27,3,9, 19,13,30,6, 22,11,4,25 }; unsigned char PC1[56] = { 57,49,41,33,25,17,9, 1,58,50,42,34,26,18, 10,2,59,51,43,35,27, 19,11,3,60,52,44,36, 63,55,47,39,31,23,15, 7,62,54,46,38,30,22, 14,6,61,53,45,37,29, 21,13,5,28,20,12,4 }; unsigned char PC2[48] = { 14,17,11,24,1,5, 3,28,15,6,21,10, 23,19,12,4,26,8, 16,7,27,20,13,2, 41,52,31,37,47,55, 30,40,51,45,33,48, 44,49,39,56,34,53, 46,42,50,36,29,32 }; unsigned char LS[17] = { 0,1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1}; unsigned char Ki[17][49]; void Init_4bit_tab(unsigned char *dest,unsigned char *source); unsigned char puissance(unsigned char puissance); void Init_bit_tab(unsigned char *dest,unsigned char *source,unsigned char n) { unsigned char masque,i,j; for(i=0;i<n;i++) { masque=0x80; for(j=0;j<8;j++) { dest[8*i+j] = (source[i] & masque) >> (7-j); masque >>= 1; } } } /**************************************************************************** Bin_to_Hex() : range la valeur hexa sur 8 octets d'un nombre binaire de 64 bits *****************************************************************************/ void Bin_to_Hex(unsigned char *vect,unsigned char *source) { unsigned char i,j,masque; memset(vect,0,8); for(i=0; i <8; i++) { masque=7; for(j=0; j<8; j++) { vect[i] += (puissance(masque)) * source[i*8+j]; --masque; } } } unsigned char puissance(unsigned char puissance) { unsigned char res = 1, i; for(i=1 ; i <= puissance; i++) res *= 2; return(res); } void Vect_Permutation(unsigned char *vect,unsigned char n_vect,unsigned char *regle,unsigned char n_regle) { unsigned char buff[65],i; memset(buff,0,65); memcpy(buff,vect,n_vect); for(i=0;i<n_regle;i++) vect[i] = buff[regle[i]-1]; } void S_Box_Calc(unsigned char *vect) { unsigned char *S_Box[8]; unsigned lig,col,i; S_Box[0]=S1; S_Box[1]=S2; S_Box[2]=S3; S_Box[3]=S4; S_Box[4]=S5; S_Box[5]=S6; S_Box[6]=S7; S_Box[7]=S8; for(i=0;i<8;i++) { col= 8*vect[1+6*i] + 4*vect[2+6*i] + 2*vect[3+6*i] + vect[4+6*i]; lig= 2*vect[6*i] + vect[5+6*i]; Init_4bit_tab(&vect[4*i],&S_Box[i][col+lig*16]); } } void Init_4bit_tab(unsigned char *dest,unsigned char *source) { unsigned char masque,i; masque=0x08; for(i=0; i<4; i++) { dest[i] = (*source & masque)>>(3-i); masque >>= 1; } } void Xor(unsigned char *vect1,unsigned char * vect2,unsigned char num_byte) { unsigned char i; for(i=0; i<num_byte; i++) vect1[i] ^= vect2[i]; } void Left_shifts(unsigned char *vect,unsigned char n) { unsigned char i,tmp_vect28,tmp_vect0; for(i=0; i<n; i++) { tmp_vect0 = vect[0]; memcpy(vect,&vect[1],27); vect[27] = tmp_vect0; tmp_vect28 = vect[28]; memcpy(&vect[28],&vect[29],27); vect[55] = tmp_vect28; } } void Calcul_sous_cles(unsigned char *DESKEY) { unsigned char i; unsigned char Kb[65],inter_key[57]; Init_bit_tab(&Kb[1],DESKEY,8); Vect_Permutation(&Kb[1],64,PC1,56); for(i=1; i<=16; i++) { Left_shifts(&Kb[1],LS[i]); memcpy(&inter_key[1],&Kb[1],56); Vect_Permutation(&inter_key[1],56,PC2,48); memcpy(&Ki[i][1],&inter_key[1],48); } } void _Des(char cryp_decrypt,unsigned char *DES_DATA,unsigned char *DES_RESULT,unsigned char *DESKEY) { unsigned char right32_bit[32],i; unsigned char Data_B[81]; Init_bit_tab(&Data_B[1],DES_DATA,8); Vect_Permutation(&Data_B[1],64,aip,64); Calcul_sous_cles(DESKEY); /******************* boucle principale de 15 iterations */ for(i=1; i<=15; i++) { memcpy(right32_bit,&Data_B[33],32); Vect_Permutation(&Data_B[33],32,E,48); switch(cryp_decrypt) { case DES_ENCRYPT: Xor(&Data_B[33],&Ki[i][1],48); break; case DES_DECRYPT: Xor(&Data_B[33],&Ki[17-i][1],48); break; } S_Box_Calc(&Data_B[33]); Vect_Permutation(&Data_B[33],32,ap,32); Xor(&Data_B[33],&Data_B[1],32); memcpy(&Data_B[1],right32_bit,32); } /******************************** 16 iteration *****/ memcpy(right32_bit,&Data_B[33],32); Vect_Permutation(&Data_B[33],32,E,48); if(cryp_decrypt==DES_ENCRYPT) Xor(&Data_B[33],&Ki[16][1],48); else Xor(&Data_B[33],&Ki[1][1],48); S_Box_Calc(&Data_B[33]); Vect_Permutation(&Data_B[33],32,ap,32); Xor(&Data_B[1],&Data_B[33],32); memcpy(&Data_B[33],right32_bit,32); Vect_Permutation(&Data_B[1],64,aipinv,64); Bin_to_Hex(DES_RESULT,&Data_B[1]); } void MAC(unsigned char msg[], int length, unsigned char key[], unsigned char result[]) { int block; block=0; memset(result,0,8); while ( length > block ) { if ( (length-block) <= 8 ) { Xor(result,&msg[block],(unsigned char)(length-block)); _Des(DES_ENCRYPT, result, key, result); return; } Xor(result,&msg[block],8); _Des(DES_ENCRYPT, result, key, result); block += 8; } } void Des_string(unsigned char *in_data, unsigned char data_length, unsigned char *key, unsigned char key_lenth, unsigned char *out_data, unsigned char DES_MODE) { unsigned char data_block,i,tmp[8]; data_block = data_length / 8; for(i=0;i<data_block;i++) { if(DES_MODE == DES_ENCRYPT) { _Des(DES_ENCRYPT, in_data+i*8, out_data+i*8, key ); } else if (DES_MODE == DES_DECRYPT) { _Des(DES_DECRYPT, in_data+i*8, out_data+i*8, key ); } else if (DES_MODE == TDES_ENCRYPT) { _Des(DES_ENCRYPT, in_data+i*8, tmp, key ); _Des(DES_DECRYPT, tmp, tmp, key+8 ); if(key_lenth==24) { _Des( DES_ENCRYPT,tmp, out_data+i*8, key+16 ); } else { _Des(DES_ENCRYPT, tmp, out_data+i*8, key ); } } else if (DES_MODE == TDES_DECRYPT) { if(key_lenth==24) { _Des(DES_DECRYPT, in_data+i*8, tmp, key+16 ); } else { _Des(DES_DECRYPT, in_data+i*8, tmp, key ); } _Des(DES_ENCRYPT, tmp, tmp, key+8 ); _Des(DES_DECRYPT, tmp, out_data+i*8, key ); } } }
[ "ccima@rocket-internet.com" ]
ccima@rocket-internet.com
3a1b3956edb2177f7366dae3f01dfa42c4a9d7c6
ab80f1c39e390b86bffd41c3c53bfedb84761b86
/test/test_jaccobian.cpp
7463a254d568cee50914bb2ef33ad8d62594f20f
[]
no_license
MaouLim/ME-DSO
a7a434d1ca55b25cefadda54a00b898641752cac
213ec11c54803df52cb7142f4785c3bc46999d05
refs/heads/master
2021-05-19T09:17:27.920219
2020-05-12T12:54:14
2020-05-12T12:54:14
251,624,996
1
0
null
null
null
null
UTF-8
C++
false
false
349
cpp
#include <iostream> #include <vo/jaccobian.hpp> int main() { const Eigen::Vector3d q = { 1, 2, 3 }; /** * @test test dTpdesp */ { std::cout << vslam::jaccobian_dTpdeps(q) << std::endl; } /** * @test test dSpdzet */ { std::cout << vslam::jaccobian_dSpdzet(q) << std::endl; } return 0; }
[ "502329767@qq.com" ]
502329767@qq.com
c08d019ad69e2c92a6c4128f32a7506b2b7801b2
e5091c3a8477fa12e1adfdb1f3d826eb6e9bb2be
/UVa/jolly_jumpers.cpp
07a8e908a92f1f9f16822b4f40eb14b04c0d24d9
[]
no_license
leonardoAnjos16/Competitive-Programming
1db3793bfaa7b16fc9a2854c502b788a47f1bbe1
4c9390da44b2fa3c9ec4298783bfb3258b34574d
refs/heads/master
2023-08-14T02:25:31.178582
2023-08-06T06:54:52
2023-08-06T06:54:52
230,381,501
7
0
null
null
null
null
UTF-8
C++
false
false
663
cpp
#include <bits/stdc++.h> using namespace std; #define MAX 3001 bool is_jolly(int numbers[], int size) { vector<bool> used(size - 1, false); for (int i = 1; i < size; i++) { int diff = abs(numbers[i] - numbers[i - 1]); if (diff == 0 || diff >= size || used[diff - 1]) return false; used[diff - 1] = true; } return true; } int main() { int size; while (scanf("%d", &size) != EOF) { int numbers[MAX]; for (int i = 0; i < size; i++) scanf("%d", &numbers[i]); if (is_jolly(numbers, size)) printf("Jolly\n"); else printf("Not jolly\n"); } }
[ "las4@cin.ufpe.br" ]
las4@cin.ufpe.br
26967066f19b4b7772897820a9acb7644056be7f
9a3b9d80afd88e1fa9a24303877d6e130ce22702
/src/Providers/UNIXProviders/ServiceOptionAspect/UNIX_ServiceOptionAspect_ZOS.hxx
6ef359bccd3a856dc55dae2e3c912cb445ce5ec0
[ "MIT" ]
permissive
brunolauze/openpegasus-providers
3244b76d075bc66a77e4ed135893437a66dd769f
f24c56acab2c4c210a8d165bb499cd1b3a12f222
refs/heads/master
2020-04-17T04:27:14.970917
2015-01-04T22:08:09
2015-01-04T22:08:09
19,707,296
0
0
null
null
null
null
UTF-8
C++
false
false
1,821
hxx
//%LICENSE//////////////////////////////////////////////////////////////// // // Licensed to The Open Group (TOG) under one or more contributor license // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with // this work for additional information regarding copyright ownership. // Each contributor licenses this file to you under the OpenPegasus Open // Source License; you may not use this file except in compliance with the // License. // // 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. // ////////////////////////////////////////////////////////////////////////// // //%///////////////////////////////////////////////////////////////////////// #ifdef PEGASUS_OS_ZOS #ifndef __UNIX_SERVICEOPTIONASPECT_PRIVATE_H #define __UNIX_SERVICEOPTIONASPECT_PRIVATE_H #endif #endif
[ "brunolauze@msn.com" ]
brunolauze@msn.com
8711abc0942a89bcf8eeb3afa631f9463ce02e6f
e30ab85bde0c8887f4fb519337da95ad4393fe8d
/Local.cpp
0df3586d194102d55fa374b4958dc6e432709cfa
[]
no_license
rodrigolmonteiro/muonline-client-sources
a80a105c2d278cee482b504b167c393d3b05322e
be7f279f0d17bb8ca87455e434edd30b60e5a5fe
refs/heads/master
2023-06-29T09:45:22.154516
2021-08-04T17:10:15
2021-08-04T17:10:15
null
0
0
null
null
null
null
UHC
C++
false
false
27,814
cpp
// Local.cpp: implementation of the Local // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "Local.h" #ifdef KJH_MOD_NATION_LANGUAGE_REDEFINE char lpszFindHackFiles[MAX_TEXT_LENGTH]; char LanguageName[MAX_TEXT_LENGTH]; char lpszLocaleName[MAX_TEXT_LENGTH]; DWORD g_dwCharSet; int iLengthAuthorityCode; char lpszServerIPAddresses[MAX_TEXT_LENGTH]; //----------------------------------------------------------------------------- Kor // Kor #ifdef _LANGUAGE_KOR strncpy(lpszFindHackFiles, "findhack.exe", MAX_TEXT_LENGTH); strncpy(LanguageName, "Kor", MAX_TEXT_LENGTH); strncpy(lpszLocaleName, "korean", MAX_TEXT_LENGTH); g_dwCharSet = HANGUL_CHARSET; iLengthAuthorityCode = 7; #ifdef PJH_USER_VERSION_SERVER_LIST strncpy(lpszServerIPAddresses, "221.148.39.228", MAX_TEXT_LENGTH); // 체험서버 #else // PJH_USER_VERSION_SERVER_LIST #ifdef _BLUE_SERVER strncpy(lpszServerIPAddresses, "blueconnect.muonline.co.kr", MAX_TEXT_LENGTH); // 한국어(블루) "202.31.176.161" #else // _BLUE_SERVER strncpy(lpszServerIPAddresses, "connect.muonline.co.kr", MAX_TEXT_LENGTH); // 한국어(오리지날) #endif // _BLUE_SERVER #endif //PJH_USER_VERSION_SERVER_LIST bool CheckSpecialText(char *Text) { for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 //if ( *lpszCheck < 0x21 || *lpszCheck > 0x7E) if ( *lpszCheck < 48 || ( 58 <= *lpszCheck && *lpszCheck < 65) || ( 91 <= *lpszCheck && *lpszCheck < 97) || *lpszCheck > 122) { return ( true); } } else { // 두 바이트 unsigned char *lpszTrail = lpszCheck + 1; if ( 0x81 <= *lpszCheck && *lpszCheck <= 0xC8) { // 한글 if ( ( 0x41 <= *lpszTrail && *lpszTrail <= 0x5A) || ( 0x61 <= *lpszTrail && *lpszTrail <= 0x7A) || ( 0x81 <= *lpszTrail && *lpszTrail <= 0xFE)) { // 투명글자 뺀부분 // 안되는 특수문자영역들 if ( 0xA1 <= *lpszCheck && *lpszCheck <= 0xAF && 0xA1 <= *lpszTrail) { return ( true); } else if ( *lpszCheck == 0xC6 && 0x53 <= *lpszTrail && *lpszTrail <= 0xA0) { return ( true); } else if ( 0xC7 <= *lpszCheck && *lpszCheck <= 0xC8 && *lpszTrail <= 0xA0) { return ( true); } } else { return ( true); } } else { return ( true); } ++lpszCheck; } } } //----------------------------------------------------------------------------- Eng // Eng #elif _LANGUAGE_ENG strncpy(lpszFindHackFiles, "", MAX_TEXT_LENGTH); strncpy(LanguageName, "Eng", MAX_TEXT_LENGTH); strncpy(lpszLocaleName, "english", MAX_TEXT_LENGTH); g_dwCharSet = DEFAULT_CHARSET; #ifdef LDK_MOD_PASSWORD_LENGTH_20 iLengthAuthorityCode = 20; #else //LDK_MOD_PASSWORD_LENGTH_20 iLengthAuthorityCode = 10; #endif //LDK_MOD_PASSWORD_LENGTH_20 #ifdef LDS_MOD_URL_GLOBAL_TO_DOTCOM strncpy(lpszServerIPAddresses, "connect.muonline.webzen.com", MAX_TEXT_LENGTH); // 영어(글로벌) #else // LDS_MOD_URL_GLOBAL_TO_DOTCOM strncpy(lpszServerIPAddresses, "connect.muonline.webzen.net", MAX_TEXT_LENGTH); // 영어(글로벌) #endif // LDS_MOD_URL_GLOBAL_TO_DOTCOM bool CheckSpecialText(char *Text) { for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 //사용 가능한 0~9, A~Z, a~z 를 제외한 나머지문자 사용 금지. if( !(48 <= *lpszCheck && *lpszCheck < 58) && !(65 <= *lpszCheck && *lpszCheck < 91) && !(97 <= *lpszCheck && *lpszCheck < 123) ) { return ( true); } } else { // 두 바이트 return ( true); } } } //----------------------------------------------------------------------------- Tai // Tai #elif _LANGUAGE_TAI strncpy(lpszFindHackFiles, "findhack.exe", MAX_TEXT_LENGTH); strncpy(LanguageName, "Tai", MAX_TEXT_LENGTH); strncpy(lpszLocaleName, "taiwan", MAX_TEXT_LENGTH); g_dwCharSet = CHINESEBIG5_CHARSET; #ifdef LDK_FIX_AUTHORITYCODE_LENGTH iLengthAuthorityCode = 9; #else //LDK_FIX_AUTHORITYCODE_LENGTH iLengthAuthorityCode = 10; #endif //LDK_FIX_AUTHORITYCODE_LENGTH strncpy(lpszServerIPAddresses, "connection.muonline.com.tw", MAX_TEXT_LENGTH); // 대만어 "211.20.190.8" bool CheckSpecialText(char *Text) { for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 if ( *lpszCheck < 0x21 || *lpszCheck > 0x7E) { return ( true); } } else { // 두 바이트 unsigned char *lpszTrail = lpszCheck + 1; if ( 0xA4 <= *lpszCheck && *lpszCheck <= 0xF9) { // 한자 if ( ( 0x40 <= *lpszTrail && *lpszTrail <= 0x7E) || ( 0xA1 <= *lpszTrail && *lpszTrail <= 0xFE)) { // 한자임 if ( *lpszCheck == 0xF9 && 0xDD <= *lpszTrail) { // 일부 안되는 특수문자 return ( true); } } else { return ( true); } } else { return ( true); } ++lpszCheck; } } } //----------------------------------------------------------------------------- Chs // Chs #elif _LANGUAGE_CHS strncpy(lpszFindHackFiles, "", MAX_TEXT_LENGTH); strncpy(LanguageName, "Chs", MAX_TEXT_LENGTH); strncpy(lpszLocaleName, "chinese", MAX_TEXT_LENGTH); g_dwCharSet = GB2312_CHARSET; iLengthAuthorityCode = 7; strncpy(lpszServerIPAddresses, "connect.muchina.com", MAX_TEXT_LENGTH); // 중국어 "61.151.252.74" bool CheckSpecialText(char *Text) { for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 if ( *lpszCheck < 0x21 || *lpszCheck > 0x7E) { return ( true); } } else { // 두 바이트 unsigned char *lpszTrail = lpszCheck + 1; if ( 0xB0 <= *lpszCheck && *lpszCheck <= 0xF7) { // 한자 if ( 0xA1 <= *lpszTrail && *lpszTrail <= 0xFE) { // 한자임 if ( *lpszCheck == 0xD7 && 0xFA <= *lpszTrail) { // 일부 안되는 특수문자 return ( true); } } else { return ( true); } } else { return ( true); } ++lpszCheck; } } } //----------------------------------------------------------------------------- Jpn // Jpn #elif _LANGUAGE_JPN strncpy(lpszFindHackFiles, "", MAX_TEXT_LENGTH); strncpy(LanguageName, "Jpn", MAX_TEXT_LENGTH); strncpy(lpszLocaleName, "jpn", MAX_TEXT_LENGTH); g_dwCharSet = SHIFTJIS_CHARSET; iLengthAuthorityCode = 8; strncpy(lpszServerIPAddresses, "cs.muonline.jp", MAX_TEXT_LENGTH); // 일본어 본섭 //strncpy(lpszServerIPAddresses, "122.129.233.231", MAX_TEXT_LENGTH); // 일본어 부분 유료화 공개 테스트 bool CheckSpecialText(char *Text) { for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 if ( *lpszCheck < 0x21 || ( *lpszCheck > 0x7E && *lpszCheck < 0xA1) || *lpszCheck > 0xDF) { return ( true); } } else { // 두 바이트 unsigned char *lpszTrail = lpszCheck + 1; if ( ( 0x88 <= *lpszCheck && *lpszCheck <= 0x9F) || ( 0xE0 <= *lpszCheck && *lpszCheck <= 0xEA) || ( 0xED <= *lpszCheck && *lpszCheck <= 0xEE) || ( 0xFA <= *lpszCheck && *lpszCheck <= 0xFC)) { // 한자 if ( 0x40 <= *lpszTrail && *lpszTrail <= 0xFC) { // 사용되는 범위 if ( *lpszTrail == 0x7F) { // 공백 return ( true); } if ( *lpszCheck == 0x88 && *lpszTrail <= 0x9E) { // 공백 return ( true); } if ( *lpszCheck == 0x98 && ( 0x73 <= *lpszTrail && *lpszTrail <= 0x9E)) { // 공백 return ( true); } if ( *lpszCheck == 0xEA && 0xA5 <= *lpszTrail) { // 공백 return ( true); } if ( *lpszCheck == 0xEE && 0xED <= *lpszTrail) { // 특수 문자 와 공백 return ( true); } if ( *lpszCheck == 0xFC && 0x4C <= *lpszTrail) { // 공백 return ( true); } } else { return ( true); } } else if ( *lpszCheck == 0x81) { if ( *lpszTrail != 0x58 && *lpszTrail != 0x5B) { return ( true); } } else if ( *lpszCheck == 0x82) { if ( *lpszTrail <= 0x4E || ( 0x59 <= *lpszTrail && *lpszTrail <= 0x5F) || ( 0x7A <= *lpszTrail && *lpszTrail <= 0x80) || ( 0x9B <= *lpszTrail && *lpszTrail <= 0x9E) || ( 0xF2 <= *lpszTrail)) { // 일부 전각/히라가나를 제외한 공백 return ( true); } } else if ( *lpszCheck == 0x83) { if ( *lpszTrail < 0x40 || 0x97 <= *lpszTrail) { // 히라가나 외의 공백 및 특수문자 return ( true); } } else { return ( true); } ++lpszCheck; } } } //----------------------------------------------------------------------------- Tha // Tha #elif _LANGUAGE_THA strncpy(lpszFindHackFiles, "", MAX_TEXT_LENGTH); strncpy(LanguageName, "Tha", MAX_TEXT_LENGTH); strncpy(lpszLocaleName, "english", MAX_TEXT_LENGTH); g_dwCharSet = THAI_CHARSET; iLengthAuthorityCode = 7; strncpy(lpszServerIPAddresses, "cs.muonline.in.th", MAX_TEXT_LENGTH); // 태국어 bool CheckSpecialText(char *Text) { for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 //if ( *lpszCheck < 0x21 || *lpszCheck > 0x7E) if ( *lpszCheck < 48 || ( 58 <= *lpszCheck && *lpszCheck < 65) || ( 91 <= *lpszCheck && *lpszCheck < 97) || *lpszCheck > 122) { return ( true); } } else { // 두 바이트 unsigned char *lpszTrail = lpszCheck + 1; if ( 0x81 <= *lpszCheck && *lpszCheck <= 0xC8) { // 한글 if ( ( 0x41 <= *lpszTrail && *lpszTrail <= 0x5A) || ( 0x61 <= *lpszTrail && *lpszTrail <= 0x7A) || ( 0x81 <= *lpszTrail && *lpszTrail <= 0xFE)) { // 투명글자 뺀부분 // 안되는 특수문자영역들 if ( 0xA1 <= *lpszCheck && *lpszCheck <= 0xAF && 0xA1 <= *lpszTrail) { return ( true); } else if ( *lpszCheck == 0xC6 && 0x53 <= *lpszTrail && *lpszTrail <= 0xA0) { return ( true); } else if ( 0xC7 <= *lpszCheck && *lpszCheck <= 0xC8 && *lpszTrail <= 0xA0) { return ( true); } } else { return ( true); } } else { return ( true); } ++lpszCheck; } } } //----------------------------------------------------------------------------- Phi // Phi #elif _LANGUAGE_PHI strncpy(lpszFindHackFiles, "", MAX_TEXT_LENGTH); strncpy(LanguageName, "Phi", MAX_TEXT_LENGTH); strncpy(lpszLocaleName, "engligh", MAX_TEXT_LENGTH); g_dwCharSet = DEFAULT_CHARSET; iLengthAuthorityCode = 7; strncpy(lpszServerIPAddresses, "connect.muonline.com.ph", MAX_TEXT_LENGTH); // 필리핀 bool CheckSpecialText(char *Text) { for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 //if ( *lpszCheck < 0x21 || *lpszCheck > 0x7E) if ( *lpszCheck < 0x21 || *lpszCheck == 0x27 || *lpszCheck == 0x2C || *lpszCheck == 0x2E || *lpszCheck == 0x60 || 0x7F <= *lpszCheck) { return ( true); } } else { // 두 바이트 return ( true); } } } //----------------------------------------------------------------------------- Vie // Vie #elif _LANGUAGE_VIE strncpy(lpszFindHackFiles, "", MAX_TEXT_LENGTH); strncpy(LanguageName, "Vie", MAX_TEXT_LENGTH); strncpy(lpszLocaleName, "engligh", MAX_TEXT_LENGTH); g_dwCharSet = VIETNAMESE_CHARSET; iLengthAuthorityCode = 7; #ifdef LJH_MOD_DOMAIN_NAME_TO_IP_FOR_VIETNAM_VERSION strncpy(lpszServerIPAddresses, "180.148.130.250", MAX_TEXT_LENGTH); // 베트남 신규 접속서버 교체한 뒤에 기존 도메인으로 접속하지 못해 아이피로 입력 //strncpy(lpszServerIPAddresses, "210.245.21.245", MAX_TEXT_LENGTH); // 베트남 //strncpy(lpszServerIPAddresses, "210.245.21.114", MAX_TEXT_LENGTH); // 베트남 내부테스트 용 #else //LJH_MOD_DOMAIN_NAME_TO_IP_FOR_VIETNAM_VERSION strncpy(lpszServerIPAddresses, "connect.muonline.vn", MAX_TEXT_LENGTH); // 베트남 #endif //LJH_MOD_DOMAIN_NAME_TO_IP_FOR_VIETNAM_VERSION bool CheckSpecialText(char *Text) { for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 //if ( *lpszCheck < 0x21 || *lpszCheck > 0x7E) if ( *lpszCheck < 0x21 || *lpszCheck == 0x27 || *lpszCheck == 0x2C || *lpszCheck == 0x2E || *lpszCheck == 0x60 || 0x7F <= *lpszCheck) { return ( true); } } else { // 두 바이트 return ( true); } } } #endif //----------------------------------------------------------------------------- #else // KJH_MOD_NATION_LANGUAGE_REDEFINE #if SELECTED_LANGUAGE == LANGUAGE_KOREAN char *lpszFindHackFiles[NUM_LANGUAGE] = { "findhack.exe", "", "findhack.exe", "", "", ""}; char *LanguageName[NUM_LANGUAGE] = { "Kor", "Eng", "Tai", "Chs", "Jpn", "Tha", "Phi" }; char *lpszLocaleName[NUM_LANGUAGE] = { "korean", "english", "taiwan", "chinese", "jpn", "english", "engligh" }; DWORD g_dwCharSet[NUM_LANGUAGE] = { HANGUL_CHARSET, DEFAULT_CHARSET, CHINESEBIG5_CHARSET, GB2312_CHARSET, SHIFTJIS_CHARSET, THAI_CHARSET, DEFAULT_CHARSET }; int iLengthAuthorityCode[NUM_LANGUAGE] = { 7, // 한국 #ifdef LDK_MOD_PASSWORD_LENGTH_20 20, // 영문 #else //LDK_MOD_PASSWORD_LENGTH_20 10, // 영문 #endif //LDK_MOD_PASSWORD_LENGTH_20 #ifdef LDK_FIX_AUTHORITYCODE_LENGTH 9, // 대만 7, // 중국 #else 10, // 대만 7, // 중국 #endif //LDK_FIX_AUTHORITYCODE_LENGTH 8, // 일본 7, // 태국 7, // 필리핀 }; //!! 접속 서버 IP주소( DNS, 고정 일 경우도 있음.) char lpszServerIPAddresses[NUM_LANGUAGE][50] = { #ifdef PJH_USER_VERSION_SERVER_LIST "221.148.39.228", // 한국어 #else //박종훈 #ifdef _BLUE_SERVER "blueconnect.muonline.co.kr", // 한국어(블루) "202.31.176.161" #else // _BLUE_SERVER "connect.muonline.co.kr", // 한국어(오리지날) #endif // _BLUE_SERVER #endif //PJH_USER_VERSION_SERVER_LIST #ifdef LDS_MOD_URL_GLOBAL_TO_DOTCOM "connect.muonline.webzen.com", // 영어(글로벌) #else // LDS_MOD_URL_GLOBAL_TO_DOTCOM "connect.muonline.webzen.net", // 영어(글로벌) #endif // LDS_MOD_URL_GLOBAL_TO_DOTCOM "connection.muonline.com.tw", // 대만어 "211.20.190.8", "connect.muchina.com", // 중국어 "61.151.252.74" #ifdef LEM_ADD_GAMECHU "218.234.76.52", #else // LEM_ADD_GAMECHU //"122.129.233.231", "cs.muonline.jp", // 일본어 #endif // LEM_ADD_GAMECHU "cs.muonline.in.th", // 태국어 "connect.muonline.com.ph" // 필리핀. }; #else //SELECTED_LANGUAGE == LANGUAGE_KOREAN char *lpszFindHackFiles[NUM_LANGUAGE] = { "findhack.exe", "", "findhack.exe", "", "", "", "", ""}; char *LanguageName[NUM_LANGUAGE] = { "Kor", "Eng", "Tai", "Chs", "Jpn", "Tha", "Phi", "Vie"}; char *lpszLocaleName[NUM_LANGUAGE] = { "korean", "english", "taiwan", "chinese", "jpn", "english", "engligh", "engligh"}; DWORD g_dwCharSet[NUM_LANGUAGE] = { HANGUL_CHARSET, DEFAULT_CHARSET, CHINESEBIG5_CHARSET, GB2312_CHARSET, SHIFTJIS_CHARSET, THAI_CHARSET, DEFAULT_CHARSET, VIETNAMESE_CHARSET}; int iLengthAuthorityCode[NUM_LANGUAGE] = { 7, // 한국 #ifdef LDK_MOD_PASSWORD_LENGTH_20 20, // 영문 #else //LDK_MOD_PASSWORD_LENGTH_20 10, // 영문 #endif //LDK_MOD_PASSWORD_LENGTH_20 #ifdef LDK_FIX_AUTHORITYCODE_LENGTH 9, // 대만 7, // 중국 #else 10, // 대만 7, // 중국 #endif //LDK_FIX_AUTHORITYCODE_LENGTH 8, // 일본 7, // 태국 7, // 필리핀 7, // 베트남 }; //!! 접속 서버 IP주소( DNS, 고정 일 경우도 있음.) char lpszServerIPAddresses[NUM_LANGUAGE][50] = { #ifdef PJH_USER_VERSION_SERVER_LIST "221.148.39.228", // 한국어 #else "connect.muonline.co.kr", // 한국어 #endif //PJH_USER_VERSION_SERVER_LIST #ifdef LDS_MOD_URL_GLOBAL_TO_DOTCOM "connect.muonline.webzen.com", // 영어(글로벌) #else // LDS_MOD_URL_GLOBAL_TO_DOTCOM "connect.muonline.webzen.net", // 영어(글로벌) #endif // LDS_MOD_URL_GLOBAL_TO_DOTCOM "connection.muonline.com.tw", // 대만어 "211.20.190.8" "connect.muchina.com", // 중국어 "61.151.252.74" #ifdef LEM_ADD_GAMECHU "218.234.76.52", #else // LEM_ADD_GAMECHU //"122.129.233.231", "cs.muonline.jp", // 일본어 #endif // LEM_ADD_GAMECHU "cs.muonline.in.th", // 태국어 "connect.muonline.com.ph", // 필리핀 #ifdef LJH_MOD_DOMAIN_NAME_TO_IP_FOR_VIETNAM_VERSION "180.148.130.250" // 베트남 신규 접속서버 교체한 뒤에 기존 도메인으로 접속하지 못해 아이피로 입력 #else //LJH_MOD_DOMAIN_NAME_TO_IP_FOR_VIETNAM_VERSION "connect.muonline.vn" // 베트남 #endif //LJH_MOD_DOMAIN_NAME_TO_IP_FOR_VIETNAM_VERSION //"210.245.21.245" // 베트남 //"210.245.21.114" // 베트남 내부테스트 용 }; #endif //SELECTED_LANGUAGE == LANGUAGE_KOREAN #ifndef KJH_ADD_SERVER_LIST_SYSTEM // #ifndef BOOL IsNonPvpServer( int iServerHigh, int iServerLow) { #if SELECTED_LANGUAGE == LANGUAGE_KOREAN // 한국 if ( iServerLow == 1 || iServerLow == 2 || iServerLow == 15 ) { if(iServerHigh == #if defined PJH_FINAL_VIEW_SERVER_LIST || defined PJH_FINAL_VIEW_SERVER_LIST2 || defined PJH_SEMI_FINAL_VIEW_SERVER_LIST || defined PJH_NEW_SERVER_ADD #ifdef PJH_NEW_SERVER_ADD 8 || iServerHigh == 3 #else 3 #endif //PJH_NEW_SERVER_ADD #else 4 #endif //PJH_FINAL_VIEW_SERVER_LIST ) //. 레알(신규)서버 { return ( FALSE); } return ( TRUE); } #endif // SELECTED_LANGUAGE == LANGUAGE_KOREAN #if SELECTED_LANGUAGE == LANGUAGE_JAPANESE // 일본 if ( iServerLow<=3) { return ( TRUE); } #endif // SELECTED_LANGUAGE == LANGUAGE_JAPANESE #if SELECTED_LANGUAGE == LANGUAGE_TAIWANESE // 대만 if ( iServerLow==2 || iServerLow==3 || iServerLow==4 || iServerLow==5) // 이혁재 - 2005.07.18 대만 요청으로 인한 4,5번 non-pvp 추가 { return ( TRUE); } #endif // SELECTED_LANGUAGE == LANGUAGE_TAIWANESE #if SELECTED_LANGUAGE == LANGUAGE_PHILIPPINES || SELECTED_LANGUAGE == LANGUAGE_VIETNAMESE if ( iServerLow==1 || iServerLow==4 ) { return ( TRUE); } #endif // SELECTED_LANGUAGE == LANGUAGE_PHILIPPINES || SELECTED_LANGUAGE == LANGUAGE_VIETNAMESE #if SELECTED_LANGUAGE == LANGUAGE_ENGLISH if ( iServerLow==1 || iServerLow==2 || iServerLow==3 #ifdef PBG_MOD_NONPVPSERVER || iServerLow==4 #endif //PBG_MOD_NONPVPSERVER ) { return (TRUE); } #endif //SELECTED_LANGUAGE == LANGUAGE_ENGLISH return ( FALSE); } #endif // KJH_ADD_SERVER_LIST_SYSTEM bool CheckSpecialText(char *Text) { #if SELECTED_LANGUAGE == LANGUAGE_KOREAN // 한글판만 체크한다. for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 //if ( *lpszCheck < 0x21 || *lpszCheck > 0x7E) if ( *lpszCheck < 48 || ( 58 <= *lpszCheck && *lpszCheck < 65) || ( 91 <= *lpszCheck && *lpszCheck < 97) || *lpszCheck > 122) { return ( true); } } else { // 두 바이트 unsigned char *lpszTrail = lpszCheck + 1; if ( 0x81 <= *lpszCheck && *lpszCheck <= 0xC8) { // 한글 if ( ( 0x41 <= *lpszTrail && *lpszTrail <= 0x5A) || ( 0x61 <= *lpszTrail && *lpszTrail <= 0x7A) || ( 0x81 <= *lpszTrail && *lpszTrail <= 0xFE)) { // 투명글자 뺀부분 // 안되는 특수문자영역들 if ( 0xA1 <= *lpszCheck && *lpszCheck <= 0xAF && 0xA1 <= *lpszTrail) { return ( true); } else if ( *lpszCheck == 0xC6 && 0x53 <= *lpszTrail && *lpszTrail <= 0xA0) { return ( true); } else if ( 0xC7 <= *lpszCheck && *lpszCheck <= 0xC8 && *lpszTrail <= 0xA0) { return ( true); } } else { return ( true); } } else { return ( true); } ++lpszCheck; } } #elif SELECTED_LANGUAGE == LANGUAGE_TAIWANESE // 대만판만 체크한다. for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 if ( *lpszCheck < 0x21 || *lpszCheck > 0x7E) { return ( true); } } else { // 두 바이트 unsigned char *lpszTrail = lpszCheck + 1; if ( 0xA4 <= *lpszCheck && *lpszCheck <= 0xF9) { // 한자 if ( ( 0x40 <= *lpszTrail && *lpszTrail <= 0x7E) || ( 0xA1 <= *lpszTrail && *lpszTrail <= 0xFE)) { // 한자임 if ( *lpszCheck == 0xF9 && 0xDD <= *lpszTrail) { // 일부 안되는 특수문자 return ( true); } } else { return ( true); } } else { return ( true); } ++lpszCheck; } } #elif SELECTED_LANGUAGE == LANGUAGE_CHINESE // 중국판만 체크한다. for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 if ( *lpszCheck < 0x21 || *lpszCheck > 0x7E) { return ( true); } } else { // 두 바이트 unsigned char *lpszTrail = lpszCheck + 1; if ( 0xB0 <= *lpszCheck && *lpszCheck <= 0xF7) { // 한자 if ( 0xA1 <= *lpszTrail && *lpszTrail <= 0xFE) { // 한자임 if ( *lpszCheck == 0xD7 && 0xFA <= *lpszTrail) { // 일부 안되는 특수문자 return ( true); } } else { return ( true); } } else { return ( true); } ++lpszCheck; } } #elif SELECTED_LANGUAGE == LANGUAGE_JAPANESE // 일본판만 체크한다. for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 if ( *lpszCheck < 0x21 || ( *lpszCheck > 0x7E && *lpszCheck < 0xA1) || *lpszCheck > 0xDF) { return ( true); } } else { // 두 바이트 unsigned char *lpszTrail = lpszCheck + 1; if ( ( 0x88 <= *lpszCheck && *lpszCheck <= 0x9F) || ( 0xE0 <= *lpszCheck && *lpszCheck <= 0xEA) || ( 0xED <= *lpszCheck && *lpszCheck <= 0xEE) || ( 0xFA <= *lpszCheck && *lpszCheck <= 0xFC)) { // 한자 if ( 0x40 <= *lpszTrail && *lpszTrail <= 0xFC) { // 사용되는 범위 if ( *lpszTrail == 0x7F) { // 공백 return ( true); } if ( *lpszCheck == 0x88 && *lpszTrail <= 0x9E) { // 공백 return ( true); } if ( *lpszCheck == 0x98 && ( 0x73 <= *lpszTrail && *lpszTrail <= 0x9E)) { // 공백 return ( true); } if ( *lpszCheck == 0xEA && 0xA5 <= *lpszTrail) { // 공백 return ( true); } if ( *lpszCheck == 0xEE && 0xED <= *lpszTrail) { // 특수 문자 와 공백 return ( true); } if ( *lpszCheck == 0xFC && 0x4C <= *lpszTrail) { // 공백 return ( true); } } else { return ( true); } } else if ( *lpszCheck == 0x81) { if ( *lpszTrail != 0x58 && *lpszTrail != 0x5B) { return ( true); } } else if ( *lpszCheck == 0x82) { if ( *lpszTrail <= 0x4E || ( 0x59 <= *lpszTrail && *lpszTrail <= 0x5F) || ( 0x7A <= *lpszTrail && *lpszTrail <= 0x80) || ( 0x9B <= *lpszTrail && *lpszTrail <= 0x9E) || ( 0xF2 <= *lpszTrail)) { // 일부 전각/히라가나를 제외한 공백 return ( true); } } else if ( *lpszCheck == 0x83) { if ( *lpszTrail < 0x40 || 0x97 <= *lpszTrail) { // 히라가나 외의 공백 및 특수문자 return ( true); } } else { return ( true); } ++lpszCheck; } } #elif SELECTED_LANGUAGE == LANGUAGE_ENGLISH // 영문판만 체크한다. for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 //사용 가능한 0~9, A~Z, a~z 를 제외한 나머지문자 사용 금지. if( !(48 <= *lpszCheck && *lpszCheck < 58) && !(65 <= *lpszCheck && *lpszCheck < 91) && !(97 <= *lpszCheck && *lpszCheck < 123) ) { return ( true); } } else { // 두 바이트 return ( true); } } #elif SELECTED_LANGUAGE == LANGUAGE_PHILIPPINES // 필리핀만 체크한다. for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 //if ( *lpszCheck < 0x21 || *lpszCheck > 0x7E) if ( *lpszCheck < 0x21 || *lpszCheck == 0x27 || *lpszCheck == 0x2C || *lpszCheck == 0x2E || *lpszCheck == 0x60 || 0x7F <= *lpszCheck) { return ( true); } } else { // 두 바이트 return ( true); } } #elif SELECTED_LANGUAGE == LANGUAGE_VIETNAMESE // 베트남만 체크한다. for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 //if ( *lpszCheck < 0x21 || *lpszCheck > 0x7E) if ( *lpszCheck < 0x21 || *lpszCheck == 0x27 || *lpszCheck == 0x2C || *lpszCheck == 0x2E || *lpszCheck == 0x60 || 0x7F <= *lpszCheck) { return ( true); } } else { // 두 바이트 return ( true); } } #elif SELECTED_LANGUAGE == LANGUAGE_THAILAND // 태국판만 체크한다. for ( unsigned char *lpszCheck = ( unsigned char*)Text; *lpszCheck; ++lpszCheck) { if ( 1 == _mbclen( lpszCheck)) { // 한 바이트 //if ( *lpszCheck < 0x21 || *lpszCheck > 0x7E) if ( *lpszCheck < 48 || ( 58 <= *lpszCheck && *lpszCheck < 65) || ( 91 <= *lpszCheck && *lpszCheck < 97) || *lpszCheck > 122) { return ( true); } } else { // 두 바이트 unsigned char *lpszTrail = lpszCheck + 1; if ( 0x81 <= *lpszCheck && *lpszCheck <= 0xC8) { // 한글 if ( ( 0x41 <= *lpszTrail && *lpszTrail <= 0x5A) || ( 0x61 <= *lpszTrail && *lpszTrail <= 0x7A) || ( 0x81 <= *lpszTrail && *lpszTrail <= 0xFE)) { // 투명글자 뺀부분 // 안되는 특수문자영역들 if ( 0xA1 <= *lpszCheck && *lpszCheck <= 0xAF && 0xA1 <= *lpszTrail) { return ( true); } else if ( *lpszCheck == 0xC6 && 0x53 <= *lpszTrail && *lpszTrail <= 0xA0) { return ( true); } else if ( 0xC7 <= *lpszCheck && *lpszCheck <= 0xC8 && *lpszTrail <= 0xA0) { return ( true); } } else { return ( true); } } else { return ( true); } ++lpszCheck; } } #endif return false; } #endif // KJH_MOD_NATION_LANGUAGE_REDEFINE
[ "sasha.broslavskiy@gmail.com" ]
sasha.broslavskiy@gmail.com
24ef9bddc2a364c8f1f97fa1478db825f0aa74c7
58a117a55084a74dd9c49966dfb2d7eecca7ac62
/cpu/access.cc
eb7f24ae1aa72bf26edb2d2401ce4795cd84c343
[]
no_license
mediaexplorer74/Bochs
adaad1c2e355a330eee5900fa09600c5b4f5f19f
9f09abbcbe65ed63fae71c728cb96f59f5f5050d
refs/heads/main
2023-07-11T11:27:25.676886
2021-08-19T03:30:23
2021-08-19T03:30:23
395,043,316
4
0
null
null
null
null
UTF-8
C++
false
false
15,908
cc
///////////////////////////////////////////////////////////////////////// // $Id: access.cc 14086 2021-01-30 08:35:35Z sshwarts $ ///////////////////////////////////////////////////////////////////////// #include "pch.h" #define NEED_CPU_REG_SHORTCUTS 1 #include "../bochs/bochs.h" #include "cpu.h" #define LOG_THIS BX_CPU_THIS_PTR bx_address bx_asize_mask[] = { 0xffff, // as16 (asize = '00) 0xffffffff, // as32 (asize = '01) #if BX_SUPPORT_X86_64 BX_CONST64(0xffffffffffffffff), // as64 (asize = '10) BX_CONST64(0xffffffffffffffff) // as64 (asize = '11) #endif }; #if BX_SUPPORT_EVEX #define BX_MAX_MEM_ACCESS_LENGTH 64 #else #if BX_SUPPORT_AVX #define BX_MAX_MEM_ACCESS_LENGTH 32 #else #define BX_MAX_MEM_ACCESS_LENGTH 16 #endif #endif bool BX_CPP_AttrRegparmN(4) BX_CPU_C::write_virtual_checks(bx_segment_reg_t *seg, Bit32u offset, unsigned length, bool align) { Bit32u upper_limit; length--; if (align) { Bit32u laddr = (Bit32u)(seg->cache.u.segment.base + offset); if (laddr & length) { BX_DEBUG(("write_virtual_checks(): #GP misaligned access")); exception(BX_GP_EXCEPTION, 0); } } if (seg->cache.valid==0) { BX_DEBUG(("write_virtual_checks(): segment descriptor not valid")); return 0; } if (seg->cache.p == 0) { /* not present */ BX_ERROR(("write_virtual_checks(): segment not present")); return 0; } switch (seg->cache.type) { case 0: case 1: // read only case 4: case 5: // read only, expand down case 8: case 9: // execute only case 10: case 11: // execute/read case 12: case 13: // execute only, conforming case 14: case 15: // execute/read-only, conforming BX_ERROR(("write_virtual_checks(): no write access to seg")); return 0; case 2: case 3: /* read/write */ if (seg->cache.u.segment.limit_scaled == 0xffffffff && seg->cache.u.segment.base == 0) { seg->cache.valid |= SegAccessROK | SegAccessWOK | SegAccessROK4G | SegAccessWOK4G; break; } if (offset > (seg->cache.u.segment.limit_scaled - length) || length > seg->cache.u.segment.limit_scaled) { BX_ERROR(("write_virtual_checks(): write beyond limit, r/w")); return 0; } if (seg->cache.u.segment.limit_scaled >= (BX_MAX_MEM_ACCESS_LENGTH-1)) { // Mark cache as being OK type for succeeding read/writes. The limit // checks still needs to be done though, but is more simple. We // could probably also optimize that out with a flag for the case // when limit is the maximum 32bit value. Limit should accomodate // at least a dword, since we subtract from it in the simple // limit check in other functions, and we don't want the value to roll. // Only normal segments (not expand down) are handled this way. seg->cache.valid |= SegAccessROK | SegAccessWOK; } break; case 6: case 7: /* read/write, expand down */ if (seg->cache.u.segment.d_b) upper_limit = 0xffffffff; else upper_limit = 0x0000ffff; if (offset <= seg->cache.u.segment.limit_scaled || offset > upper_limit || (upper_limit - offset) < length) { BX_ERROR(("write_virtual_checks(): write beyond limit, r/w expand down")); return 0; } break; default: BX_PANIC(("write_virtual_checks(): unknown descriptor type=%d", seg->cache.type)); } return 1; } bool BX_CPP_AttrRegparmN(4) BX_CPU_C::read_virtual_checks(bx_segment_reg_t *seg, Bit32u offset, unsigned length, bool align) { Bit32u upper_limit; length--; if (align) { Bit32u laddr = (Bit32u)(seg->cache.u.segment.base + offset); if (laddr & length) { BX_DEBUG(("read_virtual_checks(): #GP misaligned access")); exception(BX_GP_EXCEPTION, 0); } } if (seg->cache.valid==0) { BX_DEBUG(("read_virtual_checks(): segment descriptor not valid")); return 0; } if (seg->cache.p == 0) { /* not present */ BX_ERROR(("read_virtual_checks(): segment not present")); return 0; } switch (seg->cache.type) { case 0: case 1: /* read only */ case 2: case 3: /* read/write */ case 10: case 11: /* execute/read */ case 14: case 15: /* execute/read-only, conforming */ if (seg->cache.u.segment.limit_scaled == 0xffffffff && seg->cache.u.segment.base == 0) { seg->cache.valid |= SegAccessROK | SegAccessROK4G; break; } if (offset > (seg->cache.u.segment.limit_scaled - length) || length > seg->cache.u.segment.limit_scaled) { BX_ERROR(("read_virtual_checks(): read beyond limit")); return 0; } if (seg->cache.u.segment.limit_scaled >= (BX_MAX_MEM_ACCESS_LENGTH-1)) { // Mark cache as being OK type for succeeding reads. See notes for // write checks; similar code. seg->cache.valid |= SegAccessROK; } break; case 4: case 5: /* read only, expand down */ case 6: case 7: /* read/write, expand down */ if (seg->cache.u.segment.d_b) upper_limit = 0xffffffff; else upper_limit = 0x0000ffff; if (offset <= seg->cache.u.segment.limit_scaled || offset > upper_limit || (upper_limit - offset) < length) { BX_ERROR(("read_virtual_checks(): read beyond limit expand down")); return 0; } break; case 8: case 9: /* execute only */ case 12: case 13: /* execute only, conforming */ /* can't read or write an execute-only segment */ BX_ERROR(("read_virtual_checks(): execute only")); return 0; default: BX_PANIC(("read_virtual_checks(): unknown descriptor type=%d", seg->cache.type)); } return 1; } bool BX_CPP_AttrRegparmN(3) BX_CPU_C::execute_virtual_checks(bx_segment_reg_t *seg, Bit32u offset, unsigned length) { Bit32u upper_limit; if (seg->cache.valid==0) { BX_DEBUG(("execute_virtual_checks(): segment descriptor not valid")); return 0; } if (seg->cache.p == 0) { /* not present */ BX_ERROR(("execute_virtual_checks(): segment not present")); return 0; } length--; switch (seg->cache.type) { case 0: case 1: /* read only */ case 2: case 3: /* read/write */ case 10: case 11: /* execute/read */ case 14: case 15: /* execute/read-only, conforming */ if (seg->cache.u.segment.limit_scaled == 0xffffffff && seg->cache.u.segment.base == 0) { seg->cache.valid |= SegAccessROK | SegAccessROK4G; break; } if (offset > (seg->cache.u.segment.limit_scaled - length) || length > seg->cache.u.segment.limit_scaled) { BX_ERROR(("execute_virtual_checks(): read beyond limit")); return 0; } if (seg->cache.u.segment.limit_scaled >= (BX_MAX_MEM_ACCESS_LENGTH-1)) { // Mark cache as being OK type for succeeding reads. See notes for // write checks; similar code. seg->cache.valid |= SegAccessROK; } break; case 8: case 9: /* execute only */ case 12: case 13: /* execute only, conforming */ if (offset > (seg->cache.u.segment.limit_scaled - length) || length > seg->cache.u.segment.limit_scaled) { BX_ERROR(("execute_virtual_checks(): read beyond limit execute only")); return 0; } break; case 4: case 5: /* read only, expand down */ case 6: case 7: /* read/write, expand down */ if (seg->cache.u.segment.d_b) upper_limit = 0xffffffff; else upper_limit = 0x0000ffff; if (offset <= seg->cache.u.segment.limit_scaled || offset > upper_limit || (upper_limit - offset) < length) { BX_ERROR(("execute_virtual_checks(): read beyond limit expand down")); return 0; } break; default: BX_PANIC(("execute_virtual_checks(): unknown descriptor type=%d", seg->cache.type)); } return 1; } const char *BX_CPU_C::strseg(bx_segment_reg_t *seg) { if (seg == &BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES]) return("ES"); else if (seg == &BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS]) return("CS"); else if (seg == &BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS]) return("SS"); else if (seg == &BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS]) return("DS"); else if (seg == &BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS]) return("FS"); else if (seg == &BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS]) return("GS"); else { BX_PANIC(("undefined segment passed to strseg()!")); return("??"); } } int BX_CPU_C::int_number(unsigned s) { if (s == BX_SEG_REG_SS) return BX_SS_EXCEPTION; else return BX_GP_EXCEPTION; } Bit8u BX_CPP_AttrRegparmN(1) BX_CPU_C::system_read_byte(bx_address laddr) { Bit8u data; bx_address lpf = LPFOf(laddr); bx_TLB_entry *tlbEntry = BX_DTLB_ENTRY_OF(laddr, 0); if (tlbEntry->lpf == lpf) { // See if the TLB entry privilege level allows us read access // from this CPL. if (tlbEntry->accessBits & 0x01) { bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; Bit32u pageOffset = PAGE_OFFSET(laddr); Bit8u *hostAddr = (Bit8u*) (hostPageAddr | pageOffset); data = *hostAddr; BX_NOTIFY_LIN_MEMORY_ACCESS(laddr, (tlbEntry->ppf | pageOffset), 1, tlbEntry->get_memtype(), BX_READ, (Bit8u*) &data); return data; } } if (access_read_linear(laddr, 1, 0, BX_READ, 0x0, (void *) &data) < 0) exception(BX_GP_EXCEPTION, 0); return data; } Bit16u BX_CPP_AttrRegparmN(1) BX_CPU_C::system_read_word(bx_address laddr) { Bit16u data; bx_address lpf = LPFOf(laddr); bx_TLB_entry *tlbEntry = BX_DTLB_ENTRY_OF(laddr, 1); if (tlbEntry->lpf == lpf) { // See if the TLB entry privilege level allows us read access // from this CPL. if (tlbEntry->accessBits & 0x01) { bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; Bit32u pageOffset = PAGE_OFFSET(laddr); Bit16u *hostAddr = (Bit16u*) (hostPageAddr | pageOffset); data = ReadHostWordFromLittleEndian(hostAddr); BX_NOTIFY_LIN_MEMORY_ACCESS(laddr, (tlbEntry->ppf | pageOffset), 2, tlbEntry->get_memtype(), BX_READ, (Bit8u*) &data); return data; } } if (access_read_linear(laddr, 2, 0, BX_READ, 0x0, (void *) &data) < 0) exception(BX_GP_EXCEPTION, 0); return data; } Bit32u BX_CPP_AttrRegparmN(1) BX_CPU_C::system_read_dword(bx_address laddr) { Bit32u data; bx_address lpf = LPFOf(laddr); bx_TLB_entry *tlbEntry = BX_DTLB_ENTRY_OF(laddr, 3); if (tlbEntry->lpf == lpf) { // See if the TLB entry privilege level allows us read access // from this CPL. if (tlbEntry->accessBits & 0x01) { bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; Bit32u pageOffset = PAGE_OFFSET(laddr); Bit32u *hostAddr = (Bit32u*) (hostPageAddr | pageOffset); data = ReadHostDWordFromLittleEndian(hostAddr); BX_NOTIFY_LIN_MEMORY_ACCESS(laddr, (tlbEntry->ppf | pageOffset), 4, tlbEntry->get_memtype(), BX_READ, (Bit8u*) &data); return data; } } if (access_read_linear(laddr, 4, 0, BX_READ, 0x0, (void *) &data) < 0) exception(BX_GP_EXCEPTION, 0); return data; } Bit64u BX_CPP_AttrRegparmN(1) BX_CPU_C::system_read_qword(bx_address laddr) { Bit64u data; bx_address lpf = LPFOf(laddr); bx_TLB_entry *tlbEntry = BX_DTLB_ENTRY_OF(laddr, 7); if (tlbEntry->lpf == lpf) { // See if the TLB entry privilege level allows us read access // from this CPL. if (tlbEntry->accessBits & 0x01) { bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; Bit32u pageOffset = PAGE_OFFSET(laddr); Bit64u *hostAddr = (Bit64u*) (hostPageAddr | pageOffset); data = ReadHostQWordFromLittleEndian(hostAddr); BX_NOTIFY_LIN_MEMORY_ACCESS(laddr, (tlbEntry->ppf | pageOffset), 8, tlbEntry->get_memtype(), BX_READ, (Bit8u*) &data); return data; } } if (access_read_linear(laddr, 8, 0, BX_READ, 0x0, (void *) &data) < 0) exception(BX_GP_EXCEPTION, 0); return data; } void BX_CPP_AttrRegparmN(2) BX_CPU_C::system_write_byte(bx_address laddr, Bit8u data) { bx_address lpf = LPFOf(laddr); bx_TLB_entry *tlbEntry = BX_DTLB_ENTRY_OF(laddr, 0); if (tlbEntry->lpf == lpf) { // See if the TLB entry privilege level allows us write access // from this CPL. if (isWriteOK(tlbEntry, 0)) { bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; Bit32u pageOffset = PAGE_OFFSET(laddr); bx_phy_address pAddr = tlbEntry->ppf | pageOffset; BX_NOTIFY_LIN_MEMORY_ACCESS(laddr, pAddr, 1, tlbEntry->get_memtype(), BX_WRITE, (Bit8u*) &data); Bit8u *hostAddr = (Bit8u*) (hostPageAddr | pageOffset); pageWriteStampTable.decWriteStamp(pAddr, 1); *hostAddr = data; return; } } if (access_write_linear(laddr, 1, 0, BX_WRITE, 0x0, (void *) &data) < 0) exception(BX_GP_EXCEPTION, 0); } void BX_CPP_AttrRegparmN(2) BX_CPU_C::system_write_word(bx_address laddr, Bit16u data) { bx_address lpf = LPFOf(laddr); bx_TLB_entry *tlbEntry = BX_DTLB_ENTRY_OF(laddr, 1); if (tlbEntry->lpf == lpf) { // See if the TLB entry privilege level allows us write access // from this CPL. if (isWriteOK(tlbEntry, 0)) { bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; Bit32u pageOffset = PAGE_OFFSET(laddr); bx_phy_address pAddr = tlbEntry->ppf | pageOffset; BX_NOTIFY_LIN_MEMORY_ACCESS(laddr, pAddr, 2, tlbEntry->get_memtype(), BX_WRITE, (Bit8u*) &data); Bit16u *hostAddr = (Bit16u*) (hostPageAddr | pageOffset); pageWriteStampTable.decWriteStamp(pAddr, 2); WriteHostWordToLittleEndian(hostAddr, data); return; } } if (access_write_linear(laddr, 2, 0, BX_WRITE, 0x0, (void *) &data) < 0) exception(BX_GP_EXCEPTION, 0); } void BX_CPP_AttrRegparmN(2) BX_CPU_C::system_write_dword(bx_address laddr, Bit32u data) { bx_address lpf = LPFOf(laddr); bx_TLB_entry *tlbEntry = BX_DTLB_ENTRY_OF(laddr, 3); if (tlbEntry->lpf == lpf) { // See if the TLB entry privilege level allows us write access // from this CPL. if (isWriteOK(tlbEntry, 0)) { bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; Bit32u pageOffset = PAGE_OFFSET(laddr); bx_phy_address pAddr = tlbEntry->ppf | pageOffset; BX_NOTIFY_LIN_MEMORY_ACCESS(laddr, pAddr, 4, tlbEntry->get_memtype(), BX_WRITE, (Bit8u*) &data); Bit32u *hostAddr = (Bit32u*) (hostPageAddr | pageOffset); pageWriteStampTable.decWriteStamp(pAddr, 4); WriteHostDWordToLittleEndian(hostAddr, data); return; } } if (access_write_linear(laddr, 4, 0, BX_WRITE, 0x0, (void *) &data) < 0) exception(BX_GP_EXCEPTION, 0); } Bit8u* BX_CPP_AttrRegparmN(2) BX_CPU_C::v2h_read_byte(bx_address laddr, bool user) { bx_address lpf = LPFOf(laddr); bx_TLB_entry *tlbEntry = BX_DTLB_ENTRY_OF(laddr, 0); if (tlbEntry->lpf == lpf) { // See if the TLB entry privilege level allows us read access // from this CPL. if (isReadOK(tlbEntry, user)) { bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; Bit32u pageOffset = PAGE_OFFSET(laddr); Bit8u *hostAddr = (Bit8u*) (hostPageAddr | pageOffset); return hostAddr; } } return 0; } Bit8u* BX_CPP_AttrRegparmN(2) BX_CPU_C::v2h_write_byte(bx_address laddr, bool user) { bx_address lpf = LPFOf(laddr); bx_TLB_entry *tlbEntry = BX_DTLB_ENTRY_OF(laddr, 0); if (tlbEntry->lpf == lpf) { // See if the TLB entry privilege level allows us write access // from this CPL. if (isWriteOK(tlbEntry, user)) { bx_hostpageaddr_t hostPageAddr = tlbEntry->hostPageAddr; Bit32u pageOffset = PAGE_OFFSET(laddr); Bit8u *hostAddr = (Bit8u*) (hostPageAddr | pageOffset); pageWriteStampTable.decWriteStamp(tlbEntry->ppf); return hostAddr; } } return 0; }
[ "mediaexplorer74@hotmail.com" ]
mediaexplorer74@hotmail.com
f0861987226d464844a9a4767b89b4941b61da72
d69cc85c6d1039c64112432b22a1a756b267b1a8
/_cmake/lib/arduino-upm/src/nmea_gps.hpp
26b3ca005b9eeb63b0c144401e065961270240b2
[ "MIT" ]
permissive
SSG-DRD-IOT/lab-protocols-mqtt-arduino
02a004f60fcdd8da65d221dc287f26e3a016afa1
834cef842154b4645f98f1f7da57cb0ea887ca98
refs/heads/master
2021-01-19T07:54:17.220914
2018-04-03T16:11:34
2018-04-03T16:11:34
100,647,409
0
4
MIT
2018-04-03T16:11:35
2017-08-17T21:40:18
C
UTF-8
C++
false
false
4,973
hpp
/* * Author: Jon Trulson <jtrulson@ics.com> * Copyright (c) 2016 Intel Corporation. * * 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 <string> #include <iostream> #include <stdlib.h> #include <unistd.h> #include "nmea_gps.h" namespace upm { /** * @brief UPM C++ API for a generic GPS serial device reporting NMEA data * @defgroup nmea_gps libupm-nmea_gps * @ingroup uart gpio gps */ /** * @library nmea_gps * @sensor nmea_gps * @comname Generic Serial Interface for GPS NMEA Devices * @type gps * @man dfrobot seeed * @con uart gpio * @altname VK2828u7 ublox LEA-6H * * @brief API for the NMEA GPS Module * * This driver was tested with a number of GPS devices that emit * NMEA data via a serial interface of some sort (typically a UART). * * The I2C capablity was tested with a UBLOX LEA-6H based GPS shield * from DFRobot. Currently, the I2C capability is only supported * for UBLOX devices (or compatibles) that conform to the * specifications outlined in the u-blox6 Receiver Description * Protocol Specification, Chapter 4, DDC Port. * * An example using the UART. * @snippet nmea_gps.cxx Interesting * An example using I2C. * @snippet nmea_gps-i2c.cxx Interesting */ class NMEAGPS { public: /** * NMEAGPS object constructor for a UART * * @param uart Specify which uart to use. * @param baudrate Specify the baudrate to use. The device defaults * to 9600 baud. * @param enable_pin Specify the GPIO pin to use for the enable pin, * -1 to not use an enable pin. */ NMEAGPS(unsigned int uart, unsigned int baudrate, int enable_pin); /** * NMEAGPS object constructor for a UBLOX I2C interface * * @param bus Specify which the I2C bus to use. * @param addr Specify the I2C address to use. For UBLOX devices, * this typically defaults to 0x42. */ NMEAGPS(unsigned int bus, uint8_t addr); /** * NMEAGPS object destructor */ ~NMEAGPS(); /** * Read character data from the device. * * @param size The maximum number of characters to read. * @return string containing the data read. */ std::string readStr(size_t size); /** * Write character data to the device. This is only valid for a * UART device. * * @param buffer The string containing the data to write. * @return The number of bytes written. */ int writeStr(std::string buffer); /** * Enable or disable the device. When disabled, the device enters a * low power mode and does not emit NMEA data. It will still * maintain location data however. * * @param enable true to enable the device, false otherwise. */ void enable(bool enable); /** * Set the baudrate of the device. By default, the constructor * will set the baudrate to 9600. This is only valid for UART * devices. * * @param baudrate The baud rate to set for the device. */ void setBaudrate(unsigned int baudrate); /** * Determine whether there is data available to be read. In the * case of a UART, this function will wait up to "millis" * milliseconds for data to become available. In the case of an I2C * device, the millis argument is ignored and the function will * return immediately, indicating whether data is available. * * @param millis The number of milliseconds to wait for data to * become available. * @return true if data is available to be read, false otherwise. */ bool dataAvailable(unsigned int millis); protected: // nmeaGPS device context nmea_gps_context m_nmea_gps; private: /* Disable implicit copy and assignment operators */ NMEAGPS(const NMEAGPS&) = delete; NMEAGPS &operator=(const NMEAGPS&) = delete; }; }
[ "christopherx.crase@intel.com" ]
christopherx.crase@intel.com
efdcf54505779cbd73369dce576153395bf50aa6
bc3f4abb517829c60f846e5cd9787ac61def945b
/cpp_boost/boost/boost/geometry/algorithms/detail/relate/point_geometry.hpp
74ef761febba0b9dbe065a3136d67f26b84e7f68
[]
no_license
ngzHappy/cpc2
f3a7a0082e7ab3bd995820384c938ef6f1904a34
2830d68fec95ba0afeabd9469e919f8e6deb41b3
refs/heads/master
2020-12-25T17:24:17.726694
2016-08-08T13:40:06
2016-08-08T13:40:07
58,794,358
0
0
null
null
null
null
UTF-8
C++
false
false
6,762
hpp
// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2013, 2014, 2015. // Modifications copyright (c) 2013-2015 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_POINT_GEOMETRY_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_POINT_GEOMETRY_HPP #include <boost/geometry/algorithms/detail/within/point_in_geometry.hpp> //#include <boost/geometry/algorithms/within.hpp> //#include <boost/geometry/algorithms/covered_by.hpp> #include <boost/geometry/algorithms/detail/relate/result.hpp> #include <boost/geometry/algorithms/detail/relate/topology_check.hpp> #include <boost/geometry/util/condition.hpp> namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace relate { // non-point geometry template <typename Point, typename Geometry, bool Transpose = false> struct point_geometry { // TODO: interrupt only if the topology check is complex static const bool interruption_enabled = true; template <typename Result> static inline void apply(Point const& point, Geometry const& geometry, Result & result) { int pig = detail::within::point_in_geometry(point, geometry); if ( pig > 0 ) // within { relate::set<interior, interior, '0', Transpose>(result); } else if ( pig == 0 ) { relate::set<interior, boundary, '0', Transpose>(result); } else // pig < 0 - not within { relate::set<interior, exterior, '0', Transpose>(result); } relate::set<exterior, exterior, result_dimension<Point>::value, Transpose>(result); if ( BOOST_GEOMETRY_CONDITION(result.interrupt) ) return; // the point is on the boundary if ( pig == 0 ) { // NOTE: even for MLs, if there is at least one boundary point, // somewhere there must be another one // check if there are other boundaries outside typedef detail::relate::topology_check<Geometry> tc_t; //tc_t tc(geometry, point); //if ( tc.has_interior ) relate::set<exterior, interior, tc_t::interior, Transpose>(result); //if ( tc.has_boundary ) relate::set<exterior, boundary, tc_t::boundary, Transpose>(result); } else { // check if there is a boundary in Geometry typedef detail::relate::topology_check<Geometry> tc_t; tc_t tc(geometry); if ( tc.has_interior ) relate::set<exterior, interior, tc_t::interior, Transpose>(result); if ( tc.has_boundary ) relate::set<exterior, boundary, tc_t::boundary, Transpose>(result); } } }; // transposed result of point_geometry template <typename Geometry, typename Point> struct geometry_point { // TODO: interrupt only if the topology check is complex static const bool interruption_enabled = true; template <typename Result> static inline void apply(Geometry const& geometry, Point const& point, Result & result) { point_geometry<Point, Geometry, true>::apply(point, geometry, result); } }; // TODO: rewrite the folowing: //// NOTE: Those tests should be consistent with within(Point, Box) and covered_by(Point, Box) //// There is no EPS used in those functions, values are compared using < or <= //// so comparing MIN and MAX in the same way should be fine // //template <typename Box, std::size_t I = 0, std::size_t D = geometry::dimension<Box>::value> //struct box_has_interior //{ // static inline bool apply(Box const& box) // { // return geometry::get<min_corner, I>(box) < geometry::get<max_corner, I>(box) // && box_has_interior<Box, I + 1, D>::apply(box); // } //}; // //template <typename Box, std::size_t D> //struct box_has_interior<Box, D, D> //{ // static inline bool apply(Box const&) { return true; } //}; // //// NOTE: especially important here (see the NOTE above). // //template <typename Box, std::size_t I = 0, std::size_t D = geometry::dimension<Box>::value> //struct box_has_equal_min_max //{ // static inline bool apply(Box const& box) // { // return geometry::get<min_corner, I>(box) == geometry::get<max_corner, I>(box) // && box_has_equal_min_max<Box, I + 1, D>::apply(box); // } //}; // //template <typename Box, std::size_t D> //struct box_has_equal_min_max<Box, D, D> //{ // static inline bool apply(Box const&) { return true; } //}; // //template <typename Point, typename Box> //struct point_box //{ // static inline result apply(Point const& point, Box const& box) // { // result res; // // if ( geometry::within(point, box) ) // this also means that the box has interior // { // return result("0FFFFFTTT"); // } // else if ( geometry::covered_by(point, box) ) // point is on the boundary // { // //if ( box_has_interior<Box>::apply(box) ) // //{ // // return result("F0FFFFTTT"); // //} // //else if ( box_has_equal_min_max<Box>::apply(box) ) // no boundary outside point // //{ // // return result("F0FFFFFFT"); // //} // //else // no interior outside point // //{ // // return result("F0FFFFFTT"); // //} // return result("F0FFFF**T"); // } // else // { // /*if ( box_has_interior<Box>::apply(box) ) // { // return result("FF0FFFTTT"); // } // else // { // return result("FF0FFFFTT"); // }*/ // return result("FF0FFF*TT"); // } // // return res; // } //}; // //template <typename Box, typename Point> //struct box_point //{ // static inline result apply(Box const& box, Point const& point) // { // if ( geometry::within(point, box) ) // return result("0FTFFTFFT"); // else if ( geometry::covered_by(point, box) ) // return result("FF*0F*FFT"); // else // return result("FF*FFT0FT"); // } //}; }} // namespace detail::relate #endif // DOXYGEN_NO_DETAIL }} // namespace boost::geometry #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_POINT_GEOMETRY_HPP
[ "819869472@qq.com" ]
819869472@qq.com
e3aa7b9eae62247fcde97c32873fc07c1089027b
293902682d7ee13be81ada6c28ef6b840983ac33
/OracleAccess/src/Table.h
e7f33b4cf64dbc32a64218e802edce0bc9fb3ef2
[]
no_license
cms-externals/coral
d17cba45fff7f34d7a1ba13ab3bb371e0696c1af
a879b41c994fa956ff0ae78e3410bb409582ad20
refs/heads/cms/CORAL_2_3_21py3
2022-02-26T18:51:25.258362
2022-02-23T13:19:11
2022-02-23T13:19:11
91,173,895
0
4
null
2022-02-14T13:20:11
2017-05-13T12:47:54
C++
UTF-8
C++
false
false
1,845
h
#ifndef ORACLEACCESS_TABLE_H #define ORACLEACCESS_TABLE_H 1 #include <string> #include <boost/shared_ptr.hpp> #include "RelationalAccess/ITable.h" struct OCIDescribe; namespace coral { namespace OracleAccess { class DataEditor; class PrivilegeManager; class SessionProperties; class TableDescriptionProxy; /** * Class Table * * Implementation of the ITable interface for the OracleAccess package */ class Table : virtual public coral::ITable { public: /// Constructor Table( boost::shared_ptr<const SessionProperties> properties, const std::string& schemaName, const std::string& tableName, OCIDescribe* descriptor ); /// Destructor virtual ~Table(); /** * Returns the description of the table. */ const coral::ITableDescription& description() const; /** * Returns a reference to the schema editor for the table. */ coral::ITableSchemaEditor& schemaEditor(); /** * Returns a reference to the ITableDataEditor object for the table. */ coral::ITableDataEditor& dataEditor(); /** * Returns a reference to the privilege manager of the table. */ coral::ITablePrivilegeManager& privilegeManager(); /** * Returns a new query object for performing a query involving this table only. */ coral::IQuery* newQuery() const; private: /// The session properties boost::shared_ptr<const SessionProperties> m_sessionProperties; /// The proxy to the table description TableDescriptionProxy* m_descriptionProxy; /// The privilege manager PrivilegeManager* m_privilegeManager; /// The data editor DataEditor* m_dataEditor; }; } } #endif
[ "cmsbuild@cern.ch" ]
cmsbuild@cern.ch
ad7d4d9a688ed40e8ff3af52bef6874c125dac10
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive2/af/ebebb12df1665b/main.cpp
1a9698a222e54f0b9b429f8e452107110e1eaeca
[]
no_license
WhiZTiM/coliru
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
2c72c048846c082f943e6c7f9fa8d94aee76979f
refs/heads/master
2021-01-01T05:10:33.812560
2015-08-24T19:09:22
2015-08-24T19:09:22
56,789,706
3
0
null
null
null
null
UTF-8
C++
false
false
98
cpp
class A { public: A(int) { } }; int main() { A a[10] = A(1); return 0; }
[ "francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df" ]
francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df
d49420c174ec0f355d17f5d609c7ab1230bcc310
a754da405bc3d2d2d1d8940d7d277c63bf2b7768
/3party/boost/boost/polygon/point_data.hpp
e42a7aa78dbdb77d13d85dcffb98445f52ed190c
[ "BSL-1.0", "Apache-2.0" ]
permissive
icyleaf/omim
3a5a4f07890e6ad0155447ed39563a710178ec35
a1a299eb341603337bf4a22b92518d9575498c97
refs/heads/master
2020-12-28T22:53:52.624975
2015-10-09T16:30:46
2015-10-09T16:30:46
43,995,093
0
0
Apache-2.0
2019-12-12T03:19:59
2015-10-10T05:08:38
C++
UTF-8
C++
false
false
3,002
hpp
// Boost.Polygon library point_data.hpp header file // Copyright (c) Intel Corporation 2008. // Copyright (c) 2008-2012 Simonson Lucanus. // Copyright (c) 2012-2012 Andrii Sydorchuk. // See http://www.boost.org for updates, documentation, and revision history. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_POLYGON_POINT_DATA_HPP #define BOOST_POLYGON_POINT_DATA_HPP #include "isotropy.hpp" #include "point_concept.hpp" namespace boost { namespace polygon { template <typename T> class point_data { public: typedef T coordinate_type; point_data() #ifndef BOOST_POLYGON_MSVC : coords_() #endif {} point_data(coordinate_type x, coordinate_type y) { coords_[HORIZONTAL] = x; coords_[VERTICAL] = y; } explicit point_data(const point_data& that) { coords_[0] = that.coords_[0]; coords_[1] = that.coords_[1]; } point_data& operator=(const point_data& that) { coords_[0] = that.coords_[0]; coords_[1] = that.coords_[1]; return *this; } template <typename PointType> #ifdef __GNUC__ explicit #endif point_data(const PointType& that) { *this = that; } template <typename PointType> point_data& operator=(const PointType& that) { assign(*this, that); return *this; } // TODO(asydorchuk): Deprecated. template <typename CT> point_data(const point_data<CT>& that) { coords_[HORIZONTAL] = (coordinate_type)that.x(); coords_[VERTICAL] = (coordinate_type)that.y(); } coordinate_type get(orientation_2d orient) const { return coords_[orient.to_int()]; } void set(orientation_2d orient, coordinate_type value) { coords_[orient.to_int()] = value; } coordinate_type x() const { return coords_[HORIZONTAL]; } point_data& x(coordinate_type value) { coords_[HORIZONTAL] = value; return *this; } coordinate_type y() const { return coords_[VERTICAL]; } point_data& y(coordinate_type value) { coords_[VERTICAL] = value; return *this; } bool operator==(const point_data& that) const { return (coords_[0] == that.coords_[0]) && (coords_[1] == that.coords_[1]); } bool operator!=(const point_data& that) const { return !(*this == that); } bool operator<(const point_data& that) const { return (coords_[0] < that.coords_[0]) || ((coords_[0] == that.coords_[0]) && (coords_[1] < that.coords_[1])); } bool operator<=(const point_data& that) const { return !(that < *this); } bool operator>(const point_data& that) const { return that < *this; } bool operator>=(const point_data& that) const { return !(*this < that); } private: coordinate_type coords_[2]; }; template <typename CType> struct geometry_concept< point_data<CType> > { typedef point_concept type; }; } // polygon } // boost #endif // BOOST_POLYGON_POINT_DATA_HPP
[ "alex@maps.me" ]
alex@maps.me
34f7f7e4a005bca5377aa002c2cb23cd0b537695
59cb0e5cd9da12a6cab1a80f8dfdbbb25f2674ff
/ChapmanKolmogorov/chapmanKolmogorov.cpp
d3e183d4fe90c30200e82fca6a071ef39b987b4f
[]
no_license
jupmorenor/CppAlgorithmsStructures
73a75be3d1314c8aec1761007f8054494fdd8f7a
a98855b65668bfa38ac2dfa25b168f5f6d12c25d
refs/heads/master
2022-11-23T10:19:14.814327
2020-07-01T02:02:42
2020-07-01T02:02:42
276,252,787
0
0
null
null
null
null
UTF-8
C++
false
false
1,158
cpp
#include <iostream> #include <stdlib.h> #include <time.h> #include <fstream> #include <windows.h> using namespace std; ofstream resultados; LARGE_INTEGER frecuencia; LARGE_INTEGER inicio; LARGE_INTEGER finale; LARGE_INTEGER delta; float matriz[3][3]; float ecuacionChapmanKolmogorov(float P[3][3], int i, int j, int n, int m, int M) { int Pij; if(n==1) { return P[i][j]; } else { Pij = 0; for (int k=0; k<M; k++) { Pij += ecuacionChapmanKolmogorov(P, i, k, n-m, n-m-1, M) * ecuacionChapmanKolmogorov(P, k, j, m, m-1, M); } } return Pij; } int main() { matriz[3][3] = {{0.1, 0.8, 0.1}, {0.9, 0, 0.1}, {0.2, 0.2, 0.6}}; float resultado, tiempo; QueryPerformanceFrequency(&frecuencia); resultados.open("resultados.txt"); for(int i=0; i<=15; i++) { QueryPerformanceCounter(&inicio); resultado = ecuacionChapmanKolmogorov(matriz, 0, 2, i+1, i, 3); QueryPerformanceCounter(&finale); cout << resultado << endl; delta.QuadPart = finale.QuadPart - inicio.QuadPart; tiempo = ((float)delta.QuadPart)/frecuencia.QuadPart; resultados << tiempo*1000 << "\n"; } resultados.close(); cout << "terminado" << endl; return 0; }
[ "jupmorenor@gmail.com" ]
jupmorenor@gmail.com
aabcb84a3c019fdb2f465a16fd740ee6e8392c39
39dd8e17cfad1212bb5896635f5f27e04710f1e9
/arangod/RestServer/ScriptFeature.h
2e5f629720cdad500c51aa355154b5ad5b99ec14
[ "Apache-2.0", "WTFPL", "MIT", "LicenseRef-scancode-proprietary-license", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "ICU", "GPL-1.0-or-later", "Unlicense", "LicenseRef-scancode-autoconf-simple-exception", "Zlib", "LicenseRef-scancode-pcre", "ISC", "BSL-1.0" ]
permissive
davinash/arangodb
18352d254c982ef5c129ceb342244061b4a27fe6
437baf4919d66697ef656467af2b39cd4dcf3132
refs/heads/master
2020-03-31T11:46:01.932874
2018-10-04T20:36:08
2018-10-04T20:36:08
152,190,055
0
1
Apache-2.0
2018-10-09T04:59:05
2018-10-09T04:59:05
null
UTF-8
C++
false
false
1,561
h
//////////////////////////////////////////////////////////////////////////////// /// DISCLAIMER /// /// Copyright 2016 ArangoDB GmbH, Cologne, Germany /// /// 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. /// /// Copyright holder is ArangoDB GmbH, Cologne, Germany /// /// @author Dr. Frank Celler //////////////////////////////////////////////////////////////////////////////// #ifndef APPLICATION_FEATURES_SCRIPT_FEATURE_H #define APPLICATION_FEATURES_SCRIPT_FEATURE_H 1 #include "ApplicationFeatures/ApplicationFeature.h" #include "GeneralServer/OperationMode.h" namespace arangodb { class ScriptFeature final : public application_features::ApplicationFeature { public: explicit ScriptFeature(application_features::ApplicationServer*, int* result); public: void collectOptions(std::shared_ptr<options::ProgramOptions>) override final; void start() override final; private: std::vector<std::string> _scriptParameters; private: int runScript(std::vector<std::string> const& scripts); private: int* _result; }; } #endif
[ "frank@arangodb.com" ]
frank@arangodb.com
303deb30fb00ef0e7ca09c1c6f63df69f968a271
8e353182fb9b8a62f8bef1a140511f50a2a34b22
/particle.cc
46f30159312353ebe566abecb18746003f939db9
[]
no_license
estarter/cpp_course
24d33a99f90d453bb214fc00a3dab6bd2c06eec5
a03c94716f2952289150210479ba5886a3cf94f0
refs/heads/master
2016-09-13T06:29:21.313920
2016-04-20T21:11:26
2016-04-20T21:11:26
56,053,807
0
0
null
null
null
null
UTF-8
C++
false
false
1,029
cc
#include "particle.h" #include "screen.h" extern const int maxColumn = 80; extern const int minColumn = 0; Particle::Particle() : symbol('o'), position(0), speed(1) {} Particle::Particle(char symbol, double position, double speed) : symbol(symbol), position(position), speed(speed) {} void Particle::drawParticle(Screen& screen) const { screen[this->position] = this->symbol; } std::istream& operator>>(std::istream& in, Particle& p) { return in >> p.symbol >> p.position >> p.speed; } void NormalParticle::moveParticle() { position += speed; if (this->position >= maxColumn) { this->position = maxColumn; this->speed = -this->speed; } else if (this->position < minColumn) { this->position = minColumn; this->speed = -this->speed; } } void MagicParticle::moveParticle() { position += speed; if (this->position >= maxColumn) { this->position = minColumn; } else if (this->position < minColumn) { this->position = maxColumn; } }
[ "estarter@gmail.com" ]
estarter@gmail.com
0651439cbe248ff35c24b43cb8be62e50794aa94
190e9521edb3825ffc80e303743aad123df5985e
/BoostUTF/BoostUTF/unit_test.cpp
74077d628505c2e3a1eb0151211eb5b8bf7947c4
[]
no_license
yql612679/boost_test
27d12d5eecad782269a3fcce66f685861bb3fa16
85f24d138b372a3841f31c2b62ebb37acd40c352
refs/heads/master
2020-04-15T13:41:54.979637
2012-08-12T01:43:39
2012-08-12T01:43:39
null
0
0
null
null
null
null
GB18030
C++
false
false
1,828
cpp
#define BOOST_TEST_INCLUDED #include "boost/test/unit_test.hpp" #include "boost/smart_ptr.hpp" #include "boost/assert.hpp" #include "boost/assign.hpp" using namespace boost; #include <iostream> using namespace std; //全局测试夹具类 struct global_fixture { global_fixture() { cout << ("global setup\n"); } ~global_fixture() { cout << ("global teardown\n"); } }; //定义全局夹具类 BOOST_GLOBAL_FIXTURE(global_fixture) //开始测试套件s_smart_ptr BOOST_AUTO_TEST_SUITE(s_smart_ptr) //测试用例1:t_scoped_ptr BOOST_AUTO_TEST_CASE(t_scoped_ptr) { boost::scoped_ptr<int> p(new int(875)); BOOST_CHECK(p); BOOST_CHECK_EQUAL(*p, 875); p.reset(); BOOST_REQUIRE(p == 0); } //测试用例2:t_shared_ptr BOOST_AUTO_TEST_CASE(t_shared_ptr) { boost::shared_ptr<int> p = boost::make_shared<int>(100); BOOST_CHECK(p); BOOST_REQUIRE_EQUAL(*p, 100); BOOST_REQUIRE_EQUAL(p.use_count(), 1); boost::shared_ptr<int> p2(p); BOOST_REQUIRE_EQUAL(p2, p); BOOST_REQUIRE_EQUAL(p2.use_count(), 2); *p2 = 255; BOOST_REQUIRE_EQUAL(*p, 255); BOOST_REQUIRE_GT(*p, 200); } BOOST_AUTO_TEST_SUITE_END() //测试套件夹具类 struct assign_fixture { assign_fixture() { cout <<("suit setup\n"); } ~assign_fixture() { cout << ("suit teardown\n"); } vector<int> v; }; ///////////////////////////////////////////////////////////// //BOOST_AUTO_TEST_SUITE(s_assign) //定义套件级别的夹具 BOOST_FIXTURE_TEST_SUITE(s_assign, assign_fixture) BOOST_AUTO_TEST_CASE(t_assign1) { using namespace boost::assign; v += 1,2,3,4; BOOST_CHECK_EQUAL(v.size(), 4); BOOST_CHECK_EQUAL(v[2], 3); } BOOST_AUTO_TEST_CASE(t_assign2) { using namespace boost::assign; boost::assign::push_back(v)(10)(20)(30); BOOST_CHECK_EQUAL(v.empty(), false); BOOST_CHECK_LT(v[0], v[1]); } BOOST_AUTO_TEST_SUITE_END()
[ "yql1223@126.com" ]
yql1223@126.com
ece342a54144d3d7ee54e29cbca2070628505602
72ce1f2f0e768e5f14682e55a0ca2e74a1077ae7
/Source/Project64-core/Plugins/PluginClass.cpp
1fee7ddfcd1b06e3b43100ff627809d95309e96f
[]
no_license
AmbientMalice/project64
5d0045559288e46c5db72c74f7559f86be433f4c
6ae6889186d5cddb30a04d5cfc34f905ad449353
refs/heads/master
2021-01-18T09:30:32.934499
2016-01-30T04:14:22
2016-01-30T04:14:22
31,362,852
0
0
null
2015-03-05T01:26:01
2015-02-26T10:50:48
C++
UTF-8
C++
false
false
15,326
cpp
/**************************************************************************** * * * Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * * License: * * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * * * ****************************************************************************/ #include "stdafx.h" #include <Project64-core/N64System/SystemGlobals.h> #include <Project64-core/N64System/N64Class.h> #include <Project64-core/Plugins/PluginClass.h> #include <Common/path.h> CPlugins::CPlugins(const stdstr & PluginDir) : m_MainWindow(NULL), m_SyncWindow(NULL), m_PluginDir(PluginDir), m_Gfx(NULL), m_Audio(NULL), m_RSP(NULL), m_Control(NULL) { CreatePlugins(); g_Settings->RegisterChangeCB(Plugin_RSP_Current, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->RegisterChangeCB(Plugin_GFX_Current, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->RegisterChangeCB(Plugin_AUDIO_Current, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->RegisterChangeCB(Plugin_CONT_Current, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->RegisterChangeCB(Plugin_UseHleGfx, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->RegisterChangeCB(Plugin_UseHleAudio, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->RegisterChangeCB(Game_EditPlugin_Gfx, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->RegisterChangeCB(Game_EditPlugin_Audio, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->RegisterChangeCB(Game_EditPlugin_Contr, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->RegisterChangeCB(Game_EditPlugin_RSP, this, (CSettings::SettingChangedFunc)PluginChanged); } CPlugins::~CPlugins(void) { g_Settings->UnregisterChangeCB(Plugin_RSP_Current, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->UnregisterChangeCB(Plugin_GFX_Current, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->UnregisterChangeCB(Plugin_AUDIO_Current, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->UnregisterChangeCB(Plugin_CONT_Current, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->UnregisterChangeCB(Plugin_UseHleGfx, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->UnregisterChangeCB(Plugin_UseHleAudio, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->UnregisterChangeCB(Game_EditPlugin_Gfx, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->UnregisterChangeCB(Game_EditPlugin_Audio, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->UnregisterChangeCB(Game_EditPlugin_Contr, this, (CSettings::SettingChangedFunc)PluginChanged); g_Settings->UnregisterChangeCB(Game_EditPlugin_RSP, this, (CSettings::SettingChangedFunc)PluginChanged); DestroyGfxPlugin(); DestroyAudioPlugin(); DestroyRspPlugin(); DestroyControlPlugin(); } void CPlugins::PluginChanged(CPlugins * _this) { if (g_Settings->LoadBool(Game_TempLoaded) == true) { return; } bool bGfxChange = _stricmp(_this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()) != 0; bool bAudioChange = _stricmp(_this->m_AudioFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()) != 0; bool bRspChange = _stricmp(_this->m_RSPFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()) != 0; bool bContChange = _stricmp(_this->m_ControlFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()) != 0; if (bGfxChange || bAudioChange || bRspChange || bContChange) { if (g_Settings->LoadBool(GameRunning_CPU_Running)) { //Ensure that base system actually exists before we go triggering the event if (g_BaseSystem) { g_BaseSystem->ExternalEvent(SysEvent_ChangePlugins); } } else { _this->Reset(NULL); } } } template <typename plugin_type> static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceModuleProject64 TraceLevel, const char * type) { if (plugin != NULL) { return; } FileName = g_Settings->LoadStringVal(PluginSettingID); CPath PluginFileName(PluginDir, FileName.c_str()); plugin = new plugin_type(); if (plugin) { WriteTrace(TraceLevel, TraceDebug, "%s Loading (%s): Starting", type, (const char *)PluginFileName); if (plugin->Load(PluginFileName)) { WriteTrace(TraceLevel, TraceDebug, "%s Current Ver: %s", type, plugin->PluginName()); g_Settings->SaveString(PluginVerSettingID, plugin->PluginName()); } else { WriteTrace(TraceError, TraceDebug, "Failed to load %s", (const char *)PluginFileName); delete plugin; plugin = NULL; } WriteTrace(TraceLevel, TraceDebug, "%s Loading Done", type); } else { WriteTrace(TraceError, TraceDebug, "Failed to allocate %s plugin", type); } } void CPlugins::CreatePlugins(void) { LoadPlugin(Game_Plugin_Gfx, Plugin_GFX_CurVer, m_Gfx, m_PluginDir.c_str(), m_GfxFile, TraceGFXPlugin, "GFX"); LoadPlugin(Game_Plugin_Audio, Plugin_AUDIO_CurVer, m_Audio, m_PluginDir.c_str(), m_AudioFile, TraceAudioPlugin, "Audio"); LoadPlugin(Game_Plugin_RSP, Plugin_RSP_CurVer, m_RSP, m_PluginDir.c_str(), m_RSPFile, TraceRSPPlugin, "RSP"); LoadPlugin(Game_Plugin_Controller, Plugin_CONT_CurVer, m_Control, m_PluginDir.c_str(), m_ControlFile, TraceControllerPlugin, "Control"); //Enable debugger if (m_RSP != NULL && m_RSP->EnableDebugging) { WriteTrace(TraceRSPPlugin, TraceInfo, "EnableDebugging starting"); m_RSP->EnableDebugging(bHaveDebugger()); WriteTrace(TraceRSPPlugin, TraceInfo, "EnableDebugging done"); } } void CPlugins::GameReset(void) { if (m_Gfx) { m_Gfx->GameReset(); } if (m_Audio) { m_Audio->GameReset(); } if (m_RSP) { m_RSP->GameReset(); } if (m_Control) { m_Control->GameReset(); } } void CPlugins::DestroyGfxPlugin(void) { if (m_Gfx == NULL) { return; } WriteTrace(TraceGFXPlugin, TraceInfo, "before delete m_Gfx"); delete m_Gfx; WriteTrace(TraceGFXPlugin, TraceInfo, "after delete m_Gfx"); m_Gfx = NULL; // g_Settings->UnknownSetting_GFX = NULL; DestroyRspPlugin(); } void CPlugins::DestroyAudioPlugin(void) { if (m_Audio == NULL) { return; } WriteTrace(TraceAudioPlugin, TraceDebug, "before close"); m_Audio->Close(); WriteTrace(TraceAudioPlugin, TraceDebug, "before delete"); delete m_Audio; WriteTrace(TraceAudioPlugin, TraceDebug, "after delete"); m_Audio = NULL; WriteTrace(TraceAudioPlugin, TraceDebug, "before DestroyRspPlugin"); // g_Settings->UnknownSetting_AUDIO = NULL; DestroyRspPlugin(); WriteTrace(TraceAudioPlugin, TraceDebug, "after DestroyRspPlugin"); } void CPlugins::DestroyRspPlugin(void) { if (m_RSP == NULL) { return; } WriteTrace(TraceRSPPlugin, TraceDebug, "before close"); m_RSP->Close(); WriteTrace(TraceRSPPlugin, TraceDebug, "before delete"); delete m_RSP; m_RSP = NULL; WriteTrace(TraceRSPPlugin, TraceDebug, "after delete"); // g_Settings->UnknownSetting_RSP = NULL; } void CPlugins::DestroyControlPlugin(void) { if (m_Control == NULL) { return; } WriteTrace(TraceControllerPlugin, TraceDebug, "before close"); m_Control->Close(); WriteTrace(TraceControllerPlugin, TraceDebug, "before delete"); delete m_Control; m_Control = NULL; WriteTrace(TraceControllerPlugin, TraceDebug, "after delete"); // g_Settings->UnknownSetting_CTRL = NULL; } void CPlugins::SetRenderWindows(RenderWindow * MainWindow, RenderWindow * SyncWindow) { m_MainWindow = MainWindow; m_SyncWindow = SyncWindow; } void CPlugins::RomOpened(void) { m_Gfx->RomOpened(); m_RSP->RomOpened(); m_Audio->RomOpened(); m_Control->RomOpened(); } void CPlugins::RomClosed(void) { m_Gfx->RomClose(); m_RSP->RomClose(); m_Audio->RomClose(); m_Control->RomClose(); } bool CPlugins::Initiate(CN64System * System) { WriteTrace(TracePlugins, TraceDebug, "Start"); //Check to make sure we have the plugin available to be used if (m_Gfx == NULL) { return false; } if (m_Audio == NULL) { return false; } if (m_RSP == NULL) { return false; } if (m_Control == NULL) { return false; } WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Starting"); if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Done"); WriteTrace(TraceAudioPlugin, TraceDebug, "Audio Initiate Starting"); if (!m_Audio->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceAudioPlugin, TraceDebug, "Audio Initiate Done"); WriteTrace(TraceControllerPlugin, TraceDebug, "Control Initiate Starting"); if (!m_Control->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceControllerPlugin, TraceDebug, "Control Initiate Done"); WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Starting"); if (!m_RSP->Initiate(this, System)) { return false; } WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Done"); WriteTrace(TracePlugins, TraceDebug, "Done"); return true; } bool CPlugins::ResetInUiThread(CN64System * System) { return m_MainWindow->ResetPluginsInUiThread(this, System); } bool CPlugins::Reset(CN64System * System) { WriteTrace(TracePlugins, TraceDebug, "Start"); bool bGfxChange = _stricmp(m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()) != 0; bool bAudioChange = _stricmp(m_AudioFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()) != 0; bool bRspChange = _stricmp(m_RSPFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()) != 0; bool bContChange = _stricmp(m_ControlFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()) != 0; //if GFX and Audio has changed we also need to force reset of RSP if (bGfxChange || bAudioChange) bRspChange = true; if (bGfxChange) { DestroyGfxPlugin(); } if (bAudioChange) { DestroyAudioPlugin(); } if (bRspChange) { DestroyRspPlugin(); } if (bContChange) { DestroyControlPlugin(); } CreatePlugins(); if (m_Gfx && bGfxChange) { WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Starting"); if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Done"); } if (m_Audio && bAudioChange) { WriteTrace(TraceAudioPlugin, TraceDebug, "Audio Initiate Starting"); if (!m_Audio->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceAudioPlugin, TraceDebug, "Audio Initiate Done"); } if (m_Control && bContChange) { WriteTrace(TraceControllerPlugin, TraceDebug, "Control Initiate Starting"); if (!m_Control->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceControllerPlugin, TraceDebug, "Control Initiate Done"); } if (m_RSP && bRspChange) { WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Starting"); if (!m_RSP->Initiate(this, System)) { return false; } WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Done"); } WriteTrace(TracePlugins, TraceDebug, "Done"); return true; } void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) { switch (Type) { case PLUGIN_TYPE_RSP: if (m_RSP == NULL || m_RSP->DllConfig == NULL) { break; } if (!m_RSP->Initialized()) { if (!m_RSP->Initiate(this, NULL)) { break; } } m_RSP->DllConfig(hParent); break; case PLUGIN_TYPE_GFX: if (m_Gfx == NULL || m_Gfx->DllConfig == NULL) { break; } if (!m_Gfx->Initialized()) { if (!m_Gfx->Initiate(NULL, m_MainWindow)) { break; } } m_Gfx->DllConfig(hParent); break; case PLUGIN_TYPE_AUDIO: if (m_Audio == NULL || m_Audio->DllConfig == NULL) { break; } if (!m_Audio->Initialized()) { if (!m_Audio->Initiate(NULL, m_MainWindow)) { break; } } m_Audio->DllConfig(hParent); break; case PLUGIN_TYPE_CONTROLLER: if (m_Control == NULL || m_Control->DllConfig == NULL) { break; } if (!m_Control->Initialized()) { if (!m_Control->Initiate(NULL, m_MainWindow)) { break; } } m_Control->DllConfig(hParent); break; } } void DummyCheckInterrupts(void) { } void DummyFunction(void) { } bool CPlugins::CopyPlugins(const stdstr & DstDir) const { //Copy GFX Plugin CPath srcGfxPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()); CPath dstGfxPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()); if (!dstGfxPlugin.DirectoryExists()) { dstGfxPlugin.DirectoryCreate(); } if (!srcGfxPlugin.CopyTo(dstGfxPlugin)) { return false; } //Copy m_Audio Plugin CPath srcAudioPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()); CPath dstAudioPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()); if (!dstAudioPlugin.DirectoryExists()) { dstAudioPlugin.DirectoryCreate(); } if (!srcAudioPlugin.CopyTo(dstAudioPlugin)) { return false; } //Copy RSP Plugin CPath srcRSPPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()); CPath dstRSPPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()); if (!dstRSPPlugin.DirectoryExists()) { dstRSPPlugin.DirectoryCreate(); } if (!srcRSPPlugin.CopyTo(dstRSPPlugin)) { return false; } //Copy Controller Plugin CPath srcContPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()); CPath dstContPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()); if (!dstContPlugin.DirectoryExists()) { dstContPlugin.DirectoryCreate(); } if (!srcContPlugin.CopyTo(dstContPlugin)) { return false; } return true; }
[ "zilmar@pj64-emu.com" ]
zilmar@pj64-emu.com
cd2694ea2cb55574bb243a2d08c55fa4d47e81fa
1fba7a3fa4a31612af4c598baa8ddc7c98444aed
/src/chat_printer.cpp
03d8345657b4d5722d0dbc344be2d3e6d687328e
[ "MIT" ]
permissive
ulyanin/GOS_cpp_chat_server_client
369ed475f885f93a467d994d480310d9dc6bf1f5
0cbc78ad29e30ec9c4052fcf2736759b0bd82787
refs/heads/main
2023-02-19T19:10:56.385962
2021-01-19T18:09:32
2021-01-19T18:09:32
330,886,204
0
0
null
null
null
null
UTF-8
C++
false
false
48
cpp
#include "chat_printer.h" namespace NChat { }
[ "ulyanin1997@gmail.com" ]
ulyanin1997@gmail.com
5fa0c08bc2d2269da7f8685e138972fe2d6814cd
86bfae94def1ca36bec20ab0ecadd72c1f97272e
/src/post/main/Main.hpp
1046c0d423c646c940e4d3c60574cf159da014f9
[ "BSD-3-Clause" ]
permissive
ucd-plse/mpi-error-prop
22b947ff5a51c86817b973e55c68e4a2cf19e664
4367df88bcdc4d82c9a65b181d0e639d04962503
refs/heads/master
2020-09-17T06:24:19.740006
2020-01-31T21:48:35
2020-01-31T21:48:35
224,017,672
6
0
null
null
null
null
UTF-8
C++
false
false
488
hpp
#ifndef MAIN_GUARD #define MAIN_GUARD #include "Message.hpp" extern bool verbose; extern bool debugging; extern bool return_values; extern bool info; extern bool hexastore; extern bool csv; extern bool dereference; extern bool iserr; extern bool handled; extern bool input_output; extern bool predicates; extern bool option_assignment; extern Message::Formatters selected_formatter; enum PrintDirection { None, Backward, Forward }; extern PrintDirection print; #endif // !MAIN_GUARD
[ "dcdefreez@ucdavis.edu" ]
dcdefreez@ucdavis.edu
c8f3aa77beac0aa820d8c70dcd57e4b1da0557df
2a7e77565c33e6b5d92ce6702b4a5fd96f80d7d0
/fuzzedpackages/stepR/src/SmallScales.cpp
bf3376b6cdca5b68f370c9e7a737cab50e8b90f8
[]
no_license
akhikolla/testpackages
62ccaeed866e2194652b65e7360987b3b20df7e7
01259c3543febc89955ea5b79f3a08d3afe57e95
refs/heads/master
2023-02-18T03:50:28.288006
2021-01-18T13:23:32
2021-01-18T13:23:32
329,981,898
7
1
null
null
null
null
UTF-8
C++
false
false
2,929
cpp
#include "SmallScales.h" # include <algorithm> /*************** * class small scales * maintains additional finding on small scales * Florian Pein, 2017 ***************/ std::list<SmallScales> SmallScales::listSmallScales_; std::list<SmallScales>::iterator SmallScales::it_; SmallScales::SmallScales() {} SmallScales::SmallScales(unsigned int left, unsigned int right, unsigned int li, unsigned int ri, double stat, bool noDeconvolution) : left_(left), right_(right), li_(li), ri_(ri), stat_(stat), noDeconvolution_(noDeconvolution) {} unsigned int SmallScales::left() { return left_; } unsigned int SmallScales::right() { return right_; } unsigned int SmallScales::li() { return li_; } unsigned int SmallScales::ri() { return ri_; } double SmallScales::stat() { return stat_; } bool SmallScales::noDeconvolution() { return noDeconvolution_; } void SmallScales::update(unsigned int start, unsigned int len, double stat) { // find first segment that touches, intersets or is right of the new one while (it_ != listSmallScales_.end() && it_ -> ri() < start) { ++it_; } SmallScales newSegment = SmallScales(start + 1L, start + len + 1L, start + 1L, start + len + 1L, stat, false); // consider all segments for which li() <= start + len + 2L (all other are right of it with a gap) std::list<SmallScales>::iterator it(it_); unsigned int number = 0u; bool replace = true; while (it != listSmallScales_.end() && it -> li() <= start + len + 2L) { ++number; newSegment.extend(it -> li(), it -> ri()); if (it -> stat() >= stat) { replace = false; } ++it; } if (number == 0u) { listSmallScales_.insert(it_, newSegment); --it_; } else { if (replace) { if (number > 1u) { it_ -> replace(start, len, newSegment.li(), newSegment.ri(), stat, true); it = it_; ++it; while (it != listSmallScales_.end() && it -> left() <= start + len + 2L) { it = listSmallScales_.erase(it); } } else { it_ -> replace(start, len, newSegment.li(), newSegment.ri(), stat, false); } } else { it = it_; while (it != listSmallScales_.end() && it -> li() <= start + len + 2L) { it -> extend(start + 1L, start + len + 1L); ++ it; } } } } void SmallScales::replace(unsigned int start, unsigned int len, unsigned int li, unsigned int ri, double stat, bool noDe) { left_ = start + 1; right_ = start + len + 1; li_ = li; ri_ = ri; stat_ = stat; if (noDe) { noDeconvolution_ = true; } } void SmallScales::extend(unsigned int li, unsigned int ri) { li_ = std::min(li_, li); ri_ = std::max(ri_, ri); } void SmallScales::cleanUpGlobalVariables() { std::list<SmallScales> tmpListSmallScales; listSmallScales_.swap(tmpListSmallScales); }
[ "akhilakollasrinu424jf@gmail.com" ]
akhilakollasrinu424jf@gmail.com
9ef332b6201aada5b35cbd6b1c1f30369e6f8c51
3c22dd56cbdedeb8b827d7c26ae44f2dd676adaf
/inc/system/TestExecutionAlgorithm.hpp
2a3d55cf80c6be2b6e4e17354ca82d34e3bfa0a6
[]
no_license
lee20171130/x9_mipi_tof_sunny_part
fb3244a1838ec53f52db088d921b486076e9d4f5
21f11df4d8649d1590a4e8f151731e626c975d8a
refs/heads/master
2021-09-14T01:36:15.091923
2018-05-03T06:41:00
2018-05-03T06:41:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,285
hpp
/****************************************************************************\ * Copyright (C) 2016 pmdtechnologies ag * * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A * PARTICULAR PURPOSE. * \****************************************************************************/ #pragma once #include <memory> #include <functional> #include <string> #include "system/definitions.hpp" class TestExecutionAlgorithm; using TestExecutionAlgorithmPtr = std::unique_ptr<TestExecutionAlgorithm>; /** \brief base class for TestExecutionAlgorithms * * This class is the base of each TestExecutionAlgorithm and provides the * common functions of TestExecutionAlgorithms. * The idea behind TestExecutionAlgorithm is to provide a common interface * for the kind of tests that we do on the processing algorithms. * An specific implementation of an TestExecutionAlgorithm must call initTestSeries(noOfTests) * to set up everything for noOfTest consecutive calls of runTest(). Afterwards an implementation * must call runTest() maximal noOfTests times. This call sequence can be arbitrarily repeated. * * To use a TestExecutionAlgorithm in a test case get a TestExecutionAlgorithm instance * via TestExecutionAlgorithmFabric. if necessary assign an appropriate init function via * setInitTestSeries(). Assign the actual call that should be tested via setTestFunction(). * run the actual test by calling run(). Afterwards you can check your input and output values * as necessary. */ class TestExecutionAlgorithm { public: /** \brief default constructor * * */ TestExecutionAlgorithm() = default; /** \brief default destructor * * */ virtual ~TestExecutionAlgorithm() = default; using initSeriesType = std::function<void (size_t noOfTests) >; //! type of the init function using testFunctionType = std::function<void (size_t testIndex) >; //! type of the test function /** \brief starts the actual execution * * \return virtual void * */ virtual void run() = 0; /** \brief method clones the object without copying the functors * * \return TestExecutionAlgorithmPtr a clone of the object without the functors * */ virtual TestExecutionAlgorithmPtr cloneEmpty() = 0; /** \brief method returns the type name of the underlying TestExecutionAlgorithm implementation * * \return the type name of the underlying TestExecutionAlgorithm implementation as string * */ virtual std::string getTestTypeName() = 0; /** \brief set the function for initializing the test data * * \param initTestSeries the functor of the actual init function * */ void setInitTestSeries (initSeriesType initTestSeries); /** \brief method to get the init functions of the algorithm * * \return initSeriesType A functor to the actual init function. * If no function is set, a nullptr functor is returned. * */ initSeriesType getInitTestSeries() const; /** \brief set the function that runs the actual call to test * * \param testFunction the functor of the actual call to test * */ void setTestFunction (testFunctionType testFunction); /** \brief method to get the test functor of the algorithm * * \return testFunctionType A functor to the actual test function. * If no function is set, a nullptr functor is returned. * */ testFunctionType getTestFunction() const; /** \brief sets the name of the current test * * \param name The name of the test. * * Sets the name of the Test that should be executed. This can be used by the * TestExecutionAlgorithm in output or messages. */ void setTestName (const std::string &name); /** \brief returns the name of test * * \return std::string the name of the test as set by setTestName(). * Returns an empty string if no name is set. * */ std::string getTestName() const; protected: /** \brief method encapsulates the call of initTestSeriesFunc * * \param size_t noOfTests no of consecutive runTest() calls * */ inline void initTestSeries (size_t noOfTests) { if (m_initTestSeriesFunc) { m_initTestSeriesFunc (noOfTests); } } /** method encapsulates the call of testFunction * * \param size_t testIndex index of of nth consecutive call. * */ inline void runTest (size_t testIndex) { m_testFunction (testIndex); } private: initSeriesType m_initTestSeriesFunc; //! functor of the initTestSeries function. testFunctionType m_testFunction; //! functor of the actual test function. std::string m_TestName = ""; //! the name of the test. }; struct TestNameEmpty: public std::exception { virtual const char* what() const NOEXCEPT override { return "Test name is empty."; } };
[ "zhangw66@outlook.com" ]
zhangw66@outlook.com
341f8dfdf10050f1c89e8e79e66e3c75eaf266e3
87706d9fd69e4d2216e9022939ca9e6b2443a4c6
/src/scene.cpp
562744477178019b344f1f867a773c67c30612aa
[]
no_license
t1101675/PPM-Render
977b408c49589cbf4927f8add11c311b626bc8ef
eea40978ff41cb40e3fa1f11c3a6f02314babe29
refs/heads/master
2020-06-18T07:54:20.245918
2019-07-11T02:07:26
2019-07-11T02:07:26
196,222,753
1
0
null
null
null
null
UTF-8
C++
false
false
2,573
cpp
#include <json/json.h> #include "scene.h" #include "utils.h" #include "ball.hpp" #include "plane.hpp" #include "b_obj.hpp" #include "sub_ball.hpp" #include "mesh_obj.hpp" Scene::Scene(const Color& Ia) { this->Ia = Ia; } Scene::~Scene() { for (int i = 0; i < objs.size(); ++i) { if (objs[i]->fromJson) { delete objs[i]; } } } void Scene::addObj(Object* obj) { objs.push_back(obj); } void Scene::load(const Json::Value& config) { this->Ia = jArr2Vec3(config["eI"]); Json::Value sourcesConf = config["sources"]; for (int i = 0; i < sourcesConf.size(); ++i) { DiskPlane* s = new DiskPlane(); s->load(sourcesConf[i]); s->fromJson = true; this->addSource(s); } Json::Value objsConf = config["objs"]; for (int i = 0; i < objsConf.size(); ++i) { std::string type = objsConf[i]["type"].asString(); if (type == "ball") { Ball* ball = new Ball(); ball->load(objsConf[i]); ball->fromJson = true; this->addObj(ball); } else if (type == "sub_ball") { SubBall* subBall = new SubBall(); subBall->load(objsConf[i]); subBall->fromJson = true; this->addObj(subBall); } else if (type == "plane") { Plane* plane = new Plane(); plane->load(objsConf[i]); plane->fromJson = true; this->addObj(plane); } else if (type == "bezier") { BezierObj* bObj = new BezierObj(); bObj->load(objsConf[i]); bObj->fromJson = true; this->addObj(bObj); } else if (type == "mesh") { MeshObj* meshObj = new MeshObj(); meshObj->load(objsConf[i], objs); meshObj->fromJson = true; this->addObj(meshObj); } else { std::cout << "invalid type: " << type << std::endl; } } int* objIndices = new int[objs.size()]; for (int i = 0; i < objs.size(); ++i) { objIndices[i] = i; } std::cout << objs.size() << std::endl; objKdTree.buildTree(objs.data(), objIndices, objs.size()); std::cout << "[info] Build object kdtree complete" << std::endl; delete[] objIndices; } void Scene::addSource(Object* s) { sources.push_back(s); objs.push_back(s); } Light Scene::generateLight(unsigned short* X) { int r = int(erand48(X) * sources.size()); Object* source = sources[r]; return source->generateLight(X); }
[ "gu-yx17@mails.tsinghua.edu.cn" ]
gu-yx17@mails.tsinghua.edu.cn
a046592521e36f059a8265394fe02db83e66e6f1
cb23f2682aea2ab5c5484aaec420fe2f00c8aab9
/win32_prj/vc6/xclannad/SDL_win32_main.cpp
d412fe9de1b622bde0a89992eed6c79bd511a498
[]
no_license
athna/xclannad_fork
41d6282414736c44709d95fd8522a1a81ea908b2
8e6766eb96efcea2f735ab05897b42a4afe0a14e
refs/heads/master
2021-09-18T22:34:28.827348
2018-07-21T02:02:15
2018-07-21T02:02:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,210
cpp
/* SDL_main.c, placed in the public domain by Sam Lantinga 4/13/98 The WinMain function -- calls your program's main() function Customised to handle stdout/stderr redirection in a UAC-compliant way by Peter Jolly, 2006-11-22 */ #include <stdio.h> #include <stdlib.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> typedef HRESULT (WINAPI *GETFOLDERPATH)(HWND, int, HANDLE, DWORD, LPTSTR); #ifdef _WIN32_WCE # define DIR_SEPARATOR TEXT("\\") # undef _getcwd # define _getcwd(str,len) wcscpy(str,TEXT("")) # define setbuf(f,b) # define setvbuf(w,x,y,z) # define fopen _wfopen # define freopen _wfreopen # define remove(x) DeleteFile(x) #else # define DIR_SEPARATOR TEXT("/") # include <direct.h> #endif /* Include the SDL main definition header */ #include "SDL.h" #include "SDL_main.h" #ifdef main # ifndef _WIN32_WCE_EMULATION # undef main # endif /* _WIN32_WCE_EMULATION */ #endif /* main */ /* The standard output files */ #define STDOUT_FILE TEXT("stdout.txt") #define STDERR_FILE TEXT("stderr.txt") #ifndef NO_STDIO_REDIRECT # ifdef _WIN32_WCE static wchar_t outputPath[MAX_PATH]; static wchar_t stdoutPath[MAX_PATH]; static wchar_t stderrPath[MAX_PATH]; # else static char outputPath[MAX_PATH]; static char stdoutPath[MAX_PATH]; static char stderrPath[MAX_PATH]; # endif #endif #if defined(_WIN32_WCE) && _WIN32_WCE < 300 /* seems to be undefined in Win CE although in online help */ #define isspace(a) (((CHAR)(a) == ' ') || ((CHAR)(a) == '\t')) #endif /* _WIN32_WCE < 300 */ /* Parse a command line buffer into arguments */ static int ParseCommandLine(char *cmdline, char **argv) { char *bufp; int argc; argc = 0; for ( bufp = cmdline; *bufp; ) { /* Skip leading whitespace */ while ( isspace(*bufp) ) { ++bufp; } /* Skip over argument */ if ( *bufp == '"' ) { ++bufp; if ( *bufp ) { if ( argv ) { argv[argc] = bufp; } ++argc; } /* Skip over word */ while ( *bufp && (*bufp != '"') ) { ++bufp; } } else { if ( *bufp ) { if ( argv ) { argv[argc] = bufp; } ++argc; } /* Skip over word */ while ( *bufp && (isalnum(*bufp) || !isspace(*bufp)) ) { ++bufp; } } if ( *bufp ) { if ( argv ) { *bufp = '\0'; } ++bufp; } } if ( argv ) { argv[argc] = NULL; } return(argc); } /* Show an error message */ static void ShowError(const char *title, const char *message) { /* If USE_MESSAGEBOX is defined, you need to link with user32.lib */ #ifdef USE_MESSAGEBOX MessageBox(NULL, message, title, MB_ICONEXCLAMATION|MB_OK); #endif fprintf(stderr, "[System] %s: %s\n", title, message); } /* Pop up an out of memory message, returns to Windows */ static BOOL OutOfMemory(void) { ShowError("Fatal Error", "Out of memory - aborting"); return FALSE; } /* SDL_Quit() shouldn't be used with atexit() directly because calling conventions may differ... */ static void cleanup(void) { SDL_Quit(); } /* Remove the output files if there was no output written */ static void cleanup_output(void) { #ifndef NO_STDIO_REDIRECT FILE *file; int empty; #endif /* Flush the output in case anything is queued */ fclose(stdout); fclose(stderr); #ifndef NO_STDIO_REDIRECT /* See if the files have any output in them */ if ( stdoutPath[0] ) { file = fopen(stdoutPath, TEXT("rb")); if ( file ) { empty = (fgetc(file) == EOF) ? 1 : 0; fclose(file); if ( empty ) { remove(stdoutPath); } } } if ( stderrPath[0] ) { file = fopen(stderrPath, TEXT("rb")); if ( file ) { empty = (fgetc(file) == EOF) ? 1 : 0; fclose(file); if ( empty ) { remove(stderrPath); } } } #endif } #if defined(_MSC_VER) && !defined(_WIN32_WCE) /* The VC++ compiler needs main defined */ #define console_main main #endif /* This is where execution begins [console apps] */ int console_main(int argc, char *argv[]) { size_t n; char *bufp, *appname; int status; /* Get the class name from argv[0] */ appname = argv[0]; if ( (bufp=SDL_strrchr(argv[0], '\\')) != NULL ) { appname = bufp+1; } else if ( (bufp=SDL_strrchr(argv[0], '/')) != NULL ) { appname = bufp+1; } if ( (bufp=SDL_strrchr(appname, '.')) == NULL ) n = SDL_strlen(appname); else n = (bufp-appname); bufp = SDL_stack_alloc(char, n+1); if ( bufp == NULL ) { return OutOfMemory(); } SDL_strlcpy(bufp, appname, n+1); appname = bufp; /* Load SDL dynamic link library */ if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) { ShowError("WinMain() error", SDL_GetError()); return(FALSE); } atexit(cleanup_output); atexit(cleanup); /* Sam: We still need to pass in the application handle so that DirectInput will initialize properly when SDL_RegisterApp() is called later in the video initialization. */ SDL_SetModuleHandle(GetModuleHandle(NULL)); /* Run the application main() code */ status = SDL_main(argc, argv); /* Exit cleanly, calling atexit() functions */ exit(status); /* Hush little compiler, don't you cry... */ return 0; } /* This is where execution begins [windowed apps] */ #ifdef _WIN32_WCE int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR szCmdLine, int sw) #else int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) #endif { HINSTANCE handle; char **argv; int argc; char *cmdline; DWORD pathlen = 0; //shutting up gcc warnings #ifdef _WIN32_WCE wchar_t *bufp; int nLen; #else char *bufp; size_t nLen; #endif #ifndef NO_STDIO_REDIRECT FILE *newfp; #endif /* Start up DDHELP.EXE before opening any files, so DDHELP doesn't keep them open. This is a hack.. hopefully it will be fixed someday. DDHELP.EXE starts up the first time DDRAW.DLL is loaded. */ handle = LoadLibrary(TEXT("DDRAW.DLL")); if ( handle != NULL ) { FreeLibrary(handle); } #ifndef NO_STDIO_REDIRECT outputPath[0] = 0; HMODULE shdll = LoadLibrary("shfolder"); if (shdll) { GETFOLDERPATH gfp = (GETFOLDERPATH)GetProcAddress(shdll, "SHGetFolderPathA"); if (gfp) { char hpath[MAX_PATH]; #define CSIDL_COMMON_APPDATA 0x0023 // for [Profiles]/All Users/Application Data #define CSIDL_APPDATA 0x001a // for [Profiles]/[User]/Application Data HRESULT res = gfp(0, CSIDL_APPDATA, 0, 0, hpath); //now user-based if (res != S_FALSE && res != E_FAIL && res != E_INVALIDARG) { sprintf(outputPath, "%s\\XClannad\\", hpath); CreateDirectory(outputPath, 0); pathlen = strlen(outputPath); OutputDebugString(outputPath); OutputDebugString("\n"); } } FreeLibrary(shdll); } if (outputPath[0] == 0) pathlen = GetModuleFileName(NULL, outputPath, SDL_arraysize(outputPath)); while ( pathlen > 0 && outputPath[pathlen] != '\\' ) { --pathlen; } outputPath[pathlen] = '\0'; #ifdef _WIN32_WCE wcsncpy( stdoutPath, outputPath, SDL_arraysize(stdoutPath) ); wcsncat( stdoutPath, DIR_SEPARATOR STDOUT_FILE, SDL_arraysize(stdoutPath) ); #else SDL_strlcpy( stdoutPath, outputPath, SDL_arraysize(stdoutPath) ); SDL_strlcat( stdoutPath, DIR_SEPARATOR STDOUT_FILE, SDL_arraysize(stdoutPath) ); #endif /* Redirect standard input and standard output */ newfp = freopen(stdoutPath, TEXT("w"), stdout); #ifndef _WIN32_WCE if ( newfp == NULL ) { /* This happens on NT */ #if !defined(stdout) stdout = fopen(stdoutPath, TEXT("w")); #else newfp = fopen(stdoutPath, TEXT("w")); if ( newfp ) { *stdout = *newfp; } #endif } #endif /* _WIN32_WCE */ #ifdef _WIN32_WCE wcsncpy( stderrPath, outputPath, SDL_arraysize(stdoutPath) ); wcsncat( stderrPath, DIR_SEPARATOR STDOUT_FILE, SDL_arraysize(stdoutPath) ); #else SDL_strlcpy( stderrPath, outputPath, SDL_arraysize(stderrPath) ); SDL_strlcat( stderrPath, DIR_SEPARATOR STDERR_FILE, SDL_arraysize(stderrPath) ); #endif newfp = freopen(stderrPath, TEXT("w"), stderr); #ifndef _WIN32_WCE if ( newfp == NULL ) { /* This happens on NT */ #if !defined(stderr) stderr = fopen(stderrPath, TEXT("w")); #else newfp = fopen(stderrPath, TEXT("w")); if ( newfp ) { *stderr = *newfp; } #endif } #endif /* _WIN32_WCE */ setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* Line buffered */ setbuf(stderr, NULL); /* No buffering */ #endif /* !NO_STDIO_REDIRECT */ #ifdef _WIN32_WCE nLen = wcslen(szCmdLine)+128+1; bufp = SDL_stack_alloc(wchar_t, nLen*2); wcscpy (bufp, TEXT("\"")); GetModuleFileName(NULL, bufp+1, 128-3); wcscpy (bufp+wcslen(bufp), TEXT("\" ")); wcsncpy(bufp+wcslen(bufp), szCmdLine,nLen-wcslen(bufp)); nLen = wcslen(bufp)+1; cmdline = SDL_stack_alloc(char, nLen); if ( cmdline == NULL ) { return OutOfMemory(); } WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL); #else /* Grab the command line */ bufp = GetCommandLine(); nLen = SDL_strlen(bufp)+1; cmdline = SDL_stack_alloc(char, nLen); if ( cmdline == NULL ) { return OutOfMemory(); } SDL_strlcpy(cmdline, bufp, nLen); #endif /* Parse it into argv and argc */ argc = ParseCommandLine(cmdline, NULL); argv = SDL_stack_alloc(char*, argc+1); if ( argv == NULL ) { return OutOfMemory(); } ParseCommandLine(cmdline, argv); /* Run the main program (after a little SDL initialization) */ console_main(argc, argv); /* Hush little compiler, don't you cry... */ return 0; }
[ "weimingtom@qq.com" ]
weimingtom@qq.com
dfe5a215a4b92db05ace61cf5f94886417a30c7e
b6607ecc11e389cc56ee4966293de9e2e0aca491
/codeforces.com/Contests/246 div 2/D/D.cpp
6830c576fa20ceeb85a6f7fe0502209a143eebc5
[]
no_license
BekzhanKassenov/olymp
ec31cefee36d2afe40eeead5c2c516f9bf92e66d
e3013095a4f88fb614abb8ac9ba532c5e955a32e
refs/heads/master
2022-09-21T10:07:10.232514
2021-11-01T16:40:24
2021-11-01T16:40:24
39,900,971
5
0
null
null
null
null
UTF-8
C++
false
false
1,513
cpp
/**************************************** ** Solution by Bekzhan Kassenov ** ****************************************/ #include <bits/stdc++.h> using namespace std; #define F first #define S second #define MP make_pair #define all(x) (x).begin(), (x).end() #define fill(x, y) memset((x), y, sizeof(x)) typedef pair <int, int> PII; typedef vector <int> VI; typedef vector <VI> VVI; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const int MOD = 1000 * 1000 * 1000 + 7; const int INF = 2000 * 1000 * 1000; const double EPS = 1e-9; const double pi = acos(-1.0); const int maxn = 100010; template <typename T> inline T sqr(T n) { return (n * n); } char s[maxn]; int n, z[maxn], st[maxn]; vector <pair <int, int> > ans; int main() { #ifndef ONLINE_JUDGE freopen("in", "r", stdin); #endif gets(s); n = strlen(s); for (int i = 1, l = 0, r = 0; i < n; i++) { if (i <= r) z[i] = min(r - i + 1, z[i - l]); while (i + z[i] < n && s[z[i]] == s[i + z[i]]) z[i]++; if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1; st[i] = z[i]; } sort(st, st + n); for (int i = 1; i < n; i++) { if (z[n - i] == i) { ans.push_back(MP(i, n - (lower_bound(st, st + n, i) - st) + 1)); } } ans.push_back(MP(n, 1)); printf("%u\n", ans.size()); for (size_t i = 0; i < ans.size(); i++) printf("%d %d\n", ans[i].F, ans[i].S); return 0; }
[ "bekzhan.kassenov@nu.edu.kz" ]
bekzhan.kassenov@nu.edu.kz
9c789f4d14a56188a8bd5c4c972a2c797429b692
677c0b293022f34d85eb3478f05998f24f16d94f
/examples/string_hash.cpp
b5638c8ae404ec36f3d598e190237af1d506f62f
[ "MIT" ]
permissive
CMakeezer/petra
42945bceab569f2edd818f59031861a104a8c447
7db7eef381a20c91664553c28f57dfed96e32a50
refs/heads/master
2020-03-19T08:45:30.253879
2017-10-29T14:42:53
2017-10-29T14:42:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
900
cpp
// Copyright Jacqueline Kay 2017 // Distributed under the MIT License. // See accompanying LICENSE.md or https://opensource.org/licenses/MIT #include <iostream> #include "petra/string_literal.hpp" #include "petra/string_map.hpp" #include "petra/utilities.hpp" using namespace petra::literals; int main(int argc, char** argv) { if (argc < 2) { std::cout << "Please enter a test token!\n"; return 255; } const char* input = argv[1]; auto callback = [](auto&& token) { using T = std::decay_t<decltype(token)>; if constexpr (petra::utilities::is_error_type<T>()) { std::cout << "Could not hash input to a matching key.\n"; } else { std::cout << "hash value: " << T::value << "\n"; } }; auto map = petra::make_string_map(callback, "hello"_s, "goodbye"_s, "dog"_s, "fish"_s, "cat"_s); map(input); return 0; }
[ "jacquelinekay1@gmail.com" ]
jacquelinekay1@gmail.com
cd72c1dff100ac31a389c80c248c087cb488ac17
85c532a4b223f81e7e4a52387a84d80e4f29c8b3
/chapter04/4.3_Logical_and_Relational_Operators.cpp
5c3a3af1a0e54bb9a4fc04e6cdfb45335de244b4
[ "MIT" ]
permissive
alcret/Cpp-Primer
4c527891d7db73fc9138e8e3d1eac216ae1427cc
bc0e4f0c0fe45042ae367a28a87d03b5c3c787e3
refs/heads/master
2022-01-06T21:20:27.193408
2018-04-26T12:54:37
2018-04-26T12:54:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
181
cpp
/** * 4.3 逻辑和关系运算符 * @Author Bob * @Eamil 0haizhu0@gmail.com * @Date 2017/7/27 */ int main(){ /** * <,<=,>,>= * ==,!=,! * &&,|| */ }
[ "0haizhu0@gmail.com" ]
0haizhu0@gmail.com
35fa58ec45b3018f6285edb757fa4838276d108e
90bbcca1d7d1ff12ead222fa0cdba4ab4a62cc6d
/合并两个有序单链表.cpp
cb9f02294fa0459ab2cce31f2b6241f9450444ce
[]
no_license
Zhouyongkan/leetcode-
590a488f6e25c1bac8f80d97dc7a5540bd1f7584
700462c374be56c264b18a1c153fe95cde8e6441
refs/heads/master
2021-07-14T20:05:13.704400
2020-10-26T08:26:21
2020-10-26T08:26:21
219,739,776
0
0
null
null
null
null
UTF-8
C++
false
false
664
cpp
class Solution { public: ListNode* Merge(ListNode* pHead1, ListNode* pHead2) { ListNode* newhead = (ListNode*)malloc(sizeof(ListNode)); ListNode* cur = newhead; ListNode* del = newhead; while (pHead1 && pHead2) { if (pHead1->val <= pHead2->val) { ListNode* node = new ListNode(pHead1->val); cur->next = node; cur = node; pHead1 = pHead1->next; } else { ListNode* node = new ListNode(pHead2->val); cur->next = node; cur = node; pHead2 = pHead2->next; } } if (pHead1) { cur->next = pHead1; } else { cur->next = pHead2; } newhead = newhead->next; free(del); return newhead; } };
[ "1033378094@qq.com" ]
1033378094@qq.com
ed2ad23c82d559985f05e30ade2c8fa3965f12e9
2246a1fa8355aebe4f2e7a8f9c28fbc1ceac9739
/Exercise_1_3.cpp
818c6a03d26689a86a99701e4a6c76c7147d43ab
[]
no_license
BethIovine/BethPrimer
6a5418ad68a35436ba6e57cb4291f4d3c93fdba2
622c3947ee2c4361afef7d44fa6dd5ca690ac5b9
refs/heads/master
2023-06-03T10:59:34.184514
2021-06-20T14:36:08
2021-06-20T14:36:08
366,083,302
0
0
null
null
null
null
UTF-8
C++
false
false
113
cpp
#include <iostream> using namespace std; int main_1_3() { cout << "Hello World!" << endl; return 0; }
[ "18980406207@163.com" ]
18980406207@163.com
99149e0ff8950fb45dcf4be8da3122ac6a43b302
c0e9f18941ca50892c0a37c55663a2f8f5afa10b
/XMega_Code/include/OneWire.cpp
e48731b5814ae2a9823e43bad44e6bff5b47b658
[]
no_license
sandro2/xmega-qrp
bc3bab64b2e8dc1cfd0b4915c5925fed7a2d36fe
8550a61f83333006a0233d33fabb60d733ff0f2d
refs/heads/master
2016-09-11T02:55:43.773029
2010-10-25T04:51:51
2010-10-25T04:51:51
34,281,354
0
0
null
null
null
null
UTF-8
C++
false
false
16,142
cpp
/* Copyright (c) 2007, Jim Studt Version 2.0: Modifications by Paul Stoffregen, January 2010: http://www.pjrc.com/teensy/td_libs_OneWire.html Search fix from Robin James http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27 Use direct optimized I/O in all cases Disable interrupts during timing critical sections (this solves many random communication errors) Disable interrupts during read-modify-write I/O Reduce RAM consumption by eliminating unnecessary variables and trimming many to 8 bits Optimize both crc8 - table version moved to flash Modified to work with larger numbers of devices - avoids loop. Tested in Arduino 11 alpha with 12 sensors. 26 Sept 2008 -- Robin James http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27 Updated to work with arduino-0008 and to include skip() as of 2007/07/06. --RJL20 Modified to calculate the 8-bit CRC directly, avoiding the need for the 256-byte lookup table to be loaded in RAM. Tested in arduino-0010 -- Tom Pollard, Jan 23, 2008 'Ported' to the XMega. Currently locked to PORTA. -- Mark Jessop, October 4, 2010 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. Much of the code was inspired by Derek Yerger's code, though I don't think much of that remains. In any event that was.. (copyleft) 2006 by Derek Yerger - Free to distribute freely. The CRC code was excerpted and inspired by the Dallas Semiconductor sample code bearing this copyright. //--------------------------------------------------------------------------- // Copyright (C) 2000 Dallas Semiconductor Corporation, 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 DALLAS SEMICONDUCTOR 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. // // Except as contained in this notice, the name of Dallas Semiconductor // shall not be used except as stated in the Dallas Semiconductor // Branding Policy. //-------------------------------------------------------------------------- */ #include "OneWire.h" //#include "pins_arduino.h" extern "C" { //#include "WConstants.h" #include <avr/io.h> #include <avr/interrupt.h> #include <avr/pgmspace.h> #define F_CPU 32000000UL #include <util/delay.h> } #define ONEWIREPORT PORTA #define ONEWIREMASK 0x04 OneWire::OneWire()//uint8_t pin) { bitmask = ONEWIREMASK;//digitalPinToBitMask(pin); //baseReg = portInputRegister(digitalPinToPort(pin)); #if ONEWIRE_SEARCH reset_search(); #endif } /* #define DIRECT_READ(base, mask) (((*(base)) & (mask)) ? 1 : 0) #define DIRECT_MODE_INPUT(base, mask) ((*(base+1)) &= ~(mask)) #define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) |= (mask)) #define DIRECT_WRITE_LOW(base, mask) ((*(base+2)) &= ~(mask)) #define DIRECT_WRITE_HIGH(base, mask) ((*(base+2)) |= (mask)) */ #define DIRECT_READ(mask) ((ONEWIREPORT.IN & (mask)) ? 1 : 0) #define DIRECT_MODE_INPUT(mask) (ONEWIREPORT.DIRCLR = mask) #define DIRECT_MODE_OUTPUT(mask) (ONEWIREPORT.DIRSET = mask) #define DIRECT_WRITE_LOW(mask) (ONEWIREPORT.OUTCLR = mask) #define DIRECT_WRITE_HIGH(mask) (ONEWIREPORT.OUTSET = mask) #define delayMicroseconds(time) _delay_us(time) // Perform the onewire reset function. We will wait up to 250uS for // the bus to come high, if it doesn't then it is broken or shorted // and we return a 0; // // Returns 1 if a device asserted a presence pulse, 0 otherwise. // uint8_t OneWire::reset(void) { uint8_t mask=bitmask; //volatile uint8_t *reg asm("r30") = baseReg; uint8_t r; uint8_t retries = 125; cli(); DIRECT_MODE_INPUT(mask); sei(); // wait until the wire is high... just in case do { if (--retries == 0) return 0; delayMicroseconds(2); } while ( !DIRECT_READ(mask) ); cli(); DIRECT_WRITE_LOW(mask); DIRECT_MODE_OUTPUT(mask); // drive output low sei(); delayMicroseconds(500); cli(); DIRECT_MODE_INPUT(mask); // allow it to float delayMicroseconds(80); r = !DIRECT_READ(mask); sei(); delayMicroseconds(420); return r; } // // Write a bit. Port and bit is used to cut lookup time and provide // more certain timing. // void OneWire::write_bit(uint8_t v) { uint8_t mask=bitmask; //volatile uint8_t *reg asm("r30") = baseReg; if (v & 1) { cli(); DIRECT_WRITE_LOW(mask); DIRECT_MODE_OUTPUT(mask); // drive output low delayMicroseconds(10); DIRECT_WRITE_HIGH(mask); // drive output high sei(); delayMicroseconds(55); } else { cli(); DIRECT_WRITE_LOW(mask); DIRECT_MODE_OUTPUT(mask); // drive output low delayMicroseconds(65); DIRECT_WRITE_HIGH(mask); // drive output high sei(); delayMicroseconds(5); } } // // Read a bit. Port and bit is used to cut lookup time and provide // more certain timing. // uint8_t OneWire::read_bit(void) { uint8_t mask=bitmask; //volatile uint8_t *reg asm("r30") = baseReg; uint8_t r; cli(); DIRECT_MODE_OUTPUT(mask); DIRECT_WRITE_LOW(mask); delayMicroseconds(3); DIRECT_MODE_INPUT(mask); // let pin float, pull up will raise delayMicroseconds(9); r = DIRECT_READ(mask); sei(); delayMicroseconds(53); return r; } // // Write a byte. The writing code uses the active drivers to raise the // pin high, if you need power after the write (e.g. DS18S20 in // parasite power mode) then set 'power' to 1, otherwise the pin will // go tri-state at the end of the write to avoid heating in a short or // other mishap. // void OneWire::write(uint8_t v, uint8_t power /* = 0 */) { uint8_t bitMask; for (bitMask = 0x01; bitMask; bitMask <<= 1) { OneWire::write_bit( (bitMask & v)?1:0); } if ( !power) { cli(); DIRECT_MODE_INPUT(bitmask); DIRECT_WRITE_LOW(bitmask); sei(); } } // // Read a byte // uint8_t OneWire::read() { uint8_t bitMask; uint8_t r = 0; for (bitMask = 0x01; bitMask; bitMask <<= 1) { if ( OneWire::read_bit()) r |= bitMask; } return r; } // // Do a ROM select // void OneWire::select( uint8_t rom[8]) { int i; write(0x55); // Choose ROM for( i = 0; i < 8; i++) write(rom[i]); } // // Do a ROM skip // void OneWire::skip() { write(0xCC); // Skip ROM } void OneWire::depower() { cli(); DIRECT_MODE_INPUT(bitmask); sei(); } #if ONEWIRE_SEARCH // // You need to use this function to start a search again from the beginning. // You do not need to do it for the first search, though you could. // void OneWire::reset_search() { // reset the search state LastDiscrepancy = 0; LastDeviceFlag = FALSE; LastFamilyDiscrepancy = 0; for(int i = 7; ; i--) { ROM_NO[i] = 0; if ( i == 0) break; } } // // Perform a search. If this function returns a '1' then it has // enumerated the next device and you may retrieve the ROM from the // OneWire::address variable. If there are no devices, no further // devices, or something horrible happens in the middle of the // enumeration then a 0 is returned. If a new device is found then // its address is copied to newAddr. Use OneWire::reset_search() to // start over. // // --- Replaced by the one from the Dallas Semiconductor web site --- //-------------------------------------------------------------------------- // Perform the 1-Wire Search Algorithm on the 1-Wire bus using the existing // search state. // Return TRUE : device found, ROM number in ROM_NO buffer // FALSE : device not found, end of search // uint8_t OneWire::search(uint8_t *newAddr) { uint8_t id_bit_number; uint8_t last_zero, rom_byte_number, search_result; uint8_t id_bit, cmp_id_bit; unsigned char rom_byte_mask, search_direction; // initialize for search id_bit_number = 1; last_zero = 0; rom_byte_number = 0; rom_byte_mask = 1; search_result = 0; // if the last call was not the last one if (!LastDeviceFlag) { // 1-Wire reset if (!reset()) { // reset the search LastDiscrepancy = 0; LastDeviceFlag = FALSE; LastFamilyDiscrepancy = 0; return FALSE; } // issue the search command write(0xF0); // loop to do the search do { // read a bit and its complement id_bit = read_bit(); cmp_id_bit = read_bit(); // check for no devices on 1-wire if ((id_bit == 1) && (cmp_id_bit == 1)) break; else { // all devices coupled have 0 or 1 if (id_bit != cmp_id_bit) search_direction = id_bit; // bit write value for search else { // if this discrepancy if before the Last Discrepancy // on a previous next then pick the same as last time if (id_bit_number < LastDiscrepancy) search_direction = ((ROM_NO[rom_byte_number] & rom_byte_mask) > 0); else // if equal to last pick 1, if not then pick 0 search_direction = (id_bit_number == LastDiscrepancy); // if 0 was picked then record its position in LastZero if (search_direction == 0) { last_zero = id_bit_number; // check for Last discrepancy in family if (last_zero < 9) LastFamilyDiscrepancy = last_zero; } } // set or clear the bit in the ROM byte rom_byte_number // with mask rom_byte_mask if (search_direction == 1) ROM_NO[rom_byte_number] |= rom_byte_mask; else ROM_NO[rom_byte_number] &= ~rom_byte_mask; // serial number search direction write bit write_bit(search_direction); // increment the byte counter id_bit_number // and shift the mask rom_byte_mask id_bit_number++; rom_byte_mask <<= 1; // if the mask is 0 then go to new SerialNum byte rom_byte_number and reset mask if (rom_byte_mask == 0) { rom_byte_number++; rom_byte_mask = 1; } } } while(rom_byte_number < 8); // loop until through all ROM bytes 0-7 // if the search was successful then if (!(id_bit_number < 65)) { // search successful so set LastDiscrepancy,LastDeviceFlag,search_result LastDiscrepancy = last_zero; // check for last device if (LastDiscrepancy == 0) LastDeviceFlag = TRUE; search_result = TRUE; } } // if no device found then reset counters so next 'search' will be like a first if (!search_result || !ROM_NO[0]) { LastDiscrepancy = 0; LastDeviceFlag = FALSE; LastFamilyDiscrepancy = 0; search_result = FALSE; } for (int i = 0; i < 8; i++) newAddr[i] = ROM_NO[i]; return search_result; } #endif #if ONEWIRE_CRC // The 1-Wire CRC scheme is described in Maxim Application Note 27: // "Understanding and Using Cyclic Redundancy Checks with Maxim iButton Products" // #if ONEWIRE_CRC8_TABLE // This table comes from Dallas sample code where it is freely reusable, // though Copyright (C) 2000 Dallas Semiconductor Corporation static const uint8_t PROGMEM dscrc_table[] = { 0, 94,188,226, 97, 63,221,131,194,156,126, 32,163,253, 31, 65, 157,195, 33,127,252,162, 64, 30, 95, 1,227,189, 62, 96,130,220, 35,125,159,193, 66, 28,254,160,225,191, 93, 3,128,222, 60, 98, 190,224, 2, 92,223,129, 99, 61,124, 34,192,158, 29, 67,161,255, 70, 24,250,164, 39,121,155,197,132,218, 56,102,229,187, 89, 7, 219,133,103, 57,186,228, 6, 88, 25, 71,165,251,120, 38,196,154, 101, 59,217,135, 4, 90,184,230,167,249, 27, 69,198,152,122, 36, 248,166, 68, 26,153,199, 37,123, 58,100,134,216, 91, 5,231,185, 140,210, 48,110,237,179, 81, 15, 78, 16,242,172, 47,113,147,205, 17, 79,173,243,112, 46,204,146,211,141,111, 49,178,236, 14, 80, 175,241, 19, 77,206,144,114, 44,109, 51,209,143, 12, 82,176,238, 50,108,142,208, 83, 13,239,177,240,174, 76, 18,145,207, 45,115, 202,148,118, 40,171,245, 23, 73, 8, 86,180,234,105, 55,213,139, 87, 9,235,181, 54,104,138,212,149,203, 41,119,244,170, 72, 22, 233,183, 85, 11,136,214, 52,106, 43,117,151,201, 74, 20,246,168, 116, 42,200,150, 21, 75,169,247,182,232, 10, 84,215,137,107, 53}; // // Compute a Dallas Semiconductor 8 bit CRC. These show up in the ROM // and the registers. (note: this might better be done without to // table, it would probably be smaller and certainly fast enough // compared to all those delayMicrosecond() calls. But I got // confused, so I use this table from the examples.) // uint8_t OneWire::crc8( uint8_t *addr, uint8_t len) { uint8_t crc = 0; while (len--) { crc = pgm_read_byte(dscrc_table + (crc ^ *addr++)); } return crc; } #else // // Compute a Dallas Semiconductor 8 bit CRC directly. // uint8_t OneWire::crc8( uint8_t *addr, uint8_t len) { uint8_t crc = 0; while (len--) { uint8_t inbyte = *addr++; for (uint8_t i = 8; i; i--) { uint8_t mix = (crc ^ inbyte) & 0x01; crc >>= 1; if (mix) crc ^= 0x8C; inbyte >>= 1; } } return crc; } #endif #if ONEWIRE_CRC16 static short oddparity[16] = { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }; // // Compute a Dallas Semiconductor 16 bit CRC. I have never seen one of // these, but here it is. // unsigned short OneWire::crc16(unsigned short *data, unsigned short len) { unsigned short i; unsigned short crc = 0; for ( i = 0; i < len; i++) { unsigned short cdata = data[len]; cdata = (cdata ^ (crc & 0xff)) & 0xff; crc >>= 8; if (oddparity[cdata & 0xf] ^ oddparity[cdata >> 4]) crc ^= 0xc001; cdata <<= 6; crc ^= cdata; cdata <<= 1; crc ^= cdata; } return crc; } #endif #endif
[ "lenniethelemming@2f291951-c1d2-6b09-a047-4ba468d48a57" ]
lenniethelemming@2f291951-c1d2-6b09-a047-4ba468d48a57
5868e5ef356368e9982d3c1c8a596c6cf93a84c5
757ef3684431651ae761dfe785a8c432535f5a08
/lab8/cpp11.cpp
811b00c30c763c818c16297c98a2f830703466d7
[]
no_license
zer0chance/os
ac226aade26b977f5171f5bc073691ae3aee5219
7d4d23dd3bfdc661b1d320700e1e0a9ae5ab81cc
refs/heads/master
2023-02-05T09:06:12.102027
2020-12-30T04:51:40
2020-12-30T04:51:40
292,607,985
0
0
null
null
null
null
UTF-8
C++
false
false
589
cpp
// > cl /MT /D "_X86_" th4.cpp #include <iostream> #include <thread> #include <windows.h> typedef int (*fun)(char*,int* p); int g(char* str, int* p) { *p=0; printf("%s\n",str); return 0; } int q = 1; void Thread(void* pg) { int counter = 0; while (q) { printf("child\n"); Sleep(10); if(counter++ > 1000) break; } ((fun)pg)((char*) "thread_is_over!", &q); } int main(void) { std::thread thr(Thread, (void*)g); while(q) { printf("parent %d\n", q); Sleep(10); } thr.join(); return 0; }
[ "ier2000@yandex.ru" ]
ier2000@yandex.ru
69e0f158cf41abdabf3207d5ee0c3133dba20762
0db2bedf9ba7a70b1a7d72db6b354197accd96bd
/Engine/Graphics/OpenGL/cRenderState.gl.cpp
a0bfe4e9ae5f1d4495b28675a363e22dd01c4665
[]
no_license
arpit09891/GraphicEngine
e10654f510b1bbf684517fc1915d674505abac5d
707c0c3f9d2b4f9aaa1b128e68bb4fb74c3b9c95
refs/heads/master
2020-03-18T11:10:18.649190
2019-01-16T02:18:04
2019-01-16T02:18:04
134,655,019
0
0
null
null
null
null
UTF-8
C++
false
false
2,233
cpp
// Include Files //============== #include "../cRenderState.h" #include "Includes.h" #include <Engine/Asserts/Asserts.h> // Interface //========== // Render //------- void eae6320::Graphics::cRenderState::Bind() const { // Alpha Transparency if ( IsAlphaTransparencyEnabled() ) { glEnable( GL_BLEND ); EAE6320_ASSERT( glGetError() == GL_NO_ERROR ); // result = ( source * source.a ) + ( destination * ( 1 - source.a ) ) glBlendEquation( GL_FUNC_ADD ); EAE6320_ASSERT( glGetError() == GL_NO_ERROR ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); EAE6320_ASSERT( glGetError() == GL_NO_ERROR ); } else { glDisable( GL_BLEND ); EAE6320_ASSERT( glGetError() == GL_NO_ERROR ); } // Depth Buffering if ( IsDepthBufferingEnabled() ) { // The new fragment becomes a pixel if its depth is less than what has previously been written glEnable( GL_DEPTH_TEST ); EAE6320_ASSERT( glGetError() == GL_NO_ERROR ); glDepthFunc( GL_LESS ); EAE6320_ASSERT( glGetError() == GL_NO_ERROR ); // Write to the depth buffer glDepthMask( GL_TRUE ); EAE6320_ASSERT( glGetError() == GL_NO_ERROR ); } else { // Don't test the depth buffer glDisable( GL_DEPTH_TEST ); EAE6320_ASSERT( glGetError() == GL_NO_ERROR ); // Don't write to the depth buffer glDepthMask( GL_FALSE ); EAE6320_ASSERT( glGetError() == GL_NO_ERROR ); } // Draw Both Triangle Sides if ( ShouldBothTriangleSidesBeDrawn() ) { // Don't cull any triangles glDisable( GL_CULL_FACE ); EAE6320_ASSERT( glGetError() == GL_NO_ERROR ); } else { // Cull triangles that are facing backwards glEnable( GL_CULL_FACE ); EAE6320_ASSERT( glGetError() == GL_NO_ERROR ); // Triangles use right-handed winding order // (opposite from Direct3D) glFrontFace( GL_CCW ); EAE6320_ASSERT( glGetError() == GL_NO_ERROR ); } } // Initialization / Clean Up //-------------------------- eae6320::cResult eae6320::Graphics::cRenderState::CleanUp() { return Results::Success; } // Implementation //=============== // Initialization / Clean Up //-------------------------- eae6320::cResult eae6320::Graphics::cRenderState::InitializeFromBits() { // OpenGL uses the bits directly at binding time return Results::Success; }
[ "u1060328@utah.edu" ]
u1060328@utah.edu
da83a2f51c47f4621ec4c9bb2559c5d637edcc2f
24f26275ffcd9324998d7570ea9fda82578eeb9e
/chrome/browser/safe_browsing/chrome_password_protection_service_unittest.cc
304a5e5505b67d6505f6e4f2d6b6371f6960e0e6
[ "BSD-3-Clause" ]
permissive
Vizionnation/chromenohistory
70a51193c8538d7b995000a1b2a654e70603040f
146feeb85985a6835f4b8826ad67be9195455402
refs/heads/master
2022-12-15T07:02:54.461083
2019-10-25T15:07:06
2019-10-25T15:07:06
217,557,501
2
1
BSD-3-Clause
2022-11-19T06:53:07
2019-10-25T14:58:54
null
UTF-8
C++
false
false
59,038
cc
// Copyright 2017 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. #include "chrome/browser/safe_browsing/chrome_password_protection_service.h" #include <memory> #include "base/bind.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" #include "base/test/bind_test_util.h" #include "base/test/scoped_feature_list.h" #include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.h" #include "chrome/browser/password_manager/password_store_factory.h" #include "chrome/browser/safe_browsing/test_extension_event_observer.h" #include "chrome/browser/safe_browsing/ui_manager.h" #include "chrome/browser/signin/chrome_signin_client_factory.h" #include "chrome/browser/signin/identity_test_environment_profile_adaptor.h" #include "chrome/browser/signin/test_signin_client_builder.h" #include "chrome/browser/sync/user_event_service_factory.h" #include "chrome/common/extensions/api/safe_browsing_private.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" #include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/password_manager/core/browser/hash_password_manager.h" #include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/password_manager/core/browser/password_manager_test_utils.h" #include "components/password_manager/core/browser/test_password_store.h" #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" #include "components/safe_browsing/common/utils.h" #include "components/safe_browsing/db/v4_protocol_manager_util.h" #include "components/safe_browsing/features.h" #include "components/safe_browsing/password_protection/password_protection_navigation_throttle.h" #include "components/safe_browsing/password_protection/password_protection_request.h" #include "components/safe_browsing/verdict_cache_manager.h" #include "components/signin/public/identity_manager/account_info.h" #include "components/strings/grit/components_strings.h" #include "components/sync/model/model_type_controller_delegate.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/sync_user_events/fake_user_event_service.h" #include "content/public/browser/navigation_handle.h" #include "content/public/browser/web_contents.h" #include "content/public/test/browser_task_environment.h" #include "content/public/test/mock_navigation_handle.h" #include "extensions/browser/test_event_router.h" #include "net/http/http_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/l10n/l10n_util.h" using sync_pb::UserEventSpecifics; using GaiaPasswordReuse = sync_pb::GaiaPasswordReuse; using GaiaPasswordCaptured = UserEventSpecifics::GaiaPasswordCaptured; using PasswordReuseDialogInteraction = GaiaPasswordReuse::PasswordReuseDialogInteraction; using PasswordReuseEvent = safe_browsing::LoginReputationClientRequest::PasswordReuseEvent; using PasswordReuseLookup = GaiaPasswordReuse::PasswordReuseLookup; using ::testing::_; using ::testing::Return; using ::testing::WithArg; namespace OnPolicySpecifiedPasswordReuseDetected = extensions::api:: safe_browsing_private::OnPolicySpecifiedPasswordReuseDetected; namespace OnPolicySpecifiedPasswordChanged = extensions::api::safe_browsing_private::OnPolicySpecifiedPasswordChanged; class MockSecurityEventRecorder : public SecurityEventRecorder { public: MockSecurityEventRecorder() = default; ~MockSecurityEventRecorder() override = default; static BrowserContextKeyedServiceFactory::TestingFactory Create() { return base::BindRepeating( [](content::BrowserContext* context) -> std::unique_ptr<KeyedService> { return std::make_unique<MockSecurityEventRecorder>(); }); } MOCK_METHOD0(GetControllerDelegate, base::WeakPtr<syncer::ModelTypeControllerDelegate>()); MOCK_METHOD1(RecordGaiaPasswordReuse, void(const GaiaPasswordReuse&)); }; namespace safe_browsing { namespace { const char kPhishingURL[] = "http://phishing.com/"; const char kPasswordReuseURL[] = "http://login.example.com/"; const char kTestEmail[] = "foo@example.com"; const char kTestGmail[] = "foo@gmail.com"; const char kRedirectURL[] = "http://redirect.com"; const char kUserName[] = "username"; BrowserContextKeyedServiceFactory::TestingFactory GetFakeUserEventServiceFactory() { return base::BindRepeating( [](content::BrowserContext* context) -> std::unique_ptr<KeyedService> { return std::make_unique<syncer::FakeUserEventService>(); }); } constexpr struct { // The response from the password protection service. RequestOutcome request_outcome; // The enum to log in the user event for that response. PasswordReuseLookup::LookupResult lookup_result; } kTestCasesWithoutVerdict[]{ {RequestOutcome::MATCHED_WHITELIST, PasswordReuseLookup::WHITELIST_HIT}, {RequestOutcome::URL_NOT_VALID_FOR_REPUTATION_COMPUTING, PasswordReuseLookup::URL_UNSUPPORTED}, {RequestOutcome::CANCELED, PasswordReuseLookup::REQUEST_FAILURE}, {RequestOutcome::TIMEDOUT, PasswordReuseLookup::REQUEST_FAILURE}, {RequestOutcome::DISABLED_DUE_TO_INCOGNITO, PasswordReuseLookup::REQUEST_FAILURE}, {RequestOutcome::REQUEST_MALFORMED, PasswordReuseLookup::REQUEST_FAILURE}, {RequestOutcome::FETCH_FAILED, PasswordReuseLookup::REQUEST_FAILURE}, {RequestOutcome::RESPONSE_MALFORMED, PasswordReuseLookup::REQUEST_FAILURE}, {RequestOutcome::SERVICE_DESTROYED, PasswordReuseLookup::REQUEST_FAILURE}, {RequestOutcome::DISABLED_DUE_TO_FEATURE_DISABLED, PasswordReuseLookup::REQUEST_FAILURE}, {RequestOutcome::DISABLED_DUE_TO_USER_POPULATION, PasswordReuseLookup::REQUEST_FAILURE}}; } // namespace class MockChromePasswordProtectionService : public ChromePasswordProtectionService { public: explicit MockChromePasswordProtectionService( Profile* profile, scoped_refptr<SafeBrowsingUIManager> ui_manager, StringProvider sync_password_hash_provider, VerdictCacheManager* cache_manager) : ChromePasswordProtectionService(profile, ui_manager, sync_password_hash_provider, cache_manager), is_incognito_(false), is_extended_reporting_(false), is_syncing_(false), is_no_hosted_domain_found_(false), is_account_signed_in_(false) {} bool IsExtendedReporting() override { return is_extended_reporting_; } bool IsIncognito() override { return is_incognito_; } bool IsPrimaryAccountSyncing() const override { return is_syncing_; } bool IsPrimaryAccountSignedIn() const override { return is_account_signed_in_; } bool IsPrimaryAccountGmail() const override { return is_no_hosted_domain_found_; } AccountInfo GetSignedInNonSyncAccount( const std::string& username) const override { return account_info_; } // Configures the results returned by IsExtendedReporting(), IsIncognito(), // and IsHistorySyncEnabled(). void ConfigService(bool is_incognito, bool is_extended_reporting) { is_incognito_ = is_incognito; is_extended_reporting_ = is_extended_reporting; } void SetIsSyncing(bool is_syncing) { is_syncing_ = is_syncing; } void SetIsNoHostedDomainFound(bool is_no_hosted_domain_found) { is_no_hosted_domain_found_ = is_no_hosted_domain_found; } void SetIsAccountSignedIn(bool is_account_signed_in) { is_account_signed_in_ = is_account_signed_in; } void SetAccountInfo(const std::string& username) { AccountInfo account_info; account_info.account_id = "account_id"; account_info.email = username; account_info.gaia = "gaia"; account_info_ = account_info; } SafeBrowsingUIManager* ui_manager() { return ui_manager_.get(); } protected: friend class ChromePasswordProtectionServiceTest; private: bool is_incognito_; bool is_extended_reporting_; bool is_syncing_; bool is_no_hosted_domain_found_; bool is_account_signed_in_; AccountInfo account_info_; std::string mocked_sync_password_hash_; }; class ChromePasswordProtectionServiceTest : public ChromeRenderViewHostTestHarness { public: ChromePasswordProtectionServiceTest() {} void SetUp() override { ChromeRenderViewHostTestHarness::SetUp(); // Use TestPasswordStore to remove a possible race. Normally the // PasswordStore does its database manipulation on the DB thread, which // creates a possible race during navigation. Specifically the // PasswordManager will ignore any forms in a page if the load from the // PasswordStore has not completed. PasswordStoreFactory::GetInstance()->SetTestingFactory( profile(), base::BindRepeating( &password_manager::BuildPasswordStore< content::BrowserContext, password_manager::TestPasswordStore>)); profile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled, true); profile()->GetPrefs()->SetInteger( prefs::kPasswordProtectionWarningTrigger, PasswordProtectionTrigger::PHISHING_REUSE); HostContentSettingsMap::RegisterProfilePrefs(test_pref_service_.registry()); content_setting_map_ = new HostContentSettingsMap( &test_pref_service_, false /* is_off_the_record */, false /* store_last_modified */, false /* migrate_requesting_and_top_level_origin_settings */); cache_manager_ = std::make_unique<VerdictCacheManager>( nullptr, content_setting_map_.get()); service_ = NewMockPasswordProtectionService(); fake_user_event_service_ = static_cast<syncer::FakeUserEventService*>( browser_sync::UserEventServiceFactory::GetInstance() ->SetTestingFactoryAndUse(browser_context(), GetFakeUserEventServiceFactory())); test_event_router_ = extensions::CreateAndUseTestEventRouter(browser_context()); extensions::SafeBrowsingPrivateEventRouterFactory::GetInstance() ->SetTestingFactory( browser_context(), base::BindRepeating(&BuildSafeBrowsingPrivateEventRouter)); identity_test_env_profile_adaptor_ = std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile()); security_event_recorder_ = static_cast<MockSecurityEventRecorder*>( SecurityEventRecorderFactory::GetInstance()->SetTestingFactoryAndUse( browser_context(), MockSecurityEventRecorder::Create())); // To make sure we are not accidentally calling the SecurityEventRecorder. EXPECT_CALL(*security_event_recorder_, RecordGaiaPasswordReuse(_)).Times(0); } void TearDown() override { base::RunLoop().RunUntilIdle(); service_.reset(); request_ = nullptr; identity_test_env_profile_adaptor_.reset(); cache_manager_.reset(); content_setting_map_->ShutdownOnUIThread(); ChromeRenderViewHostTestHarness::TearDown(); } // This can be called whenever to reset service_, if initialition // conditions have changed. std::unique_ptr<MockChromePasswordProtectionService> NewMockPasswordProtectionService( const std::string& sync_password_hash = std::string()) { StringProvider sync_password_hash_provider = base::BindLambdaForTesting([=] { return sync_password_hash; }); // TODO(crbug/925153): Port consumers of the SafeBrowsingService // to use the interface in components/safe_browsing, and remove this // cast. return std::make_unique<MockChromePasswordProtectionService>( profile(), new SafeBrowsingUIManager( static_cast<safe_browsing::SafeBrowsingService*>( SafeBrowsingService::CreateSafeBrowsingService())), sync_password_hash_provider, cache_manager_.get()); } TestingProfile::TestingFactories GetTestingFactories() const override { return IdentityTestEnvironmentProfileAdaptor:: GetIdentityTestEnvironmentFactories(); } syncer::FakeUserEventService* GetUserEventService() { return fake_user_event_service_; } void InitializeRequest(LoginReputationClientRequest::TriggerType trigger_type, PasswordType reused_password_type) { if (trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) { request_ = new PasswordProtectionRequest( web_contents(), GURL(kPhishingURL), GURL(), GURL(), kUserName, PasswordType::PASSWORD_TYPE_UNKNOWN, std::vector<std::string>({"somedomain.com"}), trigger_type, true, service_.get(), 0); } else { ASSERT_EQ(LoginReputationClientRequest::PASSWORD_REUSE_EVENT, trigger_type); request_ = new PasswordProtectionRequest( web_contents(), GURL(kPhishingURL), GURL(), GURL(), kUserName, reused_password_type, std::vector<std::string>(), trigger_type, /* password_field_exists*/ true, service_.get(), /*request_timeout_in_ms=*/0); } } void InitializeVerdict(LoginReputationClientResponse::VerdictType type) { verdict_ = std::make_unique<LoginReputationClientResponse>(); verdict_->set_verdict_type(type); } void SimulateRequestFinished( LoginReputationClientResponse::VerdictType verdict_type) { std::unique_ptr<LoginReputationClientResponse> verdict = std::make_unique<LoginReputationClientResponse>(); verdict->set_verdict_type(verdict_type); service_->RequestFinished(request_.get(), RequestOutcome::SUCCEEDED, std::move(verdict)); } CoreAccountInfo SetPrimaryAccount(const std::string& email) { identity_test_env()->MakeAccountAvailable(email); return identity_test_env()->SetPrimaryAccount(email); } void SetUpSyncAccount(const std::string& hosted_domain, const CoreAccountInfo& account_info) { identity_test_env()->SimulateSuccessfulFetchOfAccountInfo( account_info.account_id, account_info.email, account_info.gaia, hosted_domain, "full_name", "given_name", "locale", "http://picture.example.com/picture.jpg"); } void PrepareRequest(LoginReputationClientRequest::TriggerType trigger_type, PasswordType reused_password_type, bool is_warning_showing) { InitializeRequest(trigger_type, reused_password_type); request_->set_is_modal_warning_showing(is_warning_showing); service_->pending_requests_.insert(request_); } int GetSizeofUnhandledSyncPasswordReuses() { DictionaryPrefUpdate unhandled_sync_password_reuses( profile()->GetPrefs(), prefs::kSafeBrowsingUnhandledGaiaPasswordReuses); return unhandled_sync_password_reuses->size(); } size_t GetNumberOfNavigationThrottles() { return request_ ? request_->throttles_.size() : 0u; } signin::IdentityTestEnvironment* identity_test_env() { return identity_test_env_profile_adaptor_->identity_test_env(); } protected: sync_preferences::TestingPrefServiceSyncable test_pref_service_; scoped_refptr<HostContentSettingsMap> content_setting_map_; std::unique_ptr<MockChromePasswordProtectionService> service_; scoped_refptr<PasswordProtectionRequest> request_; std::unique_ptr<LoginReputationClientResponse> verdict_; std::unique_ptr<IdentityTestEnvironmentProfileAdaptor> identity_test_env_profile_adaptor_; MockSecurityEventRecorder* security_event_recorder_; // Owned by KeyedServiceFactory. syncer::FakeUserEventService* fake_user_event_service_; extensions::TestEventRouter* test_event_router_; std::unique_ptr<VerdictCacheManager> cache_manager_; }; TEST_F(ChromePasswordProtectionServiceTest, VerifyUserPopulationForPasswordOnFocusPing) { ReusedPasswordAccountType reused_password_type; reused_password_type.set_account_type(ReusedPasswordAccountType::UNKNOWN); // Password field on focus pinging is enabled on !incognito && SBER. RequestOutcome reason; service_->ConfigService(false /*incognito*/, false /*SBER*/); EXPECT_FALSE(service_->IsPingingEnabled( LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, reused_password_type, &reason)); EXPECT_EQ(RequestOutcome::DISABLED_DUE_TO_USER_POPULATION, reason); service_->ConfigService(false /*incognito*/, true /*SBER*/); EXPECT_TRUE(service_->IsPingingEnabled( LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, reused_password_type, &reason)); service_->ConfigService(true /*incognito*/, false /*SBER*/); EXPECT_FALSE(service_->IsPingingEnabled( LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, reused_password_type, &reason)); EXPECT_EQ(RequestOutcome::DISABLED_DUE_TO_INCOGNITO, reason); service_->ConfigService(true /*incognito*/, true /*SBER*/); EXPECT_FALSE(service_->IsPingingEnabled( LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, reused_password_type, &reason)); EXPECT_EQ(RequestOutcome::DISABLED_DUE_TO_INCOGNITO, reason); } TEST_F(ChromePasswordProtectionServiceTest, VerifyUserPopulationForSavedPasswordEntryPing) { base::test::ScopedFeatureList feature_list; feature_list.InitAndDisableFeature( safe_browsing::kPasswordProtectionForSignedInUsers); ReusedPasswordAccountType reused_password_type; reused_password_type.set_account_type( ReusedPasswordAccountType::SAVED_PASSWORD); RequestOutcome reason; service_->ConfigService(false /*incognito*/, false /*SBER*/); EXPECT_FALSE(service_->IsPingingEnabled( LoginReputationClientRequest::PASSWORD_REUSE_EVENT, reused_password_type, &reason)); service_->ConfigService(false /*incognito*/, true /*SBER*/); EXPECT_TRUE(service_->IsPingingEnabled( LoginReputationClientRequest::PASSWORD_REUSE_EVENT, reused_password_type, &reason)); service_->ConfigService(true /*incognito*/, false /*SBER*/); EXPECT_FALSE(service_->IsPingingEnabled( LoginReputationClientRequest::PASSWORD_REUSE_EVENT, reused_password_type, &reason)); service_->ConfigService(true /*incognito*/, true /*SBER*/); EXPECT_TRUE(service_->IsPingingEnabled( LoginReputationClientRequest::PASSWORD_REUSE_EVENT, reused_password_type, &reason)); { base::test::ScopedFeatureList feature_list; feature_list.InitAndEnableFeature( safe_browsing::kPasswordProtectionForSavedPasswords); service_->ConfigService(false /*incognito*/, false /*SBER*/); EXPECT_TRUE(service_->IsPingingEnabled( LoginReputationClientRequest::PASSWORD_REUSE_EVENT, reused_password_type, &reason)); } } TEST_F(ChromePasswordProtectionServiceTest, VerifyUserPopulationForSyncPasswordEntryPing) { RequestOutcome reason; // Sets up the account as a gmail account as there is no hosted domain. ReusedPasswordAccountType reused_password_type; reused_password_type.set_account_type(ReusedPasswordAccountType::GMAIL); reused_password_type.set_is_account_syncing(true); // Sync password entry pinging is enabled by default. service_->ConfigService(false /*incognito*/, false /*SBER*/); EXPECT_TRUE(service_->IsPingingEnabled( LoginReputationClientRequest::PASSWORD_REUSE_EVENT, reused_password_type, &reason)); service_->ConfigService(false /*incognito*/, true /*SBER*/); EXPECT_TRUE(service_->IsPingingEnabled( LoginReputationClientRequest::PASSWORD_REUSE_EVENT, reused_password_type, &reason)); service_->ConfigService(true /*incognito*/, false /*SBER*/); EXPECT_TRUE(service_->IsPingingEnabled( LoginReputationClientRequest::PASSWORD_REUSE_EVENT, reused_password_type, &reason)); // Even if sync password entry pinging is disabled by policy, // |IsPingingEnabled(..)| should still default to true if the // the password reuse type is syncing Gmail account. service_->ConfigService(true /*incognito*/, true /*SBER*/); service_->SetIsNoHostedDomainFound(true); EXPECT_TRUE(service_->IsPingingEnabled( LoginReputationClientRequest::PASSWORD_REUSE_EVENT, reused_password_type, &reason)); profile()->GetPrefs()->SetInteger(prefs::kPasswordProtectionWarningTrigger, PASSWORD_PROTECTION_OFF); service_->ConfigService(false /*incognito*/, false /*SBER*/); EXPECT_TRUE(service_->IsPingingEnabled( LoginReputationClientRequest::PASSWORD_REUSE_EVENT, reused_password_type, &reason)); profile()->GetPrefs()->SetInteger(prefs::kPasswordProtectionWarningTrigger, PASSWORD_REUSE); EXPECT_TRUE(service_->IsPingingEnabled( LoginReputationClientRequest::PASSWORD_REUSE_EVENT, reused_password_type, &reason)); } TEST_F(ChromePasswordProtectionServiceTest, VerifyPingingIsSkippedIfMatchEnterpriseWhitelist) { RequestOutcome reason = RequestOutcome::UNKNOWN; ASSERT_FALSE( profile()->GetPrefs()->HasPrefPath(prefs::kSafeBrowsingWhitelistDomains)); // If there's no whitelist, IsURLWhitelistedForPasswordEntry(_,_) should // return false. EXPECT_FALSE(service_->IsURLWhitelistedForPasswordEntry( GURL("https://www.mydomain.com"), &reason)); EXPECT_EQ(RequestOutcome::UNKNOWN, reason); // Verify if match enterprise whitelist. base::ListValue whitelist; whitelist.AppendString("mydomain.com"); whitelist.AppendString("mydomain.net"); profile()->GetPrefs()->Set(prefs::kSafeBrowsingWhitelistDomains, whitelist); EXPECT_TRUE(service_->IsURLWhitelistedForPasswordEntry( GURL("https://www.mydomain.com"), &reason)); EXPECT_EQ(RequestOutcome::MATCHED_ENTERPRISE_WHITELIST, reason); // Verify if matches enterprise change password url. profile()->GetPrefs()->ClearPref(prefs::kSafeBrowsingWhitelistDomains); reason = RequestOutcome::UNKNOWN; EXPECT_FALSE(service_->IsURLWhitelistedForPasswordEntry( GURL("https://www.mydomain.com"), &reason)); EXPECT_EQ(RequestOutcome::UNKNOWN, reason); profile()->GetPrefs()->SetString(prefs::kPasswordProtectionChangePasswordURL, "https://mydomain.com/change_password.html"); EXPECT_TRUE(service_->IsURLWhitelistedForPasswordEntry( GURL("https://mydomain.com/change_password.html#ref?user_name=alice"), &reason)); EXPECT_EQ(RequestOutcome::MATCHED_ENTERPRISE_CHANGE_PASSWORD_URL, reason); // Verify if matches enterprise login url. profile()->GetPrefs()->ClearPref(prefs::kSafeBrowsingWhitelistDomains); profile()->GetPrefs()->ClearPref(prefs::kPasswordProtectionChangePasswordURL); reason = RequestOutcome::UNKNOWN; EXPECT_FALSE(service_->IsURLWhitelistedForPasswordEntry( GURL("https://www.mydomain.com"), &reason)); EXPECT_EQ(RequestOutcome::UNKNOWN, reason); base::ListValue login_urls; login_urls.AppendString("https://mydomain.com/login.html"); profile()->GetPrefs()->Set(prefs::kPasswordProtectionLoginURLs, login_urls); EXPECT_TRUE(service_->IsURLWhitelistedForPasswordEntry( GURL("https://mydomain.com/login.html#ref?user_name=alice"), &reason)); EXPECT_EQ(RequestOutcome::MATCHED_ENTERPRISE_LOGIN_URL, reason); } TEST_F(ChromePasswordProtectionServiceTest, VerifyCanSendSamplePing) { // If experiment is not enabled, do not send ping. service_->ConfigService(/*is_incognito=*/false, /*is_extended_reporting=*/true); service_->set_bypass_probability_for_tests(true); EXPECT_FALSE(service_->CanSendSamplePing()); { base::test::ScopedFeatureList feature_list; feature_list.InitAndEnableFeature( safe_browsing::kSendSampledPingsForAllowlistDomains); EXPECT_TRUE(service_->CanSendSamplePing()); // If not SBER, do not send sample ping. service_->ConfigService(/*is_incognito=*/false, /*is_extended_reporting=*/false); EXPECT_FALSE(service_->CanSendSamplePing()); // If incognito, do not send sample ping. service_->ConfigService(/*is_incognito=*/true, /*is_extended_reporting=*/true); EXPECT_FALSE(service_->CanSendSamplePing()); service_->ConfigService(/*is_incognito=*/true, /*is_extended_reporting=*/false); EXPECT_FALSE(service_->CanSendSamplePing()); } } TEST_F(ChromePasswordProtectionServiceTest, VerifyGetOrganizationTypeGmail) { ReusedPasswordAccountType reused_password_type; reused_password_type.set_account_type(ReusedPasswordAccountType::GMAIL); reused_password_type.set_is_account_syncing(true); EXPECT_TRUE(service_->GetOrganizationName(reused_password_type).empty()); EXPECT_EQ("", service_->GetOrganizationName(reused_password_type)); } TEST_F(ChromePasswordProtectionServiceTest, VerifyGetOrganizationTypeGSuite) { CoreAccountInfo account_info = SetPrimaryAccount(kTestEmail); SetUpSyncAccount("example.com", account_info); ReusedPasswordAccountType reused_password_type; reused_password_type.set_account_type(ReusedPasswordAccountType::GSUITE); reused_password_type.set_is_account_syncing(true); EXPECT_EQ("example.com", service_->GetOrganizationName(reused_password_type)); } TEST_F(ChromePasswordProtectionServiceTest, VerifyUpdateSecurityState) { GURL url("http://password_reuse_url.com"); NavigateAndCommit(url); SBThreatType current_threat_type = SB_THREAT_TYPE_UNUSED; ASSERT_FALSE(service_->ui_manager()->IsUrlWhitelistedOrPendingForWebContents( url, false, web_contents()->GetController().GetLastCommittedEntry(), web_contents(), false, &current_threat_type)); EXPECT_EQ(SB_THREAT_TYPE_UNUSED, current_threat_type); // Cache a verdict for this URL. LoginReputationClientResponse verdict_proto; verdict_proto.set_verdict_type(LoginReputationClientResponse::PHISHING); verdict_proto.set_cache_duration_sec(600); verdict_proto.set_cache_expression("password_reuse_url.com/"); ReusedPasswordAccountType reused_password_type; reused_password_type.set_account_type(ReusedPasswordAccountType::GSUITE); reused_password_type.set_is_account_syncing(true); service_->CacheVerdict( url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, reused_password_type, verdict_proto, base::Time::Now()); service_->UpdateSecurityState(SB_THREAT_TYPE_SIGNED_IN_SYNC_PASSWORD_REUSE, reused_password_type, web_contents()); ASSERT_TRUE(service_->ui_manager()->IsUrlWhitelistedOrPendingForWebContents( url, false, web_contents()->GetController().GetLastCommittedEntry(), web_contents(), false, &current_threat_type)); EXPECT_EQ(SB_THREAT_TYPE_SIGNED_IN_SYNC_PASSWORD_REUSE, current_threat_type); service_->UpdateSecurityState(safe_browsing::SB_THREAT_TYPE_SAFE, reused_password_type, web_contents()); current_threat_type = SB_THREAT_TYPE_UNUSED; service_->ui_manager()->IsUrlWhitelistedOrPendingForWebContents( url, false, web_contents()->GetController().GetLastCommittedEntry(), web_contents(), false, &current_threat_type); EXPECT_EQ(SB_THREAT_TYPE_UNUSED, current_threat_type); LoginReputationClientResponse verdict; EXPECT_EQ(LoginReputationClientResponse::SAFE, service_->GetCachedVerdict( url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, reused_password_type, &verdict)); } TEST_F(ChromePasswordProtectionServiceTest, VerifyPasswordReuseUserEventNotRecordedDueToIncognito) { // Configure sync account type to GMAIL. CoreAccountInfo account_info = SetPrimaryAccount(kTestEmail); SetUpSyncAccount(kNoHostedDomainFound, account_info); service_->ConfigService(true /*is_incognito*/, false /*is_extended_reporting*/); ASSERT_TRUE(service_->IsIncognito()); // Nothing should be logged because of incognito. NavigateAndCommit(GURL("https:www.example.com/")); // PasswordReuseDetected service_->MaybeLogPasswordReuseDetectedEvent(web_contents()); EXPECT_TRUE(GetUserEventService()->GetRecordedUserEvents().empty()); service_->MaybeLogPasswordReuseLookupEvent( web_contents(), RequestOutcome::MATCHED_WHITELIST, PasswordType::PRIMARY_ACCOUNT_PASSWORD, nullptr); EXPECT_TRUE(GetUserEventService()->GetRecordedUserEvents().empty()); // PasswordReuseLookup unsigned long t = 0; for (const auto& it : kTestCasesWithoutVerdict) { service_->MaybeLogPasswordReuseLookupEvent( web_contents(), it.request_outcome, PasswordType::PRIMARY_ACCOUNT_PASSWORD, nullptr); ASSERT_TRUE(GetUserEventService()->GetRecordedUserEvents().empty()) << t; t++; } // PasswordReuseDialogInteraction service_->MaybeLogPasswordReuseDialogInteraction( 1000 /* navigation_id */, PasswordReuseDialogInteraction::WARNING_ACTION_TAKEN); ASSERT_TRUE(GetUserEventService()->GetRecordedUserEvents().empty()); } TEST_F(ChromePasswordProtectionServiceTest, VerifyPasswordReuseDetectedUserEventRecorded) { // Configure sync account type to GMAIL. CoreAccountInfo account_info = SetPrimaryAccount(kTestEmail); SetUpSyncAccount(kNoHostedDomainFound, account_info); service_->SetIsAccountSignedIn(true); NavigateAndCommit(GURL("https://www.example.com/")); // Case 1: safe_browsing_enabled = true profile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled, true); service_->MaybeLogPasswordReuseDetectedEvent(web_contents()); ASSERT_EQ(1ul, GetUserEventService()->GetRecordedUserEvents().size()); GaiaPasswordReuse event = GetUserEventService() ->GetRecordedUserEvents()[0] .gaia_password_reuse_event(); EXPECT_TRUE(event.reuse_detected().status().enabled()); // Case 2: safe_browsing_enabled = false profile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled, false); service_->MaybeLogPasswordReuseDetectedEvent(web_contents()); ASSERT_EQ(2ul, GetUserEventService()->GetRecordedUserEvents().size()); event = GetUserEventService() ->GetRecordedUserEvents()[1] .gaia_password_reuse_event(); EXPECT_FALSE(event.reuse_detected().status().enabled()); // Not checking for the extended_reporting_level since that requires setting // multiple prefs and doesn't add much verification value. } TEST_F(ChromePasswordProtectionServiceTest, VerifyPasswordReuseDetectedSecurityEventRecorded) { identity_test_env()->SetPrimaryAccount(kTestEmail); service_->set_username_for_last_shown_warning(kTestEmail); EXPECT_CALL(*security_event_recorder_, RecordGaiaPasswordReuse(_)) .WillOnce(WithArg<0>([&](const auto& message) { EXPECT_EQ(PasswordReuseLookup::REQUEST_SUCCESS, message.reuse_lookup().lookup_result()); EXPECT_EQ(PasswordReuseLookup::SAFE, message.reuse_lookup().verdict()); EXPECT_EQ("verdict_token", message.reuse_lookup().verdict_token()); })); service_->MaybeLogPasswordReuseLookupResultWithVerdict( web_contents(), PasswordType::OTHER_GAIA_PASSWORD, PasswordReuseLookup::REQUEST_SUCCESS, PasswordReuseLookup::SAFE, "verdict_token"); } // Check that the PaswordCapturedEvent timer is set for 1 min if password // hash is saved and no timer pref is set yet. TEST_F(ChromePasswordProtectionServiceTest, VerifyPasswordCaptureEventScheduledOnStartup) { // Configure sync account type to GMAIL. CoreAccountInfo account_info = SetPrimaryAccount(kTestEmail); SetUpSyncAccount(kNoHostedDomainFound, account_info); // Case 1: Check that the timer is not set in the ctor if no password hash is // saved. service_ = NewMockPasswordProtectionService( /*sync_password_hash=*/""); EXPECT_FALSE(service_->log_password_capture_timer_.IsRunning()); // Case 1: Timer is set to 60 sec by default. service_ = NewMockPasswordProtectionService( /*sync_password_hash=*/"some-hash-value"); EXPECT_TRUE(service_->log_password_capture_timer_.IsRunning()); EXPECT_EQ( 60, service_->log_password_capture_timer_.GetCurrentDelay().InSeconds()); } // Check that the timer is set for prescribed time based on pref. TEST_F(ChromePasswordProtectionServiceTest, VerifyPasswordCaptureEventScheduledFromPref) { // Pick a delay and store the deadline in the pref base::TimeDelta delay = base::TimeDelta::FromDays(13); SetDelayInPref(profile()->GetPrefs(), prefs::kSafeBrowsingNextPasswordCaptureEventLogTime, delay); // Configure sync account type to GMAIL. CoreAccountInfo account_info = SetPrimaryAccount(kTestEmail); SetUpSyncAccount(kNoHostedDomainFound, account_info); service_ = NewMockPasswordProtectionService( /*sync_password_hash=*/""); // Check that the timer is not set if no password hash is saved. EXPECT_EQ( 0, service_->log_password_capture_timer_.GetCurrentDelay().InSeconds()); // Save a password hash service_ = NewMockPasswordProtectionService( /*sync_password_hash=*/"some-hash-value"); // Verify the delay is approx correct (not exact since we're not controlling // the clock). base::TimeDelta cur_delay = service_->log_password_capture_timer_.GetCurrentDelay(); EXPECT_GE(14, cur_delay.InDays()); EXPECT_LE(12, cur_delay.InDays()); } // Check that we do log the event TEST_F(ChromePasswordProtectionServiceTest, VerifyPasswordCaptureEventRecorded) { // Configure sync account type to GMAIL. CoreAccountInfo account_info = SetPrimaryAccount(kTestEmail); SetUpSyncAccount(kNoHostedDomainFound, account_info); // Case 1: Default service_ ctor has an empty password hash. Should not log. service_->MaybeLogPasswordCapture(/*did_log_in=*/false); ASSERT_EQ(0ul, GetUserEventService()->GetRecordedUserEvents().size()); // Cases 2 and 3: With a password hash. Should log. service_ = NewMockPasswordProtectionService( /*sync_password_hash=*/"some-hash-value"); service_->SetIsAccountSignedIn(true); service_->MaybeLogPasswordCapture(/*did_log_in=*/false); ASSERT_EQ(1ul, GetUserEventService()->GetRecordedUserEvents().size()); GaiaPasswordCaptured event = GetUserEventService() ->GetRecordedUserEvents()[0] .gaia_password_captured_event(); EXPECT_EQ(event.event_trigger(), GaiaPasswordCaptured::EXPIRED_28D_TIMER); service_->MaybeLogPasswordCapture(/*did_log_in=*/true); ASSERT_EQ(2ul, GetUserEventService()->GetRecordedUserEvents().size()); event = GetUserEventService() ->GetRecordedUserEvents()[1] .gaia_password_captured_event(); EXPECT_EQ(event.event_trigger(), GaiaPasswordCaptured::USER_LOGGED_IN); } // Check that we reschedule after logging. TEST_F(ChromePasswordProtectionServiceTest, VerifyPasswordCaptureEventReschedules) { // Configure sync account type to GMAIL. CoreAccountInfo account_info = SetPrimaryAccount(kTestEmail); SetUpSyncAccount(kNoHostedDomainFound, account_info); // Case 1: Default service_ ctor has an empty password hash, so we don't log // or reschedule the logging. service_->MaybeLogPasswordCapture(/*did_log_in=*/false); EXPECT_FALSE(service_->log_password_capture_timer_.IsRunning()); // Case 2: A non-empty password hash. service_ = NewMockPasswordProtectionService( /*sync_password_hash=*/"some-hash-value"); service_->SetIsAccountSignedIn(true); service_->MaybeLogPasswordCapture(/*did_log_in=*/false); // Verify the delay is approx correct. Will be 24-28 days, +- clock drift. EXPECT_TRUE(service_->log_password_capture_timer_.IsRunning()); base::TimeDelta cur_delay = service_->log_password_capture_timer_.GetCurrentDelay(); EXPECT_GT(29, cur_delay.InDays()); EXPECT_LT(23, cur_delay.InDays()); } TEST_F(ChromePasswordProtectionServiceTest, VerifyPasswordReuseLookupUserEventRecorded) { // Configure sync account type to GMAIL. CoreAccountInfo account_info = SetPrimaryAccount(kTestEmail); SetUpSyncAccount(kNoHostedDomainFound, account_info); NavigateAndCommit(GURL("https://www.example.com/")); unsigned long t = 0; for (const auto& it : kTestCasesWithoutVerdict) { service_->MaybeLogPasswordReuseLookupEvent( web_contents(), it.request_outcome, PasswordType::PRIMARY_ACCOUNT_PASSWORD, nullptr); ASSERT_EQ(t + 1, GetUserEventService()->GetRecordedUserEvents().size()) << t; PasswordReuseLookup reuse_lookup = GetUserEventService() ->GetRecordedUserEvents()[t] .gaia_password_reuse_event() .reuse_lookup(); EXPECT_EQ(it.lookup_result, reuse_lookup.lookup_result()) << t; t++; } { auto response = std::make_unique<LoginReputationClientResponse>(); response->set_verdict_token("token1"); response->set_verdict_type(LoginReputationClientResponse::LOW_REPUTATION); service_->MaybeLogPasswordReuseLookupEvent( web_contents(), RequestOutcome::RESPONSE_ALREADY_CACHED, PasswordType::PRIMARY_ACCOUNT_PASSWORD, response.get()); ASSERT_EQ(t + 1, GetUserEventService()->GetRecordedUserEvents().size()) << t; PasswordReuseLookup reuse_lookup = GetUserEventService() ->GetRecordedUserEvents()[t] .gaia_password_reuse_event() .reuse_lookup(); EXPECT_EQ(PasswordReuseLookup::CACHE_HIT, reuse_lookup.lookup_result()) << t; EXPECT_EQ(PasswordReuseLookup::LOW_REPUTATION, reuse_lookup.verdict()) << t; EXPECT_EQ("token1", reuse_lookup.verdict_token()) << t; t++; } { auto response = std::make_unique<LoginReputationClientResponse>(); response->set_verdict_token("token2"); response->set_verdict_type(LoginReputationClientResponse::SAFE); service_->MaybeLogPasswordReuseLookupEvent( web_contents(), RequestOutcome::SUCCEEDED, PasswordType::PRIMARY_ACCOUNT_PASSWORD, response.get()); ASSERT_EQ(t + 1, GetUserEventService()->GetRecordedUserEvents().size()) << t; PasswordReuseLookup reuse_lookup = GetUserEventService() ->GetRecordedUserEvents()[t] .gaia_password_reuse_event() .reuse_lookup(); EXPECT_EQ(PasswordReuseLookup::REQUEST_SUCCESS, reuse_lookup.lookup_result()) << t; EXPECT_EQ(PasswordReuseLookup::SAFE, reuse_lookup.verdict()) << t; EXPECT_EQ("token2", reuse_lookup.verdict_token()) << t; t++; } } TEST_F(ChromePasswordProtectionServiceTest, VerifyGetDefaultChangePasswordURL) { CoreAccountInfo account_info = SetPrimaryAccount(kTestEmail); SetUpSyncAccount("example.com", account_info); EXPECT_EQ(GURL("https://accounts.google.com/" "AccountChooser?Email=foo%40example.com&continue=https%3A%2F%" "2Fmyaccount.google.com%2Fsigninoptions%2Fpassword%3Futm_" "source%3DGoogle%26utm_campaign%3DPhishGuard&hl=en"), service_->GetDefaultChangePasswordURL()); } TEST_F(ChromePasswordProtectionServiceTest, VerifyGetEnterprisePasswordURL) { // If enterprise change password url is not set. This will return the default // GAIA change password url. EXPECT_TRUE(service_->GetEnterpriseChangePasswordURL().DomainIs( "accounts.google.com")); // Sets enterprise change password url. GURL enterprise_change_password_url("https://changepassword.example.com"); profile()->GetPrefs()->SetString(prefs::kPasswordProtectionChangePasswordURL, enterprise_change_password_url.spec()); EXPECT_EQ(enterprise_change_password_url, service_->GetEnterpriseChangePasswordURL()); } TEST_F(ChromePasswordProtectionServiceTest, VerifyNavigationDuringPasswordOnFocusPingNotBlocked) { GURL trigger_url(kPhishingURL); NavigateAndCommit(trigger_url); PrepareRequest(LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, PasswordType::PASSWORD_TYPE_UNKNOWN, /*is_warning_showing=*/false); GURL redirect_url(kRedirectURL); content::MockNavigationHandle test_handle(redirect_url, main_rfh()); std::unique_ptr<PasswordProtectionNavigationThrottle> throttle = service_->MaybeCreateNavigationThrottle(&test_handle); EXPECT_EQ(nullptr, throttle); } TEST_F(ChromePasswordProtectionServiceTest, VerifyNavigationDuringPasswordReusePingDeferred) { GURL trigger_url(kPhishingURL); NavigateAndCommit(trigger_url); service_->SetIsSyncing(true); service_->SetIsAccountSignedIn(true); // Simulate a on-going password reuse request that hasn't received // verdict yet. PrepareRequest(LoginReputationClientRequest::PASSWORD_REUSE_EVENT, PasswordType::PRIMARY_ACCOUNT_PASSWORD, /*is_warning_showing=*/false); GURL redirect_url(kRedirectURL); bool was_navigation_resumed = false; content::MockNavigationHandle test_handle(redirect_url, main_rfh()); std::unique_ptr<PasswordProtectionNavigationThrottle> throttle = service_->MaybeCreateNavigationThrottle(&test_handle); ASSERT_NE(nullptr, throttle); throttle->set_resume_callback_for_testing( base::BindLambdaForTesting([&]() { was_navigation_resumed = true; })); // Verify navigation get deferred. EXPECT_EQ(content::NavigationThrottle::DEFER, throttle->WillStartRequest()); base::RunLoop().RunUntilIdle(); // Simulate receiving a SAFE verdict. SimulateRequestFinished(LoginReputationClientResponse::SAFE); base::RunLoop().RunUntilIdle(); EXPECT_EQ(true, was_navigation_resumed); // Verify that navigation can be resumed. EXPECT_EQ(content::NavigationThrottle::PROCEED, throttle->WillProcessResponse()); } TEST_F(ChromePasswordProtectionServiceTest, VerifyNavigationDuringModalWarningCanceled) { GURL trigger_url(kPhishingURL); NavigateAndCommit(trigger_url); // Simulate a password reuse request, whose verdict is triggering a modal // warning. PrepareRequest(LoginReputationClientRequest::PASSWORD_REUSE_EVENT, PasswordType::PRIMARY_ACCOUNT_PASSWORD, /*is_warning_showing=*/true); base::RunLoop().RunUntilIdle(); // Simulate receiving a phishing verdict. SimulateRequestFinished(LoginReputationClientResponse::PHISHING); base::RunLoop().RunUntilIdle(); GURL redirect_url(kRedirectURL); content::MockNavigationHandle test_handle(redirect_url, main_rfh()); std::unique_ptr<PasswordProtectionNavigationThrottle> throttle = service_->MaybeCreateNavigationThrottle(&test_handle); // Verify that navigation gets canceled. EXPECT_EQ(content::NavigationThrottle::CANCEL, throttle->WillStartRequest()); } TEST_F(ChromePasswordProtectionServiceTest, VerifyNavigationThrottleRemovedWhenNavigationHandleIsGone) { GURL trigger_url(kPhishingURL); NavigateAndCommit(trigger_url); service_->SetIsSyncing(true); service_->SetIsAccountSignedIn(true); // Simulate a on-going password reuse request that hasn't received // verdict yet. PrepareRequest(LoginReputationClientRequest::PASSWORD_REUSE_EVENT, PasswordType::PRIMARY_ACCOUNT_PASSWORD, /*is_warning_showing=*/false); GURL redirect_url(kRedirectURL); content::MockNavigationHandle test_handle(redirect_url, main_rfh()); std::unique_ptr<PasswordProtectionNavigationThrottle> throttle = service_->MaybeCreateNavigationThrottle(&test_handle); // Verify navigation get deferred. EXPECT_EQ(content::NavigationThrottle::DEFER, throttle->WillStartRequest()); EXPECT_EQ(1u, GetNumberOfNavigationThrottles()); // Simulate the deletion of the PasswordProtectionNavigationThrottle. throttle.reset(); base::RunLoop().RunUntilIdle(); // Expect no navigation throttle kept by |request_|. EXPECT_EQ(0u, GetNumberOfNavigationThrottles()); // Simulate receiving a SAFE verdict. SimulateRequestFinished(LoginReputationClientResponse::SAFE); base::RunLoop().RunUntilIdle(); } TEST_F(ChromePasswordProtectionServiceTest, VerifyUnhandledSyncPasswordReuseUponClearHistoryDeletion) { ASSERT_EQ(0, GetSizeofUnhandledSyncPasswordReuses()); GURL url_a("https://www.phishinga.com"); GURL url_b("https://www.phishingb.com"); GURL url_c("https://www.phishingc.com"); DictionaryPrefUpdate update(profile()->GetPrefs(), prefs::kSafeBrowsingUnhandledGaiaPasswordReuses); update->SetKey(Origin::Create(url_a).Serialize(), base::Value("navigation_id_a")); update->SetKey(Origin::Create(url_b).Serialize(), base::Value("navigation_id_b")); update->SetKey(Origin::Create(url_c).Serialize(), base::Value("navigation_id_c")); // Delete a https://www.phishinga.com URL. history::URLRows deleted_urls; deleted_urls.push_back(history::URLRow(url_a)); deleted_urls.push_back(history::URLRow(GURL("https://www.notinlist.com"))); service_->RemoveUnhandledSyncPasswordReuseOnURLsDeleted( /*all_history=*/false, deleted_urls); base::RunLoop().RunUntilIdle(); EXPECT_EQ(2, GetSizeofUnhandledSyncPasswordReuses()); service_->RemoveUnhandledSyncPasswordReuseOnURLsDeleted( /*all_history=*/true, {}); EXPECT_EQ(0, GetSizeofUnhandledSyncPasswordReuses()); } TEST_F(ChromePasswordProtectionServiceTest, VerifyOnPolicySpecifiedPasswordChangedEvent) { TestExtensionEventObserver event_observer(test_event_router_); // Preparing sync account. CoreAccountInfo account_info = SetPrimaryAccount(kTestEmail); SetUpSyncAccount("example.com", account_info); service_->SetIsAccountSignedIn(true); // Simulates change password. service_->OnGaiaPasswordChanged("foo@example.com", false); base::RunLoop().RunUntilIdle(); ASSERT_EQ(1, test_event_router_->GetEventCount( OnPolicySpecifiedPasswordChanged::kEventName)); auto captured_args = event_observer.PassEventArgs().GetList()[0].Clone(); EXPECT_EQ("foo@example.com", captured_args.GetString()); // If user is in incognito mode, no event should be sent. service_->ConfigService(true /*incognito*/, false /*SBER*/); service_->OnGaiaPasswordChanged("foo@example.com", false); base::RunLoop().RunUntilIdle(); // Event count should be unchanged. EXPECT_EQ(1, test_event_router_->GetEventCount( OnPolicySpecifiedPasswordChanged::kEventName)); } TEST_F(ChromePasswordProtectionServiceTest, VerifyTriggerOnPolicySpecifiedPasswordReuseDetectedForGsuiteUser) { TestExtensionEventObserver event_observer(test_event_router_); CoreAccountInfo account_info = SetPrimaryAccount(kTestEmail); SetUpSyncAccount("example.com", account_info); profile()->GetPrefs()->SetInteger(prefs::kPasswordProtectionWarningTrigger, PASSWORD_REUSE); NavigateAndCommit(GURL(kPasswordReuseURL)); service_->MaybeReportPasswordReuseDetected(web_contents(), kUserName, PasswordType::ENTERPRISE_PASSWORD, /*is_phishing_url =*/true); base::RunLoop().RunUntilIdle(); ASSERT_EQ(1, test_event_router_->GetEventCount( OnPolicySpecifiedPasswordReuseDetected::kEventName)); auto captured_args = event_observer.PassEventArgs().GetList()[0].Clone(); EXPECT_EQ(kPasswordReuseURL, captured_args.FindKey("url")->GetString()); EXPECT_EQ(kUserName, captured_args.FindKey("userName")->GetString()); EXPECT_TRUE(captured_args.FindKey("isPhishingUrl")->GetBool()); // If the reused password is not Enterprise password but the account is // GSuite, event should be sent. service_->SetAccountInfo(kUserName); service_->SetIsAccountSignedIn(true); service_->MaybeReportPasswordReuseDetected(web_contents(), kUserName, PasswordType::OTHER_GAIA_PASSWORD, /*is_phishing_url =*/true); base::RunLoop().RunUntilIdle(); ASSERT_EQ(2, test_event_router_->GetEventCount( OnPolicySpecifiedPasswordReuseDetected::kEventName)); // If no password is used , no event should be sent. service_->MaybeReportPasswordReuseDetected( web_contents(), kUserName, PasswordType::PASSWORD_TYPE_UNKNOWN, /*is_phishing_url =*/true); base::RunLoop().RunUntilIdle(); EXPECT_EQ(2, test_event_router_->GetEventCount( OnPolicySpecifiedPasswordReuseDetected::kEventName)); // If user is in incognito mode, no event should be sent. service_->ConfigService(true /*incognito*/, false /*SBER*/); service_->MaybeReportPasswordReuseDetected(web_contents(), kUserName, PasswordType::ENTERPRISE_PASSWORD, /*is_phishing_url =*/true); base::RunLoop().RunUntilIdle(); EXPECT_EQ(2, test_event_router_->GetEventCount( OnPolicySpecifiedPasswordReuseDetected::kEventName)); } TEST_F(ChromePasswordProtectionServiceTest, VerifyTriggerOnPolicySpecifiedPasswordReuseDetectedForGmailUser) { TestExtensionEventObserver event_observer(test_event_router_); // If user is a Gmail user and enterprise password is used, event should be // sent. CoreAccountInfo gmail_account_info = SetPrimaryAccount(kTestGmail); SetUpSyncAccount(kNoHostedDomainFound, gmail_account_info); profile()->GetPrefs()->SetInteger(prefs::kPasswordProtectionWarningTrigger, PASSWORD_REUSE); NavigateAndCommit(GURL(kPasswordReuseURL)); service_->MaybeReportPasswordReuseDetected(web_contents(), kUserName, PasswordType::ENTERPRISE_PASSWORD, /*is_phishing_url =*/true); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1, test_event_router_->GetEventCount( OnPolicySpecifiedPasswordReuseDetected::kEventName)); // If user is a Gmail user and not an enterprise password is used , no event // should be sent. service_->MaybeReportPasswordReuseDetected(web_contents(), kUserName, PasswordType::OTHER_GAIA_PASSWORD, /*is_phishing_url =*/true); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1, test_event_router_->GetEventCount( OnPolicySpecifiedPasswordReuseDetected::kEventName)); // If user is a Gmail user and no password is used , no event should be sent. service_->MaybeReportPasswordReuseDetected( web_contents(), kUserName, PasswordType::PASSWORD_TYPE_UNKNOWN, /*is_phishing_url =*/true); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1, test_event_router_->GetEventCount( OnPolicySpecifiedPasswordReuseDetected::kEventName)); } TEST_F(ChromePasswordProtectionServiceTest, VerifyGetWarningDetailTextSaved) { base::string16 warning_text = l10n_util::GetStringUTF16(IDS_PAGE_INFO_CHANGE_PASSWORD_DETAILS_SAVED); base::test::ScopedFeatureList feature_list; feature_list.InitAndEnableFeature( safe_browsing::kPasswordProtectionForSavedPasswords); ReusedPasswordAccountType reused_password_type; reused_password_type.set_account_type( ReusedPasswordAccountType::SAVED_PASSWORD); EXPECT_EQ(warning_text, service_->GetWarningDetailText(reused_password_type)); } TEST_F(ChromePasswordProtectionServiceTest, VerifyGetWarningDetailTextEnterprise) { base::string16 warning_text_non_sync = l10n_util::GetStringUTF16( IDS_PAGE_INFO_CHANGE_PASSWORD_DETAILS_SIGNED_IN_NON_SYNC); base::string16 generic_enterprise_warning_text = l10n_util::GetStringUTF16( IDS_PAGE_INFO_CHANGE_PASSWORD_DETAILS_ENTERPRISE); base::string16 warning_text_with_org_name = l10n_util::GetStringFUTF16( IDS_PAGE_INFO_CHANGE_PASSWORD_DETAILS_ENTERPRISE_WITH_ORG_NAME, base::UTF8ToUTF16("example.com")); base::string16 warning_text_sync = l10n_util::GetStringUTF16(IDS_PAGE_INFO_CHANGE_PASSWORD_DETAILS_SYNC); ReusedPasswordAccountType reused_password_type; reused_password_type.set_account_type(ReusedPasswordAccountType::GMAIL); reused_password_type.set_is_account_syncing(true); EXPECT_EQ(warning_text_sync, service_->GetWarningDetailText(reused_password_type)); reused_password_type.set_account_type( ReusedPasswordAccountType::NON_GAIA_ENTERPRISE); reused_password_type.set_is_account_syncing(false); EXPECT_EQ(generic_enterprise_warning_text, service_->GetWarningDetailText(reused_password_type)); { base::test::ScopedFeatureList feature_list; feature_list.InitAndEnableFeature( safe_browsing::kPasswordProtectionForSignedInUsers); reused_password_type.set_account_type(ReusedPasswordAccountType::GSUITE); EXPECT_EQ(warning_text_non_sync, service_->GetWarningDetailText(reused_password_type)); } reused_password_type.set_account_type(ReusedPasswordAccountType::GSUITE); reused_password_type.set_is_account_syncing(true); CoreAccountInfo core_account_info = SetPrimaryAccount(kTestEmail); SetUpSyncAccount(std::string("example.com"), core_account_info); EXPECT_EQ(warning_text_with_org_name, service_->GetWarningDetailText(reused_password_type)); reused_password_type.set_account_type( ReusedPasswordAccountType::NON_GAIA_ENTERPRISE); EXPECT_EQ(generic_enterprise_warning_text, service_->GetWarningDetailText(reused_password_type)); } TEST_F(ChromePasswordProtectionServiceTest, VerifyGetWarningDetailTextGmail) { base::string16 warning_text_non_sync = l10n_util::GetStringUTF16( IDS_PAGE_INFO_CHANGE_PASSWORD_DETAILS_SIGNED_IN_NON_SYNC); base::string16 warning_text_sync = l10n_util::GetStringUTF16(IDS_PAGE_INFO_CHANGE_PASSWORD_DETAILS_SYNC); base::test::ScopedFeatureList feature_list; feature_list.InitAndEnableFeature( safe_browsing::kPasswordProtectionForSignedInUsers); ReusedPasswordAccountType reused_password_type; reused_password_type.set_account_type(ReusedPasswordAccountType::GMAIL); EXPECT_EQ(warning_text_non_sync, service_->GetWarningDetailText(reused_password_type)); reused_password_type.set_is_account_syncing(true); EXPECT_EQ(warning_text_sync, service_->GetWarningDetailText(reused_password_type)); } TEST_F(ChromePasswordProtectionServiceTest, VerifyCanShowInterstitial) { // Do not show interstitial if policy not set for password_alert. ASSERT_FALSE( profile()->GetPrefs()->HasPrefPath(prefs::kSafeBrowsingWhitelistDomains)); GURL trigger_url = GURL(kPhishingURL); ReusedPasswordAccountType reused_password_type; reused_password_type.set_account_type( ReusedPasswordAccountType::SAVED_PASSWORD); EXPECT_FALSE(service_->CanShowInterstitial( RequestOutcome::TURNED_OFF_BY_ADMIN, reused_password_type, trigger_url)); reused_password_type.set_account_type(ReusedPasswordAccountType::GSUITE); reused_password_type.set_is_account_syncing(true); EXPECT_FALSE(service_->CanShowInterstitial( RequestOutcome::TURNED_OFF_BY_ADMIN, reused_password_type, trigger_url)); { base::test::ScopedFeatureList feature_list; feature_list.InitAndEnableFeature( safe_browsing::kPasswordProtectionForSignedInUsers); service_->SetAccountInfo(kUserName); reused_password_type.set_is_account_syncing(false); EXPECT_FALSE( service_->CanShowInterstitial(RequestOutcome::TURNED_OFF_BY_ADMIN, reused_password_type, trigger_url)); } reused_password_type.set_account_type( ReusedPasswordAccountType::NON_GAIA_ENTERPRISE); reused_password_type.set_is_account_syncing(false); EXPECT_FALSE(service_->CanShowInterstitial( RequestOutcome::TURNED_OFF_BY_ADMIN, reused_password_type, trigger_url)); reused_password_type.set_account_type( ReusedPasswordAccountType::SAVED_PASSWORD); EXPECT_FALSE(service_->CanShowInterstitial( RequestOutcome::PASSWORD_ALERT_MODE, reused_password_type, trigger_url)); // Show interstitial if user is a syncing GSuite user and the policy is set to // password_alert. reused_password_type.set_account_type(ReusedPasswordAccountType::GSUITE); reused_password_type.set_is_account_syncing(true); EXPECT_TRUE(service_->CanShowInterstitial(RequestOutcome::PASSWORD_ALERT_MODE, reused_password_type, trigger_url)); { base::test::ScopedFeatureList feature_list; feature_list.InitAndEnableFeature( safe_browsing::kPasswordProtectionForSignedInUsers); service_->SetAccountInfo(kUserName); reused_password_type.set_account_type(ReusedPasswordAccountType::GSUITE); reused_password_type.set_is_account_syncing(false); EXPECT_TRUE( service_->CanShowInterstitial(RequestOutcome::PASSWORD_ALERT_MODE, reused_password_type, trigger_url)); } // Show interstitial if user is a Enterprise user and the policy is set to // password_alert. reused_password_type.set_account_type( ReusedPasswordAccountType::NON_GAIA_ENTERPRISE); reused_password_type.set_is_account_syncing(false); EXPECT_TRUE(service_->CanShowInterstitial(RequestOutcome::PASSWORD_ALERT_MODE, reused_password_type, trigger_url)); // Add |trigger_url| to enterprise whitelist. base::ListValue whitelisted_domains; whitelisted_domains.AppendString(trigger_url.host()); profile()->GetPrefs()->Set(prefs::kSafeBrowsingWhitelistDomains, whitelisted_domains); reused_password_type.set_account_type( ReusedPasswordAccountType::SAVED_PASSWORD); reused_password_type.set_is_account_syncing(false); EXPECT_FALSE(service_->CanShowInterstitial( RequestOutcome::PASSWORD_ALERT_MODE, reused_password_type, trigger_url)); reused_password_type.set_account_type(ReusedPasswordAccountType::GSUITE); reused_password_type.set_is_account_syncing(true); EXPECT_FALSE(service_->CanShowInterstitial( RequestOutcome::PASSWORD_ALERT_MODE, reused_password_type, trigger_url)); } TEST_F(ChromePasswordProtectionServiceTest, VerifySendsPingForAboutBlank) { RequestOutcome reason; ReusedPasswordAccountType reused_password_type; reused_password_type.set_account_type( ReusedPasswordAccountType::SAVED_PASSWORD); service_->ConfigService(false /*incognito*/, true /*SBER*/); EXPECT_TRUE(service_->CanSendPing( LoginReputationClientRequest::PASSWORD_REUSE_EVENT, GURL("about:blank"), reused_password_type, &reason)); } } // namespace safe_browsing
[ "rjkroege@chromium.org" ]
rjkroege@chromium.org
0195f5d28438f3a447905dc5bca5f2b5ad2d4fc8
cd21437811a92f55c273980ad1a227f227555b74
/05_13_ex/05_13_ex/05_13_ex.cpp
f7f3b9869636620b6be86cc5121ed2f1c5605f63
[]
no_license
ycs-wikim/2021_oop1
7ef33d9844284409c4a0f38f4c6737c72ad0270e
7b17507763d3998614db82232c1cb4f1d6222fe4
refs/heads/main
2023-06-13T06:56:59.345696
2021-07-13T05:29:34
2021-07-13T05:29:34
345,536,285
6
3
null
null
null
null
UTF-8
C++
false
false
2,041
cpp
// 05_13_ex.cpp : 이 파일에는 'main' 함수가 포함됩니다. 거기서 프로그램 실행이 시작되고 종료됩니다. // #include <iostream> /// 함수 원형에 디폴트 인자를 사용했다면, 구현 함수에는 디폴트 인자를 생략해야 한다. void function(int x, int y = 15); void functionA(int a, int b = 23487, int c = 765, int d = 34) { printf("%d %d %d %d\n", a, b, c, d); } /// 가변인자는 오른쪽 끝에서부터 사용 가능. 중간에 일반 매개변수가 존재하면 안된다. /* void functionB(int a, int b = 23487, int c, int d = 34) { printf("%d %d %d %d\n", a, b, c, d); } */ int main() { functionA(78); functionA(678, 43287); function(3, 5); function(99); } /// 기본 인자 : 실인수가 없을 때 기본으로 설정할 값 void function(int x, int y) { printf("%d %d\n", x, y); } /* /// call-by-value : 일반 변수를 그대로 전달 -> 실인수 또는 임시 변수의 값이 매개변수로 복사 void cbv(int x) /// int x = k; 속도 : 3 { x++; } /// call-by-address : 주소를 전달 -> 실인수 또는 임시 변수의 값이 매개변수로 복사 void cba(int *x) /// int *x = &k; 1 { (*x)++; } /// call-by-reference : 주소를 전달 -> 실인수 또는 임시 변수의 값이 매개변수로 복사 void cbr(int &x) /// int &x = k; 1 { x++; } int main() { int k = 9; cbv(k); printf("K1 : %d\n", k); cba(&k); printf("K1 : %d\n", k); cbr(k); printf("K1 : %d\n", k); } /* /// 함수 원형(프로토타입) -> 함수 이름과 인수의 자료형 void AB(); /// 함수 구현체의 내용을 그대로 복사해서 붙인 경우 //void AB(int a, int b); /// 함수 구현체의 자료형만을 이용하여 선언 //void AB(int, int); /// 함수 구현체와 변수명이 다르게 선언 void AB(int xsdfkljh, int afisduhfi324); int main() { AB(); AB(3, 5); std::cout << "Hello World!\n"; } void AB() { printf("Hello AB\n"); } void AB(int a, int b) /// int a = 3, int b = 5 { printf("Hello AB(int, int)\n"); } */
[ "unangel@yuhan.ac.kr" ]
unangel@yuhan.ac.kr
a8c7aeb7a59c368622852049e1068ee86bad2c15
0033376f4c68df82a0ccbaf8765af526dda09e69
/ASSIGNMENTS/ASSIGNMENT_PHYSCIAL_PROTOTYPE/_Liu_WenYue_prototype.ino/_Liu_WenYue_prototype.ino.ino
7acc23bff52057bc09fd2a52b1c91cdf8a65773a
[]
no_license
Liu-WenYue/cart360-2019
1f7d8395e9e9da79728ea2ac997dfd0050737051
2d390a70671f0bbc37f99c91ec778034a3f16fef
refs/heads/master
2020-07-22T01:23:17.808875
2019-12-06T19:18:00
2019-12-06T19:18:00
207,028,779
0
0
null
null
null
null
UTF-8
C++
false
false
3,833
ino
/********************** PROTOTYPE CART 360 2019 ******************************* * Liu WenYue - November 07 2019 * Professor: Elio Bidinost & Sabine Rosenberg * This code is for the prototype of the project “THIS = THEN = THAT”. * * In this prototype, I will be testing the plushie's musical response function. * When user touch/press on the stomache of the plushie, audio generates using the pressure input. * * Library used: Mozzi Audio Synthesis Library for Arduino * URL for Mozzi: https://sensorium.github.io/Mozzi/ * */ #include <MozziGuts.h> #include <Oscil.h> // oscillator #include <tables/cos2048_int8.h> // table for Oscils to play #include <AutoMap.h> // maps unpredictable inputs to a range // desired carrier frequency max and min, for AutoMap const int MIN_CARRIER_FREQ = 22; const int MAX_CARRIER_FREQ = 440; // desired intensity max and min, for AutoMap, note they're inverted for reverse dynamics const int MIN_INTENSITY = 700; const int MAX_INTENSITY = 10; AutoMap kMapCarrierFreq(0,1023,MIN_CARRIER_FREQ,MAX_CARRIER_FREQ); AutoMap kMapIntensity(0,1023,MIN_INTENSITY,MAX_INTENSITY); // Define variables for the five touch pins. #define TOUCH_PIN_M A2 #define TOUCH_PIN_LU A4 #define TOUCH_PIN_LL A5 #define TOUCH_PIN_RU A1 #define TOUCH_PIN_RL A0 //int touchpins[4] = {A4, A5, A1, A0}; //int touchpressure[4] = {0}; // Define variables for the button pins. #define BUTTON_L 5 #define BUTTON_R 6 Oscil<COS2048_NUM_CELLS, AUDIO_RATE> aCarrier(COS2048_DATA); Oscil<COS2048_NUM_CELLS, AUDIO_RATE> aModulator(COS2048_DATA); int mod_ratio = 3; // harmonics long fm_intensity; // carries control info from updateControl() to updateAudio() void setup() { // Serial.begin(9600); // for Teensy 3.1, beware printout can cause glitches Serial.begin(115200); // set up the Serial output so we can look at the piezo values // set up the Serial output for debugging // Set the pin mode for the button pins. pinMode(BUTTON_L, INPUT); pinMode(BUTTON_R, INPUT); startMozzi(); // :)) } void updateControl(){ // test code for touch array // for (int i = 0; i < 4; i++) { // touchpressure[i] = mozziAnalogRead(touchpins[i]); // delay(5); // Serial.println(touchpressure[i]); // } // // int touchValue = touchpressure[random(0, 4)]; // test code for averaging // for (int i = 0; i < MeasurementsToAverage; i++) { // AverageTouchPressure1 += mozziAnalogRead(TOUCH_PIN_LU); // delay(1); // } // // touchValue1 = AverageTouchPressure1 /= MeasurementsToAverage; int touchValue = mozziAnalogRead(TOUCH_PIN_RU); // map the knob to carrier frequency int carrier_freq = kMapCarrierFreq(touchValue); // print the value to the Serial monitor for debugging Serial.print("carrier_freq = "); Serial.print(carrier_freq); Serial.print("\t"); // prints a tab //calculate the modulation frequency to stay in ratio int mod_freq = carrier_freq * mod_ratio; // set the FM oscillator frequencies to the calculated values aCarrier.setFreq(carrier_freq); aModulator.setFreq(mod_freq); // read the middle_press on the Analog input pin int middle_press= mozziAnalogRead(TOUCH_PIN_M); // value is 0-1023 // print the value to the Serial monitor for debugging Serial.print("middle_press = "); Serial.print(middle_press); Serial.print("\t"); // prints a tab fm_intensity = kMapIntensity(middle_press); Serial.print("fm_intensity = "); Serial.print(fm_intensity); Serial.println(); // print a carraige return for the next line of debugging info } int updateAudio(){ long modulation = fm_intensity * aModulator.next(); // Print the word in the Serial monitor Serial.print("Working!"); // updateAudio() is only called when this line is here. return aCarrier.phMod(modulation); // phMod does the FM } void loop() { audioHook(); }
[ "LiuWY0912@gmail.com" ]
LiuWY0912@gmail.com
b4838209c1438f93b0ab15462a7975c226dc0911
6ded1c6d0b6e892973642fed5eface7e8fd20679
/AppleKiwiRoot.cpp
17b368da88f2275d6255002a56e369ea09c5e5ad
[]
no_license
apple-oss-distributions/AppleKiwiRoot
a2a6db2db122756b62c698025b0f7f1d45b99c31
f7fb7c98552b21abd7bb25ab5fff23d6e823897d
refs/heads/main
2023-08-25T19:08:11.696743
2007-07-14T04:23:33
2021-10-06T04:40:20
413,589,678
1
2
null
null
null
null
UTF-8
C++
false
false
37,307
cpp
/* * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * The contents of this file constitute Original Code as defined in and * are subject to the Apple Public Source License Version 1.1 (the * "License"). You may not use this file except in compliance with the * License. Please obtain a copy of the License at * http://www.apple.com/publicsource and read it before using this file. * * This Original Code and all software distributed under the License are * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * * AppleKiwiRoot.cpp * Need something to match the device registry entry. * * */ #include <ppc/proc_reg.h> #include "AppleKiwiRoot.h" #include <IOKit/assert.h> #include <IOKit/IOTypes.h> #include <IOKit/IOLib.h> #include <IOKit/pci/IOPCIDevice.h> #include <libkern/OSByteOrder.h> #include <libkern/OSAtomic.h> #include <IOKit/IODeviceTreeSupport.h> #include <IOKit/IOPlatformExpert.h> #include <IOKit/pwr_mgt/IOPM.h> #include <IOKit/pwr_mgt/RootDomain.h> #include <IOKit/ata/IOATATypes.h> #include <kern/clock.h> #ifdef DLOG #undef DLOG #endif // debugging features // define to enable debug of the root class //#define KIWI_ROOT_DEBUG 1 // define to enable debug of the bay handles //#define KIWI_BAY_DEBUG 1 // define to enable debug of the interrupt controller. //#define KIWI_IC_DEBUG 1 #ifdef KIWI_ROOT_DEBUG #define DLOG(fmt, args...) IOLog(fmt, ## args) #else #define DLOG(fmt, args...) #endif #define kDeviceTypeString "pci-ide" #define kDevicetypeKey "device_type" #define kNameKey "name" #define kNameString "AppleKiwi" #define kPCIInlineKey "pci_inline" #define kMode6Key "mode6" #define k100mhz_pll 0x0d2b #define k133mhz_pll 0x0826 //property keys as defined in the 4.4.2a3 boot rom. #define kTrayPresentStatusKey "platform-drivePresent" #define kBayInUseStatusKey "platform-driveInUse" #define kBayPowerStatusKey "platform-drivePower" #define kBayOpenSwitchStatusKey "platform-driveSwitch" #define kBaySetActiveLEDKey "platform-setDriveInUse" #define kBaySetFailLEDKey "platform-setDriveFail" #define kBaySetPowerKey "platform-setDrivePower" // enablers for event mechanism #define kEnableInsertEvent "enable-drivePresent" #define kEnableSwitchEvent "enable-driveSwitch" #define kDisableInsertEvent "disable-drivePresent" #define kDisableSwitchEvent "disable-driveSwitch" // constants used for registering handlers for bay events. #define kRegisterForInsertEvent "register-drivePresent" #define kRegisterForSwitchEvent "register-driveSwitch" // Bay event constants. #define kInsertEvent 'Inst' #define kSwitchEvent 'Swch' //--------------------------------------------------------------------------- #define super IOService OSDefineMetaClassAndStructors ( AppleKiwiRoot, IOService ) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- bool AppleKiwiRoot::init(OSDictionary* properties) { DLOG("AppleKiwiRoot init start\n"); // Initialize instance variables. baseZeroMap = baseOneMap = baseTwoMap = baseThreeMap = baseFourMap = baseFiveMap = 0; baseAddrZero = baseAddrOne = baseAddrTwo = baseAddrThree = baseAddrFour = baseAddrFive = 0; pmRootDomain = 0; systemIsSleeping = false; chiplockOnBus = true; pdc271 = false; masterpllF = k100mhz_pll; if (super::init(properties) == false) { DLOG("AppleKiwiRoot: super::init() failed\n"); return false; } DLOG("AppleKiwiRoot init done\n"); return true; } /*--------------------------------------------------------------------------- * * Check and see if we really match this device. * override to accept or reject close matches based on further information ---------------------------------------------------------------------------*/ IOService* AppleKiwiRoot::probe(IOService* provider, SInt32* score) { OSData *compatibleEntry; DLOG("AppleKiwiRoot starting probe\n"); compatibleEntry = OSDynamicCast( OSData, provider->getProperty( "name" ) ); if ( compatibleEntry == 0 ) { // error unknown controller type. DLOG("AppleKiwiRoot failed getting compatible property\n"); return 0; } // test the compatible property for a match to the controller type name. if ( compatibleEntry->isEqualTo( kNameString, sizeof(kNameString)-1 ) == false ) { // not our type of controller DLOG("AppleKiwiRoot compatible property doesn't match\n"); return 0; } return this; } bool AppleKiwiRoot::start( IOService * provider ) { DLOG("AppleKiwiRoot: starting\n"); static const IOPMPowerState powerStates[ 2 ] = { { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, IOPMPowerOn, IOPMPowerOn, IOPMPowerOn, 0, 0, 0, 0, 0, 0, 0, 0 } }; IOPCIDevice *pciNub = (IOPCIDevice *)provider; if( !super::start( provider)) return( false); // test if pci inline is available if(pciNub->configRead8( kIOPCIConfigRevisionID) < 0x03) { chiplockOnBus = true; kiwiChipLock = IORecursiveLockAlloc(); if( !kiwiChipLock ) return false; DLOG("AppleKiwiRoot: pci inline not detected\n"); } else { DLOG("AppleKiwiRoot: pci inline available\n"); chiplockOnBus = false; conf40Val = pciNub->configRead8( 0x40); conf40Val |= 0x01; pciNub->configWrite8( 0x40, conf40Val); } // test if 20271 controller if(pciNub->configRead16( kIOPCIConfigDeviceID) == 0x6269) { pdc271 = true; masterpllF = k133mhz_pll; DLOG("AppleKiwiRoot: pdc271 detected\n"); } // Make sure IO space is on. pciNub->setIOEnable(true); // turn on the bus-mastering enable pciNub->setBusMasterEnable( true ); // enable mem access pciNub->setMemoryEnable(true); setupPDC270(provider); AppleKiwiIC* kiwiIC = new AppleKiwiIC; if( !kiwiIC ) { DLOG("AppleKiwiRoot: failed to create KiwiIC\n"); return false; } if( !kiwiIC->init(NULL) ) { DLOG("AppleKiwiRoot: failed to init KiwiIC\n"); return false; } //kiwiIC->attach( provider ); if( !kiwiIC->start(provider,baseAddrFive) ) { DLOG("AppleKiwiRoot: failed to start KiwiIC\n"); return false; } pmRootDomain = getPMRootDomain(); if (pmRootDomain != 0) { pmRootDomain->registerInterestedDriver(this); } // Show we are awake now: systemIsSleeping = false; PMinit(); registerPowerDriver(this,(IOPMPowerState *)powerStates,2); joinPMtree(this); // create the stack publishBelow(provider); DLOG("AppleKiwiRoot: started\n"); return( true); } /*--------------------------------------------------------------------------- * free() - the pseudo destructor. Let go of what we don't need anymore. * * ---------------------------------------------------------------------------*/ void AppleKiwiRoot::free() { if( baseZeroMap ) { baseZeroMap->release(); } if( baseOneMap ) { baseOneMap->release(); } if( baseTwoMap ) { baseTwoMap->release(); } if( baseThreeMap) { baseThreeMap->release(); } if( baseFourMap ) { baseFourMap->release(); } if( baseFiveMap ) { baseFiveMap->release(); } if( kiwiChipLock ) { IORecursiveLockFree( kiwiChipLock); kiwiChipLock = 0; } super::free(); } AppleKiwiDevice * AppleKiwiRoot::createNub( IORegistryEntry * from ) { AppleKiwiDevice * nub; nub = new AppleKiwiDevice; if( nub && !nub->init( from, gIODTPlane )) { nub->free(); nub = 0; } return( nub); } void AppleKiwiRoot::processNub(AppleKiwiDevice * nub) { if(!chiplockOnBus) { nub->setProperty(kPCIInlineKey, true ); } if( pdc271 ) { nub->setProperty(kMode6Key, true ); } nub->setDeviceMemory( getProvider()->getDeviceMemory()); nub->initProperties(); } void AppleKiwiRoot::publishBelow( IORegistryEntry * root ) { DLOG("AppleKiwiRoot publish below\n"); OSCollectionIterator * kids = 0; IORegistryEntry * next; AppleKiwiDevice * nub; // publish everything below, minus excludeList kids = IODTFindMatchingEntries( root, kIODTRecursive | kIODTExclusive, "('ata-disk','atapi-disk','disk')"); if( kids) { DLOG("AppleKiwiRoot found kids\n"); while( (next = (IORegistryEntry *)kids->getNextObject())) { if( 0 == (nub = createNub( next ))) continue; nub->attach( this ); processNub(nub); if( !nub->deviceIsPresent() ) { // float the bus pins if no drive is present; // figure out which bus this child is int busNum = 0; UInt32* gcrReg = (UInt32*) ( baseAddrFive + 0x1108 ); OSString* locationCompare = OSString::withCString( "1" ); if( locationCompare->isEqualTo( nub->getLocation() )) { gcrReg = (UInt32*) ( baseAddrFive + 0x1208 ); busNum = 1; } locationCompare->release(); *gcrReg |= 0x00000800; //LE format OSSynchronizeIO(); DLOG("AppleKiwiRoot - turning off empty bus %d\n", busNum); } } kids->release(); } } bool AppleKiwiRoot::compareNubName( const IOService * nub, OSString * name, OSString ** matched ) const { return( IODTCompareNubName( nub, name, matched ) || nub->IORegistryEntry::compareName( name, matched ) ); } IOReturn AppleKiwiRoot::getNubResources( IOService * nub ) { if( nub->getDeviceMemory()) return( kIOReturnSuccess ); IODTResolveAddressing( nub, "reg", getProvider()->getDeviceMemoryWithIndex(0) ); return( kIOReturnSuccess); } void AppleKiwiRoot::setupPDC270(IOService* provider) { IOPCIDevice *pciNub = (IOPCIDevice *)provider; baseFiveMap = pciNub->mapDeviceMemoryWithRegister( kIOPCIConfigBaseAddress5 ); if( baseFiveMap == 0 ) { DLOG("Failed to get base address maps\n"); return; } baseAddrFive = (UInt8*) baseFiveMap->getVirtualAddress(); DLOG("baseAddrFive = %lx \n", (UInt32) baseAddrFive); //Set pll program value OSWriteLittleInt16((void*) baseAddrFive, 0x1202, masterpllF); IOSleep( 10 ); // give it 10ms to stabilize. return; } void AppleKiwiRoot::getLock(bool lock) { if(!chiplockOnBus) return; if( lock ) { IORecursiveLockLock( kiwiChipLock); } else { IORecursiveLockUnlock( kiwiChipLock); } } IOReturn AppleKiwiRoot::powerStateWillChangeTo (IOPMPowerFlags theFlags, unsigned long, IOService* whichDevice) { if ( (whichDevice == pmRootDomain) && systemIsSleeping ) { if ((theFlags & IOPMPowerOn) || (theFlags & IOPMSoftSleep) ) { DLOG("KiwiRoot::powerStateWillChangeTo waking up\n"); systemIsSleeping = false; } //DLOG("KiwiRoot::powerStateDidChangeTo acknoledging power change flags = %lx\n", theFlags); } return IOPMAckImplied; } IOReturn AppleKiwiRoot::powerStateDidChangeTo (IOPMPowerFlags theFlags, unsigned long, IOService* whichDevice) { if ( ( whichDevice == pmRootDomain) && !systemIsSleeping ) { if (!(theFlags & IOPMPowerOn) && !(theFlags & IOPMSoftSleep) ) { DLOG("KiwiRoot::powerStateDidChangeTo - going to sleep\n"); // time to go to sleep getLock(true); systemIsSleeping = true; } //DLOG("KiwiRoot::powerStateDidChangeTo acknoledging power change flags = %lx\n", theFlags); } return IOPMAckImplied; } IOReturn AppleKiwiRoot::setPowerState ( unsigned long powerStateOrdinal, IOService* whatDevice ) { //DLOG( "AppleKiwiRoot::setPowerState - entered: ordinal = %ld, whatDevice = %p\n", powerStateOrdinal, whatDevice ); if( powerStateOrdinal == 0 && systemIsSleeping ) { DLOG("AppleKiwiRoot::setPowerState - power ordinal 0\n"); } if( powerStateOrdinal == 1 && !(systemIsSleeping) ) { DLOG("AppleKiwiRoot::setPowerState - power ordinal 1\n"); // time to wake up IOPCIDevice *pciNub = (IOPCIDevice *)getProvider(); if(!chiplockOnBus) { pciNub->configWrite8( 0x40, conf40Val); } OSWriteLittleInt16((void*) baseAddrFive, 0x1202, masterpllF); IODelay( 250 ); // allow PLL to stabilise getLock(false); } return IOPMAckImplied; } #pragma mark - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifdef DLOG #undef DLOG #endif //#define KIWI_BAY_DEBUG 1 #ifdef KIWI_BAY_DEBUG #define DLOG(fmt, args...) IOLog(fmt, ## args) #else #define DLOG(fmt, args...) #endif #undef super #define super IOService OSDefineMetaClassAndStructors(AppleKiwiDevice, IOService); enum { kKiwiDevCPowerStateCount = 2 }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bool AppleKiwiDevice::init( IORegistryEntry * from, const IORegistryPlane * inPlane ) { bool result = super::init(from, inPlane); bayPHandle = 0; bayState = kBayInitialState; eventGate = kEventsOff; childBusState = kChildBusNone; currPwrState = 1; // initial state is power on and running. return result; } // setup the cookies from the properties published for this nub. void AppleKiwiDevice::initProperties(void) { OSData* registryData = 0; IOReturn retval; static const IOPMPowerState powerStates[ kKiwiDevCPowerStateCount ] = { { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, IOPMPowerOn, IOPMPowerOn, IOPMPowerOn, 0, 0, 0, 0, 0, 0, 0, 0 } }; registryData = OSDynamicCast( OSData, getProperty("AAPL,phandle") ); if( registryData ) { bayPHandle = * ((UInt32*) registryData->getBytesNoCopy(0,4) ); DLOG("Kiwi Device found %s with data %lx\n", kTrayPresentStatusKey, bayPHandle); } // register for Bay Events here // we care about insertion events and removal handle switch events. char callName[255]; if( bayPHandle ) { snprintf(callName, sizeof(callName), "%s-%8lx", kRegisterForInsertEvent, bayPHandle); retval = callPlatformFunction(callName, true, (void*) &sBayEventOccured, (void*)this, (void*)kInsertEvent, 0 ); DLOG("AppleKiwiDevice registering handler %s returned %x\n", callName, retval); } else { DLOG( "AppleKiwiDevice bayPHandle not found, handler not registerd\n" ); } if( bayPHandle ) { snprintf(callName, sizeof(callName),"%s-%8lx", kRegisterForSwitchEvent, bayPHandle); retval = callPlatformFunction(callName, true, (void*) &sBayEventOccured, (void*) this, (void*)kSwitchEvent, 0 ); DLOG("AppleKiwiDevice registering handler %s returned %x\n", callName, retval); } else { DLOG( "AppleKiwiDevice bayPHandle not found, handler not registerd\n" ); } pmRootDomain = getPMRootDomain(); if (pmRootDomain != 0) { pmRootDomain->registerInterestedDriver(this); } // Show we are awake now: systemIsSleeping = false; PMinit(); // register as controlling driver registerPowerDriver( this, (IOPMPowerState *) powerStates, kKiwiDevCPowerStateCount); // join the tree getProvider()->joinPMtree( this); // OSCompareAndSwap(kEventsOff, kEventsOn, &eventGate ); enableBayEvents(); } IOService* AppleKiwiDevice::matchLocation( IOService * /* client */ ) { // DLOG("KiwiDevice matchLocation\n"); return( this ); } IOReturn AppleKiwiDevice::getResources( void ) { return( ((AppleKiwiRoot *)getProvider())->getNubResources( this )); } IOReturn AppleKiwiDevice::message (UInt32 type, IOService* provider, void* argument) { // look for a sneaky message from the child if( provider == 0 ) { switch( type ) { case 'onli': // device has succesfully come up. DLOG( "AppleKiwiRoot::message - message 'onli' received. Setting LED = green.\n" ); childBusState = kChildBusOnline; setLEDColor( kLEDGreen ); break; case 'fail': // device is now down DLOG( "AppleKiwiRoot::message - message 'fail' received. Setting LED = red.\n" ); childBusState = kChildBusNone; setLEDColor( kLEDRed ); break; case 'ofln': DLOG( "AppleKiwiRoot::message - message 'ofln' received. Setting LED = OFF.\n" ); setBayPower( kBayPowerOff); IOSleep(3000); setLEDColor( kLEDOff ); break; default: //DLOG( "AppleKiwiRoot::message - provider == 0, unhandled message (0x%08lX) received and ignored\n", type ); break; } } else { //DLOG( "AppleKiwiRoot::message - provider != 0, unhandled message (0x%08lX) being passed to ::super\n", type ); return super::message(type, provider, argument); } return kATANoErr; } /// Hot bay features // test to see if there's a device in the bay. bool AppleKiwiDevice::deviceIsPresent(void) { UInt32 isPresent = 0; IOReturn retval = 0; char callName[255]; if( bayPHandle ) { snprintf(callName, sizeof(callName),"%s-%8lx", kTrayPresentStatusKey, bayPHandle ); retval = callPlatformFunction(callName, false, (void *)&isPresent, 0, 0, 0); DLOG("AppleKiwiDevice::deviceIsPresent - call platform %s returned %08X, isPresent = %lu\n", callName, retval, isPresent); } else { DLOG( "AppleKiwiDevice::deviceIsPresent - bayPHandle not found. isPresent == 0\n" ); } if(isPresent) { bayState = kBayDriveNotLocked; snprintf(callName, sizeof( callName ),"%s-%8lx", kBayOpenSwitchStatusKey, bayPHandle ); retval = callPlatformFunction(callName, false, (void *)&isPresent, 0, 0, 0); DLOG("AppleKiwiDevice::deviceIsPresent - call platform %s returned %08X, isPresent = %lu\n", callName, retval, isPresent); if(isPresent) { bayState = kBayDriveLocked; makeBayReady(0); registerService(); } else { //DLOG( "AppleKiwiDevice::deviceIsPresent - isPresent && kBayDriveNotLocked. callPlatformFunction returned isPresent = 0. calling handleBayRemoved()\n" ); handleBayRemoved(); } } else { //DLOG( "AppleKiwiDevice::deviceIsPresent - isPresent == 0; calling handlBayRemoved()\n" ); handleBayRemoved(); bayState = kBayEmpty; } // now enable processing from the handle/bay switches. OSCompareAndSwap(kEventsOff, kEventsOn, &eventGate ); return isPresent; } // prepare bay by turning on power and enabling the interface void AppleKiwiDevice::makeBayReady(UInt32 delayMS) { setBayPower( kBayPowerOn); switch( childBusState ) { case kChildBusNone: case kChildBusStarting: // leave the LED alone. break; case kChildBusOnline: setLEDColor( kLEDGreen ); break; case kChildBusFail: setLEDColor(kLEDRed); break; } } // shutdown the bay when user starts removal void AppleKiwiDevice::handleBayRemoved(void) { // light is red now setLEDColor( kLEDRed ); // message the client (ata driver) with a kATARemovedEvent (IOATATypes.h) IORegistryEntry *myTempchild = getChildEntry(gIOServicePlane); // It mUst be an IOService to be terminated: IOService *ioServiceChild = OSDynamicCast(IOService, myTempchild); if (ioServiceChild != NULL) { DLOG("AppleKiwiDevice::handleBayRemoved - Sending removal message\n"); messageClient(kATARemovedEvent, ioServiceChild, (void*)OSString::withCString( kNameString ), 0); // the child driver will message us when tear down is complete } else { DLOG("AppleKiwiDevice::handleBayRemoved - removal event but no ioService child to message\n"); setBayPower( kBayPowerOff); setLEDColor( kLEDOff ); } childBusState = kChildBusNone; } void AppleKiwiDevice::enableBayEvents(void) { IOReturn retval; char callName[256]; snprintf(callName, sizeof( callName ), "%s-%8lx", kEnableInsertEvent, bayPHandle); retval = callPlatformFunction(callName, true, (void*) &sBayEventOccured, (void*)this, (void*)kInsertEvent, 0 ); snprintf(callName, sizeof( callName ), "%s-%8lx", kEnableSwitchEvent, bayPHandle); retval = callPlatformFunction(callName, true, (void*) &sBayEventOccured, (void*) this,(void*)kSwitchEvent, 0 ); DLOG("AppleKiwiDevice::enableBayEvents - enable handler '%s' returned %x\n", callName, retval); } void AppleKiwiDevice::disableBayEvents(void) { IOReturn retval; char callName[256]; snprintf(callName, sizeof( callName ), "%s-%8lx", kDisableInsertEvent, bayPHandle); retval = callPlatformFunction(callName, true, (void*) &sBayEventOccured, (void*)this, (void*)kInsertEvent, 0 ); snprintf(callName, sizeof( callName ), "%s-%8lx", kDisableSwitchEvent, bayPHandle); retval = callPlatformFunction(callName, true, (void*) &sBayEventOccured, (void*) this,(void*)kSwitchEvent, 0 ); DLOG("AppleKiwiDevice::disableBayEvents - disable handler '%s' returned %x\n", callName, retval); } // bring up a newly inserted device void AppleKiwiDevice::handleBayEvent(UInt32 event, UInt32 newData) { if( childBusState == kChildBusStarting ) { DLOG("AppleKiwiDevice::handleBayEvent - bus is still starting - handle bay event ignored.\n"); return; } // test for an unexpected removal event first, in case the drive is forced from the // socket or the handle is not working correctly as in EVT2 build. if( (event == kInsertEvent) && (newData == 0) // drive remove event && (bayState == kBayDriveLocked ) ) // wrong state!!! { DLOG("AppleKiwiDevice::handleBayEvent - drive was removed while bay in locked state!!!!\n"); handleBayRemoved(); bayState = kBayEmpty; return; } // normal operation is expected to be orderly with two kinds of events altering the state of the bay switch( bayState ) { case kBayInitialState: // initial state - unknown condition DLOG("AppleKiwiDevice::handleBayEvent - handleBay event status unknown!\n"); break; case kBayEmpty: // no drive present in bay // only legal event is device inserted if( (event == kInsertEvent) && (newData != 0) ) { bayState = kBayDriveNotLocked; DLOG( "AppleKiwiDevice::handleBayEvent - drive inserted\n"); // late change in handle design allows insertion with handle already closed. // this means that we won't get an event later. Check for this state and send ourself // a handle lock message if that happens. UInt32 bayBits = getBayStatus(); if( bayBits & 0x02) { // send lock event handleBayEvent( kSwitchEvent, 1); } } else { DLOG("AppleKiwiDevice::handleBayEvent - bay empty but got some other event!\n"); } break; case kBayDriveNotLocked: // drive present but handle unlocked. // two legal events - handle switch event or removal if( ( event == kInsertEvent ) && (newData == 0) ) { // bay is now empty bayState = kBayEmpty; DLOG("AppleKiwiDevice::handleBayEvent - bay empty\n"); } else if( (event == kSwitchEvent) && (newData != 0) ) { // bay is locked. childBusState = kChildBusStarting; setBayPower( kBayPowerOn); setLEDColor( kLEDOrange ); // when the ATADriver start succeeds, the light will turn green. DLOG("AppleKiwiDevice::handleBayEvent - bay latching. Data = %x\n", (unsigned int)newData); IOSleep( 1000 ); registerService(); bayState = kBayDriveLocked; DLOG("AppleKiwiDevice::handleBayEvent - handle locked, starting disk.\n"); } else { DLOG("AppleKiwiDevice::handleBayEvent - kBayDriveNotLocked got unexpected event %08lX, data %08lX\n", event, newData); } break; case kBayDriveLocked : // drive is present and locked in place. // only legal event is switch if( event == kSwitchEvent && newData == 0) { DLOG("AppleKiwiDevice::handleBayEvent - handle is being unlocked, stopping disk. Data = %x\n", (unsigned int) newData); handleBayRemoved(); bayState = kBayDrivePendRemoval; } else { DLOG("AppleKiwiDevice::handleBayEvent - kBayDriveLocked got unexpected event %08lX, data %08lX\n", event, newData); } break; case kBayDrivePendRemoval: // drive has been unlocked and must be removed for bay to activate again. if( (event == kInsertEvent) && (newData == 0) ) // drive remove event { // bay is now empty bayState = kBayEmpty; DLOG("AppleKiwiDevice::handleBayEvent - bay empty from pend-removal\n"); } else { DLOG("AppleKiwiDevice::handleBayEvent - event while in pend-removal state\n"); // ignore the event and leave the state in place. ; } break; // should never get here. default: DLOG("AppleKiwiDevice::handleBayEvent - (default case) handled unexpected default event %08lX, data %08lX\n", event, newData); break; } // enableBayEvents(); } // static handler registered with the system void AppleKiwiDevice::sBayEventOccured( void* p1, void* p2, void* p3, void* p4) { AppleKiwiDevice* me = (AppleKiwiDevice*) p1; if( OSCompareAndSwap( kEventsOn, kEventsOff, &(me->eventGate) ) ) { me->handleBayEvent( (UInt32)p2, (UInt32)p4 ); OSCompareAndSwap( kEventsOff, kEventsOn, &(me->eventGate) ); } } void AppleKiwiDevice::setLEDColor( UInt32 color) { char callGreen[255]; char callRed[255]; // enable power by calling platform function if( bayPHandle ) { snprintf(callGreen, sizeof( callGreen ), "%s-%8lx", kBaySetActiveLEDKey, bayPHandle ); snprintf(callRed, sizeof( callRed ), "%s-%8lx", kBaySetFailLEDKey, bayPHandle ); switch( color ) { case kLEDOff: callPlatformFunction(callGreen, false, (void *)0, 0, 0, 0); callPlatformFunction(callRed, false, (void *)0, 0, 0, 0); break; case kLEDGreen: callPlatformFunction(callGreen, false, (void *)1, 0, 0, 0); callPlatformFunction(callRed, false, (void *)0, 0, 0, 0); break; case kLEDOrange: callPlatformFunction(callGreen, false, (void *)1, 0, 0, 0); callPlatformFunction(callRed, false, (void *)1, 0, 0, 0); break; case kLEDRed: callPlatformFunction(callGreen, false, (void *)0, 0, 0, 0); callPlatformFunction(callRed, false, (void *)1, 0, 0, 0); break; default: break; } } } void AppleKiwiDevice::setBayPower( UInt32 powerState ) { // disable power char callName[255]; // enable power by calling platform function if( bayPHandle ) { snprintf(callName, sizeof( callName ),"%s-%8lx", kBaySetPowerKey, bayPHandle ); switch( powerState ) { case kBayPowerOn: DLOG( "AppleKiwiDevice::setBayPower - turning on drive bay power\n" ); callPlatformFunction(callName, false, (void*)1, 0, 0, 0); // pass 1 in first parm to enable power break; case kBayPowerOff: DLOG( "AppleKiwiDevice::setBayPower - turning OFF drive bay power\n" ); callPlatformFunction(callName, false, 0, 0, 0, 0); // pass 0 in first parm to disable power break; default: DLOG( "AppleKiwiDevice::setBayPower - power state not ON or OFF. Ignoring...\n" ); break; } } } UInt32 AppleKiwiDevice::getBayStatus( void ) { IOReturn errVal = 0; UInt32 platformStatus = 0; int retries; UInt32 bayBits = 0; // bit 0 = presence, bit 1 = handle state char callName[255]; snprintf(callName, sizeof( callName ), "%s-%8lx", kTrayPresentStatusKey, bayPHandle ); for( retries = 0; retries < 100; retries ++ ) { errVal = callPlatformFunction(callName, false, (void *)&platformStatus, 0, 0, 0); DLOG( "AppleKiwiDevice::getBayStatus(retry %d) - callPlatformFunction('%s') returned %d (0x%08X)\n", retries, callName, errVal, errVal ); if ( errVal == kIOReturnSuccess ) break; IOSleep( 100 ); // wait 100ms and try again } if( platformStatus ) { bayBits |= 0x01; } platformStatus = 0; snprintf(callName, sizeof( callName ), "%s-%8lx", kBayOpenSwitchStatusKey, bayPHandle ); for( retries = 0; retries < 100; retries ++ ) { errVal = callPlatformFunction(callName, false, (void *)&platformStatus, 0, 0, 0); DLOG( "AppleKiwiDevice::getBayStatus(retry %d) - callPlatformFunction('%s') returned %d (0x%08X)\n", retries, callName, errVal, errVal ); if ( errVal == kIOReturnSuccess ) break; IOSleep( 100 ); // wait 100ms and try again } if( platformStatus ) { bayBits |= (0x02); } if(bayBits == 0x02 ) { DLOG("AppleKiwiDevice::getBayStatus - bay handles in invalid state!!!\n"); ; } return bayBits; } IOReturn AppleKiwiDevice::setPowerState ( unsigned long powerStateOrdinal, IOService* whatDevice ) { if( powerStateOrdinal == 0 && systemIsSleeping ) { DLOG("AppleKiwiDevice::setPowerState - power ordinal 0\n"); currPwrState = 0; // offline or sleep. } UInt32 states[4] = { kBayEmpty, kBayDriveNotLocked, 0xffffffff, kBayDriveLocked}; // 00=empty, 01=present but not locked, 10=invalid state, 11=locked if( powerStateOrdinal == 1 && (currPwrState == 0) && !(systemIsSleeping) ) { DLOG("AppleKiwiDevice::setPowerState - power ordinal 1\n"); if( bayState == kBayDrivePendRemoval ) { // qualify a sleep event as the same as removal and insert back to the unlocked state bayState = kBayDriveNotLocked; } UInt32 bayBits = getBayStatus(); UInt32 bayStatNow = states[bayBits]; if( bayBits == 0x02 ) { // invalid state - handle locked but no carrier present? bayStatNow = kBayEmpty; } if( bayStatNow == bayState ) { //everything is cool just restore the previous power state if( bayState == kBayDriveLocked) { makeBayReady( 0 ); } else { setLEDColor( kLEDOff ); setBayPower( kBayPowerOff ); } } // something has changed across sleep - we will now callHandleBayEvent with // the event and the state to move the bay state machine along to reflect the current bay status. switch( bayState ) { case kBayEmpty: if( bayBits & 0x01 ) { // send insert event DLOG( "AppleKiwiDevice::setPowerState - send insert event\n" ); handleBayEvent( kInsertEvent, 1); } if( bayBits & 0x02) { // send lock event DLOG( "AppleKiwiDevice::setPowerState - send lock event\n" ); handleBayEvent( kSwitchEvent, 1); } break; case kBayDriveNotLocked: if( !(bayBits & 0x01) ) { // send remove event DLOG( "AppleKiwiDevice::setPowerState - send remove event\n" ); handleBayEvent( kInsertEvent, 0); } else if( bayBits & 0x02) { // send lock event DLOG( "AppleKiwiDevice::setPowerState - send lock event\n" ); handleBayEvent( kSwitchEvent, 1); } break; case kBayDriveLocked: if( !(bayBits & 0x02)) { //send unlock event DLOG( "AppleKiwiDevice::setPowerState - send unlock event\n" ); handleBayEvent( kSwitchEvent, 0); } if( !(bayBits & 0x01) ) { // send remove event DLOG( "AppleKiwiDevice::setPowerState - send remove event\n" ); handleBayEvent( kInsertEvent, 0); } break; default: // nonsensical state //DLOG( "AppleKiwiDevice::setPowerState - unexpected bay state (%ld, 0x%08lX). Ignoring ...\n", bayState, bayState ); break; } } return IOPMAckImplied; } IOReturn AppleKiwiDevice::powerStateWillChangeTo (IOPMPowerFlags theFlags, unsigned long, IOService* whichDevice) { if ( ( whichDevice == pmRootDomain) && ! systemIsSleeping ) { if (!(theFlags & IOPMPowerOn) && !(theFlags & IOPMSoftSleep) ) { DLOG("AppleKiwiDevice::powerStateWillChangeTo - going to sleep\n"); // time to go to sleep systemIsSleeping = true; } } else { DLOG( "AppleKiwiDevice::powerStateWillChangeTo - state change not handled!\n" ); ; } return IOPMAckImplied; } IOReturn AppleKiwiDevice::powerStateDidChangeTo (IOPMPowerFlags theFlags, unsigned long, IOService* whichDevice) { if ( (whichDevice == pmRootDomain) && systemIsSleeping ) { if ((theFlags & IOPMPowerOn) || (theFlags & IOPMSoftSleep) ) { DLOG("AppleKiwiDevice::powerStateDidChangeTo - waking up\n"); // time to wake up systemIsSleeping = false; } } else { DLOG( "AppleKiwiDevice::powerStateDidChangeTo - state change not handled!\n" ); ; } return IOPMAckImplied; } #pragma mark - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifdef DLOG #undef DLOG #endif #ifdef KIWI_IC_DEBUG #define DLOG(fmt, args...) IOLog(fmt, ## args) #else #define DLOG(fmt, args...) #endif #undef super #define super IOService #undef super #define super IOInterruptController OSDefineMetaClassAndStructors(AppleKiwiIC, IOInterruptController); enum { kIOSLICPowerStateCount = 2 }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bool AppleKiwiIC::start(IOService *provider, UInt8* inBar5) { if( !provider || !inBar5 ) return false; // static const IOPMPowerState powerStates[ kIOSLICPowerStateCount ] = { // { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // { 1, IOPMPowerOn, IOPMPowerOn, IOPMPowerOn, 0, 0, 0, 0, 0, 0, 0, 0 } // }; gcr0 = (volatile UInt32*) (inBar5 + 0x1108); gcr1 = (volatile UInt32*) (inBar5 + 0x1208); if (!super::start(provider)) { DLOG ("AppleKiwiIC::start - super::start(provider) returned false\n"); return false; } // remember this, as we will need it to call disable/enableInterrupt myProvider = provider; interruptControllerName = (OSSymbol *)IODTInterruptControllerName( provider ); if (interruptControllerName == 0) { DLOG ("AppleKiwiIC::start - interruptControllerName is NULL\n"); return false; } UInt32 numVectors = 2; UInt32 sizeofVectors = numVectors * sizeof(IOInterruptVector); // Allocate the memory for the vectors. vectors = (IOInterruptVector *)IOMalloc(sizeofVectors); if (vectors == NULL) { DLOG ("AppleKiwiIC::start - cannot allocate vectors\n"); return false; } bzero(vectors, sizeofVectors); // Allocate locks for the vectors. for (unsigned int cnt = 0; cnt < numVectors ; cnt++) { vectors[cnt].interruptLock = IOLockAlloc(); if (vectors[cnt].interruptLock == NULL) { for (cnt = 0; cnt < numVectors; cnt++) { if (vectors[cnt].interruptLock != NULL) IOLockFree(vectors[cnt].interruptLock); } DLOG ("AppleKiwiIC::start - cannot allocate lock for vectors[%d]\n", cnt); return false; } } // initialize the interrupt control bits to mask propogation *gcr0 &= (~ 0x00000200); // little endian format *gcr1 &= (~ 0x00000400); // little endian format provider->registerInterrupt(0, this, getInterruptHandlerAddress(), 0); // Register this interrupt controller so clients can find it. getPlatform()->registerInterruptController(interruptControllerName, this); provider->enableInterrupt(0); DLOG ("AppleKiwiIC::start - finished\n"); return true; } IOReturn AppleKiwiIC::getInterruptType(IOService *nub, int source, int *interruptType) { if (interruptType == 0) return kIOReturnBadArgument; *interruptType = kIOInterruptTypeLevel; return kIOReturnSuccess; } IOInterruptAction AppleKiwiIC::getInterruptHandlerAddress(void) { // return (IOInterruptAction) &AppleKiwiIC::handleInterrupt ; // change for gcc 4 return OSMemberFunctionCast(IOInterruptAction, this, &AppleKiwiIC::handleInterrupt) ; } IOReturn AppleKiwiIC::handleInterrupt( void* /*refCon*/, IOService* /*nub*/, int /*source*/ ) { long vectorNumber = 0; IOInterruptVector *vector; // unsigned short events; // iterate each possible interrupt vector and let it decide whether it wants to // handle the interrupt. for(int i = 0; i < 2; i++) { vectorNumber = i; vector = &vectors[vectorNumber]; vector->interruptActive = 1; #if defined( __PPC__ ) sync(); isync(); #endif if (!vector->interruptDisabledSoft) { #if defined( __PPC__ ) isync(); #endif // Call the handler if it exists. if (vector->interruptRegistered) { vector->handler(vector->target, vector->refCon, vector->nub, vector->source); if (vector->interruptDisabledSoft) { // Hard disable the source. vector->interruptDisabledHard = 1; disableVectorHard(vectorNumber, vector); } } } else { // Hard disable the source. vector->interruptDisabledHard = 1; disableVectorHard(vectorNumber, vector); } vector->interruptActive = 0; } return kIOReturnSuccess; } bool AppleKiwiIC::vectorCanBeShared(long vectorNumber, IOInterruptVector *vector) { return false; } void AppleKiwiIC::initVector(long vectorNumber, IOInterruptVector *vector) { return; } void AppleKiwiIC::disableVectorHard(long vectorNumber, IOInterruptVector *vector) { myProvider->disableInterrupt( 0 ); #if 0 switch( vectorNumber ) { case 0: //*gcr0 |= 0x00000200; // little endian formatted OSSynchronizeIO(); break; case 1: //*gcr1 |= 0x00000400; // little endian formatted OSSynchronizeIO(); break; default: break; // ??? should not happen } } #endif } void AppleKiwiIC::enableVector(long vectorNumber, IOInterruptVector *vector) { myProvider->enableInterrupt( 0 ); #if 0 switch( vectorNumber ) { case 0: //*gcr0 &= (~ 0x00000200); // little endian formatted OSSynchronizeIO(); break; case 1: //*gcr1 &= (~ 0x00000400); // little endian formatted OSSynchronizeIO(); break; default: break; // ??? should not happen } #endif } IOReturn AppleKiwiIC::setPowerState ( unsigned long powerStateOrdinal, IOService* whatDevice ) { return IOPMAckImplied; }
[ "91980991+AppleOSSDistributions@users.noreply.github.com" ]
91980991+AppleOSSDistributions@users.noreply.github.com
84875319f84dd5b005f00247dfe78d413aa80e68
aac1e6a799e7b4df4008ba4334b32e30ce254ff6
/practice/hsm_threads.cpp
f16531debba17f01502782766054e9adeca4aa86
[]
no_license
so1dier/practice_cpp
7c4b73572fd04cade0d6810cb06224a9b0bdb61b
91d74f49c93d63c464e8d1b55ce07b86ab7a3cf1
refs/heads/master
2020-04-11T15:42:20.587289
2019-03-11T09:13:15
2019-03-11T09:13:15
161,900,404
0
0
null
null
null
null
UTF-8
C++
false
false
6,753
cpp
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <thread> #include <iostream> #include <string> #include <mutex> #include <condition_variable> #include <chrono> std::mutex m; std::condition_variable cv; std::string data; bool ready=false; bool processed=false; void WorkerThreadWait() { //wait until main() sends data std::unique_lock<std::mutex> lk(m); //WAIT cv.wait(lk, []{return ready;}); //after the wait, we own the lock. std::cout << __FUNCTION__ << " thread is processing data" << std::endl; data += " after processing"; //send data back to main() processed = true; std::cout << __FUNCTION__ << " thread signals data processing completed" << std::endl; //Manual unlocking is done before notifying, to avoid waking up //the waiting rhead onlu to block again lk.unlock(); cv.notify_one(); } void WorkerThreadWaitFor() { //wait until main() sends data std::unique_lock<std::mutex> lk(m); //WAIT_FOR if(cv.wait_for(lk, std::chrono::seconds(1), []{return ready;})) { std::cout << __FUNCTION__ << " thread finished waiting" << std::endl; } else { std::cout << __FUNCTION__ << " thread timed out" << std::endl; } //after the wait, we own the lock. std::cout << __FUNCTION__ << " thread is processing data" << std::endl; data += " after processing"; //send data back to main() processed = true; std::cout << __FUNCTION__ << "thread signals data processing completed" << std::endl; //Manual unlocking is done before notifying, to avoid waking up //the waiting rhead onlu to block again lk.unlock(); cv.notify_one(); } void WorkerThreadWaitUntil() { //wait until main() sends data std::unique_lock<std::mutex> lk(m); //WAIT_UNTIL if(cv.wait_until(lk, std::chrono::system_clock::now() + std::chrono::seconds(1), []{return ready;})) { std::cout << __FUNCTION__ << " thread finished waiting" << std::endl; } else { std::cout << __FUNCTION__ << " thread timed out" << std::endl; } //after the wait, we own the lock. std::cout << __FUNCTION__ << " thread is processing data" << std::endl; data += " adter processing"; //send data back to main() processed = true; std::cout << __FUNCTION__ << " thread signals data processing completed" << std::endl; //Manual unlocking is done before notifying, to avoid waking up //the waiting rhead onlu to block again lk.unlock(); cv.notify_one(); } void error(const char *msg) { perror(msg); exit(0); } //int WorkerSocket(int argc, char *argv[]) void WorkerSocket(int argc, char *argv[]) { //wait until main() sends data std::unique_lock<std::mutex> lk(m); //WAIT_FOR //if(cv.wait_for(lk, // std::chrono::seconds(1), // []{return ready;})) // //{ // std::cout << __FUNCTION__ << " thread finished waiting" << std::endl; //} //else //{ // std::cout << __FUNCTION__ << " thread timed out" << std::endl; //} cv.wait_for(lk, []{return ready;}); //after the wait, we own the lock. std::cout << __FUNCTION__ << " thread is processing data" << std::endl; //data += " after processing"; int sockfd, portno, n; struct sockaddr_in serv_addr; struct hostent *server; char buffer[256]; if (argc < 3) { fprintf(stderr,"usage %s hostname port\n", argv[0]); processed = true; lk.unlock(); cv.notify_one(); exit(0); } portno = atoi(argv[2]); sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) { processed = true; lk.unlock(); cv.notify_one(); error("ERROR opening socket"); } server = gethostbyname(argv[1]); if (server == NULL) { fprintf(stderr,"ERROR, no such host\n"); processed = true; lk.unlock(); cv.notify_one(); exit(0); } bzero((char *) &serv_addr, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length); serv_addr.sin_port = htons(portno); if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) { processed = true; lk.unlock(); cv.notify_one(); error("ERROR connecting"); } int iteration = 0; while (1) { //printf("Please enter the message: "); bzero(buffer,256); std::this_thread::sleep_for(std::chrono::seconds(1)); printf("Out of sleeping\n"); //fgets(buffer,255,stdin); sprintf(buffer, "%d", ++iteration); n = write(sockfd,buffer,strlen(buffer)); if (n < 0) { processed = true; lk.unlock(); cv.notify_one(); error("ERROR writing to socket"); } bzero(buffer,256); n = read(sockfd,buffer,255); if (n < 0) { processed = true; lk.unlock(); cv.notify_one(); error("ERROR reading from socket"); } printf(">>reply inside thread: %s\n",buffer); data = buffer; //send data back to main() processed = true; std::cout << __FUNCTION__ << "thread signals data processing completed" << std::endl; //Manual unlocking is done before notifying, to avoid waking up //the waiting rhead onlu to block again lk.unlock(); cv.notify_one(); } close(sockfd); } int main(int argc, char* argv[]) { //std::thread worker_wait(WorkerThreadWait); //std::thread worker_wait_for(WorkerThreadWaitFor); //std::thread worker_wait_until(WorkerThreadWaitUntil); std::thread worker_socket(WorkerSocket, argc, argv); data = "Example data"; while(1) { //send data to worker thread { std::lock_guard<std::mutex> lk(m); ready = true; //ready = false; std::cout << "main() signals data ready for processing" << std::endl; } cv.notify_one(); //wait for worker { std::unique_lock<std::mutex> lk(m); cv.wait(lk, []{return processed;}); } } std::cout << "Back in main(), data = " << data << std::endl; //worker_wait.join(); //worker_wait_for.join(); //worker_wait_until.join(); worker_socket.join(); }
[ "dgolitsynski@emerchants.com.au" ]
dgolitsynski@emerchants.com.au
2aaeeff477bb1448275f204a3b9718766d5105a2
88a4ad819500a46934f31f2cdff872bd4c2cef20
/hit/include/common/utils.h
4a6202355218903f6c532d70aa1028d5c9b79234
[]
no_license
kaikai2/hitca
41508d2d5290a06dc8f3e5337f1a67b980581333
804a5c07a7214a273a22476df40e58b2c8bb5549
refs/heads/master
2020-05-23T14:11:32.256659
2013-05-23T06:52:47
2013-05-23T06:52:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,151
h
#ifndef UTILS_H #define UTILS_H #include <cmath> #include <cassert> // not allowed to copy class NoCopy { protected: NoCopy() { } private: NoCopy(const NoCopy &o) { o; } NoCopy &operator = (const NoCopy &o) { return o, *this; } }; // singleton template<typename T> class Singleton : public NoCopy { static T *ms_Singleton; public: Singleton() { assert(ms_Singleton == 0); ms_Singleton = static_cast<T *>(this); } virtual ~Singleton() { assert(ms_Singleton); ms_Singleton = 0; } static T& getSingleton() { assert(ms_Singleton); return *ms_Singleton; } static T* getSingletonPtr() { return ms_Singleton; } virtual void releaseSingleton() { } }; #define DEF_SINGLETON(c) \ template<> c *Singleton<c>::ms_Singleton = 0 inline float sign(float x) { return (x < 0.0f)? -1.0f : 1.0f; } inline float frand(float x = 1.0f) { return (rand() / (float) RAND_MAX) * x; } inline float Pi() { static const float pi = atan(1.0f) * 4.0f; return pi; } #endif//UTILS_H
[ "zikaizhang@gmail.com" ]
zikaizhang@gmail.com
b6bb03bd8d88ec1b72f549367baf284180158d40
c01033791350d8774512719dc355ab3108961010
/NTupleMaker/test/Mt2/Nt2_332_Calculator.h
5e52433afd2cdb9010700f1ff5a4651dd9c5b5e2
[]
no_license
bobovnii/Stau
6a89180e686785e51d9d65064b569ddb3966c985
f442a26fb5c5f94190ee45f74f8184dc20861e8d
refs/heads/8020
2021-01-11T18:32:12.304538
2018-09-28T10:12:23
2018-09-28T10:12:23
79,561,902
1
1
null
2019-06-06T10:41:09
2017-01-20T13:36:42
C++
UTF-8
C++
false
false
1,286
h
// Header file for the Oxbridge Stransverse Mass Library -- oxbridgekinetics. // See http://www.hep.phy.cam.ac.uk/~lester/mt2/index.html // Authors: Christopher Lester and Alan Barr #ifndef NT2_332_CALCULATOR_H #define NT2_332_CALCULATOR_H #include "Mt2Vectors.h" #include "Mt2Calculator.h" namespace Mt2 { /** Class which knows how to calculate N_T2. Please take care when choosing the appropriate function to use for your analysis. @author Alan Barr & Chris Lester @date 9 Feb 2006 and onwards */ class Nt2_332_Calculator : public Mt2Calculator { public: /** nt2_332 Calculate N_T2 knowing ptmiss not pvis-transverse-lorentz vec */ virtual double nt2_332(const LorentzTransverseVector& visibleA, // 3 d.o.f. const LorentzTransverseVector& visibleB, // 3 d.o.f. const TwoVector& ptmiss, // 2 d.o.f. const double mHeavy1, const double mHeavy2) = 0; virtual double nt2_332_Sq(const LorentzTransverseVector& visibleA, // 3 d.o.f. const LorentzTransverseVector& visibleB, // 3 d.o.f. const TwoVector& ptmiss, // 2 d.o.f. const double mHeavy1, const double mHeavy2) = 0; Nt2_332_Calculator(const std::string & algName) : Mt2Calculator(algName) {}; }; } #endif
[ "alexis.kalogeropoulos@cern.ch" ]
alexis.kalogeropoulos@cern.ch
6ddf05bac3642176f7953a49817d49de3423df86
f073895081af9f7c8b588dc674bb4ef6ae6f96a3
/include/nodes/DateDiffNode.hpp
9a9824ecde10de90a0144f0fe3a5cacad27fb677
[ "BSD-3-Clause" ]
permissive
sempr-tk/sempr
8291cd19082a130603c11baa8e4a3534dfc01c8c
2f3b04c031d70b9675ad441f97728a8fb839abed
refs/heads/master
2021-08-29T13:43:51.606247
2021-08-11T08:56:24
2021-08-11T08:56:24
114,119,870
9
1
NOASSERTION
2021-08-13T11:48:31
2017-12-13T12:46:44
C++
UTF-8
C++
false
false
687
hpp
#ifndef SEMPR_DATEDIFFNODE_HPP_ #define SEMPR_DATEDIFFNODE_HPP_ #include <rete-core/Builtin.hpp> #include <rete-core/Accessors.hpp> namespace sempr { /* Compute the difference in days between two date strings, format: YYYY-MM-DD HH:MM:SS */ class DateDiffNode : public rete::Builtin { public: DateDiffNode(rete::PersistentInterpretation<std::string> date1, rete::PersistentInterpretation<std::string> date2); rete::WME::Ptr process(rete::Token::Ptr) override; bool operator == (const rete::BetaNode& other) const override; private: rete::PersistentInterpretation<std::string> date1_; rete::PersistentInterpretation<std::string> date2_; }; } #endif
[ "juan.saborio@dfki.de" ]
juan.saborio@dfki.de
eb61974d2cb4c87915344c33b8fdc9dabf1e7188
9bd74a4d490f0ec2cfc90d1e53d4070c9bd46a2b
/3D Shooter/Core/ShaderLoader.hpp
e5c50edad7e05b2083b6a262b8608d91475e311b
[]
no_license
KPNBOrganization/shooter
ff1a87f083f9af8d7923e43df4fa2097761a85e4
38b6d732c04613a46d3add48c71cadcb63a8784a
refs/heads/master
2020-07-08T00:27:02.572444
2019-09-08T13:17:44
2019-09-08T13:17:44
203,516,600
0
0
null
null
null
null
UTF-8
C++
false
false
466
hpp
#ifndef SHADER_LOADER_H #define SHADER_LOADER_H #endif #include <iostream> #include "../libs/glew/glew.h" #include "../libs/freeglut/freeglut.h" namespace Core { class ShaderLoader { private: std::string ReadShader(char* filename); GLuint CreateShader(GLenum shaderType, std::string source, char* shaderName); public: ShaderLoader(void); ~ShaderLoader(void); GLuint CreateProgram(char* VertexShaderFileName, char* FragmentShaderFileName); }; }
[ "kirill.pilipchuk@gmail.com" ]
kirill.pilipchuk@gmail.com
352e48d4554c4d7cb056b11cc28a43cfb4d8657c
2f4ff9e7ced72e2757082d7326e0303ababa51de
/win32cpp/src/using-asm-jmp/using-asm-jmp.cpp
b8017e0f3fb8cceeb7b07263071e8730fee0125a
[]
no_license
aurelienrb/articles
b04ce69861a31452a8f89244b697ac882896ff8e
4248b8fdf8e2fb45d4b58e60ab35f6ec92bee91b
refs/heads/master
2020-11-25T19:31:51.604477
2017-01-12T23:35:41
2017-01-12T23:35:41
67,840,256
0
0
null
null
null
null
UTF-8
C++
false
false
674
cpp
#include <winapi/module.h> #ifdef _WIN64 #error "Inline assembly is not available on 64 bit" #endif #define WIN32_LEAN_AND_MEAN #include <windows.h> namespace winapi { __declspec(naked) Module * WINAPI Module::Load(const char *) { __asm jmp[LoadLibraryA] } __declspec(naked) Module * WINAPI Module::Load(const char *, std::nullptr_t, LoadingFlags) { __asm jmp[LoadLibraryExA] } __declspec(naked) bool WINAPI Module::Free() { __asm jmp[FreeLibrary] } // handle name collision with Win32 static auto Win32GetProcAddress = &::GetProcAddress; __declspec(naked) void * WINAPI Module::GetProcAddress(const char *) { __asm jmp[Win32GetProcAddress] } }
[ "arb@cyberkarma.net" ]
arb@cyberkarma.net
9b79f1b139b42c1b53ecd890a87c6172484271db
8f6e44fc124906c473ed861777d90acd20afe303
/transmitter/transmitter.ino
6c64f39ea28b8207276419ef1a04e78799ffef85
[ "MIT" ]
permissive
DroneAid/DroneAid_master
f97358f45c15c55710537e11d0ec0a72a8e6227f
3cff2e62919fa2b37fcb57d5b94afa142003048c
refs/heads/master
2020-09-25T12:18:44.086554
2016-08-29T10:47:23
2016-08-29T10:47:23
66,770,655
0
0
null
null
null
null
UTF-8
C++
false
false
403
ino
#include <Printers.h> #include <XBee.h> XBee xbee = XBee(); int serialPortVar; int serialPortVarTheLastOne = new int(); void setup() { Serial.begin(9600); xbee.setSerial(Serial); } void loop() { serialPortVar = Serial.parseInt(); if(&& serialPortVar != 0 && serialPortVarTheLastOne != serialPortVar) { xbee.send(serialPortVar); serialPortVarTheLastOne = serialPortVar; } }
[ "droneaidteam@gmail.com" ]
droneaidteam@gmail.com
690f18925cedcc02e6e75e52956bf957a537ff14
3b6c98e13a05919cb06244ee37e00b8652ede65c
/1/prog1b.cpp
ba68d31d093437e4a7b133ca668e6afab86aacda
[ "MIT" ]
permissive
Meenakshi1998/FS-LAB
cd9b2c925cad3b1bde317ae49a1488930f8f6835
03c048974335b98f3f6ad5f76cc96309698c8fe5
refs/heads/master
2020-03-31T04:31:35.952494
2018-04-28T05:18:09
2018-04-28T05:18:09
151,909,266
0
0
MIT
2018-10-07T05:33:51
2018-10-07T05:32:22
C++
UTF-8
C++
false
false
670
cpp
#include<iostream> #include<cstring> #include<fstream> using namespace std; int main() { char s1[25]; fstream f1,f2; char fname1[25],fname3[25]; int x =0; cout<<"Enter input file\n"; cin >> fname1; cout<<"Enter output file\n"; cin >> fname3; f1.open(fname1,ios::in); f2.open(fname3,ios::out); if(!f1) { cerr<<"File doesn't exist: "<<fname1; return -1; } if(!f2) { cerr << "File doesn't exist:" << fname3; return -1; } while(1) { f1.getline(s1,25); if(f1.fail()) break; x = strlen(s1); for(int i=x-1;i >=0;i--) f2 << s1[i]; f2<<endl; } f1.close(); f2.close(); return 0; }
[ "aravindsuresh98@gmail.com" ]
aravindsuresh98@gmail.com
1158e1cdd293f4cbe160d3122c5fee1c40178385
5b22d68f9c01682fa96d7ca4e796ad5a7b72d9ab
/code/routingkit2/src/test_osm_profile.cpp
8a4a703c938770322160bf33a9d0921582e866eb
[ "BSD-3-Clause" ]
permissive
kit-algo/ch_potentials
54d1b0b28712d7a4f794a5decedce98fa1c36c52
f833a2153635961b01c2d68e2da6d1ae213117a5
refs/heads/master
2022-11-12T17:41:01.667707
2022-11-08T12:01:09
2022-11-08T12:01:09
347,034,552
5
0
null
null
null
null
UTF-8
C++
false
false
1,090
cpp
#include "osm_profile.h" #include <random> #include <iostream> #include "catch.hpp" using namespace RoutingKit2; using namespace std; TEST_CASE("parse_osm_duration_value", "[OSMProfile]"){ auto log_message = [](string msg){ cerr << msg << endl; }; REQUIRE(parse_osm_duration_value(42, "5", log_message) == 300); REQUIRE(parse_osm_duration_value(42, "05", log_message) == 300); REQUIRE(parse_osm_duration_value(42, "15", log_message) == 900); REQUIRE(parse_osm_duration_value(42, "1:8", log_message) == 4080); REQUIRE(parse_osm_duration_value(42, "01:8", log_message) == 4080); REQUIRE(parse_osm_duration_value(42, "11:8", log_message) == 40080); REQUIRE(parse_osm_duration_value(42, "1:8:2", log_message) == 4082); REQUIRE(parse_osm_duration_value(42, "01:8:2", log_message) == 4082); REQUIRE(parse_osm_duration_value(42, "11:8:2", log_message) == 40082); REQUIRE(parse_osm_duration_value(42, "1:8:12", log_message) == 4092); REQUIRE(parse_osm_duration_value(42, "01:8:12", log_message) == 4092); REQUIRE(parse_osm_duration_value(42, "11:8:12", log_message) == 40092); }
[ "github@ben-strasser.net" ]
github@ben-strasser.net
af480a7b5f148bb4d6baa8a3ad405c9641810c5d
de1b6c40b2b94f39336a2bfe48022cf2718ba3c2
/reverse.cpp
a6c09a0a88fb7f875d02b117417d63b926781a08
[]
no_license
VatchalaBakthavatchalu/EveryDay_Cplusplus
738fe62aa2864c5eef0483b61ed3baab0e272de1
3061b56620a14fa8eeac7c040bc55db5d8f9e10b
refs/heads/master
2020-04-19T17:34:03.851400
2019-02-11T04:16:49
2019-02-11T04:16:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
207
cpp
#include <iostream> using namespace std; int main() { string n; cout<<"Enter the string"; cin>>n; for (string i=0;i<=n.size;i++) while( string i) { string rev=""; rev=i + rev; cout<<rev<<endl; } }
[ "33224372+vatchala123@users.noreply.github.com" ]
33224372+vatchala123@users.noreply.github.com
5781766b95741be91adbbbc27ad65336e014eae1
ba07219ee1860d301a7ffb05a17200cbdf2c4e45
/Multi-process_server/Multi_process_server.cpp
4720e83f051f7b33ce1b3727f2dbcb045d6f6f8a
[]
no_license
horoyoii/server_models
83cd001cbfad3cbf349134054e6543ff9db35368
ce4fb0b2a21fe163e98aca35957a6f7b61c01170
refs/heads/master
2020-09-22T08:47:24.781099
2020-04-06T04:51:18
2020-04-06T04:51:18
225,127,259
0
0
null
null
null
null
UTF-8
C++
false
false
2,183
cpp
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<unistd.h> #include<sys/socket.h> #include<arpa/inet.h> #include<signal.h> #include<sys/wait.h> #define BUF_SIZE 30 void handleTerminatedChild(int sig); int main(int argc, char* argv[]){ int serv_sock, cli_sock; struct sockaddr_in serv_adr, cli_adr; pid_t pid; struct sigaction act; socklen_t adr_sz; int str_len, state; char buf[BUF_SIZE]; act.sa_handler = handleTerminatedChild; sigemptyset(&act.sa_mask); act.sa_flags = 0; state = sigaction(SIGCHLD, &act, 0); serv_sock = socket(PF_INET, SOCK_STREAM, 0); memset(&serv_adr, 0, sizeof(serv_adr)); serv_adr.sin_family = AF_INET; serv_adr.sin_addr.s_addr = htonl(INADDR_ANY); serv_adr.sin_port = htons(atoi(argv[1])); if(bind(serv_sock, (struct sockaddr*)&serv_adr, sizeof(serv_adr)) == -1) perror("error : "); if(listen(serv_sock, 5) == -1) perror("error : "); while(1){ adr_sz = sizeof(cli_adr); cli_sock = accept(serv_sock, (struct sockaddr*)&cli_adr, &adr_sz); if(cli_sock == -1) continue; else printf("new client connected...\n"); /** * create a new process to handle the request. */ pid = fork(); if(pid == -1){ // whne failed to craete new process close(cli_sock); continue; } /** * child process's routine * */ if(pid == 0 ){ close(serv_sock); //sleep(3); while((str_len = read(cli_sock, buf, BUF_SIZE)) != 0) write(cli_sock, buf, str_len); close(cli_sock); printf(" child process is done with its job\n"); return 0; }else{ // Parent process removes the client socket fd immediately close(cli_sock); } } close(serv_sock); return 0; } void handleTerminatedChild(int sig){ pid_t pid; int status; pid = waitpid(-1, &status, WNOHANG); printf("removed proc id : %d\n", pid); }
[ "demonic3540@naver.com" ]
demonic3540@naver.com
8caa6196127c0103ad1ffa92fe984fc815c9201d
b004c39c4ee606163333b0a987c2bc8a2e503fb6
/src/Waluta.cpp
a0044845055087dc63ad82bd32ecea1861cb0c84
[]
no_license
PiterPSP/Personal-Wallet
b3c0696ea4a021580f1dfa67d17ae4f0c1f05c15
36ed5774d65b23ebc15e754ed0f0108cd22d9058
refs/heads/master
2020-05-04T19:01:50.717131
2019-04-03T22:18:29
2019-04-03T22:18:29
179,376,658
0
0
null
null
null
null
UTF-8
C++
false
false
835
cpp
// // Created by Piter on 2018-01-28. // #include "Waluta.h" #include <fstream> using namespace std; Waluta::Waluta() {} Waluta::Waluta(const string &nazwa, double wartosc, int liczbaJednostek, double przyrost) : Aktywa(nazwa, wartosc, liczbaJednostek, przyrost) {} double Waluta::symulujWartosc(int okres) { double ile = getWartosc(); for (int i = 0; i < okres; ++i) { ile += ile * (getPrzyrost() / 100); } return ile * getLiczbaJednostek(); } void Waluta::zapisz(ofstream &plik) { plik << "waluta " << getNazwa() << " " << getWartosc() << " " << getLiczbaJednostek() << " " << getPrzyrost() << endl; }
[ "piter-h20@wp.pl" ]
piter-h20@wp.pl
652f3e4211282bf305f5c2972b2c044a12a15d12
8cf4d67c2c0447f25015bb603edad781d20d312a
/Project/Project1/CDAL copy.H
adb9b36c30494e09695c7f079440d5a5635e2773
[]
no_license
tianwenlan/COP3530-Data-structure-and-Algorithms
99963afe30d78c5834124c7f60c7c20462b93b18
9c14e486c0c8e00f11155c527eac65e7891e0dff
refs/heads/master
2021-01-10T02:32:24.981666
2016-02-09T19:56:39
2016-02-09T19:56:39
51,350,406
3
1
null
null
null
null
UTF-8
C++
false
false
13,759
h
#ifndef _CDAL_H_ #define _CDAL_H_ // CDAL.H // // Chained Dynamic Array-based List (CDAL) // // Author: Wenlan Tian // Project 1 for COP 3530 // Date: 09/17/2014 // Version 1 #include <iostream> namespace cop3530 { template <typename T> class CDAL { private: struct Node { Node* next; T* arr; Node(){ next = NULL; arr = new T[50]; } }; // end struct Node int mySize = 0; Node* head; Node* first; public: class SSLL_Iter //: public std::iterator<std::forward_iterator_tag, T> { public: // inheriting from std::iterator<std::forward_iterator_tag, T> // automagically sets up these typedefs... typedef T value_type; typedef std::ptrdiff_t difference_type; typedef T& reference; typedef T* pointer; typedef std::forward_iterator_tag iterator_category; // but not these typedefs... typedef SSLL_Iter self_type; typedef SSLL_Iter& self_reference; private: Node* here; public: explicit SSLL_Iter( Node* start = NULL ) : here( start ) { } SSLL_Iter( const SSLL_Iter& src ) : here( src.here ) { } reference operator*() const { return here -> data;; } pointer operator->() const { } self_reference operator=( const SSLL_Iter& src ) { } self_reference operator++() { here = here ->next; return *this; } // preincrement self_type operator++(int) { self_type result (*this); here = here ->next; return result; } // postincrement bool operator==(const SSLL_Iter& rhs) const { return here == rhs.here; } bool operator!=(const SSLL_Iter& rhs) const { return here != rhs.here; } }; // end SSLL_Iter class SSLL_Const_Iter //: public std::iterator<std::forward_iterator_tag, T> { public: // inheriting from std::iterator<std::forward_iterator_tag, T> // automagically sets up these typedefs... typedef T value_type; typedef std::ptrdiff_t difference_type; typedef T& reference; typedef T* pointer; typedef std::forward_iterator_tag iterator_category; // but not these typedefs... typedef SSLL_Const_Iter self_type; typedef SSLL_Const_Iter& self_reference; private: Node* here; public: explicit SSLL_Const_Iter( Node* start = NULL ) : here( start ) { } SSLL_Const_Iter( const SSLL_Const_Iter& src ) : here( src.here ) { } reference operator*() const { return here -> data; } pointer operator->() const { } self_reference operator=( const SSLL_Const_Iter& src ) { } self_reference operator++() { here = here ->next; return *this; } // preincrement self_type operator++(int) { self_type result (*this); here = here -> next; return result; } // postincrement bool operator==(const SSLL_Const_Iter& rhs) const { return here == rhs.here; } bool operator!=(const SSLL_Const_Iter& rhs) const { return here != rhs.here; } }; // end SSLL_Const_Iter //-------------------------------------------------- // types //-------------------------------------------------- typedef std::size_t size_t; typedef T value_type; typedef SSLL_Iter iterator; typedef SSLL_Const_Iter const_iterator; iterator begin() { return SSLL_Iter( head ); } iterator end() { return SSLL_Iter(tail ); } const_iterator begin() const { return SSLL_Const_Iter( head ); } const_iterator end() const { return SSLL_Const_Iter( tail ); } //-------------------------------------------------- // Constructors/destructor/assignment operator //-------------------------------------------------- CDAL() { mySize = 0; first = new Node(); head = first; } //-------------------------------------------------- CDAL( const CDAL& src ) { } //-------------------------------------------------- ~CDAL() { // safely dispose of this CDAL's contents } //-------------------------------------------------- CDAL& operator=( const CDAL& src ) { if ( &src == this ) // check for self-assignment return *this; // do nothing // safely dispose of this CDAL's contents // populate this CDAL with copies of the other CDAL's contents } //-------------------------------------------------- // member functions //-------------------------------------------------- T replace( const T& element, int position ) { if (is_empty()){ throw std::out_of_range("Empty list!"); } if (position < 0 || position >= size()){ throw std::domain_error("Invalid position!"); } if(position < 50){ first->arr[position] = element; }else{ Node* temp = head; for (int i = 0; i < (position -(position%50))/50; ++i){ temp = temp -> next; } temp->arr[position%50] = element; } } //-------------------------------------------------- void insert( const T& element, int position ) { if (position < 0 || position > size()){ throw std::domain_error("Invalid position!"); } if (position == 0){ push_front(element); }else if(position == size()){ push_back(element); }else if (size()<50){ Node* current = head; for(int i = size(); i > position; --i){ current->arr[i] = current->arr[i-1]; } current->arr[position]=element; }else if (size()==50){ Node* current = head; Node* tempNode = new Node(); if(position==50){ tempNode->arr[0]= element; current -> next = tempNode; }else{ tempNode->arr[0]=current->arr[49]; for (int i = 49; i > position; --i){ current->arr[i] = current->arr[i-1]; } current->arr[position] = element; } }else{ Node* current = head; int position_node= (position -position%50)/50; int total_node = (size()-size()%50)/50; //move to the node with position to be inserted for (int i =0; i< position_node; ++i){ current = current -> next; } T temp = NULL; if (position_node < total_node){ for(int i = position_node; i< total_node; i++){ if (i== position_node){ temp = current->arr[49]; for(int j = 49; j > position%50; --j){ current->arr[j] = current->arr[j-1]; } current->arr[position%50] = element; }else{ temp = current->arr[49]; for (int j =49; j> 0; --j){ current->arr[j] = current->arr[j-1]; } current->arr[0] = temp; } current = current -> next; } if (size()%50==0){ Node* tempNode = new Node(); tempNode->arr[0]=current->arr[49]; for (int i =49; i> 0; --i){ current->arr[i] = current->arr[i-1]; } current->arr[0]=temp; current -> next = tempNode; }else{ for (int i = size()%50; i> 0; --i){ current->arr[i] = current->arr[i-1]; } current->arr[0]=temp; } }else{ for (int i = size()%50; i> position%50; --i){ current->arr[i] = current->arr[i-1]; } current->arr[position%50]=element; } } } //-------------------------------------------------- void push_front( const T& element ) { Node* current = head; if(size()<50){ for(int i = size(); i > 0; --i){ current->arr[i] = current->arr[i-1]; } current->arr[0]=element; }else{ T temp = NULL; while(current -> next != NULL){ temp = current->arr[49]; for (int i =49; i> 0; --i){ current->arr[i] = current->arr[i-1]; } if(current==head){ current->arr[0]=element; }else{ current->arr[0] = temp; } current = current -> next; } if (size()%50==0){ temp = current->arr[49]; for (int i =49; i> 0; --i){ current->arr[i] = current->arr[i-1]; } Node* tempNode = new Node(); tempNode->arr[0]= temp; current -> next = tempNode; }else{ for (int i = size()%50; i> 0; --i){ current->arr[i] = current->arr[i-1]; } current->arr[0]=temp; } } mySize++; } //-------------------------------------------------- void push_back( const T& element ) { Node* current = head; while (current -> next != NULL){ current = current -> next; } if(size()<50){ current->arr[size()]=element; }else if(size()%50==0){ Node* temp = new Node(); temp->arr[0]=element; current -> next = temp; }else{ current->arr[size()%50] = element; } mySize++; } //-------------------------------------------------- T pop_front() { if (is_empty()){ throw std::out_of_range("Empty list!"); } Node* current = head; T result = current->arr[0]; if (size() <= 50){ for (int i = 0; i< 49; ++i){ current->arr[i] = current->arr[i+1]; } mySize--; }else{ while(current -> next != NULL){ for (int i = 0; i< 49; ++i){ current->arr[i] = current->arr[i+1]; } current->arr[49] = current->next->arr[0]; current = current -> next; } if (size()%50==1){ current->arr[0] = NULL; }else{ for (int i = 0; i< size()%50 -1; ++i){ current->arr[i] = current->arr[i+1]; } current->arr[size()%50-1] = NULL; } mySize--; } return result; } //-------------------------------------------------- T pop_back() { if (is_empty()){ throw std::out_of_range("Empty list!"); } T result; Node* temp = head; while(temp -> next != NULL){ temp = temp -> next; } if(size()<=50){ result = first->arr[size()-1]; first->arr[size()-1]=NULL; }else if(size()%50==1){ std::cout << result ; result = temp->arr[0]; temp->arr[0] = NULL; delete []temp->arr; temp = NULL; }else{ result = temp->arr[size()%50-1]; temp->arr[size()%50-1]=NULL; } mySize--; return result; } //-------------------------------------------------- T remove( int position ) { if (is_empty()){ throw std::out_of_range("Empty list!"); } if (position < 0 || position >= size()){ throw std::domain_error("Invalid position!"); } if (position == 0){ pop_front(); }else if(position == size()-1){ pop_back(); }else if (size() <= 50){ Node* current = head; for (int i = position; i< 49; ++i){ current->arr[i] = current->arr[i+1]; } mySize--; }else{ Node* current = head; for (int i =0; i< (position-position%50)/50; ++i){ current = current -> next; } while(current -> next != NULL){ for (int i = position%50; i< 49; ++i){ current->arr[i] = current->arr[i+1]; } current->arr[49] = current->next->arr[0]; current = current -> next; } if (size()%50==1){ current->arr[0] = NULL; }else{ for (int i = 0; i< size()%50 -1; ++i){ current->arr[i] = current->arr[i+1]; } current->arr[size()%50-1] = NULL; } mySize--; } } //-------------------------------------------------- T item_at( int position ) const { if (is_empty()){ throw std::out_of_range("Empty list!"); } if (position < 0 || position >= size()){ throw std::domain_error("Invalid index!"); } if(position < 50){ std::cout << "Item at position " << position << " is " << first->arr[position] << std::endl; return (first->arr[position]); }else{ Node* temp = head; for (int i = 0; i < (position -(position%50))/50; ++i){ temp = temp -> next; } std::cout << "Item at position " << position << " is " << temp->arr[position%50] << std::endl; return (temp->arr[position%50]); } } //-------------------------------------------------- bool is_empty() const { return (!first->next && first->arr[0]== NULL) ? true:false; } //-------------------------------------------------- size_t size() const { return mySize; } //-------------------------------------------------- void clear() { while(size()!=0){ pop_back(); } first = new Node(); head = first; } //-------------------------------------------------- bool contains( const T& element, bool equals( const T& a, const T& b ) ) const { int match = 0; if (size()==0){ return false; } Node* current = head; while(current->next->next!=NULL){ for(int i =0; i < 50; ++i){ if(current->arr[i] == element){ match ++; } } current = current -> next; } for(int i =0; i < size()%50; ++i){ if(current->next->arr[i] == element){ match ++; } } return (match == 1)? true : false; } //-------------------------------------------------- std::ostream& print( std::ostream& out ) const { if(size()==0){ out << "<empty list>" << std::endl; }else{ Node* current = head; out << "[" << current->arr[0] << std::flush; while(current!=NULL){ if(current!=head){ out << "," << current->arr[0] << std::flush; } for (int i = 1; i< 50; ++i){ if(current->arr[i]!=NULL) out << "," << current->arr[i] << std::flush; } current = current -> next; } out << "]" << std::endl; } return out; } T& operator[](int i){ if (is_empty()){ throw std::out_of_range("Empty list!"); } if (i < 0 || i >= size()){ throw std::domain_error("Invalid index!"); } if(i < 50){ return (first->arr[i]); }else{ Node* temp = head; for (int k = 0; k < (i -(i%50))/50; ++k){ temp = temp -> next; } return (temp->arr[i%50]); } } T const& operator[](int i) const{ if (is_empty()){ throw std::out_of_range("Empty list!"); } if (i < 0 || i >= size()){ throw std::domain_error("Invalid index!"); } if(i < 50){ return (first->arr[i]); }else{ Node* temp = head; for (int k = 0; k < (i -(i%50))/50; ++k){ temp = temp -> next; } return (temp->arr[i%50]); } } }; //end class CDAL } // end namespace cop3530 #endif // _CDAL_H_
[ "tianwenlan@Wenlans-MacBook-Pro.local" ]
tianwenlan@Wenlans-MacBook-Pro.local
a8f5c555861fe54db23cc88ac3d6ec43ae655cf5
44573c3ec6f4087d46a731ff7dc2b7b031772f5b
/LED_RING/1-8-12-16-24_32/1-8-12-16-24_32.ino
578a0a69fa045425d87bfacfdd5ea3090622c50b
[]
no_license
djerun/sketchbook
215f653fa9397c60d599b8dede90511765e3fd83
493340ea97c6b9a2e9cc632604c1d34efc9ca52e
refs/heads/master
2022-12-04T09:37:21.298869
2020-08-27T14:04:34
2020-08-27T14:04:34
290,778,828
0
0
null
null
null
null
UTF-8
C++
false
false
9,915
ino
#include "FastLED.h" #define LED_TYPE WS2812B #define COLOR_ORDER GRB #define NUM_LEDS (((1+8+12+16+24+32))) unsigned int leds_per_ring(unsigned int n) { switch (n) { case 0: return 1; case 1: return 8; case 2: return 12; case 3: return 16; case 4: return 24; case 5: return 32; default: return 0; } } unsigned int ring_index_offset(unsigned int n) { switch (n) { case 0: return 0; case 1: return 1; case 2: return 1+8; case 3: return 1+8+12; case 4: return 1+8+12+16; case 5: return 1+8+12+16+24; default: return 0; } } unsigned char Brightness = 0xff; unsigned char MaxSaturation = 0xbf; CRGB Leds[NUM_LEDS]; typedef union t_FieldData { unsigned char starfireData[NUM_LEDS]; // temperature for all cells } FieldData; FieldData fieldData; #define DEFAULT_SPEED 0xfff int Speed = 0xff; float speedFactor() { return ((float)Speed) / ((float)DEFAULT_SPEED); } unsigned char Special = 0; #define NUM_MODES 4 int Mode = 1; void (*Modes[])(void) = { &hueWalk, // 0 &sineValueWalk, // 1 &sineHueSaturationWalk, // 2 &sineHueValueWalk // 3 }; void (*ModeInits[])(void) = { &hueWalkInit, // 0 &sineValueWalkInit, // 1 &sineHueSaturationWalkInit, // 2 &sineHueValueWalkInit // 3 }; unsigned char PrimaryHue = 0; CRGB PrimaryColor = CHSV(PrimaryHue, 255, 255); void increaseBrightness() { Brightness = min(0xff, Brightness+0x10); Serial.print(Brightness, HEX); } void decreaseBrightness() { Brightness = max(0x0f, Brightness-0x10); Serial.print(Brightness, HEX); } void nextMode() { Mode = (Mode+1)%NUM_MODES; Serial.println(Mode, HEX); (*ModeInits[Mode])(); } void previousMode() { Mode = (Mode+NUM_MODES-1)%NUM_MODES; Serial.println(Mode, HEX); (*ModeInits[Mode])(); } void nextColor() { PrimaryHue += 0x10; Serial.println(PrimaryHue, HEX); PrimaryColor = CHSV(PrimaryHue, 255, 255); } void previousColor() { PrimaryHue -= 0x10; Serial.println(PrimaryHue, HEX); PrimaryColor = CHSV(PrimaryHue, 255, 255); } void increaseSaturation() { MaxSaturation = min(0xff, MaxSaturation + 0x10); Serial.println(MaxSaturation, HEX); } void decreaseSaturation() { MaxSaturation = max(0x0f, MaxSaturation - 0x10); } void speedUp() { Speed = min(0xff, Speed + 0x10); Serial.println(Speed, HEX); } void speedDown() { Speed = max(0x0f, Speed - 0x10); Serial.println(Speed, HEX); } void specialPlus() { Special = min(0xff, Special + 1); Serial.println(Special, HEX); } void specialMinus() { Special = max(0, Special - 1); Serial.println(Special, HEX); } void handleSerial() { if (Serial.available()) { byte cmd = Serial.read(); Serial.print(cmd, HEX); switch (cmd) { case '1': nextMode(); break; case '2': previousMode(); break; case '3': nextColor(); break; case '4': previousColor(); break; case '5': increaseSaturation(); break; case '6': decreaseSaturation(); break; case '7': increaseBrightness(); break; case '8': decreaseBrightness(); break; case '9': speedUp(); break; case '0': speedDown(); break; case '-': specialPlus(); break; case '=': specialMinus(); break; case 'r': randomizeMode(); break; default: break; } Serial.println(""); } } void randomizeMode() { Mode = random(NUM_MODES); PrimaryHue = random(16)*0x10; PrimaryColor = CHSV(PrimaryHue, 255, 255); (*ModeInits[Mode])(); } int ButtonStates[] = { 1, 1, 1, 1 }; void handleControls() { MaxSaturation = analogRead(0) >> 2; PrimaryHue = analogRead(1) >> 2; Speed = analogRead(2) >> 2; Brightness = analogRead(3) >> 2; int val = digitalRead(12); if (val != ButtonStates[0]) { ButtonStates[0] = val; if (val == 0) { previousMode(); } } val = digitalRead(10); if (val != ButtonStates[1]) { ButtonStates[1] = val; if (val == 0) { specialMinus(); } } val = digitalRead( 8); if (val != ButtonStates[2]) { ButtonStates[2] = val; if (val == 0) { specialPlus(); } } val = digitalRead( 6); if (val != ButtonStates[3]) { ButtonStates[3] = val; if (val == 0) { nextMode(); } } } void setup() { Serial.begin(9600); pinMode(12, INPUT_PULLUP); pinMode(10, INPUT_PULLUP); pinMode( 8, INPUT_PULLUP); pinMode( 6, INPUT_PULLUP); /*FastLED.addLeds<LED_TYPE, 2, COLOR_ORDER>(Leds, 0, 1+8+12+16+24+32); //all FastLED.addLeds<LED_TYPE, 12, COLOR_ORDER>(Leds, 0, 1); //ring 0 FastLED.addLeds<LED_TYPE, 11, COLOR_ORDER>(Leds, 1, 8); //ring 1 FastLED.addLeds<LED_TYPE, 10, COLOR_ORDER>(Leds, 1+8, 12); //ring 2 FastLED.addLeds<LED_TYPE, 9, COLOR_ORDER>(Leds, 1+8+12, 16); //ring 3 FastLED.addLeds<LED_TYPE, 8, COLOR_ORDER>(Leds, 1+8+12+16, 24); //ring 4 FastLED.addLeds<LED_TYPE, 7, COLOR_ORDER>(Leds, 1+8+12+16+24, 32); //ring 5*/ FastLED.addLeds<LED_TYPE, 2, COLOR_ORDER>(Leds, 1+8+12+16+24, 32); FastLED.setBrightness(Brightness); randomSeed(analogRead(0) ^ analogRead(1) ^ analogRead(2) ^ analogRead(3) ^ analogRead(4) ^ analogRead(5)); randomizeMode(); } void loop() { handleControls(); handleSerial(); advanceTime(); (*Modes[Mode])(); } //////////////////////// UTILITY //////////////////////// void fillScreen(CRGB color) { for (int i = 0; i < NUM_LEDS; ++i) { Leds[i] = color; } FastLED.show(); } void clearScreen() { fillScreen(CRGB::Black); } float Time = 0.0f; unsigned long MillisLast = 0; float advanceTime() { unsigned long millisNow = millis(); Time += ((float)(millisNow - MillisLast)) / 1000.0f * speedFactor(); MillisLast = millisNow; } float time() { return Time; } float frac(float n) { return n - floor(n); } #define FTIME_STRETCH 1.0 float ftime() { return frac(time() * FTIME_STRETCH) * 2.0 - 1.0; } /** * @param t current step [0.0, 1.0] */ float easeInOutExpo(float t) { t *= 2; if (t < 1) { return 0.5 * pow( 2, 10 * (t - 1) ); } else { t--; return 0.5 * ( -pow( 2, -10 * t) + 2 ); } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void hueWalkInit() { clearScreen(); } void hueWalk() { for (unsigned int ring = 1; ring < 6; ++ring) { unsigned int num_leds = leds_per_ring(ring); for (unsigned int i = 0; i < num_leds; ++i) { unsigned int offset = ring_index_offset(ring); float h = ((float)i) / ((float)(num_leds)); h += frac(time()); h *= 255.0f; unsigned char hue = (unsigned char)h; unsigned char saturation = MaxSaturation; if (i % (Special+1) == 0) { Leds[offset+i] = CHSV(hue, saturation, 255); Leds[offset+i] %= Brightness; } else { Leds[offset+i] = CRGB::Black; } } } FastLED.show(); } void sineValueWalkInit() { clearScreen(); } void sineValueWalk() { for (unsigned int ring = 1; ring < 6; ++ring) { unsigned int num_leds = leds_per_ring(ring); for (unsigned int i = 0; i < num_leds; ++i) { unsigned int offset = ring_index_offset(ring); float v = ((float)i) / ((float)(num_leds)); v += frac(time()); v *= 2.0f * PI; v = sin(((float)Special+1.0f) * v); v = abs(v); v = pow(v, 10.0f); v *= (float)Brightness; unsigned char hue = (unsigned char)PrimaryHue; unsigned char saturation = MaxSaturation; unsigned char value = (unsigned char)v; Leds[offset+i] = CHSV(hue, saturation, 255); Leds[offset+i] %= value; } } FastLED.show(); } void sineHueSaturationWalkInit() { clearScreen(); } void sineHueSaturationWalk() { for (unsigned int ring = 1; ring < 6; ++ring) { unsigned int num_leds = leds_per_ring(ring); for (unsigned int i = 0; i < num_leds; ++i) { unsigned int offset = ring_index_offset(ring); unsigned char h1 = PrimaryHue; unsigned char h2 = (h1+128)%256; float s = ((float)i) / ((float)(num_leds)); s += frac(time()); s *= 2.0f * PI; s = sin(((float)Special+1.0f) * s); float h = h1; if (s < 0.0f) h = h2; s = abs(s) * ((float)MaxSaturation); unsigned char hue = (unsigned char)h; unsigned char saturation = (unsigned char)s; Leds[offset+i] = CHSV(hue, saturation, 255); Leds[offset+i] %= Brightness; } } FastLED.show(); } void sineHueValueWalkInit() { clearScreen(); } void sineHueValueWalk() { for (unsigned int ring = 1; ring < 6; ++ring) { unsigned int num_leds = leds_per_ring(ring); for (unsigned int i = 0; i < num_leds; ++i) { unsigned int offset = ring_index_offset(ring); unsigned char h1 = PrimaryHue; unsigned char h2 = (h1+128)%256; float v = ((float)i) / ((float)(num_leds)); v += frac(time()); v *= 2.0f * PI; v = sin(((float)Special+1.0f) * v); float h = h1; if (v < 0.0f) h = h2; v = abs(v); v = pow(v, 10.0f); v *= (float)Brightness; unsigned char hue = (unsigned char)h; unsigned char saturation = MaxSaturation; unsigned char value = (unsigned char)v; Leds[offset+i] = CHSV(hue, saturation, 255); Leds[offset+i] %= value; } } FastLED.show(); }
[ "djerun@hamburg.ccc.de" ]
djerun@hamburg.ccc.de
c74c41441b79772886ca1ca764ab63992c076669
9844a920ca2124b9dca3a5384893b31174a9a334
/modules/perception/obstacle/camera/cipv/cipv.cc
45952b0d332c002a7d9c597f383a5ead1b93a387
[ "Apache-2.0" ]
permissive
RealSense3D/apollo
73af4f5cd1c22c73a3e7b219b4677166e42d9b4b
d9c05e7df7b10010856c8d06337f0670c279bba1
refs/heads/master
2021-01-25T13:24:08.119012
2018-03-02T06:51:45
2018-03-02T07:28:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
28,838
cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. 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. *****************************************************************************/ #include <math.h> #include "modules/perception/obstacle/camera/cipv/cipv.h" #include "modules/common/log.h" namespace apollo { namespace perception { namespace obstacle { Cipv::Cipv(void) {} Cipv::~Cipv(void) { // clear(); } bool Cipv::init() { _b_image_based_cipv = false; _debug_level = 0; // 0: no debug message // 1: minimal output // 2: some important output // 3: verbose message // 4: visualization // 5: all // -x: specific debugging, where x is the specific number _time_unit = AVERAGE_FRATE_RATE; return true; } // Distance from a point to a line segment bool Cipv::distance_from_point_to_line_segment( const Point2Df &point, const Point2Df &line_seg_start_point, const Point2Df &line_seg_end_point, float *distance) { float x_start_diff = point[0] - line_seg_start_point[0]; float y_start_diff = point[1] - line_seg_start_point[1]; float x_end_diff = line_seg_end_point[0] - line_seg_start_point[0]; float y_end_diff = line_seg_end_point[1] - line_seg_start_point[1]; float dot = x_start_diff * x_end_diff + y_start_diff * y_end_diff; float len_sq = x_end_diff * x_end_diff + y_end_diff * y_end_diff; float param = -1.0f; if (fabs(len_sq) > B_FLT_EPSILON) { // in case of 0 length line param = dot / len_sq; } else { return false; } float xx = 0.0f; float yy = 0.0f; if (param < 0) { // return false; xx = line_seg_start_point[0]; yy = line_seg_start_point[1]; } else if (param > 1) { // return false; xx = line_seg_end_point[0]; yy = line_seg_end_point[1]; } else { xx = line_seg_start_point[0] + param * x_end_diff; yy = line_seg_start_point[1] + param * y_end_diff; } float dx = point[0] - xx; float dy = point[1] - yy; *distance = sqrt(dx * dx + dy * dy); if (_debug_level >= 2) { AINFO << "distance_from_point (" << point[0] << ", " << point[1] << ") _to_line_segment (" << line_seg_start_point[0] << ", " << line_seg_start_point[1] << ")->(" << line_seg_end_point[0] << ", " << line_seg_end_point[1] << "): " << *distance << "m"; } return true; } // Determine CIPV among multiple objects bool Cipv::get_egolane(const LaneObjectsPtr lane_objects, EgoLane *egolane_image, EgoLane *egolane_ground, bool *b_left_valid, bool *b_right_valid) { for (size_t i = 0; i < lane_objects->size(); ++i) { if ((*lane_objects)[i].spatial == L_0) { if (_debug_level >= 2) { AINFO << "[get_egolane]LEFT(*lane_objects)[i].image_pos.size(): " << (*lane_objects)[i].image_pos.size(); } if ((*lane_objects)[i].image_pos.size() < MIN_LANE_LINE_LENGTH_FOR_CIPV_DETERMINATION) { *b_left_valid = false; } else { *b_left_valid = true; for (size_t j = 0; j < (*lane_objects)[i].image_pos.size(); ++j) { Eigen::Vector2f image_point((*lane_objects)[i].image_pos[j][0], (*lane_objects)[i].image_pos[j][1]); egolane_image->left_line.line_point.push_back(image_point); Eigen::Vector2f ground_point((*lane_objects)[i].pos[j][0], (*lane_objects)[i].pos[j][1]); egolane_ground->left_line.line_point.push_back(ground_point); } } } else if ((*lane_objects)[i].spatial == R_0) { if (_debug_level >= 2) { AINFO << "[get_egolane]RIGHT(*lane_objects)[i].image_pos.size(): " << (*lane_objects)[i].image_pos.size(); } if ((*lane_objects)[i].image_pos.size() < MIN_LANE_LINE_LENGTH_FOR_CIPV_DETERMINATION) { *b_right_valid = false; } else { *b_right_valid = true; for (size_t j = 0; j < (*lane_objects)[i].image_pos.size(); ++j) { Eigen::Vector2f image_point((*lane_objects)[i].image_pos[j][0], (*lane_objects)[i].image_pos[j][1]); egolane_image->right_line.line_point.push_back(image_point); Eigen::Vector2f ground_point((*lane_objects)[i].pos[j][0], (*lane_objects)[i].pos[j][1]); egolane_ground->right_line.line_point.push_back(ground_point); } } } } return true; } // Make a virtual lane line using a reference lane line and its offset distance bool Cipv::make_virtual_lane(const LaneLine &ref_lane_line, const float yaw_rate, const float offset_distance, LaneLine *virtual_lane_line) { // ** to do *** Use union of lane line and yaw_rate path to determine the // virtual lane virtual_lane_line->line_point.clear(); if (_b_image_based_cipv == false) { for (uint32_t i = 0; i < ref_lane_line.line_point.size(); i++) { Eigen::Vector2f virtual_line_point( ref_lane_line.line_point[i][0], ref_lane_line.line_point[i][1] + offset_distance); virtual_lane_line->line_point.push_back(virtual_line_point); } } else { // Image based extension requires to reproject virtual laneline points to // image space. } return true; } float Cipv::vehicle_dynamics(const uint32_t tick, const float yaw_rate, const float velocity, const float time_unit, float *x, float *y) { // straight model; *x = tick; *y = 0.0f; // float theta = _time_unit * yaw_rate; // float displacement = _time_unit * velocity; // Eigen::Rotation2Df rot2d(theta); // Eigen::Vector2f trans; // trans(0) = displacement * cos(theta); // trans(1) = displacement * sin(theta); // motion_2d.block(0, 0, 2, 2) = rot2d.toRotationMatrix().transpose(); // motion_2d.block(0, 2, 2, 1) = -rot2d.toRotationMatrix().transpose() * // trans; return true; } // Make a virtual lane line using a yaw_rate bool Cipv::make_virtual_ego_lane_from_yaw_rate(const float yaw_rate, const float velocity, const float offset_distance, LaneLine *left_lane_line, LaneLine *right_lane_line) { // ** to do *** Use union of lane line and yaw_rate path to determine the // virtual lane float x = 0.0f; float y = 0.0f; left_lane_line->line_point.clear(); right_lane_line->line_point.clear(); if (_b_image_based_cipv == false) { for (uint32_t i = 0; i < 120; i += 5) { vehicle_dynamics(i, yaw_rate, velocity, _time_unit, &x, &y); Eigen::Vector2f left_point(x, y + offset_distance); left_lane_line->line_point.push_back(left_point); Eigen::Vector2f right_point(x, y - offset_distance); right_lane_line->line_point.push_back(right_point); } } else { // Image based extension requires to reproject virtual laneline points to // image space. } return true; } // Elongate lane line bool Cipv::elongate_egolane( const LaneObjectsPtr lane_objects, const bool b_left_valid, const bool b_right_valid, const float yaw_rate, const float velocity, EgoLane *egolane_image, EgoLane *egolane_ground) { float offset_distance = EGO_CAR_HALF_VIRTUAL_LANE; // When left lane line is available if (b_left_valid && b_right_valid) { // elongate both lanes or do nothing AINFO << "Both lanes are fine"; // When only left lane line is avaiable } else if (!b_left_valid && b_right_valid) { // Generate virtual left lane based on right lane offset_distance = -(fabs(egolane_ground->right_line.line_point[0][1]) + EGO_CAR_HALF_VIRTUAL_LANE); make_virtual_lane(egolane_ground->right_line, yaw_rate, offset_distance, &egolane_ground->left_line); AINFO << "Made left lane"; // When only right lane line is avaiable } else if (b_left_valid && !b_right_valid) { // Generate virtual right lane based on left lane offset_distance = (fabs(egolane_ground->left_line.line_point[0][1]) + EGO_CAR_HALF_VIRTUAL_LANE); make_virtual_lane(egolane_ground->left_line, yaw_rate, offset_distance, &egolane_ground->right_line); AINFO << "Made right lane"; // When there is no lane lines available } else { // if (!b_left_valid && !b_right_valid) // Generate new egolane using yaw-rate and yaw-angle make_virtual_ego_lane_from_yaw_rate(yaw_rate, velocity, offset_distance, &egolane_ground->left_line, &egolane_ground->right_line); AINFO << "Made both lane_objects"; } return true; } // Get closest edge of an object in image cooridnate bool Cipv::find_closest_edge_of_object_image( const ObjectPtr &object, const EgoLane &egolane_image, LineSegment2Df *closted_object_edge) { float size_x = object->length; float size_y = object->width; float size_z = object->height; if (size_x < 1.0e-2 && size_y < 1.0e-2 && size_z < 1.0e-2) { // size_x = 0.1; // size_y = 0.1; // size_z = 0.1; return false; } float center_x = object->center[0]; float center_y = object->center[1]; float direction_x = object->direction[0]; float direction_y = object->direction[1]; float x1 = size_x / 2; float x2 = 0 - x1; float y1 = size_y / 2; float y2 = 0 - y1; double len = sqrt(direction_x * direction_x + direction_y * direction_y); float cos_theta = direction_x / len; float sin_theta = -direction_y / len; // Check if object direction is less than +-45 degree // angle = atan2(y, x) if (fabs(atan2(object->direction[1], object->direction[0])) <= FOURTY_FIVE_DEGREE) { // get back of the vehicle closted_object_edge->start_point[0] = x2 * cos_theta + y1 * sin_theta + center_x; closted_object_edge->start_point[1] = y1 * cos_theta - x2 * sin_theta + center_y; closted_object_edge->end_point[0] = x2 * cos_theta + y2 * sin_theta + center_x; closted_object_edge->end_point[1] = y2 * cos_theta - x2 * sin_theta + center_y; // If a vehicle faces side way, extract the side edge of a vehicle } else if (atan2(object->direction[1], object->direction[0]) > FOURTY_FIVE_DEGREE) { // get left side of the vehicle closted_object_edge->start_point[0] = x2 * cos_theta + y1 * sin_theta + center_x; closted_object_edge->start_point[1] = y1 * cos_theta - x2 * sin_theta + center_y; closted_object_edge->end_point[0] = x2 * cos_theta + y1 * sin_theta + center_x; closted_object_edge->end_point[1] = y1 * cos_theta - x2 * sin_theta + center_y; } else if (atan2(object->direction[1], object->direction[0]) < -FOURTY_FIVE_DEGREE) { // get right side of the vehicle closted_object_edge->start_point[0] = x1 * cos_theta + y2 * sin_theta + center_x; closted_object_edge->start_point[1] = y2 * cos_theta - x1 * sin_theta + center_y; closted_object_edge->end_point[0] = x2 * cos_theta + y2 * sin_theta + center_x; closted_object_edge->end_point[1] = y2 * cos_theta - x2 * sin_theta + center_y; } else { // don't get front of vehicle closted_object_edge->start_point[0] = x1 * cos_theta + y1 * sin_theta + center_x; closted_object_edge->start_point[1] = y1 * cos_theta - x1 * sin_theta + center_y; closted_object_edge->end_point[0] = x1 * cos_theta + y2 * sin_theta + center_x; closted_object_edge->end_point[1] = y2 * cos_theta - x1 * sin_theta + center_y; } return true; } // Get closest edge of an object in ground cooridnate // *** TO DO *** This funcion should be changed to find min-y and max-y edges // to determine CIPV. bool Cipv::find_closest_edge_of_object_ground( const ObjectPtr &object, const EgoLane &egolane_ground, LineSegment2Df *closted_object_edge) { if (_debug_level >= 2) { AINFO << "object->track_id: " << object->track_id; // AINFO << "object->length: " << object->length; // AINFO << "object->width: " << object->width; // AINFO << "object->height: " << object->height; } float size_x = object->length; float size_y = object->width; float size_z = object->height; if (size_x < 1.0e-2 && size_y < 1.0e-2 && size_z < 1.0e-2) { // size_x = 0.1; // size_y = 0.1; // size_z = 0.1; return false; } if (_debug_level >= 3) { AINFO << "object->center[0]: " << object->center[0]; AINFO << "object->center[1]: " << object->center[1]; AINFO << "object->center[2]: " << object->center[2]; AINFO << "object->direction[0]: " << object->direction[0]; AINFO << "object->direction[1]: " << object->direction[1]; AINFO << "object->direction[2]: " << object->direction[2]; } float center_x = object->center[0]; float center_y = object->center[1]; float direction_x = object->direction[0]; float direction_y = object->direction[1]; float x1 = size_x / 2; float x2 = 0 - x1; float y1 = size_y / 2; float y2 = 0 - y1; double len = sqrt(direction_x * direction_x + direction_y * direction_y); if (len < B_FLT_EPSILON) { return false; } float cos_theta = direction_x / len; float sin_theta = -direction_y / len; Point2Df p[4]; p[0][0] = x2 * cos_theta + y1 * sin_theta + center_x; p[0][1] = y1 * cos_theta - x2 * sin_theta + center_y; p[1][0] = x2 * cos_theta + y2 * sin_theta + center_x; p[1][1] = y2 * cos_theta - x2 * sin_theta + center_y; p[2][0] = x1 * cos_theta + y1 * sin_theta + center_x; p[2][1] = y1 * cos_theta - x1 * sin_theta + center_y; p[3][0] = x1 * cos_theta + y2 * sin_theta + center_x; p[3][1] = y2 * cos_theta - x1 * sin_theta + center_y; if (_debug_level >= 2) { AINFO << "P0(" << p[0][0] << ", " << p[0][1] << ")"; AINFO << "P1(" << p[1][0] << ", " << p[1][1] << ")"; AINFO << "P2(" << p[2][0] << ", " << p[2][1] << ")"; AINFO << "P3(" << p[3][0] << ", " << p[3][1] << ")"; } float closest_x = MAX_FLOAT; float second_closest_x = MAX_FLOAT - 1.0f; int32_t closest_index = -1; int32_t second_closest_index = -1; for (int32_t i = 0; i < 4; i++) { if (p[i][0] <= closest_x) { second_closest_index = closest_index; second_closest_x = closest_x; closest_index = i; closest_x = p[i][0]; } else if (p[i][0] <= second_closest_x) { second_closest_index = i; second_closest_x = p[i][0]; } } if (p[closest_index][1] >= p[second_closest_index][1]) { closted_object_edge->start_point[0] = p[closest_index][0]; closted_object_edge->start_point[1] = p[closest_index][1]; closted_object_edge->end_point[0] = p[second_closest_index][0]; closted_object_edge->end_point[1] = p[second_closest_index][1]; } else { closted_object_edge->start_point[0] = p[second_closest_index][0]; closted_object_edge->start_point[1] = p[second_closest_index][1]; closted_object_edge->end_point[0] = p[closest_index][0]; closted_object_edge->end_point[1] = p[closest_index][1]; } if (_debug_level >= 2) { AINFO << "start(" << closted_object_edge->start_point[0] << ", " << closted_object_edge->start_point[1] << ")->"; AINFO << "end(" << closted_object_edge->end_point[0] << ", " << closted_object_edge->end_point[1] << ")"; } return true; } // Check if the distance between lane and object are OK bool Cipv::are_distances_sane(const float distance_start_point_to_right_lane, const float distance_start_point_to_left_lane, const float distance_end_point_to_right_lane, const float distance_end_point_to_left_lane) { float distance = -1.0f; if (distance_start_point_to_right_lane > MAX_DIST_OBJECT_TO_LANE_METER) { if (_debug_level >= 1) { AINFO << "distance from start to right lane(" << distance << " m) is too long"; } return false; } if (distance_start_point_to_left_lane > MAX_DIST_OBJECT_TO_LANE_METER) { if (_debug_level >= 1) { AINFO << "distance from start to left lane(" << distance << " m) is too long"; } return false; } if (distance_end_point_to_right_lane > MAX_DIST_OBJECT_TO_LANE_METER) { if (_debug_level >= 1) { AINFO << "distance from end to right lane(" << distance << " m) is too long"; } return false; } if (distance_end_point_to_left_lane > MAX_DIST_OBJECT_TO_LANE_METER) { if (_debug_level >= 1) { AINFO << "distance from end to left lane(" << distance << " m) is too long"; } return false; } distance = fabs(distance_start_point_to_right_lane - distance_end_point_to_right_lane); if (distance > MAX_VEHICLE_WIDTH_METER) { if (_debug_level >= 1) { AINFO << "width of vehicle (" << distance << " m) is too long"; } return false; } distance = fabs(distance_end_point_to_left_lane - distance_start_point_to_left_lane); if (distance > MAX_VEHICLE_WIDTH_METER) { if (_debug_level >= 1) { AINFO << "width of vehicle (" << distance << " m) is too long"; } return false; } // put more conditions here if required. // AINFO << "Distances are sane!"; return true; } // Check if a point is left of a line segment bool Cipv::is_point_left_of_line(const Point2Df &point, const Point2Df &line_seg_start_point, const Point2Df &line_seg_end_point) { float cross_product = ((line_seg_end_point[0] - line_seg_start_point[0]) * (point[1] - line_seg_start_point[1])) - ((line_seg_end_point[1] - line_seg_start_point[1]) * (point[0] - line_seg_start_point[0])); if (cross_product > 0.0f) { if (_debug_level >= 2) { AINFO << "point (" << point[0] << ", " << point[1] << ") is left of line_segment (" << line_seg_start_point[0] << ", " << line_seg_start_point[1] << ")->(" << line_seg_end_point[0] << ", " << line_seg_end_point[1] << "), cross_product: " << cross_product; } return true; } else { if (_debug_level >= 2) { AINFO << "point (" << point[0] << ", " << point[1] << ") is right of line_segment (" << line_seg_start_point[0] << ", " << line_seg_start_point[1] << ")->(" << line_seg_end_point[0] << ", " << line_seg_end_point[1] << "), cross_product: " << cross_product; } return false; } } // Check if the object is in the lane in image space bool Cipv::is_object_in_the_lane_image(const ObjectPtr &object, const EgoLane &egolane_image) { return true; } // Check if the object is in the lane in ego-ground space // | | // | *------* | // | *-+-----* // | | *--------* <- closest edge of object // *+------* | // | | // l_lane r_lane bool Cipv::is_object_in_the_lane_ground(const ObjectPtr &object, const EgoLane &egolane_ground) { LineSegment2Df closted_object_edge; uint32_t i; bool b_left_lane_clear = false; bool b_right_lane_clear = false; float shortest_distance = 0.0f; float distance = 0.0f; float shortest_distance_start_point_to_right_lane = 0.0f; float shortest_distance_start_point_to_left_lane = 0.0f; float shortest_distance_end_point_to_right_lane = 0.0f; float shortest_distance_end_point_to_left_lane = 0.0f; int closest_index = -1; // Find closest edge of a given object bounding box float b_valid_object = find_closest_edge_of_object_ground( object, egolane_ground, &closted_object_edge); if (!b_valid_object) { if (_debug_level >= 1) { ADEBUG << "The closest edge of an object is not available"; } return false; } if (_debug_level >= 3) { AINFO << "egolane_ground.left_line.line_point.size(): " << egolane_ground.left_line.line_point.size(); } if (egolane_ground.left_line.line_point.size() <= 1) { if (_debug_level >= 1) { ADEBUG << "No left lane"; } return false; } // Check end_point and left lane closest_index = -1; shortest_distance = MAX_FLOAT; for (i = 0; i < egolane_ground.left_line.line_point.size() - 1; i++) { // If a end point is in the clostest left lane line segments distance = MAX_FLOAT; if (distance_from_point_to_line_segment( closted_object_edge.end_point, egolane_ground.left_line.line_point[i], egolane_ground.left_line.line_point[i + 1], &distance) == true) { if (distance < shortest_distance) { closest_index = i; shortest_distance = distance; } } } // When the clostest line segment was found if (closest_index >= 0) { // Check if the end point is on the right of the line segment if (_debug_level >= 3) { AINFO << "[Left] closest_index: " << closest_index << ", shortest_distance: " << shortest_distance; } if (is_point_left_of_line( closted_object_edge.end_point, egolane_ground.left_line.line_point[closest_index], egolane_ground.left_line.line_point[closest_index + 1]) == false) { b_left_lane_clear = true; } } if (_debug_level >= 3) { AINFO << "egolane_ground.right_line.line_point.size(): " << egolane_ground.right_line.line_point.size(); } // Check start_point and right lane if (egolane_ground.right_line.line_point.size() <= 1) { if (_debug_level >= 1) { ADEBUG << "No right lane"; } return false; } closest_index = -1; shortest_distance = MAX_FLOAT; for (i = 0; i < egolane_ground.right_line.line_point.size() - 1; i++) { // If a end point is in the clostest right lane line segments distance = MAX_FLOAT; if (distance_from_point_to_line_segment( closted_object_edge.start_point, egolane_ground.right_line.line_point[i], egolane_ground.right_line.line_point[i + 1], &distance) == true) { if (distance < shortest_distance) { closest_index = i; shortest_distance = distance; } } } // When the clostest line segment was found if (closest_index >= 0) { if (_debug_level >= 3) { AINFO << "[right] closest_index: " << closest_index << ", shortest_distance: " << shortest_distance; } // Check if the end point is on the right of the line segment if (is_point_left_of_line( closted_object_edge.start_point, egolane_ground.right_line.line_point[closest_index], egolane_ground.right_line.line_point[closest_index + 1]) == true) { b_right_lane_clear = true; } } // Check if the distance is sane if (are_distances_sane(shortest_distance_start_point_to_right_lane, shortest_distance_start_point_to_left_lane, shortest_distance_end_point_to_right_lane, shortest_distance_end_point_to_left_lane)) { return (b_left_lane_clear && b_right_lane_clear); } else { return false; } return true; } // Check if the object is in the lane in ego-ground space bool Cipv::is_object_in_the_lane(const ObjectPtr &object, const EgoLane &egolane_image, const EgoLane &egolane_ground) { if (_b_image_based_cipv == true) { return is_object_in_the_lane_image(object, egolane_image); } else { return is_object_in_the_lane_ground(object, egolane_ground); } } // ===================================================================== // Determine CIPV among multiple objects bool Cipv::determine_cipv(std::shared_ptr<SensorObjects> sensor_objects, CipvOptions *options) { if (_debug_level >= 3) { AINFO << "Cipv Got SensorObjects size " << sensor_objects->objects.size(); AINFO << "Cipv Got lane object size " << sensor_objects->lane_objects->size(); } float yaw_rate = options->yaw_rate; float velocity = options->yaw_rate; int32_t old_cipv_index = sensor_objects->cipv_index; int32_t cipv_index = -1; // int32_t old_cipv_track_id = sensor_objects->cipv_track_id; int32_t cipv_track_id = -1; // AINFO<<"static_cast<int32_t>(sensor_objects->objects.size(): " // << static_cast<int32_t>(sensor_objects->objects.size()); bool b_left_valid = false; bool b_right_valid = false; EgoLane egolane_image; EgoLane egolane_ground; // Get ego lanes (in both image and ground coordinate) get_egolane(sensor_objects->lane_objects, &egolane_image, &egolane_ground, &b_left_valid, &b_right_valid); elongate_egolane(sensor_objects->lane_objects, b_left_valid, b_right_valid, yaw_rate, velocity, &egolane_image, &egolane_ground); for (int32_t i = 0; i < static_cast<int32_t>(sensor_objects->objects.size()); i++) { if (_debug_level >= 2) { AINFO << "sensor_objects->objects[i]->track_id: " << sensor_objects->objects[i]->track_id; } if (is_object_in_the_lane(sensor_objects->objects[i], egolane_image, egolane_ground) == true) { if (cipv_index >= 0) { // if there is existing CIPV // if objects[i] is closer than objects[cipv_index] in ego-x coordinate // AINFO << "sensor_objects->objects[i]->center[0]: " // << sensor_objects->objects[i]->center[0]; // AINFO << "sensor_objects->objects[cipv_index]->center[0]: " // << sensor_objects->objects[cipv_index]->center[0]; if (sensor_objects->objects[i]->center[0] < sensor_objects->objects[cipv_index]->center[0]) { cipv_index = i; cipv_track_id = sensor_objects->objects[i]->track_id; } } else { cipv_index = i; cipv_track_id = sensor_objects->objects[i]->track_id; } if (_debug_level >= 2) { AINFO << "current cipv_index: " << cipv_index; } } } // AINFO << "old_cipv_index: " << old_cipv_index; if (old_cipv_index != cipv_index && cipv_index >= 0) { // AINFO << "sensor_objects->objects[cipv_index]->b_cipv: " // << sensor_objects->objects[cipv_index]->b_cipv; // AINFO << "sensor_objects->cipv_index: " // << sensor_objects->cipv_index; // AINFO << "sensor_objects->cipv_track_id: " // << sensor_objects->cipv_track_id; if (old_cipv_index >= 0) { // AINFO << "sensor_objects->objects[old_cipv_index]->b_cipv: " // << sensor_objects->objects[old_cipv_index]->b_cipv; sensor_objects->objects[old_cipv_index]->b_cipv = false; } sensor_objects->objects[cipv_index]->b_cipv = true; sensor_objects->cipv_index = cipv_index; sensor_objects->cipv_track_id = cipv_track_id; if (_debug_level >= 1) { AINFO << "final cipv_index: " << cipv_index; AINFO << "final cipv_track_id: " << cipv_track_id; // AINFO << "CIPV Index is changed from " << old_cipv_index << "th // object to " // << cipv_index << "th object."; // AINFO << "CIPV Track_ID is changed from " << old_cipv_track_id << // " to " // << cipv_track_id << "."; } } else { if (_debug_level >= 1) { AINFO << "No cipv"; } } return true; } std::string Cipv::name() const { return "Cipv"; } // Register plugin. // REGISTER_CIPV(Cipv); } // namespace obstacle } // namespace perception } // namespace apollo
[ "ycool@users.noreply.github.com" ]
ycool@users.noreply.github.com
9366ae2eed577e3226a950146d3317dd14704d7b
4ef69f0044f45be4fbce54f7b7c0319e4c5ec53d
/include/cv/core/cmd/out/zlacn2.inl
e66f6f02daf57cd6310b7aa95024b1f845630c16
[]
no_license
15831944/cstd
c6c3996103953ceda7c06625ee1045127bf79ee8
53b7e5ba73cbdc9b5bbc61094a09bf3d5957f373
refs/heads/master
2021-09-15T13:44:37.937208
2018-06-02T10:14:16
2018-06-02T10:14:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
116
inl
#ifndef __zlacn2__ #define __zlacn2__ #define c__1 c__1_zlacn2 #include "zlacn2.c" #undef c__1 #endif // __zlacn2__
[ "31720406@qq.com" ]
31720406@qq.com
1cb80036797f1ebf7e42a1748073b8f07e22c74e
7ef6453e6ee6cd88f04779c54930d9e33dbfaef2
/Source/MeetupNov2019/Actors/HorizontalLayoutComponent.cpp
5e60b947108ad5e29886ed93ac4c3fe21f7c7397
[ "MIT" ]
permissive
mmischitelli/MeetupNov2019
5b4a82eb99778bf0041db1572fb7cb2ab94e6808
645f381417c85a5349df712b67e34157dc487277
refs/heads/master
2021-07-16T05:37:49.690330
2020-10-11T17:18:50
2020-10-11T17:18:50
217,704,958
4
1
null
null
null
null
UTF-8
C++
false
false
1,192
cpp
#include "HorizontalLayoutComponent.h" #include "GameFramework/Actor.h" #include "MeetupNov2019/Common/Utils.h" #include "Engine/Engine.h" UHorizontalLayoutComponent::UHorizontalLayoutComponent() { PrimaryComponentTick.bCanEverTick = true; } void UHorizontalLayoutComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); TArray<AActor*> Actors; GetOwner()->GetAttachedActors(Actors); if (Actors.Num() == 0) return; const auto TotalSize = UStd::TAccumulate_N(Actors.CreateConstIterator(), Actors.Num(), .0f, [&](float curr, AActor* Actor) { FVector Origin, Extent; Actor->GetActorBounds(true, Origin, Extent); return curr + Extent.Y * 2.0f + m_Margin; }); const auto StartingOffset = (-TotalSize + m_Margin) * 0.5f; UStd::TForEach_N(Actors.CreateConstIterator(), Actors.Num(), [&, accumSize = .0f](AActor* Actor) mutable { FVector Origin, Extent; Actor->GetActorBounds(true, Origin, Extent); Actor->SetActorRelativeLocation({ StartingOffset + accumSize + Extent.Y + m_Margin * 0.5f, .0f, .0f }); accumSize += Extent.Y * 2.0f + m_Margin; }); }
[ "michelemischitelli@outlook.com" ]
michelemischitelli@outlook.com
5af2faac46ae0b3bdcdf93f39912756f4d8839fa
861f7edb325e1ec205c8d44bfb5169174bbbdc76
/hello.cpp
ffbe15e83f0dfbee481d60826dc508671efa1711
[]
no_license
ShawnZhou2000/test
c7346e19afd54a6034e08c887a45b8eb510fe67b
93f1fe5e9305508abe5fd96a36ba0a7beba94660
refs/heads/master
2020-08-28T20:37:47.164677
2019-10-27T07:27:37
2019-10-27T07:27:37
217,814,250
0
0
null
2019-10-27T07:27:38
2019-10-27T06:27:31
C++
UTF-8
C++
false
false
113
cpp
#include <iostream> using namespace std; int main() { cout << "hello,git" << endl; return 0; } //feature
[ "txbb@qaq.com" ]
txbb@qaq.com
277feaa4503e5b30066907442834b9121d8b00e3
9f9660f318732124b8a5154e6670e1cfc372acc4
/Case_save/Case30/case3/500/U
120eea6fe0603da51bd3268f0691535008de8c99
[]
no_license
mamitsu2/aircond5
9a6857f4190caec15823cb3f975cdddb7cfec80b
20a6408fb10c3ba7081923b61e44454a8f09e2be
refs/heads/master
2020-04-10T22:41:47.782141
2019-09-02T03:42:37
2019-09-02T03:42:37
161,329,638
0
0
null
null
null
null
UTF-8
C++
false
false
13,137
// -*- C++ -*- // File generated by PyFoam - sorry for the ugliness FoamFile { version 2.0; format ascii; class volVectorField; location "500"; object U; } dimensions [ 0 1 -1 0 0 0 0 ]; internalField nonuniform List<vector> 459 ( (0.040513 0.0835694 0) (-0.162283 0.0233102 0) (-0.18318 0.0174098 0) (-0.213282 0.0129513 0) (-0.236735 0.00792513 0) (-0.25292 0.00261871 0) (-0.260769 -0.00308645 0) (-0.25876 -0.00929619 0) (-0.246232 -0.0160369 0) (-0.223497 -0.022651 0) (-0.19204 -0.0282783 0) (-0.154202 -0.0324845 0) (-0.112713 -0.035839 0) (-0.0734773 -0.0403984 0) (-0.0547614 -0.0475012 0) (0.00850947 0.0064034 0) (-0.0153619 -0.0189908 0) (0.0108153 -0.0250082 0) (0.0284802 -0.0174623 0) (0.0428112 -0.0112124 0) (0.0521789 -0.00695942 0) (0.0569891 -0.00426244 0) (0.0590258 -0.0028806 0) (0.0598177 -0.00223723 0) (0.0601686 -0.00190096 0) (0.0603052 -0.00168787 0) (0.0602396 -0.00151065 0) (0.0599056 -0.00128374 0) (0.0590972 -0.000845632 0) (0.0572645 0.000176626 0) (0.0532644 0.0022975 0) (0.0458662 0.00441754 0) (0.0400577 0.0055281 0) (-0.0170595 0.0194335 0) (0.218348 0.171623 0) (-0.154455 0.0617105 0) (-0.147806 0.0502871 0) (-0.17902 0.0410896 0) (-0.201938 0.0307466 0) (-0.217967 0.019363 0) (-0.226193 0.00644963 0) (-0.224949 -0.00828791 0) (-0.213574 -0.0240442 0) (-0.192838 -0.0386581 0) (-0.164694 -0.0498414 0) (-0.132107 -0.0562488 0) (-0.0985882 -0.05802 0) (-0.0690617 -0.0567435 0) (-0.0500456 -0.0518347 0) (-0.0337222 -0.0298159 0) (-0.0109147 -0.00164083 0) (0.0777204 0.0215747 0) (0.0390779 -0.0190351 0) (0.0422935 -0.0270949 0) (0.0521397 -0.0214329 0) (0.059469 -0.0135767 0) (0.0635774 -0.00692857 0) (0.06485 -0.00230981 0) (0.0647654 0.000112263 0) (0.0645698 0.00120229 0) (0.0645774 0.00175606 0) (0.0646599 0.00212279 0) (0.0647005 0.00243806 0) (0.0646724 0.00286774 0) (0.0645246 0.00374522 0) (0.0637197 0.00594703 0) (0.0598602 0.0121066 0) (0.0501302 0.0169769 0) (0.0461341 0.0192966 0) (-0.0524016 0.0426103 0) (0.380627 0.257103 0) (-0.175208 0.0994091 0) (-0.110977 0.0816721 0) (-0.141665 0.0645375 0) (-0.161568 0.0473436 0) (-0.176088 0.0288902 0) (-0.184053 0.00795494 0) (-0.182796 -0.0158931 0) (-0.171327 -0.041056 0) (-0.151262 -0.0636534 0) (-0.125234 -0.0799631 0) (-0.0964422 -0.0881653 0) (-0.0680864 -0.0883227 0) (-0.0432528 -0.0816855 0) (-0.0241689 -0.0677537 0) (-0.00892266 -0.0435771 0) (0.00879778 -0.0118685 0) (0.103205 -0.0535994 0) (0.0659171 -0.0469787 0) (0.0625496 -0.0377058 0) (0.0660399 -0.0277059 0) (0.0682896 -0.01811 0) (0.0690231 -0.0102784 0) (0.0673437 -0.00865407 0) (0.0646772 -0.00653039 0) (0.0630901 -0.0054174 0) (0.0625371 -0.0048032 0) (0.0624432 -0.00442908 0) (0.0625588 -0.00414755 0) (0.062952 -0.00380965 0) (0.064078 -0.00310514 0) (0.0671166 -0.000147898 0) (0.0651619 0.0169111 0) (0.0516329 0.0286453 0) (0.053701 0.0356997 0) (-0.0825157 0.0673403 0) (0.525191 0.326013 0) (-0.213047 0.133633 0) (-0.0719122 0.108158 0) (-0.102014 0.0840983 0) (-0.115973 0.0623094 0) (-0.126691 0.0388846 0) (-0.132896 0.0111681 0) (-0.129781 -0.0219028 0) (-0.116782 -0.0568089 0) (-0.0971996 -0.0867221 0) (-0.0743094 -0.106847 0) (-0.0508791 -0.115666 0) (-0.0292305 -0.113783 0) (-0.0106406 -0.103173 0) (0.00536218 -0.083989 0) (0.0203003 -0.0590758 0) (0.0418488 -0.0335902 0) (0.0729094 -0.00804882 0) (0.0837085 -0.0391598 0) (0.071225 -0.0401047 0) (0.0650167 -0.0325978 0) (0.0637431 -0.0249517 0) (0.0637365 -0.0172495 0) (0.0651238 -0.00872029 0) (0.06882 -0.00564143 0) (0.0738767 -0.00517241 0) (0.0783812 -0.00486663 0) (0.0821015 -0.00444765 0) (0.084859 -0.00366819 0) (0.0859668 -0.00234807 0) (0.0840817 -0.000289017 0) (0.0780305 0.00273913 0) (0.0652785 0.00724048 0) (0.0536442 0.0273966 0) (0.041828 0.0440498 0) (0.0575644 0.0566267 0) (-0.115343 0.0900624 0) (0.64817 0.379861 0) (-0.256652 0.162594 0) (-0.0332027 0.123206 0) (-0.0607304 0.095202 0) (-0.0665702 0.071007 0) (-0.0709719 0.0447964 0) (-0.073238 0.0122213 0) (-0.0638535 -0.0293824 0) (-0.0482002 -0.0728181 0) (-0.030416 -0.107207 0) (-0.0131784 -0.128167 0) (0.00218132 -0.135381 0) (0.0144485 -0.13035 0) (0.0238815 -0.116621 0) (0.0315813 -0.0965746 0) (0.0393562 -0.0732316 0) (0.0496414 -0.0514354 0) (0.0609795 -0.0396796 0) (0.064531 -0.0422969 0) (0.0595781 -0.0378622 0) (0.0534367 -0.0302982 0) (0.0497843 -0.0233259 0) (0.0481807 -0.0171672 0) (0.0486631 -0.0116073 0) (0.0511859 -0.00785575 0) (0.0552027 -0.006283 0) (0.0592773 -0.00559512 0) (0.0631613 -0.0046815 0) (0.0666067 -0.00276293 0) (0.0690781 0.000716528 0) (0.0694407 0.00573425 0) (0.066958 0.0122888 0) (0.0611502 0.0209795 0) (0.0538744 0.036658 0) (0.0433985 0.0553211 0) (0.0654624 0.0757331 0) (-0.0218335 0.103624 0) (0.0441064 0.0297305 0) (-0.0645832 -0.0362075 0) (-0.272774 -0.0586741 0) (0.735181 0.425395 0) (-0.297172 0.18311 0) (-0.00428331 0.119263 0) (-0.0182264 0.0964721 0) (-0.0143214 0.0738489 0) (-0.0107755 0.0470042 0) (-0.0066379 0.00979087 0) (0.016755 -0.0432911 0) (0.0331812 -0.0896136 0) (0.0458119 -0.122446 0) (0.0541162 -0.140079 0) (0.0581512 -0.143732 0) (0.05871 -0.136035 0) (0.0569492 -0.120261 0) (0.0540943 -0.0994684 0) (0.051592 -0.0769182 0) (0.0505507 -0.0562477 0) (0.0501701 -0.0419859 0) (0.0469865 -0.0357254 0) (0.0403887 -0.0306697 0) (0.0335378 -0.024987 0) (0.0289325 -0.0199528 0) (0.0267693 -0.0158782 0) (0.0269401 -0.0125568 0) (0.0290713 -0.0104939 0) (0.0324758 -0.00999504 0) (0.0363613 -0.0099215 0) (0.0404803 -0.00921268 0) (0.0446771 -0.00700301 0) (0.0486407 -0.00246754 0) (0.0520477 0.00463501 0) (0.0534475 0.0136656 0) (0.0532763 0.0246667 0) (0.0531792 0.0394413 0) (0.0513613 0.0577175 0) (0.0739109 0.0809764 0) (0.0524544 0.0986405 0) (0.0926264 0.0684716 0) (0.116381 0.0445819 0) (-0.132353 -0.00948067 0) (0.781307 0.466936 0) (-0.316393 0.170085 0) (0.0199703 0.0701037 0) (0.0382146 0.0761488 0) (0.0504057 0.066941 0) (0.0617932 0.0383084 0) (0.0861729 -0.00824292 0) (0.109133 -0.060506 0) (0.122222 -0.102148 0) (0.126071 -0.128893 0) (0.122266 -0.140759 0) (0.112585 -0.139784 0) (0.099097 -0.128973 0) (0.0838534 -0.111572 0) (0.0685505 -0.0906386 0) (0.0546059 -0.0691793 0) (0.0428016 -0.0498914 0) (0.0331387 -0.0357673 0) (0.0240909 -0.0276664 0) (0.0155047 -0.0228714 0) (0.00851006 -0.0191921 0) (0.00402321 -0.0164865 0) (0.00189176 -0.0146761 0) (0.00178344 -0.0135114 0) (0.00325335 -0.01313 0) (0.00568595 -0.0135096 0) (0.00859741 -0.0139284 0) (0.0118986 -0.0136246 0) (0.0157043 -0.0118007 0) (0.0201624 -0.00744625 0) (0.0262654 0.000451622 0) (0.0323424 0.0106777 0) (0.0375919 0.0220523 0) (0.0442751 0.0352874 0) (0.0515649 0.0503419 0) (0.0738295 0.0692367 0) (0.0865105 0.0769683 0) (0.118626 0.0535623 0) (0.15864 0.0440545 0) (-0.0366116 0.0935313 0) (0.884124 0.472 0) (-0.0787898 0.150468 0) (0.101951 -0.00511604 0) (0.163694 -0.00829749 0) (0.170088 -0.00288632 0) (0.175968 -0.0268778 0) (0.204419 -0.0594098 0) (0.220019 -0.0888943 0) (0.219296 -0.111137 0) (0.205555 -0.123867 0) (0.18287 -0.126453 0) (0.154835 -0.120019 0) (0.124629 -0.106825 0) (0.0948279 -0.0892969 0) (0.0671767 -0.0697849 0) (0.0429472 -0.0508056 0) (0.0226004 -0.0342991 0) (0.00709835 -0.0229015 0) (-0.00496606 -0.0170309 0) (-0.0131583 -0.0148861 0) (-0.0189673 -0.0139155 0) (-0.0227663 -0.0135674 0) (-0.0249998 -0.0136516 0) (-0.0260272 -0.0140336 0) (-0.026195 -0.0147203 0) (-0.0258911 -0.0156311 0) (-0.025378 -0.0164468 0) (-0.0246665 -0.01676 0) (-0.0235496 -0.0160978 0) (-0.0216085 -0.0138848 0) (-0.0177974 -0.00940248 0) (-0.00803541 -0.00185743 0) (0.000968852 0.00761002 0) (0.0116479 0.0163494 0) (0.0234742 0.0236994 0) (0.0439401 0.0313187 0) (0.0630429 0.0241955 0) (0.082997 -0.00471879 0) (0.14264 0.039056 0) (-0.41374 0.206213 0) (1.02668 0.427819 0) (0.490699 0.283539 0) (0.502164 0.195631 0) (0.511448 0.137518 0) (0.474527 0.0967965 0) (0.438492 0.0545861 0) (0.402774 0.00900933 0) (0.360089 -0.0318512 0) (0.311999 -0.0618663 0) (0.261007 -0.078926 0) (0.209887 -0.0838227 0) (0.160702 -0.0793282 0) (0.115166 -0.0687587 0) (0.0744928 -0.0546834 0) (0.0392353 -0.0391488 0) (0.01009 -0.0246093 0) (-0.0135362 -0.0131992 0) (-0.0269749 -0.00884357 0) (-0.035821 -0.00801338 0) (-0.0419821 -0.00861971 0) (-0.0467409 -0.00951505 0) (-0.0505421 -0.0104798 0) (-0.0536869 -0.0114708 0) (-0.0564284 -0.0124786 0) (-0.0590272 -0.0135079 0) (-0.061774 -0.0144749 0) (-0.0649401 -0.0151445 0) (-0.0687681 -0.0151438 0) (-0.0735468 -0.0139454 0) (-0.0797021 -0.0108521 0) (-0.0877572 -0.00507143 0) (-0.0979955 0.00398864 0) (-0.107737 0.0154757 0) (-0.122538 0.029566 0) (-0.146311 0.0464254 0) (-0.18154 0.0649439 0) (-0.231763 0.0810347 0) (-0.28929 0.0921928 0) (-0.358372 0.0984407 0) (-0.621323 0.100319 0) (-0.19864 0.0297641 0) (0.144167 0.0624332 0) (0.239003 0.041616 0) (0.233644 0.0145411 0) (0.21808 -0.00965592 0) (0.203207 -0.0268409 0) (0.178498 -0.0371879 0) (0.14655 -0.041553 0) (0.110586 -0.0403352 0) (0.0735004 -0.0348867 0) (0.0378328 -0.0265351 0) (0.00448582 -0.0156099 0) (-0.0246142 -0.00443912 0) (-0.0433468 0.0016182 0) (-0.0545787 0.00353122 0) (-0.0608147 0.00282287 0) (-0.0653881 0.00132011 0) (-0.0694254 -0.000437318 0) (-0.07332 -0.00203651 0) (-0.0772495 -0.00343505 0) (-0.0812946 -0.00462796 0) (-0.085543 -0.00560073 0) (-0.0900997 -0.0063102 0) (-0.095068 -0.00663896 0) (-0.100505 -0.00637123 0) (-0.106382 -0.00520894 0) (-0.112569 -0.00280282 0) (-0.118814 0.00120605 0) (-0.124588 0.00713958 0) (-0.128696 0.0156599 0) (-0.131929 0.0279534 0) (-0.134621 0.0443152 0) (-0.137645 0.0638509 0) (-0.141572 0.0829145 0) (-0.143305 0.0914397 0) (-0.126116 0.0683434 0) (-0.0834382 -0.0259121 0) (-0.280075 -0.203859 0) (-0.0422616 0.213381 0) (0.0597054 0.105482 0) (0.036137 0.0385311 0) (0.0379012 0.0220259 0) (0.0401739 0.0113736 0) (0.0370831 0.000106552 0) (0.0267739 -0.00844831 0) (0.00867939 -0.0117564 0) (-0.0151882 -0.00928151 0) (-0.0384205 -0.0052014 0) (-0.05801 -0.0022289 0) (-0.0717962 -0.0012579 0) (-0.0790685 -0.00286644 0) (-0.0821583 -0.00643196 0) (-0.0837983 -0.0106128 0) (-0.0852061 -0.0146586 0) (-0.0869613 -0.0176003 0) (-0.0891697 -0.0193113 0) (-0.0918688 -0.0200028 0) (-0.094972 -0.0202689 0) (-0.0984526 -0.0202866 0) (-0.102265 -0.0201093 0) (-0.106345 -0.0197398 0) (-0.1106 -0.0191175 0) (-0.114866 -0.0180942 0) (-0.118874 -0.0164138 0) (-0.122218 -0.0136888 0) (-0.124341 -0.00935461 0) (-0.124573 -0.00286414 0) (-0.122066 0.00602238 0) (-0.115378 0.018145 0) (-0.103236 0.0342093 0) (-0.0854042 0.0537877 0) (-0.0628962 0.0728584 0) (-0.0385754 0.084071 0) (0.00138573 0.0683199 0) (0.144275 -0.00367683 0) (-0.208145 -0.114867 0) (-0.0615598 -0.328297 0) (-0.418557 -0.118821 0) (-0.305907 0.0799163 0) (-0.222805 -0.0192204 0) (-0.173244 -0.0388813 0) (-0.144133 -0.0328514 0) (-0.129904 -0.0271283 0) (-0.125346 -0.0207208 0) (-0.125493 -0.0118507 0) (-0.128104 -0.00207182 0) (-0.129112 0.00727113 0) (-0.126803 0.0154403 0) (-0.12248 0.0232334 0) (-0.116375 0.0307135 0) (-0.109531 0.0374346 0) (-0.103229 0.0431141 0) (-0.0983058 0.0477443 0) (-0.095044 0.0510911 0) (-0.0933337 0.0528912 0) (-0.09287 0.0531584 0) (-0.0933518 0.0521343 0) (-0.0945778 0.0506276 0) (-0.0963957 0.0488742 0) (-0.0986864 0.0469695 0) (-0.101338 0.0449782 0) (-0.104214 0.0429561 0) (-0.107121 0.0409574 0) (-0.109764 0.0390309 0) (-0.111702 0.0372117 0) (-0.112246 0.0355291 0) (-0.110183 0.0344484 0) (-0.10353 0.0350288 0) (-0.089833 0.03802 0) (-0.067206 0.0442814 0) (-0.0361602 0.0543171 0) (0.0124591 0.0678579 0) (0.0585132 0.0694394 0) (0.101792 0.0542458 0) (0.164507 0.0245066 0) (-0.219115 -0.0312589 0) ) ; boundaryField { floor { type noSlip; } ceiling { type noSlip; } sWall { type noSlip; } nWall { type noSlip; } sideWalls { type empty; } glass1 { type noSlip; } glass2 { type noSlip; } sun { type noSlip; } heatsource1 { type noSlip; } heatsource2 { type noSlip; } Table_master { type noSlip; } Table_slave { type noSlip; } inlet { type fixedValue; value uniform (0.277164 -0.114805 0); } outlet { type zeroGradient; } } // ************************************************************************* //
[ "mitsuaki.makino@tryeting.jp" ]
mitsuaki.makino@tryeting.jp
c0bb310a6043078261d9a5b3dd0b7e672bd7559e
2ee4e5f7838a06ecd45de8fc7b62bc8416279ed0
/CWE-120 Buffer Copy without Checking Size of Input/Testdata/post-951046.cpp
3e41fe973512976deb46796897136035716622be
[]
no_license
madhuselvarajj/IoT-Stack-Overflow
3a2fca97b76992122e18280df6e440ab7eef818b
ee72ba9d95e035554453c2dd78e9ea7e8ad131f2
refs/heads/main
2023-05-06T04:03:34.047992
2021-05-25T19:22:58
2021-05-25T19:22:58
363,993,350
0
0
null
2021-05-05T04:12:30
2021-05-03T16:31:54
null
UTF-8
C++
false
false
253
cpp
#include <stdio.h> static int bar = 0; int __real_main(int argc, char **argv); int __wrap_main(int argc, char **argv) { bar = 1; return __real_main(argc, argv); } int main(int argc, char **argv) { printf("bar %d\n",bar); return 0; }
[ "madhuselvaraj24@gmail.com" ]
madhuselvaraj24@gmail.com
2d0f2d5070af9b03152d4e023b40a17b3b31037c
b2a53d6df93fa501eb026d9593aacafd12f55bed
/09.FixedFunctionPipeline/44. Solar system moon/Solar system with moon.cpp
ff9cd68b1dc8893a90e1578633cd4b1f81a897a9
[]
no_license
Aniket2926/RTR2020
61af678bc8fe98af0d3cf7c93e8b11c61492fdea
5439b866435fd57bbf053a71bc95862228ce3c23
refs/heads/master
2023-07-06T11:45:04.367852
2021-08-08T10:26:57
2021-08-08T10:26:57
264,096,556
0
0
null
null
null
null
UTF-8
C++
false
false
9,850
cpp
// Headers #include<windows.h> #include<stdio.h> #include<gl/gl.h> #include<gl/glu.h> // 1st change in prespective #pragma comment(lib,"opengl32.lib") #pragma comment(lib,"glu32.lib") // 2nd change in prespective // macros #define MY_ICON 2926 #define WIN_WIDTH 800 #define WIN_HEIGHT 600 // global function declartions LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); FILE* gpfile = NULL; //global variable for fullScreen DWORD dwStyle; // interally long ahe WINDOWPLACEMENT wpPrev = { sizeof(WINDOWPLACEMENT) }; // initialization(inline) bool gbFullScreen = false; // our variable g is for global, by default ti adhi fullscreen nahi bool gbActiveWindow = false; HWND ghwnd = NULL; HDC ghdc = NULL; HGLRC ghrc; // Solar variable int day = 0; int year = 0; int moon = 0; //data struture GLUquadric* quadric = NULL; //WinMain() int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int iCmdShow) { //function void initialize(void); void display(void); //local variable declarations WNDCLASSEX wndclass; HWND hwnd; MSG msg; TCHAR szAppName[] = TEXT("My Window2926"); bool BDone = false; // file IO if (fopen_s(&gpfile, "coder.txt", "w") != 0) { MessageBox(NULL, TEXT("can not create desired file"), TEXT("error"), MB_OK); exit(0); } //code //initialization of WNDCLASSEX wndclass.cbSize = sizeof(WNDCLASSEX); wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.lpfnWndProc = WndProc; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(MY_ICON)); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wndclass.lpszClassName = szAppName; wndclass.lpszMenuName = NULL; wndclass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(MY_ICON)); // register above class RegisterClassEx(&wndclass); //centering window int x = GetSystemMetrics(SM_CXSCREEN); int y = GetSystemMetrics(SM_CYSCREEN); // create window hwnd = CreateWindowEx(WS_EX_APPWINDOW, szAppName, TEXT("My Window2926"), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, (x / 2) - (800 / 2), (y / 2) - (600 / 2), WIN_WIDTH, WIN_HEIGHT, NULL, NULL, hInstance, NULL); ghwnd = hwnd; // for fullscreen(its not null now) initialize(); ShowWindow(hwnd, iCmdShow); SetForegroundWindow(hwnd); SetFocus(hwnd); // messgae loop while (BDone == false) // game loop { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) BDone = true; else { TranslateMessage(&msg); DispatchMessage(&msg); } } else { if (gbActiveWindow == true) { //call updatefuntion //call dispaly funtion display(); } } } return((int)msg.wParam); } LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { //function declare void ToggleFullScreen(void); void Resize(int, int); void Uninitialize(void); switch (iMsg) { case WM_SETFOCUS: gbActiveWindow = true; break; case WM_KILLFOCUS: gbActiveWindow = false; break; case WM_ERASEBKGND: return(0); case WM_SIZE: Resize(LOWORD(lParam), HIWORD(lParam)); break; case WM_KEYDOWN: switch (wParam) { case VK_ESCAPE: DestroyWindow(hwnd); break; case 0x46: //x for hexa case 0x66: //f=66,F=46 ToggleFullScreen(); // calling Func. break; default: break; } break; // for solar case WM_CHAR: switch (wParam) { // rotation case 'D': day = (day + 6) % 360; // reminder sathi % break; case 'd': day = (day - 6) % 360; break; //revolution case 'Y': year = (year + 3) % 360; break; case'y': year = (year - 3) % 360; break; case 'M': moon = (moon + 6) % 360; break; case 'm': moon = (moon - 6) % 360; break; } case WM_CREATE: fprintf(gpfile, "India is my country.\n"); break; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: fprintf(gpfile, "Jay Hind\n"); Uninitialize(); PostQuitMessage(0); break; } return(DefWindowProc(hwnd, iMsg, wParam, lParam)); } // Function Declartion void ToggleFullScreen(void) { //local Variable declartion MONITORINFO mi = { sizeof(MONITORINFO) }; //code if (gbFullScreen == false) { dwStyle = GetWindowLong(ghwnd, GWL_STYLE); //getwindowlong:get style,get from OS if (dwStyle & WS_OVERLAPPEDWINDOW) { if (GetWindowPlacement(ghwnd, &wpPrev) && GetMonitorInfo(MonitorFromWindow(ghwnd, MONITORINFOF_PRIMARY), &mi))// calling internally { SetWindowLong(ghwnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW); //call SetWindowPos(ghwnd, HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top, SWP_NOZORDER | SWP_FRAMECHANGED); //call } } ShowCursor(FALSE);//SDK wala false gbFullScreen = true; } else { SetWindowLong(ghwnd, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW); SetWindowPlacement(ghwnd, &wpPrev); SetWindowPos(ghwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_FRAMECHANGED); ShowCursor(TRUE); gbFullScreen = FALSE; } } void initialize(void) { //function declare void Resize(int, int); // variable declaration PIXELFORMATDESCRIPTOR pfd; INT iPixelFormatIndex; //code ghdc = GetDC(ghwnd); ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR)); pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 32; pfd.cRedBits = 8; pfd.cGreenBits = 8; pfd.cBlueBits = 8; pfd.cAlphaBits = 8; iPixelFormatIndex = ChoosePixelFormat(ghdc, &pfd); if (iPixelFormatIndex == 0) { fprintf(gpfile, "Choose Pixcel Format Funtion failed\n"); DestroyWindow(ghwnd); } if (SetPixelFormat(ghdc, iPixelFormatIndex, &pfd) == FALSE) { fprintf(gpfile, "Set Pixcel Format Fail\n"); DestroyWindow(ghwnd); } ghrc = wglCreateContext(ghdc); if (ghrc == NULL) { fprintf(gpfile, "Create context Fail\n"); DestroyWindow(ghwnd); } if (wglMakeCurrent(ghdc, ghrc) == FALSE) { fprintf(gpfile, "Make Current Fail\n"); DestroyWindow(ghwnd); } //Set clear color (1st opengl function) glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // background change Resize(WIN_WIDTH, WIN_HEIGHT); //warm up resize call } void Resize(int width, int height) { //code if (height == 0) height = 1; glViewport(0, 0, (GLsizei)width, (GLsizei)height); //second opengl call glMatrixMode(GL_PROJECTION); //ortho prespective change 3rd change glLoadIdentity(); gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 100.0f); // width and height ratio } void display(void) { //code glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //third call glMatrixMode(GL_MODELVIEW); //ortho prespective change 3rd change glLoadIdentity(); //***** solar code********* gluLookAt(0.0f, 0.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); // push is used for save and i have to come back to matrix so i saved it so push matrix and lookAt matrix is saved glPushMatrix(); // ** Beautification lines glRotatef(90.0f, 1.0f, 0.0f, 0.0f); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); //.....1para front and back pahijhe..kasa pahijhe solid or line so we choose lines glColor3f(1.0f, 1.0f, 0.0f); //*** Creating Sun *** //**new ahe toh memory to new quadric object ..internally its a malloc memory..here memory allocate keli jate and uninitialize madhe free quadric = gluNewQuadric(); // function //**1st para...quadric pointer hya sphere banav... 2 para radius ...3 slices=longitude...4 para stack = latitude //**more stack and slices more the more it get realizm but performance get low so get the middle figure to balance gluSphere(quadric, 0.75, 30, 30); //beautification ADJUSTING pole glPopMatrix(); glPushMatrix(); //**int converted into float year int hota so ani angle float madhe asto so //** year degree ne rotate hoo and translate kela ...adhi rotate kela ani mag tyach rotated avastet translate kela (red book) // rotate karun translate karna revolution // translate karun rotate karna rotation glRotatef((GLfloat)year, 0.0f, 1.0f, 0.0f); glTranslatef(1.0f, 0.0f, 0.0f); //adjust the north and south pole line ... // Transformation navin ala nantr push yeila pahijhe glRotatef(90.0f, 1.0f, 0.0f, 0.0f); glRotatef((GLfloat)day, 0.0f, 0.0f, 1.0f); // CHANGED AXIS //** Beautification glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glColor3f(0.4f, 0.9f, 1.0f); //***** Creating Earth **** quadric = gluNewQuadric(); // function gluSphere(quadric, 0.2, 30, 30); // **** creating moon **** glPushMatrix(); glTranslatef(1.0f, 0.0f, 0.0f); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glColor3f(1.0f, 1.0f, 1.0f); quadric = gluNewQuadric(); gluSphere(quadric, 0.10f, 10, 10); glPopMatrix(); glPopMatrix(); SwapBuffers(ghdc);//for double buffer } void Uninitialize(void) { //code if (gbFullScreen == true) { dwStyle = GetWindowLong(ghwnd, GWL_STYLE); //getwindowlong:get style,get from OS SetWindowLong(ghwnd, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW); SetWindowPlacement(ghwnd, &wpPrev); SetWindowPos(ghwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_FRAMECHANGED); ShowCursor(TRUE); } if (wglGetCurrentContext() == ghrc) { wglMakeCurrent(NULL, NULL); } if (ghrc) { wglDeleteContext(ghrc); ghrc = NULL; } if (ghdc) { ReleaseDC(ghwnd, ghdc); ghdc = NULL; } if (gpfile) { fclose(gpfile); gpfile = NULL; } // Solar gluDeleteQuadric(quadric); }
[ "aniketkadam2926@gmail.com" ]
aniketkadam2926@gmail.com
a06559c91698180c7a0b7bf0d6329979108333cd
27c1031607e501faf1c95ec69afccf9281660346
/Pass_Manager/EntryList.cpp
5e50cc365d143e2574aacf7917d6793ecd46ed71
[]
no_license
Nachiket27p/PassManager
357192e9e4c48c24e742611f6395390499b4228f
83ce34c174a27827541633c17b227e0e9e49a435
refs/heads/master
2020-09-21T03:23:47.093698
2019-12-10T09:11:54
2019-12-10T09:11:54
224,664,512
0
0
null
null
null
null
UTF-8
C++
false
false
1,696
cpp
#pragma once #include "Entry.cpp" #include <cliext/map> ref class EntryList { private: cliext::map<String^, Entry^> list; public: bool hasEntry(String^ name) { if (list.find(name) == list.end()) { return false; } else { return true; } } Entry^ getEntry(String^ name) { if (list.find(name) != list.end()) { return list[name]; } else { return nullptr; } } int size() { return list.size(); } bool deleteEntry(String^ name) { return list.erase(name); } bool modifyEntry(String^ plainName, String^ name, String^ userName, String^ password, String^ notes) { cliext::map<String^, Entry^>::iterator i = list.find(plainName); if (i == list.end()) { return false; } else { list[plainName]->setUserName(userName); list[plainName]->setPassword(password); list[plainName]->setNotes(notes); return true; } } bool addEntry(String^ plainName, String^ name, String^ userName, String^ password, String^ notes) { if (list.find(plainName) == list.end()) { Entry^ n = gcnew Entry(name, userName, password, notes); list.insert(cliext::map<String^, Entry^>::make_value(plainName, n)); return true; } else { return false; } } array<String^>^ getEntryNames() { int siz = list.size(); array<String^>^ n = gcnew array<String^>(siz); int idx = 0; for each (cliext::map<String^, Entry^>::value_type elem in list) { n[idx++] = elem->first; } return n; } array<String^>^ getAllEntries() { int siz = list.size(); array<String^>^ n = gcnew array<String^>(siz); int idx = 0; for each (cliext::map<String^, Entry^>::value_type elem in list) { n[idx++] = elem->second->toString(); } return n; } };
[ "nachiket27p@gmail.com" ]
nachiket27p@gmail.com
2a355166b730fd18bb6ab0ee3871f0fbf01b8b75
83f7cbd1728e1756ce26f249f23e562143de6b5c
/Vs1/InterPath.Vs2.download2.cpp
b5df21d6a186dc907d0d8e88b5f233c179d2209a
[]
no_license
mturchin20/InterPath
765135535783c63122ba5d006ba671ac1cb4448f
4b07e1377aa6bfd14cda7ed5e1ffb02ce52bd494
refs/heads/master
2021-09-08T23:55:41.264911
2021-09-06T23:28:53
2021-09-06T23:28:53
136,239,536
0
0
null
null
null
null
UTF-8
C++
false
false
4,484
cpp
// load Rcpp #define ARMA_64BIT_WORD 1 #include <RcppArmadillo.h> #include <omp.h> using namespace Rcpp; using namespace arma; // [[Rcpp::depends(RcppArmadillo)]] // [[Rcpp::plugins(cpp11)]] // [[Rcpp::plugins(openmp)]] // [[Rcpp::export]] arma::mat GetLinearKernel(arma::mat X){ double p = X.n_rows; return X.t()*X/p; } // [[Rcpp::export]] arma::mat ComputePCs(arma::mat X,int top = 10){ mat U; vec s; mat V; svd(U,s,V,X); mat PCs = U*diagmat(s); return PCs.cols(0,top-1); } // [[Rcpp::export]] arma::mat droprows(arma::mat X, uvec j){ vec ind(X.n_rows); ind.ones(); ind.elem(j-1) = zeros(j.n_elem); return X.rows(arma::find(ind == 1)); } // [[Rcpp::export]] mat test(mat X, mat regions, int i){ uvec j = find_finite(regions.col(i)); return X.rows(j); } //////////////////////////////////////////////////////////////////////////// //Below is a function for InterPath looking for interaction effects for pathways //////////////////////////////////////////////////////////////////////////// // [[Rcpp::export]] List InterPath(mat X,vec y, mat regions,int cores = 1){ int i; const int n = X.n_cols; const int nsnp = X.n_rows; const int p = regions.n_cols; //Set up the vectors to save the outputs NumericVector sigma_est(p); NumericVector pve(p); mat Lambda(n,p); //Pre-compute the Linear GSM mat GSM = GetLinearKernel(X); omp_set_num_threads(cores); #pragma omp parallel for schedule(dynamic) for(i=0; i<p; i++){ //Pre-compute the Linear GSM uvec j = find_finite(regions.col(i)); //Compute K covariance matrices mat K = (GSM*nsnp-GetLinearKernel(X.rows(j))*j.n_elem)/(nsnp-j.n_elem-1); mat G = GetLinearKernel(X.rows(j))%K; //Transform K and G using projection M mat b = zeros(n,j.n_elem+1); b.col(0) = ones<vec>(n); b.cols(1,j.n_elem) = trans(X.rows(j)); mat btb_inv = inv(b.t()*b); mat Kc = K-b*btb_inv*(b.t()*K)-(K*b)*btb_inv*b.t()+b*btb_inv*(b.t()*(K*b))*btb_inv*b.t(); mat Gc = G-b*btb_inv*(b.t()*G)-(G*b)*btb_inv*b.t()+b*btb_inv*(b.t()*(G*b))*btb_inv*b.t(); vec yc = (eye<mat>(n,n)-(b*btb_inv)*b.t())*y; //Compute the quantities q and S vec q = zeros(3); //Create k-vector q to save mat S = zeros(3,3); //Create kxk-matrix S to save q(0) = as_scalar(yc.t()*Kc*yc); q(1) = as_scalar(yc.t()*Gc*yc); q(2) = as_scalar(yc.t()*(eye<mat>(n,n)-(b*btb_inv)*b.t())*yc); S(0,0) = as_scalar(accu(Kc%Kc)); S(0,1) = as_scalar(accu(Kc%Gc)); S(0,2) = as_scalar(accu(Kc%(eye<mat>(n,n)-(b*btb_inv)*b.t()))); S(1,0) = S(0,1); S(1,1) = as_scalar(accu(Gc%Gc)); S(1,2) = as_scalar(accu(Gc%(eye<mat>(n,n)-(b*btb_inv)*b.t()))); S(2,0) = S(0,2); S(2,1) = S(1,2); S(2,2) = as_scalar(accu((eye<mat>(n,n)-(b*btb_inv)*b.t())%(eye<mat>(n,n)-(b*btb_inv)*b.t()))); //Compute delta and Sinv mat Sinv = inv(S); vec delta = Sinv*q; //Record nu^2, and tau^2 under the null hypothesis vec q_sub = zeros(2); mat S_sub = zeros(2,2); q_sub(0)=q(0); q_sub(1)=q(2); S_sub(0,0)=S(0,0); S_sub(0,1)=S(0,2); S_sub(1,0)=S(2,0); S_sub(1,1)=S(2,2); //Compute P and P^{1/2} matrix vec delta_null = inv(S_sub)*q_sub; vec eigval; mat eigvec; eig_sym(eigval,eigvec,delta_null(0)*Kc+delta_null(1)*(eye<mat>(n,n)-(b*btb_inv)*b.t())); //Find the eigenvalues of the projection matrix vec evals; eig_sym(evals, (eigvec.cols(find(eigval>0))*diagmat(sqrt(eigval(find(eigval>0))))*trans(eigvec.cols(find(eigval>0))))*(Sinv(1,0)*Kc+Sinv(1,1)*Gc+Sinv(1,2)*(eye<mat>(n,n)-(b*btb_inv)*b.t()))*(eigvec.cols(find(eigval>0))*diagmat(sqrt(eigval(find(eigval>0))))*trans(eigvec.cols(find(eigval>0))))); Lambda.col(i) = evals; //Save point estimates and SE of the epistasis component sigma_est(i) = delta(1); //Compute the PVE pve(i) = delta(1)/accu(delta); } //Return a list of the arguments return Rcpp::List::create(Rcpp::Named("Est") = sigma_est, Rcpp::Named("Eigenvalues") = Lambda,Rcpp::Named("PVE") = pve); }
[ "mturchin20@gmail.com" ]
mturchin20@gmail.com
6931a7eb7e53fffca6828071149eb762cec63250
3cfecda337087261050c7f498534048837590455
/Header.h
626d5490f88772c50c30786aa7333e8756a343be
[]
no_license
sergeyturko/AIfil_git
f3ee0c4c777e51ae2195a729757aab00b72758e2
5cd45285e1e62866bf537f7709bb2e727206fc4b
refs/heads/master
2021-01-10T04:15:03.219046
2016-08-14T18:37:56
2016-08-14T18:37:56
53,070,843
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
1,253
h
#include "opencv2/opencv.hpp" #include <iostream> using namespace std; using namespace cv; #define THRESHOLD_BRIGHTNESS 90.0 // порог яркости. На кадрах сшивки не должна быть мала т.к. кадры сшивки серые или светлее #define THRESHOLD_VARIANCE 500.0 // дисперсия. Разброс значений на кадрах сшивки должен быть достаточно мал #define THRESHOLD_ENERGY 0.02 // енергия на кадрах сшивки будет максимальна, но на темных кадрах тоже #define THRESHOLD_GAP_FRAME 8 // расстояние между "подходящими" кадрами #define THRESHOLD_FRAME_SEQUENCE 8 // длина последовательности кадров, которые можно считать местом сшивки #define MIN_LENGTH_SEQUENCE_FRAME 25 // минимальная длина места сшивки #define PERCENT_EDGE 0.07 // доля удаляемая с краев изображения (т.к. они черные и никакой информации не несут) bool HistEvidenceAnaliz(const Mat*, const int, const long int, vector<int>*, int&);
[ "t1s2a3@mail.ru" ]
t1s2a3@mail.ru
36a2a88e27f456291fd78c662e8ce777052c9436
d0fb46aecc3b69983e7f6244331a81dff42d9595
/adb/src/model/ModifyDBClusterMaintainTimeRequest.cc
6848a0dd9d096b63abd49a41146c7363079adf8b
[ "Apache-2.0" ]
permissive
aliyun/aliyun-openapi-cpp-sdk
3d8d051d44ad00753a429817dd03957614c0c66a
e862bd03c844bcb7ccaa90571bceaa2802c7f135
refs/heads/master
2023-08-29T11:54:00.525102
2023-08-29T03:32:48
2023-08-29T03:32:48
115,379,460
104
82
NOASSERTION
2023-09-14T06:13:33
2017-12-26T02:53:27
C++
UTF-8
C++
false
false
3,145
cc
/* * Copyright 2009-2017 Alibaba Cloud 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. */ #include <alibabacloud/adb/model/ModifyDBClusterMaintainTimeRequest.h> using AlibabaCloud::Adb::Model::ModifyDBClusterMaintainTimeRequest; ModifyDBClusterMaintainTimeRequest::ModifyDBClusterMaintainTimeRequest() : RpcServiceRequest("adb", "2019-03-15", "ModifyDBClusterMaintainTime") { setMethod(HttpRequest::Method::Post); } ModifyDBClusterMaintainTimeRequest::~ModifyDBClusterMaintainTimeRequest() {} long ModifyDBClusterMaintainTimeRequest::getResourceOwnerId() const { return resourceOwnerId_; } void ModifyDBClusterMaintainTimeRequest::setResourceOwnerId(long resourceOwnerId) { resourceOwnerId_ = resourceOwnerId; setParameter(std::string("ResourceOwnerId"), std::to_string(resourceOwnerId)); } std::string ModifyDBClusterMaintainTimeRequest::getAccessKeyId() const { return accessKeyId_; } void ModifyDBClusterMaintainTimeRequest::setAccessKeyId(const std::string &accessKeyId) { accessKeyId_ = accessKeyId; setParameter(std::string("AccessKeyId"), accessKeyId); } std::string ModifyDBClusterMaintainTimeRequest::getMaintainTime() const { return maintainTime_; } void ModifyDBClusterMaintainTimeRequest::setMaintainTime(const std::string &maintainTime) { maintainTime_ = maintainTime; setParameter(std::string("MaintainTime"), maintainTime); } std::string ModifyDBClusterMaintainTimeRequest::getResourceOwnerAccount() const { return resourceOwnerAccount_; } void ModifyDBClusterMaintainTimeRequest::setResourceOwnerAccount(const std::string &resourceOwnerAccount) { resourceOwnerAccount_ = resourceOwnerAccount; setParameter(std::string("ResourceOwnerAccount"), resourceOwnerAccount); } std::string ModifyDBClusterMaintainTimeRequest::getDBClusterId() const { return dBClusterId_; } void ModifyDBClusterMaintainTimeRequest::setDBClusterId(const std::string &dBClusterId) { dBClusterId_ = dBClusterId; setParameter(std::string("DBClusterId"), dBClusterId); } std::string ModifyDBClusterMaintainTimeRequest::getOwnerAccount() const { return ownerAccount_; } void ModifyDBClusterMaintainTimeRequest::setOwnerAccount(const std::string &ownerAccount) { ownerAccount_ = ownerAccount; setParameter(std::string("OwnerAccount"), ownerAccount); } long ModifyDBClusterMaintainTimeRequest::getOwnerId() const { return ownerId_; } void ModifyDBClusterMaintainTimeRequest::setOwnerId(long ownerId) { ownerId_ = ownerId; setParameter(std::string("OwnerId"), std::to_string(ownerId)); }
[ "sdk-team@alibabacloud.com" ]
sdk-team@alibabacloud.com
397e735aec910807467fc1d6ebcc05aa794aa7a3
eef1252a691768a250b6ef8e9f052f7d6308b405
/making_programm.ino
60d04546f4f394ffc79268c0fcd010670b1447ad
[]
no_license
consilience90/aruduino_device
e0a47849d3f31f8a0eda4d818dd07de553598988
f411bc794d52a56ed74aab1aed2215d2c4c170e3
refs/heads/master
2021-05-15T14:55:00.009029
2017-10-18T02:17:09
2017-10-18T02:17:09
107,347,935
0
0
null
null
null
null
UTF-8
C++
false
false
4,648
ino
#include <SoftwareSerial.h> #include <TinyGPS.h> SoftwareSerial BTSerial(2, 3); SoftwareSerial GPSSerial(7, 8); // 시리얼을 두개 이상 사용할 때 http://m.blog.naver.com/roboholic84/220550737629 TinyGPS gps; static void smartdelay(unsigned long ms); static void print_float(float val, float invalid, int len, int prec); static void print_int(unsigned long val, unsigned long invalid, int len); static void print_date(TinyGPS &gps); static void print_str(const char *str, int len); static String makeHex(long value); void setup() { Serial.begin(9600); BTSerial.begin(9600); GPSSerial.begin(9600); delay(1000); BTSerial.listen(); BTSerial.write("AT+DELO2"); BTSerial.flush(); delay(1000); BTSerial.write("AT+IBEA1"); BTSerial.flush(); delay(1000); BTSerial.write("AT+POWE3"); BTSerial.flush(); delay(1000); BTSerial.write("AT+PWRM1"); BTSerial.flush(); delay(1000); BTSerial.write("AT+ROLE0"); BTSerial.flush(); delay(1000); BTSerial.write("AT+ADTY3"); BTSerial.flush(); delay(1000); BTSerial.write("AT+ADVI0"); BTSerial.flush(); delay(1000); BTSerial.write("AT+ROLE0"); BTSerial.flush(); delay(1000); } void loop() { Serial.println(); Serial.println("---------------------------------------"); GPSSerial.listen(); smartdelay(1000); float flat, flon; unsigned long age; gps.f_get_position(&flat, &flon, &age); Serial.print(flat,10); // 6자리로 이상의 소수점 단위는 가만히 있어도 오차가 발생하는 정도. 완전 정확할 수 없다. // flat 값을 소수점 이하 6자리까지만 저장해서 // 16진수로 변환해야 함. Serial.println(); Serial.println(TinyGPS::GPS_INVALID_F_ANGLE); Serial.println(); Serial.println("위도"); print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 10, 6); Serial.println(); Serial.println("경도"); print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 11, 6); Serial.println(); Serial.println("고도"); print_int(age, TinyGPS::GPS_INVALID_AGE, 5); long tempFlat = flat*1000000; long tempFlon = flon*1000000; //Serial.println(tempFlat); String flatHex = makeHex(tempFlat); String flonHex = makeHex(tempFlon); //Serial.println(flatHex); String comFlat = String("AT+IBE0" + flatHex); String comFlon = String("AT+IBE1" + flonHex); Serial.println(comFlat); Serial.println(comFlon); byte flatBuff[16]; byte flonBuff[16]; comFlat.getBytes(flatBuff,16); comFlon.getBytes(flonBuff,16); BTSerial.listen(); BTSerial.flush(); BTSerial.write(flatBuff,15); BTSerial.flush(); delay(1000); BTSerial.write(flonBuff,15); delay(3000); if(BTSerial.available()){ Serial.write(BTSerial.read()); } if(Serial.available()){ BTSerial.write(Serial.read()); } Serial.println(); } ///////////////////--------------------------- 함수 ------------------------------///////////////////////////// static void smartdelay(unsigned long ms) { unsigned long start = millis(); do { while (GPSSerial.available()) gps.encode(GPSSerial.read()); } while (millis() - start < ms); } static void print_float(float val, float invalid, int len, int prec) { if (val == invalid) { while (len-- > 1) Serial.print('*'); Serial.print(' '); } else { Serial.print(val, prec); int vi = abs((int)val); int flen = prec + (val < 0.0 ? 2 : 1); // . and - flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1; for (int i=flen; i<len; ++i) Serial.print(' '); } smartdelay(0); } static void print_int(unsigned long val, unsigned long invalid, int len) { char sz[32]; if (val == invalid) strcpy(sz, "*******"); else sprintf(sz, "%ld", val); sz[len] = 0; for (int i=strlen(sz); i<len; ++i) sz[i] = ' '; if (len > 0) sz[len-1] = ' '; Serial.print(sz); smartdelay(0); } static void print_str(const char *str, int len) { int slen = strlen(str); for (int i=0; i<len; ++i) Serial.print(i<slen ? str[i] : ' '); smartdelay(0); } static String makeHex(long value){ String hexValue = String(value, HEX); hexValue.toUpperCase(); int lengthHex = hexValue.length(); switch(lengthHex){ case 7: hexValue = String("0"+hexValue); break; case 6: hexValue = String("00"+hexValue); break; case 5: hexValue = String("000"+hexValue); break; case 4: hexValue = String("0000"+hexValue); break; case 3: hexValue = String("00000"+hexValue); break; case 2: hexValue = String("000000"+hexValue); break; case 1: hexValue = String("0000000"+hexValue); break; } return hexValue; }
[ "consillience@hanmail.net" ]
consillience@hanmail.net
f1df1509c9a97ec81a242a8bc838012cf2dcaefc
e5eeb435acdfa1dc708994808821e37c1340c2d2
/quickfast/Communication/FileSender_fwd.h
3582d77b996a36aa48bd83496f440efe5f0f976e
[]
no_license
skiof007/MarketData.Quickfast
73ee4537ca6e9cc83b5c09b753cec205469294e9
dce80ee47d79b32c4a34d82ce9ec806c6b4d2319
refs/heads/master
2020-03-23T04:18:20.272851
2018-03-15T16:05:39
2018-04-13T15:53:31
141,075,319
1
0
null
2018-07-16T02:11:53
2018-07-16T02:11:53
null
UTF-8
C++
false
false
285
h
// Copyright (c) 2009, Object Computing, Inc. // All rights reserved. // See the file license.txt for licensing information. // #ifndef FILESENDER_FWD_H #define FILESENDER_FWD_H namespace QuickFAST { namespace Communication { class FileSender; } } #endif // FILESENDER_FWD_H
[ "tarcisio.genaro@gmail.com" ]
tarcisio.genaro@gmail.com
ba9d282b28abd8d3598a9ea7dcea94ca330eca83
adfc2e5cc8c77574bf911dbe899dca63ac7d8564
/TopoBlenderLib/DynamicGraph.cpp
d90b8247cb963c317dd0d482da9dac1ad2b002b7
[]
no_license
ialhashim/topo-blend
818279ffd0c3c25a68d33cc2b97d007e1bdc7ed6
39b13612ebd645a65eda854771b517371f2f858a
refs/heads/master
2020-12-25T19:03:40.666581
2015-03-13T18:17:18
2015-03-13T18:17:18
32,125,014
25
2
null
null
null
null
UTF-8
C++
false
false
16,320
cpp
#include "DynamicGraph.h" using namespace DynamicGraphs; DynamicGraph::DynamicGraph(Structure::Graph *fromGraph) { this->mGraph = fromGraph; this->uniqueID = 0; this->uniqueEdgeID = 0; if(mGraph == NULL) return; // Add nodes foreach(Structure::Node * n, mGraph->nodes) addNode( SingleProperty("original", n->id) ); // Add edges foreach(Structure::Link * e, mGraph->edges) addEdge( nodeIndex("original", e->n1->id), nodeIndex("original", e->n2->id) ); } DynamicGraph DynamicGraph::clone() { DynamicGraph g; g.mGraph = this->mGraph; g.nodes = this->nodes; g.edges = this->edges; g.adjacency = this->adjacency; g.uniqueID = this->uniqueID; g.uniqueEdgeID = this->uniqueEdgeID; return g; } int DynamicGraph::addNode(Properties properties, int index) { if(index < 0) index = nodes.size(); nodes[index] = SimpleNode(index); nodes[index].property = properties; // Always increasing global identifier uniqueID++; return index; } int DynamicGraph::addEdge(int fromNode, int toNode) { //if(fromNode == toNode) assert(0); SimpleEdge e(fromNode, toNode); int edgeIndex = uniqueEdgeID; edges[edgeIndex] = e; uniqueEdgeID++; adjacency[fromNode].insert(e); adjacency[toNode].insert(e); return edgeIndex; } int DynamicGraph::nodeIndex( QString property_name, QVariant property_value ) { foreach(SimpleNode n, nodes) { if(n.property.contains(property_name) && n.property[property_name] == property_value) return n.idx; } assert(0); return -1; } std::vector<int> DynamicGraph::nodesWith( QString property_name, QVariant property_value ) { std::vector<int> result; foreach(SimpleNode n, nodes) { if(n.property.contains(property_name) && n.property[property_name] == property_value) result.push_back(n.idx); } return result; } QString DynamicGraph::nodeType( int index ) { return mGraph->getNode(nodes[index].str("original"))->type(); } void DynamicGraph::removeNode( int idx ) { // Remove edges foreach(int adj, adjNodes(idx)) removeEdge(idx, adj); // Remove node and adjacency list nodes.remove(idx); adjacency.remove(idx); } void DynamicGraph::removeEdge(int fromNode, int toNode) { if(fromNode == toNode) assert(0); SimpleEdge e(fromNode, toNode); QMapIterator<int, SimpleEdge> i(edges); while (i.hasNext()) { i.next(); if(i.value() == e){ edges.remove(i.key()); break; } } adjacency[fromNode].remove(e); adjacency[toNode].remove(e); } QSet<int> DynamicGraph::adjNodes(int index) { QSet<int> adj; foreach(SimpleEdge e, adjacency[index]) adj.insert( e.n[0] == index ? e.n[1] : e.n[0] ); return adj; } GraphState DynamicGraph::State() { GraphState state; state.numSheets = numSheets(); state.numCurves = numCurves(); state.numSheetEdges = numEdges(SAME_SHEET); state.numCurveEdges = numEdges(SAME_CURVE); state.numMixedEdges = numEdges(CURVE_SHEET); return state; } void DynamicGraph::printState() { GraphState state = this->State(); state.print(); } int DynamicGraph::numEdges( EdgeType t ) { int count = 0; foreach(SimpleEdge e, edges){ switch(t) { case ANY_EDGE : count++; break; case CURVE_SHEET:if(nodeType(e.n[0]) != nodeType(e.n[1])) count++; break; case SAME_CURVE :if(nodeType(e.n[0]) == Structure::CURVE && nodeType(e.n[0]) == nodeType(e.n[1])) count++; break; case SAME_SHEET :if(nodeType(e.n[0]) == Structure::SHEET && nodeType(e.n[0]) == nodeType(e.n[1])) count++; break; } } return count; } QVector<int> DynamicGraph::getSheets() { QVector<int> sheets; foreach(SimpleNode n, nodes) if(nodeType(n.idx) == Structure::SHEET) sheets.push_back(n.idx); return sheets; } int DynamicGraph::numSheets() { return getSheets().size(); } QVector<int> DynamicGraph::getCurves() { QVector<int> curves; foreach(SimpleNode n, nodes) if(nodeType(n.idx) == Structure::CURVE) curves.push_back(n.idx); return curves; } int DynamicGraph::numCurves() { return getCurves().size(); } int DynamicGraph::cloneNode( int index, bool cloneEdges ) { int newIndex = addNode( nodes[index].property, uniqueID ); if(cloneEdges){ QSet<int> adj = adjNodes( index ); foreach(int ni, adj) addEdge(newIndex, ni); } return newIndex; } void DynamicGraph::printNodeInfo( int index ) { qDebug() << "\nNode:"; qDebug() << " idx : " << nodes[index].idx; qDebug() << " type : " << nodeType(index); // Adjacent info QStringList adjList; foreach(int ni, adjNodes(index)) adjList << QString::number(ni); qDebug() << " adj : " << adjList.join(", "); } GraphState DynamicGraph::difference( GraphState & other ) { GraphState diff; GraphState my = State(); diff.numSheets = my.numSheets - other.numSheets; diff.numCurves = my.numCurves - other.numCurves; diff.numSheetEdges = my.numSheetEdges - other.numSheetEdges; diff.numCurveEdges = my.numCurveEdges - other.numCurveEdges; diff.numMixedEdges = my.numMixedEdges - other.numMixedEdges; return diff; } Structure::Graph * DynamicGraph::toStructureGraph() { Structure::Graph * graph = new Structure::Graph(); QMap<int,QString> nodeMap; QMap<int,QString> originalNodeIds; // Add nodes foreach(SimpleNode n, nodes) { QString nodeId = n.str("original"); QString newId = nodeId + QString("_%1").arg(n.idx); if(nodeType(n.idx) == Structure::SHEET) { Structure::Sheet * s = (Structure::Sheet *) mGraph->getNode(nodeId); graph->addNode( new Structure::Sheet(s->surface, newId) ); } if(nodeType(n.idx) == Structure::CURVE) { Structure::Curve * s = (Structure::Curve *) mGraph->getNode(nodeId); graph->addNode( new Structure::Curve(s->curve, newId) ); } nodeMap[n.idx] = newId; originalNodeIds[n.idx] = nodeId; } // Add edges QMapIterator<int, SimpleEdge> i(edges); while (i.hasNext()){ i.next(); int edgeIndex = i.key(); SimpleEdge e = i.value(); QString id1 = nodeMap[e.n[0]]; QString id2 = nodeMap[e.n[1]]; QString orig_id1 = originalNodeIds[e.n[0]]; QString orig_id2 = originalNodeIds[e.n[1]]; Structure::Node *n1 = graph->getNode(id1), *n2 = graph->getNode(id2); graph->addEdge( n1, n2, Array1D_Vector4d(1, Vector4d(0,0,0,0)), Array1D_Vector4d(1, Vector4d(0,0,0,0)), graph->linkName(n1, n2) ); // Copy edge coordinates Structure::Link *toEdge = graph->getEdge(id1, id2); Structure::Link *fromEdge; if(fromEdge = mGraph->getEdge(orig_id1,orig_id2)) { toEdge->setCoord(id1, fromEdge->getCoord(id1)); toEdge->setCoord(id2, fromEdge->getCoord(id2)); } // Assign coordinates to special edges if( specialCoords.contains(edgeIndex) ) { // Deal with special coordinates toEdge->setCoord(id1, specialCoords[edgeIndex][e.n[0]]); toEdge->setCoord(id2, specialCoords[edgeIndex][e.n[1]]); toEdge->property["special"] = true; } // Track movable nodes if( movable.contains(edgeIndex) ) { QString movableNode = nodeMap[movable[edgeIndex]]; toEdge->property["movable"] = movableNode; } if( growingCurves.contains(edgeIndex) ) { toEdge->property["growing"] = nodeMap[growingCurves[edgeIndex].first]; toEdge->property["growAnchor"] = growingCurves[edgeIndex].second.first; toEdge->property["growFactor"] = growingCurves[edgeIndex].second.second; } if( growingSheets.contains(edgeIndex) ) { QString growingNodeID = nodeMap[growingSheets[edgeIndex].first]; toEdge->property["growing"] = growingNodeID; QVariant val; val.setValue(growingSheets[edgeIndex].second); toEdge->property["deltas"] = val; QVariant cpts; cpts.setValue(((Structure::Sheet*)toEdge->getNode(growingNodeID))->surface.mCtrlPoint); toEdge->property["cpts"] = cpts; } } return graph; } QVector<DynamicGraph> DynamicGraph::candidateNodes(DynamicGraph & targetGraph) { QVector<DynamicGraph> candidate; GraphState futureState = targetGraph.State(); // Compute graph difference GraphState diff = difference( futureState ); // Should return no candidates when they are exactly the same if( diff.isZero() ) return candidate; QVector<int> activeNodes; bool isAdding = true; int discrepancy = 0; // Missing nodes: nodes have precedent if(diff.numSheets != 0 || diff.numCurves != 0) { // Sheets and curves: sheet have precedent if(diff.numSheets != 0) { activeNodes = getSheets(); if(diff.numSheets > 0) isAdding = false; discrepancy = abs(diff.numSheets); } else if(diff.numCurves != 0) { activeNodes = getCurves(); if(diff.numCurves > 0) isAdding = false; discrepancy = abs(diff.numCurves); } } if(activeNodes.size() < 1) return candidate; // Try all sets of new edges of size std::vector<int> nodesSet = activeNodes.toStdVector(); std::vector<int>::iterator begin = nodesSet.begin(), end = nodesSet.end(); do { std::vector<int> currentSet (begin, begin + discrepancy); // Add operation as a candidate graph DynamicGraph g = clone(); foreach(int ci, currentSet) { if(isAdding) g.cloneNode(ci); else g.removeNode(ci); } candidate.push_back(g); } while (next_combination(begin, begin + discrepancy, end)); return candidate; } QVector<DynamicGraph> DynamicGraph::candidateEdges(DynamicGraph & targetGraph) { QVector<DynamicGraph> candidate; GraphState futureState = targetGraph.State(); // Compute graph difference GraphState diff = difference( futureState ); // Should return no candidates when they are exactly the same if( diff.isZero() ) return candidate; QVector<int> groupA, groupB; QSet<SimpleEdge> exploredEdges; bool isAdding = true; int discrepancy = 0; // Add existing edges as explored foreach(SimpleEdge e, edges) exploredEdges.insert(e); if(diff.numMixedEdges != 0) { // Curve-Sheet edges if(diff.numMixedEdges > 0) isAdding = false; groupA = getSheets(); groupB = getCurves(); discrepancy = abs(diff.numMixedEdges); } else if(diff.numSheetEdges != 0) { // Sheet-Sheet edges if(diff.numSheetEdges > 0) isAdding = false; groupA = getSheets(); groupB = groupA; discrepancy = abs(diff.numSheetEdges); } else if(diff.numCurveEdges != 0) { // Curve-Curve edges if(diff.numCurveEdges > 0) isAdding = false; groupA = getCurves(); groupB = groupA; discrepancy = abs(diff.numCurveEdges); } // Find all possible new edges QMap<int, SimpleEdge> uniqueEdges; foreach(int a, groupA) { foreach(int b, groupB) { SimpleEdge e(a, b); // Uniqueness check: if(a == b || exploredEdges.contains(e)) continue; exploredEdges.insert(e); uniqueEdges[uniqueEdges.size()] = e; } } // Try all sets of new edges of size std::vector<int> uniqueEdgesIdx; foreach(int key, uniqueEdges.keys()) uniqueEdgesIdx.push_back(key); std::vector<int>::iterator begin = uniqueEdgesIdx.begin(), end = uniqueEdgesIdx.end(); do { std::vector<int> currentSet (begin, begin + discrepancy); // Add operation as a candidate graph DynamicGraph g = clone(); foreach(int key, currentSet) { SimpleEdge e = uniqueEdges[key]; if(isAdding) g.addEdge(e.n[0], e.n[1]); else g.removeEdge(e.n[0], e.n[1]); } candidate.push_back(g); } while (next_combination(begin, begin + discrepancy, end)); return candidate; } int DynamicGraph::valence( int nodeIndex ) { return adjacency[nodeIndex].size(); } QVector< QPairInt > DynamicGraph::valences(bool isPrint) { std::vector<int> vals; std::vector<unsigned int> indx; foreach(int ni, nodes.keys()) { vals.push_back( adjacency[ni].size() ); indx.push_back( ni ); } // Sort by valence paired_sort(indx, vals, true); // DEBUG: if(isPrint){ QStringList vstr; foreach(int v, vals) vstr << QString::number(v); qDebug() << vstr; } QVector< QPairInt > valPair; for(int i = 0; i < (int) vals.size(); i++) valPair.push_back( qMakePair(vals[i], (int)indx[i]) ); return valPair; } bool DynamicGraph::sameValences( DynamicGraph & other ) { QVector< QPairInt > myValence = valences(); QVector< QPairInt > otherValence = other.valences(); for(int i = 0; i < (int) myValence.size(); i++){ if(otherValence[i].first != myValence[i].first) return false; } return true; } QVector< QPairInt > DynamicGraph::correspondence( DynamicGraph & other, double & score, bool isPrint ) { QVector< QPairInt > corr; QVector< QPairInt > vme = valences(); QVector< QPairInt > vother = other.valences(); // Build the set for the other graph QMap< int, QList<int> > vset; foreach(QPairInt p, vother) { vset[ p.first ].push_back( p.second ); } if(isPrint) qDebug() << "Correspondence map:"; // Test correspondence score and assign to smallest foreach(QPairInt p, vme) { int valence = p.first; int nodeID = p.second; QMap<double, int> scoreBoard; std::vector<Vector3> nf = noFrame(); QString n1_id = nodes[nodeID].str("original"); Structure::Node * n1 = this->mGraph->getNode( n1_id ); Vector3 center1(0,0,0); n1->get(Vector4d(0.5,0.5,0.5,0.5), center1, nf); // Test against possible corresponding nodes foreach( int curID, vset[ valence ] ) { QString n2_id = other.nodes[curID].str("original"); Structure::Node * n2 = other.mGraph->getNode( n2_id ); Vector3 center2(0,0,0); n2->get(Vector4d(0.5,0.5,0.5,0.5), center2, nf); double currScore = (center1 - center2).norm(); scoreBoard[ currScore ] = curID; } // Add minimum score to total double minScore = scoreBoard.keys().first(); score += minScore; int otherID = scoreBoard[ minScore ]; vset[ valence ].removeAll( otherID ); // Pair current node with minimum one corr.push_back( qMakePair(nodeID, otherID) ); if(isPrint) qDebug() << nodes[nodeID].str("original") << " <--> " << other.nodes[otherID].str("original"); } if(isPrint) qDebug() << "===\n"; return corr; } void DynamicGraph::flagNodes( QString propertyName, QVariant value ) { foreach(int i, nodes.keys()) nodes[i].property[propertyName] = value; } QVector<QVariant> DynamicGraph::flags( QString propertyName ) { QVector<QVariant> f; foreach(int i, nodes.keys()) f.push_back(nodes[i].property[propertyName]); return f; } SimpleNode * DynamicGraph::getNode( QString originalID ) { foreach(int i, nodes.keys()) if(nodes[i].str("original") == originalID) return &nodes[i]; return NULL; } QMap<int, SimpleEdge> DynamicGraph::getEdges( int nodeIDX ) { QMap<int, SimpleEdge> result; foreach(int i, edges.keys()){ if(edges[i].n[0] == nodeIDX || edges[i].n[1] == nodeIDX) result[i] = edges[i]; } return result; } Structure::Link * DynamicGraph::getOriginalLink( QString originalID1, QString originalID2 ) { QString n1_id = nodes[getNode(originalID1)->idx].str("original"); QString n2_id = nodes[getNode(originalID2)->idx].str("original"); return mGraph->getEdge(n1_id, n2_id); } bool DynamicGraph::hasEdge( int n1_index, int n2_index ) { return edges.values().contains(SimpleEdge(n1_index,n2_index)); } Array1D_Vector4d DynamicGraph::firstSpecialCoord( int node_index ) { typedef QMap< int, Array1D_Vector4d > NodeCoord; foreach(NodeCoord nodeCoord, specialCoords.values()) { if(nodeCoord.contains(node_index)) return nodeCoord[node_index]; } return Array1D_Vector4d(1, Vector4d(0,0,0,0)); } /* void DynamicGraph::correspondTo( DynamicGraph & other ) { double score = 0; QVector< QPairInt > corr = correspondence(other, score); foreach( QPairInt p, corr ) { int from = p.first; int to = p.second; if(from == to) continue; // Swap QString from_original = nodes[from].property["original"]; QString to_original = nodes[to].property["original"]; nodes[from].property["original"] = to_original; nodes[to].property["original"] = from_original; } }*/
[ "ennetws@1df9bfc3-c503-87f1-cf23-23127e9eb428" ]
ennetws@1df9bfc3-c503-87f1-cf23-23127e9eb428
29e2e4890fdf7e05a5dee2a0e0d2f1410db3db0f
31a5895b513c9aa3447c4fb4d4c0e9792e424b02
/hiir/test/ResultCheck.cpp
dbc130889fd1b465b8cae50451671ec5340910f1
[]
no_license
US1GHQ/PowerSDR-2.8.0-SDR-1000
7849ba11b17493168bf14efa764bb94d0e707f6b
46bd2361bfc4c100b8ca1f32b23ce0dbb97f785c
refs/heads/main
2023-03-16T18:33:52.580230
2023-03-08T20:17:46
2023-03-08T20:17:46
91,976,579
3
0
null
null
null
null
UTF-8
C++
false
false
7,880
cpp
/***************************************************************************** ResultCheck.cpp Copyright (c) 2005 Laurent de Soras --- Legal stuff --- This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ #if defined (_MSC_VER) #pragma warning (1 : 4130) // "'operator' : logical operation on address of string constant" #pragma warning (1 : 4223) // "nonstandard extension used : non-lvalue array converted to pointer" #pragma warning (1 : 4705) // "statement has no effect" #pragma warning (1 : 4706) // "assignment within conditional expression" #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" #pragma warning (4 : 4355) // "'this' : used in base member initializer list" #endif /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ #include "hiir/test/ResultCheck.h" #include "hiir/test/SweepingSine.h" #include "hiir/test/fnc.h" #include "hiir/def.h" #include <vector> #include <cassert> #include <cmath> #include <cstdio> namespace hiir { namespace test { /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ // We should take group delay into account int ResultCheck::check_dspl (const SweepingSine &ss, double bw, double at, const float out_ptr []) { assert (out_ptr != 0); assert (&ss != 0); assert (bw > 0); assert (bw < 0.5); assert (at > 0); using namespace std; int ret_val = 0; printf ("Checking... "); fflush (stdout); // Relax the specs in order to take filter ringing into account bw = get_max (bw, 0.01); at = get_min (at, 20.0); const float f_nyquist = ss.get_sample_freq () * 0.5f; const float f_pb_end = f_nyquist * static_cast <float> (0.5 - bw); const float f_sb_beg = f_nyquist * static_cast <float> (0.5 + bw); const long pos_pb_b = 0; const long pos_pb_e = ss.get_sample_pos_for (f_pb_end) / 2; assert (pos_pb_b < pos_pb_e); const long pos_sb_b = ss.get_sample_pos_for (f_sb_beg) / 2; const long pos_sb_e = ss.get_sample_pos_for (f_nyquist) / 2; assert (pos_sb_b < pos_sb_e); // Measures passband volume double sum_pb = 0; { for (long pos = pos_pb_b; pos < pos_pb_e; ++pos) { const double val = out_ptr [pos]; sum_pb += val * val; } } // Measures stopband volume double sum_sb = 0; { for (long pos = pos_sb_b; pos < pos_sb_e; ++pos) { const double val = out_ptr [pos]; sum_sb += val * val; } } printf ("Done.\n"); // Checks passband volume const double vol_pb_avg = sqrt (sum_pb * 2 / pos_pb_e); const double err_pb_avg = fabs (vol_pb_avg - 1); if (err_pb_avg > 0.1) { assert (vol_pb_avg > 0); const double vol_pb_avg_db = log10 (vol_pb_avg) * 20; printf ( "Error: abnormal average volume in passband (%f dB).\n", vol_pb_avg_db ); ret_val = -1; } // Checks stopband volume const double vol_sb_avg = sqrt (sum_sb * 2 / (pos_sb_e - pos_sb_b)); const double vol_sb_th = pow (10.0, at / -20.0); const double err_sb_avg = vol_sb_avg / vol_sb_th - 1; if (err_sb_avg > 0.25) { assert (vol_sb_avg > 0); const double vol_sb_avg_db = log10 (vol_sb_avg) * 20; printf ( "Error: abnormal average volume in stopband (%f dB).\n", vol_sb_avg_db ); ret_val = -2; } return (ret_val); } int ResultCheck::check_uspl (const SweepingSine &ss, double bw, double at, const float out_ptr []) { assert (out_ptr != 0); assert (&ss != 0); assert (bw > 0); assert (bw < 0.5); assert (at > 0); using namespace std; int ret_val = 0; // Relax the specs in order to take FIR accuracy into account bw = get_max (bw, 0.01); at = get_min (at, 50.0); printf ("Checking... "); fflush (stdout); // Builds a simple FIR to keep only signal in the stopband. const long fir_len = 127; // Must be odd because of the fir_mid case assert ((fir_len & 1) != 0); const double f_sb_beg = 0.5 + bw; const double f_shft = 3.5 / (fir_len + 1); // Shifts main lobe into the stopband const double f_fir = f_sb_beg + f_shft; std::vector <float> fir (fir_len); for (long fir_pos = 0; fir_pos < fir_len; ++fir_pos) { const long fir_mid = (fir_len - 1) / 2; if (fir_pos == fir_mid) { fir [fir_pos] = static_cast <float> (f_fir - 1); } else { const double w_phase = 2 * hiir::PI * (fir_pos + 0.5) / fir_len; const double w = 0.5 * (1 - cos (w_phase)); const double s_phase = f_fir * hiir::PI * (fir_pos - fir_mid); const double s = f_fir * sin (s_phase) / s_phase; fir [fir_pos] = static_cast <float> (w * s); } } const long len = ss.get_len () * 2; const long len_ana = len - fir_len + 1; assert (len_ana > 0); // Measures global and stopband volumes double sum = 0; double sum_sb = 0; for (long pos = 0; pos < len_ana; ++pos) { const double val = out_ptr [pos]; sum += val * val; double val_fir = 0; for (long k = 0; k < fir_len; ++k) { val_fir += out_ptr [pos + k] * fir [k]; } sum_sb += val_fir * val_fir; } printf ("Done.\n"); // Checks global volume const double vol_avg = sqrt (sum * 2 / len_ana); const double err_avg = fabs (vol_avg - 1); if (err_avg > 0.1) { assert (vol_avg > 0); const double vol_avg_db = log10 (vol_avg) * 20; printf ( "Error: abnormal average volume (%f dB).\n", vol_avg_db ); ret_val = -1; } // Checks stopband volume const double vol_sb_avg = sqrt (sum_sb * 2 / len_ana); const double vol_sb_th = pow (10.0, at / -20.0); const double err_sb_avg = vol_sb_avg / vol_sb_th - 1; if (err_sb_avg > 0.25) { assert (vol_sb_avg > 0); const double vol_sb_avg_db = log10 (vol_sb_avg) * 20; printf ( "Error: abnormal average volume in stopband (%f dB).\n", vol_sb_avg_db ); ret_val = -2; } return (ret_val); } // We should take group delay into account int ResultCheck::check_phase (const SweepingSine &ss, double bw, const float out_0_ptr [], const float out_1_ptr []) { assert (out_0_ptr != 0); assert (out_1_ptr != 0); assert (&ss != 0); assert (bw > 0); assert (bw < 0.5); using namespace std; printf ("Checking... "); fflush (stdout); int ret_val = 0; const float f_nyquist = ss.get_sample_freq () * 0.5f; const float f_b = static_cast <float> (f_nyquist * bw ); const float f_e = static_cast <float> (f_nyquist * (1 - bw)); const long pos_b = ss.get_sample_pos_for (f_b); const long pos_e = ss.get_sample_pos_for (f_e); assert (pos_b < pos_e); double err_sum = 0; double err_max = 0; for (long pos = pos_b; pos < pos_e; ++pos) { using namespace std; const double v_0 = out_0_ptr [pos]; const double v_1 = out_1_ptr [pos]; const double val = sqrt (v_0 * v_0 + v_1 * v_1); const double err = val - 1; const double err_pos = (err > 0) ? err : 0; const double err_abs = fabs (err); err_max = get_max (err_max, err_pos); err_sum += err_abs; } const double err_avg = err_sum / (pos_e - pos_b); printf ("Done.\n"); if (err_max > 0.25) { printf ("Error: abnormal maximum phase error (%f %%).\n", err_max * 100); ret_val = -1; } if (err_avg > 0.125) { printf ("Error: abnormal average phase error (%f %%).\n", err_avg * 100); ret_val = -2; } return (ret_val); } /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ } // namespace test } // namespace hiir /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
[ "sim201010@gmail.com" ]
sim201010@gmail.com
1d6644a71b254c289f367d369bce7b903904ae86
de7e771699065ec21a340ada1060a3cf0bec3091
/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizer.h
f42162f30c797ae241d6aa845e9bdda7d03c0826
[]
no_license
sraihan73/Lucene-
0d7290bacba05c33b8d5762e0a2a30c1ec8cf110
1fe2b48428dcbd1feb3e10202ec991a5ca0d54f3
refs/heads/master
2020-03-31T07:23:46.505891
2018-12-08T14:57:54
2018-12-08T14:57:54
152,020,180
7
0
null
null
null
null
UTF-8
C++
false
false
2,703
h
#pragma once #include "BaseUIMATokenizer.h" #include "stringhelper.h" #include <any> #include <memory> #include <string> #include <unordered_map> // C++ NOTE: Forward class declarations: #include "core/src/java/org/apache/lucene/analysis/tokenattributes/CharTermAttribute.h" #include "core/src/java/org/apache/lucene/analysis/tokenattributes/OffsetAttribute.h" #include "core/src/java/org/apache/lucene/util/AttributeFactory.h" /* * Licensed to the Syed Mamun Raihan (sraihan.com) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * sraihan.com licenses this file to You under GPLv3 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 * * https://www.gnu.org/licenses/gpl-3.0.en.html * * 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. */ namespace org::apache::lucene::analysis::uima { using CharTermAttribute = org::apache::lucene::analysis::tokenattributes::CharTermAttribute; using OffsetAttribute = org::apache::lucene::analysis::tokenattributes::OffsetAttribute; using AttributeFactory = org::apache::lucene::util::AttributeFactory; /** * a {@link Tokenizer} which creates tokens from UIMA Annotations */ class UIMAAnnotationsTokenizer final : public BaseUIMATokenizer { GET_CLASS_NAME(UIMAAnnotationsTokenizer) private: const std::shared_ptr<CharTermAttribute> termAttr; const std::shared_ptr<OffsetAttribute> offsetAttr; const std::wstring tokenTypeString; int finalOffset = 0; public: UIMAAnnotationsTokenizer( const std::wstring &descriptorPath, const std::wstring &tokenType, std::unordered_map<std::wstring, std::any> &configurationParameters); UIMAAnnotationsTokenizer( const std::wstring &descriptorPath, const std::wstring &tokenType, std::unordered_map<std::wstring, std::any> &configurationParameters, std::shared_ptr<AttributeFactory> factory); protected: void initializeIterator() override; public: bool incrementToken() override; void end() override; protected: std::shared_ptr<UIMAAnnotationsTokenizer> shared_from_this() { return std::static_pointer_cast<UIMAAnnotationsTokenizer>( BaseUIMATokenizer::shared_from_this()); } }; } // #include "core/src/java/org/apache/lucene/analysis/uima/
[ "smamunr@fedora.localdomain" ]
smamunr@fedora.localdomain
776cd4511230899f272dc89b242853d8e727b9ae
9be29ab016d2be4b1f88a3656759cd7a5954711d
/uan/model/uan-mac-wakeup.h
def325ec11db36472c7e5acd22cc78beed213716
[]
no_license
ojuejuno/ns3.25-wakeup
23e85b76a19161b5bdb72626c1059f19c409662d
616bbddd49f6cb9a138c88f26dcfe7df8588c96d
refs/heads/master
2021-01-01T04:00:39.189467
2016-05-23T14:17:49
2016-05-23T14:17:49
58,214,842
4
3
null
null
null
null
UTF-8
C++
false
false
4,968
h
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 Universitat Politècnica de València * * This program 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; * * 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 * * Author: Salvador Climent <jocliba@upvnet.upv.es> */ #ifndef UAN_MAC_WAKEUP_H_ #define UAN_MAC_WAKEUP_H_ #include "uan-mac.h" #include "uan-address.h" #include "ns3/random-variable-stream.h" #include "ns3/event-id.h" #include "ns3/timer.h" #include "ns3/uan-phy-gen.h" #include "ns3/simulator.h" #include <queue> namespace ns3 { class UanPhy; class UanTxMode; class UanMacWakeup : public UanMac, public UanPhyListener { public: enum PhyState { BUSY, IDLE }; typedef Callback<void> TxEndCallback; typedef Callback<void> ToneRxCallback; UanMacWakeup (); virtual ~UanMacWakeup (); static TypeId GetTypeId (void); //Inherited functions Address GetAddress (void); virtual void SetAddress (UanAddress addr); virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber); virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress& > cb); void SetTxEndCallback (TxEndCallback cb); void SetToneRxCallback (ToneRxCallback cb); virtual void AttachPhy (Ptr<UanPhy> phy); void AttachWakeupPhy (Ptr<UanPhy> phy); //void AttachWakeupHEPhy (Ptr<UanPhy> phy); virtual Address GetBroadcast (void) const; virtual void Clear (void); bool Send (); void SendWU (UanAddress dst); bool SendWUAlone (UanAddress dst); //void SendWUHE (); void SendBroadcastWU (); //void SetHighEnergyMode (); void SetToneMode (); void SetSendPhyStateChangeCb (Callback<void, PhyState> cb); void SetSleepMode(bool isSleep); void SetUseWakeup(bool useWakeup); uint32_t GetHeadersSize () const; //PhyListener /** * \brief Function called when Phy object begins receiving packet */ virtual void NotifyRxStart (void); /** * \brief Function called when Phy object finishes receiving packet without error */ virtual void NotifyRxEndOk (void); /** * \brief Function called when Phy object finishes receiving packet in error */ virtual void NotifyRxEndError (void); /** * \brief Function called when Phy object begins sensing channel is busy */ virtual void NotifyCcaStart (void); /** * \brief Function called when Phy object stops sensing channel is busy */ virtual void NotifyCcaEnd (void); /** * \param duration Duration of transmission * \brief Function called when transmission starts from Phy object */ virtual void NotifyTxStart (Time duration); int64_t AssignStreams (int64_t stream); private: enum State { WU, DATA }; Ptr<UniformRandomVariable> m_rand; Callback<void> m_sendDataCallback; UanAddress m_address; Ptr<UanPhyGen> m_phy; Ptr<UanPhy> m_wakeupPhy; //Ptr<UanPhy> m_wakeupPhyHE; Callback<void, Ptr<Packet>, const UanAddress& > m_forUpCb; Callback<void, PhyState> m_stateChangeCb; bool m_cleared; bool m_wuAlone; bool m_useWakeup; Ptr<Packet> m_pkt; UanAddress m_dest; Timer m_timerEndTx; Timer m_timerDelayTx; //Timer m_timerDelayTxWUHE; Timer m_timerTxFail; uint64_t m_timeDelayTx; //Miliseconds bool m_dataSent; //bool m_highEnergyMode; bool m_toneMode; State m_state; PhyState m_phyState; TxEndCallback m_txEnd; ToneRxCallback m_toneRxCallback; void On_timerEndTx (void); void On_timerDelayTx (void); //void On_timerDelayTxWUHE (void); void On_timerTxFail (void); /** * \brief Receive packet from lower layer (passed to PHY as callback) * \param pkt Packet being received * \param sinr SINR of received packet * \param txMode Mode of received packet */ void RxPacketGood (Ptr<Packet> pkt, double sinr, UanTxMode txMode); //void RxPacketGoodData (Ptr<Packet> pkt, double sinr, UanTxMode txMode); void RxPacketGoodW (Ptr<Packet> pkt, double sinr, UanTxMode txMode); //void RxPacketGoodWHE (Ptr<Packet> pkt, double sinr, UanTxMode txMode); /** * \brief Packet received at lower layer in error * \param pkt Packet received in error * \param sinr SINR of received packet */ void RxPacketError (Ptr<Packet> pkt, double sinr); void RxPacketErrorW (Ptr<Packet> pkt, double sinr); //void RxPacketErrorWHE (Ptr<Packet> pkt, double sinr); protected: virtual void DoDispose (); }; } #endif /* UAN_MAC_WAKEUP_H_ */
[ "ojuejuno@gmail.com" ]
ojuejuno@gmail.com
301ea9ec38851fa332d89c71b56c75a84d677eed
2039498c2770eb7f1f32f25d24e8b20c141caa69
/problems/292-Nim-Game/test.cpp
d32a2de3d0ca033233b5d81f4e7af43787dae64d
[]
no_license
DavyVan/PhDStillNeedLeetCode
c10f38447d9b0ad5d50c2f529ee4a4159105e58d
0dd4dcd3a598a85cb2189ab4993e1f63c0305c4c
refs/heads/master
2023-08-11T01:14:30.483187
2023-07-31T02:33:30
2023-07-31T02:33:30
253,396,587
4
0
null
null
null
null
UTF-8
C++
false
false
460
cpp
#include "kernel.h" #include <gtest/gtest.h> TEST(_292, _1) { int n = 1; bool expect = true; EXPECT_EQ(canWinNim(n), expect); } TEST(_292, _2) { int n = 2; bool expect = true; EXPECT_EQ(canWinNim(n), expect); } TEST(_292, _3) { int n = 3; bool expect = true; EXPECT_EQ(canWinNim(n), expect); } TEST(_292, _4) { int n = 4; bool expect = false; EXPECT_EQ(canWinNim(n), expect); }
[ "affqqa@163.com" ]
affqqa@163.com
439b932204e3adc2fb1f9f91a7782c3bd22fe76a
6b40e9dccf2edc767c44df3acd9b626fcd586b4d
/NT/admin/wmi/wbem/winmgmt/ess3/permbind.h
ceb93ea9c5afcdebd631211cee1145db743a7c1f
[]
no_license
jjzhang166/WinNT5_src_20201004
712894fcf94fb82c49e5cd09d719da00740e0436
b2db264153b80fbb91ef5fc9f57b387e223dbfc2
refs/heads/Win2K3
2023-08-12T01:31:59.670176
2021-10-14T15:14:37
2021-10-14T15:14:37
586,134,273
1
0
null
2023-01-07T03:47:45
2023-01-07T03:47:44
null
UTF-8
C++
false
false
1,165
h
//****************************************************************************** // // PERMBIND.H // // Copyright (C) 1996-1999 Microsoft Corporation // //****************************************************************************** #ifndef __WMI_ESS_PERM_BINDING__H_ #define __WMI_ESS_PERM_BINDING__H_ #include "binding.h" #include "fastall.h" class CPermanentBinding : public CBinding { protected: static long mstatic_lConsumerHandle; static long mstatic_lFilterHandle; static long mstatic_lSynchronicityHandle; static long mstatic_lQosHandle; static long mstatic_lSlowDownHandle; static long mstatic_lSecureHandle; static long mstatic_lSidHandle; static bool mstatic_bHandlesInitialized; protected: static HRESULT InitializeHandles( _IWmiObject* pBindingObj); public: CPermanentBinding() {} HRESULT Initialize(IWbemClassObject* pBindingObj); static HRESULT ComputeKeysFromObject(IWbemClassObject* pBindingObj, BSTR* pstrConsumer, BSTR* pstrFilter); static DELETE_ME INTERNAL PSID GetSidFromObject(IWbemClassObject* pObj); }; #endif
[ "seta7D5@protonmail.com" ]
seta7D5@protonmail.com
88367d8209169fe505233d2a192cbabb43487b39
49536aafb22a77a6caf249c7fadef46d63d24dfe
/tensorflow/tensorflow/core/grappler/costs/virtual_placer_test.cc
f5d3e184d67bdd0206f76b458b6004d462dd9615
[ "Apache-2.0" ]
permissive
wangzhi01/deeplearning-1
4e5ad93f0d9ecd302b74352f80fe1fa6ae70bf0d
46ab82253d956953b8aa98e97ceb6cd290e82288
refs/heads/master
2020-05-28T03:14:55.687567
2018-09-12T16:52:09
2018-09-12T16:52:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,029
cc
/* Copyright 2017 The TensorFlow Authors. 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. ==============================================================================*/ #include "tensorflow/core/grappler/costs/virtual_placer.h" #include "tensorflow/core/framework/node_def.pb.h" #include "tensorflow/core/grappler/clusters/virtual_cluster.h" #include "tensorflow/core/lib/strings/strcat.h" #include "tensorflow/core/platform/test.h" #include "tensorflow/core/protobuf/device_properties.pb.h" namespace tensorflow { namespace grappler { TEST(VirtualPlacerTest, LocalDevices) { // Create a virtual cluster with a local CPU and a local GPU std::unordered_map<string, DeviceProperties> devices; DeviceProperties cpu_device; cpu_device.set_type("CPU"); devices["/job:localhost/replica:0/task:0/cpu:0"] = cpu_device; DeviceProperties gpu_device; gpu_device.set_type("GPU"); devices["/job:localhost/replica:0/task:0/device:GPU:0"] = gpu_device; VirtualCluster cluster(devices); VirtualPlacer placer(&cluster); NodeDef node; node.set_op("Conv2D"); // node.device() is empty, but GPU is default device if there is. EXPECT_EQ("GPU", placer.get_device(node).type()); EXPECT_EQ("/job:localhost/replica:0/task:0/device:GPU:0", placer.get_canonical_device_name(node)); node.set_device("CPU"); EXPECT_EQ("CPU", placer.get_device(node).type()); EXPECT_EQ("/job:localhost/replica:0/task:0/cpu:0", placer.get_canonical_device_name(node)); node.set_device("GPU:0"); EXPECT_EQ("GPU", placer.get_device(node).type()); EXPECT_EQ("/job:localhost/replica:0/task:0/device:GPU:0", placer.get_canonical_device_name(node)); } TEST(VirtualPlacerTest, ShortNames) { // Create a virtual cluster with a local CPU and a local GPU std::unordered_map<string, DeviceProperties> devices; DeviceProperties cpu_device; cpu_device.set_type("CPU"); devices["/CPU:0"] = cpu_device; DeviceProperties gpu_device; gpu_device.set_type("GPU"); devices["/GPU:0"] = gpu_device; VirtualCluster cluster(devices); VirtualPlacer placer(&cluster); NodeDef node; node.set_op("Conv2D"); // node.device() is empty, but GPU is default device if there is. EXPECT_EQ("GPU", placer.get_device(node).type()); EXPECT_EQ("/GPU:0", placer.get_canonical_device_name(node)); node.set_device("CPU"); EXPECT_EQ("CPU", placer.get_device(node).type()); EXPECT_EQ("/CPU:0", placer.get_canonical_device_name(node)); node.set_device("GPU:0"); EXPECT_EQ("GPU", placer.get_device(node).type()); EXPECT_EQ("/GPU:0", placer.get_canonical_device_name(node)); } TEST(VirtualPlacerTest, PlacementOnNonDefaultDevice) { // Create a virtual cluster with a CPU and a device:TPU // Test that placement on TPU works // In contrast with GPU, TPU is not selected as default device at the moment. std::unordered_map<string, DeviceProperties> devices; DeviceProperties cpu_device; cpu_device.set_type("CPU"); devices["/job:localhost/replica:0/task:0/cpu:0"] = cpu_device; DeviceProperties tpu_device; tpu_device.set_type("TPU"); devices["/job:localhost/replica:0/task:0/device:TPU:0"] = tpu_device; VirtualCluster cluster(devices); VirtualPlacer placer(&cluster); NodeDef node; node.set_op("Conv2D"); // node.device() is empty, and CPU is default device. EXPECT_EQ("CPU", placer.get_device(node).type()); EXPECT_EQ("/job:localhost/replica:0/task:0/cpu:0", placer.get_canonical_device_name(node)); node.set_device("/device:TPU:0"); EXPECT_EQ("TPU", placer.get_device(node).type()); EXPECT_EQ("/job:localhost/replica:0/task:0/device:TPU:0", placer.get_canonical_device_name(node)); } TEST(VirtualPlacerTest, EmptyJobName) { // Virtual placer choose job name from the devices in cluster if a device name // of an op is empty. In case there are more than one kind of job name // or job names are missin in the devices in cluster, we use local_host. for (const string& job_name : {"localhost", "worker", "worker_train"}) { std::unordered_map<string, DeviceProperties> devices; DeviceProperties cpu_device; cpu_device.set_type("CPU"); devices[strings::StrCat("/job:", job_name, "/replica:0/task:0/cpu:0")] = cpu_device; DeviceProperties gpu_device; gpu_device.set_type("GPU"); devices[strings::StrCat("/job:", job_name, "/replica:0/task:0/device:GPU:0")] = gpu_device; VirtualCluster cluster(devices); VirtualPlacer placer(&cluster); NodeDef node; node.set_op("Conv2D"); node.set_device("/device:CPU:0"); EXPECT_EQ(strings::StrCat("/job:", job_name, "/replica:0/task:0/cpu:0"), placer.get_canonical_device_name(node)); node.set_device("/device:GPU:0"); EXPECT_EQ( strings::StrCat("/job:", job_name, "/replica:0/task:0/device:GPU:0"), placer.get_canonical_device_name(node)); } // When more than one job names are used, we use default "localhost" // This may be improved later. std::unordered_map<string, DeviceProperties> devices; DeviceProperties cpu_device; cpu_device.set_type("CPU"); devices["/job:localhost/replica:0/task:0/cpu:0"] = cpu_device; devices["/job:ps/replica:0/task:0/cpu:0"] = cpu_device; devices["/job:worker/replica:0/task:0/cpu:0"] = cpu_device; VirtualCluster cluster(devices); VirtualPlacer placer(&cluster); NodeDef node; node.set_op("Conv2D"); node.set_device("/device:CPU:0"); EXPECT_EQ("/job:localhost/replica:0/task:0/cpu:0", placer.get_canonical_device_name(node)); } string GetDefaultDeviceName( const std::unordered_map<string, DeviceProperties>& devices) { VirtualCluster cluster(devices); VirtualPlacer placer(&cluster); NodeDef node; node.set_op("Conv2D"); // Device is not set to the node, so get_canonical_device_name() will return // the default_device_. return placer.get_canonical_device_name(node); } TEST(VirtualPlacerTest, DefaultDevice) { std::unordered_map<string, DeviceProperties> devices; DeviceProperties cpu_device; cpu_device.set_type("CPU"); devices["/job:worker/replica:0/task:0/cpu:0"] = cpu_device; // CPU is default when there is only CPU. EXPECT_EQ("/job:worker/replica:0/task:0/cpu:0", GetDefaultDeviceName(devices)); DeviceProperties gpu_device; gpu_device.set_type("GPU"); // If there is any GPU, then gpu:0 is default device. for (int i = 0; i < 8; i++) { devices[strings::StrCat("/job:worker/replica:0/task:0/gpu:", i)] = gpu_device; EXPECT_EQ("/job:worker/replica:0/task:0/gpu:0", GetDefaultDeviceName(devices)); } } TEST(VirtualPlacerTest, MultiReplica) { // Create a cluster with 8 workers, each with 8 GPUs. std::unordered_map<string, DeviceProperties> devices; DeviceProperties cpu_device; cpu_device.set_type("CPU"); DeviceProperties gpu_device; gpu_device.set_type("GPU"); for (int i = 0; i < 8; i++) { devices[strings::StrCat("/job:worker/replica:", i, "/task:0/cpu:0")] = cpu_device; for (int j = 0; j < 8; j++) { devices[strings::StrCat("/job:worker/replica:", i, "/task:0/gpu:", j)] = gpu_device; } } std::unique_ptr<VirtualCluster> cluster(new VirtualCluster(devices)); std::unique_ptr<VirtualPlacer> placer(new VirtualPlacer(cluster.get())); auto get_device_name = [&placer](const string& device) -> string { NodeDef node; node.set_op("Conv2D"); node.set_device(device); return placer->get_canonical_device_name(node); }; // Validate device name is correct when we pass only replica ID and device // name. EXPECT_EQ("/job:worker/replica:0/task:0/cpu:0", get_device_name("/replica:0/cpu:0")); EXPECT_EQ("/job:worker/replica:2/task:0/cpu:0", get_device_name("/replica:2/cpu:0")); EXPECT_EQ("/job:worker/replica:7/task:0/cpu:0", get_device_name("/replica:7/cpu:0")); EXPECT_EQ("/job:worker/replica:3/task:0/gpu:0", get_device_name("/replica:3/gpu:0")); EXPECT_EQ("/job:worker/replica:5/task:0/gpu:3", get_device_name("/replica:5/gpu:3")); EXPECT_EQ("/job:worker/replica:4/task:0/gpu:7", get_device_name("/replica:4/gpu:7")); // Now add PS replicas; with multiple job names present in the cluster, // device names in nodes should specify job names correctly. for (int i = 0; i < 4; i++) { devices[strings::StrCat("/job:ps/replica:", i, "/task:0/cpu:0")] = cpu_device; } cluster.reset(new VirtualCluster(devices)); placer.reset(new VirtualPlacer(cluster.get())); EXPECT_EQ("/job:worker/replica:0/task:0/cpu:0", get_device_name("/job:worker/replica:0/cpu:0")); EXPECT_EQ("/job:worker/replica:7/task:0/gpu:3", get_device_name("/job:worker/replica:7/gpu:3")); EXPECT_EQ("/job:ps/replica:0/task:0/cpu:0", get_device_name("/job:ps/replica:0/cpu:0")); EXPECT_EQ("/job:ps/replica:1/task:0/cpu:0", get_device_name("/job:ps/replica:1/cpu:0")); EXPECT_EQ("/job:ps/replica:2/task:0/cpu:0", get_device_name("/job:ps/replica:2/cpu:0")); EXPECT_EQ("/job:ps/replica:3/task:0/cpu:0", get_device_name("/job:ps/replica:3/cpu:0")); } TEST(VirtualPlacerTest, FallBackUnknown) { // Virtual placer falls back to "UNKNOWN" only if there are no devices in the // cluster. std::unordered_map<string, DeviceProperties> devices; VirtualCluster cluster(devices); VirtualPlacer placer(&cluster); NodeDef node; node.set_op("Conv2D"); // Device falls back to UNKNOWN since the cluster has no devices. EXPECT_EQ("UNKNOWN", placer.get_device(node).type()); EXPECT_EQ("UNKNOWN", placer.get_canonical_device_name(node)); } TEST(VirtualPlacerTest, FallBackCPU) { std::unordered_map<string, DeviceProperties> devices; DeviceProperties cpu_device; cpu_device.set_type("CPU"); devices["/job:my_job/replica:0/task:0/cpu:0"] = cpu_device; VirtualCluster cluster(devices); VirtualPlacer placer(&cluster); NodeDef node; node.set_op("Conv2D"); // Device falls back to CPU since there is no GPU. EXPECT_EQ("CPU", placer.get_device(node).type()); EXPECT_EQ("/job:my_job/replica:0/task:0/cpu:0", placer.get_canonical_device_name(node)); } TEST(VirtualPlacerTest, RemoteDevices) { std::unordered_map<string, DeviceProperties> devices; DeviceProperties cpu_device; cpu_device.set_type("CPU"); devices["/job:my_job/replica:0/task:0/cpu:0"] = cpu_device; DeviceProperties gpu_device; gpu_device.set_type("GPU"); devices["/job:my_job/replica:0/task:0/device:GPU:0"] = gpu_device; VirtualCluster cluster(devices); VirtualPlacer placer(&cluster); NodeDef node; node.set_op("Conv2D"); // Device falls back to GPU. EXPECT_EQ("GPU", placer.get_device(node).type()); EXPECT_EQ("/job:my_job/replica:0/task:0/device:GPU:0", placer.get_canonical_device_name(node)); node.set_device("/job:my_job/replica:0/task:0/cpu:0"); EXPECT_EQ("CPU", placer.get_device(node).type()); EXPECT_EQ("/job:my_job/replica:0/task:0/cpu:0", placer.get_canonical_device_name(node)); node.set_device("/job:my_job/replica:0/task:0/device:GPU:0"); EXPECT_EQ("GPU", placer.get_device(node).type()); EXPECT_EQ("/job:my_job/replica:0/task:0/device:GPU:0", placer.get_canonical_device_name(node)); // There is no local cpu available. Device falls back to GPU. node.set_device("CPU"); EXPECT_EQ("GPU", placer.get_device(node).type()); EXPECT_EQ("/job:my_job/replica:0/task:0/device:GPU:0", placer.get_canonical_device_name(node)); node.set_device("GPU:0"); // There is no local GPU available. Fall back to default GPU. EXPECT_EQ("GPU", placer.get_device(node).type()); EXPECT_EQ("/job:my_job/replica:0/task:0/device:GPU:0", placer.get_canonical_device_name(node)); // This isn't a valid name. Fall back to GPU. node.set_device("/job:my_job/replica:0/task:0"); EXPECT_EQ("GPU", placer.get_device(node).type()); EXPECT_EQ("/job:my_job/replica:0/task:0/device:GPU:0", placer.get_canonical_device_name(node)); } } // end namespace grappler } // end namespace tensorflow
[ "hanshuobest@163.com" ]
hanshuobest@163.com
20659bec3cfb3b68a43cac5c990b029b22b1c9df
c3d3062f0fdd751a49ccbe907cff41aa4680b42b
/include/denis/DenisLevelMap.h
a4a55741ae69d852d628ff6f53525ae48e1970c0
[]
no_license
Flower35/ZookieWizard
5a233d71f2202ae120dd7c160e8d022a40c15eeb
1d398f194e1ad74d5b6cf7f865dc2baab33936b7
refs/heads/master
2023-06-07T04:34:27.333278
2022-08-18T17:12:13
2022-08-18T17:12:13
228,497,238
12
6
null
null
null
null
UTF-8
C++
false
false
2,341
h
#ifndef H_DENIS_LEVEL_MAP #define H_DENIS_LEVEL_MAP #include <denis/Denis.h> namespace ZookieWizard { struct DenisLevelTexture; struct DenisLevelSample; struct DenisLevelWObj; struct DenisLevelObject; struct DenisLevelMaxObj; struct DenisLevelZone; struct DenisLevelBillboard; struct DenisLevelBonus; class eScene; class eMaterial; //////////////////////////////////////////////////////////////// // Kao the Kangaroo: Level Map interface //////////////////////////////////////////////////////////////// class DenisLevelMap { /*** Properties ***/ protected: eString levelName; int32_t texturesCount; int32_t texturesMaxLength; DenisLevelTexture* textures; int32_t ambientSamplesCount; int32_t ambientSamplesMaxLength; DenisLevelSample* ambientSamples; int32_t worldObjectsCount; int32_t worldObjectsMaxLength; DenisLevelWObj* worldObjects; int32_t objectsCount[DENIS_LEVEL_OBJECT_TYPES]; int32_t objectsMaxLength[DENIS_LEVEL_OBJECT_TYPES]; DenisLevelObject* objects[DENIS_LEVEL_OBJECT_TYPES]; int32_t proxiesCount; int32_t proxiesMaxLength; DenisLevelMaxObj* proxies; int32_t eventZonesCount; int32_t eventZonesMaxLength; DenisLevelZone* eventZones; int32_t billboardsCount; int32_t billboardsMaxLength; DenisLevelBillboard* billboards; int32_t bonusesCount; int32_t bonusesMaxLength; DenisLevelBonus* bonuses; /* External things */ eMaterial** materialsList; eMaterial* collisionMaterials[4]; float kaoPos[3]; uint16_t kaoRot[3]; /*** Methods ***/ public: DenisLevelMap(); DenisLevelMap(eString new_name); ~DenisLevelMap(); void openAndSerialize(DenisFileOperator &file); void destroy(); eString getName() const; void createMaterialsList(DenisFileOperator &file); void deleteMaterialsList(); eScene* convertToKao2(DenisFileOperator &file); }; } #endif
[ "46760021+Flower35@users.noreply.github.com" ]
46760021+Flower35@users.noreply.github.com
f44d847d1a51010bf6d8da4e20e8d1f9fdbba0ee
6546d748c306c9bfea7ab961bf2f520f2880531b
/PLIN_Driver.h
033593744a993304af2dbd4805f040239bfe2ce9
[]
no_license
sunbeam0529/PLinBootloader
53d63d0dc701f5c9231e67ac9f330c6b8652edec
1efb640631918c229634ed8a1c6dbf3e951b8ae0
refs/heads/master
2021-06-08T23:46:24.775332
2021-05-24T02:46:22
2021-05-24T02:46:22
183,719,665
2
0
null
null
null
null
UTF-8
C++
false
false
40,116
h
#pragma once #include "PLinApi.h" #include <QtWidgets/QMainWindow> // Function pointers // typedef TLINError(__stdcall* fpOneParamCli) (HLINCLIENT); typedef TLINError(__stdcall* fpTwoParam) (HLINCLIENT, HLINHW); typedef TLINError(__stdcall* fpDelStartSchedule) (HLINCLIENT, HLINHW, int); typedef TLINError(__stdcall* fpRegisterClient) (LPSTR, DWORD, HLINCLIENT*); typedef TLINError(__stdcall* fpIdentifyHardware) (HLINHW); typedef TLINError(__stdcall* fpSetClientParam) (HLINCLIENT, TLINClientParam, DWORD); typedef TLINError(__stdcall* fpGetClientParam) (HLINCLIENT, TLINClientParam, void*, WORD); typedef TLINError(__stdcall* fpSetClientFilter) (HLINCLIENT, HLINHW, unsigned __int64); typedef TLINError(__stdcall* fpGetClientFilter) (HLINCLIENT, HLINHW, unsigned __int64*); typedef TLINError(__stdcall* fpRead) (HLINCLIENT, TLINRcvMsg*); typedef TLINError(__stdcall* fpReadMulti) (HLINCLIENT, TLINRcvMsg*, int, int*); typedef TLINError(__stdcall* fpWrite) (HLINCLIENT, HLINHW, TLINMsg*); typedef TLINError(__stdcall* fpInitializeHardware) (HLINCLIENT, HLINHW, TLINHardwareMode, WORD); typedef TLINError(__stdcall* fpGetAvailableHardware) (HLINHW*, WORD, int*); typedef TLINError(__stdcall* fpSetHardwareParam) (HLINCLIENT, HLINHW, TLINHardwareParam, void*, WORD); typedef TLINError(__stdcall* fpGetHardwareParam) (HLINHW, TLINHardwareParam, void*, WORD); typedef TLINError(__stdcall* fpRegisterFrameId) (HLINCLIENT, HLINHW, BYTE, BYTE); typedef TLINError(__stdcall* fpSetFrameEntry) (HLINCLIENT, HLINHW, TLINFrameEntry*); typedef TLINError(__stdcall* fpGetFrameEntry) (HLINHW, TLINFrameEntry*); typedef TLINError(__stdcall* fpUpdateByteArray) (HLINCLIENT, HLINHW, BYTE, BYTE, BYTE, BYTE*); typedef TLINError(__stdcall* fpStartKeepAlive) (HLINCLIENT, HLINHW, BYTE, WORD); typedef TLINError(__stdcall* fpSetSchedule) (HLINCLIENT, HLINHW, int, TLINScheduleSlot*, int); typedef TLINError(__stdcall* fpGetSchedule) (HLINHW, int, TLINScheduleSlot*, int, int*); typedef TLINError(__stdcall* fpSetScheduleBreakPoint) (HLINCLIENT, HLINHW, int, DWORD); typedef TLINError(__stdcall* fpStartAutoBaud) (HLINCLIENT, HLINHW, WORD); typedef TLINError(__stdcall* fpGetStatus) (HLINHW, TLINHardwareStatus*); typedef TLINError(__stdcall* fpCalculateChecksum) (TLINMsg*); typedef TLINError(__stdcall* fpGetVersion) (TLINVersion*); typedef TLINError(__stdcall* fpGetVersionInfo) (LPSTR, WORD); typedef TLINError(__stdcall* fpGetErrorText) (TLINError, BYTE, LPSTR, WORD); typedef TLINError(__stdcall* fpGetPID) (BYTE*); typedef TLINError(__stdcall* fpGetTargetTime) (HLINHW, unsigned __int64*); typedef TLINError(__stdcall* fpSetResponseRemap) (HLINCLIENT, HLINHW, BYTE*); typedef TLINError(__stdcall* fpGetResponseRemap) (HLINHW, BYTE*); typedef TLINError(__stdcall* fpGetSystemTime) (unsigned __int64*); #define fpRemoveClient fpOneParamCli #define fpResetClient fpOneParamCli #define fpConnectClient fpTwoParam #define fpDisconnectClient fpTwoParam #define fpResetHardware fpTwoParam #define fpSuspendKeepAlive fpTwoParam #define fpResumeKeepAlive fpTwoParam #define fpResetHardwareConfig fpTwoParam #define fpSuspendSchedule fpTwoParam #define fpResumeSchedule fpTwoParam #define fpXmtWakeUp fpTwoParam #define fpDeleteSchedule fpDelStartSchedule #define fpStartSchedule fpDelStartSchedule typedef struct { HLINHW hLINHW; int devnum; int channel; }AVAILABLE_HW; #define RET_OK 0 #define RET_ERR 1 class PLIN_DRIVER { public: PLIN_DRIVER(void); ~PLIN_DRIVER(void); HINSTANCE m_hDll = NULL; HLINCLIENT m_hClient = NULL; HLINHW m_hHW; AVAILABLE_HW* AvailableHW; int m_bWasLoaded; fpRemoveClient m_pRemoveClient; fpResetClient m_pResetClient; fpConnectClient m_pConnectClient; fpDisconnectClient m_pDisconnectClient; fpResetHardware m_pResetHardware; fpSuspendKeepAlive m_pSuspendKeepAlive; fpResumeKeepAlive m_pResumeKeepAlive; fpResetHardwareConfig m_pResetHardwareConfig; fpSuspendSchedule m_pSuspendSchedule; fpResumeSchedule m_pResumeSchedule; fpXmtWakeUp m_pXmtWakeUp; fpDeleteSchedule m_pDeleteSchedule; fpStartSchedule m_pStartSchedule; fpRegisterClient m_pRegisterClient; fpIdentifyHardware m_pIdentifyHardware; fpSetClientParam m_pSetClientParam; fpGetClientParam m_pGetClientParam; fpSetClientFilter m_pSetClientFilter; fpGetClientFilter m_pGetClientFilter; fpRead m_pRead; fpReadMulti m_pReadMulti; fpWrite m_pWrite; fpInitializeHardware m_pInitializeHardware; fpGetAvailableHardware m_pGetAvailableHardware; fpSetHardwareParam m_pSetHardwareParam; fpGetHardwareParam m_pGetHardwareParam; fpRegisterFrameId m_pRegisterFrameId; fpSetFrameEntry m_pSetFrameEntry; fpGetFrameEntry m_pGetFrameEntry; fpUpdateByteArray m_pUpdateByteArray; fpStartKeepAlive m_pStartKeepAlive; fpSetSchedule m_pSetSchedule; fpGetSchedule m_pGetSchedule; fpSetScheduleBreakPoint m_pSetScheduleBreakPoint; fpStartAutoBaud m_pStartAutoBaud; fpGetStatus m_pGetStatus; fpCalculateChecksum m_pCalculateChecksum; fpGetVersion m_pGetVersion; fpGetVersionInfo m_pGetVersionInfo; fpGetErrorText m_pGetErrorText; fpGetPID m_pGetPID; fpGetTargetTime m_pGetTargetTime; fpSetResponseRemap m_pSetResponseRemap; fpGetResponseRemap m_pGetResponseRemap; fpGetSystemTime m_pGetSystemTime; int LoadDLL(void); int FreshHW(QList<QString>* HWList); FARPROC GetFunction(LPSTR szName); int isConnect(void); int DoLINConnect(int index, int burdrate); void DoLINDisconnect(void); /// <summary> /// Registers a Client at the LIN Manager. Creates a Client handle and /// allocates the Receive Queue (only one per Client). The hWnd parameter /// can be zero for DOS Box Clients. The Client does not receive any /// messages until LIN_RegisterFrameId() or LIN_SetClientFilter() is called. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue /// </summary> /// <param name="strName">Name of the Client</param> /// <param name="hWnd">Window handle of the Client (only for information purposes)</param> /// <param name="hClient">Pointer to the Client handle buffer</param> /// <returns>A LIN Error Code</returns> TLINError RegisterClient( LPSTR strName, DWORD hWnd, HLINCLIENT* hClient); /// <summary> /// Removes a Client from the Client list of the LIN Manager. Frees all /// resources (receive queues, message counters, etc.). If the Client was /// a Boss-Client for one or more Hardware, the Boss-Client property for /// those Hardware will be set to INVALID_LIN_HANDLE. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient /// </summary> /// <param name="hClient">Handle of the Client</param> /// <returns>A LIN Error Code</returns> TLINError RemoveClient( HLINCLIENT hClient); /// <summary> /// Connects a Client to a Hardware. /// The Hardware is assigned by its Handle. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware to be connected</param> /// <returns>A LIN Error Code</returns> TLINError ConnectClient( HLINCLIENT hClient, HLINHW hHw); /// <summary> /// Disconnects a Client from a Hardware. This means: no more messages /// will be received by this Client from this Hardware. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware to be disconnected</param> /// <returns>A LIN Error Code</returns> TLINError DisconnectClient( HLINCLIENT hClient, HLINHW hHw); /// <summary> /// Flushes the Receive Queue of the Client and resets its counters. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient /// </summary> /// <param name="hClient">Handle of the Client</param> /// <returns>A LIN Error Code</returns> TLINError ResetClient( HLINCLIENT hClient); /// <summary> /// Sets a Client parameter to a given value. /// /// Allowed TLINClientParam Parameter /// values in wParam: type: Description: /// ------------------------- ---------- ------------------------------ /// clpReceiveStatusFrames int 0 = Status Frames deactivated, /// otherwise active /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterType, errWrongParameterValue, errIllegalClient /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="wParam">Parameter to set</param> /// <param name="dwValue">parameter value</param> /// <returns>A LIN Error Code</returns> TLINError SetClientParam( HLINCLIENT hClient, TLINClientParam wParam, DWORD dwValue); /// <summary> /// Gets a Client parameter. /// /// Allowed TLINClientParam Parameter /// values in wParam: type: Description: /// ------------------------- ---------- ------------------------------ /// clpName string Name of the Client /// clpMessagesOnQueue int Unread messages in the Receive Queue /// clpWindowHandle int Window handle of the Client application /// (can be zero for DOS Box Clients) /// clpConnectedHardware HLINHW[] Array of Hardware Handles connected by a Client /// The first item in the array refers to the /// amount of handles. So [*] = Total handles + 1 /// clpTransmittedMessages int Number of transmitted messages /// clpReceivedMessages int Number of received messages /// clpReceiveStatusFrames int 0 = Status Frames deactivated, otherwise active /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterType, errWrongParameterValue, errIllegalClient, /// errBufferInsufficient /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="wParam">Parameter to get</param> /// <param name="pBuff">Buffer for the parameter value</param> /// <param name="wBuffSize">Buffer size in bytes</param> /// <returns>A LIN Error Code</returns> TLINError GetClientParam( HLINCLIENT hClient, TLINClientParam wParam, void* pBuff, WORD wBuffSize); /// <summary> /// Sets the filter of a Client and modifies the filter of /// the connected Hardware. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="iRcvMask">Filter. Each bit corresponds to a Frame ID (0..63)</param> /// <returns>A LIN Error Code</returns> TLINError SetClientFilter( HLINCLIENT hClient, HLINHW hHw, unsigned __int64 iRcvMask); /// <summary> /// Gets the filter corresponding to a given Client-Hardware pair. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="pRcvMask">Filter buffer. Each bit corresponds to a Frame ID (0..63)</param> /// <returns>A LIN Error Code</returns> TLINError GetClientFilter( HLINCLIENT hClient, HLINHW hHw, unsigned __int64* pRcvMask); /// <summary> /// Reads the next message/status information from a Client's Receive /// Queue. The message will be written to 'pMsg'. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errRcvQueueEmpty /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="pMsg">Message read buffer</param> /// <returns>A LIN Error Code</returns> TLINError Read( HLINCLIENT hClient, TLINRcvMsg* pMsg); /// <summary> /// Reads several received messages. /// pMsgBuff must be an array of 'iMaxCount' entries (must have at least /// a size of iMaxCount * sizeof(TLINRcvMsg) bytes). /// The size 'iMaxCount' of the array = max. messages that can be received. /// The real number of read messages will be returned in 'pCount'. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errRcvQueueEmpty /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="pMsgBuff">Messages buffer</param> /// <param name="iMaxCount"> Maximum number of messages to read (pMsgBuff length)</param> /// <param name="pCount">Buffer for the real number of messages read</param> /// <returns>A LIN Error Code</returns> TLINError ReadMulti( HLINCLIENT hClient, TLINRcvMsg* pMsgBuff, int iMaxCount, int* pCount); /// <summary> /// The Client 'hClient' transmits a message 'pMsg' to the Hardware 'hHw'. /// The message is written into the Transmit Queue of the Hardware. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware, /// errIllegalDirection, errIllegalLength /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="pMsg">Message write buffer</param> /// <returns>A LIN Error Code</returns> TLINError Write( HLINCLIENT hClient, HLINHW hHw, TLINMsg* pMsg); /// <summary> /// Initializes a Hardware with a given Mode and Baudrate. /// /// <remarks> /// If the Hardware was initialized by another Client, the function /// will re-initialize the Hardware. All connected clients will be affected. /// It is the job of the user to manage the setting and/or configuration of /// Hardware, e.g. by using the Boss-Client parameter of the Hardware. /// </remarks> /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware, /// errIllegalBaudrate /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="byMode">Hardware mode (see LIN Hardware Operation Modes)</param> /// <param name="wBaudrate">Baudrate (see LIN_MIN_BAUDRATE and LIN_MAX_BAUDRATE)</param> /// <returns>A LIN Error Code</returns> TLINError InitializeHardware( HLINCLIENT hClient, HLINHW hHw, TLINHardwareMode bMode, WORD wBaudrate); /// <summary> /// Gets an array containing the handles of the current Hardware /// available in the system. /// The count of Hardware handles returned in the array is written in /// 'pCount'. /// /// <remarks> /// To ONLY get the count of available Hardware, call this /// function using 'pBuff' = NULL and wBuffSize = 0. /// </remarks> /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errBufferInsufficient /// </summary> /// <param name="pBuff">Buffer for the handles</param> /// <param name="wBuffSize">Size of the buffer in bytes </param> /// <param name="pCount">Number of Hardware available</param> /// <returns>A LIN Error Code</returns> TLINError GetAvailableHardware( HLINHW* pBuff, WORD wBuffSize, int* pCount); /// <summary> /// Sets a Hardware parameter to a given value. /// /// Allowed TLINHardwareParam Parameter /// values in wParam: type: Description: /// ------------------------- ---------- ------------------------------ /// hwpMessageFilter UInt64 Hardware message filter. Each bit /// corresponds to a Frame ID (0..63) /// hwpBossClient HLINCLIENT Handle of the new Boss-Client /// hwpIdNumber int Identification number for a hardware /// hwpUserData byte[] User data to write on a hardware. See LIN_MAX_USER_DATA /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterType, errWrongParameterValue, errIllegalClient, /// errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="wParam">Parameter to set</param> /// <param name="pBuff">Parameter value buffer</param> /// <param name="wBuffSize">Value buffer size</param> /// <returns>A LIN Error Code</returns> TLINError SetHardwareParam( HLINCLIENT hClient, HLINHW hHw, TLINHardwareParam wParam, void* pBuff, WORD wBuffSize); /// <summary> /// Gets a Hardware parameter. /// /// Allowed TLINHardwareParam Parameter /// values in wParam: type: Description: /// ------------------------- ---------- ------------------------------ /// hwpName string Name of the Hardware. See LIN_MAX_NAME_LENGTH /// hwpDeviceNumber int Index of the Device owner of the Hardware /// hwpChannelNumber int Channel Index of the Hardware on the owner device /// hwpConnectedClients HLINCLIENT[]Array of Client Handles conencted to a Hardware /// The first item in the array refers to the /// amount of handles. So [*] = Total handles + 1 /// hwpMessageFilter UInt64 Configured message filter. Each bit corresponds /// to a Frame ID (0..63) /// hwpBaudrate int Configured baudrate /// hwpMode int 0 = Slave, otehrwise Master /// hwpFirmwareVersion TLINVersion A TLINVersion structure containing the Firmware Version /// hwpBufferOverrunCount int Receive Buffer Overrun Counter /// hwpBossClient HLINCLIENT Handle of the current Boss-Client /// hwpSerialNumber int Serial number of the Hardware /// hwpVersion int Version of the Hardware /// hwpType int Type of the Hardware /// hwpQueueOverrunCount int Receive Queue Buffer Overrun Counter /// hwpIdNumber int Identification number for a hardware /// hwpUserData byte[] User data saved on the hardware. See LIN_MAX_USER_DATA /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterType, errWrongParameterValue, errIllegalHardware, /// errBufferInsufficient /// </summary> /// <param name="hHw">Handle of the Hardware</param> /// <param name="wParam">Parameter to get</param> /// <param name="pBuff">Parameter buffer</param> /// <param name="wBuffSize">Buffer size</param> /// <returns>A LIN Error Code</returns> TLINError GetHardwareParam( HLINHW hHw, TLINHardwareParam wParam, void* pBuff, WORD wBuffSize); /// <summary> /// Flushes the queues of the Hardware and resets its counters. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <returns>A LIN Error Code</returns> TLINError ResetHardware( HLINCLIENT hClient, HLINHW hHw); /// <summary> /// Deletes the current configuration of the Hardware and sets its defaults. /// The Client 'hClient' must be registered and connected to the Hardware to /// be accessed. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <returns>A LIN Error Code</returns> TLINError ResetHardwareConfig( HLINCLIENT hClient, HLINHW hHw); /// <summary> /// Physically identifies a LIN Hardware (a channel on a LIN Device) by /// blinking its associated LED. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalHardware /// </summary> /// <param name="hHw">Handle of the Hardware</param> /// <returns>A LIN Error Code</returns> TLINError IdentifyHardware( HLINHW hHw); /// <summary> /// Modifies the filter of a Client and, eventually, the filter of the /// connected Hardware. The messages with FrameID 'bFromFrameId' to /// 'bToFrameId' will be received. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware, /// errIllegalFrameID /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="bFromFrameId">First ID of the frame range</param> /// <param name="bToFrameId">Last ID of the frame range</param> /// <returns>A LIN Error Code</returns> TLINError RegisterFrameId( HLINCLIENT hClient, HLINHW hHw, BYTE bFromFrameId, BYTE bToFrameId); /// <summary> /// Configures a LIN Frame in a given Hardware. The Client 'hClient' must /// be registered and connected to the Hardware to be accessed. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware, /// errIllegalFrameID, errIllegalLength /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="pFrameEntry">Frame entry information buffer</param> /// <returns>A LIN Error Code</returns> TLINError SetFrameEntry( HLINCLIENT hClient, HLINHW hHw, TLINFrameEntry* pFrameEntry); /// <summary> /// Gets the configuration of a LIN Frame from a given Hardware. /// /// <remarks> /// The 'pFrameEntry.FrameId' must be set to the ID of the frame, whose /// configuration should be returned. /// </remarks> /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalHardware, errIllegalFrameID /// </summary> /// <param name="hHw">Handle of the Hardware</param> /// <param name="pFrameEntry">Frame entry buffer. The member FrameId /// must be set to the ID of the frame, whose configuration should /// be returned </param> /// <returns>A LIN Error Code</returns> TLINError GetFrameEntry( HLINHW hHw, TLINFrameEntry* pFrameEntry); /// <summary> /// Updates the data of a LIN Frame for a given Hardware. The Client /// 'hClient' must be registered and connected to the Hardware to be /// accessed. 'pData' must have at least a size of 'bLen'. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware, /// errIllegalFrameID, errIllegalLength, errIllegalIndex, /// errIllegalRange /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="bFrameId">Frame ID</param> /// <param name="bIndex">Index where the update data Starts (0..7)</param> /// <param name="bLen">Count of Data bytes to be updated.</param> /// <param name="pData">Data buffer</param> /// <returns>A LIN Error Code</returns> TLINError UpdateByteArray( HLINCLIENT hClient, HLINHW hHw, BYTE bFrameId, BYTE bIndex, BYTE bLen, BYTE* pData); /// <summary> /// Sets the Frame 'bFrameId' as Keep-Alive frame for the given Hardware and /// starts to send it every 'wPeriod' Milliseconds. The Client 'hClient' must /// be registered and connected to the Hardware to be accessed. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware, /// errIllegalFrameID /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="bFrameId">ID of the Keep-Alive Frame</param> /// <param name="wPeriod">Keep-Alive Interval in Milliseconds</param> /// <returns>A LIN Error Code</returns> TLINError StartKeepAlive( HLINCLIENT hClient, HLINHW hHw, BYTE bFrameId, WORD wPeriod); /// <summary> /// Suspends the sending of a Keep-Alive frame in the given Hardware. /// The Client 'hClient' must be registered and connected to the Hardware /// to be accessed. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <returns>A LIN Error Code</returns> TLINError SuspendKeepAlive( HLINCLIENT hClient, HLINHW hHw); /// <summary> /// Resumes the sending of a Keep-Alive frame in the given Hardware. /// The Client 'hClient' must be registered and connected to the Hardware /// to be accessed. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <returns>A LIN Error Code</returns> TLINError ResumeKeepAlive( HLINCLIENT hClient, HLINHW hHw); /// <summary> /// Configures the slots of a Schedule in a given Hardware. The Client /// 'hClient' must be registered and connected to the Hardware to be /// accessed. The Slot handles will be returned in the parameter /// "pSchedule" (Slots buffer), when this function successfully completes. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware, /// errIllegalScheduleNo, errIllegalSlotCount /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="iScheduleNumber">Schedule number (see /// LIN_MIN_SCHEDULE_NUMBER and LIN_MAX_SCHEDULE_NUMBER)</param> /// <param name="pSchedule">Slots buffer</param> /// <param name="iSlotCount">Count of Slots in the slots buffer</param> /// <returns>A LIN Error Code</returns> TLINError SetSchedule( HLINCLIENT hClient, HLINHW hHw, int iScheduleNumber, TLINScheduleSlot* pSchedule, int iSlotCount); /// <summary> /// Gets the slots of a Schedule from a given Hardware. The count of slots /// returned in the array is written in 'pSlotCount'. /// /// <remarks> /// To ONLY get the count of slots contained in the given Schedule, /// call this function using 'pScheduleBuff' = NULL and iMaxSlotCount = 0. /// </remarks> /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalHardware, errIllegalScheduleNo, /// errIllegalSlotCount /// </summary> /// <param name="hHw">Handle of the Hardware</param> /// <param name="iScheduleNumber">Schedule Number (see /// LIN_MIN_SCHEDULE_NUMBER and LIN_MAX_SCHEDULE_NUMBER)</param> /// <param name="pScheduleBuff">Slots Buffer.</param> /// <param name="iMaxSlotCount">Maximum number of slots to read.</param> /// <param name="pSlotCount">Real number of slots read.</param> /// <returns>A LIN Error Code</returns> TLINError GetSchedule( HLINHW hHw, int iScheduleNumber, TLINScheduleSlot* pScheduleBuff, int iMaxSlotCount, int* pSlotCount); /// <summary> /// Removes all slots contained by a Schedule of a given Hardware. The /// Client 'hClient' must be registered and connected to the Hardware to /// be accessed. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware, /// errIllegalScheduleNo /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="iScheduleNumber">Schedule Number (see /// LIN_MIN_SCHEDULE_NUMBER and LIN_MAX_SCHEDULE_NUMBER)</param> /// <returns>A LIN Error Code</returns> TLINError DeleteSchedule( HLINCLIENT hClient, HLINHW hHw, int iScheduleNumber); /// <summary> /// Sets a 'breakpoint' on a slot from a Schedule in a given Hardware. The /// Client 'hClient' must be registered and connected to the Hardware to /// be accessed. /// /// <remarks> /// Giving 'dwHandle' a value of 0 ('null'), causes the deletion of // the breakpoint. /// </remarks> /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="iBreakPointNumber">Breakpoint Number (0 or 1)</param> /// <param name="dwHandle">Slot Handle</param> /// <returns>A LIN Error Code</returns> TLINError SetScheduleBreakPoint( HLINCLIENT hClient, HLINHW hHw, int iBreakPointNumber, DWORD dwHandle); /// <summary> /// Activates a Schedule in a given Hardware. The Client 'hClient' must /// be registered and connected to the Hardware to be accessed. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware, /// errIllegalScheduleNo /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="iScheduleNumber">Schedule Number (see /// LIN_MIN_SCHEDULE_NUMBER and LIN_MAX_SCHEDULE_NUMBER)</param> /// <returns>A LIN Error Code</returns> TLINError StartSchedule( HLINCLIENT hClient, HLINHW hHw, int iScheduleNumber); /// <summary> /// Suspends an active Schedule in a given Hardware. The Client 'hClient' /// must be registered and connected to the Hardware to be accessed. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <returns>A LIN Error Code</returns> TLINError SuspendSchedule( HLINCLIENT hClient, HLINHW hHw); /// <summary> /// Restarts a configured Schedule in a given Hardware. The Client 'hClient' /// must be registered and connected to the Hardware to be accessed. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <returns>A LIN Error Code</returns> TLINError ResumeSchedule( HLINCLIENT hClient, HLINHW hHw); /// <summary> /// Sends a wake-up message impulse (single data byte 0xF0). The Client /// 'hClient' must be registered and connected to the Hardware to be /// accessed. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <returns>A LIN Error Code</returns> TLINError XmtWakeUp( HLINCLIENT hClient, HLINHW hHw); /// <summary> /// Starts a process to detect the Baud rate of the LIN bus that is /// connected to the indicated Hardware. /// The Client 'hClient' must be registered and connected to the Hardware /// to be accessed. The Hardware must be not initialized in order /// to do an Auto-baudrate procedure. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalClient, errIllegalHardware /// </summary> /// <param name="hClient">Handle of the Client</param> /// <param name="hHw">Handle of the Hardware</param> /// <param name="wTimeOut">Auto-baudrate Timeout in Milliseconds</param> /// <returns>A LIN Error Code</returns> TLINError StartAutoBaud( HLINCLIENT hClient, HLINHW hHw, WORD wTimeOut); /// <summary> /// Retrieves current status information from the given Hardware. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalHardware /// </summary> /// <param name="hHw">Handle of the Hardware</param> /// <param name="pStatusBuff">Status data buffer</param> /// <returns>A LIN Error Code</returns> TLINError GetStatus( HLINHW hHw, TLINHardwareStatus* pStatusBuff); /// <summary> /// Calculates the checksum of a LIN Message and writes it into the /// 'Checksum' field of 'pMsg'. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalLength /// </summary> /// <param name="pMsg">Message buffer</param> /// <returns>A LIN Error Code</returns> TLINError CalculateChecksum( TLINMsg* pMsg); /// <summary> /// Returns a TLINVersion structure containing the PLIN-API DLL version. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue /// </summary> /// <param name="pVerBuffer">Version buffer</param> /// <returns>A LIN Error Code</returns> TLINError GetVersion( TLINVersion* pVerBuff ); /// <summary> /// Returns a string containing Copyright information. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue /// </summary> /// <param name="pTextBuff">String buffer</param> /// <param name="wBuffSize">Size in bytes of the buffer</param> /// <returns>A LIN Error Code</returns> TLINError GetVersionInfo( LPSTR strTextBuff, WORD wBuffSize); /// <summary> /// Converts the error code 'dwError' to a text containing an error /// description in the language given as parameter (when available). /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errBufferInsufficient /// </summary> /// <param name="dwError">A TLINError Code</param> /// <param name="bLanguage">Indicates a "Primary language ID"</param> /// <param name="strTextBuff">Error string buffer</param> /// <param name="wBuffSize">Buffer size in bytes</param> /// <returns>A LIN Error Code</returns> TLINError GetErrorText( TLINError dwError, BYTE bLanguage, LPSTR strTextBuff, WORD wBuffSize); /// <summary> /// Gets the 'FrameId with Parity' corresponding to the given /// 'pFrameId' and writes the result on it. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalFrameID /// </summary> /// <param name="pframeid">Frame ID (0..LIN_MAX_FRAME_ID)</param> /// <returns>A LIN Error Code</returns> TLINError GetPID( BYTE* pFrameId); /// <summary> /// Gets the system time used by the LIN-USB adapter. /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalHardware /// </summary> /// <param name="hHw">Handle of the Hardware</param> /// <param name="pTargetTime">Target Time buffer</param> /// <returns>A LIN Error Code</returns> TLINError GetTargetTime( HLINHW hHw, unsigned __int64* pTargetTime); /// <summary> /// Sets the Response Remap of a LIN Slave /// /// Possible DLL interaction errors: /// errManagerNotLoaded, errManagerNotResponse, errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue, errIllegalFrameID, errIllegalClient, errIllegalHardware, /// errMemoryAccess /// </summary> /// <param name="hClient">Client Handle</param> /// <param name="hHw">Hardware Handle</param> /// <param name="pRemapTab">Remap Response buffer</param> /// <returns>A LIN Error Code</returns> TLINError SetResponseRemap( HLINCLIENT hClient, HLINHW hHw, BYTE* pRemapTab); /// <summary> /// Gets the Response Remap of a LIN Slave /// </summary> /// <param name="hHw">Hardware Handle</param> /// <param name="pRemapTab">Remap Response buffer</param> /// <returns>A LIN Error Code</returns> TLINError GetResponseRemap( HLINHW hHw, BYTE* pRemapTab); /// <summary> /// Gets the current system time. The system time is returned by /// Windows as the elapsed number of microseconds since system start. /// /// Possible DLL interaction errors: /// errMemoryAccess /// /// Possible API errors: /// errWrongParameterValue /// </summary> /// <param name="pTargetTime">System Time buffer</param> /// <returns>A LIN Error Code</returns> TLINError GetSystemTime( unsigned __int64* pSystemTime); };
[ "fcb1995@163.com" ]
fcb1995@163.com
f04026d67e81a0e407c46a29e29dc323c715fe99
cefd6c17774b5c94240d57adccef57d9bba4a2e9
/folly/io/test/CompressionTest.cpp
eabd399367ecfbdb1f21f23cccc7b9c99b2d6ef9
[ "BSL-1.0" ]
permissive
adzhou/oragle
9c054c25b24ff0a65cb9639bafd02aac2bcdce8b
5442d418b87d0da161429ffa5cb83777e9b38e4d
refs/heads/master
2022-11-01T05:04:59.368831
2014-03-12T15:50:08
2014-03-12T15:50:08
17,238,063
0
1
BSL-1.0
2022-10-18T04:23:53
2014-02-27T05:39:44
C++
UTF-8
C++
false
false
7,686
cpp
/* * Copyright 2014 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "folly/io/Compression.h" // Yes, tr1, as that's what gtest requires #include <random> #include <thread> #include <tr1/tuple> #include <unordered_map> #include <boost/noncopyable.hpp> #include <glog/logging.h> #include <gtest/gtest.h> #include "folly/Benchmark.h" #include "folly/Hash.h" #include "folly/Random.h" #include "folly/io/IOBufQueue.h" namespace folly { namespace io { namespace test { class DataHolder : private boost::noncopyable { public: uint64_t hash(size_t size) const; ByteRange data(size_t size) const; protected: explicit DataHolder(size_t sizeLog2); const size_t size_; std::unique_ptr<uint8_t[]> data_; mutable std::unordered_map<uint64_t, uint64_t> hashCache_; }; DataHolder::DataHolder(size_t sizeLog2) : size_(size_t(1) << sizeLog2), data_(new uint8_t[size_]) { } uint64_t DataHolder::hash(size_t size) const { CHECK_LE(size, size_); auto p = hashCache_.find(size); if (p != hashCache_.end()) { return p->second; } uint64_t h = folly::hash::fnv64_buf(data_.get(), size); hashCache_[size] = h; return h; } ByteRange DataHolder::data(size_t size) const { CHECK_LE(size, size_); return ByteRange(data_.get(), size); } uint64_t hashIOBuf(const IOBuf* buf) { uint64_t h = folly::hash::FNV_64_HASH_START; for (auto& range : *buf) { h = folly::hash::fnv64_buf(range.data(), range.size(), h); } return h; } class RandomDataHolder : public DataHolder { public: explicit RandomDataHolder(size_t sizeLog2); }; RandomDataHolder::RandomDataHolder(size_t sizeLog2) : DataHolder(sizeLog2) { constexpr size_t numThreadsLog2 = 3; constexpr size_t numThreads = size_t(1) << numThreadsLog2; uint32_t seed = randomNumberSeed(); std::vector<std::thread> threads; threads.reserve(numThreads); for (size_t t = 0; t < numThreads; ++t) { threads.emplace_back( [this, seed, t, numThreadsLog2, sizeLog2] () { std::mt19937 rng(seed + t); size_t countLog2 = size_t(1) << (sizeLog2 - numThreadsLog2); size_t start = size_t(t) << countLog2; for (size_t i = 0; i < countLog2; ++i) { this->data_[start + i] = rng(); } }); } for (auto& t : threads) { t.join(); } } class ConstantDataHolder : public DataHolder { public: explicit ConstantDataHolder(size_t sizeLog2); }; ConstantDataHolder::ConstantDataHolder(size_t sizeLog2) : DataHolder(sizeLog2) { memset(data_.get(), 'a', size_); } constexpr size_t dataSizeLog2 = 27; // 128MiB RandomDataHolder randomDataHolder(dataSizeLog2); ConstantDataHolder constantDataHolder(dataSizeLog2); TEST(CompressionTestNeedsUncompressedLength, Simple) { EXPECT_FALSE(getCodec(CodecType::NO_COMPRESSION)->needsUncompressedLength()); EXPECT_TRUE(getCodec(CodecType::LZ4)->needsUncompressedLength()); EXPECT_FALSE(getCodec(CodecType::SNAPPY)->needsUncompressedLength()); EXPECT_FALSE(getCodec(CodecType::ZLIB)->needsUncompressedLength()); EXPECT_FALSE(getCodec(CodecType::LZ4_VARINT_SIZE)->needsUncompressedLength()); EXPECT_TRUE(getCodec(CodecType::LZMA2)->needsUncompressedLength()); EXPECT_FALSE(getCodec(CodecType::LZMA2_VARINT_SIZE) ->needsUncompressedLength()); } class CompressionTest : public testing::TestWithParam< std::tr1::tuple<int, CodecType>> { protected: void SetUp() { auto tup = GetParam(); uncompressedLength_ = uint64_t(1) << std::tr1::get<0>(tup); codec_ = getCodec(std::tr1::get<1>(tup)); } void runSimpleTest(const DataHolder& dh); uint64_t uncompressedLength_; std::unique_ptr<Codec> codec_; }; void CompressionTest::runSimpleTest(const DataHolder& dh) { auto original = IOBuf::wrapBuffer(dh.data(uncompressedLength_)); auto compressed = codec_->compress(original.get()); if (!codec_->needsUncompressedLength()) { auto uncompressed = codec_->uncompress(compressed.get()); EXPECT_EQ(uncompressedLength_, uncompressed->computeChainDataLength()); EXPECT_EQ(dh.hash(uncompressedLength_), hashIOBuf(uncompressed.get())); } { auto uncompressed = codec_->uncompress(compressed.get(), uncompressedLength_); EXPECT_EQ(uncompressedLength_, uncompressed->computeChainDataLength()); EXPECT_EQ(dh.hash(uncompressedLength_), hashIOBuf(uncompressed.get())); } } TEST_P(CompressionTest, RandomData) { runSimpleTest(randomDataHolder); } TEST_P(CompressionTest, ConstantData) { runSimpleTest(constantDataHolder); } INSTANTIATE_TEST_CASE_P( CompressionTest, CompressionTest, testing::Combine( testing::Values(0, 1, 12, 22, 25, 27), testing::Values(CodecType::NO_COMPRESSION, CodecType::LZ4, CodecType::SNAPPY, CodecType::ZLIB, CodecType::LZ4_VARINT_SIZE, CodecType::LZMA2, CodecType::LZMA2_VARINT_SIZE))); class CompressionCorruptionTest : public testing::TestWithParam<CodecType> { protected: void SetUp() { codec_ = getCodec(GetParam()); } void runSimpleTest(const DataHolder& dh); std::unique_ptr<Codec> codec_; }; void CompressionCorruptionTest::runSimpleTest(const DataHolder& dh) { constexpr uint64_t uncompressedLength = 42; auto original = IOBuf::wrapBuffer(dh.data(uncompressedLength)); auto compressed = codec_->compress(original.get()); if (!codec_->needsUncompressedLength()) { auto uncompressed = codec_->uncompress(compressed.get()); EXPECT_EQ(uncompressedLength, uncompressed->computeChainDataLength()); EXPECT_EQ(dh.hash(uncompressedLength), hashIOBuf(uncompressed.get())); } { auto uncompressed = codec_->uncompress(compressed.get(), uncompressedLength); EXPECT_EQ(uncompressedLength, uncompressed->computeChainDataLength()); EXPECT_EQ(dh.hash(uncompressedLength), hashIOBuf(uncompressed.get())); } EXPECT_THROW(codec_->uncompress(compressed.get(), uncompressedLength + 1), std::runtime_error); // Corrupt the first character ++(compressed->writableData()[0]); if (!codec_->needsUncompressedLength()) { EXPECT_THROW(codec_->uncompress(compressed.get()), std::runtime_error); } EXPECT_THROW(codec_->uncompress(compressed.get(), uncompressedLength), std::runtime_error); } TEST_P(CompressionCorruptionTest, RandomData) { runSimpleTest(randomDataHolder); } TEST_P(CompressionCorruptionTest, ConstantData) { runSimpleTest(constantDataHolder); } INSTANTIATE_TEST_CASE_P( CompressionCorruptionTest, CompressionCorruptionTest, testing::Values( // NO_COMPRESSION can't detect corruption // LZ4 can't detect corruption reliably (sigh) CodecType::SNAPPY, CodecType::ZLIB)); }}} // namespaces int main(int argc, char *argv[]) { testing::InitGoogleTest(&argc, argv); google::ParseCommandLineFlags(&argc, &argv, true); auto ret = RUN_ALL_TESTS(); if (!ret) { folly::runBenchmarksOnFlag(); } return ret; }
[ "adzhou@hp.com" ]
adzhou@hp.com
86e27428b6b48d75366ef8c5ae2a4dbc1add8777
23c84c283f0dd2ffe6811e85d5924102a05d7ed1
/UVa/V015/1594 - Ducci Sequence.cpp
39dce36f9c351cbd303471c23f75b36e0bf1dd17
[]
no_license
HJackH/OnlineJudges
efaaaf35fabeb5393a3fefac9a19e3c89a535b3b
1e5bfc7ad13cc171e16d562a4cac0bcdc92bbce2
refs/heads/master
2022-07-08T21:31:37.960165
2022-06-22T07:01:57
2022-06-22T07:01:57
245,434,136
4
1
null
null
null
null
UTF-8
C++
false
false
814
cpp
#include <bits/stdc++.h> using namespace std; int T, n, a[20], tmp[20]; bool chkZero() { for (int i = 0; i < n; i++) { if (a[i] != 0) { return false; } } return true; } void nextArr() { memcpy(tmp, a, n * sizeof(int)); for (int i = 0; i < n; i++) { a[i] = abs(tmp[i] - tmp[(i + 1) % n]); } } int main() { cin >> T; while (T--) { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } bool flag = chkZero(); if (!flag) { for (int i = 1; i <= 1000 && !flag; i++) { nextArr(); flag = chkZero(); } } if (flag) { cout << "ZERO" << endl; } else { cout << "LOOP" << endl; } } }
[ "56967377+HJackH@users.noreply.github.com" ]
56967377+HJackH@users.noreply.github.com
d8bb985c01e91b6107a1d0180f9c6120b43b7cc6
b58d467ded99f268f0c1ebc4957ddb30d8271494
/srcs/main.cpp
be3e2c90579143b3231e7abb8b0943ac4be4996f
[]
no_license
mdufaud/gomoku
77d9beca7d55a7b1fd52c05ae5da3ec5ac362fcc
1d01901bdcbb97b4bd0dfd751578b5b45c7d21bc
refs/heads/master
2022-03-20T02:41:05.518900
2019-12-19T22:14:36
2019-12-19T22:14:36
197,841,725
0
0
null
null
null
null
UTF-8
C++
false
false
1,585
cpp
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mdufaud <mdufaud@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/03/10 14:37:44 by mdufaud #+# #+# */ /* Updated: 2016/03/17 19:37:47 by mdufaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "gomoku.hpp" #include "Graph.class.hpp" int main(int argc, char **argv) { Graph graph; bool running = true; (void)argc; (void)argv; printf("Keys for interface:\n\t- S for printing IA stats\n\ \t- B and N to go back and forth in game state\n\ \t- P to activate or deactivate auto play\n\t- I to activate or deactivate IA\n\ \t- Backspace to go back to main menu\n\t- Page up and down to go through logs\n\ \t- Up, left, down, right to navigate through the game window\n\ \t- H to activate help for next move\n"); srand(time(NULL)); if (graph.getError()) return (1); while (running && graph.doContinue()) { graph.parseEvent(running); graph.draw(); } return (0); }
[ "mdufaud@student.42.fr" ]
mdufaud@student.42.fr
3554c2f57022f0213aa2e54e0e48f4652d2efcb9
a01fb7bb8e8738a3170083d84bc3fcfd40e7e44f
/cpp/std_c/memory/alignment.cpp
01b39bc44a10e983ba6c6696f530c29df51c9457
[]
no_license
jk983294/CommonScript
f07acf603611b4691b176aa4a02791ef7d4d9370
774bcbbae9c146f37312c771c9e867fb93a0c452
refs/heads/master
2023-08-21T17:50:19.036159
2023-08-16T00:22:03
2023-08-16T00:22:03
42,732,160
5
0
null
null
null
null
UTF-8
C++
false
false
881
cpp
#include <iostream> #include <malloc.h> using namespace std; /** * The address returned by malloc or realloc in GNU systems always aligned to 16 on 64-bit systems */ int main() { void* p1 = memalign(64, 32); // align to 64, size is 32 uint64_t addr = reinterpret_cast<uint64_t>(p1); cout << (addr % 64) << " " << (addr % 128) << " " << addr << endl; free(p1); posix_memalign(&p1, 128, 32); // align to 64, size is 32 addr = reinterpret_cast<uint64_t>(p1); cout << (addr % 64) << " " << (addr % 128) << " " << addr << endl; free(p1); /** * using memalign and passing the page size as the value of the second argument. * like memalign (getpagesize(), size); */ p1 = valloc(32); // align to page size, size is 32 cout << (addr % 64) << " " << (addr % 128) << " " << addr << endl; free(p1); return 0; }
[ "jk983294@gmail.com" ]
jk983294@gmail.com
8be07f73680084ad80256f60cfe7561e4da08b5d
473fc28d466ddbe9758ca49c7d4fb42e7d82586e
/app/src/main/java/com/syd/source/aosp/external/vixl/test/aarch32/test-simulator-cond-rd-memop-rs-a32.cc
485b76fac98e5266844a404e905245dc80670410
[]
no_license
lz-purple/Source
a7788070623f2965a8caa3264778f48d17372bab
e2745b756317aac3c7a27a4c10bdfe0921a82a1c
refs/heads/master
2020-12-23T17:03:12.412572
2020-01-31T01:54:37
2020-01-31T01:54:37
237,205,127
4
2
null
null
null
null
UTF-8
C++
false
false
141,417
cc
// Copyright 2016, VIXL authors // 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 ARM Limited 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 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. // ----------------------------------------------------------------------------- // This file is auto generated from the // test/aarch32/config/template-simulator-aarch32.cc.in template file using // tools/generate_tests.py. // // PLEASE DO NOT EDIT. // ----------------------------------------------------------------------------- #include "test-runner.h" #include "test-utils.h" #include "test-utils-aarch32.h" #include "aarch32/assembler-aarch32.h" #include "aarch32/macro-assembler-aarch32.h" #include "aarch32/disasm-aarch32.h" #define __ masm. #define BUF_SIZE (4096) #ifdef VIXL_INCLUDE_SIMULATOR_AARCH32 // Run tests with the simulator. #define SETUP() MacroAssembler masm(BUF_SIZE) #define START() masm.GetBuffer()->Reset() #define END() \ __ Hlt(0); \ __ FinalizeCode(); // TODO: Run the tests in the simulator. #define RUN() #define TEARDOWN() #else // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32. #define SETUP() \ MacroAssembler masm(BUF_SIZE); \ UseScratchRegisterScope harness_scratch(&masm); \ harness_scratch.ExcludeAll(); #define START() \ masm.GetBuffer()->Reset(); \ __ Push(r4); \ __ Push(r5); \ __ Push(r6); \ __ Push(r7); \ __ Push(r8); \ __ Push(r9); \ __ Push(r10); \ __ Push(r11); \ __ Push(lr); \ harness_scratch.Include(ip); #define END() \ harness_scratch.Exclude(ip); \ __ Pop(lr); \ __ Pop(r11); \ __ Pop(r10); \ __ Pop(r9); \ __ Pop(r8); \ __ Pop(r7); \ __ Pop(r6); \ __ Pop(r5); \ __ Pop(r4); \ __ Bx(lr); \ __ FinalizeCode(); #define RUN() \ { \ int pcs_offset = masm.IsUsingT32() ? 1 : 0; \ masm.GetBuffer()->SetExecutable(); \ ExecuteMemory(masm.GetBuffer()->GetStartAddress<byte*>(), \ masm.GetSizeOfCodeGenerated(), \ pcs_offset); \ masm.GetBuffer()->SetWritable(); \ } #define TEARDOWN() harness_scratch.Close(); #endif // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32 namespace vixl { namespace aarch32 { // List of instruction encodings: #define FOREACH_INSTRUCTION(M) \ M(Ldr) \ M(Ldrb) \ M(Ldrh) \ M(Ldrsb) \ M(Ldrsh) \ M(Str) \ M(Strb) \ M(Strh) // The following definitions are defined again in each generated test, therefore // we need to place them in an anomymous namespace. It expresses that they are // local to this file only, and the compiler is not allowed to share these types // across test files during template instantiation. Specifically, `Operands` and // `Inputs` have various layouts across generated tests so they absolutely // cannot be shared. #ifdef VIXL_INCLUDE_TARGET_A32 namespace { // Values to be passed to the assembler to produce the instruction under test. struct Operands { Condition cond; Register rd; Register rn; Sign sign; Register rm; AddrMode addr_mode; }; // Input data to feed to the instruction. struct Inputs { uint32_t apsr; uint32_t rd; uint32_t rm; uint32_t memop[2]; }; // This structure contains all input data needed to test one specific encoding. // It used to generate a loop over an instruction. struct TestLoopData { // The `operands` fields represents the values to pass to the assembler to // produce the instruction. Operands operands; // Description of the operands, used for error reporting. const char* operands_description; // Unique identifier, used for generating traces. const char* identifier; // Array of values to be fed to the instruction. size_t input_size; const Inputs* inputs; }; static const Inputs kCondition[] = {{NFlag, 0xabababab, 0, {0, 0x77777777}}, {ZFlag, 0xabababab, 0, {0, 0x77777777}}, {CFlag, 0xabababab, 0, {0, 0x77777777}}, {VFlag, 0xabababab, 0, {0, 0x77777777}}, {NZFlag, 0xabababab, 0, {0, 0x77777777}}, {NCFlag, 0xabababab, 0, {0, 0x77777777}}, {NVFlag, 0xabababab, 0, {0, 0x77777777}}, {ZCFlag, 0xabababab, 0, {0, 0x77777777}}, {ZVFlag, 0xabababab, 0, {0, 0x77777777}}, {CVFlag, 0xabababab, 0, {0, 0x77777777}}, {NZCFlag, 0xabababab, 0, {0, 0x77777777}}, {NZVFlag, 0xabababab, 0, {0, 0x77777777}}, {NCVFlag, 0xabababab, 0, {0, 0x77777777}}, {ZCVFlag, 0xabababab, 0, {0, 0x77777777}}, {NZCVFlag, 0xabababab, 0, {0, 0x77777777}}}; static const Inputs kPositiveOffset[] = {{NoFlag, 0xabababab, 1651, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 601, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 1934, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 3952, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 674, {0, 0x55555555}}, {NoFlag, 0xabababab, 3438, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 3963, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 1428, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 1835, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 2619, {0, 0x77777777}}}; static const Inputs kNegativeOffset[] = {{NoFlag, 0xabababab, 1635, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 48, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 3871, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 517, {0, 0x77777777}}, {NoFlag, 0xabababab, 513, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 1348, {0, 0x77777777}}, {NoFlag, 0xabababab, 3002, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 306, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 1458, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 3028, {0, 0x55555555}}}; static const Inputs kPositivePostIndex[] = {{NoFlag, 0xabababab, 2442, {0, 0x55555555}}, {NoFlag, 0xabababab, 1485, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 674, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 55, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 2395, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 582, {0, 0x77777777}}, {NoFlag, 0xabababab, 3572, {0, 0x77777777}}, {NoFlag, 0xabababab, 2849, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 3522, {0, 0x77777777}}, {NoFlag, 0xabababab, 1234, {0, 0x0badbeef}}}; static const Inputs kNegativePostIndex[] = {{NoFlag, 0xabababab, 3413, {0, 0x55555555}}, {NoFlag, 0xabababab, 2442, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 3136, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 2119, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 778, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 1666, {0, 0x77777777}}, {NoFlag, 0xabababab, 3069, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 365, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 3094, {0, 0x55555555}}, {NoFlag, 0xabababab, 2690, {0, 0x55555555}}}; static const Inputs kPositivePreIndex[] = {{NoFlag, 0xabababab, 2072, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 22, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 2254, {0, 0x55555555}}, {NoFlag, 0xabababab, 3002, {0, 0x55555555}}, {NoFlag, 0xabababab, 3391, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 3449, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 2796, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 3325, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 365, {0, 0x55555555}}, {NoFlag, 0xabababab, 1323, {0, 0x77777777}}}; static const Inputs kNegativePreIndex[] = {{NoFlag, 0xabababab, 3821, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 2892, {0, 0x77777777}}, {NoFlag, 0xabababab, 3439, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 3057, {0, 0x55555555}}, {NoFlag, 0xabababab, 2559, {0, 0x55555555}}, {NoFlag, 0xabababab, 3663, {0, 0x0cabba9e}}, {NoFlag, 0xabababab, 1506, {0, 0x0badbeef}}, {NoFlag, 0xabababab, 2011, {0, 0x77777777}}, {NoFlag, 0xabababab, 3865, {0, 0x77777777}}, {NoFlag, 0xabababab, 4058, {0, 0x55555555}}}; // A loop will be generated for each element of this array. const TestLoopData kTests[] = {{{eq, r0, r1, plus, r8, Offset}, "eq r0 r1 plus r8 Offset", "Condition_eq_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{ne, r0, r1, plus, r8, Offset}, "ne r0 r1 plus r8 Offset", "Condition_ne_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{cs, r0, r1, plus, r8, Offset}, "cs r0 r1 plus r8 Offset", "Condition_cs_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{cc, r0, r1, plus, r8, Offset}, "cc r0 r1 plus r8 Offset", "Condition_cc_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{mi, r0, r1, plus, r8, Offset}, "mi r0 r1 plus r8 Offset", "Condition_mi_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{pl, r0, r1, plus, r8, Offset}, "pl r0 r1 plus r8 Offset", "Condition_pl_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{vs, r0, r1, plus, r8, Offset}, "vs r0 r1 plus r8 Offset", "Condition_vs_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{vc, r0, r1, plus, r8, Offset}, "vc r0 r1 plus r8 Offset", "Condition_vc_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{hi, r0, r1, plus, r8, Offset}, "hi r0 r1 plus r8 Offset", "Condition_hi_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{ls, r0, r1, plus, r8, Offset}, "ls r0 r1 plus r8 Offset", "Condition_ls_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{ge, r0, r1, plus, r8, Offset}, "ge r0 r1 plus r8 Offset", "Condition_ge_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{lt, r0, r1, plus, r8, Offset}, "lt r0 r1 plus r8 Offset", "Condition_lt_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{gt, r0, r1, plus, r8, Offset}, "gt r0 r1 plus r8 Offset", "Condition_gt_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{le, r0, r1, plus, r8, Offset}, "le r0 r1 plus r8 Offset", "Condition_le_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{al, r0, r1, plus, r8, Offset}, "al r0 r1 plus r8 Offset", "Condition_al_r0_r1_plus_r8_Offset", ARRAY_SIZE(kCondition), kCondition}, {{al, r9, r8, plus, r14, Offset}, "al r9 r8 plus r14 Offset", "PositiveOffset_al_r9_r8_plus_r14_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r3, r8, plus, r9, Offset}, "al r3 r8 plus r9 Offset", "PositiveOffset_al_r3_r8_plus_r9_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r11, r6, plus, r9, Offset}, "al r11 r6 plus r9 Offset", "PositiveOffset_al_r11_r6_plus_r9_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r4, r0, plus, r12, Offset}, "al r4 r0 plus r12 Offset", "PositiveOffset_al_r4_r0_plus_r12_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r8, r3, plus, r14, Offset}, "al r8 r3 plus r14 Offset", "PositiveOffset_al_r8_r3_plus_r14_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r10, r9, plus, r14, Offset}, "al r10 r9 plus r14 Offset", "PositiveOffset_al_r10_r9_plus_r14_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r7, r4, plus, r0, Offset}, "al r7 r4 plus r0 Offset", "PositiveOffset_al_r7_r4_plus_r0_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r4, r5, plus, r0, Offset}, "al r4 r5 plus r0 Offset", "PositiveOffset_al_r4_r5_plus_r0_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r14, r4, plus, r6, Offset}, "al r14 r4 plus r6 Offset", "PositiveOffset_al_r14_r4_plus_r6_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r3, r10, plus, r0, Offset}, "al r3 r10 plus r0 Offset", "PositiveOffset_al_r3_r10_plus_r0_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r8, r3, plus, r7, Offset}, "al r8 r3 plus r7 Offset", "PositiveOffset_al_r8_r3_plus_r7_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r11, r10, plus, r3, Offset}, "al r11 r10 plus r3 Offset", "PositiveOffset_al_r11_r10_plus_r3_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r10, r4, plus, r14, Offset}, "al r10 r4 plus r14 Offset", "PositiveOffset_al_r10_r4_plus_r14_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r0, r3, plus, r9, Offset}, "al r0 r3 plus r9 Offset", "PositiveOffset_al_r0_r3_plus_r9_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r10, r8, plus, r3, Offset}, "al r10 r8 plus r3 Offset", "PositiveOffset_al_r10_r8_plus_r3_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r3, r1, plus, r5, Offset}, "al r3 r1 plus r5 Offset", "PositiveOffset_al_r3_r1_plus_r5_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r6, r14, plus, r12, Offset}, "al r6 r14 plus r12 Offset", "PositiveOffset_al_r6_r14_plus_r12_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r14, r3, plus, r1, Offset}, "al r14 r3 plus r1 Offset", "PositiveOffset_al_r14_r3_plus_r1_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r12, r7, plus, r4, Offset}, "al r12 r7 plus r4 Offset", "PositiveOffset_al_r12_r7_plus_r4_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r0, r12, plus, r11, Offset}, "al r0 r12 plus r11 Offset", "PositiveOffset_al_r0_r12_plus_r11_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r5, r10, plus, r9, Offset}, "al r5 r10 plus r9 Offset", "PositiveOffset_al_r5_r10_plus_r9_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r6, r9, plus, r10, Offset}, "al r6 r9 plus r10 Offset", "PositiveOffset_al_r6_r9_plus_r10_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r1, r2, plus, r14, Offset}, "al r1 r2 plus r14 Offset", "PositiveOffset_al_r1_r2_plus_r14_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r4, r6, plus, r10, Offset}, "al r4 r6 plus r10 Offset", "PositiveOffset_al_r4_r6_plus_r10_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r1, r14, plus, r9, Offset}, "al r1 r14 plus r9 Offset", "PositiveOffset_al_r1_r14_plus_r9_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r14, r4, plus, r8, Offset}, "al r14 r4 plus r8 Offset", "PositiveOffset_al_r14_r4_plus_r8_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r9, r11, plus, r4, Offset}, "al r9 r11 plus r4 Offset", "PositiveOffset_al_r9_r11_plus_r4_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r9, r7, plus, r12, Offset}, "al r9 r7 plus r12 Offset", "PositiveOffset_al_r9_r7_plus_r12_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r8, r6, plus, r11, Offset}, "al r8 r6 plus r11 Offset", "PositiveOffset_al_r8_r6_plus_r11_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r1, r12, plus, r4, Offset}, "al r1 r12 plus r4 Offset", "PositiveOffset_al_r1_r12_plus_r4_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r3, r7, plus, r10, Offset}, "al r3 r7 plus r10 Offset", "PositiveOffset_al_r3_r7_plus_r10_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r11, r4, plus, r7, Offset}, "al r11 r4 plus r7 Offset", "PositiveOffset_al_r11_r4_plus_r7_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r3, r7, plus, r0, Offset}, "al r3 r7 plus r0 Offset", "PositiveOffset_al_r3_r7_plus_r0_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r4, r0, plus, r2, Offset}, "al r4 r0 plus r2 Offset", "PositiveOffset_al_r4_r0_plus_r2_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r5, r14, plus, r6, Offset}, "al r5 r14 plus r6 Offset", "PositiveOffset_al_r5_r14_plus_r6_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r6, r14, plus, r9, Offset}, "al r6 r14 plus r9 Offset", "PositiveOffset_al_r6_r14_plus_r9_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r2, r9, plus, r6, Offset}, "al r2 r9 plus r6 Offset", "PositiveOffset_al_r2_r9_plus_r6_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r1, r3, plus, r4, Offset}, "al r1 r3 plus r4 Offset", "PositiveOffset_al_r1_r3_plus_r4_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r5, r11, plus, r8, Offset}, "al r5 r11 plus r8 Offset", "PositiveOffset_al_r5_r11_plus_r8_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r11, r9, plus, r3, Offset}, "al r11 r9 plus r3 Offset", "PositiveOffset_al_r11_r9_plus_r3_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r4, r12, plus, r5, Offset}, "al r4 r12 plus r5 Offset", "PositiveOffset_al_r4_r12_plus_r5_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r7, r8, plus, r12, Offset}, "al r7 r8 plus r12 Offset", "PositiveOffset_al_r7_r8_plus_r12_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r10, r14, plus, r6, Offset}, "al r10 r14 plus r6 Offset", "PositiveOffset_al_r10_r14_plus_r6_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r1, r6, plus, r10, Offset}, "al r1 r6 plus r10 Offset", "PositiveOffset_al_r1_r6_plus_r10_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r2, r6, plus, r3, Offset}, "al r2 r6 plus r3 Offset", "PositiveOffset_al_r2_r6_plus_r3_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r9, r10, plus, r6, Offset}, "al r9 r10 plus r6 Offset", "PositiveOffset_al_r9_r10_plus_r6_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r8, r3, plus, r10, Offset}, "al r8 r3 plus r10 Offset", "PositiveOffset_al_r8_r3_plus_r10_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r5, r9, plus, r12, Offset}, "al r5 r9 plus r12 Offset", "PositiveOffset_al_r5_r9_plus_r12_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r3, r0, plus, r12, Offset}, "al r3 r0 plus r12 Offset", "PositiveOffset_al_r3_r0_plus_r12_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r3, r8, plus, r2, Offset}, "al r3 r8 plus r2 Offset", "PositiveOffset_al_r3_r8_plus_r2_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r9, r5, plus, r6, Offset}, "al r9 r5 plus r6 Offset", "PositiveOffset_al_r9_r5_plus_r6_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r3, r0, plus, r9, Offset}, "al r3 r0 plus r9 Offset", "PositiveOffset_al_r3_r0_plus_r9_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r7, r12, plus, r9, Offset}, "al r7 r12 plus r9 Offset", "PositiveOffset_al_r7_r12_plus_r9_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r10, r3, plus, r0, Offset}, "al r10 r3 plus r0 Offset", "PositiveOffset_al_r10_r3_plus_r0_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r1, r14, plus, r11, Offset}, "al r1 r14 plus r11 Offset", "PositiveOffset_al_r1_r14_plus_r11_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r11, r10, plus, r6, Offset}, "al r11 r10 plus r6 Offset", "PositiveOffset_al_r11_r10_plus_r6_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r9, r11, plus, r6, Offset}, "al r9 r11 plus r6 Offset", "PositiveOffset_al_r9_r11_plus_r6_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r4, r0, plus, r5, Offset}, "al r4 r0 plus r5 Offset", "PositiveOffset_al_r4_r0_plus_r5_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r10, r14, plus, r4, Offset}, "al r10 r14 plus r4 Offset", "PositiveOffset_al_r10_r14_plus_r4_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r11, r7, plus, r14, Offset}, "al r11 r7 plus r14 Offset", "PositiveOffset_al_r11_r7_plus_r14_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r8, r2, plus, r9, Offset}, "al r8 r2 plus r9 Offset", "PositiveOffset_al_r8_r2_plus_r9_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r7, r2, plus, r11, Offset}, "al r7 r2 plus r11 Offset", "PositiveOffset_al_r7_r2_plus_r11_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r12, r6, plus, r14, Offset}, "al r12 r6 plus r14 Offset", "PositiveOffset_al_r12_r6_plus_r14_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r3, r2, plus, r1, Offset}, "al r3 r2 plus r1 Offset", "PositiveOffset_al_r3_r2_plus_r1_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r14, r5, plus, r12, Offset}, "al r14 r5 plus r12 Offset", "PositiveOffset_al_r14_r5_plus_r12_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r4, r9, plus, r2, Offset}, "al r4 r9 plus r2 Offset", "PositiveOffset_al_r4_r9_plus_r2_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r5, r4, plus, r7, Offset}, "al r5 r4 plus r7 Offset", "PositiveOffset_al_r5_r4_plus_r7_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r7, r2, plus, r14, Offset}, "al r7 r2 plus r14 Offset", "PositiveOffset_al_r7_r2_plus_r14_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r4, r8, plus, r2, Offset}, "al r4 r8 plus r2 Offset", "PositiveOffset_al_r4_r8_plus_r2_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r7, r5, plus, r6, Offset}, "al r7 r5 plus r6 Offset", "PositiveOffset_al_r7_r5_plus_r6_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r11, r8, plus, r6, Offset}, "al r11 r8 plus r6 Offset", "PositiveOffset_al_r11_r8_plus_r6_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r8, r0, plus, r1, Offset}, "al r8 r0 plus r1 Offset", "PositiveOffset_al_r8_r0_plus_r1_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r4, r9, plus, r8, Offset}, "al r4 r9 plus r8 Offset", "PositiveOffset_al_r4_r9_plus_r8_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r7, r1, plus, r12, Offset}, "al r7 r1 plus r12 Offset", "PositiveOffset_al_r7_r1_plus_r12_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r12, r14, plus, r11, Offset}, "al r12 r14 plus r11 Offset", "PositiveOffset_al_r12_r14_plus_r11_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r1, r6, plus, r5, Offset}, "al r1 r6 plus r5 Offset", "PositiveOffset_al_r1_r6_plus_r5_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r9, r10, plus, r1, Offset}, "al r9 r10 plus r1 Offset", "PositiveOffset_al_r9_r10_plus_r1_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r8, r14, plus, r10, Offset}, "al r8 r14 plus r10 Offset", "PositiveOffset_al_r8_r14_plus_r10_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r12, r10, plus, r0, Offset}, "al r12 r10 plus r0 Offset", "PositiveOffset_al_r12_r10_plus_r0_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r6, r2, plus, r10, Offset}, "al r6 r2 plus r10 Offset", "PositiveOffset_al_r6_r2_plus_r10_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r9, r1, plus, r5, Offset}, "al r9 r1 plus r5 Offset", "PositiveOffset_al_r9_r1_plus_r5_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r4, r6, plus, r5, Offset}, "al r4 r6 plus r5 Offset", "PositiveOffset_al_r4_r6_plus_r5_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r12, r5, plus, r11, Offset}, "al r12 r5 plus r11 Offset", "PositiveOffset_al_r12_r5_plus_r11_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r0, r2, plus, r1, Offset}, "al r0 r2 plus r1 Offset", "PositiveOffset_al_r0_r2_plus_r1_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r9, r1, plus, r8, Offset}, "al r9 r1 plus r8 Offset", "PositiveOffset_al_r9_r1_plus_r8_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r6, r4, plus, r9, Offset}, "al r6 r4 plus r9 Offset", "PositiveOffset_al_r6_r4_plus_r9_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r11, r2, plus, r7, Offset}, "al r11 r2 plus r7 Offset", "PositiveOffset_al_r11_r2_plus_r7_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r11, r4, plus, r0, Offset}, "al r11 r4 plus r0 Offset", "PositiveOffset_al_r11_r4_plus_r0_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r2, r11, plus, r7, Offset}, "al r2 r11 plus r7 Offset", "PositiveOffset_al_r2_r11_plus_r7_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r3, r7, plus, r5, Offset}, "al r3 r7 plus r5 Offset", "PositiveOffset_al_r3_r7_plus_r5_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r1, r0, plus, r4, Offset}, "al r1 r0 plus r4 Offset", "PositiveOffset_al_r1_r0_plus_r4_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r10, r12, plus, r0, Offset}, "al r10 r12 plus r0 Offset", "PositiveOffset_al_r10_r12_plus_r0_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r5, r0, plus, r11, Offset}, "al r5 r0 plus r11 Offset", "PositiveOffset_al_r5_r0_plus_r11_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r3, r5, plus, r7, Offset}, "al r3 r5 plus r7 Offset", "PositiveOffset_al_r3_r5_plus_r7_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r2, r14, plus, r4, Offset}, "al r2 r14 plus r4 Offset", "PositiveOffset_al_r2_r14_plus_r4_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r3, r12, plus, r10, Offset}, "al r3 r12 plus r10 Offset", "PositiveOffset_al_r3_r12_plus_r10_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r0, r11, plus, r1, Offset}, "al r0 r11 plus r1 Offset", "PositiveOffset_al_r0_r11_plus_r1_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r2, r14, plus, r6, Offset}, "al r2 r14 plus r6 Offset", "PositiveOffset_al_r2_r14_plus_r6_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r0, r10, plus, r11, Offset}, "al r0 r10 plus r11 Offset", "PositiveOffset_al_r0_r10_plus_r11_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r14, r10, plus, r2, Offset}, "al r14 r10 plus r2 Offset", "PositiveOffset_al_r14_r10_plus_r2_Offset", ARRAY_SIZE(kPositiveOffset), kPositiveOffset}, {{al, r9, r7, minus, r8, Offset}, "al r9 r7 minus r8 Offset", "NegativeOffset_al_r9_r7_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r0, r6, minus, r2, Offset}, "al r0 r6 minus r2 Offset", "NegativeOffset_al_r0_r6_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r3, r0, minus, r7, Offset}, "al r3 r0 minus r7 Offset", "NegativeOffset_al_r3_r0_minus_r7_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r3, r0, minus, r2, Offset}, "al r3 r0 minus r2 Offset", "NegativeOffset_al_r3_r0_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r7, r10, minus, r0, Offset}, "al r7 r10 minus r0 Offset", "NegativeOffset_al_r7_r10_minus_r0_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r1, r11, minus, r10, Offset}, "al r1 r11 minus r10 Offset", "NegativeOffset_al_r1_r11_minus_r10_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r8, r7, minus, r3, Offset}, "al r8 r7 minus r3 Offset", "NegativeOffset_al_r8_r7_minus_r3_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r6, r5, minus, r4, Offset}, "al r6 r5 minus r4 Offset", "NegativeOffset_al_r6_r5_minus_r4_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r3, r10, minus, r6, Offset}, "al r3 r10 minus r6 Offset", "NegativeOffset_al_r3_r10_minus_r6_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r3, r14, minus, r0, Offset}, "al r3 r14 minus r0 Offset", "NegativeOffset_al_r3_r14_minus_r0_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r10, r4, minus, r5, Offset}, "al r10 r4 minus r5 Offset", "NegativeOffset_al_r10_r4_minus_r5_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r10, r0, minus, r11, Offset}, "al r10 r0 minus r11 Offset", "NegativeOffset_al_r10_r0_minus_r11_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r7, r0, minus, r10, Offset}, "al r7 r0 minus r10 Offset", "NegativeOffset_al_r7_r0_minus_r10_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r9, r4, minus, r10, Offset}, "al r9 r4 minus r10 Offset", "NegativeOffset_al_r9_r4_minus_r10_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r6, r3, minus, r10, Offset}, "al r6 r3 minus r10 Offset", "NegativeOffset_al_r6_r3_minus_r10_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r14, r2, minus, r8, Offset}, "al r14 r2 minus r8 Offset", "NegativeOffset_al_r14_r2_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r14, r8, minus, r1, Offset}, "al r14 r8 minus r1 Offset", "NegativeOffset_al_r14_r8_minus_r1_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r9, r6, minus, r11, Offset}, "al r9 r6 minus r11 Offset", "NegativeOffset_al_r9_r6_minus_r11_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r11, r7, minus, r6, Offset}, "al r11 r7 minus r6 Offset", "NegativeOffset_al_r11_r7_minus_r6_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r8, r5, minus, r7, Offset}, "al r8 r5 minus r7 Offset", "NegativeOffset_al_r8_r5_minus_r7_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r1, r2, minus, r10, Offset}, "al r1 r2 minus r10 Offset", "NegativeOffset_al_r1_r2_minus_r10_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r0, r12, minus, r5, Offset}, "al r0 r12 minus r5 Offset", "NegativeOffset_al_r0_r12_minus_r5_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r7, r8, minus, r1, Offset}, "al r7 r8 minus r1 Offset", "NegativeOffset_al_r7_r8_minus_r1_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r4, r12, minus, r6, Offset}, "al r4 r12 minus r6 Offset", "NegativeOffset_al_r4_r12_minus_r6_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r2, r11, minus, r9, Offset}, "al r2 r11 minus r9 Offset", "NegativeOffset_al_r2_r11_minus_r9_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r4, r14, minus, r11, Offset}, "al r4 r14 minus r11 Offset", "NegativeOffset_al_r4_r14_minus_r11_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r8, r5, minus, r6, Offset}, "al r8 r5 minus r6 Offset", "NegativeOffset_al_r8_r5_minus_r6_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r10, r11, minus, r8, Offset}, "al r10 r11 minus r8 Offset", "NegativeOffset_al_r10_r11_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r14, r4, minus, r2, Offset}, "al r14 r4 minus r2 Offset", "NegativeOffset_al_r14_r4_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r2, r4, minus, r12, Offset}, "al r2 r4 minus r12 Offset", "NegativeOffset_al_r2_r4_minus_r12_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r0, r4, minus, r8, Offset}, "al r0 r4 minus r8 Offset", "NegativeOffset_al_r0_r4_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r14, r5, minus, r0, Offset}, "al r14 r5 minus r0 Offset", "NegativeOffset_al_r14_r5_minus_r0_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r8, r4, minus, r9, Offset}, "al r8 r4 minus r9 Offset", "NegativeOffset_al_r8_r4_minus_r9_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r7, r11, minus, r2, Offset}, "al r7 r11 minus r2 Offset", "NegativeOffset_al_r7_r11_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r7, r5, minus, r10, Offset}, "al r7 r5 minus r10 Offset", "NegativeOffset_al_r7_r5_minus_r10_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r5, r0, minus, r14, Offset}, "al r5 r0 minus r14 Offset", "NegativeOffset_al_r5_r0_minus_r14_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r1, r10, minus, r12, Offset}, "al r1 r10 minus r12 Offset", "NegativeOffset_al_r1_r10_minus_r12_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r0, r14, minus, r10, Offset}, "al r0 r14 minus r10 Offset", "NegativeOffset_al_r0_r14_minus_r10_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r5, r10, minus, r4, Offset}, "al r5 r10 minus r4 Offset", "NegativeOffset_al_r5_r10_minus_r4_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r8, r5, minus, r4, Offset}, "al r8 r5 minus r4 Offset", "NegativeOffset_al_r8_r5_minus_r4_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r9, r5, minus, r3, Offset}, "al r9 r5 minus r3 Offset", "NegativeOffset_al_r9_r5_minus_r3_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r9, r3, minus, r11, Offset}, "al r9 r3 minus r11 Offset", "NegativeOffset_al_r9_r3_minus_r11_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r9, r11, minus, r1, Offset}, "al r9 r11 minus r1 Offset", "NegativeOffset_al_r9_r11_minus_r1_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r11, r8, minus, r1, Offset}, "al r11 r8 minus r1 Offset", "NegativeOffset_al_r11_r8_minus_r1_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r5, r12, minus, r14, Offset}, "al r5 r12 minus r14 Offset", "NegativeOffset_al_r5_r12_minus_r14_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r5, r0, minus, r7, Offset}, "al r5 r0 minus r7 Offset", "NegativeOffset_al_r5_r0_minus_r7_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r1, r3, minus, r6, Offset}, "al r1 r3 minus r6 Offset", "NegativeOffset_al_r1_r3_minus_r6_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r12, r5, minus, r14, Offset}, "al r12 r5 minus r14 Offset", "NegativeOffset_al_r12_r5_minus_r14_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r7, r9, minus, r6, Offset}, "al r7 r9 minus r6 Offset", "NegativeOffset_al_r7_r9_minus_r6_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r10, r0, minus, r2, Offset}, "al r10 r0 minus r2 Offset", "NegativeOffset_al_r10_r0_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r8, r10, minus, r6, Offset}, "al r8 r10 minus r6 Offset", "NegativeOffset_al_r8_r10_minus_r6_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r4, r9, minus, r2, Offset}, "al r4 r9 minus r2 Offset", "NegativeOffset_al_r4_r9_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r11, r1, minus, r14, Offset}, "al r11 r1 minus r14 Offset", "NegativeOffset_al_r11_r1_minus_r14_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r10, r11, minus, r2, Offset}, "al r10 r11 minus r2 Offset", "NegativeOffset_al_r10_r11_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r5, r7, minus, r14, Offset}, "al r5 r7 minus r14 Offset", "NegativeOffset_al_r5_r7_minus_r14_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r7, r14, minus, r5, Offset}, "al r7 r14 minus r5 Offset", "NegativeOffset_al_r7_r14_minus_r5_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r14, r11, minus, r10, Offset}, "al r14 r11 minus r10 Offset", "NegativeOffset_al_r14_r11_minus_r10_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r10, r4, minus, r12, Offset}, "al r10 r4 minus r12 Offset", "NegativeOffset_al_r10_r4_minus_r12_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r10, r12, minus, r6, Offset}, "al r10 r12 minus r6 Offset", "NegativeOffset_al_r10_r12_minus_r6_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r8, r11, minus, r9, Offset}, "al r8 r11 minus r9 Offset", "NegativeOffset_al_r8_r11_minus_r9_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r9, r1, minus, r3, Offset}, "al r9 r1 minus r3 Offset", "NegativeOffset_al_r9_r1_minus_r3_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r4, r12, minus, r14, Offset}, "al r4 r12 minus r14 Offset", "NegativeOffset_al_r4_r12_minus_r14_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r8, r11, minus, r1, Offset}, "al r8 r11 minus r1 Offset", "NegativeOffset_al_r8_r11_minus_r1_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r3, r2, minus, r8, Offset}, "al r3 r2 minus r8 Offset", "NegativeOffset_al_r3_r2_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r5, r3, minus, r8, Offset}, "al r5 r3 minus r8 Offset", "NegativeOffset_al_r5_r3_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r9, r7, minus, r0, Offset}, "al r9 r7 minus r0 Offset", "NegativeOffset_al_r9_r7_minus_r0_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r6, r12, minus, r8, Offset}, "al r6 r12 minus r8 Offset", "NegativeOffset_al_r6_r12_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r10, r8, minus, r9, Offset}, "al r10 r8 minus r9 Offset", "NegativeOffset_al_r10_r8_minus_r9_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r11, r0, minus, r3, Offset}, "al r11 r0 minus r3 Offset", "NegativeOffset_al_r11_r0_minus_r3_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r10, r0, minus, r6, Offset}, "al r10 r0 minus r6 Offset", "NegativeOffset_al_r10_r0_minus_r6_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r11, r10, minus, r12, Offset}, "al r11 r10 minus r12 Offset", "NegativeOffset_al_r11_r10_minus_r12_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r0, r1, minus, r2, Offset}, "al r0 r1 minus r2 Offset", "NegativeOffset_al_r0_r1_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r5, r9, minus, r2, Offset}, "al r5 r9 minus r2 Offset", "NegativeOffset_al_r5_r9_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r14, r6, minus, r5, Offset}, "al r14 r6 minus r5 Offset", "NegativeOffset_al_r14_r6_minus_r5_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r6, r9, minus, r1, Offset}, "al r6 r9 minus r1 Offset", "NegativeOffset_al_r6_r9_minus_r1_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r3, r2, minus, r6, Offset}, "al r3 r2 minus r6 Offset", "NegativeOffset_al_r3_r2_minus_r6_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r2, r0, minus, r8, Offset}, "al r2 r0 minus r8 Offset", "NegativeOffset_al_r2_r0_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r11, r0, minus, r8, Offset}, "al r11 r0 minus r8 Offset", "NegativeOffset_al_r11_r0_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r6, r7, minus, r12, Offset}, "al r6 r7 minus r12 Offset", "NegativeOffset_al_r6_r7_minus_r12_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r0, r2, minus, r9, Offset}, "al r0 r2 minus r9 Offset", "NegativeOffset_al_r0_r2_minus_r9_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r1, r10, minus, r8, Offset}, "al r1 r10 minus r8 Offset", "NegativeOffset_al_r1_r10_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r5, r3, minus, r2, Offset}, "al r5 r3 minus r2 Offset", "NegativeOffset_al_r5_r3_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r6, r11, minus, r8, Offset}, "al r6 r11 minus r8 Offset", "NegativeOffset_al_r6_r11_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r6, r11, minus, r9, Offset}, "al r6 r11 minus r9 Offset", "NegativeOffset_al_r6_r11_minus_r9_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r14, r12, minus, r9, Offset}, "al r14 r12 minus r9 Offset", "NegativeOffset_al_r14_r12_minus_r9_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r3, r4, minus, r2, Offset}, "al r3 r4 minus r2 Offset", "NegativeOffset_al_r3_r4_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r7, r3, minus, r8, Offset}, "al r7 r3 minus r8 Offset", "NegativeOffset_al_r7_r3_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r6, r14, minus, r8, Offset}, "al r6 r14 minus r8 Offset", "NegativeOffset_al_r6_r14_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r11, r10, minus, r14, Offset}, "al r11 r10 minus r14 Offset", "NegativeOffset_al_r11_r10_minus_r14_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r3, r4, minus, r7, Offset}, "al r3 r4 minus r7 Offset", "NegativeOffset_al_r3_r4_minus_r7_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r9, r6, minus, r0, Offset}, "al r9 r6 minus r0 Offset", "NegativeOffset_al_r9_r6_minus_r0_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r10, r3, minus, r2, Offset}, "al r10 r3 minus r2 Offset", "NegativeOffset_al_r10_r3_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r10, r5, minus, r1, Offset}, "al r10 r5 minus r1 Offset", "NegativeOffset_al_r10_r5_minus_r1_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r10, r11, minus, r9, Offset}, "al r10 r11 minus r9 Offset", "NegativeOffset_al_r10_r11_minus_r9_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r3, r1, minus, r8, Offset}, "al r3 r1 minus r8 Offset", "NegativeOffset_al_r3_r1_minus_r8_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r6, r1, minus, r2, Offset}, "al r6 r1 minus r2 Offset", "NegativeOffset_al_r6_r1_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r7, r6, minus, r14, Offset}, "al r7 r6 minus r14 Offset", "NegativeOffset_al_r7_r6_minus_r14_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r3, r9, minus, r5, Offset}, "al r3 r9 minus r5 Offset", "NegativeOffset_al_r3_r9_minus_r5_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r10, r7, minus, r2, Offset}, "al r10 r7 minus r2 Offset", "NegativeOffset_al_r10_r7_minus_r2_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r12, r9, minus, r7, Offset}, "al r12 r9 minus r7 Offset", "NegativeOffset_al_r12_r9_minus_r7_Offset", ARRAY_SIZE(kNegativeOffset), kNegativeOffset}, {{al, r8, r11, plus, r4, PostIndex}, "al r8 r11 plus r4 PostIndex", "PositivePostIndex_al_r8_r11_plus_r4_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r4, r1, plus, r2, PostIndex}, "al r4 r1 plus r2 PostIndex", "PositivePostIndex_al_r4_r1_plus_r2_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r0, r7, plus, r5, PostIndex}, "al r0 r7 plus r5 PostIndex", "PositivePostIndex_al_r0_r7_plus_r5_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r3, r6, plus, r10, PostIndex}, "al r3 r6 plus r10 PostIndex", "PositivePostIndex_al_r3_r6_plus_r10_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r7, r3, plus, r6, PostIndex}, "al r7 r3 plus r6 PostIndex", "PositivePostIndex_al_r7_r3_plus_r6_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r14, r0, plus, r3, PostIndex}, "al r14 r0 plus r3 PostIndex", "PositivePostIndex_al_r14_r0_plus_r3_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r11, r0, plus, r2, PostIndex}, "al r11 r0 plus r2 PostIndex", "PositivePostIndex_al_r11_r0_plus_r2_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r11, r14, plus, r3, PostIndex}, "al r11 r14 plus r3 PostIndex", "PositivePostIndex_al_r11_r14_plus_r3_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r10, r3, plus, r14, PostIndex}, "al r10 r3 plus r14 PostIndex", "PositivePostIndex_al_r10_r3_plus_r14_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r3, r10, plus, r4, PostIndex}, "al r3 r10 plus r4 PostIndex", "PositivePostIndex_al_r3_r10_plus_r4_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r14, r0, plus, r11, PostIndex}, "al r14 r0 plus r11 PostIndex", "PositivePostIndex_al_r14_r0_plus_r11_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r10, r1, plus, r14, PostIndex}, "al r10 r1 plus r14 PostIndex", "PositivePostIndex_al_r10_r1_plus_r14_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r7, r2, plus, r10, PostIndex}, "al r7 r2 plus r10 PostIndex", "PositivePostIndex_al_r7_r2_plus_r10_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r4, r11, plus, r9, PostIndex}, "al r4 r11 plus r9 PostIndex", "PositivePostIndex_al_r4_r11_plus_r9_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r6, r7, plus, r8, PostIndex}, "al r6 r7 plus r8 PostIndex", "PositivePostIndex_al_r6_r7_plus_r8_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r3, r7, plus, r6, PostIndex}, "al r3 r7 plus r6 PostIndex", "PositivePostIndex_al_r3_r7_plus_r6_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r1, r9, plus, r5, PostIndex}, "al r1 r9 plus r5 PostIndex", "PositivePostIndex_al_r1_r9_plus_r5_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r5, r10, plus, r2, PostIndex}, "al r5 r10 plus r2 PostIndex", "PositivePostIndex_al_r5_r10_plus_r2_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r9, r3, plus, r5, PostIndex}, "al r9 r3 plus r5 PostIndex", "PositivePostIndex_al_r9_r3_plus_r5_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r2, r11, plus, r14, PostIndex}, "al r2 r11 plus r14 PostIndex", "PositivePostIndex_al_r2_r11_plus_r14_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r14, r5, plus, r3, PostIndex}, "al r14 r5 plus r3 PostIndex", "PositivePostIndex_al_r14_r5_plus_r3_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r0, r1, plus, r4, PostIndex}, "al r0 r1 plus r4 PostIndex", "PositivePostIndex_al_r0_r1_plus_r4_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r5, r14, plus, r8, PostIndex}, "al r5 r14 plus r8 PostIndex", "PositivePostIndex_al_r5_r14_plus_r8_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r0, r1, plus, r9, PostIndex}, "al r0 r1 plus r9 PostIndex", "PositivePostIndex_al_r0_r1_plus_r9_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r8, r12, plus, r5, PostIndex}, "al r8 r12 plus r5 PostIndex", "PositivePostIndex_al_r8_r12_plus_r5_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r6, r3, plus, r5, PostIndex}, "al r6 r3 plus r5 PostIndex", "PositivePostIndex_al_r6_r3_plus_r5_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r3, r10, plus, r8, PostIndex}, "al r3 r10 plus r8 PostIndex", "PositivePostIndex_al_r3_r10_plus_r8_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r9, r6, plus, r12, PostIndex}, "al r9 r6 plus r12 PostIndex", "PositivePostIndex_al_r9_r6_plus_r12_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r10, r5, plus, r3, PostIndex}, "al r10 r5 plus r3 PostIndex", "PositivePostIndex_al_r10_r5_plus_r3_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r3, r10, plus, r6, PostIndex}, "al r3 r10 plus r6 PostIndex", "PositivePostIndex_al_r3_r10_plus_r6_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r4, r7, plus, r2, PostIndex}, "al r4 r7 plus r2 PostIndex", "PositivePostIndex_al_r4_r7_plus_r2_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r14, r12, plus, r5, PostIndex}, "al r14 r12 plus r5 PostIndex", "PositivePostIndex_al_r14_r12_plus_r5_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r1, r8, plus, r7, PostIndex}, "al r1 r8 plus r7 PostIndex", "PositivePostIndex_al_r1_r8_plus_r7_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r5, r7, plus, r8, PostIndex}, "al r5 r7 plus r8 PostIndex", "PositivePostIndex_al_r5_r7_plus_r8_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r0, r6, plus, r11, PostIndex}, "al r0 r6 plus r11 PostIndex", "PositivePostIndex_al_r0_r6_plus_r11_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r5, r6, plus, r7, PostIndex}, "al r5 r6 plus r7 PostIndex", "PositivePostIndex_al_r5_r6_plus_r7_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r7, r2, plus, r6, PostIndex}, "al r7 r2 plus r6 PostIndex", "PositivePostIndex_al_r7_r2_plus_r6_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r6, r8, plus, r5, PostIndex}, "al r6 r8 plus r5 PostIndex", "PositivePostIndex_al_r6_r8_plus_r5_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r7, r4, plus, r0, PostIndex}, "al r7 r4 plus r0 PostIndex", "PositivePostIndex_al_r7_r4_plus_r0_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r2, r8, plus, r3, PostIndex}, "al r2 r8 plus r3 PostIndex", "PositivePostIndex_al_r2_r8_plus_r3_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r3, r2, plus, r6, PostIndex}, "al r3 r2 plus r6 PostIndex", "PositivePostIndex_al_r3_r2_plus_r6_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r7, r6, plus, r2, PostIndex}, "al r7 r6 plus r2 PostIndex", "PositivePostIndex_al_r7_r6_plus_r2_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r0, r4, plus, r10, PostIndex}, "al r0 r4 plus r10 PostIndex", "PositivePostIndex_al_r0_r4_plus_r10_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r9, r14, plus, r6, PostIndex}, "al r9 r14 plus r6 PostIndex", "PositivePostIndex_al_r9_r14_plus_r6_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r0, r3, plus, r12, PostIndex}, "al r0 r3 plus r12 PostIndex", "PositivePostIndex_al_r0_r3_plus_r12_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r8, r7, plus, r5, PostIndex}, "al r8 r7 plus r5 PostIndex", "PositivePostIndex_al_r8_r7_plus_r5_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r5, r14, plus, r2, PostIndex}, "al r5 r14 plus r2 PostIndex", "PositivePostIndex_al_r5_r14_plus_r2_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r7, r6, plus, r4, PostIndex}, "al r7 r6 plus r4 PostIndex", "PositivePostIndex_al_r7_r6_plus_r4_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r1, r14, plus, r12, PostIndex}, "al r1 r14 plus r12 PostIndex", "PositivePostIndex_al_r1_r14_plus_r12_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r11, r1, plus, r0, PostIndex}, "al r11 r1 plus r0 PostIndex", "PositivePostIndex_al_r11_r1_plus_r0_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r4, r2, plus, r12, PostIndex}, "al r4 r2 plus r12 PostIndex", "PositivePostIndex_al_r4_r2_plus_r12_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r0, r1, plus, r3, PostIndex}, "al r0 r1 plus r3 PostIndex", "PositivePostIndex_al_r0_r1_plus_r3_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r4, r0, plus, r5, PostIndex}, "al r4 r0 plus r5 PostIndex", "PositivePostIndex_al_r4_r0_plus_r5_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r8, r4, plus, r0, PostIndex}, "al r8 r4 plus r0 PostIndex", "PositivePostIndex_al_r8_r4_plus_r0_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r1, r7, plus, r11, PostIndex}, "al r1 r7 plus r11 PostIndex", "PositivePostIndex_al_r1_r7_plus_r11_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r9, r0, plus, r14, PostIndex}, "al r9 r0 plus r14 PostIndex", "PositivePostIndex_al_r9_r0_plus_r14_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r8, r9, plus, r14, PostIndex}, "al r8 r9 plus r14 PostIndex", "PositivePostIndex_al_r8_r9_plus_r14_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r10, r14, plus, r12, PostIndex}, "al r10 r14 plus r12 PostIndex", "PositivePostIndex_al_r10_r14_plus_r12_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r8, r9, plus, r10, PostIndex}, "al r8 r9 plus r10 PostIndex", "PositivePostIndex_al_r8_r9_plus_r10_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r14, r8, plus, r11, PostIndex}, "al r14 r8 plus r11 PostIndex", "PositivePostIndex_al_r14_r8_plus_r11_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r4, r10, plus, r2, PostIndex}, "al r4 r10 plus r2 PostIndex", "PositivePostIndex_al_r4_r10_plus_r2_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r7, r8, plus, r10, PostIndex}, "al r7 r8 plus r10 PostIndex", "PositivePostIndex_al_r7_r8_plus_r10_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r11, r4, plus, r7, PostIndex}, "al r11 r4 plus r7 PostIndex", "PositivePostIndex_al_r11_r4_plus_r7_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r8, r6, plus, r1, PostIndex}, "al r8 r6 plus r1 PostIndex", "PositivePostIndex_al_r8_r6_plus_r1_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r0, r5, plus, r12, PostIndex}, "al r0 r5 plus r12 PostIndex", "PositivePostIndex_al_r0_r5_plus_r12_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r14, r11, plus, r5, PostIndex}, "al r14 r11 plus r5 PostIndex", "PositivePostIndex_al_r14_r11_plus_r5_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r12, r7, plus, r3, PostIndex}, "al r12 r7 plus r3 PostIndex", "PositivePostIndex_al_r12_r7_plus_r3_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r6, r4, plus, r8, PostIndex}, "al r6 r4 plus r8 PostIndex", "PositivePostIndex_al_r6_r4_plus_r8_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r14, r3, plus, r2, PostIndex}, "al r14 r3 plus r2 PostIndex", "PositivePostIndex_al_r14_r3_plus_r2_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r7, r6, plus, r1, PostIndex}, "al r7 r6 plus r1 PostIndex", "PositivePostIndex_al_r7_r6_plus_r1_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r7, r14, plus, r12, PostIndex}, "al r7 r14 plus r12 PostIndex", "PositivePostIndex_al_r7_r14_plus_r12_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r8, r7, plus, r14, PostIndex}, "al r8 r7 plus r14 PostIndex", "PositivePostIndex_al_r8_r7_plus_r14_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r3, r11, plus, r5, PostIndex}, "al r3 r11 plus r5 PostIndex", "PositivePostIndex_al_r3_r11_plus_r5_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r8, r2, plus, r9, PostIndex}, "al r8 r2 plus r9 PostIndex", "PositivePostIndex_al_r8_r2_plus_r9_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r8, r2, plus, r0, PostIndex}, "al r8 r2 plus r0 PostIndex", "PositivePostIndex_al_r8_r2_plus_r0_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r10, r9, plus, r4, PostIndex}, "al r10 r9 plus r4 PostIndex", "PositivePostIndex_al_r10_r9_plus_r4_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r1, r5, plus, r9, PostIndex}, "al r1 r5 plus r9 PostIndex", "PositivePostIndex_al_r1_r5_plus_r9_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r14, r7, plus, r2, PostIndex}, "al r14 r7 plus r2 PostIndex", "PositivePostIndex_al_r14_r7_plus_r2_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r2, r1, plus, r9, PostIndex}, "al r2 r1 plus r9 PostIndex", "PositivePostIndex_al_r2_r1_plus_r9_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r9, r3, plus, r2, PostIndex}, "al r9 r3 plus r2 PostIndex", "PositivePostIndex_al_r9_r3_plus_r2_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r14, r7, plus, r0, PostIndex}, "al r14 r7 plus r0 PostIndex", "PositivePostIndex_al_r14_r7_plus_r0_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r0, r14, plus, r5, PostIndex}, "al r0 r14 plus r5 PostIndex", "PositivePostIndex_al_r0_r14_plus_r5_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r7, r4, plus, r12, PostIndex}, "al r7 r4 plus r12 PostIndex", "PositivePostIndex_al_r7_r4_plus_r12_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r4, r10, plus, r7, PostIndex}, "al r4 r10 plus r7 PostIndex", "PositivePostIndex_al_r4_r10_plus_r7_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r10, r4, plus, r7, PostIndex}, "al r10 r4 plus r7 PostIndex", "PositivePostIndex_al_r10_r4_plus_r7_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r8, r4, plus, r2, PostIndex}, "al r8 r4 plus r2 PostIndex", "PositivePostIndex_al_r8_r4_plus_r2_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r0, r3, plus, r6, PostIndex}, "al r0 r3 plus r6 PostIndex", "PositivePostIndex_al_r0_r3_plus_r6_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r2, r8, plus, r11, PostIndex}, "al r2 r8 plus r11 PostIndex", "PositivePostIndex_al_r2_r8_plus_r11_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r11, r9, plus, r7, PostIndex}, "al r11 r9 plus r7 PostIndex", "PositivePostIndex_al_r11_r9_plus_r7_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r5, r2, plus, r10, PostIndex}, "al r5 r2 plus r10 PostIndex", "PositivePostIndex_al_r5_r2_plus_r10_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r6, r12, plus, r7, PostIndex}, "al r6 r12 plus r7 PostIndex", "PositivePostIndex_al_r6_r12_plus_r7_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r12, r11, plus, r0, PostIndex}, "al r12 r11 plus r0 PostIndex", "PositivePostIndex_al_r12_r11_plus_r0_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r5, r11, plus, r6, PostIndex}, "al r5 r11 plus r6 PostIndex", "PositivePostIndex_al_r5_r11_plus_r6_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r1, r0, plus, r11, PostIndex}, "al r1 r0 plus r11 PostIndex", "PositivePostIndex_al_r1_r0_plus_r11_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r12, r10, plus, r9, PostIndex}, "al r12 r10 plus r9 PostIndex", "PositivePostIndex_al_r12_r10_plus_r9_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r2, r3, plus, r9, PostIndex}, "al r2 r3 plus r9 PostIndex", "PositivePostIndex_al_r2_r3_plus_r9_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r3, r0, plus, r2, PostIndex}, "al r3 r0 plus r2 PostIndex", "PositivePostIndex_al_r3_r0_plus_r2_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r2, r5, plus, r1, PostIndex}, "al r2 r5 plus r1 PostIndex", "PositivePostIndex_al_r2_r5_plus_r1_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r2, r9, plus, r12, PostIndex}, "al r2 r9 plus r12 PostIndex", "PositivePostIndex_al_r2_r9_plus_r12_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r4, r2, plus, r14, PostIndex}, "al r4 r2 plus r14 PostIndex", "PositivePostIndex_al_r4_r2_plus_r14_PostIndex", ARRAY_SIZE(kPositivePostIndex), kPositivePostIndex}, {{al, r12, r11, minus, r8, PostIndex}, "al r12 r11 minus r8 PostIndex", "NegativePostIndex_al_r12_r11_minus_r8_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r4, r10, minus, r9, PostIndex}, "al r4 r10 minus r9 PostIndex", "NegativePostIndex_al_r4_r10_minus_r9_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r9, r12, minus, r10, PostIndex}, "al r9 r12 minus r10 PostIndex", "NegativePostIndex_al_r9_r12_minus_r10_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r2, r1, minus, r11, PostIndex}, "al r2 r1 minus r11 PostIndex", "NegativePostIndex_al_r2_r1_minus_r11_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r14, r8, minus, r6, PostIndex}, "al r14 r8 minus r6 PostIndex", "NegativePostIndex_al_r14_r8_minus_r6_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r7, r2, minus, r8, PostIndex}, "al r7 r2 minus r8 PostIndex", "NegativePostIndex_al_r7_r2_minus_r8_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r9, r1, minus, r8, PostIndex}, "al r9 r1 minus r8 PostIndex", "NegativePostIndex_al_r9_r1_minus_r8_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r1, r6, minus, r5, PostIndex}, "al r1 r6 minus r5 PostIndex", "NegativePostIndex_al_r1_r6_minus_r5_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r6, r2, minus, r14, PostIndex}, "al r6 r2 minus r14 PostIndex", "NegativePostIndex_al_r6_r2_minus_r14_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r11, r1, minus, r9, PostIndex}, "al r11 r1 minus r9 PostIndex", "NegativePostIndex_al_r11_r1_minus_r9_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r9, r7, minus, r12, PostIndex}, "al r9 r7 minus r12 PostIndex", "NegativePostIndex_al_r9_r7_minus_r12_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r10, r6, minus, r1, PostIndex}, "al r10 r6 minus r1 PostIndex", "NegativePostIndex_al_r10_r6_minus_r1_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r4, r9, minus, r6, PostIndex}, "al r4 r9 minus r6 PostIndex", "NegativePostIndex_al_r4_r9_minus_r6_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r11, r4, minus, r9, PostIndex}, "al r11 r4 minus r9 PostIndex", "NegativePostIndex_al_r11_r4_minus_r9_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r7, r12, minus, r0, PostIndex}, "al r7 r12 minus r0 PostIndex", "NegativePostIndex_al_r7_r12_minus_r0_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r10, r3, minus, r7, PostIndex}, "al r10 r3 minus r7 PostIndex", "NegativePostIndex_al_r10_r3_minus_r7_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r7, r14, minus, r11, PostIndex}, "al r7 r14 minus r11 PostIndex", "NegativePostIndex_al_r7_r14_minus_r11_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r6, r12, minus, r2, PostIndex}, "al r6 r12 minus r2 PostIndex", "NegativePostIndex_al_r6_r12_minus_r2_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r10, r7, minus, r1, PostIndex}, "al r10 r7 minus r1 PostIndex", "NegativePostIndex_al_r10_r7_minus_r1_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r3, r11, minus, r0, PostIndex}, "al r3 r11 minus r0 PostIndex", "NegativePostIndex_al_r3_r11_minus_r0_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r4, r5, minus, r11, PostIndex}, "al r4 r5 minus r11 PostIndex", "NegativePostIndex_al_r4_r5_minus_r11_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r6, r12, minus, r5, PostIndex}, "al r6 r12 minus r5 PostIndex", "NegativePostIndex_al_r6_r12_minus_r5_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r4, r11, minus, r12, PostIndex}, "al r4 r11 minus r12 PostIndex", "NegativePostIndex_al_r4_r11_minus_r12_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r5, minus, r4, PostIndex}, "al r12 r5 minus r4 PostIndex", "NegativePostIndex_al_r12_r5_minus_r4_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r11, r10, minus, r9, PostIndex}, "al r11 r10 minus r9 PostIndex", "NegativePostIndex_al_r11_r10_minus_r9_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r8, r11, minus, r2, PostIndex}, "al r8 r11 minus r2 PostIndex", "NegativePostIndex_al_r8_r11_minus_r2_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r6, r7, minus, r4, PostIndex}, "al r6 r7 minus r4 PostIndex", "NegativePostIndex_al_r6_r7_minus_r4_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r14, r8, minus, r2, PostIndex}, "al r14 r8 minus r2 PostIndex", "NegativePostIndex_al_r14_r8_minus_r2_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r7, r10, minus, r12, PostIndex}, "al r7 r10 minus r12 PostIndex", "NegativePostIndex_al_r7_r10_minus_r12_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r14, r5, minus, r7, PostIndex}, "al r14 r5 minus r7 PostIndex", "NegativePostIndex_al_r14_r5_minus_r7_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r9, r8, minus, r2, PostIndex}, "al r9 r8 minus r2 PostIndex", "NegativePostIndex_al_r9_r8_minus_r2_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r10, r8, minus, r9, PostIndex}, "al r10 r8 minus r9 PostIndex", "NegativePostIndex_al_r10_r8_minus_r9_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r11, r6, minus, r1, PostIndex}, "al r11 r6 minus r1 PostIndex", "NegativePostIndex_al_r11_r6_minus_r1_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r3, r7, minus, r0, PostIndex}, "al r3 r7 minus r0 PostIndex", "NegativePostIndex_al_r3_r7_minus_r0_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r3, r12, minus, r5, PostIndex}, "al r3 r12 minus r5 PostIndex", "NegativePostIndex_al_r3_r12_minus_r5_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r1, minus, r14, PostIndex}, "al r12 r1 minus r14 PostIndex", "NegativePostIndex_al_r12_r1_minus_r14_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r11, r14, minus, r4, PostIndex}, "al r11 r14 minus r4 PostIndex", "NegativePostIndex_al_r11_r14_minus_r4_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r7, r8, minus, r11, PostIndex}, "al r7 r8 minus r11 PostIndex", "NegativePostIndex_al_r7_r8_minus_r11_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r3, r11, minus, r1, PostIndex}, "al r3 r11 minus r1 PostIndex", "NegativePostIndex_al_r3_r11_minus_r1_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r7, minus, r1, PostIndex}, "al r12 r7 minus r1 PostIndex", "NegativePostIndex_al_r12_r7_minus_r1_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r3, r0, minus, r5, PostIndex}, "al r3 r0 minus r5 PostIndex", "NegativePostIndex_al_r3_r0_minus_r5_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r2, r1, minus, r12, PostIndex}, "al r2 r1 minus r12 PostIndex", "NegativePostIndex_al_r2_r1_minus_r12_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r6, r11, minus, r0, PostIndex}, "al r6 r11 minus r0 PostIndex", "NegativePostIndex_al_r6_r11_minus_r0_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r9, r4, minus, r10, PostIndex}, "al r9 r4 minus r10 PostIndex", "NegativePostIndex_al_r9_r4_minus_r10_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r1, r3, minus, r8, PostIndex}, "al r1 r3 minus r8 PostIndex", "NegativePostIndex_al_r1_r3_minus_r8_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r2, r5, minus, r4, PostIndex}, "al r2 r5 minus r4 PostIndex", "NegativePostIndex_al_r2_r5_minus_r4_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r3, minus, r9, PostIndex}, "al r12 r3 minus r9 PostIndex", "NegativePostIndex_al_r12_r3_minus_r9_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r14, r6, minus, r1, PostIndex}, "al r14 r6 minus r1 PostIndex", "NegativePostIndex_al_r14_r6_minus_r1_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r8, r4, minus, r7, PostIndex}, "al r8 r4 minus r7 PostIndex", "NegativePostIndex_al_r8_r4_minus_r7_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r14, r2, minus, r3, PostIndex}, "al r14 r2 minus r3 PostIndex", "NegativePostIndex_al_r14_r2_minus_r3_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r11, r2, minus, r0, PostIndex}, "al r11 r2 minus r0 PostIndex", "NegativePostIndex_al_r11_r2_minus_r0_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r10, r14, minus, r5, PostIndex}, "al r10 r14 minus r5 PostIndex", "NegativePostIndex_al_r10_r14_minus_r5_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r3, r8, minus, r5, PostIndex}, "al r3 r8 minus r5 PostIndex", "NegativePostIndex_al_r3_r8_minus_r5_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r6, r1, minus, r5, PostIndex}, "al r6 r1 minus r5 PostIndex", "NegativePostIndex_al_r6_r1_minus_r5_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r1, r2, minus, r11, PostIndex}, "al r1 r2 minus r11 PostIndex", "NegativePostIndex_al_r1_r2_minus_r11_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r9, minus, r4, PostIndex}, "al r12 r9 minus r4 PostIndex", "NegativePostIndex_al_r12_r9_minus_r4_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r14, r12, minus, r7, PostIndex}, "al r14 r12 minus r7 PostIndex", "NegativePostIndex_al_r14_r12_minus_r7_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r5, r2, minus, r4, PostIndex}, "al r5 r2 minus r4 PostIndex", "NegativePostIndex_al_r5_r2_minus_r4_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r2, r6, minus, r8, PostIndex}, "al r2 r6 minus r8 PostIndex", "NegativePostIndex_al_r2_r6_minus_r8_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r5, r3, minus, r8, PostIndex}, "al r5 r3 minus r8 PostIndex", "NegativePostIndex_al_r5_r3_minus_r8_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r6, r11, minus, r3, PostIndex}, "al r6 r11 minus r3 PostIndex", "NegativePostIndex_al_r6_r11_minus_r3_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r6, minus, r11, PostIndex}, "al r12 r6 minus r11 PostIndex", "NegativePostIndex_al_r12_r6_minus_r11_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r8, r14, minus, r7, PostIndex}, "al r8 r14 minus r7 PostIndex", "NegativePostIndex_al_r8_r14_minus_r7_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r2, r6, minus, r5, PostIndex}, "al r2 r6 minus r5 PostIndex", "NegativePostIndex_al_r2_r6_minus_r5_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r5, minus, r1, PostIndex}, "al r12 r5 minus r1 PostIndex", "NegativePostIndex_al_r12_r5_minus_r1_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r11, r2, minus, r9, PostIndex}, "al r11 r2 minus r9 PostIndex", "NegativePostIndex_al_r11_r2_minus_r9_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r4, minus, r0, PostIndex}, "al r12 r4 minus r0 PostIndex", "NegativePostIndex_al_r12_r4_minus_r0_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r4, r3, minus, r12, PostIndex}, "al r4 r3 minus r12 PostIndex", "NegativePostIndex_al_r4_r3_minus_r12_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r14, r1, minus, r6, PostIndex}, "al r14 r1 minus r6 PostIndex", "NegativePostIndex_al_r14_r1_minus_r6_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r4, minus, r7, PostIndex}, "al r12 r4 minus r7 PostIndex", "NegativePostIndex_al_r12_r4_minus_r7_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r7, minus, r3, PostIndex}, "al r12 r7 minus r3 PostIndex", "NegativePostIndex_al_r12_r7_minus_r3_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r8, r0, minus, r4, PostIndex}, "al r8 r0 minus r4 PostIndex", "NegativePostIndex_al_r8_r0_minus_r4_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r10, r0, minus, r5, PostIndex}, "al r10 r0 minus r5 PostIndex", "NegativePostIndex_al_r10_r0_minus_r5_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r4, r2, minus, r8, PostIndex}, "al r4 r2 minus r8 PostIndex", "NegativePostIndex_al_r4_r2_minus_r8_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r7, r8, minus, r1, PostIndex}, "al r7 r8 minus r1 PostIndex", "NegativePostIndex_al_r7_r8_minus_r1_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r8, r2, minus, r10, PostIndex}, "al r8 r2 minus r10 PostIndex", "NegativePostIndex_al_r8_r2_minus_r10_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r11, r2, minus, r5, PostIndex}, "al r11 r2 minus r5 PostIndex", "NegativePostIndex_al_r11_r2_minus_r5_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r5, r12, minus, r14, PostIndex}, "al r5 r12 minus r14 PostIndex", "NegativePostIndex_al_r5_r12_minus_r14_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r8, r1, minus, r14, PostIndex}, "al r8 r1 minus r14 PostIndex", "NegativePostIndex_al_r8_r1_minus_r14_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r10, r6, minus, r8, PostIndex}, "al r10 r6 minus r8 PostIndex", "NegativePostIndex_al_r10_r6_minus_r8_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r0, r4, minus, r12, PostIndex}, "al r0 r4 minus r12 PostIndex", "NegativePostIndex_al_r0_r4_minus_r12_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r6, r0, minus, r11, PostIndex}, "al r6 r0 minus r11 PostIndex", "NegativePostIndex_al_r6_r0_minus_r11_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r10, r7, minus, r11, PostIndex}, "al r10 r7 minus r11 PostIndex", "NegativePostIndex_al_r10_r7_minus_r11_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r0, r10, minus, r5, PostIndex}, "al r0 r10 minus r5 PostIndex", "NegativePostIndex_al_r0_r10_minus_r5_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r4, r7, minus, r12, PostIndex}, "al r4 r7 minus r12 PostIndex", "NegativePostIndex_al_r4_r7_minus_r12_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r8, r2, minus, r0, PostIndex}, "al r8 r2 minus r0 PostIndex", "NegativePostIndex_al_r8_r2_minus_r0_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r2, r11, minus, r10, PostIndex}, "al r2 r11 minus r10 PostIndex", "NegativePostIndex_al_r2_r11_minus_r10_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r8, r10, minus, r5, PostIndex}, "al r8 r10 minus r5 PostIndex", "NegativePostIndex_al_r8_r10_minus_r5_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r11, r5, minus, r10, PostIndex}, "al r11 r5 minus r10 PostIndex", "NegativePostIndex_al_r11_r5_minus_r10_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r9, r14, minus, r2, PostIndex}, "al r9 r14 minus r2 PostIndex", "NegativePostIndex_al_r9_r14_minus_r2_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r7, r12, minus, r3, PostIndex}, "al r7 r12 minus r3 PostIndex", "NegativePostIndex_al_r7_r12_minus_r3_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r8, minus, r6, PostIndex}, "al r12 r8 minus r6 PostIndex", "NegativePostIndex_al_r12_r8_minus_r6_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r9, r12, minus, r5, PostIndex}, "al r9 r12 minus r5 PostIndex", "NegativePostIndex_al_r9_r12_minus_r5_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r4, r8, minus, r10, PostIndex}, "al r4 r8 minus r10 PostIndex", "NegativePostIndex_al_r4_r8_minus_r10_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r10, r12, minus, r1, PostIndex}, "al r10 r12 minus r1 PostIndex", "NegativePostIndex_al_r10_r12_minus_r1_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r7, minus, r8, PostIndex}, "al r12 r7 minus r8 PostIndex", "NegativePostIndex_al_r12_r7_minus_r8_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r8, r6, minus, r0, PostIndex}, "al r8 r6 minus r0 PostIndex", "NegativePostIndex_al_r8_r6_minus_r0_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r8, r3, minus, r14, PostIndex}, "al r8 r3 minus r14 PostIndex", "NegativePostIndex_al_r8_r3_minus_r14_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r14, minus, r3, PostIndex}, "al r12 r14 minus r3 PostIndex", "NegativePostIndex_al_r12_r14_minus_r3_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r10, r2, minus, r7, PostIndex}, "al r10 r2 minus r7 PostIndex", "NegativePostIndex_al_r10_r2_minus_r7_PostIndex", ARRAY_SIZE(kNegativePostIndex), kNegativePostIndex}, {{al, r12, r9, plus, r0, PreIndex}, "al r12 r9 plus r0 PreIndex", "PositivePreIndex_al_r12_r9_plus_r0_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r0, r4, plus, r11, PreIndex}, "al r0 r4 plus r11 PreIndex", "PositivePreIndex_al_r0_r4_plus_r11_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r14, r8, plus, r7, PreIndex}, "al r14 r8 plus r7 PreIndex", "PositivePreIndex_al_r14_r8_plus_r7_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r2, r1, plus, r8, PreIndex}, "al r2 r1 plus r8 PreIndex", "PositivePreIndex_al_r2_r1_plus_r8_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r7, r9, plus, r5, PreIndex}, "al r7 r9 plus r5 PreIndex", "PositivePreIndex_al_r7_r9_plus_r5_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r11, r12, plus, r3, PreIndex}, "al r11 r12 plus r3 PreIndex", "PositivePreIndex_al_r11_r12_plus_r3_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r8, r1, plus, r6, PreIndex}, "al r8 r1 plus r6 PreIndex", "PositivePreIndex_al_r8_r1_plus_r6_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r9, r10, plus, r8, PreIndex}, "al r9 r10 plus r8 PreIndex", "PositivePreIndex_al_r9_r10_plus_r8_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r12, r1, plus, r0, PreIndex}, "al r12 r1 plus r0 PreIndex", "PositivePreIndex_al_r12_r1_plus_r0_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r10, r7, plus, r3, PreIndex}, "al r10 r7 plus r3 PreIndex", "PositivePreIndex_al_r10_r7_plus_r3_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r9, r0, plus, r2, PreIndex}, "al r9 r0 plus r2 PreIndex", "PositivePreIndex_al_r9_r0_plus_r2_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r9, r5, plus, r3, PreIndex}, "al r9 r5 plus r3 PreIndex", "PositivePreIndex_al_r9_r5_plus_r3_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r6, r0, plus, r8, PreIndex}, "al r6 r0 plus r8 PreIndex", "PositivePreIndex_al_r6_r0_plus_r8_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r3, r4, plus, r8, PreIndex}, "al r3 r4 plus r8 PreIndex", "PositivePreIndex_al_r3_r4_plus_r8_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r1, r7, plus, r6, PreIndex}, "al r1 r7 plus r6 PreIndex", "PositivePreIndex_al_r1_r7_plus_r6_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r2, r8, plus, r7, PreIndex}, "al r2 r8 plus r7 PreIndex", "PositivePreIndex_al_r2_r8_plus_r7_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r10, r11, plus, r0, PreIndex}, "al r10 r11 plus r0 PreIndex", "PositivePreIndex_al_r10_r11_plus_r0_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r10, r9, plus, r11, PreIndex}, "al r10 r9 plus r11 PreIndex", "PositivePreIndex_al_r10_r9_plus_r11_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r9, r7, plus, r11, PreIndex}, "al r9 r7 plus r11 PreIndex", "PositivePreIndex_al_r9_r7_plus_r11_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r11, r0, plus, r7, PreIndex}, "al r11 r0 plus r7 PreIndex", "PositivePreIndex_al_r11_r0_plus_r7_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r9, r0, plus, r4, PreIndex}, "al r9 r0 plus r4 PreIndex", "PositivePreIndex_al_r9_r0_plus_r4_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r6, r1, plus, r3, PreIndex}, "al r6 r1 plus r3 PreIndex", "PositivePreIndex_al_r6_r1_plus_r3_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r0, r11, plus, r1, PreIndex}, "al r0 r11 plus r1 PreIndex", "PositivePreIndex_al_r0_r11_plus_r1_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r5, r10, plus, r7, PreIndex}, "al r5 r10 plus r7 PreIndex", "PositivePreIndex_al_r5_r10_plus_r7_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r3, r2, plus, r10, PreIndex}, "al r3 r2 plus r10 PreIndex", "PositivePreIndex_al_r3_r2_plus_r10_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r8, r2, plus, r0, PreIndex}, "al r8 r2 plus r0 PreIndex", "PositivePreIndex_al_r8_r2_plus_r0_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r3, r0, plus, r9, PreIndex}, "al r3 r0 plus r9 PreIndex", "PositivePreIndex_al_r3_r0_plus_r9_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r2, r4, plus, r7, PreIndex}, "al r2 r4 plus r7 PreIndex", "PositivePreIndex_al_r2_r4_plus_r7_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r14, r1, plus, r6, PreIndex}, "al r14 r1 plus r6 PreIndex", "PositivePreIndex_al_r14_r1_plus_r6_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r9, r8, plus, r14, PreIndex}, "al r9 r8 plus r14 PreIndex", "PositivePreIndex_al_r9_r8_plus_r14_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r14, r5, plus, r1, PreIndex}, "al r14 r5 plus r1 PreIndex", "PositivePreIndex_al_r14_r5_plus_r1_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r5, r14, plus, r12, PreIndex}, "al r5 r14 plus r12 PreIndex", "PositivePreIndex_al_r5_r14_plus_r12_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r0, r8, plus, r14, PreIndex}, "al r0 r8 plus r14 PreIndex", "PositivePreIndex_al_r0_r8_plus_r14_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r2, r3, plus, r10, PreIndex}, "al r2 r3 plus r10 PreIndex", "PositivePreIndex_al_r2_r3_plus_r10_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r2, r10, plus, r11, PreIndex}, "al r2 r10 plus r11 PreIndex", "PositivePreIndex_al_r2_r10_plus_r11_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r7, r9, plus, r14, PreIndex}, "al r7 r9 plus r14 PreIndex", "PositivePreIndex_al_r7_r9_plus_r14_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r1, r10, plus, r12, PreIndex}, "al r1 r10 plus r12 PreIndex", "PositivePreIndex_al_r1_r10_plus_r12_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r1, r10, plus, r0, PreIndex}, "al r1 r10 plus r0 PreIndex", "PositivePreIndex_al_r1_r10_plus_r0_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r12, r11, plus, r9, PreIndex}, "al r12 r11 plus r9 PreIndex", "PositivePreIndex_al_r12_r11_plus_r9_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r0, r5, plus, r8, PreIndex}, "al r0 r5 plus r8 PreIndex", "PositivePreIndex_al_r0_r5_plus_r8_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r2, r4, plus, r8, PreIndex}, "al r2 r4 plus r8 PreIndex", "PositivePreIndex_al_r2_r4_plus_r8_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r14, r11, plus, r12, PreIndex}, "al r14 r11 plus r12 PreIndex", "PositivePreIndex_al_r14_r11_plus_r12_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r4, r5, plus, r3, PreIndex}, "al r4 r5 plus r3 PreIndex", "PositivePreIndex_al_r4_r5_plus_r3_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r1, r6, plus, r12, PreIndex}, "al r1 r6 plus r12 PreIndex", "PositivePreIndex_al_r1_r6_plus_r12_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r4, r8, plus, r3, PreIndex}, "al r4 r8 plus r3 PreIndex", "PositivePreIndex_al_r4_r8_plus_r3_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r0, r14, plus, r12, PreIndex}, "al r0 r14 plus r12 PreIndex", "PositivePreIndex_al_r0_r14_plus_r12_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r0, r11, plus, r9, PreIndex}, "al r0 r11 plus r9 PreIndex", "PositivePreIndex_al_r0_r11_plus_r9_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r11, r10, plus, r2, PreIndex}, "al r11 r10 plus r2 PreIndex", "PositivePreIndex_al_r11_r10_plus_r2_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r8, r0, plus, r12, PreIndex}, "al r8 r0 plus r12 PreIndex", "PositivePreIndex_al_r8_r0_plus_r12_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r0, r10, plus, r7, PreIndex}, "al r0 r10 plus r7 PreIndex", "PositivePreIndex_al_r0_r10_plus_r7_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r2, r6, plus, r9, PreIndex}, "al r2 r6 plus r9 PreIndex", "PositivePreIndex_al_r2_r6_plus_r9_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r7, r9, plus, r0, PreIndex}, "al r7 r9 plus r0 PreIndex", "PositivePreIndex_al_r7_r9_plus_r0_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r11, r2, plus, r4, PreIndex}, "al r11 r2 plus r4 PreIndex", "PositivePreIndex_al_r11_r2_plus_r4_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r2, r3, plus, r4, PreIndex}, "al r2 r3 plus r4 PreIndex", "PositivePreIndex_al_r2_r3_plus_r4_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r0, r14, plus, r11, PreIndex}, "al r0 r14 plus r11 PreIndex", "PositivePreIndex_al_r0_r14_plus_r11_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r7, r5, plus, r0, PreIndex}, "al r7 r5 plus r0 PreIndex", "PositivePreIndex_al_r7_r5_plus_r0_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r6, r12, plus, r9, PreIndex}, "al r6 r12 plus r9 PreIndex", "PositivePreIndex_al_r6_r12_plus_r9_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r8, r11, plus, r10, PreIndex}, "al r8 r11 plus r10 PreIndex", "PositivePreIndex_al_r8_r11_plus_r10_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r5, r14, plus, r2, PreIndex}, "al r5 r14 plus r2 PreIndex", "PositivePreIndex_al_r5_r14_plus_r2_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r4, r7, plus, r5, PreIndex}, "al r4 r7 plus r5 PreIndex", "PositivePreIndex_al_r4_r7_plus_r5_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r14, r8, plus, r10, PreIndex}, "al r14 r8 plus r10 PreIndex", "PositivePreIndex_al_r14_r8_plus_r10_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r8, r1, plus, r9, PreIndex}, "al r8 r1 plus r9 PreIndex", "PositivePreIndex_al_r8_r1_plus_r9_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r4, r9, plus, r1, PreIndex}, "al r4 r9 plus r1 PreIndex", "PositivePreIndex_al_r4_r9_plus_r1_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r8, r5, plus, r11, PreIndex}, "al r8 r5 plus r11 PreIndex", "PositivePreIndex_al_r8_r5_plus_r11_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r0, r7, plus, r5, PreIndex}, "al r0 r7 plus r5 PreIndex", "PositivePreIndex_al_r0_r7_plus_r5_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r8, r3, plus, r11, PreIndex}, "al r8 r3 plus r11 PreIndex", "PositivePreIndex_al_r8_r3_plus_r11_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r12, r8, plus, r6, PreIndex}, "al r12 r8 plus r6 PreIndex", "PositivePreIndex_al_r12_r8_plus_r6_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r5, r0, plus, r12, PreIndex}, "al r5 r0 plus r12 PreIndex", "PositivePreIndex_al_r5_r0_plus_r12_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r12, r2, plus, r8, PreIndex}, "al r12 r2 plus r8 PreIndex", "PositivePreIndex_al_r12_r2_plus_r8_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r7, r4, plus, r5, PreIndex}, "al r7 r4 plus r5 PreIndex", "PositivePreIndex_al_r7_r4_plus_r5_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r4, r12, plus, r3, PreIndex}, "al r4 r12 plus r3 PreIndex", "PositivePreIndex_al_r4_r12_plus_r3_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r7, r11, plus, r1, PreIndex}, "al r7 r11 plus r1 PreIndex", "PositivePreIndex_al_r7_r11_plus_r1_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r6, r14, plus, r3, PreIndex}, "al r6 r14 plus r3 PreIndex", "PositivePreIndex_al_r6_r14_plus_r3_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r5, r9, plus, r10, PreIndex}, "al r5 r9 plus r10 PreIndex", "PositivePreIndex_al_r5_r9_plus_r10_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r6, r11, plus, r12, PreIndex}, "al r6 r11 plus r12 PreIndex", "PositivePreIndex_al_r6_r11_plus_r12_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r12, r7, plus, r4, PreIndex}, "al r12 r7 plus r4 PreIndex", "PositivePreIndex_al_r12_r7_plus_r4_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r9, r10, plus, r0, PreIndex}, "al r9 r10 plus r0 PreIndex", "PositivePreIndex_al_r9_r10_plus_r0_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r12, r11, plus, r10, PreIndex}, "al r12 r11 plus r10 PreIndex", "PositivePreIndex_al_r12_r11_plus_r10_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r6, r11, plus, r3, PreIndex}, "al r6 r11 plus r3 PreIndex", "PositivePreIndex_al_r6_r11_plus_r3_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r9, r8, plus, r6, PreIndex}, "al r9 r8 plus r6 PreIndex", "PositivePreIndex_al_r9_r8_plus_r6_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r11, r7, plus, r8, PreIndex}, "al r11 r7 plus r8 PreIndex", "PositivePreIndex_al_r11_r7_plus_r8_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r2, r11, plus, r7, PreIndex}, "al r2 r11 plus r7 PreIndex", "PositivePreIndex_al_r2_r11_plus_r7_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r6, r7, plus, r2, PreIndex}, "al r6 r7 plus r2 PreIndex", "PositivePreIndex_al_r6_r7_plus_r2_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r8, r5, plus, r4, PreIndex}, "al r8 r5 plus r4 PreIndex", "PositivePreIndex_al_r8_r5_plus_r4_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r0, r4, plus, r6, PreIndex}, "al r0 r4 plus r6 PreIndex", "PositivePreIndex_al_r0_r4_plus_r6_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r11, r14, plus, r1, PreIndex}, "al r11 r14 plus r1 PreIndex", "PositivePreIndex_al_r11_r14_plus_r1_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r7, r3, plus, r12, PreIndex}, "al r7 r3 plus r12 PreIndex", "PositivePreIndex_al_r7_r3_plus_r12_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r4, r7, plus, r12, PreIndex}, "al r4 r7 plus r12 PreIndex", "PositivePreIndex_al_r4_r7_plus_r12_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r6, r14, plus, r0, PreIndex}, "al r6 r14 plus r0 PreIndex", "PositivePreIndex_al_r6_r14_plus_r0_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r11, r5, plus, r7, PreIndex}, "al r11 r5 plus r7 PreIndex", "PositivePreIndex_al_r11_r5_plus_r7_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r12, r14, plus, r2, PreIndex}, "al r12 r14 plus r2 PreIndex", "PositivePreIndex_al_r12_r14_plus_r2_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r10, r14, plus, r2, PreIndex}, "al r10 r14 plus r2 PreIndex", "PositivePreIndex_al_r10_r14_plus_r2_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r5, r2, plus, r3, PreIndex}, "al r5 r2 plus r3 PreIndex", "PositivePreIndex_al_r5_r2_plus_r3_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r8, r6, plus, r7, PreIndex}, "al r8 r6 plus r7 PreIndex", "PositivePreIndex_al_r8_r6_plus_r7_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r1, r2, plus, r4, PreIndex}, "al r1 r2 plus r4 PreIndex", "PositivePreIndex_al_r1_r2_plus_r4_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r2, r6, plus, r5, PreIndex}, "al r2 r6 plus r5 PreIndex", "PositivePreIndex_al_r2_r6_plus_r5_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r11, r7, plus, r2, PreIndex}, "al r11 r7 plus r2 PreIndex", "PositivePreIndex_al_r11_r7_plus_r2_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r4, r10, plus, r3, PreIndex}, "al r4 r10 plus r3 PreIndex", "PositivePreIndex_al_r4_r10_plus_r3_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r1, r8, plus, r4, PreIndex}, "al r1 r8 plus r4 PreIndex", "PositivePreIndex_al_r1_r8_plus_r4_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r14, r2, plus, r6, PreIndex}, "al r14 r2 plus r6 PreIndex", "PositivePreIndex_al_r14_r2_plus_r6_PreIndex", ARRAY_SIZE(kPositivePreIndex), kPositivePreIndex}, {{al, r8, r14, minus, r4, PreIndex}, "al r8 r14 minus r4 PreIndex", "NegativePreIndex_al_r8_r14_minus_r4_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r11, r12, minus, r8, PreIndex}, "al r11 r12 minus r8 PreIndex", "NegativePreIndex_al_r11_r12_minus_r8_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r14, r3, minus, r6, PreIndex}, "al r14 r3 minus r6 PreIndex", "NegativePreIndex_al_r14_r3_minus_r6_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r9, r14, minus, r12, PreIndex}, "al r9 r14 minus r12 PreIndex", "NegativePreIndex_al_r9_r14_minus_r12_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r12, r10, minus, r9, PreIndex}, "al r12 r10 minus r9 PreIndex", "NegativePreIndex_al_r12_r10_minus_r9_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r11, r3, minus, r8, PreIndex}, "al r11 r3 minus r8 PreIndex", "NegativePreIndex_al_r11_r3_minus_r8_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r4, r7, minus, r2, PreIndex}, "al r4 r7 minus r2 PreIndex", "NegativePreIndex_al_r4_r7_minus_r2_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r0, r5, minus, r1, PreIndex}, "al r0 r5 minus r1 PreIndex", "NegativePreIndex_al_r0_r5_minus_r1_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r8, r14, minus, r9, PreIndex}, "al r8 r14 minus r9 PreIndex", "NegativePreIndex_al_r8_r14_minus_r9_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r4, r5, minus, r6, PreIndex}, "al r4 r5 minus r6 PreIndex", "NegativePreIndex_al_r4_r5_minus_r6_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r8, r5, minus, r12, PreIndex}, "al r8 r5 minus r12 PreIndex", "NegativePreIndex_al_r8_r5_minus_r12_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r1, r5, minus, r12, PreIndex}, "al r1 r5 minus r12 PreIndex", "NegativePreIndex_al_r1_r5_minus_r12_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r6, r0, minus, r10, PreIndex}, "al r6 r0 minus r10 PreIndex", "NegativePreIndex_al_r6_r0_minus_r10_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r12, r2, minus, r10, PreIndex}, "al r12 r2 minus r10 PreIndex", "NegativePreIndex_al_r12_r2_minus_r10_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r6, r8, minus, r2, PreIndex}, "al r6 r8 minus r2 PreIndex", "NegativePreIndex_al_r6_r8_minus_r2_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r7, r3, minus, r9, PreIndex}, "al r7 r3 minus r9 PreIndex", "NegativePreIndex_al_r7_r3_minus_r9_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r11, r9, minus, r10, PreIndex}, "al r11 r9 minus r10 PreIndex", "NegativePreIndex_al_r11_r9_minus_r10_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r10, r9, minus, r2, PreIndex}, "al r10 r9 minus r2 PreIndex", "NegativePreIndex_al_r10_r9_minus_r2_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r10, r1, minus, r3, PreIndex}, "al r10 r1 minus r3 PreIndex", "NegativePreIndex_al_r10_r1_minus_r3_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r3, r1, minus, r7, PreIndex}, "al r3 r1 minus r7 PreIndex", "NegativePreIndex_al_r3_r1_minus_r7_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r11, r14, minus, r9, PreIndex}, "al r11 r14 minus r9 PreIndex", "NegativePreIndex_al_r11_r14_minus_r9_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r14, r0, minus, r6, PreIndex}, "al r14 r0 minus r6 PreIndex", "NegativePreIndex_al_r14_r0_minus_r6_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r6, r3, minus, r2, PreIndex}, "al r6 r3 minus r2 PreIndex", "NegativePreIndex_al_r6_r3_minus_r2_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r9, r11, minus, r5, PreIndex}, "al r9 r11 minus r5 PreIndex", "NegativePreIndex_al_r9_r11_minus_r5_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r11, r2, minus, r8, PreIndex}, "al r11 r2 minus r8 PreIndex", "NegativePreIndex_al_r11_r2_minus_r8_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r8, r1, minus, r6, PreIndex}, "al r8 r1 minus r6 PreIndex", "NegativePreIndex_al_r8_r1_minus_r6_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r10, r11, minus, r5, PreIndex}, "al r10 r11 minus r5 PreIndex", "NegativePreIndex_al_r10_r11_minus_r5_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r12, r4, minus, r7, PreIndex}, "al r12 r4 minus r7 PreIndex", "NegativePreIndex_al_r12_r4_minus_r7_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r14, r4, minus, r8, PreIndex}, "al r14 r4 minus r8 PreIndex", "NegativePreIndex_al_r14_r4_minus_r8_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r3, r6, minus, r9, PreIndex}, "al r3 r6 minus r9 PreIndex", "NegativePreIndex_al_r3_r6_minus_r9_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r2, r1, minus, r0, PreIndex}, "al r2 r1 minus r0 PreIndex", "NegativePreIndex_al_r2_r1_minus_r0_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r3, r12, minus, r9, PreIndex}, "al r3 r12 minus r9 PreIndex", "NegativePreIndex_al_r3_r12_minus_r9_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r10, r5, minus, r6, PreIndex}, "al r10 r5 minus r6 PreIndex", "NegativePreIndex_al_r10_r5_minus_r6_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r11, r2, minus, r6, PreIndex}, "al r11 r2 minus r6 PreIndex", "NegativePreIndex_al_r11_r2_minus_r6_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r1, r4, minus, r10, PreIndex}, "al r1 r4 minus r10 PreIndex", "NegativePreIndex_al_r1_r4_minus_r10_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r11, r2, minus, r10, PreIndex}, "al r11 r2 minus r10 PreIndex", "NegativePreIndex_al_r11_r2_minus_r10_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r14, r12, minus, r5, PreIndex}, "al r14 r12 minus r5 PreIndex", "NegativePreIndex_al_r14_r12_minus_r5_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r2, r12, minus, r5, PreIndex}, "al r2 r12 minus r5 PreIndex", "NegativePreIndex_al_r2_r12_minus_r5_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r7, r3, minus, r0, PreIndex}, "al r7 r3 minus r0 PreIndex", "NegativePreIndex_al_r7_r3_minus_r0_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r0, r9, minus, r11, PreIndex}, "al r0 r9 minus r11 PreIndex", "NegativePreIndex_al_r0_r9_minus_r11_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r0, r6, minus, r9, PreIndex}, "al r0 r6 minus r9 PreIndex", "NegativePreIndex_al_r0_r6_minus_r9_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r4, r6, minus, r0, PreIndex}, "al r4 r6 minus r0 PreIndex", "NegativePreIndex_al_r4_r6_minus_r0_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r12, r11, minus, r14, PreIndex}, "al r12 r11 minus r14 PreIndex", "NegativePreIndex_al_r12_r11_minus_r14_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r6, r2, minus, r10, PreIndex}, "al r6 r2 minus r10 PreIndex", "NegativePreIndex_al_r6_r2_minus_r10_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r11, r4, minus, r10, PreIndex}, "al r11 r4 minus r10 PreIndex", "NegativePreIndex_al_r11_r4_minus_r10_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r5, r3, minus, r12, PreIndex}, "al r5 r3 minus r12 PreIndex", "NegativePreIndex_al_r5_r3_minus_r12_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r0, r9, minus, r3, PreIndex}, "al r0 r9 minus r3 PreIndex", "NegativePreIndex_al_r0_r9_minus_r3_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r4, r7, minus, r12, PreIndex}, "al r4 r7 minus r12 PreIndex", "NegativePreIndex_al_r4_r7_minus_r12_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r8, r3, minus, r14, PreIndex}, "al r8 r3 minus r14 PreIndex", "NegativePreIndex_al_r8_r3_minus_r14_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r8, r12, minus, r10, PreIndex}, "al r8 r12 minus r10 PreIndex", "NegativePreIndex_al_r8_r12_minus_r10_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r6, r5, minus, r9, PreIndex}, "al r6 r5 minus r9 PreIndex", "NegativePreIndex_al_r6_r5_minus_r9_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r3, r6, minus, r14, PreIndex}, "al r3 r6 minus r14 PreIndex", "NegativePreIndex_al_r3_r6_minus_r14_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r0, r8, minus, r4, PreIndex}, "al r0 r8 minus r4 PreIndex", "NegativePreIndex_al_r0_r8_minus_r4_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r2, r6, minus, r12, PreIndex}, "al r2 r6 minus r12 PreIndex", "NegativePreIndex_al_r2_r6_minus_r12_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r8, r12, minus, r11, PreIndex}, "al r8 r12 minus r11 PreIndex", "NegativePreIndex_al_r8_r12_minus_r11_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r5, r10, minus, r11, PreIndex}, "al r5 r10 minus r11 PreIndex", "NegativePreIndex_al_r5_r10_minus_r11_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r12, r5, minus, r10, PreIndex}, "al r12 r5 minus r10 PreIndex", "NegativePreIndex_al_r12_r5_minus_r10_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r10, r2, minus, r1, PreIndex}, "al r10 r2 minus r1 PreIndex", "NegativePreIndex_al_r10_r2_minus_r1_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r10, r6, minus, r7, PreIndex}, "al r10 r6 minus r7 PreIndex", "NegativePreIndex_al_r10_r6_minus_r7_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r14, r10, minus, r11, PreIndex}, "al r14 r10 minus r11 PreIndex", "NegativePreIndex_al_r14_r10_minus_r11_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r11, r14, minus, r10, PreIndex}, "al r11 r14 minus r10 PreIndex", "NegativePreIndex_al_r11_r14_minus_r10_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r9, r7, minus, r11, PreIndex}, "al r9 r7 minus r11 PreIndex", "NegativePreIndex_al_r9_r7_minus_r11_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r2, r10, minus, r6, PreIndex}, "al r2 r10 minus r6 PreIndex", "NegativePreIndex_al_r2_r10_minus_r6_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r6, r5, minus, r0, PreIndex}, "al r6 r5 minus r0 PreIndex", "NegativePreIndex_al_r6_r5_minus_r0_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r0, r6, minus, r2, PreIndex}, "al r0 r6 minus r2 PreIndex", "NegativePreIndex_al_r0_r6_minus_r2_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r14, r6, minus, r8, PreIndex}, "al r14 r6 minus r8 PreIndex", "NegativePreIndex_al_r14_r6_minus_r8_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r14, r9, minus, r2, PreIndex}, "al r14 r9 minus r2 PreIndex", "NegativePreIndex_al_r14_r9_minus_r2_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r6, r5, minus, r3, PreIndex}, "al r6 r5 minus r3 PreIndex", "NegativePreIndex_al_r6_r5_minus_r3_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r0, r12, minus, r7, PreIndex}, "al r0 r12 minus r7 PreIndex", "NegativePreIndex_al_r0_r12_minus_r7_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r11, r3, minus, r4, PreIndex}, "al r11 r3 minus r4 PreIndex", "NegativePreIndex_al_r11_r3_minus_r4_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r10, r4, minus, r5, PreIndex}, "al r10 r4 minus r5 PreIndex", "NegativePreIndex_al_r10_r4_minus_r5_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r1, r8, minus, r0, PreIndex}, "al r1 r8 minus r0 PreIndex", "NegativePreIndex_al_r1_r8_minus_r0_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r10, r14, minus, r9, PreIndex}, "al r10 r14 minus r9 PreIndex", "NegativePreIndex_al_r10_r14_minus_r9_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r12, r3, minus, r9, PreIndex}, "al r12 r3 minus r9 PreIndex", "NegativePreIndex_al_r12_r3_minus_r9_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r7, r9, minus, r10, PreIndex}, "al r7 r9 minus r10 PreIndex", "NegativePreIndex_al_r7_r9_minus_r10_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r8, r6, minus, r1, PreIndex}, "al r8 r6 minus r1 PreIndex", "NegativePreIndex_al_r8_r6_minus_r1_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r12, r10, minus, r8, PreIndex}, "al r12 r10 minus r8 PreIndex", "NegativePreIndex_al_r12_r10_minus_r8_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r0, r4, minus, r12, PreIndex}, "al r0 r4 minus r12 PreIndex", "NegativePreIndex_al_r0_r4_minus_r12_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r2, r10, minus, r3, PreIndex}, "al r2 r10 minus r3 PreIndex", "NegativePreIndex_al_r2_r10_minus_r3_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r5, r11, minus, r14, PreIndex}, "al r5 r11 minus r14 PreIndex", "NegativePreIndex_al_r5_r11_minus_r14_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r7, r5, minus, r11, PreIndex}, "al r7 r5 minus r11 PreIndex", "NegativePreIndex_al_r7_r5_minus_r11_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r1, r3, minus, r5, PreIndex}, "al r1 r3 minus r5 PreIndex", "NegativePreIndex_al_r1_r3_minus_r5_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r6, r11, minus, r1, PreIndex}, "al r6 r11 minus r1 PreIndex", "NegativePreIndex_al_r6_r11_minus_r1_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r5, r10, minus, r9, PreIndex}, "al r5 r10 minus r9 PreIndex", "NegativePreIndex_al_r5_r10_minus_r9_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r5, r12, minus, r2, PreIndex}, "al r5 r12 minus r2 PreIndex", "NegativePreIndex_al_r5_r12_minus_r2_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r4, r2, minus, r12, PreIndex}, "al r4 r2 minus r12 PreIndex", "NegativePreIndex_al_r4_r2_minus_r12_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r11, r2, minus, r12, PreIndex}, "al r11 r2 minus r12 PreIndex", "NegativePreIndex_al_r11_r2_minus_r12_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r14, r11, minus, r5, PreIndex}, "al r14 r11 minus r5 PreIndex", "NegativePreIndex_al_r14_r11_minus_r5_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r11, r14, minus, r3, PreIndex}, "al r11 r14 minus r3 PreIndex", "NegativePreIndex_al_r11_r14_minus_r3_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r11, r5, minus, r9, PreIndex}, "al r11 r5 minus r9 PreIndex", "NegativePreIndex_al_r11_r5_minus_r9_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r2, r1, minus, r14, PreIndex}, "al r2 r1 minus r14 PreIndex", "NegativePreIndex_al_r2_r1_minus_r14_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r8, r7, minus, r12, PreIndex}, "al r8 r7 minus r12 PreIndex", "NegativePreIndex_al_r8_r7_minus_r12_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r5, r1, minus, r10, PreIndex}, "al r5 r1 minus r10 PreIndex", "NegativePreIndex_al_r5_r1_minus_r10_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r1, r10, minus, r2, PreIndex}, "al r1 r10 minus r2 PreIndex", "NegativePreIndex_al_r1_r10_minus_r2_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r7, r3, minus, r2, PreIndex}, "al r7 r3 minus r2 PreIndex", "NegativePreIndex_al_r7_r3_minus_r2_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r9, r4, minus, r12, PreIndex}, "al r9 r4 minus r12 PreIndex", "NegativePreIndex_al_r9_r4_minus_r12_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r8, r10, minus, r1, PreIndex}, "al r8 r10 minus r1 PreIndex", "NegativePreIndex_al_r8_r10_minus_r1_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r5, r0, minus, r4, PreIndex}, "al r5 r0 minus r4 PreIndex", "NegativePreIndex_al_r5_r0_minus_r4_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r3, r2, minus, r11, PreIndex}, "al r3 r2 minus r11 PreIndex", "NegativePreIndex_al_r3_r2_minus_r11_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}, {{al, r6, r14, minus, r2, PreIndex}, "al r6 r14 minus r2 PreIndex", "NegativePreIndex_al_r6_r14_minus_r2_PreIndex", ARRAY_SIZE(kNegativePreIndex), kNegativePreIndex}}; // We record all inputs to the instructions as outputs. This way, we also check // that what shouldn't change didn't change. struct TestResult { size_t output_size; const Inputs* outputs; }; // These headers each contain an array of `TestResult` with the reference output // values. The reference arrays are names `kReference{mnemonic}`. #include "aarch32/traces/simulator-cond-rd-memop-rs-a32-ldr.h" #include "aarch32/traces/simulator-cond-rd-memop-rs-a32-ldrb.h" #include "aarch32/traces/simulator-cond-rd-memop-rs-a32-ldrh.h" #include "aarch32/traces/simulator-cond-rd-memop-rs-a32-ldrsb.h" #include "aarch32/traces/simulator-cond-rd-memop-rs-a32-ldrsh.h" #include "aarch32/traces/simulator-cond-rd-memop-rs-a32-str.h" #include "aarch32/traces/simulator-cond-rd-memop-rs-a32-strb.h" #include "aarch32/traces/simulator-cond-rd-memop-rs-a32-strh.h" // The maximum number of errors to report in detail for each test. const unsigned kErrorReportLimit = 8; typedef void (MacroAssembler::*Fn)(Condition cond, Register rd, const MemOperand& memop); void TestHelper(Fn instruction, const char* mnemonic, const TestResult reference[]) { SETUP(); masm.UseA32(); START(); // Data to compare to `reference`. TestResult* results[ARRAY_SIZE(kTests)]; // Test cases for memory bound instructions may allocate a buffer and save its // address in this array. byte* scratch_memory_buffers[ARRAY_SIZE(kTests)]; // Generate a loop for each element in `kTests`. Each loop tests one specific // instruction. for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) { // Allocate results on the heap for this test. results[i] = new TestResult; results[i]->outputs = new Inputs[kTests[i].input_size]; results[i]->output_size = kTests[i].input_size; size_t input_stride = sizeof(kTests[i].inputs[0]) * kTests[i].input_size; VIXL_ASSERT(IsUint32(input_stride)); scratch_memory_buffers[i] = NULL; Label loop; UseScratchRegisterScope scratch_registers(&masm); // Include all registers from r0 ro r12. scratch_registers.Include(RegisterList(0x1fff)); // Values to pass to the macro-assembler. Condition cond = kTests[i].operands.cond; Register rd = kTests[i].operands.rd; Register rn = kTests[i].operands.rn; Sign sign = kTests[i].operands.sign; Register rm = kTests[i].operands.rm; AddrMode addr_mode = kTests[i].operands.addr_mode; MemOperand memop(rn, sign, rm, addr_mode); scratch_registers.Exclude(rd); scratch_registers.Exclude(rn); scratch_registers.Exclude(rm); // Allocate reserved registers for our own use. Register input_ptr = scratch_registers.Acquire(); Register input_end = scratch_registers.Acquire(); Register result_ptr = scratch_registers.Acquire(); // Initialize `input_ptr` to the first element and `input_end` the address // after the array. __ Mov(input_ptr, Operand::From(kTests[i].inputs)); __ Add(input_end, input_ptr, static_cast<uint32_t>(input_stride)); __ Mov(result_ptr, Operand::From(results[i]->outputs)); __ Bind(&loop); { UseScratchRegisterScope temp_registers(&masm); Register nzcv_bits = temp_registers.Acquire(); Register saved_q_bit = temp_registers.Acquire(); // Save the `Q` bit flag. __ Mrs(saved_q_bit, APSR); __ And(saved_q_bit, saved_q_bit, QFlag); // Set the `NZCV` and `Q` flags together. __ Ldr(nzcv_bits, MemOperand(input_ptr, offsetof(Inputs, apsr))); __ Orr(nzcv_bits, nzcv_bits, saved_q_bit); __ Msr(APSR_nzcvq, nzcv_bits); } __ Ldr(rd, MemOperand(input_ptr, offsetof(Inputs, rd))); __ Ldr(rm, MemOperand(input_ptr, offsetof(Inputs, rm))); // Allocate 4 bytes for the instruction to work with. scratch_memory_buffers[i] = new byte[4]; { UseScratchRegisterScope temp_registers(&masm); Register memop_tmp = temp_registers.Acquire(); Register base_register = memop.GetBaseRegister(); // Write the expected data into the scratch buffer. __ Mov(base_register, Operand::From(scratch_memory_buffers[i])); __ Ldr(memop_tmp, MemOperand(input_ptr, offsetof(Inputs, memop) + 4)); __ Str(memop_tmp, MemOperand(base_register)); // Compute the address to put into the base register so that the // `MemOperand` points to the right location. // TODO: Support more kinds of `MemOperand`. if (!memop.IsPostIndex()) { if (memop.IsImmediate()) { if (memop.GetSign().IsPlus()) { __ Mov(memop_tmp, memop.GetOffsetImmediate()); __ Sub(base_register, base_register, memop_tmp); } else { __ Mov(memop_tmp, -memop.GetOffsetImmediate()); __ Add(base_register, base_register, memop_tmp); } } else if (memop.IsShiftedRegister()) { __ Mov(memop_tmp, Operand(memop.GetOffsetRegister(), memop.GetShift(), memop.GetShiftAmount())); if (memop.GetSign().IsPlus()) { __ Sub(base_register, base_register, memop_tmp); } else { __ Add(base_register, base_register, memop_tmp); } } } } (masm.*instruction)(cond, rd, memop); { UseScratchRegisterScope temp_registers(&masm); Register nzcv_bits = temp_registers.Acquire(); __ Mrs(nzcv_bits, APSR); // Only record the NZCV bits. __ And(nzcv_bits, nzcv_bits, NZCVFlag); __ Str(nzcv_bits, MemOperand(result_ptr, offsetof(Inputs, apsr))); } __ Str(rd, MemOperand(result_ptr, offsetof(Inputs, rd))); __ Str(rm, MemOperand(result_ptr, offsetof(Inputs, rm))); { UseScratchRegisterScope temp_registers(&masm); Register memop_tmp = temp_registers.Acquire(); Register base_register = memop.GetBaseRegister(); // Compute the address of the scratch buffer by from the base register. If // the instruction has updated the base register, we will be able to // record it. if (!memop.IsPostIndex()) { if (memop.IsImmediate()) { if (memop.GetSign().IsPlus()) { __ Mov(memop_tmp, memop.GetOffsetImmediate()); __ Add(base_register, base_register, memop_tmp); } else { __ Mov(memop_tmp, -memop.GetOffsetImmediate()); __ Sub(base_register, base_register, memop_tmp); } } else if (memop.IsShiftedRegister()) { __ Mov(memop_tmp, Operand(memop.GetOffsetRegister(), memop.GetShift(), memop.GetShiftAmount())); if (memop.GetSign().IsPlus()) { __ Add(base_register, base_register, memop_tmp); } else { __ Sub(base_register, base_register, memop_tmp); } } } // Record the value of the base register, as an offset from the scratch // buffer's address. __ Mov(memop_tmp, Operand::From(scratch_memory_buffers[i])); __ Sub(base_register, base_register, memop_tmp); __ Str(base_register, MemOperand(result_ptr, offsetof(Inputs, memop))); // Record the 32 bit word from memory. __ Ldr(memop_tmp, MemOperand(memop_tmp)); __ Str(memop_tmp, MemOperand(result_ptr, offsetof(Inputs, memop) + 4)); } // Advance the result pointer. __ Add(result_ptr, result_ptr, Operand::From(sizeof(kTests[i].inputs[0]))); // Loop back until `input_ptr` is lower than `input_base`. __ Add(input_ptr, input_ptr, Operand::From(sizeof(kTests[i].inputs[0]))); __ Cmp(input_ptr, input_end); __ B(ne, &loop); } END(); RUN(); if (Test::generate_test_trace()) { // Print the results. for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) { printf("const Inputs kOutputs_%s_%s[] = {\n", mnemonic, kTests[i].identifier); for (size_t j = 0; j < results[i]->output_size; j++) { printf(" { "); printf("0x%08" PRIx32, results[i]->outputs[j].apsr); printf(", "); printf("0x%08" PRIx32, results[i]->outputs[j].rd); printf(", "); printf("0x%08" PRIx32, results[i]->outputs[j].rm); printf(", "); printf("{0x%08" PRIx32 ", 0x%08" PRIx32 "}", results[i]->outputs[j].memop[0], results[i]->outputs[j].memop[1]); printf(" },\n"); } printf("};\n"); } printf("const TestResult kReference%s[] = {\n", mnemonic); for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) { printf(" {\n"); printf(" ARRAY_SIZE(kOutputs_%s_%s),\n", mnemonic, kTests[i].identifier); printf(" kOutputs_%s_%s,\n", mnemonic, kTests[i].identifier); printf(" },\n"); } printf("};\n"); } else if (kCheckSimulatorTestResults) { // Check the results. unsigned total_error_count = 0; for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) { bool instruction_has_errors = false; for (size_t j = 0; j < kTests[i].input_size; j++) { uint32_t apsr = results[i]->outputs[j].apsr; uint32_t rd = results[i]->outputs[j].rd; uint32_t rm = results[i]->outputs[j].rm; uint32_t memop[2] = {results[i]->outputs[j].memop[0], results[i]->outputs[j].memop[1]}; uint32_t apsr_input = kTests[i].inputs[j].apsr; uint32_t rd_input = kTests[i].inputs[j].rd; uint32_t rm_input = kTests[i].inputs[j].rm; uint32_t memop_input[2] = {kTests[i].inputs[j].memop[0], kTests[i].inputs[j].memop[1]}; uint32_t apsr_ref = reference[i].outputs[j].apsr; uint32_t rd_ref = reference[i].outputs[j].rd; uint32_t rm_ref = reference[i].outputs[j].rm; uint32_t memop_ref[2] = {results[i]->outputs[j].memop[0], results[i]->outputs[j].memop[1]}; if (((apsr != apsr_ref) || (rd != rd_ref) || (rm != rm_ref) || ((memop[0] != memop_ref[0]) && (memop[1] != memop_ref[1]))) && (++total_error_count <= kErrorReportLimit)) { // Print the instruction once even if it triggered multiple failures. if (!instruction_has_errors) { printf("Error(s) when testing \"%s %s\":\n", mnemonic, kTests[i].operands_description); instruction_has_errors = true; } // Print subsequent errors. printf(" Input: "); printf("0x%08" PRIx32, apsr_input); printf(", "); printf("0x%08" PRIx32, rd_input); printf(", "); printf("0x%08" PRIx32, rm_input); printf(", "); printf("{0x%08" PRIx32 ", 0x%08" PRIx32 "}", memop_input[0], memop_input[1]); printf("\n"); printf(" Expected: "); printf("0x%08" PRIx32, apsr_ref); printf(", "); printf("0x%08" PRIx32, rd_ref); printf(", "); printf("0x%08" PRIx32, rm_ref); printf(", "); printf("{0x%08" PRIx32 ", 0x%08" PRIx32 "}", memop_ref[0], memop_ref[1]); printf("\n"); printf(" Found: "); printf("0x%08" PRIx32, apsr); printf(", "); printf("0x%08" PRIx32, rd); printf(", "); printf("0x%08" PRIx32, rm); printf(", "); printf("{0x%08" PRIx32 ", 0x%08" PRIx32 "}", memop[0], memop[1]); printf("\n\n"); } } } if (total_error_count > kErrorReportLimit) { printf("%u other errors follow.\n", total_error_count - kErrorReportLimit); } VIXL_CHECK(total_error_count == 0); } else { VIXL_WARNING("Assembled the code, but did not run anything.\n"); } for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) { delete[] results[i]->outputs; delete results[i]; delete[] scratch_memory_buffers[i]; } TEARDOWN(); } // Instantiate tests for each instruction in the list. // TODO: Remove this limitation by having a sandboxing mechanism. #if defined(VIXL_HOST_POINTER_32) #define TEST(mnemonic) \ void Test_##mnemonic() { \ TestHelper(&MacroAssembler::mnemonic, #mnemonic, kReference##mnemonic); \ } \ Test test_##mnemonic("AARCH32_SIMULATOR_COND_RD_MEMOP_RS_A32_" #mnemonic, \ &Test_##mnemonic); #else #define TEST(mnemonic) \ void Test_##mnemonic() { \ VIXL_WARNING("This test can only run on a 32-bit host.\n"); \ USE(TestHelper); \ } \ Test test_##mnemonic("AARCH32_SIMULATOR_COND_RD_MEMOP_RS_A32_" #mnemonic, \ &Test_##mnemonic); #endif FOREACH_INSTRUCTION(TEST) #undef TEST } // namespace #endif } // namespace aarch32 } // namespace vixl
[ "997530783@qq.com" ]
997530783@qq.com
5f7e6b93ea2847bcd45174c0aea97fe1338d5004
ca193aec8ef77d7e9ab211f62f79d7cfb8ef4c95
/AIEOpenGL/src/UtilitySystems/BaseNPC.h
5a42c06bdb1a6ef58ba83193e4c66c7807f87834
[]
no_license
johnsietsma/AIE_OpenGLTutorials
511349736a444bc455be3a284c8f1c0232773df2
a8134f56a7fecb6d4ae78a3460b7f0d54c5d3e98
refs/heads/master
2021-01-10T09:56:22.163741
2016-04-13T23:07:53
2016-04-13T23:07:53
52,057,891
1
0
null
null
null
null
UTF-8
C++
false
false
1,716
h
#ifndef BASE_NPC_H_ #define BASE_NPC_H_ #include <glm/glm.hpp> class World; class BaseNPC { public: //Don't want any base constructor BaseNPC() = delete; BaseNPC(World* a_pWorld); ~BaseNPC(); void update(float a_fdeltaTime); void render(); //This will just output the NPC's vitals and information to the console void reportStatus(); unsigned int getWaterValue() const { return m_uiWater; } unsigned int getFoodValue() const { return m_uiFood; } unsigned int getRestValue() const { return m_uiRested; } unsigned int getNumberOfLogs() const { return m_uiNumberOfLogs; } glm::vec3 getPosition() const { return m_vPosition; } protected: //Called every frame by update - should call one of the behaviour functions below. virtual void selectAction(float a_fdeltaTime) { collectWater(a_fdeltaTime); } //Different behaviours that our AI can run - these will move the AI towards the required location //and then do the task. void collectWater(float a_fdeltaTime); void collectFood(float a_fdeltaTime); void rest(float a_fdeltaTime); void chopTree(float a_fdeltaTime); void buildHouse(float a_fdeltaTime); World* m_pWorld; private: bool travelTo(glm::vec3 a_vLoc, float a_fDeltaTime); void checkAlive(); void calculateStatusChange(); glm::vec3 m_vPosition; unsigned int m_uiFood; unsigned int m_uiWater; unsigned int m_uiRested; unsigned int m_uiNumberOfLogs; float m_fMoveSpeed; bool m_bAlive; float m_fLastReportTime; float m_fReportTime; float m_fLastFoodReductionTime; float m_fLastWaterReductionTime; float m_fLastRestedReductionTime; float m_fFoodReductionTime; float m_fWaterReductionTime; float m_fRestedReductionTime; }; #endif
[ "johns@ad.aie.edu" ]
johns@ad.aie.edu
a209f7291e85eba4c68bbd890b13729fbf24cd10
1e7c67d1428ec483c2ffcb78538a06abb32abddc
/helper_db/baseinfoclass.cpp
c89d81caeda80b265675f60646942dc48eb523e8
[]
no_license
lzmths/annotations_repos
e2d37729f69a5fe6372c6e04ed9b9f98af9f8a45
b8b70d1b0f94702c44ba8ceda3741f7925bcf1ae
refs/heads/master
2020-03-26T04:00:02.473432
2018-05-03T12:57:35
2018-05-03T12:57:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,714
cpp
#include "baseinfoclass.h" void BaseInfoClass::setId(QString &id) { this->mId = id; } void BaseInfoClass::setRefList(QList<BaseInfoClass *> &reflist) { this->mReferenceList = reflist; } BaseInfoClass::BaseInfoClass(QString id) : mId(id) {} BaseInfoClass::BaseInfoClass(){} bool BaseInfoClass::fromJson(QJsonObject &obj) { return false; } QJsonObject BaseInfoClass::toJson() const {return QJsonObject();} BaseInfoClass::~BaseInfoClass() { clearOwnedPtrs(); mReferenceList.clear(); } void BaseInfoClass::appendToRefs(BaseInfoClass *ref) { if (ref != nullptr) { if (!mReferenceList.contains(ref)) { mReferenceList.append(ref); } } } QStringList BaseInfoClass::gRefsStr() const { QStringList strList; for(auto&& ref : mReferenceList) { strList.append(ref->toString()); } return strList; } QString BaseInfoClass::toString() const {return mId;} QString BaseInfoClass::getId() const { return mId; } bool BaseInfoClass::updateReference(BaseInfoClass *reference) { int i = deletable_refs.indexOf(reference); int i2 = mReferenceList.indexOf(reference); //Delete owned reference if (i >= 0 ) { delete deletable_refs.at(i); if (i2 >= 0 ) { //Update reference mReferenceList[i2] = reference; } return true; } //Haven't found related reference, can't update return false; } bool BaseInfoClass::operator ==(BaseInfoClass &a) const{ return (this->mId == a.mId) && (a.mReferenceList == this->mReferenceList); } bool BaseInfoClass::operator ==(BaseInfoClass a) const{ return (this->mId == a.mId) && (a.mReferenceList == this->mReferenceList); }
[ "pmop@ic.ufal.br" ]
pmop@ic.ufal.br
6b3ac11824cbc3ce2ca8c72907ba3600b733a00b
06c78c7ef6fa4054e504c91f6849b6b20f826f6d
/Classes/Item/ItemManager.cpp
f6e0813d33ac09af0fbd8ec1b435a5fe6ad87dd6
[ "MIT" ]
permissive
cnsuhao/Armada
1a40a3a3c12db3ce81407ed7d9353ed7f8791fd3
b465849332d09951e7309d788602eca297026057
refs/heads/master
2021-08-28T02:26:04.726383
2016-01-26T08:16:01
2016-01-26T08:16:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,094
cpp
#include "ItemManager.h" #include "Item.h" #include "ItemQuicken.h" #include "Ship/ShipManager.h" ItemManager::ItemManager() { } ItemManager::~ItemManager() { } ItemManager* ItemManager::GetInstance() { static ItemManager T; return &T; } Item* ItemManager::CreateItem(int itemType) { Item* item = nullptr; switch (itemType) { case 1: item = new ItemQuicken(); break; default: break; } // return item; } void ItemManager::ClearAllItems() { std::list<Item*>::iterator it = mItems.begin(); while (it != mItems.end()) { Item* item = *it; it = mItems.erase(it); item->removeFromParentAndCleanup(true); delete item; } } void ItemManager::Init() { } void ItemManager::Free() { } void ItemManager::AddItem(Item* item) { mItems.push_back(item); } void ItemManager::RemoveItem(Item* item, bool clearup) { if (clearup) mItems.remove(item); item->DestoryItem(); } void ItemManager::UpdateItems(float dt) { std::list<Item*>::iterator it = mItems.begin(); while (it != mItems.end()) { Item* item = *it; // std::map<TeamShipSeat, ShipBase*>& left_ships = ShipManager::getInstance()->GetTeamLeftShips(); std::map<TeamShipSeat, ShipBase*>::iterator itTeam = left_ships.begin(); for (; itTeam != left_ships.end(); ++itTeam) { ShipBase* pShip = itTeam->second; if (pShip != nullptr) { if (item->OnCollision(pShip)) { item->DestoryItem(); } } } // std::map<TeamShipSeat, ShipBase*>& right_ships = ShipManager::getInstance()->GetTeamRightShips(); std::map<TeamShipSeat, ShipBase*>::iterator itEnemy = right_ships.begin(); for (; itEnemy != right_ships.end(); ++itEnemy) { ShipBase* pShip = itEnemy->second; if (pShip != nullptr) { if (item->OnCollision(pShip)) { item->DestoryItem(); } } } // item->UpdateItem(dt); // if (!item->Alive()) { it = mItems.erase(it); RemoveItem(item,false); } else { it++; } } } //
[ "mrhitman@949e9b60-923a-47c5-a6f0-92605c387864" ]
mrhitman@949e9b60-923a-47c5-a6f0-92605c387864
9346156c15d47c0d13931ee5518923477074be52
c51febc209233a9160f41913d895415704d2391f
/library/ATF/_guild_query_info_request_clzo.hpp
8547b29c31c3cec555d84e3c4ab6ebf17bd25f50
[ "MIT" ]
permissive
roussukke/Yorozuya
81f81e5e759ecae02c793e65d6c3acc504091bc3
d9a44592b0714da1aebf492b64fdcb3fa072afe5
refs/heads/master
2023-07-08T03:23:00.584855
2023-06-29T08:20:25
2023-06-29T08:20:25
463,330,454
0
0
MIT
2022-02-24T23:15:01
2022-02-24T23:15:00
null
UTF-8
C++
false
false
281
hpp
// This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually #pragma once #include <common/common.h> START_ATF_NAMESPACE struct _guild_query_info_request_clzo { unsigned int dwGuildSerial; }; END_ATF_NAMESPACE
[ "b1ll.cipher@yandex.ru" ]
b1ll.cipher@yandex.ru
54355e4dd3daab8ac276717ad6ca4ffeeb1f1b10
51109b5df8a269cc8c0b58472b7b590d316b5121
/SWTOR_2.4_Sorc_Healer_BiS/Main.cpp
a91fc3223f52608f22d1f2ce50ac7f3f6fa6ca82
[]
no_license
caeruleus1F/SWTOR-2.4-Sorc-Healer-BiS
f0ffb5f8e2c4c997df76740dbe37f161ca619b2f
ecadf79f5f58ab5210269fa1d2e4163751a6f6de
refs/heads/master
2020-03-27T04:24:55.616628
2014-08-02T04:21:52
2014-08-02T04:21:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
694
cpp
#include "Player.h" int main () { cout << "... Initializing stats ...\n\n"; Player AD; float StatCompare[6] = {0}; AD.IN_GROUP = 1; AD.COMP_HEALTH_BUFF = 1; AD.COMP_CRIT_BUFF = 1; AD.COMP_SURGE_BUFF = 1; AD.COMP_ACCURACY_BUFF = 1; cout << "... Stats Initialized ...\n\n"; AD.OffHiltArmorings(StatCompare); AD.OffMods(StatCompare); AD.OffEnhancements(StatCompare); AD.OffEarpieces(StatCompare); AD.OffImplants(StatCompare); AD.OffColorCrystals(StatCompare); AD.OffAugments(StatCompare); //2 Relics AD.modOffStats("AC", 0.0, "WP", 0.0, "PO", 64.0, "CR", 0.0, "SU", 0.0, "AL", 0.0); //show end result stats AD.showOffStats(); AD.showHPS(); cin.get(); return 0; }
[ "gbates31@gmail.com" ]
gbates31@gmail.com
4c83959975d6112c412504c4a88a0921a7c115dc
3e1ac5a6f5473c93fb9d4174ced2e721a7c1ff4c
/build/iOS/Preview/include/Fuse.Node.NodeDataSubscription.h
62565410818d5697c1e52ba5322a83e57cbac803
[]
no_license
dream-plus/DreamPlus_popup
49d42d313e9cf1c9bd5ffa01a42d4b7c2cf0c929
76bb86b1f2e36a513effbc4bc055efae78331746
refs/heads/master
2020-04-28T20:47:24.361319
2019-05-13T12:04:14
2019-05-13T12:04:14
175,556,703
0
1
null
null
null
null
UTF-8
C++
false
false
2,050
h
// This file was generated based on /usr/local/share/uno/Packages/Fuse.Nodes/1.9.0/Node.DataContext.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Fuse.Node.IDataListener.h> #include <Uno.IDisposable.h> #include <Uno.Object.h> namespace g{namespace Fuse{struct Node;}} namespace g{namespace Fuse{struct Node__NodeDataSubscription;}} namespace g{ namespace Fuse{ // internal sealed class Node.NodeDataSubscription :277 // { struct Node__NodeDataSubscription_type : uType { ::g::Fuse::Node__IDataListener interface0; ::g::Uno::IDisposable interface1; }; Node__NodeDataSubscription_type* Node__NodeDataSubscription_typeof(); void Node__NodeDataSubscription__ctor__fn(Node__NodeDataSubscription* __this, ::g::Fuse::Node* origin, int32_t* type, uString* key, uObject* listener); void Node__NodeDataSubscription__get_Data_fn(Node__NodeDataSubscription* __this, uObject** __retval); void Node__NodeDataSubscription__Dispose_fn(Node__NodeDataSubscription* __this); void Node__NodeDataSubscription__FuseNodeIDataListenerOnDataChanged_fn(Node__NodeDataSubscription* __this); void Node__NodeDataSubscription__get_HasData_fn(Node__NodeDataSubscription* __this, bool* __retval); void Node__NodeDataSubscription__New1_fn(::g::Fuse::Node* origin, int32_t* type, uString* key, uObject* listener, Node__NodeDataSubscription** __retval); void Node__NodeDataSubscription__get_Provider_fn(Node__NodeDataSubscription* __this, uObject** __retval); struct Node__NodeDataSubscription : uObject { int32_t _type; uStrong<uString*> _key; bool _hasData; uStrong<uObject*> _data; uStrong<uObject*> _provider; uStrong< ::g::Fuse::Node*> _origin; uStrong<uObject*> _listener; void ctor_(::g::Fuse::Node* origin, int32_t type, uString* key, uObject* listener); uObject* Data(); void Dispose(); bool HasData(); uObject* Provider(); static Node__NodeDataSubscription* New1(::g::Fuse::Node* origin, int32_t type, uString* key, uObject* listener); }; // } }} // ::g::Fuse
[ "cowodbs156@gmail.com" ]
cowodbs156@gmail.com
a417d1e6ed745d24062b4ffe96fd89a84ba7294c
ca32936825c3cbae13e4db108ad97d670e0a9264
/oce-0.17/include/oce/SelectBasics_SortAlgo.hxx
bd944c8d0d4df49116379e98a2f1118df60da91a
[]
no_license
zqqiang/node-cad
7b783fb758dcacb5b1e1b8276c73dfe0942adfbb
739ff348b4d2c77b275c3a0fe87682c14ffd8181
refs/heads/master
2021-01-14T08:03:53.991041
2016-12-23T19:07:33
2016-12-23T19:07:33
46,592,925
5
0
null
null
null
null
UTF-8
C++
false
false
2,206
hxx
// This file is generated by WOK (CPPExt). // Please do not edit this file; modify original file instead. // The copyright and license terms as defined for the original file apply to // this header file considered to be the "object code" form of the original source. #ifndef _SelectBasics_SortAlgo_HeaderFile #define _SelectBasics_SortAlgo_HeaderFile #include <Standard.hxx> #include <Standard_DefineAlloc.hxx> #include <Standard_Macro.hxx> #include <Bnd_Box2d.hxx> #include <Standard_Real.hxx> #include <Bnd_BoundSortBox2d.hxx> #include <TColStd_MapOfInteger.hxx> #include <TColStd_MapIteratorOfMapOfInteger.hxx> #include <Handle_Bnd_HArray1OfBox2d.hxx> #include <Standard_Boolean.hxx> #include <Standard_Integer.hxx> class Bnd_Box2d; class Bnd_HArray1OfBox2d; //! Quickly selection of a rectangle in a set of rectangles //! Sort algorithm for 2D rectangles. class SelectBasics_SortAlgo { public: DEFINE_STANDARD_ALLOC //! Empty rectangle selector. Standard_EXPORT SelectBasics_SortAlgo(); //! Creates a initialized selector. Standard_EXPORT SelectBasics_SortAlgo(const Bnd_Box2d& ClippingRectangle, const Standard_Real sizeOfSensitiveArea, const Handle(Bnd_HArray1OfBox2d)& theRectangles); //! Clears and initializes the selector. Standard_EXPORT void Initialize (const Bnd_Box2d& ClippingRectangle, const Standard_Real sizeOfSensitiveArea, const Handle(Bnd_HArray1OfBox2d)& theRectangles) ; //! Searchs the items on this position. Standard_EXPORT void InitSelect (const Standard_Real x, const Standard_Real y) ; //! Searchs the items in this rectangle. Standard_EXPORT void InitSelect (const Bnd_Box2d& rect) ; //! Returns true if there is something selected. Standard_EXPORT Standard_Boolean More() const; //! Sets value on the next selected item. Standard_EXPORT void Next() ; //! Returns the index of the selected rectangle. Standard_EXPORT Standard_Integer Value() const; protected: private: Bnd_Box2d clipRect; Standard_Real sizeArea; Bnd_BoundSortBox2d sortedRect; TColStd_MapOfInteger myMap; TColStd_MapIteratorOfMapOfInteger curResult; }; #endif // _SelectBasics_SortAlgo_HeaderFile
[ "qiangzhaoqing@gmail.com" ]
qiangzhaoqing@gmail.com
3b02fd613d1f7b9601b3b219c0866ddeeb788004
5cec37261e756a98b632eda290d4869461738403
/core/src/quadrature/clenshaw_curtis.tpp
5bfab07b1ed833ad35328cfb6da49de89a52598a
[ "MIT" ]
permissive
maierbn/opendihu
d78630244fbba035f34f98a4f4bd0102abe57f04
e753fb2a277f95879ef107ef4d9ac9a1d1cec16d
refs/heads/develop
2023-09-05T08:54:47.345690
2023-08-30T10:53:10
2023-08-30T10:53:10
98,750,904
28
11
MIT
2023-07-16T22:08:44
2017-07-29T18:13:32
C++
UTF-8
C++
false
false
1,677
tpp
// weights are calculated corresponding to the implementation in ClenshawCurtisweights() // which is located in examples/quadrature/dominik/src/quadrature.cpp #include "quadrature/clenshaw_curtis.h" #include <array> namespace Quadrature { template<unsigned int NumberIntegrationPoints> constexpr int ClenshawCurtis<NumberIntegrationPoints>::numberEvaluations() { return NumberIntegrationPoints; } template<unsigned int NumberIntegrationPoints> template<typename ValueType> ValueType ClenshawCurtis<NumberIntegrationPoints>:: computeIntegral(const typename std::array<ValueType,ClenshawCurtis<NumberIntegrationPoints>::numberEvaluations()> &evaluations) { return ClenshawCurtis<NumberIntegrationPoints>::template computeIntegral<ValueType>(evaluations.begin()); } // quadrature with 1 ClenshawCurtis point template<> template<typename ValueType> ValueType ClenshawCurtis<1>:: computeIntegral(const typename std::array<ValueType,1>::const_iterator evaluationsIter) { ValueType result{}; result = *evaluationsIter; return result; } // quadrature with more than 2 integration points template<unsigned int NumberIntegrationPoints> template<typename ValueType> ValueType ClenshawCurtis<NumberIntegrationPoints>:: computeIntegral(const typename std::array<ValueType,ClenshawCurtis<NumberIntegrationPoints>::numberEvaluations()>::const_iterator evaluationsIter) { ValueType result{}; const std::array<double,NumberIntegrationPoints> weights = quadratureWeights(); for (int i = 0; i < NumberIntegrationPoints; i++) { result += weights[i] * (*(evaluationsIter+i)); } return result; } } // namespace
[ "maier.bn@gmail.com" ]
maier.bn@gmail.com
4973381596d92f5347a021b39f7e1080cec9193a
f3bb9e8806db3db77a8079988d74ffce847593f9
/org.alloytools.kodkod.nativesat/lib/cryptominisat-2.9.5/cmsat/XorFinder.h
b94a156457f92bba53ecd201feaec76674cf6afb
[ "MIT", "Apache-2.0" ]
permissive
danielleberre/org.alloytools.alloy
de673f3d078083f3a3d8c6e55b5d067404c4420d
dcc3d4d04ef7970dca35047cb3f51945922f9e8f
refs/heads/master
2021-04-03T04:49:03.932626
2018-03-12T07:35:13
2018-03-12T07:35:13
125,003,790
0
1
Apache-2.0
2018-03-13T06:34:15
2018-03-13T06:34:15
null
UTF-8
C++
false
false
5,828
h
/***************************************************************************************[Solver.cc] Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson Copyright (c) 2007-2009, Niklas Sorensson Copyright (c) 2009-2012, Mate Soos 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. **************************************************************************************************/ #ifndef XORFINDER_H #define XORFINDER_H #include "cmsat/constants.h" #define DEBUG_XORFIND //#define DEBUG_XORFIND2 #include "cmsat/Clause.h" #include "cmsat/VarReplacer.h" #include "cmsat/ClauseCleaner.h" namespace CMSat { class Solver; using std::pair; /** @brief Finds xors given a set of clauses It basically sorts clauses' literals, sorts clauses according to size and variable content, then idetifies continious reagions that could be an XOR clause, finds the xor clause by counting the number of unique negation permutations of the literals, then removes the clauses, and inserts the xor clause */ class XorFinder { public: XorFinder(Solver& _solver, vec<Clause*>& cls); bool fullFindXors(const uint32_t minSize, const uint32_t maxSize); void addAllXorAsNorm(); private: typedef vector<pair<Clause*, uint32_t> > ClauseTable; bool findXors(uint32_t& sumLengths); bool getNextXor(ClauseTable::iterator& begin, ClauseTable::iterator& end, bool& impair); /** @brief For sorting clauses according to their size&their var content. Clauses' variables must already be sorted */ struct clause_sorter_primary { bool operator()(const pair<Clause*, uint32_t>& c11, const pair<Clause*, uint32_t>& c22) { if (c11.first->size() != c22.first->size()) return (c11.first->size() < c22.first->size()); #ifdef DEBUG_XORFIND2 Clause& c1 = *c11.first; for (uint32_t i = 0; i+1 < c1.size(); i++) assert(c1[i].var() <= c1[i+1].var()); Clause& c2 = *c22.first; for (uint32_t i = 0; i+1 < c2.size(); i++) assert(c2[i].var() <= c2[i+1].var()); #endif //DEBUG_XORFIND2 for (a = c11.first->getData(), b = c22.first->getData(), end = c11.first->getDataEnd(); a != end; a++, b++) { if (a->var() != b->var()) return (a->var() > b->var()); } return false; } Lit const *a; Lit const *b; Lit const *end; }; /** @brief Sorts clauses with equal length and variable content according to their literals' signs NOTE: the length and variable content of c11 and c22 MUST be the same Used to avoid the problem of having 2 clauses with exactly the same content being counted as two different clauses (when counting the (im)pairedness of XOR being searched) */ struct clause_sorter_secondary { bool operator()(const pair<Clause*, uint32_t>& c11, const pair<Clause*, uint32_t>& c22) const { const Clause& c1 = *(c11.first); const Clause& c2 = *(c22.first); assert(c1.size() == c2.size()); for (uint32_t i = 0, size = c1.size(); i < size; i++) { assert(c1[i].var() == c2[i].var()); if (c1[i].sign() != c2[i].sign()) return c1[i].sign(); } return false; } }; /** @brief Returns whether vars in clauses are the same -- clauses' literals must be identically sorted */ bool clause_vareq(const Clause* c1, const Clause* c2) const { if (c1->size() != c2->size()) return false; for (uint32_t i = 0, size = c1->size(); i < size; i++) if ((*c1)[i].var() != (*c2)[i].var()) return false; return true; } ClauseTable table; vector<bool> toRemove; vector<bool> toLeaveInPlace; void clearToRemove(); uint32_t foundXors; //For adding xor clause as normal clause void addXorAsNormal3(XorClause& c); void addXorAsNormal4(XorClause& c); vec<Clause*>& cls; bool clauseEqual(const Clause& c1, const Clause& c2) const; bool impairSigns(const Clause& c) const; void countImpairs(const ClauseTable::iterator& begin, const ClauseTable::iterator& end, uint32_t& numImpair, uint32_t& numPair) const; bool isXor(const uint32_t size, const ClauseTable::iterator& begin, const ClauseTable::iterator& end, bool& impair); Solver& solver; }; } #endif //XORFINDER_H
[ "peter.kriens@aqute.biz" ]
peter.kriens@aqute.biz
4a9a0ec27532c399166cb9493f9bdd712a9dd8e3
9aa4284e68ac05d9a141a8dbc324d7fbeef3b611
/acc_2body_13C/Scattering.cc
5f1ccd2b15e7dde1fc5a14bbdba8d8dc333919f9
[]
no_license
fengjunpku/NucExpAnaCode
7e4d5bddf40c40970be45b6f1c90a66164fc2e66
7693f309e9f7c84dd3cf0d8705ca52c11e95e506
refs/heads/master
2021-01-09T21:47:32.954362
2015-12-12T09:26:51
2015-12-12T09:26:51
47,031,343
0
0
null
null
null
null
UTF-8
C++
false
false
2,772
cc
/* #include "TROOT.h" #include "TVector3.h" #include "TMath.h" #include "TString.h" #include "TH1.h" #include "TH2F.h" #include "TF1.h" #include "TCanvas.h" //A(a,b)B const Double_t M_a=13.0;//beam const Double_t M_A=9.0;//target const Double_t M_b=13.0;//out const Double_t M_B=9.0;//recoil const Double_t Me=0.511/939;//elec:u const Int_t Z_a=6; const Int_t Z_A=4; const Double_t NA=6.022e23; const Double_t rou_A=1.85;//unit:g/cm3 const Double_t qe=1.60217e-19;//unit:C const Double_t KK=81e18;// JingDianLi Const ^2 */ //A(a,b)B #include "Scattering.hh" Double_t deLoss(Double_t Ek) { ////Double_t vv=2*Ek/M_a; Double_t beta2=1.-TMath::Power(1/(1+Ek/939.0/M_a),2.); Double_t vv=9e16*beta2*1.66055e-27/1.60217e-13;//unit: MeV/u ////////// //Double_t IPart=9.1e-6*Z_A*(1+1.9*TMath::Power(Z_A,2.0/3.0));//MeV Double_t IPart=63.6e-6;//MeV ///////////// Double_t partf=1e6*4*TMath::Pi()*Z_a*Z_a*Z_A*rou_A*NA/M_A;//unit:: 1/m3 Double_t partm=KK*qe*qe*qe*qe/(Me*vv*1.60217e-13);//unit:: C^4/J Double_t partb=TMath::Log(2*Me*vv/IPart)-TMath::Log(1-beta2)-beta2; return partf*partm*partb/1.60217e-7;//unit::MeV/um } void Scattering() { TCanvas *c=new TCanvas("c1","",800,600); TH2F *hh=new TH2F("hh","E:theta",300,0,30,50,0,5); TF1 *ET=new TF1("ET","[0]+[1]*x+[2]*x*x",0,30);//E(th) @ Ein Double_t sTheta=40.0*TMath::Pi()/180.0; Double_t Ein=70; TVector3 Pin; Pin.SetMagThetaPhi(TMath::Sqrt(2*Ein*M_a),0,0); cout<<"Energy @ angle: "<<sTheta<<" is :"<<scatterE(Ein,sTheta)/M_a<<endl; Double_t x=0; while(x<=35) { Double_t temp=x*TMath::Pi()/180.0; hh->Fill(x,scatterE(70,temp)/M_a); x+=0.01; } hh->Fit(ET,"","",0,28.8); hh->Draw(); } Double_t scatterE(Double_t Ein,Double_t sTheta) { Double_t Qvalue=-15.0; Double_t part1,part2,part3; part1=TMath::Sqrt(M_a*M_b*Ein)*TMath::Cos(sTheta)/(M_B+M_b); part2=Ein*(M_B-M_a)/(M_B+M_b)+TMath::Power(part1,2); part3=M_B*Qvalue/(M_B+M_b); if((part2+part3)>0) return TMath::Power((part1+TMath::Sqrt(part2+part3)),2); else return -1; } Double_t LossE(Double_t Ein,Double_t Deff)//Deff :um { Double_t step=0.01;//um Double_t range=0; Double_t eloss=0; Double_t Ere=Ein; while((range<=Deff)) { Double_t tempe=step*deLoss(Ere); //if(tempe>0.01) {step/=2;continue;} eloss+=tempe; Ere-=tempe; range+=step; //cout<<Ere<<" "<<step<<endl; } return eloss; } Double_t Range(Double_t Ein) { Double_t step=0.01;//um Double_t range=0; Double_t eloss=0; Double_t tempe=100; Double_t Ere=Ein; while(Ere>1e-6&&tempe>1e-6) { tempe=step*deLoss(Ere); if(tempe>0.01) {step/=2;continue;} Ere-=tempe; range+=step; cout<<range<<" "<<Ere<<endl; } return range; }
[ "fengjun2013@pku.edu.cn" ]
fengjun2013@pku.edu.cn
05946ce032bd5569b452695225de5d4a412455e8
7075de2d63093df610ef62b78fea4a77e8e15467
/CODEVS/1203.cpp
2f14b5b6394b6f1f84ce6110d46b7db777aa6491
[]
no_license
SHawnHardy/SH_ACM_OLD
c6a6d2d062228b47bb5076fbf3cca7b29a3650f0
5a12a3fea751ef7ec35da95c360515a6fd6f69cd
refs/heads/master
2020-03-11T13:23:14.281586
2018-08-27T19:49:57
2018-08-27T20:31:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
191
cpp
#include "cstdio" const double eps=1e-8; int main(){ double a,b; scanf("%lf%lf",&a,&b); if(-eps<a-b&&a-b<eps) puts("yes"); else puts("no"); return 0; }
[ "shawn_work@outlook.com" ]
shawn_work@outlook.com
829b6f45839e5a807ec1f89c0e2871d8c57ad8f6
263eb7dd9a368a9fb501698b5b6554938851c7a2
/Data Structure/Data Structure/10809_알파벳찾기.cpp
8c36cf4e6c05eeb9db30f0b1d7e9fcbacbc9aafb
[]
no_license
Jasonarea/Baekjoon_
6938a75d43a86195d08431c8a932eef1ef4a3929
0dadeb99d4bbd2c5dc09cc169b54e8df44deb782
refs/heads/master
2018-10-15T20:53:09.798370
2018-09-28T02:24:15
2018-09-28T02:24:15
115,684,698
1
0
null
null
null
null
UTF-8
C++
false
false
324
cpp
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; for (int i = 'a'; i <= 'z'; i++) { auto it = find(s.begin(), s.end(), i); if (it == s.end()) { cout << -1 << ' '; } else { cout << (it - s.begin()) << ' '; } } cout << '\n'; return 0; }
[ "hyeonsuns123@gmail.com" ]
hyeonsuns123@gmail.com