blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
66d999850d7be94f02c1a124e0ec668792e044a3
238e6518f6e43c480543f223940515275bbdb036
/tugas algo9/tugas2/tugas2.cpp
36a32097c0951762b57a9cb82c9efa302ee902a7
[]
no_license
MuhamadAufi/tugas_algoritma
aad4f333d9f9aa10c64f12c1900969b0663a9cc4
149e0e2ed1e1bdb56348a3daf6e64e7848a2870a
refs/heads/master
2020-04-14T05:41:11.038609
2018-12-31T12:17:24
2018-12-31T12:17:24
163,666,147
0
0
null
null
null
null
UTF-8
C++
false
false
309
cpp
#include<stdio.h> #include<conio.h> int main(){ int bil[7],i; printf("elemen 1?"); scanf("%d",&bil[0]); bil[1]=5; bil[2]=bil[1]+20; for(i=4;i<7;i++)bil[i]=i*10; bil[3]=bil[bil[1]]; for(i=0;i<7;i++) printf("bil[%d] =%d dan alamatnya :%X\n",i,bil[i],&bil[i]); getch(); return 0; }
[ "muhamadaufi25@gmail.com" ]
muhamadaufi25@gmail.com
4ef26164152006d77e6f2ce481cafde784dbabd2
0307233373b9d1ab1866edc5f6588a0a3df5ba1a
/cf-1516-A.cpp
db96302346f8ebd68e5bd0d60597170756258ba4
[]
no_license
MuntasirNahid/oj-solution
67750f7e72f454dfe3ae15a7f1d169a12c4b2957
e99269d73e400206e096d38b1a5415b3ff8fd7b9
refs/heads/master
2023-04-23T09:40:54.608961
2021-05-12T08:54:08
2021-05-12T08:54:08
343,897,545
0
0
null
null
null
null
UTF-8
C++
false
false
769
cpp
#include<bits/stdc++.h> #define ll long long #define pb push_back #define pi acos(-1) #define INF 1e18 #define MN7 ios::sync_with_stdio(0);cin.tie(nullptr); #define MOD 1000000007 #define popb pop_back() #define popf pop_front() #define revers(x) reverse(x.begin(),x.end()) #define fo(i,a,n) for(i=a;i<n;i++) using namespace std; ll t, n, i, j, k, a, b, c, d, p, q, r, x, y, z, m, cnt, flag, ans, u, v, w; string s; void nahid() { cin >> n >> k; vector<int>v(n); for (i = 0; i < n; i++) { cin >> v[i]; } i = 0; j = n - 1; while(k--){ while (v[i] <= 0){ i++; } if(j < i) break; v[i] -= 1; v[j] += 1; } for (i = 0; i < n; i++) { cout << v[i] << " \n"[i == n - 1]; } } int main() { MN7 cin >> t; while (t--) nahid(); }
[ "muntasirnahid87@gmail.com" ]
muntasirnahid87@gmail.com
c9d1a669dc6565d8751db85bf30efb0b728aaa30
ecb92108525bfe6c03c4be891fde61c67443c1f8
/205. Isomorphic Strings/main.cpp
602114edaf4681f9a64a776e1a3f05177cf2ae6b
[]
no_license
PCzhangPC/lc_coding
25d282a9479d210635e4aec852a29ec4f9c2717b
deacf01b2399520a6b407cc1426a49b060eca3d2
refs/heads/master
2018-10-12T05:17:42.298949
2018-07-10T07:48:36
2018-07-10T07:48:36
111,921,153
0
0
null
null
null
null
UTF-8
C++
false
false
909
cpp
#include <iostream> #include <map> using namespace std; class Solution { public: bool isIsomorphic(string s, string t) { if (s.size() != t.size()) return false; bool flag = true; map<char, char> dict1; map<char, char> dict2; for (int i = 0; i < s.size(); i++) { if (dict1.count(s[i]) == 0) { dict1[s[i]] = t[i]; } else { if (dict1[s[i]] != t[i]) { flag = false; break; } } if (dict2.count(t[i]) == 0) { dict2[t[i]] = s[i]; } else { if (dict2[t[i]] != s[i]) { flag = false; break; } } } return flag; } }; int main() { Solution s; s.isIsomorphic("ab", "aa"); return 0; }
[ "ZhangPCplus@163.com" ]
ZhangPCplus@163.com
c00b2f6eade523dce6ca220db650ffbf5a9904ce
da3c0b2772247e877a9b21a308acde5612af020d
/Widgets/wreportssetold.cpp
4021dad563e49662640c871947e13701bf0ddac5
[]
no_license
End1-1/Resort-2
857ef7fdf26ce9eb7d5e1c11f1ee6959d8fbd21e
b99a39d4600213ac5affcf32ab8a9e4b8b07cdc2
refs/heads/master
2023-02-21T22:27:59.031695
2023-02-09T07:54:38
2023-02-09T07:54:38
151,714,828
1
0
null
null
null
null
UTF-8
C++
false
false
8,754
cpp
#include "wreportssetold.h" #include "ui_wreportssetold.h" #include "wreportgrid.h" #include "databaseresult.h" #include "edateedit.h" #include "ecomboboxcompleter.h" WReportsSetOld::WReportsSetOld(QWidget *parent) : BaseWidget(parent), ui(new Ui::WReportsSetOld) { ui->setupUi(this); ui->tabWidget->tabBar()->tabButton(0, QTabBar::RightSide)->resize(0, 0); fBtnMonth.addButton(ui->rbJanuary); fBtnMonth.addButton(ui->rbFebrary); fBtnMonth.addButton(ui->rbMarch); fBtnMonth.addButton(ui->rbApril); fBtnMonth.addButton(ui->rbMay); fBtnMonth.addButton(ui->rbJune); fBtnMonth.addButton(ui->rbJuly); fBtnMonth.addButton(ui->rbAugust); fBtnMonth.addButton(ui->rbSeptember); fBtnMonth.addButton(ui->rbOctober); fBtnMonth.addButton(ui->rbNovember); fBtnMonth.addButton(ui->rbDecember); fBtnMonth.addButton(ui->rbYear); ui->rbJanuary->fData["month"] = 1; ui->rbFebrary->fData["month"] = 2; ui->rbMarch->fData["month"] = 3; ui->rbApril->fData["month"] = 4; ui->rbMay->fData["month"] = 5; ui->rbJune->fData["month"] = 6; ui->rbJuly->fData["month"] = 7; ui->rbAugust->fData["month"] = 8; ui->rbSeptember->fData["month"] = 9; ui->rbOctober->fData["month"] = 10; ui->rbNovember->fData["month"] = 11; ui->rbDecember->fData["month"] = 12; ui->rbYear->fData["month"] = 0; int month = QDate::currentDate().month(); QList<QAbstractButton*> e = fBtnMonth.buttons(); for (int i = 0; i < e.count(); i++) { ERadioButton *er = static_cast<ERadioButton*>(e.at(i)); if (er->fData["month"].toInt() == month) { er->setChecked(true); break; } } fBtnGroup.addButton(ui->rbrCategory); fBtnGroup.addButton(ui->rbrCategoryYearly); fBtnGroup.addButton(ui->rbrOccupancyCategory); fBtnGroup.addButton(ui->rbrNationality); fBtnGroup.addButton(ui->rbrCardex); fBtnGroup.addButton(ui->rbrCardexYearly); fBtnGroup.addButton(ui->rbrNatYearly); fBtnGroup.addButton(ui->rbrNationalityPax); fBtnGroup.addButton(ui->rbrSalesMan); fBtnGroup.addButton(ui->rbrSalesManYearly); fBtnGroup.addButton(ui->rbrArrangement); fBtnGroup.addButton(ui->rbrPax); fBtnGroup.addButton(ui->rbrMarketSigmentYearly); fBtnGroup.addButton(ui->rbrMarketSigment); ui->rbrCategory->fData["rep"] = 5; ui->rbrCategoryYearly->fData["rep"] = 6; ui->rbrOccupancyCategory->fData["rep"] = 7; ui->rbrNationality->fData["rep"] = 8; ui->rbrCardex->fData["rep"] = 9; ui->rbrCardexYearly->fData["rep"] = 10; ui->rbrNatYearly->fData["rep"] = 11; ui->rbrNationalityPax->fData["rep"] = 120; ui->rbrSalesMan->fData["rep"] = 12; ui->rbrSalesManYearly->fData["rep"] = 13; ui->rbrArrangement->fData["rep"] = 14; ui->rbrMarketSigmentYearly->fData["rep"] = 15; ui->rbrMarketSigment->fData["rep"] = 16; connect(ui->tabWidget, &QTabWidget::tabCloseRequested, [this] (int index) { QWidget *w = ui->tabWidget->widget(index); w->deleteLater(); ui->tabWidget->removeTab(index); }); ui->cbYear->setCurrentIndex(ui->cbYear->findText(QDate::currentDate().toString("yyyy"))); } WReportsSetOld::~WReportsSetOld() { delete ui; } void WReportsSetOld::setup() { setupTabTextAndIcon(tr("Statistics"), ":/images/report.png"); } QString WReportsSetOld::title() { return ""; } void WReportsSetOld::rbClicked() { ERadioButton *rb = static_cast<ERadioButton*>(sender()); DatabaseResult dr; fDbBind[":f_id"] = rb->fData["rep"]; dr.select("select f_sql, f_widths, f_titles_en, f_filter, f_sum from serv_reports where f_id=:f_id", fDbBind); if (dr.rowCount() == 0) { message_error_tr("Cannot load report data."); return; } foreach (QWidget* w, fFilterWidgets) { ui->hlFilter->removeWidget(w); delete w; } fFilterWidgets.clear(); ui->hlFilter->removeItem(ui->hlFilter->takeAt(0)); fFilterFields.clear(); fFilterDefExpr.clear(); QStringList filter = dr.value("f_filter").toString().split(";", QString::SkipEmptyParts); int i = 0; foreach (QString s, filter) { QStringList f = s.split("^", QString::KeepEmptyParts); if (f.at(0) == ":year" || f.at(0) == ":month") { continue; } QLabel *l = new QLabel(f.at(1)); fFilterWidgets.append(l); ui->hlFilter->addWidget(l); QWidget *wdt = 0; if (f.at(2).toLower() == "date") { wdt = new EDateEdit(); } else if (f.at(2).toLower() == "integer") { } else if (f.at(2).toLower() == "combobox") { wdt = new EComboBoxCompleter(); EComboBoxCompleter *cc = static_cast<EComboBoxCompleter*>(wdt); QStringList comboParams = f.at(4).split(":", QString::SkipEmptyParts); if (comboParams.at(0).toLower() == "sql") { cc->setSQL(comboParams.at(1)); } else if (comboParams.at(0).toLower() == "list") { QStringList list = comboParams.at(1).split(",", QString::SkipEmptyParts); foreach (QString l, list) { cc->addItem(l, l); } } if (comboParams.count() > 2) { cc->setCurrentIndex(comboParams.at(2).toInt()); } } else if (f.at(2).toLower() == "combo month") { } else { message_error_tr("Unknown filter widget. Contact to administrator."); } if (wdt) { fFilterWidgets.append(wdt); fFilterFields[wdt] = f.at(0); fFilterBuilds[wdt] = f.at(3); fFilterDefExpr[wdt] = f.at(5); ui->hlFilter->addWidget(wdt); if (i == 1) { wdt->setFocus(); } } i++; } ui->hlFilter->addStretch(); } void WReportsSetOld::on_btnGo_clicked() { ERadioButton *eb = static_cast<ERadioButton*>(fBtnGroup.checkedButton()); if (!eb) { return; } fDbBind[":f_id"] = eb->fData["rep"]; DatabaseResult dr; dr.select("select f_sql, f_widths, f_titles_en, f_filter, f_sum, f_name from serv_reports where f_id=:f_id", fDbBind); if (dr.rowCount() == 0) { message_error_tr("Cannot load report data."); return; } QString fFilterSQL = dr.value("f_sql").toString(); QString reportTitle = QString("%1 %2%3") .arg(dr.value("f_name").toString()) .arg(ui->cbYear->currentText()) .arg(static_cast<ERadioButton*>(fBtnMonth.checkedButton())->fData["month"].toInt() > 0 ? "-" + static_cast<ERadioButton*>(fBtnMonth.checkedButton())->fData["month"].toString() : ""); WReportGrid *rg = new WReportGrid(this); ui->tabWidget->addTab(rg, QIcon(":/images/report.png"), reportTitle); rg->setTab(ui->tabWidget, ui->tabWidget->count() - 1); rg->setupTabTextAndIcon(reportTitle, ":/images/report.png"); rg->fModel->clearColumns(); QStringList widths = dr.value("f_widths").toString().split(";", QString::SkipEmptyParts); QStringList titles = dr.value("f_titles_en").toString().split(";", QString::SkipEmptyParts); for (int i = 0; i < widths.count(); i++) { rg->fModel->setColumn(widths.at(i).toInt(), "", titles.at(i)); } QString query = fFilterSQL; query.replace(":year", ui->cbYear->currentText()) .replace(":month", static_cast<ERadioButton*>(fBtnMonth.checkedButton())->fData["month"].toString()); for (QMap<QWidget*, QString>::const_iterator it = fFilterFields.begin(); it != fFilterFields.end(); it++) { if (isEDateEdit(it.key())) { EDateEdit *e = static_cast<EDateEdit*>(it.key()); query.replace(it.value(), e->dateMySql()); } else if (isComboCompleter(it.key()) || isComboMonth(it.key())) { EComboBoxCompleter *c = static_cast<EComboBoxCompleter*>(it.key()); if (c->currentData().toString().isEmpty()) { query.replace(it.value(), fFilterDefExpr[c]); } else { QString repStr = fFilterBuilds[c]; query.replace(it.value(), repStr.replace(it.value(), c->currentData().toString())); } } } rg->fModel->apply(query.split(";", QString::SkipEmptyParts)); ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1); rg->setTblNoTotalData(); QStringList sums = dr.value("f_sum").toString().split(";", QString::SkipEmptyParts); QList<int> cols; QList<double> vals; if (sums.count() > 0) { foreach (QString s, sums) { cols << s.toInt(); } rg->fModel->sumOfColumns(cols, vals); rg->setTblTotalData(cols, vals); } }
[ "end1_1@yahoo.com" ]
end1_1@yahoo.com
5fe8fdffdcd7bcdc7d8c145fc6bd64939955fab3
44dc84c3a5d385c32f1ae891192330ddb0aa6a38
/root/src/Clipper.cpp
9ac40ab9230b7f855814cf7127cfdeb760cb2f9f
[]
no_license
NickBMarine/NicksPix
bd4adfe2ab2e27d2447d30f3960139139ed9e748
03d430c1c68bbde06ff136ea6e6011890de3221d
refs/heads/master
2016-09-06T06:26:41.197059
2011-04-18T05:07:20
2011-04-18T05:07:20
1,243,284
0
0
null
null
null
null
UTF-8
C++
false
false
2,261
cpp
#include "Clipper.h" Clipper::Clipper(NPolygon poly) { _clipPoly = poly; SetBoundaries(); SetBinaryOuts(); } void Clipper::SetBoundaries() { _B[0] = Vertex(1.0f, 0.0f, 0.0f, 1.0f); _B[1] = Vertex(-1.0f, 0.0f, 0.0f, 1.0f); _B[2] = Vertex(0.0f, 1.0f, 0.0f, 1.0f); _B[3] = Vertex(0.0f, -1.0f, 0.0f, 1.0f); _B[4] = Vertex(0.0f, 0.0f, 1.0, 0.0f); _B[5] = Vertex(0.0f, 0.0f, -1.0f, 1.0f); } void Clipper::SetBinaryOuts() { float f; float * fx = &f; unsigned int * fxt = (unsigned int*)fx; for (int i = 0; i < 5; i++) { _biB[i] = *fxt; } _biP[0] = *fxt; _biP[1] = *fxt; _biB[0] = 0x20; _biB[1] = 0x10; _biB[2] = 0x08; _biB[3] = 0x04; _biB[4] = 0x02; _biB[5] = 0x01; _biP[0] = 0x00; _biP[1] = 0x00; } void Clipper::ResetBinaries() { _biP[0] = 0x00; _biP[1] = 0x00; } NPolygon Clipper::GetClippedPoly() { CycleBounds(); _clipPoly.DiscardExtras(); return _clipPoly; } Vertex Clipper::ComputeVert(Vertex P0, Vertex P1, Vertex boundary) { float u; Vertex diffVert; float BC0; float BC1; Vertex tempVert; diffVert = P1.SubtractHom(P0); BC0 = P0.GetDotHom(boundary); BC1 = P1.GetDotHom(boundary); u = (BC0/(BC0 - BC1)); tempVert = P0 + (diffVert * u); return tempVert; } void Clipper::CycleBounds() { NPolygon t; for ( int i = 0; i < 5; i++) { _clipPoly.DiscardExtras(); t.ClearPoly(); t = _clipPoly; _clipPoly.ClearPoly(); int sides = t.GetSides(); for (int j = 0; j < sides; j++) { if (t._vertices[j].GetDotHom(_B[i]) < 0) { _biP[0] += _biB[i]; } if (t._vertices[(j+1)%sides].GetDotHom(_B[i]) < 0) { _biP[1] += _biB[i]; } if ((_biP[0] | _biP[1]) == 0x00) { _clipPoly.AddPoint(t._vertices[j]); _clipPoly.AddPoint(t._vertices[(j+1)%sides]); } if ((_biP[0] & _biP[1]) == 0x00) { Vertex tempVerts; if ( _biP[0] != 0x00) { tempVerts = ComputeVert(t._vertices[j], t._vertices[(j+1)%sides], _B[i]); _clipPoly.AddPoint(tempVerts); _clipPoly.AddPoint(t._vertices[(j+1)%sides]); } if ( _biP[1] != 0x00) { tempVerts = ComputeVert(t._vertices[(j+1)%sides], t._vertices[j], _B[i]); _clipPoly.AddPoint(t._vertices[j]); _clipPoly.AddPoint(tempVerts); } } ResetBinaries(); } } }
[ "Nick and Christine@.(none)" ]
Nick and Christine@.(none)
4c8ebe0aa6d5a093ad1a9b51a9fa899046eb613c
8e5798c3cc39ada1ac18ef9f2bf07bc084029b7e
/Bulls/Simple/BullCowGame.cpp
531b43ad70cf9b365916621b3bf724519340cf7c
[ "MIT" ]
permissive
NathanKr/CPP
07a43d0f84f599ef7d99b88cbc8023eec3da6259
62f9c996af49e42d9f4e2ff1961a59fbb2b29d6d
refs/heads/master
2020-04-05T07:14:42.193351
2019-01-14T08:41:33
2019-01-14T08:41:33
156,668,246
0
0
null
null
null
null
UTF-8
C++
false
false
2,590
cpp
#include "BullCowGame.h" #include <string> #include <stdlib.h> /* srand, rand */ #include <time.h> /* time */ void BullCowGame::Reset() { clear(); } size_t BullCowGame::GetMaxTries() const { return m_nMaxTries; } size_t BullCowGame::GetCurrentTry() const { return m_nCurrentTry; } bool BullCowGame::IsGameWon() const { return m_bGameWon; } bool BullCowGame::isAllLower(std::string strGuess) { bool bIsAllLOwer = true; for (char letter : strGuess) { if (!((letter >= 'a') && (letter <= 'z'))) { bIsAllLOwer = false; break; } } return bIsAllLOwer; } GuessStatus BullCowGame::CheckGuessValid(std::string strGuess) const { GuessStatus status = GuessStatus::Ok; if (strGuess.length() != m_strHiddenWord.length()) { status = GuessStatus::Wrong_Number_Of_Letters; } else if (!isAllLower(strGuess)) { status = GuessStatus::Only_Lowercase_Letters_Allowed; } else if (!isAllUnique(strGuess)) { status = GuessStatus::Letter_Is_Not_Unique; } return status; } bool BullCowGame::isUnique(char c, std::string strGuess) { int nCount = 0; for (char letter : strGuess) { if (c == letter) { nCount++; if (nCount > 1) { return false; } } } return true; } bool BullCowGame::isAllUnique(std::string strGuess) { for (char letter : strGuess) { if (!isUnique(letter,strGuess)) { return false; } } return true; } /* assume input is valid so we also increment m_nCurrentTry */ BullCowCount BullCowGame::SubmitValidGuess(std::string strGuess) { BullCowCount count; m_nCurrentTry++; for (size_t i = 0; i < m_strHiddenWord.length(); i++) { if (m_strHiddenWord[i] == strGuess[i]) { count.bulls++; } else { size_t found = m_strHiddenWord.find(strGuess[i]); if ((found >= 0) && (found < m_strHiddenWord.length())) { count.cows++; } } } m_bGameWon = (count.bulls == m_strHiddenWord.length()); return count; } BullCowGame::BullCowGame(int nMaxTries , int nWorldLength) : m_strHiddenWord(nWorldLength,' ') { m_nMaxTries = nMaxTries; clear(); } bool BullCowGame::doesExist(char c, std::string strGuess) { return strGuess.find(c) != std::string::npos; } void BullCowGame::clear() { srand((unsigned int)time(NULL)); int nNumLetters = 'z' - 'a' + 1, nSecret ; char cSecret; for (size_t i = 0; i < m_strHiddenWord.length(); i++) { do { nSecret = rand() % nNumLetters; cSecret = (char)('a' + nSecret); } while (doesExist(cSecret, m_strHiddenWord)); m_strHiddenWord[i] = cSecret; } m_nCurrentTry = 0; // --- it is incremented in SubmitGuess m_bGameWon = false; }
[ "natankrasney@gmail.com" ]
natankrasney@gmail.com
35643db53dcf0fd0c1f923825fb0430c5681bd4c
fc57402c4d8e200d2d2d297de92a302df464e834
/UniversalLibs/Umove/demo/UiUmoveTestVehicle.cpp
37781f468af0bb47d6aecd7c6c3e213db8457bcc
[]
no_license
vladsopen/fragments
07f5bb7e478c95db75e5091c86d3a9f8f7e180a8
41d59d0fc7ed3d0d3bd23c02136ab8f11c40df11
refs/heads/master
2022-01-11T23:29:21.562445
2019-07-03T21:23:34
2019-07-03T21:23:34
195,126,945
0
0
null
null
null
null
UTF-8
C++
false
false
3,808
cpp
// UiUmoveTestVehicle.cpp #include "CProject.h" #include "CDemoVehicle.h" #include "CUmoveIfaceGp.h" #include "CUmoveTest.h" void UiUmoveTestVehicle::Ui() { ref<CUmoveIfaceGp> rUmove = m_rDemoVehicle-> x_rUmove; // // this // { ref<CUiPanelGp> rUi = this; m_rDemoVehicle->_m_ptrmapUiUmoveTestVehicle += rUi; if (m_rDemoVehicle->x_bUnmovable) { rUi->SetDisableInfo( "Disabled Vehicle cannot be moved. " "Also the demo does not allow another vehicle box at this " "position to show you how to restrict movements."); } rUi->SetIndependentShape(true); rUi->OnIndependentShape = [=] { //TODO: you must ask Umove the Vehicle position point pointVehicle = rUmove-> GetVehiclePosInParentPanel( m_rUmoveTest->x_sizeUmoveVehicleParent); rUi->SetInstantPos(pointVehicle.x, pointVehicle.y); //TODO: you must make sure you told Umove the correct Vehicle size size sizeVehicle = rUmove->x_sizeVehicle; // horizontal marker logic if (m_rDemoVehicle->x_bStretchWidthAsForHorizontalMarker) { sizeVehicle.w = m_rUmoveTest->x_sizeUmoveVehicleParent.Get().w; rUmove->x_sizeVehicle = sizeVehicle; } // vertical marker logic if (m_rDemoVehicle->x_bStretchHeightAsForVerticalMarker) { sizeVehicle.h = m_rUmoveTest->x_sizeUmoveVehicleParent.Get().h; rUmove->x_sizeVehicle = sizeVehicle; } rUi->SetInstantSize(sizeVehicle.w, sizeVehicle.h); } rUi->OnMouse = [=] { // save prev pos point pointOldPos = rUmove-> x_pointLogicalVehiclePos; //TODO: you must allow Umove hook mouse drag and drop bool bMoved = rUmove-> HandleVehicleOnMouse( m_rUmoveTest->x_sizeUmoveVehicleParent, rUi, GetOnMouseEvent()); if (bMoved) { // here we can restrict new position point pointNewPos = rUmove-> x_pointLogicalVehiclePos; if (pointNewPos.x == m_rDemoVehicle->x_pointForbiddenPlace.Get().x && pointNewPos.y == m_rDemoVehicle->x_pointForbiddenPlace.Get().y) { // force previous position rUmove-> x_pointLogicalVehiclePos = pointOldPos; } // we've got a new position. OnModifyShape will take care rUi->InvalidateLayout(); m_rUmoveTest->UpdateForNewVehiclePositions(); // DO NOT INVALIDATE CONTENT HERE you'll break mouse capture! } } } // // The content which is being Moved // { ref<CUiButtonGp> rUi; // stretch to Vehicle panel independent shape rUi->SetMaxX(oo); rUi->SetMaxY(oo); //TODO: if you don't want to invent the wheel ask Umove cursor rUi->SetCursor(rUmove->GetUmoveCursorForVehicle()); if (m_rDemoVehicle->x_bUnmovable) { rUi->SetIcon(RES__CANCEL_ICON()); rUi->SetAlignContentToCenterX(); rUi->SetAlignContentToCenterY(); } } }
[ "vladsprog@gmail.com" ]
vladsprog@gmail.com
f9d8f68bf0cd93ade5ed922d27560a4a69f5b5fa
7ec6bbd1ff6600be1de4e8a41bcea38ba8fc7079
/Graphics/source/VertexShader.cpp
66df27ad6db2e31f75f86756cf0203b6a909e783
[]
no_license
ruulaasz/Diablito
6f51c8e2724ff3ff6ff63622ab6eeeddd2c6b922
92a1b9b0b89fbb4cdb2009acc85d4dff38c29d38
refs/heads/master
2021-01-22T23:10:26.286830
2017-06-08T03:56:47
2017-06-08T03:56:47
92,801,684
0
0
null
null
null
null
UTF-8
C++
false
false
633
cpp
#include "VertexShader.h" VertexShader::VertexShader() { m_vertexShader = nullptr; } VertexShader::~VertexShader() { } void VertexShader::createVertexShader(ID3D11Device* _device, WCHAR* _szFileName, LPCSTR _szEntryPoint, LPCSTR _szShaderModel) { compileShaderFromFile(_szFileName, _szEntryPoint, _szShaderModel, &m_shaderBlob); if (!m_shaderBlob) { throw "CreationFailed m_shaderBlob"; } _device->CreateVertexShader(m_shaderBlob->GetBufferPointer(), m_shaderBlob->GetBufferSize(), nullptr, &m_vertexShader); if (!m_vertexShader) { m_shaderBlob->Release(); throw "CreationFailed m_vertexShader"; } }
[ "ruulaasz.28gmail.com" ]
ruulaasz.28gmail.com
dcb5009edaf330edbb9c50ffd90395a824bb80d1
7d07a4453b6faad6cbc24d44caaa3ad1ab6ebe7f
/src/generic/scrlwing.cpp
9ceda4929ad9be3408d1a5d00fb1adc2738619f9
[]
no_license
rickyzhang82/wxpython-src-2.9.4.0
5a7fff6156fbf9ec1f372a3c6afa860c59bf8ea8
c9269e81638ccb74ae5086557567592aaa2aa695
refs/heads/master
2020-05-24T12:12:13.805532
2019-05-17T17:34:34
2019-05-17T17:34:34
187,259,114
0
0
null
null
null
null
UTF-8
C++
false
false
50,997
cpp
///////////////////////////////////////////////////////////////////////////// // Name: src/generic/scrlwing.cpp // Purpose: wxScrolledWindow implementation // Author: Julian Smart // Modified by: Vadim Zeitlin on 31.08.00: wxScrollHelper allows to implement. // Ron Lee on 10.4.02: virtual size / auto scrollbars et al. // Created: 01/02/97 // RCS-ID: $Id: scrlwing.cpp 70443 2012-01-23 11:28:12Z VZ $ // Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ // declarations // ============================================================================ // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #include "wx/scrolwin.h" #ifndef WX_PRECOMP #include "wx/utils.h" #include "wx/panel.h" #include "wx/dcclient.h" #include "wx/timer.h" #include "wx/sizer.h" #include "wx/settings.h" #endif #ifdef __WXMAC__ #include "wx/scrolbar.h" #endif #include "wx/recguard.h" #ifdef __WXMSW__ #include <windows.h> // for DLGC_WANTARROWS #include "wx/msw/winundef.h" #endif #ifdef __WXMOTIF__ // For wxRETAINED implementation #ifdef __VMS__ //VMS's Xm.h is not (yet) compatible with C++ //This code switches off the compiler warnings # pragma message disable nosimpint #endif #include <Xm/Xm.h> #ifdef __VMS__ # pragma message enable nosimpint #endif #endif /* TODO PROPERTIES style wxHSCROLL | wxVSCROLL */ // ---------------------------------------------------------------------------- // wxScrollHelperEvtHandler: intercept the events from the window and forward // them to wxScrollHelper // ---------------------------------------------------------------------------- class WXDLLEXPORT wxScrollHelperEvtHandler : public wxEvtHandler { public: wxScrollHelperEvtHandler(wxScrollHelperBase *scrollHelper) { m_scrollHelper = scrollHelper; } virtual bool ProcessEvent(wxEvent& event); void ResetDrawnFlag() { m_hasDrawnWindow = false; } private: wxScrollHelperBase *m_scrollHelper; bool m_hasDrawnWindow; wxDECLARE_NO_COPY_CLASS(wxScrollHelperEvtHandler); }; #if wxUSE_TIMER // ---------------------------------------------------------------------------- // wxAutoScrollTimer: the timer used to generate a stream of scroll events when // a captured mouse is held outside the window // ---------------------------------------------------------------------------- class wxAutoScrollTimer : public wxTimer { public: wxAutoScrollTimer(wxWindow *winToScroll, wxScrollHelperBase *scroll, wxEventType eventTypeToSend, int pos, int orient); virtual void Notify(); private: wxWindow *m_win; wxScrollHelperBase *m_scrollHelper; wxEventType m_eventType; int m_pos, m_orient; wxDECLARE_NO_COPY_CLASS(wxAutoScrollTimer); }; // ============================================================================ // implementation // ============================================================================ // ---------------------------------------------------------------------------- // wxAutoScrollTimer // ---------------------------------------------------------------------------- wxAutoScrollTimer::wxAutoScrollTimer(wxWindow *winToScroll, wxScrollHelperBase *scroll, wxEventType eventTypeToSend, int pos, int orient) { m_win = winToScroll; m_scrollHelper = scroll; m_eventType = eventTypeToSend; m_pos = pos; m_orient = orient; } void wxAutoScrollTimer::Notify() { // only do all this as long as the window is capturing the mouse if ( wxWindow::GetCapture() != m_win ) { Stop(); } else // we still capture the mouse, continue generating events { // first scroll the window if we are allowed to do it wxScrollWinEvent event1(m_eventType, m_pos, m_orient); event1.SetEventObject(m_win); if ( m_scrollHelper->SendAutoScrollEvents(event1) && m_win->GetEventHandler()->ProcessEvent(event1) ) { // and then send a pseudo mouse-move event to refresh the selection wxMouseEvent event2(wxEVT_MOTION); event2.SetPosition(wxGetMousePosition()); // the mouse event coordinates should be client, not screen as // returned by wxGetMousePosition wxWindow *parentTop = m_win; while ( parentTop->GetParent() ) parentTop = parentTop->GetParent(); wxPoint ptOrig = parentTop->GetPosition(); event2.m_x -= ptOrig.x; event2.m_y -= ptOrig.y; event2.SetEventObject(m_win); // FIXME: we don't fill in the other members - ok? m_win->GetEventHandler()->ProcessEvent(event2); } else // can't scroll further, stop { Stop(); } } } #endif // ---------------------------------------------------------------------------- // wxScrollHelperEvtHandler // ---------------------------------------------------------------------------- bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) { wxEventType evType = event.GetEventType(); // the explanation of wxEVT_PAINT processing hack: for historic reasons // there are 2 ways to process this event in classes deriving from // wxScrolledWindow. The user code may // // 1. override wxScrolledWindow::OnDraw(dc) // 2. define its own OnPaint() handler // // In addition, in wxUniversal wxWindow defines OnPaint() itself and // always processes the draw event, so we can't just try the window // OnPaint() first and call our HandleOnPaint() if it doesn't process it // (the latter would never be called in wxUniversal). // // So the solution is to have a flag telling us whether the user code drew // anything in the window. We set it to true here but reset it to false in // wxScrolledWindow::OnPaint() handler (which wouldn't be called if the // user code defined OnPaint() in the derived class) m_hasDrawnWindow = true; // Pass it on to the real handler: notice that we must not call // ProcessEvent() on this object itself as it wouldn't pass it to the next // handler (i.e. the real window) if we're called from a previous handler // (as indicated by "process here only" flag being set) and we do want to // execute the handler defined in the window we're associated with right // now, without waiting until TryAfter() is called from wxEvtHandler. bool processed = m_nextHandler->ProcessEvent(event); // always process the size events ourselves, even if the user code handles // them as well, as we need to AdjustScrollbars() // // NB: it is important to do it after processing the event in the normal // way as HandleOnSize() may generate a wxEVT_SIZE itself if the // scrollbar[s] (dis)appear and it should be seen by the user code // after this one if ( evType == wxEVT_SIZE ) { m_scrollHelper->HandleOnSize((wxSizeEvent &)event); return true; } if ( processed ) { // normally, nothing more to do here - except if it was a paint event // which wasn't really processed, then we'll try to call our // OnDraw() below (from HandleOnPaint) if ( m_hasDrawnWindow || event.IsCommandEvent() ) { return true; } } if ( evType == wxEVT_PAINT ) { m_scrollHelper->HandleOnPaint((wxPaintEvent &)event); return true; } if ( evType == wxEVT_CHILD_FOCUS ) { m_scrollHelper->HandleOnChildFocus((wxChildFocusEvent &)event); return true; } // reset the skipped flag (which might have been set to true in // ProcessEvent() above) to be able to test it below bool wasSkipped = event.GetSkipped(); if ( wasSkipped ) event.Skip(false); if ( evType == wxEVT_SCROLLWIN_TOP || evType == wxEVT_SCROLLWIN_BOTTOM || evType == wxEVT_SCROLLWIN_LINEUP || evType == wxEVT_SCROLLWIN_LINEDOWN || evType == wxEVT_SCROLLWIN_PAGEUP || evType == wxEVT_SCROLLWIN_PAGEDOWN || evType == wxEVT_SCROLLWIN_THUMBTRACK || evType == wxEVT_SCROLLWIN_THUMBRELEASE ) { m_scrollHelper->HandleOnScroll((wxScrollWinEvent &)event); if ( !event.GetSkipped() ) { // it makes sense to indicate that we processed the message as we // did scroll the window (and also notice that wxAutoScrollTimer // relies on our return value to stop scrolling when we are at top // or bottom already) processed = true; wasSkipped = false; } } if ( evType == wxEVT_ENTER_WINDOW ) { m_scrollHelper->HandleOnMouseEnter((wxMouseEvent &)event); } else if ( evType == wxEVT_LEAVE_WINDOW ) { m_scrollHelper->HandleOnMouseLeave((wxMouseEvent &)event); } #if wxUSE_MOUSEWHEEL // Use GTK's own scroll wheel handling in GtkScrolledWindow #ifndef __WXGTK20__ else if ( evType == wxEVT_MOUSEWHEEL ) { m_scrollHelper->HandleOnMouseWheel((wxMouseEvent &)event); return true; } #endif #endif // wxUSE_MOUSEWHEEL else if ( evType == wxEVT_CHAR ) { m_scrollHelper->HandleOnChar((wxKeyEvent &)event); if ( !event.GetSkipped() ) { processed = true; wasSkipped = false; } } event.Skip(wasSkipped); // We called ProcessEvent() on the next handler, meaning that we explicitly // worked around the request to process the event in this handler only. As // explained above, this is unfortunately really necessary but the trouble // is that the event will continue to be post-processed by the previous // handler resulting in duplicate calls to event handlers. Call the special // function below to prevent this from happening, base class DoTryChain() // will check for it and behave accordingly. // // And if we're not called from DoTryChain(), this won't do anything anyhow. event.DidntHonourProcessOnlyIn(); return processed; } // ============================================================================ // wxScrollHelperBase implementation // ============================================================================ // ---------------------------------------------------------------------------- // wxScrollHelperBase construction // ---------------------------------------------------------------------------- wxScrollHelperBase::wxScrollHelperBase(wxWindow *win) { wxASSERT_MSG( win, wxT("associated window can't be NULL in wxScrollHelper") ); m_xScrollPixelsPerLine = m_yScrollPixelsPerLine = m_xScrollPosition = m_yScrollPosition = m_xScrollLines = m_yScrollLines = m_xScrollLinesPerPage = m_yScrollLinesPerPage = 0; m_xScrollingEnabled = m_yScrollingEnabled = true; m_kbdScrollingEnabled = true; m_scaleX = m_scaleY = 1.0; #if wxUSE_MOUSEWHEEL m_wheelRotation = 0; #endif m_win = m_targetWindow = NULL; m_timerAutoScroll = NULL; m_handler = NULL; m_win = win; m_win->SetScrollHelper(static_cast<wxScrollHelper *>(this)); // by default, the associated window is also the target window DoSetTargetWindow(win); } wxScrollHelperBase::~wxScrollHelperBase() { StopAutoScrolling(); DeleteEvtHandler(); } // ---------------------------------------------------------------------------- // setting scrolling parameters // ---------------------------------------------------------------------------- void wxScrollHelperBase::SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, int noUnitsX, int noUnitsY, int xPos, int yPos, bool noRefresh) { // Convert positions expressed in scroll units to positions in pixels. int xPosInPixels = (xPos + m_xScrollPosition)*m_xScrollPixelsPerLine, yPosInPixels = (yPos + m_yScrollPosition)*m_yScrollPixelsPerLine; bool do_refresh = ( (noUnitsX != 0 && m_xScrollLines == 0) || (noUnitsX < m_xScrollLines && xPosInPixels > pixelsPerUnitX * noUnitsX) || (noUnitsY != 0 && m_yScrollLines == 0) || (noUnitsY < m_yScrollLines && yPosInPixels > pixelsPerUnitY * noUnitsY) || (xPos != m_xScrollPosition) || (yPos != m_yScrollPosition) ); m_xScrollPixelsPerLine = pixelsPerUnitX; m_yScrollPixelsPerLine = pixelsPerUnitY; m_xScrollPosition = xPos; m_yScrollPosition = yPos; int w = noUnitsX * pixelsPerUnitX; int h = noUnitsY * pixelsPerUnitY; // For better backward compatibility we set persisting limits // here not just the size. It makes SetScrollbars 'sticky' // emulating the old non-autoscroll behaviour. // m_targetWindow->SetVirtualSizeHints( w, h ); // The above should arguably be deprecated, this however we still need. // take care not to set 0 virtual size, 0 means that we don't have any // scrollbars and hence we should use the real size instead of the virtual // one which is indicated by using wxDefaultCoord m_targetWindow->SetVirtualSize( w ? w : wxDefaultCoord, h ? h : wxDefaultCoord); if (do_refresh && !noRefresh) m_targetWindow->Refresh(true, GetScrollRect()); #ifndef __WXUNIVERSAL__ // If the target is not the same as the window with the scrollbars, // then we need to update the scrollbars here, since they won't have // been updated by SetVirtualSize(). if ( m_targetWindow != m_win ) #endif // !__WXUNIVERSAL__ { AdjustScrollbars(); } #ifndef __WXUNIVERSAL__ else { // otherwise this has been done by AdjustScrollbars, above } #endif // !__WXUNIVERSAL__ } // ---------------------------------------------------------------------------- // [target] window handling // ---------------------------------------------------------------------------- void wxScrollHelperBase::DeleteEvtHandler() { // search for m_handler in the handler list if ( m_win && m_handler ) { if ( m_win->RemoveEventHandler(m_handler) ) { delete m_handler; } //else: something is very wrong, so better [maybe] leak memory than // risk a crash because of double deletion m_handler = NULL; } } void wxScrollHelperBase::ResetDrawnFlag() { wxCHECK_RET( m_handler, "invalid use of ResetDrawnFlag - no handler?" ); m_handler->ResetDrawnFlag(); } void wxScrollHelperBase::DoSetTargetWindow(wxWindow *target) { m_targetWindow = target; #ifdef __WXMAC__ target->MacSetClipChildren( true ) ; #endif // install the event handler which will intercept the events we're // interested in (but only do it for our real window, not the target window // which we scroll - we don't need to hijack its events) if ( m_targetWindow == m_win ) { // if we already have a handler, delete it first DeleteEvtHandler(); m_handler = new wxScrollHelperEvtHandler(this); m_targetWindow->PushEventHandler(m_handler); } } void wxScrollHelperBase::SetTargetWindow(wxWindow *target) { wxCHECK_RET( target, wxT("target window must not be NULL") ); if ( target == m_targetWindow ) return; DoSetTargetWindow(target); } wxWindow *wxScrollHelperBase::GetTargetWindow() const { return m_targetWindow; } // ---------------------------------------------------------------------------- // scrolling implementation itself // ---------------------------------------------------------------------------- void wxScrollHelperBase::HandleOnScroll(wxScrollWinEvent& event) { int nScrollInc = CalcScrollInc(event); if ( nScrollInc == 0 ) { // can't scroll further event.Skip(); return; } bool needsRefresh = false; int dx = 0, dy = 0; int orient = event.GetOrientation(); if (orient == wxHORIZONTAL) { if ( m_xScrollingEnabled ) { dx = -m_xScrollPixelsPerLine * nScrollInc; } else { needsRefresh = true; } } else { if ( m_yScrollingEnabled ) { dy = -m_yScrollPixelsPerLine * nScrollInc; } else { needsRefresh = true; } } if ( !needsRefresh ) { // flush all pending repaints before we change m_{x,y}ScrollPosition, as // otherwise invalidated area could be updated incorrectly later when // ScrollWindow() makes sure they're repainted before scrolling them #ifdef __WXMAC__ // wxWindowMac is taking care of making sure the update area is correctly // set up, while not forcing an immediate redraw #else m_targetWindow->Update(); #endif } if (orient == wxHORIZONTAL) { m_xScrollPosition += nScrollInc; m_win->SetScrollPos(wxHORIZONTAL, m_xScrollPosition); } else { m_yScrollPosition += nScrollInc; m_win->SetScrollPos(wxVERTICAL, m_yScrollPosition); } if ( needsRefresh ) { m_targetWindow->Refresh(true, GetScrollRect()); } else { m_targetWindow->ScrollWindow(dx, dy, GetScrollRect()); } } int wxScrollHelperBase::CalcScrollInc(wxScrollWinEvent& event) { int pos = event.GetPosition(); int orient = event.GetOrientation(); int nScrollInc = 0; if (event.GetEventType() == wxEVT_SCROLLWIN_TOP) { if (orient == wxHORIZONTAL) nScrollInc = - m_xScrollPosition; else nScrollInc = - m_yScrollPosition; } else if (event.GetEventType() == wxEVT_SCROLLWIN_BOTTOM) { if (orient == wxHORIZONTAL) nScrollInc = m_xScrollLines - m_xScrollPosition; else nScrollInc = m_yScrollLines - m_yScrollPosition; } else if (event.GetEventType() == wxEVT_SCROLLWIN_LINEUP) { nScrollInc = -1; } else if (event.GetEventType() == wxEVT_SCROLLWIN_LINEDOWN) { nScrollInc = 1; } else if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEUP) { if (orient == wxHORIZONTAL) nScrollInc = -GetScrollPageSize(wxHORIZONTAL); else nScrollInc = -GetScrollPageSize(wxVERTICAL); } else if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN) { if (orient == wxHORIZONTAL) nScrollInc = GetScrollPageSize(wxHORIZONTAL); else nScrollInc = GetScrollPageSize(wxVERTICAL); } else if ((event.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK) || (event.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE)) { if (orient == wxHORIZONTAL) nScrollInc = pos - m_xScrollPosition; else nScrollInc = pos - m_yScrollPosition; } if (orient == wxHORIZONTAL) { if ( m_xScrollPosition + nScrollInc < 0 ) { // As -ve as we can go nScrollInc = -m_xScrollPosition; } else // check for the other bound { const int posMax = m_xScrollLines - m_xScrollLinesPerPage; if ( m_xScrollPosition + nScrollInc > posMax ) { // As +ve as we can go nScrollInc = posMax - m_xScrollPosition; } } } else // wxVERTICAL { if ( m_yScrollPosition + nScrollInc < 0 ) { // As -ve as we can go nScrollInc = -m_yScrollPosition; } else // check for the other bound { const int posMax = m_yScrollLines - m_yScrollLinesPerPage; if ( m_yScrollPosition + nScrollInc > posMax ) { // As +ve as we can go nScrollInc = posMax - m_yScrollPosition; } } } return nScrollInc; } void wxScrollHelperBase::DoPrepareDC(wxDC& dc) { wxPoint pt = dc.GetDeviceOrigin(); #ifdef __WXGTK__ // It may actually be correct to always query // the m_sign from the DC here, but I leave the // #ifdef GTK for now. if (m_win->GetLayoutDirection() == wxLayout_RightToLeft) dc.SetDeviceOrigin( pt.x + m_xScrollPosition * m_xScrollPixelsPerLine, pt.y - m_yScrollPosition * m_yScrollPixelsPerLine ); else #endif dc.SetDeviceOrigin( pt.x - m_xScrollPosition * m_xScrollPixelsPerLine, pt.y - m_yScrollPosition * m_yScrollPixelsPerLine ); dc.SetUserScale( m_scaleX, m_scaleY ); } void wxScrollHelperBase::SetScrollRate( int xstep, int ystep ) { int old_x = m_xScrollPixelsPerLine * m_xScrollPosition; int old_y = m_yScrollPixelsPerLine * m_yScrollPosition; m_xScrollPixelsPerLine = xstep; m_yScrollPixelsPerLine = ystep; int new_x = m_xScrollPixelsPerLine * m_xScrollPosition; int new_y = m_yScrollPixelsPerLine * m_yScrollPosition; m_win->SetScrollPos( wxHORIZONTAL, m_xScrollPosition ); m_win->SetScrollPos( wxVERTICAL, m_yScrollPosition ); m_targetWindow->ScrollWindow( old_x - new_x, old_y - new_y ); AdjustScrollbars(); } void wxScrollHelperBase::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const { if ( x_unit ) *x_unit = m_xScrollPixelsPerLine; if ( y_unit ) *y_unit = m_yScrollPixelsPerLine; } int wxScrollHelperBase::GetScrollLines( int orient ) const { if ( orient == wxHORIZONTAL ) return m_xScrollLines; else return m_yScrollLines; } int wxScrollHelperBase::GetScrollPageSize(int orient) const { if ( orient == wxHORIZONTAL ) return m_xScrollLinesPerPage; else return m_yScrollLinesPerPage; } void wxScrollHelperBase::SetScrollPageSize(int orient, int pageSize) { if ( orient == wxHORIZONTAL ) m_xScrollLinesPerPage = pageSize; else m_yScrollLinesPerPage = pageSize; } void wxScrollHelperBase::EnableScrolling (bool x_scroll, bool y_scroll) { m_xScrollingEnabled = x_scroll; m_yScrollingEnabled = y_scroll; } // Where the current view starts from void wxScrollHelperBase::DoGetViewStart (int *x, int *y) const { if ( x ) *x = m_xScrollPosition; if ( y ) *y = m_yScrollPosition; } void wxScrollHelperBase::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine; if ( yy ) *yy = y - m_yScrollPosition * m_yScrollPixelsPerLine; } void wxScrollHelperBase::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine; if ( yy ) *yy = y + m_yScrollPosition * m_yScrollPixelsPerLine; } // ---------------------------------------------------------------------------- // geometry // ---------------------------------------------------------------------------- bool wxScrollHelperBase::ScrollLayout() { if ( m_win->GetSizer() && m_targetWindow == m_win ) { // If we're the scroll target, take into account the // virtual size and scrolled position of the window. int x = 0, y = 0, w = 0, h = 0; CalcScrolledPosition(0,0, &x,&y); m_win->GetVirtualSize(&w, &h); m_win->GetSizer()->SetDimension(x, y, w, h); return true; } // fall back to default for LayoutConstraints return m_win->wxWindow::Layout(); } void wxScrollHelperBase::ScrollDoSetVirtualSize(int x, int y) { m_win->wxWindow::DoSetVirtualSize( x, y ); AdjustScrollbars(); if (m_win->GetAutoLayout()) m_win->Layout(); } // wxWindow's GetBestVirtualSize returns the actual window size, // whereas we want to return the virtual size wxSize wxScrollHelperBase::ScrollGetBestVirtualSize() const { wxSize clientSize(m_win->GetClientSize()); if ( m_win->GetSizer() ) clientSize.IncTo(m_win->GetSizer()->CalcMin()); return clientSize; } // ---------------------------------------------------------------------------- // event handlers // ---------------------------------------------------------------------------- // Default OnSize resets scrollbars, if any void wxScrollHelperBase::HandleOnSize(wxSizeEvent& WXUNUSED(event)) { if ( m_targetWindow->GetAutoLayout() ) { wxSize size = m_targetWindow->GetBestVirtualSize(); // This will call ::Layout() and ::AdjustScrollbars() m_win->SetVirtualSize( size ); } else { AdjustScrollbars(); } } // This calls OnDraw, having adjusted the origin according to the current // scroll position void wxScrollHelperBase::HandleOnPaint(wxPaintEvent& WXUNUSED(event)) { // don't use m_targetWindow here, this is always called for ourselves wxPaintDC dc(m_win); DoPrepareDC(dc); OnDraw(dc); } // kbd handling: notice that we use OnChar() and not OnKeyDown() for // compatibility here - if we used OnKeyDown(), the programs which process // arrows themselves in their OnChar() would never get the message and like // this they always have the priority void wxScrollHelperBase::HandleOnChar(wxKeyEvent& event) { if ( !m_kbdScrollingEnabled ) { event.Skip(); return; } // prepare the event this key press maps to wxScrollWinEvent newEvent; newEvent.SetPosition(0); newEvent.SetEventObject(m_win); // this is the default, it's changed to wxHORIZONTAL below if needed newEvent.SetOrientation(wxVERTICAL); // some key events result in scrolling in both horizontal and vertical // direction, e.g. Ctrl-{Home,End}, if this flag is true we should generate // a second event in horizontal direction in addition to the primary one bool sendHorizontalToo = false; switch ( event.GetKeyCode() ) { case WXK_PAGEUP: newEvent.SetEventType(wxEVT_SCROLLWIN_PAGEUP); break; case WXK_PAGEDOWN: newEvent.SetEventType(wxEVT_SCROLLWIN_PAGEDOWN); break; case WXK_HOME: newEvent.SetEventType(wxEVT_SCROLLWIN_TOP); sendHorizontalToo = event.ControlDown(); break; case WXK_END: newEvent.SetEventType(wxEVT_SCROLLWIN_BOTTOM); sendHorizontalToo = event.ControlDown(); break; case WXK_LEFT: newEvent.SetOrientation(wxHORIZONTAL); // fall through case WXK_UP: newEvent.SetEventType(wxEVT_SCROLLWIN_LINEUP); break; case WXK_RIGHT: newEvent.SetOrientation(wxHORIZONTAL); // fall through case WXK_DOWN: newEvent.SetEventType(wxEVT_SCROLLWIN_LINEDOWN); break; default: // not a scrolling key event.Skip(); return; } m_win->ProcessWindowEvent(newEvent); if ( sendHorizontalToo ) { newEvent.SetOrientation(wxHORIZONTAL); m_win->ProcessWindowEvent(newEvent); } } // ---------------------------------------------------------------------------- // autoscroll stuff: these functions deal with sending fake scroll events when // a captured mouse is being held outside the window // ---------------------------------------------------------------------------- bool wxScrollHelperBase::SendAutoScrollEvents(wxScrollWinEvent& event) const { // only send the event if the window is scrollable in this direction wxWindow *win = (wxWindow *)event.GetEventObject(); return win->HasScrollbar(event.GetOrientation()); } void wxScrollHelperBase::StopAutoScrolling() { #if wxUSE_TIMER wxDELETE(m_timerAutoScroll); #endif } void wxScrollHelperBase::HandleOnMouseEnter(wxMouseEvent& event) { StopAutoScrolling(); event.Skip(); } void wxScrollHelperBase::HandleOnMouseLeave(wxMouseEvent& event) { // don't prevent the usual processing of the event from taking place event.Skip(); // when a captured mouse leave a scrolled window we start generate // scrolling events to allow, for example, extending selection beyond the // visible area in some controls if ( wxWindow::GetCapture() == m_targetWindow ) { // where is the mouse leaving? int pos, orient; wxPoint pt = event.GetPosition(); if ( pt.x < 0 ) { orient = wxHORIZONTAL; pos = 0; } else if ( pt.y < 0 ) { orient = wxVERTICAL; pos = 0; } else // we're lower or to the right of the window { wxSize size = m_targetWindow->GetClientSize(); if ( pt.x > size.x ) { orient = wxHORIZONTAL; pos = m_xScrollLines; } else if ( pt.y > size.y ) { orient = wxVERTICAL; pos = m_yScrollLines; } else // this should be impossible { // but seems to happen sometimes under wxMSW - maybe it's a bug // there but for now just ignore it //wxFAIL_MSG( wxT("can't understand where has mouse gone") ); return; } } // only start the auto scroll timer if the window can be scrolled in // this direction if ( !m_targetWindow->HasScrollbar(orient) ) return; #if wxUSE_TIMER delete m_timerAutoScroll; m_timerAutoScroll = new wxAutoScrollTimer ( m_targetWindow, this, pos == 0 ? wxEVT_SCROLLWIN_LINEUP : wxEVT_SCROLLWIN_LINEDOWN, pos, orient ); m_timerAutoScroll->Start(50); // FIXME: make configurable #else wxUnusedVar(pos); #endif } } #if wxUSE_MOUSEWHEEL void wxScrollHelperBase::HandleOnMouseWheel(wxMouseEvent& event) { m_wheelRotation += event.GetWheelRotation(); int lines = m_wheelRotation / event.GetWheelDelta(); m_wheelRotation -= lines * event.GetWheelDelta(); if (lines != 0) { wxScrollWinEvent newEvent; newEvent.SetPosition(0); newEvent.SetOrientation( event.GetWheelAxis() == 0 ? wxVERTICAL : wxHORIZONTAL); newEvent.SetEventObject(m_win); if (event.IsPageScroll()) { if (lines > 0) newEvent.SetEventType(wxEVT_SCROLLWIN_PAGEUP); else newEvent.SetEventType(wxEVT_SCROLLWIN_PAGEDOWN); m_win->GetEventHandler()->ProcessEvent(newEvent); } else { lines *= event.GetLinesPerAction(); if (lines > 0) newEvent.SetEventType(wxEVT_SCROLLWIN_LINEUP); else newEvent.SetEventType(wxEVT_SCROLLWIN_LINEDOWN); int times = abs(lines); for (; times > 0; times--) m_win->GetEventHandler()->ProcessEvent(newEvent); } } } #endif // wxUSE_MOUSEWHEEL void wxScrollHelperBase::HandleOnChildFocus(wxChildFocusEvent& event) { // this event should be processed by all windows in parenthood chain, // e.g. so that nested wxScrolledWindows work correctly event.Skip(); // find the immediate child under which the window receiving focus is: wxWindow *win = event.GetWindow(); if ( win == m_targetWindow ) return; // nothing to do #if defined( __WXOSX__ ) && wxUSE_SCROLLBAR if (wxDynamicCast(win, wxScrollBar)) return; #endif // Fixing ticket: http://trac.wxwidgets.org/ticket/9563 // When a child inside a wxControlContainer receives a focus, the // wxControlContainer generates an artificial wxChildFocusEvent for // itself, telling its parent that 'it' received the focus. The effect is // that this->HandleOnChildFocus is called twice, first with the // artificial wxChildFocusEvent and then with the original event. We need // to ignore the artificial event here or otherwise HandleOnChildFocus // would first scroll the target window to make the entire // wxControlContainer visible and immediately afterwards scroll the target // window again to make the child widget visible. This leads to ugly // flickering when using nested wxPanels/wxScrolledWindows. // // Ignore this event if 'win' is derived from wxControlContainer AND its // parent is the m_targetWindow AND 'win' is not actually reciving the // focus (win != FindFocus). TODO: This affects all wxControlContainer // objects, but wxControlContainer is not part of the wxWidgets RTTI and // so wxDynamicCast(win, wxControlContainer) does not compile. Find a way // to determine if 'win' derives from wxControlContainer. Until then, // testing if 'win' derives from wxPanel will probably get >90% of all // cases. wxWindow *actual_focus=wxWindow::FindFocus(); if (win != actual_focus && wxDynamicCast(win, wxPanel) != 0 && win->GetParent() == m_targetWindow) // if win is a wxPanel and receives the focus, it should not be // scrolled into view return; const wxRect viewRect(m_targetWindow->GetClientRect()); // For composite controls such as wxComboCtrl we should try to fit the // entire control inside the visible area of the target window, not just // the focused child of the control. Otherwise we'd make only the textctrl // part of a wxComboCtrl visible and the button would still be outside the // scrolled area. But do so only if the parent fits *entirely* inside the // scrolled window. In other situations, such as nested wxPanel or // wxScrolledWindows, the parent might be way too big to fit inside the // scrolled window. If that is the case, then make only the focused window // visible if ( win->GetParent() != m_targetWindow) { wxWindow *parent=win->GetParent(); wxSize parent_size=parent->GetSize(); if (parent_size.GetWidth() <= viewRect.GetWidth() && parent_size.GetHeight() <= viewRect.GetHeight()) // make the immediate parent visible instead of the focused control win=parent; } // make win position relative to the m_targetWindow viewing area instead of // its parent const wxRect winRect(m_targetWindow->ScreenToClient(win->GetScreenPosition()), win->GetSize()); // check if it's fully visible if ( viewRect.Contains(winRect) ) { // it is, nothing to do return; } // check if we can make it fully visible: this is only possible if it's not // larger than our view area if ( winRect.GetWidth() > viewRect.GetWidth() || winRect.GetHeight() > viewRect.GetHeight() ) { // we can't make it fit so avoid scrolling it at all, this is only // going to be confusing and not helpful return; } // do make the window fit inside the view area by scrolling to it int stepx, stepy; GetScrollPixelsPerUnit(&stepx, &stepy); int startx, starty; GetViewStart(&startx, &starty); // first in vertical direction: if ( stepy > 0 ) { int diff = 0; if ( winRect.GetTop() < 0 ) { diff = winRect.GetTop(); } else if ( winRect.GetBottom() > viewRect.GetHeight() ) { diff = winRect.GetBottom() - viewRect.GetHeight() + 1; // round up to next scroll step if we can't get exact position, // so that the window is fully visible: diff += stepy - 1; } starty = (starty * stepy + diff) / stepy; } // then horizontal: if ( stepx > 0 ) { int diff = 0; if ( winRect.GetLeft() < 0 ) { diff = winRect.GetLeft(); } else if ( winRect.GetRight() > viewRect.GetWidth() ) { diff = winRect.GetRight() - viewRect.GetWidth() + 1; // round up to next scroll step if we can't get exact position, // so that the window is fully visible: diff += stepx - 1; } startx = (startx * stepx + diff) / stepx; } Scroll(startx, starty); } #ifdef wxHAS_GENERIC_SCROLLWIN // ---------------------------------------------------------------------------- // wxScrollHelper implementation // ---------------------------------------------------------------------------- wxScrollHelper::wxScrollHelper(wxWindow *winToScroll) : wxScrollHelperBase(winToScroll) { m_xVisibility = m_yVisibility = wxSHOW_SB_DEFAULT; } void wxScrollHelper::DoShowScrollbars(wxScrollbarVisibility horz, wxScrollbarVisibility vert) { if ( horz != m_xVisibility || vert != m_yVisibility ) { m_xVisibility = horz; m_yVisibility = vert; AdjustScrollbars(); } } void wxScrollHelper::DoAdjustScrollbar(int orient, int clientSize, int virtSize, int pixelsPerUnit, int& scrollUnits, int& scrollPosition, int& scrollLinesPerPage, wxScrollbarVisibility visibility) { // scroll lines per page: if 0, no scrolling is needed // check if we need scrollbar in this direction at all if ( pixelsPerUnit == 0 || clientSize >= virtSize ) { // scrolling is disabled or unnecessary scrollUnits = scrollPosition = 0; scrollLinesPerPage = 0; } else // might need scrolling { // Round up integer division to catch any "leftover" client space. scrollUnits = (virtSize + pixelsPerUnit - 1) / pixelsPerUnit; // Calculate the number of fully scroll units scrollLinesPerPage = clientSize / pixelsPerUnit; if ( scrollLinesPerPage >= scrollUnits ) { // we're big enough to not need scrolling scrollUnits = scrollPosition = 0; scrollLinesPerPage = 0; } else // we do need a scrollbar { if ( scrollLinesPerPage < 1 ) scrollLinesPerPage = 1; // Correct position if greater than extent of canvas minus // the visible portion of it or if below zero const int posMax = scrollUnits - scrollLinesPerPage; if ( scrollPosition > posMax ) scrollPosition = posMax; else if ( scrollPosition < 0 ) scrollPosition = 0; } } // in wxSHOW_SB_NEVER case don't show the scrollbar even if it's needed, in // wxSHOW_SB_ALWAYS case show the scrollbar even if it's not needed by // passing a special range value to SetScrollbar() int range; switch ( visibility ) { case wxSHOW_SB_NEVER: range = 0; break; case wxSHOW_SB_ALWAYS: range = scrollUnits ? scrollUnits : -1; break; default: wxFAIL_MSG( wxS("unknown scrollbar visibility") ); // fall through case wxSHOW_SB_DEFAULT: range = scrollUnits; break; } m_win->SetScrollbar(orient, scrollPosition, scrollLinesPerPage, range); } void wxScrollHelper::AdjustScrollbars() { static wxRecursionGuardFlag s_flagReentrancy; wxRecursionGuard guard(s_flagReentrancy); if ( guard.IsInside() ) { // don't reenter AdjustScrollbars() while another call to // AdjustScrollbars() is in progress because this may lead to calling // ScrollWindow() twice and this can really happen under MSW if // SetScrollbar() call below adds or removes the scrollbar which // changes the window size and hence results in another // AdjustScrollbars() call return; } int oldXScroll = m_xScrollPosition; int oldYScroll = m_yScrollPosition; // we may need to readjust the scrollbars several times as enabling one of // them reduces the area available for the window contents and so can make // the other scrollbar necessary now although it wasn't necessary before // // VZ: normally this loop should be over in at most 2 iterations, I don't // know why do we need 5 of them for ( int iterationCount = 0; iterationCount < 5; iterationCount++ ) { wxSize clientSize = GetTargetSize(); const wxSize virtSize = m_targetWindow->GetVirtualSize(); // this block of code tries to work around the following problem: the // window could have been just resized to have enough space to show its // full contents without the scrollbars, but its client size could be // not big enough because it does have the scrollbars right now and so // the scrollbars would remain even though we don't need them any more // // to prevent this from happening, check if we have enough space for // everything without the scrollbars and explicitly disable them then const wxSize availSize = GetSizeAvailableForScrollTarget( m_win->GetSize() - m_win->GetWindowBorderSize()); if ( availSize != clientSize ) { if ( availSize.x >= virtSize.x && availSize.y >= virtSize.y ) { // this will be enough to make the scrollbars disappear below // and then the client size will indeed become equal to the // full available size clientSize = availSize; } } DoAdjustScrollbar(wxHORIZONTAL, clientSize.x, virtSize.x, m_xScrollPixelsPerLine, m_xScrollLines, m_xScrollPosition, m_xScrollLinesPerPage, m_xVisibility); DoAdjustScrollbar(wxVERTICAL, clientSize.y, virtSize.y, m_yScrollPixelsPerLine, m_yScrollLines, m_yScrollPosition, m_yScrollLinesPerPage, m_yVisibility); // If a scrollbar (dis)appeared as a result of this, we need to adjust // them again but if the client size didn't change, then we're done if ( GetTargetSize() == clientSize ) break; } #ifdef __WXMOTIF__ // Sorry, some Motif-specific code to implement a backing pixmap // for the wxRETAINED style. Implementing a backing store can't // be entirely generic because it relies on the wxWindowDC implementation // to duplicate X drawing calls for the backing pixmap. if ( m_targetWindow->GetWindowStyle() & wxRETAINED ) { Display* dpy = XtDisplay((Widget)m_targetWindow->GetMainWidget()); int totalPixelWidth = m_xScrollLines * m_xScrollPixelsPerLine; int totalPixelHeight = m_yScrollLines * m_yScrollPixelsPerLine; if (m_targetWindow->GetBackingPixmap() && !((m_targetWindow->GetPixmapWidth() == totalPixelWidth) && (m_targetWindow->GetPixmapHeight() == totalPixelHeight))) { XFreePixmap (dpy, (Pixmap) m_targetWindow->GetBackingPixmap()); m_targetWindow->SetBackingPixmap((WXPixmap) 0); } if (!m_targetWindow->GetBackingPixmap() && (m_xScrollLines != 0) && (m_yScrollLines != 0)) { int depth = wxDisplayDepth(); m_targetWindow->SetPixmapWidth(totalPixelWidth); m_targetWindow->SetPixmapHeight(totalPixelHeight); m_targetWindow->SetBackingPixmap((WXPixmap) XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)), m_targetWindow->GetPixmapWidth(), m_targetWindow->GetPixmapHeight(), depth)); } } #endif // Motif if (oldXScroll != m_xScrollPosition) { if (m_xScrollingEnabled) m_targetWindow->ScrollWindow( m_xScrollPixelsPerLine * (oldXScroll - m_xScrollPosition), 0, GetScrollRect() ); else m_targetWindow->Refresh(true, GetScrollRect()); } if (oldYScroll != m_yScrollPosition) { if (m_yScrollingEnabled) m_targetWindow->ScrollWindow( 0, m_yScrollPixelsPerLine * (oldYScroll-m_yScrollPosition), GetScrollRect() ); else m_targetWindow->Refresh(true, GetScrollRect()); } } void wxScrollHelper::DoScroll( int x_pos, int y_pos ) { if (!m_targetWindow) return; if (((x_pos == -1) || (x_pos == m_xScrollPosition)) && ((y_pos == -1) || (y_pos == m_yScrollPosition))) return; int w = 0, h = 0; GetTargetSize(&w, &h); // compute new position: int new_x = m_xScrollPosition; int new_y = m_yScrollPosition; if ((x_pos != -1) && (m_xScrollPixelsPerLine)) { new_x = x_pos; // Calculate page size i.e. number of scroll units you get on the // current client window int noPagePositions = w/m_xScrollPixelsPerLine; if (noPagePositions < 1) noPagePositions = 1; // Correct position if greater than extent of canvas minus // the visible portion of it or if below zero new_x = wxMin( m_xScrollLines-noPagePositions, new_x ); new_x = wxMax( 0, new_x ); } if ((y_pos != -1) && (m_yScrollPixelsPerLine)) { new_y = y_pos; // Calculate page size i.e. number of scroll units you get on the // current client window int noPagePositions = h/m_yScrollPixelsPerLine; if (noPagePositions < 1) noPagePositions = 1; // Correct position if greater than extent of canvas minus // the visible portion of it or if below zero new_y = wxMin( m_yScrollLines-noPagePositions, new_y ); new_y = wxMax( 0, new_y ); } if ( new_x == m_xScrollPosition && new_y == m_yScrollPosition ) return; // nothing to do, the position didn't change // flush all pending repaints before we change m_{x,y}ScrollPosition, as // otherwise invalidated area could be updated incorrectly later when // ScrollWindow() makes sure they're repainted before scrolling them m_targetWindow->Update(); // update the position and scroll the window now: if (m_xScrollPosition != new_x) { int old_x = m_xScrollPosition; m_xScrollPosition = new_x; m_win->SetScrollPos( wxHORIZONTAL, new_x ); m_targetWindow->ScrollWindow( (old_x-new_x)*m_xScrollPixelsPerLine, 0, GetScrollRect() ); } if (m_yScrollPosition != new_y) { int old_y = m_yScrollPosition; m_yScrollPosition = new_y; m_win->SetScrollPos( wxVERTICAL, new_y ); m_targetWindow->ScrollWindow( 0, (old_y-new_y)*m_yScrollPixelsPerLine, GetScrollRect() ); } } #endif // wxHAS_GENERIC_SCROLLWIN // ---------------------------------------------------------------------------- // wxScrolled<T> and wxScrolledWindow implementation // ---------------------------------------------------------------------------- wxSize wxScrolledT_Helper::FilterBestSize(const wxWindow *win, const wxScrollHelper *helper, const wxSize& origBest) { // NB: We don't do this in WX_FORWARD_TO_SCROLL_HELPER, because not // all scrollable windows should behave like this, only those that // contain children controls within scrollable area // (i.e., wxScrolledWindow) and other some scrollable windows may // have different DoGetBestSize() implementation (e.g. wxTreeCtrl). wxSize best = origBest; if ( win->GetAutoLayout() ) { // Only use the content to set the window size in the direction // where there's no scrolling; otherwise we're going to get a huge // window in the direction in which scrolling is enabled int ppuX, ppuY; helper->GetScrollPixelsPerUnit(&ppuX, &ppuY); // NB: This code used to use *current* size if min size wasn't // specified, presumably to get some reasonable (i.e., larger than // minimal) size. But that's a wrong thing to do in GetBestSize(), // so we use minimal size as specified. If the app needs some // minimal size for its scrolled window, it should set it and put // the window into sizer as expandable so that it can use all space // available to it. // // See also http://svn.wxwidgets.org/viewvc/wx?view=rev&revision=45864 wxSize minSize = win->GetMinSize(); if ( ppuX > 0 ) best.x = minSize.x + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); if ( ppuY > 0 ) best.y = minSize.y + wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y); } return best; } #ifdef __WXMSW__ WXLRESULT wxScrolledT_Helper::FilterMSWWindowProc(WXUINT nMsg, WXLRESULT rc) { #ifndef __WXWINCE__ // we need to process arrows ourselves for scrolling if ( nMsg == WM_GETDLGCODE ) { rc |= DLGC_WANTARROWS; } #endif return rc; } #endif // __WXMSW__ // NB: skipping wxScrolled<T> in wxRTTI information because being a templte, // it doesn't and can't implement wxRTTI support IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxPanel)
[ "rickyzhang@gmail.com" ]
rickyzhang@gmail.com
8addd3e54ecc23e92bf62eb25f7df60d48fbafb8
91b73204301dc0d26a196ec03da4d1f20d6834ec
/courcerainversion2.cpp
71d5bf9ee2576456cf55fc879be5c0ab9894c366
[]
no_license
kkathpal153/Spoj-
eec8347a0e64661798ebfb1057fcd6cef0d54006
37a947a22d0936a7f354854bff72dcb2d3d76b64
refs/heads/master
2021-01-10T08:29:32.415944
2018-09-24T12:19:56
2018-09-24T12:19:56
52,425,031
0
0
null
null
null
null
UTF-8
C++
false
false
1,517
cpp
#include <cstdlib> #include <iostream> #include <stdio.h> #define SIZE 100000 using namespace std; long long inv=0; long long splitInv(int *arr, long l, long u) { int *tarr = new int[u-l+2]; long i=l, j=(u-l)/2+l+1, k; long long count=0; for(k=1; (k<=u-l+1) && (i<=(u-l)/2+l) && (j<=u); k++) { if(arr[i]<arr[j]) tarr[k]=arr[i++]; else { tarr[k]=arr[j++]; count=count+((u-l)/2+l-i+1); //inv=inv+((u-l)/2+l-i+1); } } for(; k<=u-l+1 && i<=(u-l)/2+l; k++) tarr[k]=arr[i++]; for(; k<=u-l+1 && j<=u; k++) tarr[k]=arr[j++]; for(k=1, i=l ; k<=u-l+1 && i<=u; k++, i++) arr[i]=tarr[k]; delete tarr; return count; } long long numInv(int *arr, long l, long u) { if(u<=l) return 0; return numInv(arr, l, (u-l)/2+l) + numInv(arr, (u-l)/2+l+1, u) + splitInv(arr, l, u); } int main(int argc, char *argv[]) { int *arr=new int[SIZE+1]; char a[10]; FILE *f=fopen("IntegerArray.txt","r"); for(long i=1; i<=SIZE; i++) { fgets(a,10,f); arr[i]=atol(a); } fclose(f); //cout<<arr[0]<<endl; cout<<"Number of Inversions: "<<numInv(arr,1,SIZE)<<endl; //cout<<endl<<"no of split inversions are"<<inv; //cout<<"value of no"<<*arr[14578]<<" "<<*arr[24564]<<endl; delete arr; system("PAUSE"); return EXIT_SUCCESS; }
[ "kunalkathpal153@gmail.com" ]
kunalkathpal153@gmail.com
1554dce9b2821c3d57b7dc5e5f04ce433d161f44
d254e3260879a018b1f59e8319e6694afe9b20bb
/FE_v1/Layer.h
ef16a99237374f178f5dbc9bd4c3b4adcab45847
[]
no_license
Lu-UniOvi/SEV_Emblema_de_Fuego_Hacendado
e7cc59ddcc91568070e94267fa03336ce6505f93
a523ff1d7e600f2acb6a9f8e97fcef9e519f8f3c
refs/heads/master
2023-01-29T15:25:37.698278
2020-12-05T14:54:48
2020-12-05T14:54:48
316,304,369
0
0
null
null
null
null
UTF-8
C++
false
false
216
h
#pragma once #include "Game.h" class Game; class Layer { public: Layer(Game* game); virtual void init() {}; virtual void processControls() {}; virtual void update() {}; virtual void draw() {}; Game* game; };
[ "lucigbu@gmail.com" ]
lucigbu@gmail.com
3c6d8c3ff25c99cf9b5f6f3ddbd2283565e9253c
b6ac40fc9fb76cdd223482c66ec3181a48184fc6
/Tools/TimerWithComm.h
2f3976a2069857189931a54a542238dc2a378143
[ "MIT", "BSD-2-Clause" ]
permissive
sbellem/MP-SPDZ
f294fba12a14e4bbc33cad7657875694022def97
fc3a2a0f320e27910bbfdba1c96ef64e6633337f
refs/heads/master
2023-01-21T11:49:23.198664
2022-01-24T02:24:51
2022-01-24T02:26:50
238,566,768
0
1
NOASSERTION
2020-02-05T23:09:20
2020-02-05T23:09:19
null
UTF-8
C++
false
false
400
h
/* * TimerWithComm.h * */ #ifndef TOOLS_TIMERWITHCOMM_H_ #define TOOLS_TIMERWITHCOMM_H_ #include "time-func.h" #include "Networking/Player.h" class TimerWithComm : public Timer { NamedCommStats total_stats, last_stats; public: void start(const NamedCommStats& stats = {}); void stop(const NamedCommStats& stats = {}); double mb_sent(); }; #endif /* TOOLS_TIMERWITHCOMM_H_ */
[ "mks.keller@gmail.com" ]
mks.keller@gmail.com
218456455b3a9dce067464c64b6f966b6d102cfd
b907b0036bd032dee180cc321424a2d35d83e761
/MFCDragAndDrop/MFCDragAndDrop/FixedCtrlPane.h
c1c3868a6f4b4a950a5e6ddf78e200b6fcc5dbf6
[]
no_license
15831944/garage
9a495c8061b159036c13a1e06f2830257a2242d5
4745e5c88107b7051756f41fea47ff85e8754dbf
refs/heads/master
2021-12-10T20:39:28.283284
2016-09-19T14:30:19
2016-09-19T14:30:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
545
h
#pragma once // CFixedCtrlPane class CFixedCtrlPane : public CWnd { DECLARE_DYNAMIC(CFixedCtrlPane) public: CFixedCtrlPane(); virtual ~CFixedCtrlPane(); virtual BOOL PreCreateWindow(CREATESTRUCT& cs){ return CWnd::PreCreateWindow(cs); } protected: CString m_strClassName; protected: DECLARE_MESSAGE_MAP() public: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct){ if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; return 0; } afx_msg void OnSize(UINT nType, int cx, int cy){ CWnd::OnSize(nType, cx, cy); } };
[ "steppingbird@yahoo.co.jp" ]
steppingbird@yahoo.co.jp
e515a367baaef3100055d83def1d3ff521e54601
a55cec32c0191f3f99752749f8323a517be46638
/ProfessionalC++/BuddyList/BuddyList.cpp
a97647c6b6daebddf22ea1e8b8b2e3d481ef2c76
[ "Apache-2.0" ]
permissive
zzragida/CppExamples
e0b0d1609b2e485cbac22e0878e00cc8ebce6a94
d627b097efc04209aa4012f7b7f9d82858da3f2d
refs/heads/master
2021-01-18T15:06:57.286097
2016-03-08T00:23:31
2016-03-08T00:23:31
49,173,497
0
0
null
null
null
null
UTF-8
C++
false
false
986
cpp
#include "BuddyList.h" using namespace std; BuddyList::BuddyList() { } void BuddyList::addBuddy(const string& name, const string& buddy) { if (!isBuddy(name, buddy)) { mBuddies.insert({name, buddy}); } } void BuddyList::removeBuddy(const string& name, const string& buddy) { auto start = mBuddies.lower_bound(name); auto end = mBuddies.upper_bound(name); for (; start != end; ++start) { if (start->second == buddy) { mBuddies.erase(start); break; } } } bool BuddyList::isBuddy(const string& name, const string& buddy) const { auto start = mBuddies.lower_bound(name); auto end = mBuddies.upper_bound(name); for (; start != end; ++start) { if (start->second == buddy) { return true; } } return false; } list<string> BuddyList::getBuddies(const string& name) const { auto its = mBuddies.equal_range(name); list<string> buddies; for (; its.first != its.second; ++its.first) { buddies.push_back(its.first->second); } return buddies; }
[ "zzragida@gmail.com" ]
zzragida@gmail.com
8d6ae2b9628bb42564a70d1992c5b104ee95d4df
ea6a9bcf02fe7d72df645302909b1de63cdf7fe0
/src/support/lockedpool.h
41eb1f6a2868bbf53010d86585a4ac29f2436dc1
[ "MIT" ]
permissive
durgeshkmr/minicoin
69a834786413122eb2b85731b20f0fda931c7a72
4f082abe13cd34a759bf8ffb344a49244615960e
refs/heads/master
2020-05-04T22:59:23.367524
2019-04-06T16:13:28
2019-04-06T16:13:28
179,529,407
0
0
null
null
null
null
UTF-8
C++
false
false
8,038
h
// Copyright (c) 2016-2018 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef MINICOIN_SUPPORT_LOCKEDPOOL_H #define MINICOIN_SUPPORT_LOCKEDPOOL_H #include <stdint.h> #include <list> #include <map> #include <mutex> #include <memory> #include <unordered_map> /** * OS-dependent allocation and deallocation of locked/pinned memory pages. * Abstract base class. */ class LockedPageAllocator { public: virtual ~LockedPageAllocator() {} /** Allocate and lock memory pages. * If len is not a multiple of the system page size, it is rounded up. * Returns 0 in case of allocation failure. * * If locking the memory pages could not be accomplished it will still * return the memory, however the lockingSuccess flag will be false. * lockingSuccess is undefined if the allocation fails. */ virtual void* AllocateLocked(size_t len, bool *lockingSuccess) = 0; /** Unlock and free memory pages. * Clear the memory before unlocking. */ virtual void FreeLocked(void* addr, size_t len) = 0; /** Get the total limit on the amount of memory that may be locked by this * process, in bytes. Return size_t max if there is no limit or the limit * is unknown. Return 0 if no memory can be locked at all. */ virtual size_t GetLimit() = 0; }; /* An arena manages a contiguous region of memory by dividing it into * chunks. */ class Arena { public: Arena(void *base, size_t size, size_t alignment); virtual ~Arena(); Arena(const Arena& other) = delete; // non construction-copyable Arena& operator=(const Arena&) = delete; // non copyable /** Memory statistics. */ struct Stats { size_t used; size_t free; size_t total; size_t chunks_used; size_t chunks_free; }; /** Allocate size bytes from this arena. * Returns pointer on success, or 0 if memory is full or * the application tried to allocate 0 bytes. */ void* alloc(size_t size); /** Free a previously allocated chunk of memory. * Freeing the zero pointer has no effect. * Raises std::runtime_error in case of error. */ void free(void *ptr); /** Get arena usage statistics */ Stats stats() const; #ifdef ARENA_DEBUG void walk() const; #endif /** Return whether a pointer points inside this arena. * This returns base <= ptr < (base+size) so only use it for (inclusive) * chunk starting addresses. */ bool addressInArena(void *ptr) const { return ptr >= base && ptr < end; } private: typedef std::multimap<size_t, char*> SizeToChunkSortedMap; /** Map to enable O(log(n)) best-fit allocation, as it's sorted by size */ SizeToChunkSortedMap size_to_free_chunk; typedef std::unordered_map<char*, SizeToChunkSortedMap::const_iterator> ChunkToSizeMap; /** Map from begin of free chunk to its node in size_to_free_chunk */ ChunkToSizeMap chunks_free; /** Map from end of free chunk to its node in size_to_free_chunk */ ChunkToSizeMap chunks_free_end; /** Map from begin of used chunk to its size */ std::unordered_map<char*, size_t> chunks_used; /** Base address of arena */ char* base; /** End address of arena */ char* end; /** Minimum chunk alignment */ size_t alignment; }; /** Pool for locked memory chunks. * * To avoid sensitive key data from being swapped to disk, the memory in this pool * is locked/pinned. * * An arena manages a contiguous region of memory. The pool starts out with one arena * but can grow to multiple arenas if the need arises. * * Unlike a normal C heap, the administrative structures are separate from the managed * memory. This has been done as the sizes and bases of objects are not in themselves sensitive * information, as to conserve precious locked memory. In some operating systems * the amount of memory that can be locked is small. */ class LockedPool { public: /** Size of one arena of locked memory. This is a compromise. * Do not set this too low, as managing many arenas will increase * allocation and deallocation overhead. Setting it too high allocates * more locked memory from the OS than strictly necessary. */ static const size_t ARENA_SIZE = 256*1024; /** Chunk alignment. Another compromise. Setting this too high will waste * memory, setting it too low will facilitate fragmentation. */ static const size_t ARENA_ALIGN = 16; /** Callback when allocation succeeds but locking fails. */ typedef bool (*LockingFailed_Callback)(); /** Memory statistics. */ struct Stats { size_t used; size_t free; size_t total; size_t locked; size_t chunks_used; size_t chunks_free; }; /** Create a new LockedPool. This takes ownership of the MemoryPageLocker, * you can only instantiate this with LockedPool(std::move(...)). * * The second argument is an optional callback when locking a newly allocated arena failed. * If this callback is provided and returns false, the allocation fails (hard fail), if * it returns true the allocation proceeds, but it could warn. */ explicit LockedPool(std::unique_ptr<LockedPageAllocator> allocator, LockingFailed_Callback lf_cb_in = nullptr); ~LockedPool(); LockedPool(const LockedPool& other) = delete; // non construction-copyable LockedPool& operator=(const LockedPool&) = delete; // non copyable /** Allocate size bytes from this arena. * Returns pointer on success, or 0 if memory is full or * the application tried to allocate 0 bytes. */ void* alloc(size_t size); /** Free a previously allocated chunk of memory. * Freeing the zero pointer has no effect. * Raises std::runtime_error in case of error. */ void free(void *ptr); /** Get pool usage statistics */ Stats stats() const; private: std::unique_ptr<LockedPageAllocator> allocator; /** Create an arena from locked pages */ class LockedPageArena: public Arena { public: LockedPageArena(LockedPageAllocator *alloc_in, void *base_in, size_t size, size_t align); ~LockedPageArena(); private: void *base; size_t size; LockedPageAllocator *allocator; }; bool new_arena(size_t size, size_t align); std::list<LockedPageArena> arenas; LockingFailed_Callback lf_cb; size_t cumulative_bytes_locked; /** Mutex protects access to this pool's data structures, including arenas. */ mutable std::mutex mutex; }; /** * Singleton class to keep track of locked (ie, non-swappable) memory, for use in * std::allocator templates. * * Some implementations of the STL allocate memory in some constructors (i.e., see * MSVC's vector<T> implementation where it allocates 1 byte of memory in the allocator.) * Due to the unpredictable order of static initializers, we have to make sure the * LockedPoolManager instance exists before any other STL-based objects that use * secure_allocator are created. So instead of having LockedPoolManager also be * static-initialized, it is created on demand. */ class LockedPoolManager : public LockedPool { public: /** Return the current instance, or create it once */ static LockedPoolManager& Instance() { std::call_once(LockedPoolManager::init_flag, LockedPoolManager::CreateInstance); return *LockedPoolManager::_instance; } private: explicit LockedPoolManager(std::unique_ptr<LockedPageAllocator> allocator); /** Create a new LockedPoolManager specialized to the OS */ static void CreateInstance(); /** Called when locking fails, warn the user here */ static bool LockingFailed(); static LockedPoolManager* _instance; static std::once_flag init_flag; }; #endif // MINICOIN_SUPPORT_LOCKEDPOOL_H
[ "durgeshkmr4u@gmail.com" ]
durgeshkmr4u@gmail.com
0b13f30e42683e413baea5670d0eba1ce497e7bf
20899e88d501537954d7386cb6b4de12658ffe1a
/divideBy6MultiplyBy2.cpp
555684edf3bb244328593346b62a82479e9c3b64
[]
no_license
simranmahindrakar/CodeforcesCpp
5a41f5afd42fa895154fa1ae0cacba7184aa4ed5
87b62f80d527f3f08440346ec9ea139d1dd1e738
refs/heads/master
2022-12-12T04:24:43.577494
2020-09-03T13:51:30
2020-09-03T13:51:30
275,073,988
0
0
null
null
null
null
UTF-8
C++
false
false
546
cpp
#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { long n,t; cin>>t; while(t--) { cin>>n; long step2=0, step3=0; while(n%2 == 0) { step2++; n=n/2; //UPDATE n } while(n%3 == 0) { step3++; n=n/3; } if (n!=1 || step2 > step3) //number of 2s more than number of 3s { printf("-1 \n"); } else { cout<<(step3 - step2) + step3<<endl; } } return 0; }
[ "noreply@github.com" ]
noreply@github.com
849e0a2d1e035f7bfa0d21f13bfbb781879eedd1
0028c740dab82658b67c0ee21d474b455c2104c6
/ants/lib/itkSpatialMutualInformationRegistrationFunction.h
c73730c54a30bc81d10bf142412aaa1fb742107c
[ "Apache-2.0" ]
permissive
ncullen93/ANTsPy
3ecdf7af1a3c67c6fa1ed171c609d25c1104fccd
a4c990dcd5b7445a45ce7b366ee018c7350e7d9f
refs/heads/master
2021-01-20T21:35:11.910867
2017-08-29T14:30:48
2017-08-29T14:30:48
101,770,979
3
1
null
2017-08-29T14:33:06
2017-08-29T14:33:06
null
UTF-8
C++
false
false
29,923
h
/*========================================================================= Program: Insight Segmentation & Registration Toolkit Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __itkSpatialMutualInformationRegistrationFunction_h #define __itkSpatialMutualInformationRegistrationFunction_h #include "itkImageFileWriter.h" #include "itkImageToImageMetric.h" #include "itkAvantsPDEDeformableRegistrationFunction.h" #include "itkCovariantVector.h" #include "itkPoint.h" #include "itkIndex.h" #include "itkBSplineKernelFunction.h" #include "itkBSplineDerivativeKernelFunction.h" #include "itkCentralDifferenceImageFunction.h" #include "itkBSplineInterpolateImageFunction.h" #include "itkLinearInterpolateImageFunction.h" #include "itkTranslationTransform.h" #include "itkArray2D.h" #include "itkImageBase.h" #include "itkTransform.h" #include "itkInterpolateImageFunction.h" #include "itkSingleValuedCostFunction.h" #include "itkExceptionObject.h" #include "itkGradientRecursiveGaussianImageFilter.h" #include "itkSpatialObject.h" #include "itkConstNeighborhoodIterator.h" namespace itk { /** \class SpatialMutualInformationRegistrationFunction * \brief Computes the mutual information between two images to be * registered using the method of Spatial et al. * * SpatialMutualInformationRegistrationFunction computes the mutual * information between a fixed and moving image to be registered. * * This class is templated over the FixedImage type and the MovingImage * type. * * The fixed and moving images are set via methods SetFixedImage() and * SetMovingImage(). This metric makes use of user specified Transform and * Interpolator. The Transform is used to map points from the fixed image to * the moving image domain. The Interpolator is used to evaluate the image * intensity at user specified geometric points in the moving image. * The Transform and Interpolator are set via methods SetTransform() and * SetInterpolator(). * * If a BSplineInterpolationFunction is used, this class obtain * image derivatives from the BSpline interpolator. Otherwise, * image derivatives are computed using central differencing. * * \warning This metric assumes that the moving image has already been * connected to the interpolator outside of this class. * * The method GetValue() computes of the mutual information * while method GetValueAndDerivative() computes * both the mutual information and its derivatives with respect to the * transform parameters. * * The calculations are based on the method of Spatial et al [1,2] * where the probability density distribution are estimated using * Parzen histograms. Since the fixed image PDF does not contribute * to the derivatives, it does not need to be smooth. Hence, * a zero order (box car) BSpline kernel is used * for the fixed image intensity PDF. On the other hand, to ensure * smoothness a third order BSpline kernel is used for the * moving image intensity PDF. * * On Initialize(), the FixedImage is uniformly sampled within * the FixedImageRegion. The number of samples used can be set * via SetNumberOfSpatialSamples(). Typically, the number of * spatial samples used should increase with the image size. * * During each call of GetValue(), GetDerivatives(), * GetValueAndDerivatives(), marginal and joint intensity PDF's * values are estimated at discrete position or bins. * The number of bins used can be set via SetNumberOfHistogramBins(). * To handle data with arbitray magnitude and dynamic range, * the image intensity is scale such that any contribution to the * histogram will fall into a valid bin. * * One the PDF's have been contructed, the mutual information * is obtained by doubling summing over the discrete PDF values. * * * Notes: * 1. This class returns the negative mutual information value. * 2. This class in not thread safe due the private data structures * used to the store the sampled points and the marginal and joint pdfs. * * References: * [1] "Nonrigid multimodality image registration" * D. Spatial, D. R. Haynor, H. Vesselle, T. Lewellen and W. Eubank * Medical Imaging 2001: Image Processing, 2001, pp. 1609-1620. * [2] "PET-CT Image Registration in the Chest Using Free-form Deformations" * D. Spatial, D. R. Haynor, H. Vesselle, T. Lewellen and W. Eubank * IEEE Transactions in Medical Imaging. Vol.22, No.1, January 2003. pp.120-128. * [3] "Optimization of Mutual Information for MultiResolution Image * Registration" * P. Thevenaz and M. Unser * IEEE Transactions in Image Processing, 9(12) December 2000. * * \ingroup RegistrationMetrics * \ingroup ThreadUnSafe */ template <class TFixedImage, class TMovingImage, class TDisplacementField> class SpatialMutualInformationRegistrationFunction : public AvantsPDEDeformableRegistrationFunction<TFixedImage, TMovingImage, TDisplacementField> { public: /** Standard class typedefs. */ typedef SpatialMutualInformationRegistrationFunction Self; typedef AvantsPDEDeformableRegistrationFunction<TFixedImage, TMovingImage, TDisplacementField> Superclass; typedef SmartPointer<Self> Pointer; typedef SmartPointer<const Self> ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro( SpatialMutualInformationRegistrationFunction, AvantsPDEDeformableRegistrationFunction ); /** MovingImage image type. */ typedef typename Superclass::MovingImageType MovingImageType; typedef typename Superclass::MovingImagePointer MovingImagePointer; /** FixedImage image type. */ typedef typename Superclass::FixedImageType FixedImageType; typedef typename Superclass::FixedImagePointer FixedImagePointer; typedef typename FixedImageType::IndexType IndexType; typedef typename FixedImageType::SizeType SizeType; typedef typename FixedImageType::SpacingType SpacingType; /** Deformation field type. */ typedef typename Superclass::VectorType VectorType; typedef typename Superclass::DisplacementFieldType DisplacementFieldType; typedef typename Superclass::DisplacementFieldTypePointer DisplacementFieldTypePointer; /** Inherit some enums from the superclass. */ itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension); /** Inherit some enums from the superclass. */ typedef typename Superclass::PixelType PixelType; typedef typename Superclass::RadiusType RadiusType; typedef typename Superclass::NeighborhoodType NeighborhoodType; typedef typename Superclass::FloatOffsetType FloatOffsetType; typedef typename Superclass::TimeStepType TimeStepType; /** Interpolator type. */ typedef double CoordRepType; typedef // // LinearInterpolateImageFunction<MovingImageType,CoordRepType> BSplineInterpolateImageFunction<MovingImageType, CoordRepType> InterpolatorType; typedef typename InterpolatorType::Pointer InterpolatorPointer; typedef typename InterpolatorType::PointType PointType; typedef InterpolatorType DefaultInterpolatorType; // typedef LinearInterpolateImageFunction<MovingImageType,CoordRepType> // DefaultInterpolatorType; /** Covariant vector type. */ typedef CovariantVector<double, itkGetStaticConstMacro(ImageDimension)> CovariantVectorType; /** Gradient calculator type. */ typedef CentralDifferenceImageFunction<FixedImageType> GradientCalculatorType; typedef typename GradientCalculatorType::Pointer GradientCalculatorPointer; /** Set the moving image interpolator. */ void SetMovingImageInterpolator( InterpolatorType * ptr ) { m_MovingImageInterpolator = ptr; } /** Get the moving image interpolator. */ InterpolatorType * GetMovingImageInterpolator(void) { return m_MovingImageInterpolator; } /** This class uses a constant timestep of 1. */ virtual TimeStepType ComputeGlobalTimeStep(void *itkNotUsed(GlobalData) ) const ITK_OVERRIDE { return 1; } /** Return a pointer to a global data structure that is passed to * this object from the solver at each calculation. */ virtual void * GetGlobalDataPointer() const ITK_OVERRIDE { GlobalDataStruct *global = new GlobalDataStruct(); // global->m_SumOfSquaredDifference = 0.0; // / global->m_NumberOfPixelsProcessed = 0L; // global->m_SumOfSquaredChange = 0; return global; } /** Release memory for global data structure. */ virtual void ReleaseGlobalDataPointer( void *GlobalData ) const ITK_OVERRIDE { delete (GlobalDataStruct *) GlobalData; } /** Set the object's state before each iteration. */ virtual void InitializeIteration() ITK_OVERRIDE; typedef double CoordinateRepresentationType; /** Types inherited from Superclass. */ typedef TranslationTransform<CoordinateRepresentationType, // itkGetStaticConstMacro(ImageDimension), itkGetStaticConstMacro(ImageDimension)> TransformType; typedef ImageToImageMetric<TFixedImage, TMovingImage> Metricclass; typedef typename TransformType::Pointer TransformPointer; typedef typename Metricclass::TransformJacobianType TransformJacobianType; // typedef typename Metricclass::InterpolatorType InterpolatorType; typedef typename Metricclass::MeasureType MeasureType; typedef typename Metricclass::DerivativeType DerivativeType; typedef typename TransformType::ParametersType ParametersType; typedef typename Metricclass::FixedImageConstPointer FixedImageConstPointer; typedef typename Metricclass::MovingImageConstPointer MovingImageCosntPointer; // typedef typename TransformType::CoordinateRepresentationType CoordinateRepresentationType; /** Index and Point typedef support. */ typedef typename FixedImageType::IndexType FixedImageIndexType; typedef typename FixedImageIndexType::IndexValueType FixedImageIndexValueType; typedef typename MovingImageType::IndexType MovingImageIndexType; typedef typename TransformType::InputPointType FixedImagePointType; typedef typename TransformType::OutputPointType MovingImagePointType; /** The marginal PDFs are stored as std::vector. */ typedef float PDFValueType; // typedef std::vector<PDFValueType> MarginalPDFType; typedef Image<PDFValueType, 1> MarginalPDFType; typedef typename MarginalPDFType::IndexType MarginalPDFIndexType; /** Typedef for the joint PDF and PDF derivatives are stored as ITK Images. */ typedef Image<PDFValueType, 2> JointPDFType; typedef Image<PDFValueType, 3> JointPDFDerivativesType; typedef JointPDFType::IndexType JointPDFIndexType; typedef JointPDFType::PixelType JointPDFValueType; typedef JointPDFType::RegionType JointPDFRegionType; typedef JointPDFType::SizeType JointPDFSizeType; typedef JointPDFDerivativesType::IndexType JointPDFDerivativesIndexType; typedef JointPDFDerivativesType::PixelType JointPDFDerivativesValueType; typedef JointPDFDerivativesType::RegionType JointPDFDerivativesRegionType; typedef JointPDFDerivativesType::SizeType JointPDFDerivativesSizeType; /** Get the value and derivatives for single valued optimizers. */ double GetValueAndDerivative( IndexType index, MeasureType& Value, DerivativeType& Derivative1, DerivativeType& Derivative2 ); /** Get the value and derivatives for single valued optimizers. */ double GetValueAndDerivativeInv( IndexType index, MeasureType& Value, DerivativeType& Derivative1, DerivativeType& Derivative2 ); /** Number of spatial samples to used to compute metric */ // itkSetClampMacro( NumberOfSpatialSamples, unsigned long, // 1, NumericTraits<unsigned long>::max() ); // itkGetConstReferenceMacro( NumberOfSpatialSamples, unsigned long); /** Number of bins to used in the histogram. Typical value is 50. */ // itkSetClampMacro( NumberOfHistogramBins, unsigned long, // 1, NumericTraits<unsigned long>::max() ); // itkGetConstReferenceMacro( NumberOfHistogramBins, unsigned long); void SetNumberOfHistogramBins(unsigned long nhb) { m_NumberOfHistogramBins = nhb + 2 * this->m_Padding; } unsigned long GetNumberOfHistogramBins() { return m_NumberOfHistogramBins; } void SetTransform(TransformPointer t) { m_Transform = t; } TransformPointer GetTransform() { return m_Transform; } void SetInterpolator(InterpolatorPointer t) { m_Interpolator = t; } InterpolatorPointer GetInterpolator() { return m_Interpolator; } void GetProbabilities(); double ComputeMutualInformation() { // typedef ImageRegionIterator<JointPDFType> JointPDFIteratorType; // JointPDFIteratorType jointPDFIterator ( m_JointPDF, m_JointPDF->GetBufferedRegion() ); float px, py, pxy; double mival = 0; double mi; unsigned long ct = 0; typename JointPDFType::IndexType index; // for (unsigned int ii=this->m_Padding+1; ii<m_NumberOfHistogramBins-this->m_Padding-2; ii++) for( unsigned int ii = 0; ii < m_NumberOfHistogramBins; ii++ ) { MarginalPDFIndexType mind; mind[0] = ii; px = m_FixedImageMarginalPDF->GetPixel(mind); // for (unsigned int jj=this->m_Padding+1; jj<m_NumberOfHistogramBins-this->m_Padding-2; jj++) for( unsigned int jj = 0; jj < m_NumberOfHistogramBins; jj++ ) { mind[0] = jj; py = m_MovingImageMarginalPDF->GetPixel(mind); float denom = px * py; index[0] = ii; index[1] = jj; // pxy=m_JointPDF->GetPixel(index); JointPDFValueType *pdfPtr = m_JointPDF->GetBufferPointer() + ( ii * m_NumberOfHistogramBins ); // Move the pointer to the first affected bin int pdfMovingIndex = static_cast<int>( jj ); pdfPtr += pdfMovingIndex; pxy = *(pdfPtr); mi = 0; if( fabs(denom) > 0 ) { if( pxy / denom > 0 ) { // true mi mi = pxy * log(pxy / denom); // test mi // mi = 1.0 + log(pxy/denom); ct++; } } mival += mi; } // std::cout << " II " << ii << " JJ " << ii << " pxy " << pxy << " px " << px << std::endl; } this->m_Energy = (-1.0) * mival / log(2); return this->m_Energy; } double ComputeSpatialMutualInformation() { float pxy; double SMI = 0; double JointEntropy = 0, JointEntropyXuY = 0, JointEntropyXYu = 0, JointEntropyXlY = 0, JointEntropyXYl = 0; double JointEntropyXuYl = 0, JointEntropyXlYu = 0, JointEntropyXrYu = 0, JointEntropyXuYr = 0; for( unsigned int ii = 0; ii < m_NumberOfHistogramBins; ii++ ) { for( unsigned int jj = 0; jj < m_NumberOfHistogramBins; jj++ ) { int pdfMovingIndex = static_cast<int>( jj ); JointPDFValueType *pdfPtr = m_JointPDF->GetBufferPointer() + ( ii * m_NumberOfHistogramBins ) + pdfMovingIndex; pxy = *(pdfPtr); if( fabs(pxy) > 0 ) { JointEntropy -= pxy * log(pxy); } pdfPtr = m_JointPDFXuY->GetBufferPointer() + ( ii * m_NumberOfHistogramBins ) + pdfMovingIndex; pxy = *(pdfPtr); if( fabs(pxy) > 0 ) { JointEntropyXuY -= pxy * log(pxy); } pdfPtr = m_JointPDFXYu->GetBufferPointer() + ( ii * m_NumberOfHistogramBins ) + pdfMovingIndex; pxy = *(pdfPtr); if( fabs(pxy) > 0 ) { JointEntropyXYu -= pxy * log(pxy); } pdfPtr = m_JointPDFXlY->GetBufferPointer() + ( ii * m_NumberOfHistogramBins ) + pdfMovingIndex; pxy = *(pdfPtr); if( fabs(pxy) > 0 ) { JointEntropyXlY -= pxy * log(pxy); } pdfPtr = m_JointPDFXYl->GetBufferPointer() + ( ii * m_NumberOfHistogramBins ) + pdfMovingIndex; pxy = *(pdfPtr); if( fabs(pxy) > 0 ) { JointEntropyXYl -= pxy * log(pxy); } pdfPtr = m_JointPDFXuYl->GetBufferPointer() + ( ii * m_NumberOfHistogramBins ) + pdfMovingIndex; pxy = *(pdfPtr); if( fabs(pxy) > 0 ) { JointEntropyXuYl -= pxy * log(pxy); } pdfPtr = m_JointPDFXlYu->GetBufferPointer() + ( ii * m_NumberOfHistogramBins ) + pdfMovingIndex; pxy = *(pdfPtr); if( fabs(pxy) > 0 ) { JointEntropyXlYu -= pxy * log(pxy); } pdfPtr = m_JointPDFXrYu->GetBufferPointer() + ( ii * m_NumberOfHistogramBins ) + pdfMovingIndex; pxy = *(pdfPtr); if( fabs(pxy) > 0 ) { JointEntropyXrYu -= pxy * log(pxy); } pdfPtr = m_JointPDFXuYr->GetBufferPointer() + ( ii * m_NumberOfHistogramBins ) + pdfMovingIndex; pxy = *(pdfPtr); if( fabs(pxy) > 0 ) { JointEntropyXuYr -= pxy * log(pxy); } } } SMI = (0.5) * (JointEntropyXuY + JointEntropyXYu + JointEntropyXlY + JointEntropyXYl) - (0.25) * (4 * JointEntropy + JointEntropyXuYr + JointEntropyXrYu + JointEntropyXlYu + JointEntropyXuYl); // std::cout << " JE " << JointEntropy << " JEXuY " << JointEntropyXuY << " JEXYu " << JointEntropyXYu << // " // JEXuYr " << JointEntropyXuYr << std::endl; this->m_Energy = (-1.0) * fabs(SMI); return this->m_Energy; } virtual VectorType ComputeUpdateInv(const NeighborhoodType & neighborhood, void * /* globalData */, const FloatOffsetType & /* offset */ = FloatOffsetType(0.0) ) ITK_OVERRIDE { VectorType update; update.Fill(0.0); IndexType oindex = neighborhood.GetIndex(); FixedImageType* img = const_cast<FixedImageType *>(this->Superclass::m_FixedImage.GetPointer() ); if( !img ) { return update; } typename FixedImageType::SpacingType spacing = img->GetSpacing(); typename FixedImageType::SizeType imagesize = img->GetLargestPossibleRegion().GetSize(); for( unsigned int dd = 0; dd < ImageDimension; dd++ ) { if( oindex[dd] < 1 || oindex[dd] >= static_cast<typename IndexType::IndexValueType>(imagesize[dd] - 1) ) { return update; } } CovariantVectorType fixedGradient; ParametersType fdvec1(ImageDimension); ParametersType fdvec2(ImageDimension); fdvec1.Fill(0); fdvec2.Fill(0); fixedGradient = m_FixedImageGradientCalculator->EvaluateAtIndex( oindex ); double nccm1 = 0; double loce = this->GetValueAndDerivativeInv(oindex, nccm1, fdvec1, fdvec2); float eps = 10; if( loce > eps ) { loce = eps; } if( loce < eps * (-1.0) ) { loce = eps * (-1.0); } for( unsigned int imd = 0; imd < ImageDimension; imd++ ) { update[imd] = loce * fixedGradient[imd] * spacing[imd] * (1); } if( this->m_MetricImage ) { this->m_MetricImage->SetPixel(oindex, loce); } return update; } /* Normalizing the image to the range of [0 1] */ double GetMovingParzenTerm( double intensity ) { double windowTerm = static_cast<double>( intensity ) - this->m_MovingImageTrueMin; windowTerm = windowTerm / ( this->m_MovingImageTrueMax - this->m_MovingImageTrueMin ); return windowTerm; } double GetFixedParzenTerm( double intensity ) { double windowTerm = static_cast<double>( intensity ) - this->m_FixedImageTrueMin; windowTerm = windowTerm / ( this->m_FixedImageTrueMax - this->m_FixedImageTrueMin ); return windowTerm; } /* find the image index in the number of histogram bins */ unsigned int FitIndexInBins( double windowTerm ) { unsigned int movingImageParzenWindowIndex = static_cast<unsigned int>( this->m_Padding + (unsigned int)( windowTerm * (float)(this->m_NumberOfHistogramBins - 1 - this->m_Padding + 0.5) ) ); // Make sure the extreme values are in valid bins if( movingImageParzenWindowIndex < this->m_Padding ) { movingImageParzenWindowIndex = this->m_Padding - 1; } else if( movingImageParzenWindowIndex > (m_NumberOfHistogramBins - this->m_Padding ) ) { movingImageParzenWindowIndex = m_NumberOfHistogramBins - this->m_Padding - 1; } return movingImageParzenWindowIndex; } double FitContIndexInBins( double windowTerm ) { return (double) this->m_Padding + windowTerm * (float)(this->m_NumberOfHistogramBins - this->m_Padding); } virtual VectorType ComputeUpdate(const NeighborhoodType & neighborhood, void * /* globalData */, const FloatOffsetType & /* offset */ = FloatOffsetType(0.0) ) ITK_OVERRIDE { VectorType update; update.Fill(0.0); IndexType oindex = neighborhood.GetIndex(); FixedImageType* img = const_cast<FixedImageType *>(this->Superclass::m_MovingImage.GetPointer() ); if( !img ) { return update; } typename FixedImageType::SpacingType spacing = img->GetSpacing(); typename FixedImageType::SizeType imagesize = img->GetLargestPossibleRegion().GetSize(); for( unsigned int dd = 0; dd < ImageDimension; dd++ ) { if( oindex[dd] < 1 || oindex[dd] >= static_cast<typename IndexType::IndexValueType>(imagesize[dd] - 1) ) { return update; } } CovariantVectorType movingGradient; ParametersType fdvec1(ImageDimension); ParametersType fdvec2(ImageDimension); fdvec1.Fill(0); fdvec2.Fill(0); movingGradient = m_MovingImageGradientCalculator->EvaluateAtIndex( oindex ); double nccm1 = 0; double loce = this->GetValueAndDerivative(oindex, nccm1, fdvec1, fdvec2); float eps = 10; if( loce > eps ) { loce = eps; } if( loce < eps * (-1.0) ) { loce = eps * (-1.0); } for( unsigned int imd = 0; imd < ImageDimension; imd++ ) { update[imd] = loce * movingGradient[imd] * spacing[imd] * (1); } return update; } void WriteImages() { if( this->m_MetricImage ) { typedef ImageFileWriter<FixedImageType> writertype; typename writertype::Pointer w = writertype::New(); w->SetInput( this->m_MetricImage); w->SetFileName("ZZmetric.nii.gz"); w->Write(); } } void SetOpticalFlow(bool b) { m_OpticalFlow = b; } typename JointPDFType::Pointer GetJointPDF() { return m_JointPDF; } typename JointPDFType::Pointer GetJointHist() { return m_JointHist; } void SetFixedImageMask( FixedImageType* img) { m_FixedImageMask = img; } /** FixedImage image neighborhood iterator type. */ typedef ConstNeighborhoodIterator<FixedImageType> FixedImageNeighborhoodIteratorType; /** A global data type for this class of equation. Used to store * iterators for the fixed image. */ struct GlobalDataStruct { FixedImageNeighborhoodIteratorType m_FixedImageIterator; }; /** The fixed image marginal PDF. */ mutable MarginalPDFType::Pointer m_FixedImageMarginalPDF; /** The moving image marginal PDF. */ mutable MarginalPDFType::Pointer m_MovingImageMarginalPDF; /** The joint PDF and PDF derivatives. */ typename JointPDFType::Pointer m_JointPDF; unsigned long m_NumberOfSpatialSamples; unsigned long m_NumberOfParameters; /** Variables to define the marginal and joint histograms. */ unsigned long m_NumberOfHistogramBins; double m_MovingImageNormalizedMin; double m_FixedImageNormalizedMin; double m_MovingImageTrueMin; double m_MovingImageTrueMax; double m_FixedImageTrueMin; double m_FixedImageTrueMax; double m_FixedImageBinSize; double m_MovingImageBinSize; protected: SpatialMutualInformationRegistrationFunction(); virtual ~SpatialMutualInformationRegistrationFunction() { }; void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE; private: SpatialMutualInformationRegistrationFunction(const Self &); // purposely not implemented void operator=(const Self &); // purposely not implemented typename JointPDFType::Pointer m_JointHist; typename JointPDFDerivativesType::Pointer m_JointPDFDerivatives; typedef BSplineInterpolateImageFunction<JointPDFType, double> pdfintType; typename pdfintType::Pointer pdfinterpolator; // typename JointPDFType::Pointer m_JointEntropy; typename JointPDFType::Pointer m_JointPDFXuY; typename JointPDFType::Pointer m_JointPDFXYu; typename JointPDFType::Pointer m_JointPDFXlY; typename JointPDFType::Pointer m_JointPDFXYl; typename JointPDFType::Pointer m_JointPDFXuYl; typename JointPDFType::Pointer m_JointPDFXlYu; typename JointPDFType::Pointer m_JointPDFXrYu; typename JointPDFType::Pointer m_JointPDFXuYr; typename pdfintType::Pointer pdfinterpolatorXuY; typename pdfintType::Pointer pdfinterpolatorXYu; typename pdfintType::Pointer pdfinterpolatorXlY; typename pdfintType::Pointer pdfinterpolatorXYl; typename pdfintType::Pointer pdfinterpolatorXuYl; typename pdfintType::Pointer pdfinterpolatorXlYu; typename pdfintType::Pointer pdfinterpolatorXuYr; typename pdfintType::Pointer pdfinterpolatorXrYu; /** Typedefs for BSpline kernel and derivative functions. */ typedef BSplineKernelFunction<3> CubicBSplineFunctionType; typedef BSplineDerivativeKernelFunction<3> CubicBSplineDerivativeFunctionType; /** Cubic BSpline kernel for computing Parzen histograms. */ typename CubicBSplineFunctionType::Pointer m_CubicBSplineKernel; typename CubicBSplineDerivativeFunctionType::Pointer m_CubicBSplineDerivativeKernel; /** * Types and variables related to image derivative calculations. * If a BSplineInterpolationFunction is used, this class obtain * image derivatives from the BSpline interpolator. Otherwise, * image derivatives are computed using central differencing. */ typedef CovariantVector<double, itkGetStaticConstMacro(ImageDimension)> ImageDerivativesType; /** Boolean to indicate if the interpolator BSpline. */ bool m_InterpolatorIsBSpline; // boolean to determine if we use mono-modality assumption bool m_OpticalFlow; /** Typedefs for using BSpline interpolator. */ typedef BSplineInterpolateImageFunction<MovingImageType, CoordinateRepresentationType> BSplineInterpolatorType; /** Pointer to BSplineInterpolator. */ typename BSplineInterpolatorType::Pointer m_BSplineInterpolator; /** Typedefs for using central difference calculator. */ typedef CentralDifferenceImageFunction<MovingImageType, CoordinateRepresentationType> DerivativeFunctionType; /** Pointer to central difference calculator. */ typename DerivativeFunctionType::Pointer m_DerivativeCalculator; /** * Types and variables related to BSpline deformable transforms. * If the transform is of type third order BSplineTransform, * then we can speed up the metric derivative calculation by * only inspecting the parameters within the support region * of a mapped point. */ /** Boolean to indicate if the transform is BSpline deformable. */ /** The number of BSpline parameters per image dimension. */ long m_NumParametersPerDim; /** * The number of BSpline transform weights is the number of * of parameter in the support region (per dimension ). */ unsigned long m_NumBSplineWeights; /** * Enum of the deformabtion field spline order. */ enum { DeformationSplineOrder = 3 }; typename TFixedImage::SpacingType m_FixedImageSpacing; typename TFixedImage::PointType m_FixedImageOrigin; typedef FixedArray<unsigned long, FixedImageType::ImageDimension> ParametersOffsetType; ParametersOffsetType m_ParametersOffset; mutable TransformPointer m_Transform; InterpolatorPointer m_Interpolator; InterpolatorPointer m_FixedImageInterpolator; InterpolatorPointer m_MovingImageInterpolator; GradientCalculatorPointer m_FixedImageGradientCalculator; GradientCalculatorPointer m_MovingImageGradientCalculator; FixedImagePointer m_FixedImageMask; MovingImagePointer m_MovingImageMask; double m_NormalizeMetric; float m_Normalizer; // typedef BSplineInterpolateImageFunction<JointPDFDerivativesType,double> dpdfintType; // typename dpdfintType::Pointer dpdfinterpolator; typedef BSplineInterpolateImageFunction<MarginalPDFType, double> pdfintType2; typename pdfintType2::Pointer pdfinterpolator2; typename pdfintType2::Pointer pdfinterpolator3; unsigned int m_Padding; }; } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkSpatialMutualInformationRegistrationFunction.cxx" #endif #endif
[ "ncullen.th@dartmouth.edu" ]
ncullen.th@dartmouth.edu
8618ce1d73b0db23355058a63e4014798e100869
517b8f53ecc24928a787ab92cb729b7ebe6b3de4
/272.cpp
b5696173eaea831dcf05828a98407e70c56db254
[]
no_license
sajalkhan/UVA-ONLINE-JUDGE
4c738fe946d536a5b058da56d8a025be54514856
801ebd2a6366d11226e275210171c66cc4baecfe
refs/heads/master
2021-05-12T08:15:41.628850
2018-01-12T19:32:30
2018-01-12T19:32:30
117,277,417
1
0
null
null
null
null
UTF-8
C++
false
false
600
cpp
#include<bits/stdc++.h> using namespace std; int main() { char s[10000]; long long count,i; while(gets(s)) { int ln=strlen(s); for(i=0; i<ln; i++) { if(s[i]=='"') { count++; if(count%2==1) { cout<<"``"; } else if(count%2==0) { cout<<"''"; } } else { cout<<s[i]; } } cout<<endl; } return 0; }
[ "sajalhossen@yahoo.com" ]
sajalhossen@yahoo.com
636f2b025823f646f77deda1c9f090a2aa878a45
696fa6c30afdac82d8d17dcd2ac23a1f9bf3c4de
/src/miner.cpp
955d2d8441a8a894a24dbb0d7c0f35d971ef65dd
[ "MIT" ]
permissive
ethereumlaunch/testcoin
a05f36558cdcbc0c26bec6049a25fd4cbd309f3f
d62fd75860641d7f55b7f9271ab4dba941981dd1
refs/heads/master
2021-04-29T22:30:47.661119
2018-02-16T06:06:24
2018-02-16T06:06:24
115,289,048
0
0
null
null
null
null
UTF-8
C++
false
false
24,637
cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2017 The PIVX developers // Copyright (c) 2015-2017 The ALQO developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "miner.h" #include "amount.h" #include "hash.h" #include "crypto/scrypt.h" #include "main.h" #include "masternode-sync.h" #include "net.h" #include "pow.h" #include "primitives/block.h" #include "primitives/transaction.h" #include "timedata.h" #include "util.h" #include "utilmoneystr.h" #ifdef ENABLE_WALLET #include "wallet.h" #endif #include "masternode-payments.h" #include <boost/thread.hpp> #include <boost/tuple/tuple.hpp> using namespace std; ////////////////////////////////////////////////////////////////////////////// // // ALQOMiner // // // Unconfirmed transactions in the memory pool often depend on other // transactions in the memory pool. When we select transactions from the // pool, we select by highest priority or fee rate, so we might consider // transactions that depend on transactions that aren't yet in the block. // The COrphan class keeps track of these 'temporary orphans' while // CreateBlock is figuring out which transactions to include. // class COrphan { public: const CTransaction* ptx; set<uint256> setDependsOn; CFeeRate feeRate; double dPriority; COrphan(const CTransaction* ptxIn) : ptx(ptxIn), feeRate(0), dPriority(0) { } }; uint64_t nLastBlockTx = 0; uint64_t nLastBlockSize = 0; int64_t nLastCoinStakeSearchInterval = 0; // We want to sort transactions by priority and fee rate, so: typedef boost::tuple<double, CFeeRate, const CTransaction*> TxPriority; class TxPriorityCompare { bool byFee; public: TxPriorityCompare(bool _byFee) : byFee(_byFee) {} bool operator()(const TxPriority& a, const TxPriority& b) { if (byFee) { if (a.get<1>() == b.get<1>()) return a.get<0>() < b.get<0>(); return a.get<1>() < b.get<1>(); } else { if (a.get<0>() == b.get<0>()) return a.get<1>() < b.get<1>(); return a.get<0>() < b.get<0>(); } } }; void UpdateTime(CBlockHeader* pblock, const CBlockIndex* pindexPrev) { pblock->nTime = std::max(pindexPrev->GetMedianTimePast() + 1, GetAdjustedTime()); // Updating time can change work required on testnet: if (Params().AllowMinDifficultyBlocks()) pblock->nBits = GetNextWorkRequired(pindexPrev, pblock); } CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, bool fProofOfStake) { CReserveKey reservekey(pwallet); // Create new block auto_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate()); if (!pblocktemplate.get()) return NULL; CBlock* pblock = &pblocktemplate->block; // pointer for convenience // -regtest only: allow overriding block.nVersion with // -blockversion=N to test forking scenarios if (Params().MineBlocksOnDemand()) pblock->nVersion = GetArg("-blockversion", pblock->nVersion); // Create coinbase tx CMutableTransaction txNew; txNew.vin.resize(1); txNew.vin[0].prevout.SetNull(); txNew.vout.resize(1); txNew.vout[0].scriptPubKey = scriptPubKeyIn; CBlockIndex* prev = chainActive.Tip(); txNew.vout[0].nValue = GetBlockValue(prev->nHeight); pblock->vtx.push_back(txNew); pblocktemplate->vTxFees.push_back(-1); // updated at end pblocktemplate->vTxSigOps.push_back(-1); // updated at end // ppcoin: if coinstake available add coinstake tx static int64_t nLastCoinStakeSearchTime = GetAdjustedTime(); // only initialized at startup if (fProofOfStake) { boost::this_thread::interruption_point(); pblock->nTime = GetAdjustedTime(); CBlockIndex* pindexPrev = chainActive.Tip(); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock); CMutableTransaction txCoinStake; int64_t nSearchTime = pblock->nTime; // search to current time bool fStakeFound = false; if (nSearchTime >= nLastCoinStakeSearchTime) { unsigned int nTxNewTime = 0; if (pwallet->CreateCoinStake(*pwallet, pblock->nBits, nSearchTime - nLastCoinStakeSearchTime, txCoinStake, nTxNewTime)) { pblock->nTime = nTxNewTime; pblock->vtx[0].vout[0].SetEmpty(); pblock->vtx.push_back(CTransaction(txCoinStake)); fStakeFound = true; } nLastCoinStakeSearchInterval = nSearchTime - nLastCoinStakeSearchTime; nLastCoinStakeSearchTime = nSearchTime; } if (!fStakeFound) return NULL; } // Largest block you're willing to create: unsigned int nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE); // Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity: nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE - 1000), nBlockMaxSize)); // How much of the block should be dedicated to high-priority transactions, // included regardless of the fees they pay unsigned int nBlockPrioritySize = GetArg("-blockprioritysize", DEFAULT_BLOCK_PRIORITY_SIZE); nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize); // Minimum block size you want to create; block will be filled with free transactions // until there are no more or the block reaches this size: unsigned int nBlockMinSize = GetArg("-blockminsize", DEFAULT_BLOCK_MIN_SIZE); nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize); // Collect memory pool transactions into the block CAmount nFees = 0; { LOCK2(cs_main, mempool.cs); CBlockIndex* pindexPrev = chainActive.Tip(); const int nHeight = pindexPrev->nHeight + 1; CCoinsViewCache view(pcoinsTip); // Priority order to process transactions list<COrphan> vOrphan; // list memory doesn't move map<uint256, vector<COrphan*> > mapDependers; bool fPrintPriority = GetBoolArg("-printpriority", false); // This vector will be sorted into a priority queue: vector<TxPriority> vecPriority; vecPriority.reserve(mempool.mapTx.size()); for (map<uint256, CTxMemPoolEntry>::iterator mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi) { const CTransaction& tx = mi->second.GetTx(); if (tx.IsCoinBase() || tx.IsCoinStake() || !IsFinalTx(tx, nHeight)) continue; COrphan* porphan = NULL; double dPriority = 0; CAmount nTotalIn = 0; bool fMissingInputs = false; BOOST_FOREACH (const CTxIn& txin, tx.vin) { // Read prev transaction if (!view.HaveCoins(txin.prevout.hash)) { // This should never happen; all transactions in the memory // pool should connect to either transactions in the chain // or other transactions in the memory pool. if (!mempool.mapTx.count(txin.prevout.hash)) { LogPrintf("ERROR: mempool transaction missing input\n"); if (fDebug) assert("mempool transaction missing input" == 0); fMissingInputs = true; if (porphan) vOrphan.pop_back(); break; } // Has to wait for dependencies if (!porphan) { // Use list for automatic deletion vOrphan.push_back(COrphan(&tx)); porphan = &vOrphan.back(); } mapDependers[txin.prevout.hash].push_back(porphan); porphan->setDependsOn.insert(txin.prevout.hash); nTotalIn += mempool.mapTx[txin.prevout.hash].GetTx().vout[txin.prevout.n].nValue; continue; } const CCoins* coins = view.AccessCoins(txin.prevout.hash); assert(coins); CAmount nValueIn = coins->vout[txin.prevout.n].nValue; nTotalIn += nValueIn; int nConf = nHeight - coins->nHeight; dPriority += (double)nValueIn * nConf; } if (fMissingInputs) continue; // Priority is sum(valuein * age) / modified_txsize unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); dPriority = tx.ComputePriority(dPriority, nTxSize); uint256 hash = tx.GetHash(); mempool.ApplyDeltas(hash, dPriority, nTotalIn); CFeeRate feeRate(nTotalIn - tx.GetValueOut(), nTxSize); if (porphan) { porphan->dPriority = dPriority; porphan->feeRate = feeRate; } else vecPriority.push_back(TxPriority(dPriority, feeRate, &mi->second.GetTx())); } // Collect transactions into block uint64_t nBlockSize = 1000; uint64_t nBlockTx = 0; int nBlockSigOps = 100; bool fSortedByFee = (nBlockPrioritySize <= 0); TxPriorityCompare comparer(fSortedByFee); std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); while (!vecPriority.empty()) { // Take highest priority transaction off the priority queue: double dPriority = vecPriority.front().get<0>(); CFeeRate feeRate = vecPriority.front().get<1>(); const CTransaction& tx = *(vecPriority.front().get<2>()); std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); vecPriority.pop_back(); // Size limits unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); if (nBlockSize + nTxSize >= nBlockMaxSize) continue; // Legacy limits on sigOps: unsigned int nTxSigOps = GetLegacySigOpCount(tx); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) continue; // Skip free transactions if we're past the minimum block size: const uint256& hash = tx.GetHash(); double dPriorityDelta = 0; CAmount nFeeDelta = 0; mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) continue; // Prioritise by fee once past the priority size or we run out of high-priority // transactions: if (!fSortedByFee && ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) { fSortedByFee = true; comparer = TxPriorityCompare(fSortedByFee); std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); } if (!view.HaveInputs(tx)) continue; CAmount nTxFees = view.GetValueIn(tx) - tx.GetValueOut(); nTxSigOps += GetP2SHSigOpCount(tx, view); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) continue; // Note that flags: we don't want to set mempool/IsStandard() // policy here, but we still have to ensure that the block we // create only contains transactions that are valid in new blocks. CValidationState state; if (!CheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true)) continue; CTxUndo txundo; UpdateCoins(tx, state, view, txundo, nHeight); // Added pblock->vtx.push_back(tx); pblocktemplate->vTxFees.push_back(nTxFees); pblocktemplate->vTxSigOps.push_back(nTxSigOps); nBlockSize += nTxSize; ++nBlockTx; nBlockSigOps += nTxSigOps; nFees += nTxFees; if (fPrintPriority) { LogPrintf("priority %.1f fee %s txid %s\n", dPriority, feeRate.ToString(), tx.GetHash().ToString()); } // Add transactions that depend on this one to the priority queue if (mapDependers.count(hash)) { BOOST_FOREACH (COrphan* porphan, mapDependers[hash]) { if (!porphan->setDependsOn.empty()) { porphan->setDependsOn.erase(hash); if (porphan->setDependsOn.empty()) { vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx)); std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); } } } } } if (!fProofOfStake) { //Masternode and general budget payments FillBlockPayee(txNew, nFees, fProofOfStake); //Make payee if (txNew.vout.size() > 1) { pblock->payee = txNew.vout[1].scriptPubKey; } } nLastBlockTx = nBlockTx; nLastBlockSize = nBlockSize; LogPrintf("CreateNewBlock(): total size %u\n", nBlockSize); // Compute final coinbase transaction. pblock->vtx[0].vin[0].scriptSig = CScript() << nHeight << OP_0; if (!fProofOfStake) { pblock->vtx[0] = txNew; pblocktemplate->vTxFees[0] = -nFees; } // Fill in header pblock->hashPrevBlock = pindexPrev->GetBlockHash(); if (!fProofOfStake) UpdateTime(pblock, pindexPrev); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock); pblock->nNonce = 0; pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); CValidationState state; if (!TestBlockValidity(state, *pblock, pindexPrev, false, false)) { LogPrintf("CreateNewBlock() : TestBlockValidity failed\n"); return NULL; } } return pblocktemplate.release(); } void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce) { // Update nExtraNonce static uint256 hashPrevBlock; if (hashPrevBlock != pblock->hashPrevBlock) { nExtraNonce = 0; hashPrevBlock = pblock->hashPrevBlock; } ++nExtraNonce; unsigned int nHeight = pindexPrev->nHeight + 1; // Height first in coinbase required for block.version=2 CMutableTransaction txCoinbase(pblock->vtx[0]); txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS; assert(txCoinbase.vin[0].scriptSig.size() <= 100); pblock->vtx[0] = txCoinbase; pblock->hashMerkleRoot = pblock->BuildMerkleTree(); } #ifdef ENABLE_WALLET ////////////////////////////////////////////////////////////////////////////// // // Internal miner // double dHashesPerSec = 0.0; int64_t nHPSTimerStart = 0; CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, CWallet* pwallet, bool fProofOfStake) { CPubKey pubkey; if (!reservekey.GetReservedKey(pubkey)) return NULL; CScript scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; return CreateNewBlock(scriptPubKey, pwallet, fProofOfStake); } bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) { LogPrintf("%s\n", pblock->ToString()); LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue)); // Found a solution { LOCK(cs_main); if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash()) return error("ALQOMiner : generated block is stale"); } // Remove key from key pool reservekey.KeepKey(); // Track how many getdata requests this block gets { LOCK(wallet.cs_wallet); wallet.mapRequestCount[pblock->GetHash()] = 0; } // Process this block the same as if we had received it from another node CValidationState state; if (!ProcessNewBlock(state, NULL, pblock)) return error("ALQOMiner : ProcessNewBlock, block not accepted"); return true; } bool fGenerateBitcoins = false; // ***TODO*** that part changed in bitcoin, we are using a mix with old one here for now void BitcoinMiner(CWallet* pwallet, bool fProofOfStake) { LogPrintf("ALQOMiner started\n"); SetThreadPriority(THREAD_PRIORITY_LOWEST); RenameThread("alqo-miner"); // Each thread has its own key and counter CReserveKey reservekey(pwallet); unsigned int nExtraNonce = 0; //control the amount of times the client will check for mintable coins static bool fMintableCoins = false; static int nMintableLastCheck = 0; if (fProofOfStake && (GetTime() - nMintableLastCheck > 5 * 60)) // 5 minute check time { nMintableLastCheck = GetTime(); fMintableCoins = pwallet->MintableCoins(); } while (fGenerateBitcoins || fProofOfStake) { if (fProofOfStake) { if (chainActive.Tip()->nHeight < Params().LAST_POW_BLOCK()) { MilliSleep(5000); continue; } bool test = false; if(test){ if(chainActive.Tip()->nTime < 1471482000) LogPrintf("Point470 \n"); if(vNodes.empty()) LogPrintf("Point471 \n"); if(pwallet->IsLocked()) LogPrintf("Point472 \n"); if(!fMintableCoins) LogPrintf("Point473 \n"); if(nReserveBalance >= pwallet->GetBalance()) LogPrintf("Point474 \n"); if(!masternodeSync.IsSynced()) LogPrintf("Point475 \n"); if(!fGenerateBitcoins && !fProofOfStake) LogPrintf("Point476 \n"); } while (chainActive.Tip()->nTime < 1471482000 || vNodes.empty() || pwallet->IsLocked() || !fMintableCoins || nReserveBalance >= pwallet->GetBalance() || !masternodeSync.IsSynced()) { nLastCoinStakeSearchInterval = 0; MilliSleep(5000); if (!fGenerateBitcoins && !fProofOfStake) continue; } if (mapHashedBlocks.count(chainActive.Tip()->nHeight)) //search our map of hashed blocks, see if bestblock has been hashed yet { if (GetTime() - mapHashedBlocks[chainActive.Tip()->nHeight] < max(pwallet->nHashInterval, (unsigned int)1)) // wait half of the nHashDrift with max wait of 3 minutes { MilliSleep(5000); continue; } } } // // Create new block // unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); CBlockIndex* pindexPrev = chainActive.Tip(); if (!pindexPrev) continue; auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey, pwallet, fProofOfStake)); if (!pblocktemplate.get()) continue; CBlock* pblock = &pblocktemplate->block; IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); //Stake miner main if (fProofOfStake) { LogPrintf("CPUMiner : proof-of-stake block found %s \n", pblock->GetHash().ToString().c_str()); if (!pblock->SignBlock(*pwallet)) { LogPrintf("ALQOMiner(): Signing new block failed \n"); continue; } LogPrintf("CPUMiner : proof-of-stake block was signed %s \n", pblock->GetHash().ToString().c_str()); SetThreadPriority(THREAD_PRIORITY_NORMAL); ProcessBlockFound(pblock, *pwallet, reservekey); SetThreadPriority(THREAD_PRIORITY_LOWEST); continue; } LogPrintf("Running ALQOMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(), ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION)); // // Search // int64_t nStart = GetTime(); uint256 hashTarget = uint256().SetCompact(pblock->nBits); uint256 thash; while (true) { unsigned int nHashesDone = 0; char scratchpad[SCRYPT_SCRATCHPAD_SIZE]; while(true) { scrypt_1024_1_1_256_sp(BEGIN(pblock->nVersion), BEGIN(thash), scratchpad); if (thash <= hashTarget) { // Found a solution SetThreadPriority(THREAD_PRIORITY_NORMAL); LogPrintf("PhilscurrencyMiner:\n"); LogPrintf("proof-of-work found \n powhash: %s \ntarget: %s\n", thash.GetHex(), hashTarget.GetHex()); ProcessBlockFound(pblock, *pwallet, reservekey); SetThreadPriority(THREAD_PRIORITY_LOWEST); // In regression test mode, stop mining after a block is found. if (Params().MineBlocksOnDemand()) throw boost::thread_interrupted(); break; } pblock->nNonce += 1; nHashesDone += 1; if ((pblock->nNonce & 0xFF) == 0) break; } // Meter hashes/sec static int64_t nHashCounter; if (nHPSTimerStart == 0) { nHPSTimerStart = GetTimeMillis(); nHashCounter = 0; } else nHashCounter += nHashesDone; if (GetTimeMillis() - nHPSTimerStart > 4000) { static CCriticalSection cs; { LOCK(cs); if (GetTimeMillis() - nHPSTimerStart > 4000) { dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nHPSTimerStart); nHPSTimerStart = GetTimeMillis(); nHashCounter = 0; static int64_t nLogTime; if (GetTime() - nLogTime > 30 * 60) { nLogTime = GetTime(); LogPrintf("hashmeter %6.0f khash/s\n", dHashesPerSec / 1000.0); } } } } // Check for stop or if block needs to be rebuilt boost::this_thread::interruption_point(); // Regtest mode doesn't require peers if (vNodes.empty() && Params().MiningRequiresPeers()) break; if (pblock->nNonce >= 0xffff0000) break; if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60) break; if (pindexPrev != chainActive.Tip()) break; // Update nTime every few seconds UpdateTime(pblock, pindexPrev); if (Params().AllowMinDifficultyBlocks()) { // Changing pblock->nTime can change work required on testnet: hashTarget.SetCompact(pblock->nBits); } } } } void static ThreadBitcoinMiner(void* parg) { boost::this_thread::interruption_point(); CWallet* pwallet = (CWallet*)parg; try { BitcoinMiner(pwallet, false); boost::this_thread::interruption_point(); } catch (std::exception& e) { LogPrintf("ThreadALQOMiner() exception"); } catch (...) { LogPrintf("ThreadALQOMiner() exception"); } LogPrintf("ThreadALQOMiner exiting\n"); } void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads) { static boost::thread_group* minerThreads = NULL; fGenerateBitcoins = fGenerate; if (nThreads < 0) { // In regtest threads defaults to 1 if (Params().DefaultMinerThreads()) nThreads = Params().DefaultMinerThreads(); else nThreads = boost::thread::hardware_concurrency(); } if (minerThreads != NULL) { minerThreads->interrupt_all(); delete minerThreads; minerThreads = NULL; } if (nThreads == 0 || !fGenerate) return; minerThreads = new boost::thread_group(); for (int i = 0; i < nThreads; i++) minerThreads->create_thread(boost::bind(&ThreadBitcoinMiner, pwallet)); } #endif // ENABLE_WALLET
[ "test@ubuntu.ubuntu-domain" ]
test@ubuntu.ubuntu-domain
676413cbb8c58ef1429549f9d0d3462b3db56693
876f034719bc25b2bdd17466279b3b9063ceb3b7
/C++/Queue.cpp
605c8c15e2db81174eb8709925700d2a6d7f1af1
[]
no_license
gyenattila/Algo1
08339fa4332607dcd6a72d453422351f9e70cc18
d2f7ef59a0ef57da99a1584eab3ed5c7b884bc63
refs/heads/master
2020-04-22T23:39:21.939544
2019-05-22T09:27:22
2019-05-22T09:27:22
170,748,786
0
0
null
null
null
null
UTF-8
C++
false
false
1,802
cpp
#include <iostream> struct E { int key; E* next; }; template<typename T> class Queue { private: E* first; E* last; int size; public: Queue(); ~Queue(); void add(T x); T rem(); T getFirst(); int length(); bool isEmpty(); void setEmpty(); }; template <typename T> Queue<T>::Queue() { first = last = new E; first->next = nullptr; size = 0; } template<typename T> T Queue<T>::rem() { if (size != 0) { int x = first->key; E* s = first; first = first->next; delete s; size--; return x; } std::cerr << "ERROR" << std::endl; return -1; } template<typename T> void Queue<T>::add(T x) { last->next = new E; last->key = x; last = last->next; last->next = nullptr; size++; } template<typename T> T Queue<T>::getFirst() { if (size != 0) return first->key; std::cerr << "ERROR" << std::endl; return -1; } template<typename T> int Queue<T>::length() { return size; } template <typename T> bool Queue<T>::isEmpty() { return size == 0; } template<typename T> Queue<T>::~Queue() { while(first != nullptr) { E* p = first; first = first->next; delete p; } } template<typename T> void Queue<T>::setEmpty() { while(first != last) { E* p = first; first = first->next; delete p; } size = 0; } int main() { Queue<int> q; q.add(1); q.add(2); q.add(3); std::cout << q.getFirst() << std::endl; q.rem(); std::cout << q.getFirst() << std::endl; std::cout << q.length() << std::endl; q.setEmpty(); std::cout << q.getFirst() << std::endl; std::cout << q.length() << std::endl; std::cout << q.rem() << std::endl; }
[ "gyenattila@gmail.com" ]
gyenattila@gmail.com
6a6d129f50bf50ab8da92bb46c210e6b9aa197d3
37b30edf9f643225fdf697b11fd70f3531842d5f
/gpu/command_buffer/service/shared_image_video_image_reader.h
671770261dcf8aab5de3ac93b728c5ba4dc4734f
[ "BSD-3-Clause" ]
permissive
pauladams8/chromium
448a531f6db6015cd1f48e7d8bfcc4ec5243b775
bc6d983842a7798f4508ae5fb17627d1ecd5f684
refs/heads/main
2023-08-05T11:01:20.812453
2021-09-17T16:13:54
2021-09-17T16:13:54
407,628,666
1
0
BSD-3-Clause
2021-09-17T17:35:31
2021-09-17T17:35:30
null
UTF-8
C++
false
false
4,386
h
// Copyright 2021 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 GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_VIDEO_IMAGE_READER_H_ #define GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_VIDEO_IMAGE_READER_H_ #include <memory> #include "base/memory/scoped_refptr.h" #include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" #include "gpu/command_buffer/service/ref_counted_lock.h" #include "gpu/command_buffer/service/shared_context_state.h" #include "gpu/command_buffer/service/shared_image_backing_android.h" #include "gpu/command_buffer/service/shared_image_video.h" #include "gpu/command_buffer/service/stream_texture_shared_image_interface.h" #include "gpu/gpu_gles2_export.h" namespace gpu { class SharedImageRepresentationGLTexture; class SharedImageRepresentationSkia; struct Mailbox; // Implementation of SharedImageBacking that renders MediaCodec buffers to a // TextureOwner or overlay as needed in order to draw them. class GPU_GLES2_EXPORT SharedImageVideoImageReader : public SharedImageVideo, public SharedContextState::ContextLostObserver, public RefCountedLockHelperDrDc { public: SharedImageVideoImageReader( const Mailbox& mailbox, const gfx::Size& size, const gfx::ColorSpace color_space, GrSurfaceOrigin surface_origin, SkAlphaType alpha_type, scoped_refptr<StreamTextureSharedImageInterface> stream_texture_sii, scoped_refptr<SharedContextState> shared_context_state, scoped_refptr<RefCountedLock> drdc_lock); ~SharedImageVideoImageReader() override; // Disallow copy and assign. SharedImageVideoImageReader(const SharedImageVideoImageReader&) = delete; SharedImageVideoImageReader& operator=(const SharedImageVideoImageReader&) = delete; // SharedImageBacking implementation. size_t EstimatedSizeForMemTracking() const override; std::unique_ptr<base::android::ScopedHardwareBufferFenceSync> GetAHardwareBuffer() override; // SharedContextState::ContextLostObserver implementation. void OnContextLost() override; protected: std::unique_ptr<SharedImageRepresentationGLTexture> ProduceGLTexture( SharedImageManager* manager, MemoryTypeTracker* tracker) override; std::unique_ptr<SharedImageRepresentationGLTexturePassthrough> ProduceGLTexturePassthrough(SharedImageManager* manager, MemoryTypeTracker* tracker) override; std::unique_ptr<SharedImageRepresentationSkia> ProduceSkia( SharedImageManager* manager, MemoryTypeTracker* tracker, scoped_refptr<SharedContextState> context_state) override; std::unique_ptr<gpu::SharedImageRepresentationOverlay> ProduceOverlay( gpu::SharedImageManager* manager, gpu::MemoryTypeTracker* tracker) override; // TODO(vikassoni): Add overlay and AHardwareBuffer representations in future // patch. Overlays are anyways using legacy mailbox for now. private: class SharedImageRepresentationGLTextureVideo; class SharedImageRepresentationGLTexturePassthroughVideo; class SharedImageRepresentationVideoSkiaVk; class SharedImageRepresentationOverlayVideo; void BeginGLReadAccess(const GLuint service_id); // Creating representations on SharedImageVideoImageReader is already thread // safe but SharedImageVideoImageReader backing can be destroyed on any thread // when a backing is used by multiple threads like dr-dc. Hence backing is not // guaranteed to be destroyed on the same thread on which it was created. // This method ensures that all the member variables of this class are // destroyed on the thread in which it was created. static void CleanupOnCorrectThread( scoped_refptr<StreamTextureSharedImageInterface> stream_texture_sii, scoped_refptr<SharedContextState> context_state, SharedImageVideoImageReader* backing, base::WaitableEvent* event, scoped_refptr<RefCountedLock> lock); scoped_refptr<StreamTextureSharedImageInterface> stream_texture_sii_; scoped_refptr<SharedContextState> context_state_; // Currently this object is created only from gpu main thread. scoped_refptr<base::SingleThreadTaskRunner> gpu_main_task_runner_; }; } // namespace gpu #endif // GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_VIDEO_IMAGE_READER_H_
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
0d73640839ecc2cfab799f7b9ddd53bfc2379875
09882ac9f3d0949cadc9743544f24a7b12f962fd
/src/frontend/anchor.h
f0a6a549e1604d6b8c3ed5b9d855c7f5b2996c14
[]
no_license
ousttrue/w3m1
ddcc240c5d9017ce78dd41cca3197c6bd191f0a1
eaf5969cdacb3f9ae19e1fa32a652c88695fbf4c
refs/heads/master
2022-12-08T23:58:04.264222
2020-09-03T13:30:24
2020-09-03T13:30:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,004
h
#pragma once #include <vector> #include <string> #include <string_view> #include <memory> #include "bufferpoint.h" #include "stream/http.h" struct Image; struct FormItem; struct Anchor { std::string url; std::string target; HttpReferrerPolicy referer; std::string title; unsigned char accesskey = 0; // byte position BufferPoint start; BufferPoint end; bool IsHit(int pos) const { return pos >= start.pos && pos < end.pos; } int hseq = 0; char slave = 0; short y = 0; short rows = 0; Image *image = nullptr; std::shared_ptr<FormItem> item; static std::shared_ptr<Anchor> CreateHref(std::string_view url, std::string_view target, HttpReferrerPolicy referer, std::string title, unsigned char key, int line, int pos) { auto p = std::make_shared<Anchor>(); *p = Anchor{ url : std::move(std::string(url)), target : std::move(std::string(target)), referer : referer, title : std::move(std::string(title)), accesskey : key, start : { line : line, pos : pos, }, end : { line : line, pos : pos, }, }; return p; } static std::shared_ptr<Anchor> CreateName(std::string_view url, int line, int pos) { auto p = std::make_shared<Anchor>(); *p = Anchor{ url : std::move(std::string(url)), accesskey : '\0', start : { line : line, pos : pos, }, end : { line : line, pos : pos, }, }; return p; } static std::shared_ptr<Anchor> CreateImage(std::string_view url, std::string_view title, int line, int pos) { auto p = std::make_shared<Anchor>(); *p = Anchor{ url : std::move(std::string(url)), title : std::move(std::string(title)), accesskey : '\0', start : { line : line, pos : pos, }, end : { line : line, pos : pos, }, }; return p; } int CmpOnAnchor(const BufferPoint &bp) const; }; using AnchorPtr = std::shared_ptr<Anchor>; class AnchorList { mutable int m_acache = -1; public: std::vector<AnchorPtr> anchors; void clear() { m_acache = -1; } size_t size() const { return anchors.size(); } operator bool() const { return !anchors.empty(); } void Put(const AnchorPtr &a); AnchorPtr RetrieveAnchor(const BufferPoint &bp) const; AnchorPtr SearchByUrl(const char *str) const; AnchorPtr ClosestNext(const AnchorPtr &an, int x, int y) const; AnchorPtr ClosestPrev(const AnchorPtr &an, int x, int y) const; };
[ "ousttrue@gmail.com" ]
ousttrue@gmail.com
110a5006b85875fc72e9ed894a92db6ff589e519
f97b1fe262bab9f88a4fe7bab7ceb37c6919a622
/assignment1.cpp
04930caa1cdc42fbe76150b11c60ccfd986214e0
[]
no_license
daiseyj15/1428CS1
9e46d9975f8f60ef9ffa002d48b806b03dbdc0db
abea47e069ce228bba26a9edfc658923cfde40ef
refs/heads/master
2020-11-28T14:52:42.564094
2019-12-24T14:35:46
2019-12-24T14:35:46
229,850,626
0
0
null
null
null
null
UTF-8
C++
false
false
4,312
cpp
/* * 1428_4_F18_PA1_Jaramillo_Daisey.cpp * * Author : Daisey Marie Jaramillo * Due date : September 10,2018 * Programming Assignment Number 1 * Fall 2018 - CS1428 - Section Number 4 * * Instructor : Husain Gholoom * * ** This program prints information about myself :) ** * */ #include <iostream> using namespace std; int main() { // Displaying the first part cout << "*********************************************************************************" << endl; cout << "*\t\t WELCOME \t\t\t\t\t\t\t*" << endl; // Declare variables string firstName , lastName; firstName = "Daisey"; lastName = "Jaramillo"; // My name char midInitial; midInitial = 'M'; string course; // The name of the course course = "Foundations of Computer Science I"; int sectionNumber; sectionNumber = 1428; // The section number for this class int sectionNumber2; sectionNumber2 = 004; int serialNumber; // Number next to my name on the roster serialNumber = 31; string month; month = "September"; int date; // The due date date = 10; int year; year = 2018; string major; // My major major = "Computer Science"; string minor; // My minor minor = "Mathematics"; string classification; // The class I'm in classification = "Junior"; string Iam; // If I'm a full time student Iam = "a full time student"; string reason; // My reasoning for being in this class reason = "This class is part of earning my *\n* \t degree and I also really enjoy learning to code!"; char grade; // what grade i expect to get in this class grade = 'A'; string workXP; // places i have worked at before workXP = "Beaver's Kitchen and HEB"; string computerSkills; // My computer skills computerSkills = "Java"; string favMovie; // My favorite movie favMovie = "The Great Gatsby"; string favSport; // My favorite sport favSport = "Baseball"; string favSong; // My favorite song favSong = "Blood On The Leaves by: Kanye West"; string favShow; // My favorite show favShow = "American Horror Story"; string hobbies; // Some hobbies of mine hobbies = "Making YouTube videos and making music"; // Display answers and stars cout << "*\t My Name is : " << lastName << " " << firstName << " " << midInitial << "\t\t\t\t\t*" << endl; cout << "*\t This course is : " << course << "\t\t\t*" << endl; cout << "*\t Section Number : " << sectionNumber << "-" << sectionNumber2 << "\t\t\t\t\t\t*" << endl; cout << "*\t Serial Number : " << serialNumber << "\t\t\t\t\t\t\t*" << endl; cout << "*\t Date : " << month << " " << date << ", " << year << "\t\t\t\t\t\t*" << endl; cout << "*\t Major : " << major << "\t\t\t\t\t\t*" << endl; cout << "*\t Minor : " << minor << "\t\t\t\t\t\t\t*" << endl; cout << "*\t Classification : " << classification << "\t\t\t\t\t\t*" << endl; cout << "*\t I am : " << Iam << "\t\t\t\t\t\t*" << endl; cout << "*\t The Reason for Taking This Class : " << reason << "\t\t\t*" << endl; cout << "*\t Grade Expected : " << grade << "\t\t\t\t\t\t\t*" << endl; cout << "*\t About Me : \t\t\t\t\t\t\t\t*" << endl; cout << "*\t\t Working Experience : " << workXP << "\t\t\t*" << endl; cout << "*\t\t Computer Skills : " << computerSkills << "\t\t\t\t\t\t*" << endl; cout << "*\t\t\t\t\t\t\t\t\t\t*" << endl; cout << "*\t\t Favorite Movie : " << favMovie << "\t\t\t\t*" << endl; cout << "*\t\t Favorite Sport : " << favSport << "\t\t\t\t\t*" << endl; cout << "*\t\t Favorite Artist / Song : " << favSong << "\t*" << endl; cout << "*\t\t Favorite TV Show : " << favShow << "\t\t\t*" << endl; cout << "*\t\t Hobbies : " << hobbies << "\t\t*" << endl; cout << "*\t\t\t\t\t\t\t\t\t\t*" << endl; cout << "*********************************************************************************" << endl << endl << endl; cout << "Prepared by : " << lastName << " " << firstName << " " << midInitial << "." << endl; cout << month << " " << year << endl << endl << endl; return 0; }
[ "noreply@github.com" ]
noreply@github.com
9cb05eef2bae9a3eb670fe0c5a8f933fd4947315
06b63d12f3df3e2a67e82361f25ae22a972254d1
/haixiangsrc/haixiang/GoGameService/Board.h
99839011b618fb644194e5625eac643e05903d48
[]
no_license
lindianyin/testboost
64276f9a33bebcfb77d85f93a71400a58f138875
6fa4a98f9773f988a1d0855477a5cc0fc4aeeb64
refs/heads/master
2021-01-15T15:42:08.898669
2016-08-25T08:13:53
2016-08-25T08:13:53
53,821,167
1
1
null
null
null
null
UTF-8
C++
false
false
2,566
h
#pragma once #include "boost/smart_ptr.hpp" #include "Chess.h" #include <map> #include <list> #include <vector> //走棋记录 class BoardRecorder : public boost::enable_shared_from_this<BoardRecorder> { public: enum RecorderType { ADD = 0, //走棋 EAT = 1, //吃子 PASS = 2, //pass }; RecorderType type; //走棋类型 Chess::ChessType cType; //操作方 int PosX; int PosY; int step; //步数,只有add有步数 }; typedef boost::shared_ptr<BoardRecorder> recorder_ptr; class Board : public boost::enable_shared_from_this<Board> { public: int cur_turn; //回合(1黑2白) int cur_timer; //当前计时 int history; //总回合次 int cur_step; //当前步数 float fBlack; //黑子得分 float fWhite; //白子得分 Chess* last_BChess; //黑子最后一步棋 Chess* last_WChess; //白子最后一步棋 std::vector<Chess*> last_eat_list; //最后一步被吃的子 std::list<recorder_ptr> recorder_list; //走棋的记录 //棋盘 std::map<std::string, Chess*> chess_list; //模拟棋盘 std::map<std::string, Chess*> simulation_list; Board(); ~Board(); bool init(); void reset(); //当前位置是否是空 bool ChessIsEmpty(int x, int y); //添加棋子 int addChess(int type, int x, int y, bool is_undo = false); //移除棋子 int removeChess(int x, int y); //是否有气 bool isLive(int type, int x, int y); //搜索块 void findBlock(int type, int x, int y, std::list<Chess*>& clist); //是否能吃子 bool isEat(int type, int x, int y, std::vector<Chess*>& clist); //尝试吃子 bool tryEat(int type, int x, int y, std::vector<Chess*>& clist); //吃子 void submitEat(int type, int x, int y); //执行一次悔棋 bool carry_out_undo(int type, recorder_ptr& cur_recorder); //清除某一个棋子 void cleanChess(int x, int y); //计算得分 bool caclulateResult(); //获得某一行棋盘信息 int getDataByLine(int y, int type); //获得某一个棋子 Chess* getChessByPoint(int x, int y, std::map<std::string, Chess*>& map); //点目 std::list<Chess*> goPoint(int type); void setPoint(int x, int y, int type, bool isHide); void clearPoint(); private: //获得同类的子list std::list<Chess*> getChessFormType(int type, std::map<std::string, Chess*>& map); //获得对手类型 Chess::ChessType getopponent(Chess::ChessType type); //点目-点目操作 void setPoint(int type, int x, int y, std::list<Chess*>& clist); };
[ "lindianyin@foxmail.com" ]
lindianyin@foxmail.com
67eb4b3cdf476e9cb7e5edb53e86fd4c10ed047b
0014fb5ce4aa3a6f460128bb646a3c3cfe81eb9e
/testdata/19/1/src/node13.cpp
6c4de559e6cab9c088426ddb757224c661adaafb
[]
no_license
yps158/randomGraph
c1fa9c531b11bb935d112d1c9e510b5c02921df2
68f9e2e5b0bed1f04095642ee6924a68c0768f0c
refs/heads/master
2021-09-05T05:32:45.210171
2018-01-24T11:23:06
2018-01-24T11:23:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,680
cpp
#include "ros/ros.h" #include "std_msgs/String.h" #include "unistd.h" #include <sstream> #include <random> std::random_device rd; std::mt19937 gen(rd()); std::normal_distribution<> d(0.021294, 0.005); class Node13{ public: Node13(){ sub_5_13_flag = 0; sub_5_13 = n.subscribe("topic_5_13", 1, &Node13::middlemanCallback5,this); sub_9_13_flag = 0; sub_9_13 = n.subscribe("topic_9_13", 1, &Node13::middlemanCallback9,this); sub_11_13_flag = 0; sub_11_13 = n.subscribe("topic_11_13", 1, &Node13::middlemanCallback11,this); pub_13_16 = n.advertise<std_msgs::String>("topic_13_16", 1); pub_13_15 = n.advertise<std_msgs::String>("topic_13_15", 1); pub_13_14 = n.advertise<std_msgs::String>("topic_13_14", 1); } void middlemanCallback5(const std_msgs::String::ConstPtr& msg){ if(sub_9_13_flag == 1 && sub_11_13_flag == 1 && true){ usleep(d(gen)*1000000); ROS_INFO("I'm node13 last from node5, intercepted: [%s]", msg->data.c_str()); pub_13_16.publish(msg); pub_13_15.publish(msg); pub_13_14.publish(msg); sub_9_13_flag = 0; sub_11_13_flag = 0; } else{ ROS_INFO("I'm node13, from node5 intercepted: [%s]", msg->data.c_str()); sub_5_13_flag = 1; } } void middlemanCallback9(const std_msgs::String::ConstPtr& msg){ if(sub_5_13_flag == 1 && sub_11_13_flag == 1 && true){ usleep(d(gen)*1000000); ROS_INFO("I'm node13 last from node9, intercepted: [%s]", msg->data.c_str()); pub_13_16.publish(msg); pub_13_15.publish(msg); pub_13_14.publish(msg); sub_5_13_flag = 0; sub_11_13_flag = 0; } else{ ROS_INFO("I'm node13, from node9 intercepted: [%s]", msg->data.c_str()); sub_9_13_flag = 1; } } void middlemanCallback11(const std_msgs::String::ConstPtr& msg){ if(sub_5_13_flag == 1 && sub_9_13_flag == 1 && true){ usleep(d(gen)*1000000); ROS_INFO("I'm node13 last from node11, intercepted: [%s]", msg->data.c_str()); pub_13_16.publish(msg); pub_13_15.publish(msg); pub_13_14.publish(msg); sub_5_13_flag = 0; sub_9_13_flag = 0; } else{ ROS_INFO("I'm node13, from node11 intercepted: [%s]", msg->data.c_str()); sub_11_13_flag = 1; } } private: ros::NodeHandle n; ros::Publisher pub_13_16; ros::Publisher pub_13_15; ros::Publisher pub_13_14; int sub_5_13_flag; ros::Subscriber sub_5_13; int sub_9_13_flag; ros::Subscriber sub_9_13; int sub_11_13_flag; ros::Subscriber sub_11_13; }; int main(int argc, char **argv){ ros::init(argc, argv, "node13"); Node13 node13; ros::spin(); return 0; }
[ "sasaki@thinkingreed.co.jp" ]
sasaki@thinkingreed.co.jp
d046db10a16e8c2b20f5bd847ce3b8d38cd51507
1a9462cf8bf332d5171afe1913fba9a0fec262f8
/externals/boost/boost/test/impl/interaction_based.ipp
a6b62c2dd8dee417ec3cc50566387f524eb76140
[ "BSD-2-Clause" ]
permissive
ugozapad/g-ray-engine
4184fd96cd06572eb7e847cc48fbed1d0ab5767a
6a28c26541a6f4d50b0ca666375ab45f815c9299
refs/heads/main
2023-06-24T06:45:37.003158
2021-07-23T01:16:34
2021-07-23T01:16:34
377,952,802
4
0
null
null
null
null
UTF-8
C++
false
false
3,615
ipp
// (C) Copyright Gennadiy Rozental 2005. // Use, modification, and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/test for the library home page. // // File : $RCSfile: interaction_based.ipp,v $ // // Version : $Revision: 1.7 $ // // Description : Facilities to perform interaction-based testing // *************************************************************************** #ifndef BOOST_TEST_INTERACTION_BASED_IPP_112105GER #define BOOST_TEST_INTERACTION_BASED_IPP_112105GER // Boost.Test #include <boost/test/detail/config.hpp> #if !BOOST_WORKAROUND(__GNUC__, < 3) && \ !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ !BOOST_WORKAROUND(BOOST_MSVC, <1310) && \ !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x530)) // Boost.Test #include <boost/test/detail/config.hpp> #include <boost/test/utils/callback.hpp> #include <boost/test/interaction_based.hpp> #include <boost/test/mock_object.hpp> #include <boost/test/framework.hpp> // for setup_error #include <boost/test/detail/suppress_warnings.hpp> // STL #include <stdexcept> #include <string> //____________________________________________________________________________// namespace boost { namespace itest { // interaction-based testing // ************************************************************************** // // ************** manager ************** // // ************************************************************************** // manager::manager() { instance_ptr( true, this ); } //____________________________________________________________________________// manager::~manager() { instance_ptr( true ); } //____________________________________________________________________________// manager* manager::instance_ptr( bool reset, manager* new_ptr ) { static manager dummy( 0 ); static manager* ptr = &dummy; if( reset ) { if( new_ptr ) { if( ptr != &dummy ) throw unit_test::framework::setup_error( BOOST_TEST_L( "Couldn't run two interation based test the same time" ) ); ptr = new_ptr; } else ptr = &dummy; } return ptr; } } // namespace itest } // namespace boost //____________________________________________________________________________// #include <boost/test/detail/enable_warnings.hpp> #endif // not ancient compiler // *************************************************************************** // Revision History : // // $Log: interaction_based.ipp,v $ // Revision 1.7 2006/03/19 07:27:52 rogeeff // streamline test setup error message // // Revision 1.6 2006/02/23 15:10:00 rogeeff // vc70 out // // Revision 1.5 2006/02/22 16:13:34 rogeeff // ifdef out for non supported compilers // // Revision 1.4 2006/01/28 08:52:35 rogeeff // operator new overloads made inline to: // 1. prevent issues with export them from DLL // 2. release link issue fixed // // Revision 1.3 2006/01/15 11:14:39 rogeeff // simpl_mock -> mock_object<>::prototype() // operator new need to be rethinked // // Revision 1.2 2005/12/22 15:49:32 rogeeff // sunpro port // made operator new conformant // // Revision 1.1 2005/12/14 05:56:56 rogeeff // Interraction based / logged expectation testing is introduced // // *************************************************************************** #endif // BOOST_TEST_INTERACTION_BASED_IPP_112105GER
[ "hp1link2@gmail.com" ]
hp1link2@gmail.com
c2dceaefd0de6d85b693088b7921e30af3c6c7fa
5eda23ada89aa9ae599a344bfbf5dc12113bb164
/posAvg.cpp
4bb606d577bb0dc55e62fe1e62c68a552f5228fe
[]
no_license
lrokey/Programming-Exercises
68a2078658818e991c31acc408bba308ec32641c
2e0112afc8f394d55f0949684bb8044ac27976b8
refs/heads/master
2023-05-04T11:21:01.249409
2023-04-23T16:06:00
2023-04-23T16:06:00
61,220,746
0
0
null
null
null
null
UTF-8
C++
false
false
997
cpp
/* Prob. 11 Input: User entered positive integers. Output: Average */ #include <iostream> #include <vector> #include <numeric> #include <iterator> using namespace std; void whatsInside(const vector<int> &numbers); double computeAverage(vector<int> numbers); int main() { int userNum; vector<int> listOfNums; do{ cout << "Enter your integer: "; cin >> userNum; if (userNum < 0){ cout << "ERROR! Enter a positive number: "; cin >> userNum; }else{ listOfNums.push_back(userNum); } }while(userNum != 0); cout << "The average for { "; whatsInside(&listOfNums); cout << "} is " << computeAverage(listOfNums) << endl; return 0; } void whatsInside(const vector<int> &numbers){ copy(numbers.begin(), numbers.end(), ostream_iterator<int>(cout, " ")); } double computeAverage(vector<int> numbers){ return accumulate(numbers.begin(), numbers.end(), 0.0)/numbers.size(); }
[ "noreply@github.com" ]
noreply@github.com
1a7056f761e0155586edbfa7a6e2baa70d00637a
e7787104bb95a209107f97abd762f125b2e20340
/PrecureModelDisplayer/D3D11Graphics.cpp
112629430562e375189fceec4532dc82a8a01d28
[]
no_license
marklang1993/3DModelDisplayer
058b706ddbc9fc4c252ad0e37022cc3ef2acf9cb
8e76b251b459ad2bc6e58227c4ab026936890def
refs/heads/master
2021-01-19T03:46:19.539136
2016-05-27T13:03:23
2016-05-27T13:03:23
45,733,078
1
0
null
null
null
null
UTF-8
C++
false
false
13,125
cpp
#include "D3D11Graphics.h" #include "PrecureModelDisplayerException.h" #include "Library.h" #include "ObjFileReader.h" #include <vector> #include <fstream> #include "math.h" using namespace DirectX; D3D11Graphics::D3D11Graphics(HWND hwnd) { //Set all Pointers to NULL device_ = NULL; deviceContext_= NULL; swapChain_ = NULL; renderTargetView_ = NULL; stencilBuffer_ = NULL; depthStencilView_ = NULL; rasterizerState_ = NULL; effect_ = NULL; effectTechnique_ = NULL; inputLayout_ = NULL; vertexBuffer_ = NULL; indexBuffer_ = NULL; //Return Value HRESULT hResult = NULL; //1. Create D3D11 Device & DeviceContext hResult = D3D11CreateDevice( NULL, //Default Adapter D3D_DRIVER_TYPE_HARDWARE, //Hardware Accleration NULL, //Hardware is chosen 0, //No Optional Flags //D3D11_CREATE_DEVICE_SINGLETHREADED, //Single Thread Mode is chosen NULL, //Array of Available D3D Feature Levels 0, //Size of the above Array D3D11_SDK_VERSION, //Fixed Value &device_, //Pointer to the pointer pointed to a D3D11 Device &d3d_feature_level_, //Selected D3D Feature Level &deviceContext_ //Pointer to the pointer pointed to a D3D11 DeviceContext ); //Check the Result of Creating D3D11 Device CheckHR(hResult, PMD_FailCreateD3D11DeviceException()); //2. CheckMultiSampling hResult = device_->CheckMultisampleQualityLevels( DXGI_FORMAT_R8G8B8A8_UNORM, 4, //4x &supportNumMSQualityLevel_ //Supported Number of Multisampling Quality Level ); if (hResult != S_OK) { //If checking failed, set it 0 (Unsupported). supportNumMSQualityLevel_ = 0; } //3. Create SwapChain RECT window_rect; if (GetWindowRect(hwnd, &window_rect) == FALSE) { SafeRelease(device_); SafeRelease(deviceContext_); throw PMD_FailCreateSwapChainException(); } DXGI_MODE_DESC mode_desc; mode_desc.Width = window_rect.right - window_rect.left; mode_desc.Height = window_rect.bottom - window_rect.top; mode_desc.RefreshRate.Numerator = 60; //60Hz mode_desc.RefreshRate.Denominator = 1; mode_desc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; mode_desc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; mode_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; DXGI_SWAP_CHAIN_DESC swap_chain_desc; swap_chain_desc.BufferDesc = mode_desc; swap_chain_desc.BufferCount = 1; //only 1 Buffer used swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; //used for render target output swap_chain_desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; swap_chain_desc.OutputWindow = hwnd; swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; swap_chain_desc.Windowed = !FULL_SCREEN; //MultiSampling if (supportNumMSQualityLevel_ == 0) { //MultiSampling is disable swap_chain_desc.SampleDesc.Count = 1; swap_chain_desc.SampleDesc.Quality = 0; } else { swap_chain_desc.SampleDesc.Count = 4; //4 sampling point swap_chain_desc.SampleDesc.Quality = supportNumMSQualityLevel_ - 1; } IDXGIDevice* pIDXGIDevice = NULL; IDXGIAdapter* pIDXGIAdapter = NULL; IDXGIFactory* pIDXGIFactory = NULL; hResult = device_->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&pIDXGIDevice)); CheckHR(hResult, PMD_FailCreateSwapChainException()); hResult = pIDXGIDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void**>(&pIDXGIAdapter)); CheckHR(hResult, PMD_FailCreateSwapChainException()); hResult = pIDXGIAdapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&pIDXGIFactory)); CheckHR(hResult, PMD_FailCreateSwapChainException()); hResult = pIDXGIFactory->CreateSwapChain(device_, &swap_chain_desc, &swapChain_); CheckHR(hResult, PMD_FailCreateSwapChainException()); SafeRelease(pIDXGIDevice); SafeRelease(pIDXGIAdapter); SafeRelease(pIDXGIFactory); //4. Create RenderTargetView ID3D11Texture2D* backBuffer; hResult = swapChain_->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**> (&backBuffer)); //GetBuffer() will increase the COM reference count CheckHR(hResult, PMD_FailCreateRenderTargetViewException()); hResult = device_->CreateRenderTargetView(backBuffer, NULL, &renderTargetView_); CheckHR(hResult, PMD_FailCreateRenderTargetViewException()); //Release SafeRelease(backBuffer); //Decrease the COM reference count //5. Create DepthStencilView D3D11_TEXTURE2D_DESC texture2d_desc; texture2d_desc.ArraySize = 1; //Used for Texture Array. NOT useful here texture2d_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL; //Binding type texture2d_desc.CPUAccessFlags = 0; //No access for CPU texture2d_desc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; //24bits for Depth, 8 bits for template texture2d_desc.Height = window_rect.bottom - window_rect.top; texture2d_desc.Width = window_rect.right - window_rect.left; texture2d_desc.MipLevels = 1; //Not use Mipmap texture2d_desc.MiscFlags = 0; texture2d_desc.Usage = D3D11_USAGE_DEFAULT; //For GPU Read & Write //MultiSampling if (supportNumMSQualityLevel_ == 0) { //MultiSampling is disable texture2d_desc.SampleDesc.Count = 1; texture2d_desc.SampleDesc.Quality = 0; } else { texture2d_desc.SampleDesc.Count = 4; //4 sampling point texture2d_desc.SampleDesc.Quality = supportNumMSQualityLevel_ - 1; } hResult = device_->CreateTexture2D(&texture2d_desc, NULL, &stencilBuffer_); CheckHR(hResult, PMD_FailCreateDepthStencilViewException()); hResult = device_->CreateDepthStencilView(stencilBuffer_, NULL, &depthStencilView_); CheckHR(hResult, PMD_FailCreateDepthStencilViewException()); //Bind to Rendering Pipeline deviceContext_->OMSetRenderTargets(1, &renderTargetView_, depthStencilView_); //6. Set ViewPoint D3D11_VIEWPORT viewpoint; //#####WARNNING windowWidth_ = static_cast<FLOAT>(window_rect.right - window_rect.left); windowHeight_ = static_cast<FLOAT>(window_rect.bottom - window_rect.top); viewpoint.Width = windowWidth_; viewpoint.Height = windowHeight_; viewpoint.TopLeftX = 0.0f; viewpoint.TopLeftY = 0.0f; viewpoint.MinDepth = NEAR_POINT; viewpoint.MaxDepth = FAR_POINT; deviceContext_->RSSetViewports(1, &viewpoint); //7. Initialize Effect initializeEffect_(); //8. Initialize InputLayout initializeInputLayout_(); //9. Initialize Buffer ObjFileReader* modelFile = new ObjFileReader("lovely_poseA_geo.obj"); initializeVertexBuffer_(modelFile); initializeIndexBuffer_(modelFile); delete modelFile; //10. Initilize Matrix initializeMatrix_(); //11. Initilize RasterizerState D3D11_RASTERIZER_DESC rasterizerDesc; rasterizerDesc.FillMode = D3D11_FILL_WIREFRAME; rasterizerDesc.CullMode = D3D11_CULL_BACK; rasterizerDesc.FrontCounterClockwise = false; rasterizerDesc.DepthBias = 0; rasterizerDesc.DepthBiasClamp = 0.0f; rasterizerDesc.SlopeScaledDepthBias = 0.0f; rasterizerDesc.DepthClipEnable = true; rasterizerDesc.ScissorEnable = false; rasterizerDesc.MultisampleEnable = true; rasterizerDesc.AntialiasedLineEnable = false; CheckHR(device_->CreateRasterizerState(&rasterizerDesc, &rasterizerState_), PMD_FailedCreateRasterizerState()); deviceContext_->RSSetState(rasterizerState_); } D3D11Graphics::~D3D11Graphics() { SafeRelease(device_); SafeRelease(deviceContext_); SafeRelease(swapChain_); SafeRelease(renderTargetView_); SafeRelease(stencilBuffer_); SafeRelease(depthStencilView_); SafeRelease(rasterizerState_); SafeRelease(effect_); //SafeRelease(effectTechnique_); SafeRelease(inputLayout_); SafeRelease(vertexBuffer_); SafeRelease(indexBuffer_); } void D3D11Graphics::Render() { //Clear Screen deviceContext_->ClearRenderTargetView(renderTargetView_, reinterpret_cast<float*>(&Colors::White)); deviceContext_->ClearDepthStencilView(depthStencilView_, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.f, 0); //Calculate Matrix WVP mWVP_ = XMLoadFloat4x4(&mWorld_) * XMLoadFloat4x4(&mView_) * XMLoadFloat4x4(&mProjection_); //Bind Vertex Buffer UINT stride = sizeof(Vertex); UINT offset = 0; deviceContext_->IASetVertexBuffers(0, 1, &vertexBuffer_, &stride, &offset); //Bind Index Buffer deviceContext_->IASetIndexBuffer(indexBuffer_, DXGI_FORMAT_R32_UINT, 0); //Set InputLayout deviceContext_->IASetInputLayout(inputLayout_); //Set Topology deviceContext_->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); //Set WVP Matrix ID3DX11EffectMatrixVariable* effectMatrixVariable; effectMatrixVariable = effect_->GetVariableByName("matrixWVP")->AsMatrix(); effectMatrixVariable->SetMatrix(reinterpret_cast<float*>(&mWVP_)); SafeRelease(effectMatrixVariable); D3DX11_TECHNIQUE_DESC techDesc; effectTechnique_->GetDesc(&techDesc); for (UINT p = 0; p < techDesc.Passes; ++p) { effectTechnique_->GetPassByIndex(p)->Apply(0, deviceContext_); deviceContext_->DrawIndexed(indexSize, 0, 0); } swapChain_->Present(0, 0); } void D3D11Graphics::getCameraPos(float& rCamera, int& alphaCamera, int& betaCamera) { rCamera = rCamera_; alphaCamera = alphaCamera_ / (PI / 180.0); betaCamera = betaCamera_ / (PI / 180.0); } void D3D11Graphics::setCameraPos(float rCamera, int alphaCamera, int betaCamera) { //Check Beta angle(Degree: -80 <= betaCamera <= 80) if (betaCamera > 80) { betaCamera = 80; } else if (betaCamera < -80) { betaCamera = -80; } //Calculate rCamera_ = rCamera; alphaCamera_ = (double)alphaCamera * (PI / 180.0); betaCamera_ = (double)betaCamera * (PI / 180.0); XMVECTOR cameraPos = XMVectorSet( rCamera_ * cos(betaCamera_) * cos(alphaCamera_), rCamera_ * sin(betaCamera_), rCamera_ * cos(betaCamera_) * sin(alphaCamera_), 1.0f); XMVECTOR focusPoint = XMVectorZero(); XMVECTOR upDirection = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f); XMMATRIX mView = XMMatrixLookAtLH(cameraPos, focusPoint, upDirection); DirectX::XMStoreFloat4x4(&mView_, mView); } void D3D11Graphics::initializeEffect_() { using namespace std; //Read fxo File ifstream fxo; fxo.open("HLSL\\Shader.fxo", ios_base::binary); //If fxo file failed to open if (fxo.fail()) { throw PMD_FailedInitializeEffect(); } fxo.seekg(0, std::ios_base::end); int length = (int)fxo.tellg(); fxo.seekg(0, std::ios_base::beg); vector<char> fxo_binary(length); fxo.read(&fxo_binary[0], length); CheckHR(D3DX11CreateEffectFromMemory(&fxo_binary[0], length, 0, device_, &effect_), PMD_FailedInitializeEffect()); effectTechnique_ = effect_->GetTechniqueByName("Tech"); //Corresponding to Shader.fx } void D3D11Graphics::initializeInputLayout_() { D3D11_INPUT_ELEMENT_DESC inputElementDesc[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; D3DX11_PASS_DESC passDesc; effectTechnique_->GetPassByIndex(0)->GetDesc(&passDesc); CheckHR(device_->CreateInputLayout(inputElementDesc, 2, passDesc.pIAInputSignature, passDesc.IAInputSignatureSize, &inputLayout_), PMD_FailedCreateInputLayout()) //deviceContext_->IASetInputLayout(inputLayout_); } void D3D11Graphics::initializeVertexBuffer_(ObjFileReader* modelFile) { //Define Vertex std::vector<Vertex>* vertex; modelFile->ParseVertex(&vertex); //Create Vertex Buffer D3D11_BUFFER_DESC bufferDesc; bufferDesc.ByteWidth = sizeof(Vertex) * vertex->size(); bufferDesc.Usage = D3D11_USAGE_IMMUTABLE; bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; bufferDesc.CPUAccessFlags = 0; bufferDesc.MiscFlags = 0; bufferDesc.StructureByteStride = 0; D3D11_SUBRESOURCE_DATA subresourceData; subresourceData.pSysMem = &(*vertex)[0]; CheckHR(device_->CreateBuffer(&bufferDesc, &subresourceData, &vertexBuffer_), PMD_FailedCreateBuffer()); ////Bind Vertex Buffer //UINT stride = sizeof(Vertex); //UINT offset = 0; //deviceContext_->IASetVertexBuffers(0, 1, &vertexBuffer_, &stride, &offset); } void D3D11Graphics::initializeIndexBuffer_(ObjFileReader* modelFile) { //Define Index std::vector<UINT>* index; modelFile->ParseIndex(&index); indexSize = index->size(); //Create Index Buffer D3D11_BUFFER_DESC bufferDesc; bufferDesc.ByteWidth = sizeof(UINT) * indexSize; bufferDesc.Usage = D3D11_USAGE_IMMUTABLE; bufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; bufferDesc.CPUAccessFlags = 0; bufferDesc.MiscFlags = 0; bufferDesc.StructureByteStride = 0; D3D11_SUBRESOURCE_DATA subresourceData; subresourceData.pSysMem = &(*index)[0]; CheckHR(device_->CreateBuffer(&bufferDesc, &subresourceData, &indexBuffer_), PMD_FailedCreateBuffer()); ////Bind Index Buffer //deviceContext_->IASetIndexBuffer(indexBuffer_, DXGI_FORMAT_R32_UINT, 0); } void D3D11Graphics::initializeMatrix_() { //World XMMATRIX mIdentity = { 20.0f, 0.0f, 0.0f, 0.0f, 0.0f, 20.0f, 0.0f, 0.0f, 0.0f, 0.0f, 20.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; DirectX::XMStoreFloat4x4(&mWorld_, mIdentity); //View setCameraPos(15, -270, 30); //Projection XMMATRIX mProjection = XMMatrixPerspectiveFovLH(0.25f * PI, windowWidth_ / windowHeight_, 1.0f, 1000.0f); DirectX::XMStoreFloat4x4(&mProjection_, mProjection); ////Calculate Matrix WVP //mWVP_ = XMLoadFloat4x4(&mWorld_) * XMLoadFloat4x4(&mView_) * XMLoadFloat4x4(&mProjection_); }
[ "marklang1993@gmail.com" ]
marklang1993@gmail.com
561d948ae1d67641693c08cad6213c64e1b44c07
62f6522dbbdfed205e30d991e6f9a2e075dd59b7
/opencensus/exporters/stats/stackdriver/internal/stackdriver_e2e_test.cc
aa1975118d10bd09ef1deed1c2904e2087293ef5
[ "Apache-2.0" ]
permissive
kirakira/opencensus-cpp
9d3fd4e703968f5c46a2c592d5169068f0943d7d
9c3ef59ea35d3ae54338d3c07283ceb9ab29b64e
refs/heads/master
2020-05-03T20:47:30.740731
2019-04-05T06:31:59
2019-04-05T06:31:59
178,810,670
0
0
Apache-2.0
2019-04-01T07:39:19
2019-04-01T07:39:19
null
UTF-8
C++
false
false
10,787
cc
// Copyright 2018, OpenCensus Authors // // 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 <cstdlib> #include <iostream> #include <grpcpp/grpcpp.h> #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "absl/time/clock.h" #include "absl/time/time.h" #include "gmock/gmock.h" #include "google/monitoring/v3/common.pb.h" #include "google/monitoring/v3/metric_service.grpc.pb.h" #include "google/protobuf/empty.pb.h" #include "gtest/gtest.h" #include "opencensus/exporters/stats/stackdriver/internal/stackdriver_utils.h" #include "opencensus/exporters/stats/stackdriver/internal/time_series_matcher.h" #include "opencensus/exporters/stats/stackdriver/stackdriver_exporter.h" #include "opencensus/stats/stats.h" namespace opencensus { namespace exporters { namespace stats { namespace { // This is a true end-to-end test for the Stackdriver Exporter, connecting to // production Stackdriver. As such, it is subject to failures in networking or // the Stackdriver backend; it also cannot be run multiple times simultaneously // under the same Cloud project. // // See comments in stackdriver_exporter.h regarding setting up authentication. // Additionally, it requires the environment variable STACKDRIVER_PROJECT_ID to // be set to the project id corresponding to the GOOGLE_APPLICATION_CREDENTIALS, // and for the account specified by the credentials to have the "Monitoring // Viewer" permission. constexpr char kGoogleStackdriverStatsAddress[] = "monitoring.googleapis.com"; constexpr char kTestMeasureName[] = "opencensus.io/TestMeasure"; opencensus::stats::MeasureDouble TestMeasure() { static const opencensus::stats::MeasureDouble foo_usage = opencensus::stats::MeasureDouble::Register( kTestMeasureName, "Test measure.", "1{test units}"); return foo_usage; } class StackdriverE2eTest : public ::testing::Test { protected: static void SetUpTestCase() { TestMeasure(); if (project_id_.empty() || credentials_.empty()) { std::cerr << "STACKDRIVER_PROJECT_ID or GOOGLE_APPLICATION_CREDENTIALS " "unset.\n"; std::abort(); } StackdriverOptions opts; opts.project_id = std::string(project_id_); opts.opencensus_task = "test_task"; StackdriverExporter::Register(opts); } // Retrieves data exported under 'descriptor'. std::vector<google::monitoring::v3::TimeSeries> RetrieveData( const opencensus::stats::ViewDescriptor& descriptor); // Cleans up by deleting the metric the Stackdriver exporter should have // created for 'descriptor'. void DeleteMetric(const opencensus::stats::ViewDescriptor& descriptor); static const absl::string_view project_id_; static const absl::string_view credentials_; // A prefix to add to view names because a newly-created Stackdriver metric // may resurrect data from deleted metrics with the same name. std::string prefix_ = absl::StrCat(absl::ToUnixMillis(absl::Now())); const std::unique_ptr<google::monitoring::v3::MetricService::Stub> stub_ = google::monitoring::v3::MetricService::NewStub(::grpc::CreateChannel( kGoogleStackdriverStatsAddress, ::grpc::GoogleDefaultCredentials())); const opencensus::tags::TagKey key1_ = opencensus::tags::TagKey::Register("key1"); const opencensus::tags::TagKey key2_ = opencensus::tags::TagKey::Register("key2"); }; const absl::string_view StackdriverE2eTest::project_id_ = std::getenv("STACKDRIVER_PROJECT_ID"); const absl::string_view StackdriverE2eTest::credentials_ = std::getenv("GOOGLE_APPLICATION_CREDENTIALS"); std::vector<google::monitoring::v3::TimeSeries> StackdriverE2eTest::RetrieveData( const opencensus::stats::ViewDescriptor& descriptor) { std::vector<google::monitoring::v3::TimeSeries> data; google::monitoring::v3::ListTimeSeriesRequest request; request.set_name(absl::StrCat("projects/", project_id_)); request.set_filter( absl::StrCat("metric.type = \"custom.googleapis.com/opencensus/", descriptor.name(), "\"")); SetTimestamp(absl::Now() - absl::Hours(1), request.mutable_interval()->mutable_start_time()); SetTimestamp(absl::Now() + absl::Hours(1), request.mutable_interval()->mutable_end_time()); while (true) { google::monitoring::v3::ListTimeSeriesResponse response; ::grpc::ClientContext context; ::grpc::Status status = stub_->ListTimeSeries(&context, request, &response); if (!status.ok()) { std::cerr << "ListTimeSeries error: " << status.error_message() << "\n"; // This may mean that the data has not propagated through Stackdriver // yet. std::cout << "Waiting and retrying.\n"; absl::SleepFor(absl::Seconds(5)); continue; } // If there are too many response Stackdriver returns them in multiple // pages. for (const auto& ts : response.time_series()) { data.push_back(ts); } if (response.next_page_token().empty()) { break; } request.set_page_token(response.next_page_token()); } return data; } void StackdriverE2eTest::DeleteMetric( const opencensus::stats::ViewDescriptor& descriptor) { // Remove from the exporter before deleting from Stackdriver so that the // exporter does not recreate it. opencensus::stats::StatsExporter::RemoveView(descriptor.name()); google::monitoring::v3::DeleteMetricDescriptorRequest request; request.set_name( absl::StrCat("projects/", project_id_, "/metricDescriptors/custom.googleapis.com/opencensus/", descriptor.name())); ::grpc::ClientContext context; google::protobuf::Empty response; ::grpc::Status status = stub_->DeleteMetricDescriptor(&context, request, &response); EXPECT_TRUE(status.ok()); } TEST_F(StackdriverE2eTest, OneView) { // Make sure that the simple case works. const auto view_descriptor = opencensus::stats::ViewDescriptor() .set_name(absl::StrCat( "opencensus.io/Test/TestMeasure-sum-cumulative-key1-key2-", prefix_)) .set_measure(kTestMeasureName) .set_aggregation(::opencensus::stats::Aggregation::Sum()) .add_column(key1_) .add_column(key2_) .set_description( "Cumulative sum of opencensus.io/TestMeasure broken down " "by 'key1' and 'key2'."); view_descriptor.RegisterForExport(); opencensus::stats::Record({{TestMeasure(), 1.0}}, {{key1_, "v11"}, {key2_, "v21"}}); opencensus::stats::Record({{TestMeasure(), 2.0}}, {{key1_, "v11"}, {key2_, "v22"}}); std::cout << "Waiting for data to propagate.\n"; absl::SleepFor(absl::Seconds(40)); EXPECT_THAT(RetrieveData(view_descriptor), ::testing::UnorderedElementsAre( testing::TimeSeriesDouble({{"opencensus_task", "test_task"}, {"key1", "v11"}, {"key2", "v21"}}, 1.0), testing::TimeSeriesDouble({{"opencensus_task", "test_task"}, {"key1", "v11"}, {"key2", "v22"}}, 2.0))); DeleteMetric(view_descriptor); } TEST_F(StackdriverE2eTest, LargeTest) { const auto count_descriptor = opencensus::stats::ViewDescriptor() .set_name(absl::StrCat( "opencensus.io/Test/TestMeasure-count-cumulative-key1-key2-", prefix_)) .set_measure(kTestMeasureName) .set_aggregation(::opencensus::stats::Aggregation::Count()) .add_column(key1_) .add_column(key2_) .set_description( "Cumulative count of opencensus.io/TestMeasure broken down " "by 'key1' and 'key2'."); count_descriptor.RegisterForExport(); const auto sum_descriptor = opencensus::stats::ViewDescriptor() .set_name(absl::StrCat( "opencensus.io/Test/TestMeasure-sum-cumulative-key1-key2-", prefix_)) .set_measure(kTestMeasureName) .set_aggregation(::opencensus::stats::Aggregation::Sum()) .add_column(key1_) .add_column(key2_) .set_description( "Cumulative sum of opencensus.io/TestMeasure broken down " "by 'key1' and 'key2'."); sum_descriptor.RegisterForExport(); std::vector<::testing::Matcher<google::monitoring::v3::TimeSeries>> sum_matchers; std::vector<::testing::Matcher<google::monitoring::v3::TimeSeries>> count_matchers; // The number of values to record for each tag--total metric cardinality will // be tag_values^2. We want this high enough that uploads require multiple // batches. const int tag_values = 25; for (int i = 0; i < tag_values; ++i) { for (int j = 0; j < tag_values; ++j) { const std::string tag1 = absl::StrCat("v1", i); const std::string tag2 = absl::StrCat("v1", j); const double value = i * j; opencensus::stats::Record({{TestMeasure(), value}}, {{key1_, tag1}, {key2_, tag2}}); sum_matchers.push_back(testing::TimeSeriesDouble( {{"opencensus_task", "test_task"}, {"key1", tag1}, {"key2", tag2}}, value)); count_matchers.push_back(testing::TimeSeriesInt( {{"opencensus_task", "test_task"}, {"key1", tag1}, {"key2", tag2}}, 1)); } } std::cout << "Waiting for data to propagate.\n"; absl::SleepFor(absl::Seconds(40)); const auto count_data = RetrieveData(count_descriptor); const auto sum_data = RetrieveData(sum_descriptor); ASSERT_EQ(tag_values * tag_values, count_data.size()); ASSERT_EQ(tag_values * tag_values, sum_data.size()); EXPECT_THAT(RetrieveData(count_descriptor), ::testing::UnorderedElementsAreArray(count_matchers)); EXPECT_THAT(RetrieveData(sum_descriptor), ::testing::UnorderedElementsAreArray(sum_matchers)); DeleteMetric(count_descriptor); DeleteMetric(sum_descriptor); } } // namespace } // namespace stats } // namespace exporters } // namespace opencensus
[ "noreply@github.com" ]
noreply@github.com
72bdad6451ecb316c960c11ecd0291213261d382
a7f8177677290aa9bea7b7d4b66c30070c8708e4
/test/synthesis/world/WorldFrameSynthesizerTest.h
3de36f14a8c4379a216f13abac3ae5a08acad0da
[ "BSD-3-Clause" ]
permissive
qtau-devgroup/libstand
a6ea8e0297ec64e8436e3aee3b6b62dd5e643ebe
c6843de9cee6a0695c5168220c64ba2aa3704e52
refs/heads/master
2021-01-22T09:47:55.169144
2014-03-24T15:51:38
2014-03-24T15:58:12
17,595,280
2
0
null
null
null
null
UTF-8
C++
false
false
3,427
h
/* WorldFrameSynthesizerTest.h from libstand http://github.com/qtau-devgroup/libstand by Hal@ShurabaP, BSD license */ #ifndef WORLDFRAMESYNTHESIZERTEST_H #define WORLDFRAMESYNTHESIZERTEST_H #include <QTest> #include "dsp/Signal.h" #include "dsp/world/world_synthesis.h" #include "synthesis/world/WorldFrameSynthesizer.h" #include "AutoTest.h" namespace stand { class WorldFrameSynthesizerTest : public QObject { Q_OBJECT private slots: void synthesize_properly_synthesize_the_same_waveform_that_world_synthesize() { int samplingFrequency = 44100; double f0 = 0; auto frame = QSharedPointer<WorldFrame>(new WorldFrame(2048, samplingFrequency, f0)); Signal signal(samplingFrequency, samplingFrequency); double *spectrum = new double[2048]; double *residual = new double[2048]; for(int i = 0; i < 2048; i++) { spectrum[i] = frame->spectrum.data()[i] = frame->residual.data()[i] = 2048 - i; } // WORLD's residual spectrum is a bit different from FFTSG :P residual[0] = frame->residual.data()[0]; for(int i = 1; i < 1024; i++) { residual[i * 2 - 1] = frame->residual.data()[i * 2]; residual[i * 2] = frame->residual.data()[i * 2 + 1]; } residual[2047] = frame->residual.data()[1]; double *expected = new double[samplingFrequency]; for(int i = 0; i < signal.size(); i++) { expected[i] = signal[i] = 0.0f; } Synthesize(&f0, 1, &spectrum, &residual, 2048, 1.0, samplingFrequency, samplingFrequency, expected); WorldFrameSynthesizer(samplingFrequency).synthesize(signal, frame, 0); for(int i = 0; i < signal.size(); i++) { QCOMPARE(signal[i], (float)expected[i]); } } void synthesize_properly_synthesize_white_spectrum_the_same_waveform_that_world_synthesize() { int samplingFrequency = 44100; double f0 = 0; auto frame = QSharedPointer<WorldFrame>(new WorldFrame(2048, samplingFrequency, f0)); Signal signal(samplingFrequency, samplingFrequency); double *spectrum = new double[2048]; double *residual = new double[2048]; for(int i = 0; i < 2048; i++) { spectrum[i] = 1.0; frame->spectrum.data()[i] = 1.0; frame->residual.data()[i] = (i % 2 == 0) ? 1.0 : 0.0; } frame->residual.data()[1] = 1.0; // WORLD's residual spectrum is a bit different from FFTSG :P residual[0] = frame->residual.data()[0]; for(int i = 1; i < 1024; i++) { residual[i * 2 - 1] = frame->residual.data()[i * 2]; residual[i * 2] = frame->residual.data()[i * 2 + 1]; } residual[2047] = frame->residual.data()[1]; double *expected = new double[samplingFrequency]; for(int i = 0; i < signal.size(); i++) { expected[i] = signal[i] = 0.0f; } Synthesize(&f0, 1, &spectrum, &residual, 2048, 1.0, samplingFrequency, samplingFrequency, expected); WorldFrameSynthesizer(samplingFrequency).synthesize(signal, frame, 0); for(int i = 0; i < signal.size(); i++) { QCOMPARE(signal[i], (float)expected[i]); } } }; } DECLARE_TEST(stand::WorldFrameSynthesizerTest) #endif // WORLDFRAMESYNTHESIZERTEST_H
[ "harunyann@hotmail.com" ]
harunyann@hotmail.com
fcede523f78108fdba51cf0dcae04dcdd4ed064b
0b69a011c9ffee099841c140be95ed93c704fb07
/problemsets/Brazil/URI/URI ONLINE/1044.cpp
5f8707fbb7a43a9fb7b4828ed1a3703976de00d8
[ "Apache-2.0" ]
permissive
juarezpaulino/coderemite
4bd03f4f2780eb6013f07c396ba16aa7dbbceea8
a4649d3f3a89d234457032d14a6646b3af339ac1
refs/heads/main
2023-01-31T11:35:19.779668
2020-12-18T01:33:46
2020-12-18T01:33:46
320,931,351
0
0
null
null
null
null
UTF-8
C++
false
false
295
cpp
/** * * Author: Juarez Paulino(coderemite) * Email: juarez.paulino@gmail.com * */ #include <cstdio> using namespace std; int main() { int a, b; scanf("%d%d", &a, &b); if (a%b==0 || b%a==0) printf("Sao Multiplos\n"); else printf("Nao sao Multiplos\n"); return 0; }
[ "juarez.paulino@gmail.com" ]
juarez.paulino@gmail.com
bbaa75851d8208e7a23625a789691a7f29b8b08c
0dea1e0728d1b3a79d7965ad5b58d322b86504eb
/source/BeEngine/Cursor.h
b0218f9cfbc241cabb62333bec95478cdec95ec0
[ "MIT" ]
permissive
Guillemsc/BeEngine-2D
500e585aee24e56ce105b9a2b8d32812fe827d11
e92801d5cd8c5e51953cbb54c58f775dace5d40d
refs/heads/master
2022-06-17T01:49:17.495795
2022-05-18T15:27:36
2022-05-18T15:27:36
150,258,664
16
2
null
null
null
null
UTF-8
C++
false
false
803
h
#ifndef __CURSOR_H__ #define __CURSOR_H__ #include "SDL\include\SDL.h" class Cursor { public: Cursor(); ~Cursor(); void Arrow(); void Ibeam(); void Wait(); void Crosshair(); void SizeNWSE(); void SizeNESW(); void SizeWE(); void SizeNS(); void SizeAll(); void Hand(); void SetShowCursor(bool set); void SetCurrentCursor(); void CleanUp(); private: SDL_Cursor* arrow = nullptr; SDL_Cursor* ibeam = nullptr; SDL_Cursor* wait = nullptr; SDL_Cursor* crosshair = nullptr; SDL_Cursor* sizenwse = nullptr; SDL_Cursor* sizenesw = nullptr; SDL_Cursor* sizewe = nullptr; SDL_Cursor* sizens = nullptr; SDL_Cursor* sizeall = nullptr; SDL_Cursor* hand = nullptr; SDL_Cursor* cursor_to_set = nullptr; SDL_Cursor* current_cursor = nullptr; bool show = true; }; #endif //__CURSOR_H__
[ "gsunyercaldu@gmail.com" ]
gsunyercaldu@gmail.com
bad2091879509aa15c99a23161e2bef216cb5518
287958d43421c0c5aba25137ddc1a60cc0e156ab
/homebrewing/temperature-controller-firmware/Config.h
48168f588b752ac5d242f508efda7e7bec4cfbbd
[ "MIT" ]
permissive
tjdistler/dev
433e2f02c113c8e69d4de8281f916ff1ec34e63c
8972ff6ffa16a0cf2fce86023fde3b9d334bd995
refs/heads/master
2023-08-03T06:24:53.554759
2023-07-28T15:49:22
2023-07-28T15:49:22
163,696,741
1
0
null
null
null
null
UTF-8
C++
false
false
3,859
h
#ifndef _CONFIG_H_ #define _CONFIG_H_ #include "Common.h" // A class for managing the configuration data, including load/store. class Config { typedef struct { Temperature setpoint; Temperature tolerance; unsigned long asc; // ms Temperature offsets[2]; unsigned char ledLevel; // 0-100 bool heatEnabled; bool coolEnabled; float Kp; float Ki; float Kd; bool autoAdjustEnabled; Temperature autoSetpoint; unsigned long autoTimePeriod; // sec unsigned long autoAdjustStartTS; // sec } config_t; public: Config(); Config( const Temperature setpoint, const Temperature tolerance, const unsigned long ascMs, const Temperature offset0, const Temperature offset1, const unsigned char ledLevel, const bool heatEnabled, const bool coolEnabled, const float Kp, const float Ki, const float Kd, const bool autoAdjustEnabled, const Temperature autoSetpoint, const unsigned long autoTimePeriod, const unsigned long autoAdjustStartTS); Config& operator=(const Config& other) { memcpy(&_config, &other._config, sizeof(_config)); _version = other._version; return *this; } void load(); // Load values from flash void store(); // Save values to flash unsigned long version() const { return _version; } Temperature getSetpoint() const { return _config.setpoint; } void setSetpoint(Temperature value) { ++_version; _config.setpoint = value; } Temperature getTolerance() const { return _config.tolerance; } void setTolerance(Temperature value) { ++_version; _config.tolerance = value; } unsigned long getAsc() const { return _config.asc; } void setAsc(unsigned long value) { ++_version; _config.asc = value; } Temperature getProbeOffset(size_t index) const { return _config.offsets[index]; } void setProbeOffset(size_t index, Temperature value) { ++_version; _config.offsets[index] = value; } unsigned char getLEDLevel() const { return _config.ledLevel; } void setLEDLevel(unsigned char level) { ++_version; _config.ledLevel = level; } bool getHeatEnabled() const { return _config.heatEnabled; } void setHeatEnabled(bool enabled) { ++_version; _config.heatEnabled = enabled; } bool getCoolEnabled() const { return _config.coolEnabled; } void setCoolEnabled(bool enabled) { ++_version; _config.coolEnabled = enabled; } float getPidKp() const { return _config.Kp; } void setPidKp(float value) { ++_version; _config.Kp = value; } float getPidKi() const { return _config.Ki; } void setPidKi(float value) { ++_version; _config.Ki = value; } float getPidKd() const { return _config.Kd; } void setPidKd(float value) { ++_version; _config.Kd = value; } bool getAutoAdjustEnabled() const { return _config.autoAdjustEnabled; } void setAutoAdjustEnabled(bool enabled) { ++_version; _config.autoAdjustEnabled = enabled; } Temperature getAutoSetpoint() const { return _config.autoSetpoint; } void setAutoSetpoint(Temperature value) { ++_version; _config.autoSetpoint = value; } unsigned long getAutoTimePeriod() const { return _config.autoTimePeriod; } void setAutoTimePeriod(unsigned long value) { ++_version; _config.autoTimePeriod = value; } unsigned long getAutoAdjustStartTS() const { return _config.autoAdjustStartTS; } void setAutoAdjustStartTS(unsigned long value) { ++_version; _config.autoAdjustStartTS = value; } private: config_t _config; unsigned long _version; // incremented on every update. }; #endif
[ "tom.distler@gmail.com" ]
tom.distler@gmail.com
70ff997df44ff4c82edf28a3ce6ef4524caa4b08
cf5132204d62719a7d322d1e8f62083e73946299
/shangcoin/src/common/download.h
18181a88283b7451b1fb2ecea81d5bb8dc97834c
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
shangproject/shangcoin-wallet-gui
f820857341854d18a1c91b4b4207869bee4072b9
9c9fc35735016b8389ac9451b40dbef10e4ce085
refs/heads/master
2020-03-10T08:09:04.088771
2018-04-13T08:49:49
2018-04-13T08:49:49
129,278,819
0
0
null
null
null
null
UTF-8
C++
false
false
2,393
h
// Copyright (c) 2017, The Shangcoin Project // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include <string> namespace tools { struct download_thread_control; typedef std::shared_ptr<download_thread_control> download_async_handle; bool download(const std::string &path, const std::string &url, std::function<bool(const std::string&, const std::string&, size_t, ssize_t)> progress = NULL); download_async_handle download_async(const std::string &path, const std::string &url, std::function<void(const std::string&, const std::string&, bool)> result, std::function<bool(const std::string&, const std::string&, size_t, ssize_t)> progress = NULL); bool download_error(const download_async_handle &h); bool download_finished(const download_async_handle &h); bool download_wait(const download_async_handle &h); bool download_cancel(const download_async_handle &h); }
[ "shang@gmail.com" ]
shang@gmail.com
af3ac8cd967c0a53cc38a2485d385badaa534763
d61e718eb470faef3f422280f825127729cac901
/Template/Template of Other Teams/NewMeta-Final/2 Graph/8 Hopcroft.cpp
aec89842cf98b2f91c3937488350b3bafa07c65a
[]
no_license
sjtu-imperishable-night/code-library
737e871ad5287fd52a596902b32f07ce56563a78
0818f507c76b534f9144ed9b64bc138c37b30c5e
refs/heads/master
2020-06-24T15:43:25.051083
2020-04-27T11:43:26
2020-04-27T11:43:26
199,004,542
1
3
null
null
null
null
UTF-8
C++
false
false
867
cpp
// 左侧 N 个点, 右侧 K 个点 , 1-based, 初始化将 matx[],maty[] 都置为 0 int N, K, que[N], dx[N], dy[N], matx[N], maty[N]; int BFS() { int flag = 0, qt = 0, qh = 0; for(int i = 1; i <= K; ++ i) dy[i] = 0; for(int i = 1; i <= N; ++ i) { dx[i] = 0; if (! matx[i]) que[qt ++] = i; } while (qh < qt) { int u = que[qh ++]; for(Edge *e = E[u]; e; e = e->n) if (! dy[e->t]) { dy[e->t] = dx[u] + 1; if (! maty[e->t]) flag = true; else { dx[maty[e->t]] = dx[u] + 2; que[qt ++] = maty[e->t]; } } } return flag; } int DFS(int u) { for(Edge *e = E[u]; e; e = e->n) if (dy[e->t] == dx[u] + 1) { dy[e->t] = 0; if (! maty[e->t] || DFS(maty[e->t])) { matx[u] = e->t; maty[e->t] = u; return true; } } return false; } void Hopcroft() { while (BFS()) for(int i = 1; i <= N; ++ i) if (! matx[i]) DFS(i); }
[ "beijingsunsiyu@126.com" ]
beijingsunsiyu@126.com
a761dc6973fca17ad2164a46bf28093bfc9c79a1
90e6ad841f0b7388bdae1e901ba10d17fa10d296
/Solved Tests/teste1_16_17/Mail.cpp
4d9542f4dfbab69bb47a5b19785f0275f6cec7f3
[]
no_license
GambuzX/MIEIC_aeda
76cdeeab32abbc072b8bfb919f1ecbde98aad0a3
6e61710af090667cbc60796b38661666181ac26e
refs/heads/master
2020-03-29T19:11:20.476777
2019-01-28T11:30:49
2019-01-28T11:30:49
150,252,024
0
0
null
null
null
null
UTF-8
C++
false
false
771
cpp
/* * Mail.cpp */ #include "Mail.h" Mail::Mail(string send, string rec, string zcode): sender(send),receiver(rec), zipCode(zcode) { } Mail::~Mail() { } string Mail::getZipCode() const { return zipCode; } RegularMail::RegularMail(string send, string rec, string zcode, unsigned int w): Mail(send, rec, zcode), weight(w) { } unsigned RegularMail::getPrice() const { if (weight <= 20) return 50; else if (weight <= 100) return 75; else if (weight <= 500) return 140; else return 325; return 0; } GreenMail::GreenMail(string send, string rec, string zcode, string t): Mail(send, rec, zcode), type(t) { } unsigned GreenMail::getPrice() const { if (type == "envelope") return 80; else if (type == "bag") return 200; else return 240; return 0; }
[ "mg_mesquita@hotmail.com" ]
mg_mesquita@hotmail.com
8d387a13cfc4e23b7e19abb941b33c6392607da2
1e29330fbf4d53cf5dfac6f0290f660647109da7
/yss/inc/mod/tft/RK043FN48H.h
20079b570d1e30b7d5041d545c8eb71eb9c748d6
[]
no_license
bluelife85/yss
2c9807bba61723a6fa578f80edadd9e8d6f9d1a9
1ada1bcc8579bf17e53d6f31525960703ef2f6b9
refs/heads/master
2023-01-16T02:12:26.099052
2020-11-26T01:18:43
2020-11-26T01:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,582
h
//////////////////////////////////////////////////////////////////////////////////////// // // 저작권 표기 License_ver_2.0 // 본 소스코드의 소유권은 yss Embedded Operating System 네이버 카페 관리자와 운영진에게 있습니다. // 운영진이 임의로 코드의 권한을 타인에게 양도할 수 없습니다. // 본 소스코드는 아래 사항에 동의할 경우에 사용 가능합니다. // 아래 사항에 대해 동의하지 않거나 이해하지 못했을 경우 사용을 금합니다. // 본 소스코드를 사용하였다면 아래 사항을 모두 동의하는 것으로 자동 간주 합니다. // 본 소스코드의 상업적 또는 비상업적 이용이 가능합니다. // 본 소스코드의 내용을 임의로 수정하여 재배포하는 행위를 금합니다. // 본 소스코드의 내용을 무단 전재하는 행위를 금합니다. // 본 소스코드의 사용으로 인해 발생하는 모든 사고에 대해서 어떤한 법적 책임을 지지 않습니다. // // Home Page : http://cafe.naver.com/yssoperatingsystem // Copyright 2020. yss Embedded Operating System all right reserved. // // 주담당자 : 아이구 (mymy49@nate.com) 2016.04.30 ~ 현재 // 부담당자 : - // //////////////////////////////////////////////////////////////////////////////////////// #ifndef YSS_MOD_TFT_RK043FN48H__H_ #define YSS_MOD_TFT_RK043FN48H__H_ #include <drv/peripherals.h> namespace mod { namespace tft { class RK043FN48H { public : void init(void); config::ltdc::Config* getConfig(void); }; } } #endif
[ "mymy49@nate.com" ]
mymy49@nate.com
8c69777f69435aec23e7a58646a98bbff7363cb9
bcd810a6908f1d9cbf686d8f7b0312c7d5410b57
/client/test/writedir.cpp
8a919f4b2d72e35d5e14dd551027ea5081617c0e
[]
no_license
qingdy/SURDFS
a1f7e6ec27d0c507aeaf459c91d705591f740235
1b2f9da4e7aff64bb231ef8e387b5c8df552148f
refs/heads/master
2016-09-11T03:33:03.418177
2013-09-05T02:00:49
2013-09-05T02:00:49
12,606,667
0
1
null
null
null
null
UTF-8
C++
false
false
4,807
cpp
#include <stdlib.h> #include <stdint.h> #include <fcntl.h> #include <stdio.h> #include <time.h> #include <dirent.h> #include <errno.h> #include <limits.h> #include "time_util.h" #include "log.h" #include "bladestore_ops.h" #include "blade_common_define.h" #include "blade_file_info.h" #include "client.h" #ifdef PATH_MAX static int pathmax = PATH_MAX; #else static int pathmax = 0; #endif #define SUSV3 200112L static long posix_version = 0; #define PATH_MAX_GUESS 1024 using namespace pandora; using namespace bladestore::client; using namespace bladestore::common; using namespace bladestore::message; static char *fullpath; string sourcepath; string destpath; Client *client = NULL; char *path_alloc(int *sizep) { char *ptr; int size; if (posix_version == 0) posix_version = sysconf(_SC_VERSION); if (pathmax == 0) { errno = 0; if ((pathmax = pathconf("/", _PC_PATH_MAX)) < 0) { if (errno == 0) { pathmax = PATH_MAX_GUESS; } else { printf("pathconf error for _PC_PATH_MAX.\n"); return NULL; } } else { ++pathmax; } } if (posix_version < SUSV3) size = pathmax + 1; else size = pathmax; if ((ptr = (char *)malloc(size)) == NULL) { printf("malloc error for pathname.\n"); return NULL; } if (sizep != NULL) *sizep = size; return (ptr); } int32_t writefiles(void *buf, int8_t issafewrite, int32_t buffersize) { int64_t localfid = open(fullpath, O_RDONLY); // Create a file char * tmp = fullpath + sourcepath.size(); string filename = destpath + tmp; int64_t fid = client->Create(filename, issafewrite, 3); LOGV(LL_INFO, "File created, filepath: %s, ID: %ld.", filename.c_str(), fid); if (fid < 0) { LOGV(LL_ERROR, "Create file error."); return -1; } int64_t alreadyread = 0; int64_t readlocallen = 0; do { readlocallen = read(localfid, buf, buffersize); if (readlocallen < 0) { LOGV(LL_ERROR, "read local file error."); return -1; } else if (readlocallen == 0) { break; } int64_t writelen = client->Write(fid, buf, readlocallen); if (writelen < 0) { LOGV(LL_ERROR, "error in write"); return -1; } alreadyread += writelen; } while (readlocallen > 0); client->Close(fid); close(localfid); return 0; } int dopath(void *buf, int8_t issafewrite, int32_t buffersize) { struct stat statbuf; struct dirent *dirp; DIR *dp; int ret; char *ptr; if (lstat(fullpath, &statbuf) < 0) return -1; if (S_ISDIR(statbuf.st_mode) == 0) { int writeret = writefiles(buf, issafewrite, buffersize); return writeret; } char * tmp = fullpath + sourcepath.size(); string dirname = destpath + tmp; int mkdirret = client->MakeDirectory(dirname); if (mkdirret != BLADE_SUCCESS && mkdirret != -RET_DIR_EXIST) { LOGV(LL_ERROR, "Makedirectory %s error.", dirname.c_str()); return -1; } ptr = fullpath + strlen(fullpath); *ptr++ = '/'; *ptr = 0; if ((dp = opendir(fullpath)) == NULL) return -1; while ((dirp = readdir(dp)) != NULL) { LOGV(LL_INFO, "the file name: %s .", dirp->d_name); if (strcmp(dirp->d_name, ".") == 0 || strcmp(dirp->d_name, "..") == 0) continue; strcpy(ptr, dirp->d_name); if ((ret = dopath(buf, issafewrite, buffersize)) != 0) break; } ptr[-1] = 0; if (closedir(dp) < 0) return -1; return ret; } int main (int argc, char **argv) { if (argc != 4) { printf("%s issafewrite sourcepath destpath (0 for write, 1 for safewrite)\n", argv[0]); return -1; } client = new Client(); int initret = client->Init(); if (BLADE_ERROR == initret) abort(); int32_t issafewrite = atoi(argv[1]); int32_t buffersize = 1048600; char *buf = (char *)malloc(buffersize); int len; fullpath = path_alloc(&len); sourcepath = argv[2]; destpath = argv[3]; //int mkdirret = client->MakeDirectory(destpath); //if (mkdirret != BLADE_SUCCESS && mkdirret != -RET_DIR_EXIST) { // LOGV(LL_ERROR, "Makedirectory destpath %s error.", destpath.c_str()); // return -1; //} strncpy(fullpath, sourcepath.c_str(), len); fullpath[len - 1] = 0; LOGV(LL_INFO, "fullpath: %s, sourcepath: %s, destpath: %s", fullpath, sourcepath.c_str(), destpath.c_str()); dopath(buf, issafewrite, buffersize); free(buf); delete client; }
[ "hustlijian@gmail.com" ]
hustlijian@gmail.com
4b2963f39e56c5cf4178afb7832846821f73f522
f0ef4dd2ecc31eb9fbbe708bb6509459af2d2458
/bigdata3/main.cpp
40e53dd681b75599d07d8ba820a98af288769b8f
[]
no_license
1970633640/program
10d961229246e6a518268cff6c034c2d1e85b4ec
b86df8515f26f34d1dfde321ac32d0bc68674a16
refs/heads/master
2020-12-25T16:47:43.896795
2017-04-12T10:18:11
2017-04-12T10:18:11
67,464,913
0
0
null
null
null
null
UTF-8
C++
false
false
2,176
cpp
#include <iostream> #include <stdio.h> #include <cstring> #include<windows.h> #include <fstream> using namespace std; string query[30]; //允许最大关键词=30 char cquery[30][15]; //char版查询词 int querysum=-1; //从零开始 #define filesum 101710//元素总数钦定0~101710 const int MAXN = 20000;//钦定文件最大20000字节 //#define filesum 1000 int ans[30][filesum]; char fname[48];//小文件名字 typedef struct node { // char astr[15]; int times; int filenum; }node; int ansfindsum; int len;//小文件长度 node ansnode[30][30000]; int cmp(const void * a,const void * b) { if( (*(node *)b).times != (*(node *)a).times ) return (*(node *)b).times - (*(node *)a).times; else return (*(node *)a).filenum-(*(node *)b).filenum; } int main() { ifstream qin; qin.open("query_task3.txt"); string x; while(qin>>x) { query[++querysum]=x; strcpy(cquery[querysum],query[querysum].c_str()); } //cout<<"all-1="<<querysum; memset(ans,0,sizeof(ans)); FILE* fin; //char* buf=new char[MAXN];//文件所有字符 char com[30]; for(int i=0; i<=filesum; ++i) { if(i%10000==0)printf("%d\n",i); sprintf(fname,"D:\\program\\bigdata\\processed\\report%d.xml",i); // printf("%s\n",fname); fin=fopen(fname,"rb"); if(fin==NULL) printf("NULL\n"); while(!feof(fin)) { fscanf(fin,"%s",com); for(int j=0; j<=querysum; ++j) //j=0-29 if( strcmp( com,cquery[j] )==0 ) { ++ans[j][i]; } } fclose(fin); } int sum2; ofstream fout; fout.open("Task3.txt"); int i,j; for(i=0; i<=querysum; ++i) {sum2=-1; for( j=0; j<=filesum; ++j) if(ans[i][j]){ansnode[i][++sum2].times=ans[i][j];ansnode[i][sum2].filenum=j; } qsort(ansnode[i],sum2+1,sizeof(ansnode[i][0]),cmp); int sum1=0; for(int k=0;k<=sum2;++k) fout<<i+1<<" report" <<ansnode[i][k].filenum<<".xml "<<++sum1<<" "<<query[i]<<endl; } fout.close(); //delete []buf; return 0; }
[ "q1970633640@gmail.com" ]
q1970633640@gmail.com
4d2ec81cdf0d9f008d899e4e14069095e6041117
da7335c593f89aed158bd0717ce64daf8bff657e
/src/alg.cpp
9eda06c479d7f087ca5e5d3022c26d43ce63383b
[]
no_license
brothergod1/ADS-2
b82605d27dc36e9eb97f53dd54d883212e550ad2
3b47c457cd5533a4ab3fbbb0db16b0bf4857c677
refs/heads/master
2021-05-26T10:25:50.834352
2020-04-09T11:27:28
2020-04-09T11:27:28
254,095,987
0
0
null
2020-04-08T13:29:59
2020-04-08T13:29:58
null
UTF-8
C++
false
false
1,449
cpp
int countPairs1(int* arr, int len, int value) { int l = 0; for (int i = 0; i <= len; i++) { for (int j = 0; j <= len; j++) { if (arr[i] + arr[j] == value) l++; } } return l; } int countPairs2(int* arr, int len, int value) { int l = 0; for (int i = 0; i <=( len / 2); i++) { for (int j = len-1; j > (len / 2)-1; j--) { if (arr[i] + arr[j] == value) l++; } } return l; } int countPairs3(int* arr, int len, int value) { int l = 0; int mid = 0; for (int i = 0; i <= len; i++) { int lx = len, rx = len; int left = i + 1; int right = len - 1; bool f = 0; while (left <= right) { mid = (left + right) / 2; if (arr[mid] == value - arr[i]) f = 1; if (arr[mid] > value - arr[i]) { lx = mid; right = mid - 1; } else { left = mid + 1; } } left = i + 1; right = len - 1; while (left <= right) { mid = (left + right) / 2; if (arr[mid] == value - arr[i]) f = 1; if (arr[mid] >= value - arr[i]) { rx = mid; right = mid - 1; } else left = mid + 1; } if (f) l += (lx - rx); } return l; }
[ "noreply@github.com" ]
noreply@github.com
e775fafb855eb67dfc34b927ab57c2818d350f18
b7a371228cb5563e850c4919cc4b70ee3e4e8632
/src/OvSPM.cpp
e5555bf783c76f484305d3905419c1c7cb5b16cc
[]
no_license
felsamps/overlap-spm-sim
d10d848c38da97b9a3d7f012676a0881a62fa635
5dc732bea7cd01827aae96509331faf3ae9af060
refs/heads/master
2020-05-30T03:04:51.860809
2015-12-23T15:00:04
2015-12-23T15:00:04
12,274,341
1
1
null
null
null
null
UTF-8
C++
false
false
6,813
cpp
#include <set> #include "../inc/OvSPM.h" OvSPM::OvSPM(Int length, Int thickness, Int center, Int numOfCores) { this->ovThicknessInBU = ceil((double)thickness / BU_SIZE); this->ovLengthInBU = ceil((double)length / BU_SIZE); this->numOfCores = numOfCores; this->powerMap = new PowerState* [ovLengthInBU]; this->statMap = new Int* [ovLengthInBU]; this->coreMap = new bool** [ovLengthInBU]; for (int i = 0; i < ovLengthInBU; i++) { this->powerMap[i] = new PowerState[ovThicknessInBU]; this->statMap[i] = new Int[ovThicknessInBU]; this->coreMap[i] = new bool* [ovThicknessInBU]; for (int t = 0; t < this->ovThicknessInBU; t++) { this->coreMap[i][t] = new bool[this->numOfCores]; } } this->ovPred = new OverlapPredictor(length, center); cout << "Overlap SPM Created: " << center << " " << this->ovLengthInBU << " " << this->ovThicknessInBU << endl; this->readAcum = 0; this->writeAcum = 0; this->acumS0 = 0; this->acumS1 = 0; this->acumS2 = 0; this->acumS3 = 0; this->acumW03 = 0; this->acumW13 = 0; this->acumW23 = 0; this->stateSet.resize(4); this->acumTimeInstant = 0; } void OvSPM::reset() { this->usage = 0; } void OvSPM::initPowerStates() { for (int l = 0; l < this->ovLengthInBU; l++) { for (int t = 0; t < this->ovThicknessInBU; t++) { if(t < this->ovPred->getActualOvThicknessInBU()) { xUpdatePowerState(make_pair<Int,Int>(l,t)); } else { this->stateSet[this->powerMap[l][t]].erase(make_pair<Int,Int>(l,t)); this->powerMap[l][t] = S0; this->stateSet[S0].insert(make_pair<Int,Int>(l,t)); } this->statMap[l][t] = 0; for (int c = 0; c < numOfCores; c++) { this->coreMap[l][t][c] = false; } } } } void OvSPM::managePowerStatesHor(vector<bool**> priv, Int** ovMap) { for (int l = 0; l < this->ovLengthInBU; l++) { for (int t = 0; t < this->ovPred->getActualOvThicknessInBU(); t++) { Int tBU = t + this->ovPred->getDispA(); Int lBU = l; bool limitsFlag = false; for (int c = 0; c < priv.size(); c++) { if(priv[c][lBU][tBU]) { limitsFlag = true; break; } } if(!limitsFlag) { //no search window intersects the corresponding overlap position PowerState toBeAssigned; pair<Int,Int> p(l,t); //TODO review it toBeAssigned = (ovMap[l][t] >= 2) ? S2 : S1; this->stateSet[this->powerMap[l][t]].erase(p); this->stateSet[toBeAssigned].insert(p); this->powerMap[l][t] = toBeAssigned; } } } } void OvSPM::managePowerStatesVer(vector<bool**> priv, Int** ovMap) { for (int l = 0; l < this->ovLengthInBU; l++) { for (int t = 0; t < this->ovPred->getActualOvThicknessInBU(); t++) { Int tBU = t + this->ovPred->getDispA(); Int lBU = l; bool limitsFlag = false; for (int c = 0; c < priv.size(); c++) { if(priv[c][tBU][lBU]) { limitsFlag = true; break; } } if(!limitsFlag) { //no search window intersects the corresponding overlap position PowerState toBeAssigned; pair<Int,Int> p(l,t); //TODO review it toBeAssigned = (ovMap[t][l] >= 2) ? S2 : S1; this->stateSet[this->powerMap[l][t]].erase(p); this->stateSet[toBeAssigned].insert(p); this->powerMap[l][t] = toBeAssigned; } } } } void OvSPM::xUpdatePowerState(pair<Int,Int> acc) { Int lPos = acc.first; Int tPos = acc.second; switch(this->powerMap[lPos][tPos]) { case S0: this->acumW03 += 1; this->stateSet[S0].erase(acc); this->stateSet[S3].insert(acc); break; case S1: this->acumW13 += 1; this->stateSet[S1].erase(acc); this->stateSet[S3].insert(acc); break; case S2: this->acumW23 += 1; this->stateSet[S2].erase(acc); this->stateSet[S3].insert(acc); break; case S3: break; } this->powerMap[lPos][tPos] = S3; } void OvSPM::updatePowerCounters() { this->acumS0 += this->stateSet[S0].size(); this->acumS1 += this->stateSet[S1].size(); this->acumS2 += this->stateSet[S2].size(); this->acumS3 += this->stateSet[S3].size(); this->acumTimeInstant += 1; } SPMStatus OvSPM::read(Int lBU, Int tBU, Int reqCore) { if(lBU >=0 and lBU < this->ovLengthInBU) { Int tPos = tBU - this->ovPred->getDispA(); Int lPos = lBU; SPMStatus returnable = (statMap[lPos][tPos] == 0) ? MISS : HIT; if(returnable == HIT) { this->statMap[lPos][tPos] += 1; this->readAcum += BU_SIZE*BU_SIZE; } //this->coreMap[lPos][tPos][reqCore] = true; xUpdatePowerState(make_pair<int,int>(lPos, tPos)); updatePowerCounters(); return returnable; } } void OvSPM::write(Int lBU, Int tBU) { for (int t = 0; t < this->ovPred->getActualOvThicknessInBU(); t++) { statMap[lBU][t] += 1; powerMap[lBU][t] = S3; this->writeAcum += BU_SIZE*BU_SIZE; } } void OvSPM::updateOverlapUsage() { this->usage = 0; for (int l = 0; l < this->ovLengthInBU; l++) { for (int t = 0; t < this->ovThicknessInBU; t++) { Int acum = 0; for (int i = 0; i < this->numOfCores; i++) { acum += (this->coreMap[l][t][i]) ? 1 : 0; } this->usage += (acum > 1) ? BU_SIZE*BU_SIZE : 0; } } this->ovPred->insertOverlapUsage(this->usage); cout << "USAGE " << this->usage << " " << (this->usage)/(double)(this->ovLengthInBU*this->ovThicknessInBU*BU_SIZE*BU_SIZE) << endl; } OverlapPredictor* OvSPM::getOvPred() const { return ovPred; } Int OvSPM::getUsage() const { return usage; } long long int OvSPM::getWriteAcum() const { return writeAcum; } long long int OvSPM::getReadAcum() const { return readAcum; } Int OvSPM::getOvLengthInBU() const { return ovLengthInBU; } Int OvSPM::getOvThicknessInBU() const { return ovThicknessInBU; } void OvSPM::report() { cout << "OvSPM Report!" << endl; cout << "S0 " << this->acumS0 << endl; cout << "S1 " << this->acumS1 << endl; cout << "S2 " << this->acumS2 << endl; cout << "S3 " << this->acumS3 << endl; cout << "W03 " << this->acumW03 << endl; cout << "W23 " << this->acumW23 << endl; cout << "W13 " << this->acumW13 << endl; } pair<double,double> OvSPM::reportPower() { report(); double energyWOPG = this->acumTimeInstant * this->ovThicknessInBU * this->ovLengthInBU * E_S3; //always in FULL VDD double energyWithPG = this->acumS0 * E_S0 + this->acumS1 * E_S1 + this->acumS2 * E_S2 + this->acumS3 * E_S3 + this->acumW03 * E_W03 + this->acumW13 * E_W13 + this->acumW23 * E_W23; double savings = (energyWOPG-energyWithPG) / energyWOPG; cout << "E(WO PG) " << energyWOPG << endl; cout << "E(With PG) " << energyWithPG << endl; cout << "SAVINGS " << savings << endl; return make_pair<double,double>(energyWOPG, energyWithPG); } void OvSPM::reportPowerStates() { cerr << this->stateSet[S0].size() << " "; cerr << this->stateSet[S1].size() << " "; cerr << this->stateSet[S2].size() << " "; cerr << this->stateSet[S3].size() << endl; }
[ "felipe.sampaio@inf.ufrgs.br" ]
felipe.sampaio@inf.ufrgs.br
ec5687770c2a70c450a18c633d68012f5bea2bcd
194040334f12882c20fc229a86e604e9ea628848
/application/camera_sobel/host/src/screen.cpp
5eeb08aa638d1ea15056cf20858fcac3b276aa00
[ "Apache-2.0" ]
permissive
amdanger/c5soc_opencl
49cfacef70a98502308e337b4b0dba89b3151b41
4b1ca28e40fbc3ef8e81f26b3a1b07fc4f375229
refs/heads/master
2023-01-08T20:44:19.766737
2020-11-07T16:46:57
2020-11-07T16:46:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,420
cpp
#include <stdio.h> #include <assert.h> #include <iostream> #include <algorithm> #include <stdlib.h> #include <string.h> #include "screen.h" #include "opt.h" #include "video.h" #include "color.h" #include <SDL2/SDL.h> extern struct options opt; extern struct video video; extern unsigned int *host_output; extern unsigned short *host_input; extern unsigned int thresh; struct screen screen; static void sdl_init(); static void create_rgb_surface(); static void update_rgb_surface(int index); static void update_rgb_pixels(const void *start); static void keyboardPressEvent(SDL_Event *event); static void sdl_init() { // Initialize. if(SDL_Init(SDL_INIT_VIDEO) != 0) { std::cerr << "Error: Could not initialize SDL: " << SDL_GetError() << "\n"; } // Create the window. screen.theWindow = SDL_CreateWindow("YUYV to RGB", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen.width, screen.height, 0); if(screen.theWindow == NULL) { std::cerr << "Error: Could not create SDL window: " << SDL_GetError() << "\n"; } // Get the window's surface. screen.theWindowSurface = SDL_GetWindowSurface( screen.theWindow); if(screen.theWindowSurface == NULL) { std::cerr << "Error: Could not get SDL window surface: " << SDL_GetError() << "\n"; } } static void create_rgb_surface() { screen.rgb.rmask = 0x000000ff; screen.rgb.gmask = 0x0000ff00; screen.rgb.bmask = 0x00ff0000; screen.rgb.amask = 0xff000000; screen.rgb.width = screen.width; screen.rgb.height = screen.height; screen.rgb.bpp = screen.bpp; screen.rgb.pitch = screen.width * 4; screen.rgb.pixels_num = screen.width * screen.height; screen.rgb.pixels = (unsigned int *)malloc(sizeof(unsigned int)*screen.rgb.pixels_num); memset(screen.rgb.pixels, 0, screen.rgb.pixels_num); screen.rgb.surface = SDL_CreateRGBSurfaceFrom(host_output, screen.rgb.width, screen.rgb.height, screen.rgb.bpp, screen.rgb.pitch, screen.rgb.rmask, screen.rgb.gmask, screen.rgb.bmask, screen.rgb.amask); screen.rgb.surface_sw = SDL_CreateRGBSurfaceFrom(screen.rgb.pixels, screen.rgb.width, screen.rgb.height, screen.rgb.bpp, screen.rgb.pitch, screen.rgb.rmask, screen.rgb.gmask, screen.rgb.bmask, screen.rgb.amask); } int saveVideo(char* fileName, char* pData, int dataLen) { //open file. FILE* fp = fopen(fileName, "a+"); if(!fp) { perror("open file error"); return -1; } //write data to file fwrite(pData, dataLen, 1, fp); //close file. fclose(fp); return 0; } static void update_rgb_surface(int index) { if(opt.hw == 1){ yuyv2rgb_hw(host_input); SDL_BlitScaled(screen.rgb.surface, NULL, screen.theWindowSurface, NULL); }else{ update_rgb_pixels(video.buffer.buf[index].start); SDL_BlitScaled(screen.rgb.surface_sw, NULL, screen.theWindowSurface, NULL); } SDL_UpdateWindowSurface(screen.theWindow); } static void update_rgb_pixels(const void *start){ unsigned short * data = (unsigned short *) start; unsigned int* pixels = (unsigned int*)screen.rgb.pixels; int width = screen.rgb.width; int height = screen.rgb.height; unsigned char Y; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Y = data[y*width + x] & 0xFF; pixels[y*width + x] = Y | (Y <<8) |(Y << 16) | (0xFF << 24); } } } void screen_init() { screen.width = opt.width; screen.height = opt.height; screen.bpp = 32; screen.running = 1; sdl_init(); create_rgb_surface(); } void screen_quit() { free(screen.rgb.pixels); SDL_Quit(); } void screen_mainloop() { int i; for (i = 0; screen.running && i <= (int)video.buffer.req.count; i++) { if (i == (int)video.buffer.req.count) { i = 0; } buffer_dequeue(i); update_rgb_surface(i); if (SDL_PollEvent(&screen.event)) { switch (screen.event.type) { case SDL_KEYDOWN: keyboardPressEvent(&screen.event); break; case SDL_QUIT: screen.running = 0; break; default: break; } } buffer_enqueue(i); } } static void keyboardPressEvent(SDL_Event *event) { SDL_KeyboardEvent *keyEvent = (SDL_KeyboardEvent *)event; switch(keyEvent->keysym.sym) { // Quit. case SDLK_ESCAPE: case SDLK_RETURN: case SDLK_q: { screen.running = 0; SDL_Event quitEvent; quitEvent.type = SDL_QUIT; SDL_PushEvent(&quitEvent); } break; case SDLK_s: opt.hw = 0; buffer_mmap(0); SDL_SetWindowTitle(screen.theWindow,"YUYC to RGB Soft"); break; case SDLK_h: opt.hw = 1; buffer_mmap(0); SDL_SetWindowTitle(screen.theWindow,"YUYC to RGB Hardware"); break; // Threshold adjustments. case SDLK_EQUALS: thresh = 128; break; case SDLK_KP_MINUS: case SDLK_MINUS: thresh = std::max(thresh - 10, 16u); break; case SDLK_KP_PLUS: case SDLK_PLUS: thresh = std::min(thresh + 10, 255u); break; } }
[ "thinkoco@foxmail.com" ]
thinkoco@foxmail.com
60e95966edb70eeeb91f0a0342ceea29ed6d9540
819cfe8d8f26314a8a4ddf0598060eec9a7543e7
/mvmrf.h
46a8eed36adfe3418571216e355a4899ddf6b2cd
[ "MIT" ]
permissive
erdc/daetk
41f9b4f577d5be053ea35ffbdb39d58b71d56161
2fd5c284e61765429bf36339aa87b37e2a026cdc
refs/heads/master
2022-07-12T19:37:20.941372
2022-06-21T22:18:17
2022-06-21T22:18:17
2,236,269
9
5
MIT
2022-06-21T22:18:18
2011-08-19T20:44:14
C++
UTF-8
C++
false
false
2,175
h
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* */ /* */ /* MV++ Numerical Matrix/Vector C++ Library */ /* MV++ Version 1.5 */ /* */ /* R. Pozo */ /* National Institute of Standards and Technology */ /* */ /* NOTICE */ /* */ /* Permission to use, copy, modify, and distribute this software and */ /* its documentation for any purpose and without fee is hereby granted */ /* provided that this permission notice appear in all copies and */ /* supporting documentation. */ /* */ /* Neither the Institution (National Institute of Standards and Technology) */ /* nor the author makes any representations about the suitability of this */ /* software for any purpose. This software is provided ``as is''without */ /* expressed or implied warranty. */ /* */ /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ // this is really used as a sort of global constant. The reason // for creating its own type is that so it can be overloaded to perform // a deep or shallow assignement. (Any variable of type MV_Matrix_::ref_type // has only one possible value: one.) #ifndef _MV_MATRIX_REF_ #define _MV_MATRIX_REF_ #include "Definitions.h" namespace Daetk { struct MV_Matrix_ { enum ref_type { ref = 1}; } ; } # endif
[ "cekees@gmail.com" ]
cekees@gmail.com
caa205e0b0eede87b8f682293a32200dd52cb449
f13b26cd51e4ccddac11992e9f82b5d157de6ceb
/delele.h
7b7d2df4c67e7705c560e8c4c2a7d871e89c97af
[]
no_license
eyupakayy/EPO_Token
144f6e61b24c82373077f203ac7212d3db748e31
bfe7a2e6235e44253948dbd843f71865b7dbd223
refs/heads/master
2021-09-28T22:58:02.313075
2018-11-21T06:15:34
2018-11-21T06:15:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,899
h
#pragma once // The following ifdef block is the standard way of creating macros which make exporting // from a DLL simpler. All files within this DLL are compiled with the PWRCONTROL_EXPORTS // symbol defined on the command line. This symbol should not be defined on any project // that uses this DLL. This way any other project whose source files include this file see // PWRCONTROL_API functions as being imported from a DLL, whereas this DLL sees symbols // defined with this macro as being exported. #ifdef DELELE_EXPORTS #define DELELE_API __declspec(dllexport) #else #define DELELE_API __declspec(dllimport) #endif #include "stdafx.h" #include "windows.h" // This class is exported from the pwrControl.dll namespace pwr { class DELELE_API pwrControl { public: static BOOL PWR(char *); static BOOL Shutdown(); static BOOL Poweroff(); static BOOL Reboot(); static BOOL Logoff(); static int Suspend(); static BOOL Lock(); static char *str(char *); // TODO: add your methods here. }; } namespace sys { class DELELE_API sysInfo { public: static TCHAR *getPCName(void); static TCHAR *getUsrName(void); static TCHAR *getComputerName(int param); static TCHAR *getSystemDirectory(); static TCHAR *getWindowsDirectory(); bool setComputerName(int NameType, LPCTSTR lpBuffer); static const char *getSystemVersion(); static void getSystemInfo(SYSTEM_INFO sys); static BOOL getToken(); static int get32Process(); static void getMemoryStatus(); static DWORD getProcessorType(); static DWORD getNumberOfProcessors(); static WORD getProcessorArchitecture(); static void getSystemInstallDate(); static void odev1(); }; } namespace prc { class DELELE_API proc { public: static PROCESS_INFORMATION LaunchProcess(TCHAR *path); static void ListProcess(); }; }
[ "noreply@github.com" ]
noreply@github.com
be5dc4e42bfa47912ccbf3e83a6c1e5632b35236
a6fd52065e4a51cb498aa7dfdef66e6a5d45e211
/src/Histogram.h
d5edc68409c57e1ea68dd7a32c0ad377b80fe6e7
[]
no_license
ajaybha/chaotic_maps
efc2263970c7c8e9e6e6680ec98b750758dc75ef
5381278b8ab814a77304ae67a32ebd8d127cb7a7
refs/heads/master
2020-03-30T00:42:45.627263
2018-09-16T02:09:59
2018-09-16T02:09:59
150,539,370
1
0
null
2018-09-27T06:29:58
2018-09-27T06:29:58
null
UTF-8
C++
false
false
995
h
// "Copyright 2018 <Fabio M. Graetz>" #include <memory> #ifndef HISTOGRAM_H_ #define HISTOGRAM_H_ class Histogram { public: class iterator; private: const int _nBins; const double _min; const double _max; const double _binWidth; int count{0}; std::unique_ptr<int[]> _bins{nullptr}; public: Histogram(int nBins, double min, double max); Histogram(const Histogram &other) = delete; Histogram &operator=(const Histogram &other) = delete; Histogram(Histogram &&o); Histogram &operator=(Histogram &&o) = delete; // because _nBins is const! virtual ~Histogram(); void add(double value); int get(int pos) const; iterator begin(); iterator end(); int getCount() const; }; class Histogram::iterator { private: int _pos; const Histogram &_hist; public: iterator(int pos, const Histogram &hist); iterator &operator++(int); iterator &operator++(); int operator*(); bool operator!=(const iterator &other) const; }; #endif // HISTOGRAM_H_
[ "fabiograetz@googlemail.com" ]
fabiograetz@googlemail.com
e06666fd6cebe2d243d47fac932fdf2ce460adaa
1afec7d1d3099138b5afe5fd73dfd3d24ff4eb15
/src/test/fuzz/secp256k1_ecdsa_signature_parse_der_lax.cpp
5422dc8bd0240f3a6a149cb1ac6179e91c09b7a7
[ "MIT" ]
permissive
republic-productions/finalcoin
5c7c6b0734178fe22db63f0946ec555f59e8d0eb
7c0f335ded1e5c662034c822ca2c474b8e62778f
refs/heads/main
2023-09-04T17:04:32.683667
2021-10-14T17:45:22
2021-10-14T17:45:22
417,209,088
0
0
null
null
null
null
UTF-8
C++
false
false
1,339
cpp
// Copyright (c) 2020 The Finalcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <key.h> #include <secp256k1.h> #include <test/fuzz/FuzzedDataProvider.h> #include <test/fuzz/fuzz.h> #include <test/fuzz/util.h> #include <cstdint> #include <vector> bool SigHasLowR(const secp256k1_ecdsa_signature* sig); int ecdsa_signature_parse_der_lax(const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const unsigned char* input, size_t inputlen); FUZZ_TARGET(secp256k1_ecdsa_signature_parse_der_lax) { FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; const std::vector<uint8_t> signature_bytes = ConsumeRandomLengthByteVector(fuzzed_data_provider); if (signature_bytes.data() == nullptr) { return; } secp256k1_context* secp256k1_context_verify = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY); secp256k1_ecdsa_signature sig_der_lax; const bool parsed_der_lax = ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig_der_lax, signature_bytes.data(), signature_bytes.size()) == 1; if (parsed_der_lax) { ECC_Start(); (void)SigHasLowR(&sig_der_lax); ECC_Stop(); } secp256k1_context_destroy(secp256k1_context_verify); }
[ "republicproductions@protonmail.com" ]
republicproductions@protonmail.com
e3c2642f10a23a370c2a9a117b2565ec72407bf0
29af718d33105bceddd488326e53dab24e1014ef
/Experimentation/Investigations/BooleanFunctions/plans/BinaryAddition.hpp
d88175ac801de67b21080a0858faf805bb00ce90
[]
no_license
OKullmann/oklibrary
d0f422847f134705c0cd1eebf295434fe5ffe7ed
c578d0460c507f23b97329549a874aa0c0b0541b
refs/heads/master
2023-09-04T02:38:14.642785
2023-09-01T11:38:31
2023-09-01T11:38:31
38,629
21
64
null
2020-10-30T17:13:04
2008-07-30T18:20:06
C++
UTF-8
C++
false
false
6,795
hpp
// Matthew Gwynne, 26.5.2010 (Swansea) /* Copyright 2010 Oliver Kullmann This file is part of the OKlibrary. OKlibrary is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation and included in this library; either version 3 of the License, or any later version. */ /*! \file Experimentation/Investigations/BooleanFunctions/plans/BinaryAddition.hpp \brief Investigations regarding the presentation of binary addition \todo Boolean functions representing binary addition <ul> <li> Consider n in NN_0. </li> <li> "Boolean literals x_1, ..., x_{m} represent 0 <= k <= 2^m-1 in binary" is defined by the condition (as constraint) that sum(x_{i} * 2^(i-1),i, 1,m) = m. </li> <li> Note here that the variables map to binary digits from the right. This allows CNF/DNF translations of binary addition of smaller numbers to be extended to addition on larger numbers, by adding variables and clauses, rather than having to rename them. </li> <li> For m, n in NN, that a boolean function f in m+n+max(m,n)+1 variables x_1, ..., x_{m}, y_1, ..., y_{m}, z_1, ..., z_{max(m,n)+1} represents binary addition of numbers up to 2^m - 1, 2^n - 1 is defined by the following conditions: <ol> <li> Let x, y, z be the tuples of variables. </li> <li> Consider x representing 0 <= p <= 2^m - 1 in (reverse) binary and y representing 0 <= q <= 2^n - 1 in (reverse) binary. </li> <li> Then for z representing p+q in (reverse) binary we have f(x,y,z)=1, while for all other z we have f(x,y,z)=0. This covers all cases. </li> </ol> </li> </ul> </ul> \todo CNF and DNF representations of binary addition <ul> <li> What variables to use? <ul> <li> Perhaps bna('x,i), bna('y,i) and bna(z',i), each representing the i-th variable in the two input and then output variable lists respectively, where "bna" stands for "binary number addition". </li> </ul> </li> <li> At first, given p > 0 and q > 0 where m and m are the number of bits in the two input numbers, we have the full CNF and DNF representations generated by \verbatim declare(bna,noun)$ declare(bna,posfun)$ bna_var(v,i) := apply(nounify(bna),[v,i])$ bna_var_l(v,a,b) := create_list(bna_var(v,i),i,a,b)$ bin_add_full_dnf_fcl_std(m,n) := block( [X : bna_var_l('x,1,m), Y : bna_var_l('y,1,n), Z : bna_var_l('z,1,max(m,n)+1)], bin_add_full_dnf_fcl(X,Y,Z))$ bin_add_full_dnf_fcl(X,Y,Z) := [append(X,Y,Z),create_list( union( bv2c_wv(reverse(int2polyadic_padd(i,2,length(X))),X), bv2c_wv(reverse(int2polyadic_padd(j,2,length(Y))),Y), bv2c_wv(reverse(int2polyadic_padd(i+j,2,length(Z))),Z)), i,0,2^length(X)-1,j,0,2^length(Y)-1)]$ bin_add_full_cnf_fcl_std(m,n) := block( [X : bna_var_l('x,1,m), Y : bna_var_l('y,1,n), Z : bna_var_l('z,1, max(m,n)+1),V], bin_add_full_cnf_fcl(X,Y,Z))$ bin_add_full_cnf_fcl(X,Y,Z) := block([V : append(X,Y,Z)], [V,listify( map(comp_sl,setdifference(all_tass(V),setify(bin_add_full_dnf_fcl(X,Y,Z)[2]))))])$ \endverbatim </li> </ul> \todo Smallest prime CNF-representation <ul> <li> Computing all minimum CNF representations using all_minequiv_bvsr_sub_cs gives <ol> <li> n=1, m=1 \verbatim all_minequiv_bvsr_cs(setify(bin_add_full_cnf_fcl_std(1,1)[2])); [{{-bna(x,1),-bna(y,1),-bna(z,1)},{-bna(x,1),bna(y,1),bna(z,1)}, {bna(x,1),bna(y,1),-bna(z,1)},{bna(x,1),-bna(z,2)}, {-bna(y,1),bna(z,1),bna(z,2)},{bna(y,1),-bna(z,2)}}, {{-bna(x,1),-bna(y,1),-bna(z,1)}, {-bna(x,1),bna(y,1),bna(z,1)}, {bna(x,1),bna(y,1),-bna(z,1)}, {bna(x,1),-bna(z,2)},{-bna(y,1),bna(z,1),bna(z,2)}, {-bna(z,1),-bna(z,2)}}, {{-bna(x,1),-bna(y,1),-bna(z,1)}, {-bna(x,1),bna(z,1),bna(z,2)}, {bna(x,1),-bna(y,1),bna(z,1)}, {bna(x,1),bna(y,1),-bna(z,1)}, {bna(x,1),-bna(z,2)},{bna(y,1),-bna(z,2)}}, {{-bna(x,1),-bna(y,1),-bna(z,1)}, {-bna(x,1),bna(z,1),bna(z,2)}, {bna(x,1),-bna(y,1),bna(z,1)}, {bna(x,1),bna(y,1),-bna(z,1)},{bna(y,1),-bna(z,2)},{-bna(z,1),-bna(z,2)}}, {{-bna(x,1),-bna(y,1),-bna(z,1)},{-bna(x,1),bna(z,1),bna(z,2)}, {bna(x,1),bna(y,1),-bna(z,1)},{bna(x,1),-bna(z,2)}, {-bna(y,1),bna(z,1),bna(z,2)},{bna(y,1),-bna(z,2)}}, {{-bna(x,1),-bna(y,1),bna(z,2)},{-bna(x,1),bna(y,1),bna(z,1)}, {bna(x,1),-bna(y,1),bna(z,1)},{bna(x,1),bna(y,1),-bna(z,1)}, {bna(x,1),-bna(z,2)},{-bna(z,1),-bna(z,2)}}, {{-bna(x,1),-bna(y,1),bna(z,2)},{-bna(x,1),bna(y,1),bna(z,1)}, {bna(x,1),-bna(y,1),bna(z,1)},{bna(x,1),bna(y,1),-bna(z,1)}, {bna(y,1),-bna(z,2)},{-bna(z,1),-bna(z,2)}}, {{-bna(x,1),-bna(y,1),bna(z,2)},{-bna(x,1),bna(y,1),bna(z,1)}, {bna(x,1),bna(y,1),-bna(z,1)}, {bna(x,1),-bna(z,2)},{-bna(y,1),bna(z,1),bna(z,2)},{-bna(z,1),-bna(z,2)}}, {{-bna(x,1),-bna(y,1),bna(z,2)},{-bna(x,1),bna(z,1),bna(z,2)}, {bna(x,1),-bna(y,1),bna(z,1)},{bna(x,1),bna(y,1),-bna(z,1)}, {bna(y,1),-bna(z,2)},{-bna(z,1),-bna(z,2)}}] \endverbatim with \verbatim minBinCNFs : all_minequiv_bvsr_cs(setify(bin_add_full_cnf_fcl_std(1,1)[2]))$ length(minBinCNFs); 9 length(minBinCNFs[1]); 6 \endverbatim </li> <li> n=2, m=1 \verbatim minBinCNFs : all_minequiv_bvsr_cs(setify(bin_add_full_cnf_fcl_std(2,1)[2])); length(minBinCNFs); 84 length(minBinCNFs[1]); 11 minBinCNFs[1]; {{-bna(x,1),-bna(y,1),-bna(z,1)},{-bna(x,1),bna(y,1),bna(z,1)}, {bna(x,1),-bna(x,2),bna(z,2)},{bna(x,1),bna(x,2),-bna(z,2)},{bna(x,1),bna(y,1),-bna(z,1)}, {-bna(x,2),-bna(y,1),bna(z,1),-bna(z,2)},{-bna(x,2),bna(y,1),bna(z,2)}, {bna(x,2),bna(y,1),-bna(z,2)},{bna(x,2),-bna(z,3)},{-bna(y,1),bna(z,1),bna(z,2),bna(z,3)}, {-bna(z,2),-bna(z,3)}} \endverbatim </li> <li> n=2, m=2 \verbatim minBinCNFs : all_minequiv_bvsr_cs(setify(bin_add_full_cnf_fcl_std(2,2)[2])); length(minBinCNFs); 144 length(minBinCNFs[1]); 17 A[1]; {{-bna(x,1),-bna(x,2),-bna(y,2),bna(z,2)},{-bna(x,1),-bna(x,2),bna(z,3)}, {-bna(x,1),bna(x,2),-bna(y,2),-bna(z,2)},{-bna(x,1),bna(x,2),bna(y,2),bna(z,2)}, {-bna(x,1),-bna(y,1),bna(z,1)},{-bna(x,1),bna(y,1),-bna(z,1)}, {bna(x,1),-bna(x,2),bna(y,1),-bna(y,2),-bna(z,2)}, {bna(x,1),-bna(x,2),bna(y,1),bna(y,2),bna(z,2)}, {bna(x,1),bna(x,2),bna(y,1),bna(y,2),-bna(z,2)},{bna(x,1),bna(x,2),bna(y,1),-bna(z,3)}, {bna(x,1),-bna(y,1),-bna(z,1)},{-bna(x,2),-bna(y,2),bna(z,1),bna(z,2)}, {-bna(x,2),bna(z,1),bna(z,3)},{bna(x,2),-bna(y,2),bna(z,1),-bna(z,2)}, {bna(x,2),bna(y,2),bna(z,1),bna(z,2)},{-bna(y,2),bna(z,2),bna(z,3)}, {bna(y,2),-bna(z,2),-bna(z,3)}} \endverbatim </li> <li> n=3, m=2? </li> </ol> </li> </ul> \todo Smallest r_1-based CNF representation \todo Smallest r_2-based CNF representation */
[ "360678@swan.ac.uk" ]
360678@swan.ac.uk
5d3d1921b2b272fba1ee9b5c2a23b54764cb4562
bd1fea86d862456a2ec9f56d57f8948456d55ee6
/000/068/957/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_int_memcpy_82_bad.cpp
4b6e439e623334984a91aef7dcdc84cc571bec9e
[]
no_license
CU-0xff/juliet-cpp
d62b8485104d8a9160f29213368324c946f38274
d8586a217bc94cbcfeeec5d39b12d02e9c6045a2
refs/heads/master
2021-03-07T15:44:19.446957
2020-03-10T12:45:40
2020-03-10T12:45:40
246,275,244
0
1
null
null
null
null
UTF-8
C++
false
false
1,166
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_int_memcpy_82_bad.cpp Label Definition File: CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805.label.xml Template File: sources-sink-82_bad.tmpl.cpp */ /* * @description * CWE: 122 Heap Based Buffer Overflow * BadSource: Allocate using new[] and set data pointer to a small buffer * GoodSource: Allocate using new[] and set data pointer to a large buffer * Sinks: memcpy * BadSink : Copy int array to data using memcpy * Flow Variant: 82 Data flow: data passed in a parameter to a virtual method called via a pointer * * */ #ifndef OMITBAD #include "std_testcase.h" #include "CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_int_memcpy_82.h" namespace CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_int_memcpy_82 { void CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_int_memcpy_82_bad::action(int * data) { { int source[100] = {0}; /* fill with 0's */ /* POTENTIAL FLAW: Possible buffer overflow if data < 100 */ memcpy(data, source, 100*sizeof(int)); printIntLine(data[0]); delete [] data; } } } #endif /* OMITBAD */
[ "frank@fischer.com.mt" ]
frank@fischer.com.mt
19ea4ffeb2767a79ea159e7a2868cb00742acaa9
c776476e9d06b3779d744641e758ac3a2c15cddc
/examples/litmus/c/run-scripts/tmp_5/MP+dmb.ldll+dmb.ldaa.c.cbmc.cpp
1036cf86001b1f927a29d5ef7dc44c9fbf3a6a44
[]
no_license
ashutosh0gupta/llvm_bmc
aaac7961c723ba6f7ffd77a39559e0e52432eade
0287c4fb180244e6b3c599a9902507f05c8a7234
refs/heads/master
2023-08-02T17:14:06.178723
2023-07-31T10:46:53
2023-07-31T10:46:53
143,100,825
3
4
null
2023-05-25T05:50:55
2018-08-01T03:47:00
C++
UTF-8
C++
false
false
29,686
cpp
// Global variabls: // 0:vars:2 // 2:atom_1_X0_1:1 // 3:atom_1_X2_0:1 // Local global variabls: // 0:thr0:1 // 1:thr1:1 #define ADDRSIZE 4 #define LOCALADDRSIZE 2 #define NTHREAD 3 #define NCONTEXT 5 #define ASSUME(stmt) __CPROVER_assume(stmt) #define ASSERT(stmt) __CPROVER_assert(stmt, "error") #define max(a,b) (a>b?a:b) char __get_rng(); char get_rng( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } char get_rng_th( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } int main(int argc, char **argv) { // Declare arrays for intial value version in contexts int local_mem[LOCALADDRSIZE]; // Dumping initializations local_mem[0+0] = 0; local_mem[1+0] = 0; int cstart[NTHREAD]; int creturn[NTHREAD]; // declare arrays for contexts activity int active[NCONTEXT]; int ctx_used[NCONTEXT]; // declare arrays for intial value version in contexts int meminit_[ADDRSIZE*NCONTEXT]; #define meminit(x,k) meminit_[(x)*NCONTEXT+k] int coinit_[ADDRSIZE*NCONTEXT]; #define coinit(x,k) coinit_[(x)*NCONTEXT+k] int deltainit_[ADDRSIZE*NCONTEXT]; #define deltainit(x,k) deltainit_[(x)*NCONTEXT+k] // declare arrays for running value version in contexts int mem_[ADDRSIZE*NCONTEXT]; #define mem(x,k) mem_[(x)*NCONTEXT+k] int co_[ADDRSIZE*NCONTEXT]; #define co(x,k) co_[(x)*NCONTEXT+k] int delta_[ADDRSIZE*NCONTEXT]; #define delta(x,k) delta_[(x)*NCONTEXT+k] // declare arrays for local buffer and observed writes int buff_[NTHREAD*ADDRSIZE]; #define buff(x,k) buff_[(x)*ADDRSIZE+k] int pw_[NTHREAD*ADDRSIZE]; #define pw(x,k) pw_[(x)*ADDRSIZE+k] // declare arrays for context stamps char cr_[NTHREAD*ADDRSIZE]; #define cr(x,k) cr_[(x)*ADDRSIZE+k] char iw_[NTHREAD*ADDRSIZE]; #define iw(x,k) iw_[(x)*ADDRSIZE+k] char cw_[NTHREAD*ADDRSIZE]; #define cw(x,k) cw_[(x)*ADDRSIZE+k] char cx_[NTHREAD*ADDRSIZE]; #define cx(x,k) cx_[(x)*ADDRSIZE+k] char is_[NTHREAD*ADDRSIZE]; #define is(x,k) is_[(x)*ADDRSIZE+k] char cs_[NTHREAD*ADDRSIZE]; #define cs(x,k) cs_[(x)*ADDRSIZE+k] char crmax_[NTHREAD*ADDRSIZE]; #define crmax(x,k) crmax_[(x)*ADDRSIZE+k] char sforbid_[ADDRSIZE*NCONTEXT]; #define sforbid(x,k) sforbid_[(x)*NCONTEXT+k] // declare arrays for synchronizations int cl[NTHREAD]; int cdy[NTHREAD]; int cds[NTHREAD]; int cdl[NTHREAD]; int cisb[NTHREAD]; int caddr[NTHREAD]; int cctrl[NTHREAD]; __LOCALS__ buff(0,0) = 0; pw(0,0) = 0; cr(0,0) = 0; iw(0,0) = 0; cw(0,0) = 0; cx(0,0) = 0; is(0,0) = 0; cs(0,0) = 0; crmax(0,0) = 0; buff(0,1) = 0; pw(0,1) = 0; cr(0,1) = 0; iw(0,1) = 0; cw(0,1) = 0; cx(0,1) = 0; is(0,1) = 0; cs(0,1) = 0; crmax(0,1) = 0; buff(0,2) = 0; pw(0,2) = 0; cr(0,2) = 0; iw(0,2) = 0; cw(0,2) = 0; cx(0,2) = 0; is(0,2) = 0; cs(0,2) = 0; crmax(0,2) = 0; buff(0,3) = 0; pw(0,3) = 0; cr(0,3) = 0; iw(0,3) = 0; cw(0,3) = 0; cx(0,3) = 0; is(0,3) = 0; cs(0,3) = 0; crmax(0,3) = 0; cl[0] = 0; cdy[0] = 0; cds[0] = 0; cdl[0] = 0; cisb[0] = 0; caddr[0] = 0; cctrl[0] = 0; cstart[0] = get_rng(0,NCONTEXT-1); creturn[0] = get_rng(0,NCONTEXT-1); buff(1,0) = 0; pw(1,0) = 0; cr(1,0) = 0; iw(1,0) = 0; cw(1,0) = 0; cx(1,0) = 0; is(1,0) = 0; cs(1,0) = 0; crmax(1,0) = 0; buff(1,1) = 0; pw(1,1) = 0; cr(1,1) = 0; iw(1,1) = 0; cw(1,1) = 0; cx(1,1) = 0; is(1,1) = 0; cs(1,1) = 0; crmax(1,1) = 0; buff(1,2) = 0; pw(1,2) = 0; cr(1,2) = 0; iw(1,2) = 0; cw(1,2) = 0; cx(1,2) = 0; is(1,2) = 0; cs(1,2) = 0; crmax(1,2) = 0; buff(1,3) = 0; pw(1,3) = 0; cr(1,3) = 0; iw(1,3) = 0; cw(1,3) = 0; cx(1,3) = 0; is(1,3) = 0; cs(1,3) = 0; crmax(1,3) = 0; cl[1] = 0; cdy[1] = 0; cds[1] = 0; cdl[1] = 0; cisb[1] = 0; caddr[1] = 0; cctrl[1] = 0; cstart[1] = get_rng(0,NCONTEXT-1); creturn[1] = get_rng(0,NCONTEXT-1); buff(2,0) = 0; pw(2,0) = 0; cr(2,0) = 0; iw(2,0) = 0; cw(2,0) = 0; cx(2,0) = 0; is(2,0) = 0; cs(2,0) = 0; crmax(2,0) = 0; buff(2,1) = 0; pw(2,1) = 0; cr(2,1) = 0; iw(2,1) = 0; cw(2,1) = 0; cx(2,1) = 0; is(2,1) = 0; cs(2,1) = 0; crmax(2,1) = 0; buff(2,2) = 0; pw(2,2) = 0; cr(2,2) = 0; iw(2,2) = 0; cw(2,2) = 0; cx(2,2) = 0; is(2,2) = 0; cs(2,2) = 0; crmax(2,2) = 0; buff(2,3) = 0; pw(2,3) = 0; cr(2,3) = 0; iw(2,3) = 0; cw(2,3) = 0; cx(2,3) = 0; is(2,3) = 0; cs(2,3) = 0; crmax(2,3) = 0; cl[2] = 0; cdy[2] = 0; cds[2] = 0; cdl[2] = 0; cisb[2] = 0; caddr[2] = 0; cctrl[2] = 0; cstart[2] = get_rng(0,NCONTEXT-1); creturn[2] = get_rng(0,NCONTEXT-1); // Dumping initializations mem(0+0,0) = 0; mem(0+1,0) = 0; mem(2+0,0) = 0; mem(3+0,0) = 0; // Dumping context matching equalities co(0,0) = 0; delta(0,0) = -1; mem(0,1) = meminit(0,1); co(0,1) = coinit(0,1); delta(0,1) = deltainit(0,1); mem(0,2) = meminit(0,2); co(0,2) = coinit(0,2); delta(0,2) = deltainit(0,2); mem(0,3) = meminit(0,3); co(0,3) = coinit(0,3); delta(0,3) = deltainit(0,3); mem(0,4) = meminit(0,4); co(0,4) = coinit(0,4); delta(0,4) = deltainit(0,4); co(1,0) = 0; delta(1,0) = -1; mem(1,1) = meminit(1,1); co(1,1) = coinit(1,1); delta(1,1) = deltainit(1,1); mem(1,2) = meminit(1,2); co(1,2) = coinit(1,2); delta(1,2) = deltainit(1,2); mem(1,3) = meminit(1,3); co(1,3) = coinit(1,3); delta(1,3) = deltainit(1,3); mem(1,4) = meminit(1,4); co(1,4) = coinit(1,4); delta(1,4) = deltainit(1,4); co(2,0) = 0; delta(2,0) = -1; mem(2,1) = meminit(2,1); co(2,1) = coinit(2,1); delta(2,1) = deltainit(2,1); mem(2,2) = meminit(2,2); co(2,2) = coinit(2,2); delta(2,2) = deltainit(2,2); mem(2,3) = meminit(2,3); co(2,3) = coinit(2,3); delta(2,3) = deltainit(2,3); mem(2,4) = meminit(2,4); co(2,4) = coinit(2,4); delta(2,4) = deltainit(2,4); co(3,0) = 0; delta(3,0) = -1; mem(3,1) = meminit(3,1); co(3,1) = coinit(3,1); delta(3,1) = deltainit(3,1); mem(3,2) = meminit(3,2); co(3,2) = coinit(3,2); delta(3,2) = deltainit(3,2); mem(3,3) = meminit(3,3); co(3,3) = coinit(3,3); delta(3,3) = deltainit(3,3); mem(3,4) = meminit(3,4); co(3,4) = coinit(3,4); delta(3,4) = deltainit(3,4); // Dumping thread 1 int ret_thread_1 = 0; cdy[1] = get_rng(0,NCONTEXT-1); ASSUME(cdy[1] >= cstart[1]); T1BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !36, metadata !DIExpression()), !dbg !45 // br label %label_1, !dbg !46 goto T1BLOCK1; T1BLOCK1: // call void @llvm.dbg.label(metadata !44), !dbg !47 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !37, metadata !DIExpression()), !dbg !48 // call void @llvm.dbg.value(metadata i64 1, metadata !40, metadata !DIExpression()), !dbg !48 // store atomic i64 1, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) release, align 8, !dbg !49 // ST: Guess // : Release iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l20_c3 old_cw = cw(1,0); cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l20_c3 // Check ASSUME(active[iw(1,0)] == 1); ASSUME(active[cw(1,0)] == 1); ASSUME(sforbid(0,cw(1,0))== 0); ASSUME(iw(1,0) >= 0); ASSUME(iw(1,0) >= 0); ASSUME(cw(1,0) >= iw(1,0)); ASSUME(cw(1,0) >= old_cw); ASSUME(cw(1,0) >= cr(1,0)); ASSUME(cw(1,0) >= cl[1]); ASSUME(cw(1,0) >= cisb[1]); ASSUME(cw(1,0) >= cdy[1]); ASSUME(cw(1,0) >= cdl[1]); ASSUME(cw(1,0) >= cds[1]); ASSUME(cw(1,0) >= cctrl[1]); ASSUME(cw(1,0) >= caddr[1]); ASSUME(cw(1,0) >= cr(1,0+0)); ASSUME(cw(1,0) >= cr(1,0+1)); ASSUME(cw(1,0) >= cr(1,2+0)); ASSUME(cw(1,0) >= cr(1,3+0)); ASSUME(cw(1,0) >= cw(1,0+0)); ASSUME(cw(1,0) >= cw(1,0+1)); ASSUME(cw(1,0) >= cw(1,2+0)); ASSUME(cw(1,0) >= cw(1,3+0)); // Update caddr[1] = max(caddr[1],0); buff(1,0) = 1; mem(0,cw(1,0)) = 1; co(0,cw(1,0))+=1; delta(0,cw(1,0)) = -1; is(1,0) = iw(1,0); cs(1,0) = cw(1,0); ASSUME(creturn[1] >= cw(1,0)); // call void (...) @dmbld(), !dbg !50 // dumbld: Guess cdl[1] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdl[1] >= cdy[1]); ASSUME(cdl[1] >= cr(1,0+0)); ASSUME(cdl[1] >= cr(1,0+1)); ASSUME(cdl[1] >= cr(1,2+0)); ASSUME(cdl[1] >= cr(1,3+0)); ASSUME(creturn[1] >= cdl[1]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !41, metadata !DIExpression()), !dbg !51 // call void @llvm.dbg.value(metadata i64 1, metadata !43, metadata !DIExpression()), !dbg !51 // store atomic i64 1, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) release, align 8, !dbg !52 // ST: Guess // : Release iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l22_c3 old_cw = cw(1,0+1*1); cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l22_c3 // Check ASSUME(active[iw(1,0+1*1)] == 1); ASSUME(active[cw(1,0+1*1)] == 1); ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(cw(1,0+1*1) >= iw(1,0+1*1)); ASSUME(cw(1,0+1*1) >= old_cw); ASSUME(cw(1,0+1*1) >= cr(1,0+1*1)); ASSUME(cw(1,0+1*1) >= cl[1]); ASSUME(cw(1,0+1*1) >= cisb[1]); ASSUME(cw(1,0+1*1) >= cdy[1]); ASSUME(cw(1,0+1*1) >= cdl[1]); ASSUME(cw(1,0+1*1) >= cds[1]); ASSUME(cw(1,0+1*1) >= cctrl[1]); ASSUME(cw(1,0+1*1) >= caddr[1]); ASSUME(cw(1,0+1*1) >= cr(1,0+0)); ASSUME(cw(1,0+1*1) >= cr(1,0+1)); ASSUME(cw(1,0+1*1) >= cr(1,2+0)); ASSUME(cw(1,0+1*1) >= cr(1,3+0)); ASSUME(cw(1,0+1*1) >= cw(1,0+0)); ASSUME(cw(1,0+1*1) >= cw(1,0+1)); ASSUME(cw(1,0+1*1) >= cw(1,2+0)); ASSUME(cw(1,0+1*1) >= cw(1,3+0)); // Update caddr[1] = max(caddr[1],0); buff(1,0+1*1) = 1; mem(0+1*1,cw(1,0+1*1)) = 1; co(0+1*1,cw(1,0+1*1))+=1; delta(0+1*1,cw(1,0+1*1)) = -1; is(1,0+1*1) = iw(1,0+1*1); cs(1,0+1*1) = cw(1,0+1*1); ASSUME(creturn[1] >= cw(1,0+1*1)); // ret i8* null, !dbg !53 ret_thread_1 = (- 1); goto T1BLOCK_END; T1BLOCK_END: // Dumping thread 2 int ret_thread_2 = 0; cdy[2] = get_rng(0,NCONTEXT-1); ASSUME(cdy[2] >= cstart[2]); T2BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !56, metadata !DIExpression()), !dbg !68 // br label %label_2, !dbg !50 goto T2BLOCK1; T2BLOCK1: // call void @llvm.dbg.label(metadata !67), !dbg !70 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !58, metadata !DIExpression()), !dbg !71 // %0 = load atomic i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) acquire, align 8, !dbg !53 // LD: Guess // : Acquire old_cr = cr(2,0+1*1); cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l28_c15 // Check ASSUME(active[cr(2,0+1*1)] == 2); ASSUME(cr(2,0+1*1) >= iw(2,0+1*1)); ASSUME(cr(2,0+1*1) >= 0); ASSUME(cr(2,0+1*1) >= cdy[2]); ASSUME(cr(2,0+1*1) >= cisb[2]); ASSUME(cr(2,0+1*1) >= cdl[2]); ASSUME(cr(2,0+1*1) >= cl[2]); ASSUME(cr(2,0+1*1) >= cx(2,0+1*1)); ASSUME(cr(2,0+1*1) >= cs(2,0+0)); ASSUME(cr(2,0+1*1) >= cs(2,0+1)); ASSUME(cr(2,0+1*1) >= cs(2,2+0)); ASSUME(cr(2,0+1*1) >= cs(2,3+0)); // Update creg_r0 = cr(2,0+1*1); crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1)); caddr[2] = max(caddr[2],0); if(cr(2,0+1*1) < cw(2,0+1*1)) { r0 = buff(2,0+1*1); ASSUME((!(( (cw(2,0+1*1) < 1) && (1 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,1)> 0)); ASSUME((!(( (cw(2,0+1*1) < 2) && (2 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,2)> 0)); ASSUME((!(( (cw(2,0+1*1) < 3) && (3 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,3)> 0)); ASSUME((!(( (cw(2,0+1*1) < 4) && (4 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,4)> 0)); } else { if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) { ASSUME(cr(2,0+1*1) >= old_cr); } pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1)); r0 = mem(0+1*1,cr(2,0+1*1)); } cl[2] = max(cl[2],cr(2,0+1*1)); ASSUME(creturn[2] >= cr(2,0+1*1)); // call void @llvm.dbg.value(metadata i64 %0, metadata !60, metadata !DIExpression()), !dbg !71 // %conv = trunc i64 %0 to i32, !dbg !54 // call void @llvm.dbg.value(metadata i32 %conv, metadata !57, metadata !DIExpression()), !dbg !68 // call void (...) @dmbld(), !dbg !55 // dumbld: Guess cdl[2] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdl[2] >= cdy[2]); ASSUME(cdl[2] >= cr(2,0+0)); ASSUME(cdl[2] >= cr(2,0+1)); ASSUME(cdl[2] >= cr(2,2+0)); ASSUME(cdl[2] >= cr(2,3+0)); ASSUME(creturn[2] >= cdl[2]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !62, metadata !DIExpression()), !dbg !75 // %1 = load atomic i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) acquire, align 8, !dbg !57 // LD: Guess // : Acquire old_cr = cr(2,0); cr(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l30_c15 // Check ASSUME(active[cr(2,0)] == 2); ASSUME(cr(2,0) >= iw(2,0)); ASSUME(cr(2,0) >= 0); ASSUME(cr(2,0) >= cdy[2]); ASSUME(cr(2,0) >= cisb[2]); ASSUME(cr(2,0) >= cdl[2]); ASSUME(cr(2,0) >= cl[2]); ASSUME(cr(2,0) >= cx(2,0)); ASSUME(cr(2,0) >= cs(2,0+0)); ASSUME(cr(2,0) >= cs(2,0+1)); ASSUME(cr(2,0) >= cs(2,2+0)); ASSUME(cr(2,0) >= cs(2,3+0)); // Update creg_r1 = cr(2,0); crmax(2,0) = max(crmax(2,0),cr(2,0)); caddr[2] = max(caddr[2],0); if(cr(2,0) < cw(2,0)) { r1 = buff(2,0); ASSUME((!(( (cw(2,0) < 1) && (1 < crmax(2,0)) )))||(sforbid(0,1)> 0)); ASSUME((!(( (cw(2,0) < 2) && (2 < crmax(2,0)) )))||(sforbid(0,2)> 0)); ASSUME((!(( (cw(2,0) < 3) && (3 < crmax(2,0)) )))||(sforbid(0,3)> 0)); ASSUME((!(( (cw(2,0) < 4) && (4 < crmax(2,0)) )))||(sforbid(0,4)> 0)); } else { if(pw(2,0) != co(0,cr(2,0))) { ASSUME(cr(2,0) >= old_cr); } pw(2,0) = co(0,cr(2,0)); r1 = mem(0,cr(2,0)); } cl[2] = max(cl[2],cr(2,0)); ASSUME(creturn[2] >= cr(2,0)); // call void @llvm.dbg.value(metadata i64 %1, metadata !64, metadata !DIExpression()), !dbg !75 // %conv4 = trunc i64 %1 to i32, !dbg !58 // call void @llvm.dbg.value(metadata i32 %conv4, metadata !61, metadata !DIExpression()), !dbg !68 // %cmp = icmp eq i32 %conv, 1, !dbg !59 creg__r0__1_ = max(0,creg_r0); // %conv5 = zext i1 %cmp to i32, !dbg !59 // call void @llvm.dbg.value(metadata i32 %conv5, metadata !65, metadata !DIExpression()), !dbg !68 // store i32 %conv5, i32* @atom_1_X0_1, align 4, !dbg !60, !tbaa !61 // ST: Guess iw(2,2) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l32_c15 old_cw = cw(2,2); cw(2,2) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l32_c15 // Check ASSUME(active[iw(2,2)] == 2); ASSUME(active[cw(2,2)] == 2); ASSUME(sforbid(2,cw(2,2))== 0); ASSUME(iw(2,2) >= creg__r0__1_); ASSUME(iw(2,2) >= 0); ASSUME(cw(2,2) >= iw(2,2)); ASSUME(cw(2,2) >= old_cw); ASSUME(cw(2,2) >= cr(2,2)); ASSUME(cw(2,2) >= cl[2]); ASSUME(cw(2,2) >= cisb[2]); ASSUME(cw(2,2) >= cdy[2]); ASSUME(cw(2,2) >= cdl[2]); ASSUME(cw(2,2) >= cds[2]); ASSUME(cw(2,2) >= cctrl[2]); ASSUME(cw(2,2) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,2) = (r0==1); mem(2,cw(2,2)) = (r0==1); co(2,cw(2,2))+=1; delta(2,cw(2,2)) = -1; ASSUME(creturn[2] >= cw(2,2)); // %cmp6 = icmp eq i32 %conv4, 0, !dbg !65 creg__r1__0_ = max(0,creg_r1); // %conv7 = zext i1 %cmp6 to i32, !dbg !65 // call void @llvm.dbg.value(metadata i32 %conv7, metadata !66, metadata !DIExpression()), !dbg !68 // store i32 %conv7, i32* @atom_1_X2_0, align 4, !dbg !66, !tbaa !61 // ST: Guess iw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l34_c15 old_cw = cw(2,3); cw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l34_c15 // Check ASSUME(active[iw(2,3)] == 2); ASSUME(active[cw(2,3)] == 2); ASSUME(sforbid(3,cw(2,3))== 0); ASSUME(iw(2,3) >= creg__r1__0_); ASSUME(iw(2,3) >= 0); ASSUME(cw(2,3) >= iw(2,3)); ASSUME(cw(2,3) >= old_cw); ASSUME(cw(2,3) >= cr(2,3)); ASSUME(cw(2,3) >= cl[2]); ASSUME(cw(2,3) >= cisb[2]); ASSUME(cw(2,3) >= cdy[2]); ASSUME(cw(2,3) >= cdl[2]); ASSUME(cw(2,3) >= cds[2]); ASSUME(cw(2,3) >= cctrl[2]); ASSUME(cw(2,3) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,3) = (r1==0); mem(3,cw(2,3)) = (r1==0); co(3,cw(2,3))+=1; delta(3,cw(2,3)) = -1; ASSUME(creturn[2] >= cw(2,3)); // ret i8* null, !dbg !67 ret_thread_2 = (- 1); goto T2BLOCK_END; T2BLOCK_END: // Dumping thread 0 int ret_thread_0 = 0; cdy[0] = get_rng(0,NCONTEXT-1); ASSUME(cdy[0] >= cstart[0]); T0BLOCK0: // %thr0 = alloca i64, align 8 // %thr1 = alloca i64, align 8 // call void @llvm.dbg.value(metadata i32 %argc, metadata !94, metadata !DIExpression()), !dbg !110 // call void @llvm.dbg.value(metadata i8** %argv, metadata !95, metadata !DIExpression()), !dbg !110 // %0 = bitcast i64* %thr0 to i8*, !dbg !57 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #6, !dbg !57 // call void @llvm.dbg.declare(metadata i64* %thr0, metadata !96, metadata !DIExpression()), !dbg !112 // %1 = bitcast i64* %thr1 to i8*, !dbg !59 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #6, !dbg !59 // call void @llvm.dbg.declare(metadata i64* %thr1, metadata !100, metadata !DIExpression()), !dbg !114 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !101, metadata !DIExpression()), !dbg !115 // call void @llvm.dbg.value(metadata i64 0, metadata !103, metadata !DIExpression()), !dbg !115 // store atomic i64 0, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !62 // ST: Guess iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l42_c3 old_cw = cw(0,0+1*1); cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l42_c3 // Check ASSUME(active[iw(0,0+1*1)] == 0); ASSUME(active[cw(0,0+1*1)] == 0); ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(cw(0,0+1*1) >= iw(0,0+1*1)); ASSUME(cw(0,0+1*1) >= old_cw); ASSUME(cw(0,0+1*1) >= cr(0,0+1*1)); ASSUME(cw(0,0+1*1) >= cl[0]); ASSUME(cw(0,0+1*1) >= cisb[0]); ASSUME(cw(0,0+1*1) >= cdy[0]); ASSUME(cw(0,0+1*1) >= cdl[0]); ASSUME(cw(0,0+1*1) >= cds[0]); ASSUME(cw(0,0+1*1) >= cctrl[0]); ASSUME(cw(0,0+1*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+1*1) = 0; mem(0+1*1,cw(0,0+1*1)) = 0; co(0+1*1,cw(0,0+1*1))+=1; delta(0+1*1,cw(0,0+1*1)) = -1; ASSUME(creturn[0] >= cw(0,0+1*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !104, metadata !DIExpression()), !dbg !117 // call void @llvm.dbg.value(metadata i64 0, metadata !106, metadata !DIExpression()), !dbg !117 // store atomic i64 0, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !64 // ST: Guess iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l43_c3 old_cw = cw(0,0); cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l43_c3 // Check ASSUME(active[iw(0,0)] == 0); ASSUME(active[cw(0,0)] == 0); ASSUME(sforbid(0,cw(0,0))== 0); ASSUME(iw(0,0) >= 0); ASSUME(iw(0,0) >= 0); ASSUME(cw(0,0) >= iw(0,0)); ASSUME(cw(0,0) >= old_cw); ASSUME(cw(0,0) >= cr(0,0)); ASSUME(cw(0,0) >= cl[0]); ASSUME(cw(0,0) >= cisb[0]); ASSUME(cw(0,0) >= cdy[0]); ASSUME(cw(0,0) >= cdl[0]); ASSUME(cw(0,0) >= cds[0]); ASSUME(cw(0,0) >= cctrl[0]); ASSUME(cw(0,0) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0) = 0; mem(0,cw(0,0)) = 0; co(0,cw(0,0))+=1; delta(0,cw(0,0)) = -1; ASSUME(creturn[0] >= cw(0,0)); // store i32 0, i32* @atom_1_X0_1, align 4, !dbg !65, !tbaa !66 // ST: Guess iw(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l44_c15 old_cw = cw(0,2); cw(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l44_c15 // Check ASSUME(active[iw(0,2)] == 0); ASSUME(active[cw(0,2)] == 0); ASSUME(sforbid(2,cw(0,2))== 0); ASSUME(iw(0,2) >= 0); ASSUME(iw(0,2) >= 0); ASSUME(cw(0,2) >= iw(0,2)); ASSUME(cw(0,2) >= old_cw); ASSUME(cw(0,2) >= cr(0,2)); ASSUME(cw(0,2) >= cl[0]); ASSUME(cw(0,2) >= cisb[0]); ASSUME(cw(0,2) >= cdy[0]); ASSUME(cw(0,2) >= cdl[0]); ASSUME(cw(0,2) >= cds[0]); ASSUME(cw(0,2) >= cctrl[0]); ASSUME(cw(0,2) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,2) = 0; mem(2,cw(0,2)) = 0; co(2,cw(0,2))+=1; delta(2,cw(0,2)) = -1; ASSUME(creturn[0] >= cw(0,2)); // store i32 0, i32* @atom_1_X2_0, align 4, !dbg !70, !tbaa !66 // ST: Guess iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l45_c15 old_cw = cw(0,3); cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l45_c15 // Check ASSUME(active[iw(0,3)] == 0); ASSUME(active[cw(0,3)] == 0); ASSUME(sforbid(3,cw(0,3))== 0); ASSUME(iw(0,3) >= 0); ASSUME(iw(0,3) >= 0); ASSUME(cw(0,3) >= iw(0,3)); ASSUME(cw(0,3) >= old_cw); ASSUME(cw(0,3) >= cr(0,3)); ASSUME(cw(0,3) >= cl[0]); ASSUME(cw(0,3) >= cisb[0]); ASSUME(cw(0,3) >= cdy[0]); ASSUME(cw(0,3) >= cdl[0]); ASSUME(cw(0,3) >= cds[0]); ASSUME(cw(0,3) >= cctrl[0]); ASSUME(cw(0,3) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,3) = 0; mem(3,cw(0,3)) = 0; co(3,cw(0,3))+=1; delta(3,cw(0,3)) = -1; ASSUME(creturn[0] >= cw(0,3)); // %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #6, !dbg !71 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,2+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,2+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[1] >= cdy[0]); // %call3 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #6, !dbg !72 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,2+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,2+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[2] >= cdy[0]); // %2 = load i64, i64* %thr0, align 8, !dbg !73, !tbaa !74 r3 = local_mem[0]; // %call4 = call i32 @pthread_join(i64 noundef %2, i8** noundef null), !dbg !76 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,2+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,2+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[1]); // %3 = load i64, i64* %thr1, align 8, !dbg !77, !tbaa !74 r4 = local_mem[1]; // %call5 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !78 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,2+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,2+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[2]); // %4 = load i32, i32* @atom_1_X0_1, align 4, !dbg !79, !tbaa !66 // LD: Guess old_cr = cr(0,2); cr(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l53_c12 // Check ASSUME(active[cr(0,2)] == 0); ASSUME(cr(0,2) >= iw(0,2)); ASSUME(cr(0,2) >= 0); ASSUME(cr(0,2) >= cdy[0]); ASSUME(cr(0,2) >= cisb[0]); ASSUME(cr(0,2) >= cdl[0]); ASSUME(cr(0,2) >= cl[0]); // Update creg_r5 = cr(0,2); crmax(0,2) = max(crmax(0,2),cr(0,2)); caddr[0] = max(caddr[0],0); if(cr(0,2) < cw(0,2)) { r5 = buff(0,2); ASSUME((!(( (cw(0,2) < 1) && (1 < crmax(0,2)) )))||(sforbid(2,1)> 0)); ASSUME((!(( (cw(0,2) < 2) && (2 < crmax(0,2)) )))||(sforbid(2,2)> 0)); ASSUME((!(( (cw(0,2) < 3) && (3 < crmax(0,2)) )))||(sforbid(2,3)> 0)); ASSUME((!(( (cw(0,2) < 4) && (4 < crmax(0,2)) )))||(sforbid(2,4)> 0)); } else { if(pw(0,2) != co(2,cr(0,2))) { ASSUME(cr(0,2) >= old_cr); } pw(0,2) = co(2,cr(0,2)); r5 = mem(2,cr(0,2)); } ASSUME(creturn[0] >= cr(0,2)); // call void @llvm.dbg.value(metadata i32 %4, metadata !107, metadata !DIExpression()), !dbg !110 // %5 = load i32, i32* @atom_1_X2_0, align 4, !dbg !80, !tbaa !66 // LD: Guess old_cr = cr(0,3); cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l54_c12 // Check ASSUME(active[cr(0,3)] == 0); ASSUME(cr(0,3) >= iw(0,3)); ASSUME(cr(0,3) >= 0); ASSUME(cr(0,3) >= cdy[0]); ASSUME(cr(0,3) >= cisb[0]); ASSUME(cr(0,3) >= cdl[0]); ASSUME(cr(0,3) >= cl[0]); // Update creg_r6 = cr(0,3); crmax(0,3) = max(crmax(0,3),cr(0,3)); caddr[0] = max(caddr[0],0); if(cr(0,3) < cw(0,3)) { r6 = buff(0,3); ASSUME((!(( (cw(0,3) < 1) && (1 < crmax(0,3)) )))||(sforbid(3,1)> 0)); ASSUME((!(( (cw(0,3) < 2) && (2 < crmax(0,3)) )))||(sforbid(3,2)> 0)); ASSUME((!(( (cw(0,3) < 3) && (3 < crmax(0,3)) )))||(sforbid(3,3)> 0)); ASSUME((!(( (cw(0,3) < 4) && (4 < crmax(0,3)) )))||(sforbid(3,4)> 0)); } else { if(pw(0,3) != co(3,cr(0,3))) { ASSUME(cr(0,3) >= old_cr); } pw(0,3) = co(3,cr(0,3)); r6 = mem(3,cr(0,3)); } ASSUME(creturn[0] >= cr(0,3)); // call void @llvm.dbg.value(metadata i32 %5, metadata !108, metadata !DIExpression()), !dbg !110 // %and = and i32 %4, %5, !dbg !81 creg_r7 = max(creg_r5,creg_r6); r7 = r5 & r6; // call void @llvm.dbg.value(metadata i32 %and, metadata !109, metadata !DIExpression()), !dbg !110 // %cmp = icmp eq i32 %and, 1, !dbg !82 creg__r7__1_ = max(0,creg_r7); // br i1 %cmp, label %if.then, label %if.end, !dbg !84 old_cctrl = cctrl[0]; cctrl[0] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[0] >= old_cctrl); ASSUME(cctrl[0] >= creg__r7__1_); if((r7==1)) { goto T0BLOCK1; } else { goto T0BLOCK2; } T0BLOCK1: // call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([105 x i8], [105 x i8]* @.str.1, i64 0, i64 0), i32 noundef 56, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #7, !dbg !85 // unreachable, !dbg !85 r8 = 1; goto T0BLOCK_END; T0BLOCK2: // %6 = bitcast i64* %thr1 to i8*, !dbg !88 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %6) #6, !dbg !88 // %7 = bitcast i64* %thr0 to i8*, !dbg !88 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %7) #6, !dbg !88 // ret i32 0, !dbg !89 ret_thread_0 = 0; goto T0BLOCK_END; T0BLOCK_END: ASSUME(meminit(0,1) == mem(0,0)); ASSUME(coinit(0,1) == co(0,0)); ASSUME(deltainit(0,1) == delta(0,0)); ASSUME(meminit(0,2) == mem(0,1)); ASSUME(coinit(0,2) == co(0,1)); ASSUME(deltainit(0,2) == delta(0,1)); ASSUME(meminit(0,3) == mem(0,2)); ASSUME(coinit(0,3) == co(0,2)); ASSUME(deltainit(0,3) == delta(0,2)); ASSUME(meminit(0,4) == mem(0,3)); ASSUME(coinit(0,4) == co(0,3)); ASSUME(deltainit(0,4) == delta(0,3)); ASSUME(meminit(1,1) == mem(1,0)); ASSUME(coinit(1,1) == co(1,0)); ASSUME(deltainit(1,1) == delta(1,0)); ASSUME(meminit(1,2) == mem(1,1)); ASSUME(coinit(1,2) == co(1,1)); ASSUME(deltainit(1,2) == delta(1,1)); ASSUME(meminit(1,3) == mem(1,2)); ASSUME(coinit(1,3) == co(1,2)); ASSUME(deltainit(1,3) == delta(1,2)); ASSUME(meminit(1,4) == mem(1,3)); ASSUME(coinit(1,4) == co(1,3)); ASSUME(deltainit(1,4) == delta(1,3)); ASSUME(meminit(2,1) == mem(2,0)); ASSUME(coinit(2,1) == co(2,0)); ASSUME(deltainit(2,1) == delta(2,0)); ASSUME(meminit(2,2) == mem(2,1)); ASSUME(coinit(2,2) == co(2,1)); ASSUME(deltainit(2,2) == delta(2,1)); ASSUME(meminit(2,3) == mem(2,2)); ASSUME(coinit(2,3) == co(2,2)); ASSUME(deltainit(2,3) == delta(2,2)); ASSUME(meminit(2,4) == mem(2,3)); ASSUME(coinit(2,4) == co(2,3)); ASSUME(deltainit(2,4) == delta(2,3)); ASSUME(meminit(3,1) == mem(3,0)); ASSUME(coinit(3,1) == co(3,0)); ASSUME(deltainit(3,1) == delta(3,0)); ASSUME(meminit(3,2) == mem(3,1)); ASSUME(coinit(3,2) == co(3,1)); ASSUME(deltainit(3,2) == delta(3,1)); ASSUME(meminit(3,3) == mem(3,2)); ASSUME(coinit(3,3) == co(3,2)); ASSUME(deltainit(3,3) == delta(3,2)); ASSUME(meminit(3,4) == mem(3,3)); ASSUME(coinit(3,4) == co(3,3)); ASSUME(deltainit(3,4) == delta(3,3)); ASSERT(r8== 0); }
[ "tuan-phong.ngo@it.uu.se" ]
tuan-phong.ngo@it.uu.se
20d741de63362954cd6c22711c4321aa1907affa
dec386dea0da2f307ea444a767b834516d3fcbc9
/MFCDemo/mfc1/mfc1.cpp
64a09263169c31374d8b75b0a56de39cc9359a3a
[]
no_license
chancelee/PBCWinDriversProject
4b18c439604e516ddc95a7970e8eef0d2e08c2a1
117756e821019a55a7893f1b2b98399930cf14c4
refs/heads/master
2022-03-20T01:44:35.487688
2019-12-06T14:28:59
2019-12-06T14:28:59
null
0
0
null
null
null
null
GB18030
C++
false
false
1,841
cpp
// mfc1.cpp : 定义应用程序的类行为。 // #include "stdafx.h" #include "mfc1.h" #include "mfc1Dlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // Cmfc1App BEGIN_MESSAGE_MAP(Cmfc1App, CWinApp) ON_COMMAND(ID_HELP, &CWinApp::OnHelp) END_MESSAGE_MAP() // Cmfc1App 构造 Cmfc1App::Cmfc1App() { // TODO: 在此处添加构造代码, // 将所有重要的初始化放置在 InitInstance 中 } // 唯一的一个 Cmfc1App 对象 Cmfc1App theApp; // Cmfc1App 初始化 BOOL Cmfc1App::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); AfxEnableControlContainer(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); Cmfc1Dlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此放置处理何时用 // “确定”来关闭对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用 // “取消”来关闭对话框的代码 } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }
[ "p0sixb1ackcat@gmail.com" ]
p0sixb1ackcat@gmail.com
056d18a1fa12d31c63c43043533d0f0cf0b53240
9185e2aefea655690f26571848cccd12a4145d2a
/BAT-0.9.3/include/BAT/BCSummaryPriorModel.h
d6a4eb2eb6aaf8b68235dc1c8261516081fe3675
[ "DOC" ]
permissive
yannmu/Gator_2020
f7460509f8df984bf3b895f0adc1e1964b16351f
8042371ec8d8ca63fe6b0fa75cf1ad6a90572ac4
refs/heads/master
2023-04-19T02:13:53.520283
2021-05-04T14:53:35
2021-05-04T14:53:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,837
h
#ifndef __BCSUMMARYPRIORMODEL__H #define __BCSUMMARYPRIORMODEL__H /*! * \class BCSummaryPriorModel * A helper class for the BCSummaryTool. * \brief A helper class for the BCSummaryTool. * \author Daniel Kollar * \author Kevin Kr&ouml;ninger * \version 1.0.0 * \date 15.02.2010 */ /* * Copyright (C) 2007-2013, the BAT core developer team * All rights reserved. * * For the licensing terms see doc/COPYING. * For documentation see http://mpp.mpg.de/bat */ // --------------------------------------------------------- #include <BAT/BCModel.h> // --------------------------------------------------------- class BCSummaryPriorModel : public BCModel { public: // Constructors and destructor /** * The default constructor. */ BCSummaryPriorModel(); /** * A constructor. * @param name The name of the model. */ BCSummaryPriorModel(const char * name); /** * The default destructor. */ ~BCSummaryPriorModel(); /** * Set a pointer to the model under study. * @param model The model under study. */ void SetModel(BCModel * model); /** * Calculates and returns the log of the prior probability at a * given point in parameter space. * @param parameters A vector of coordinates in the parameter space. * @return The prior probability. */ double LogAPrioriProbability(const std::vector<double> &parameters); /** * Calculates and returns the log of the Likelihood at a given point * in parameter space. * @param parameters A vector of coordinates in the parameter space. * @return The log likelihood. */ double LogLikelihood(const std::vector<double> &parameters); private: /** * A pointer to the model under study. */ BCModel * fTestModel; }; // --------------------------------------------------------- #endif
[ "grodriguesaraujo@protonmail.com" ]
grodriguesaraujo@protonmail.com
166bd21056b644dda40788484f9d45437121225e
54ba7685564c7d405b3349beccd814c7f42cc007
/Client/server.h
496aad3582d0c64c82f313c2026e3e536ec6f851
[]
no_license
minhtan58/Pratice1
6366efb1824dd0ea4c37de78cba9805bb8f7c84e
7cb94f09e5259b637562b00de680e7ac696d30ba
refs/heads/master
2018-12-10T17:03:30.027392
2018-09-26T17:47:52
2018-09-26T17:47:52
114,221,301
0
0
null
null
null
null
UTF-8
C++
false
false
394
h
#ifndef SERVER_H #define SERVER_H #include <QObject> #include <QTcpSocket> #include <QTcpServer> class server : public QObject { Q_OBJECT public: explicit server(QObject *parent = 0); //Q_INVOKABLE void receiveData(); Q_INVOKABLE void startServer(); private: QTcpServer *Server; signals: public slots: void newConnect(); void readData(); }; #endif // SERVER_H
[ "minhtan.tran@lge.com" ]
minhtan.tran@lge.com
985eaf0837f98d54b87174a8cce852d6771acd93
1242e452d47d1cb78444cc80c1bf7f394b14095b
/pkpluginmanager.cpp
3159b63bab766c9b350ce6f6ebaee61ecab711ac
[ "MIT" ]
permissive
chuckshaw/PresentationKit
a7dd66566c9ce5258337a1a22fe23bf02ca1132f
01ff56f06b3eb7dcf39b9c2ddd9b7d4ba4daf4b8
refs/heads/master
2016-09-05T09:09:49.432819
2012-03-31T05:22:45
2012-03-31T05:22:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
210
cpp
#include "pkpluginmanager.h" #include "presentationkit.h" PKPluginManager::PKPluginManager(PresentationKit *parent, const char* name) : PKManager(parent, name) { } PKPluginManager::~PKPluginManager() { }
[ "chuck.shaw@gmail.com" ]
chuck.shaw@gmail.com
133b019f005d431a834c6d89fc4df1d051bc90a9
23ae66f2a668367470adf11b08fff37dacb2badf
/src_cpp/lib/utils.cpp
1bbf6909887649d7f57233ffd4aa4e302d9cb1cc
[ "MIT", "BSD-3-Clause" ]
permissive
SmallJoker/ModIndexer
fff164cd98dbe0560e8341e211744e71873012ac
6932b9b6ac8a88d6fe5e52a04d3d265ca6243118
refs/heads/master
2023-04-12T22:14:40.222389
2023-04-07T08:25:03
2023-04-07T08:25:19
49,774,361
4
1
null
null
null
null
UTF-8
C++
false
false
701
cpp
#include "utils.h" #include <string.h> // Shameless copy std::string strtrim(const std::string &str) { size_t front = 0; while (std::isspace(str[front])) ++front; size_t back = str.size(); while (back > front && std::isspace(str[back - 1])) --back; return str.substr(front, back - front); } bool strequalsi(const std::string &a, const std::string &b) { if (a.size() != b.size()) return false; for (size_t i = 0; i < a.size(); ++i) if (tolower(a[i]) != tolower(b[i])) return false; return true; } size_t strfindi(std::string haystack, std::string needle) { for (char &c : haystack) c = tolower(c); for (char &c : needle) c = tolower(c); return haystack.rfind(needle); }
[ "mk939@ymail.com" ]
mk939@ymail.com
27857e54c5a0f44a39a435f47a5318c2bcd2afe5
ce497b404b38bdf2e2708fdfb870edcdef81866b
/cpp/LCM/GalaxyDB.hh
21f1028fde9a71ffbc1fb77b4cf0f2bc84fab8a2
[]
no_license
rjrivera/code-dojo
00e8c9ef5e2d3b1912c74c3afa0de66624eaa0e7
083bf5a4a41e9055dd78bc9be0a2d3b6f29651c3
refs/heads/master
2020-04-06T05:42:06.276739
2020-03-08T20:57:30
2020-03-08T20:57:30
28,792,381
0
3
null
2017-02-01T07:17:18
2015-01-05T01:35:42
C++
UTF-8
C++
false
false
1,534
hh
/* GalaxyDB DB of galaxy file information Created by: Noah Oblath Date: Jan 8, 2013 */ #include <map> #include <string> class GalaxyDB { public: typedef std::map< std::string, std::string > GalaxyFiles; private: typedef std::map< std::string, GalaxyFiles > FileMap; public: GalaxyDB(); GalaxyDB(const std::string& filename, const std::string& ltName="Label", const std::string& dirName="Dir", const std::string& dataPrefix="Data"); ~GalaxyDB(); bool LoadFile(const std::string& filename); bool DBIsReady() const; bool HasGalaxy(const std::string& galaxyLabel) const; bool HasGalaxyData(const std::string& galaxyDataLabel) const; const std::string& GetFile(const std::string& galaxyLabel, const std::string& fileType) const; const GalaxyFiles& GetFiles(const std::string& galaxyLabel) const; const std::string& GetDataFile(const std::string& galaxyLabel, const std::string& fileType) const; const GalaxyFiles& GetDataFiles(const std::string& galaxyLabel) const; const std::string& FileNotFound() const; const std::string& LabelTokenName() const; void SetLabelTokenName(const std::string& name); const std::string& DirTokenName() const; void SetDirTokenName(const std::string& name); private: bool AddGalaxy(const std::string& line); std::string Trim(const std::string& line, const std::string& whitespace = " \t"); FileMap galaxyFiles; FileMap galaxyDataFiles; std::string fileNotFound; std::string labelTokenName; std::string dirTokenName; std::string dataTokenPrefix; };
[ "rjrivera@mit.edu" ]
rjrivera@mit.edu
9ffc1cc1346dfa29e8f4667c44953b3588991806
850ae612a0b1cb7083a2ac46aa91a19534ee4a28
/test/renderer.cpp
e07abf7d37c00ddc81bd67a1efd89da1d01b1936
[ "MIT" ]
permissive
oskidan/nest
37178f4e4e779985f72511aa4ef36f4841383875
68b1c79d44be6c88ceae54c0b313fe8df5e7b826
refs/heads/master
2021-08-19T21:54:46.214147
2017-11-27T13:28:59
2017-11-27T13:28:59
111,437,715
3
0
null
null
null
null
UTF-8
C++
false
false
1,326
cpp
#include <cstdlib> #include <iostream> #include <nest/renderer.hpp> struct FakeContext final { bool valid = true; FakeContext() noexcept { std::cout << "FakeContext::FakeContext()\n"; } ~FakeContext() noexcept { if (valid) { std::cout << "FakeContext::~FakeContext()\n"; } } FakeContext(FakeContext&& that) : valid(that.valid) { that.valid = false; } void make_current() { if (valid) { std::cout << "make_current(FakeContext &)\n"; } } }; /* Build: g++ -std=c++17 -Wall -Werror -I. test/renderer.cpp Expected output: FakeContext::FakeContext() make_current(FakeContext &) Hello, World! Good bye, World! FakeContext::~FakeContext() */ int main(int const argc, char const* const argv[]) { FakeContext ctx; nest::AsyncRenderer renderer(std::move(ctx)); nest::AsyncRenderer::CommandQueue::Builder builder; renderer.submit(builder.enqueue([] { std::cout << "Hello, "; }).enqueue([] { std::cout << "World!\n"; })); renderer.submit(builder.enqueue([] { std::cout << "Good bye, "; }).enqueue([] { std::cout << "World!\n"; })); // Gives the renderer a chance to run. std::this_thread::sleep_for(std::chrono::seconds(1)); return EXIT_SUCCESS; }
[ "oleksii.skidan.contractor@weather.com, oleksii.skidan@ua.ibm.com" ]
oleksii.skidan.contractor@weather.com, oleksii.skidan@ua.ibm.com
f893a184e86891c008813d7be87c66c22ad99957
cf050ff01e829b0651617305e0655ba381740be8
/types.h
a46596ac00300218aa8016136f295c9d5c2fbb07
[ "MIT" ]
permissive
MichaelSchmidt82/kings-grid-olds
24669f018e64fd265bd92ebeb82cc0b8c111b7fb
f1188558c1920edff7c2e86b0e85ed98be8fb088
refs/heads/master
2021-05-03T08:09:00.126345
2019-01-08T22:49:47
2019-01-08T22:49:47
120,560,910
0
0
null
null
null
null
UTF-8
C++
false
false
629
h
#ifndef TYPES_H #define TYPES_H #include "globals.h" #include "BigInteger.hh" #include "node.h" using std::ofstream; using std::vector; using std::string; struct Element { Element() : prime(false) {}; int id; bool prime; bool operator == (const Element & rhs) const; bool operator != (const Element & lhs) const; bool operator < (const Element & rhs) const; }; struct Parameters { bool* pattern; Position pos; Distinguish distinguishingCallback; CoveredbyMethod gridCoveredByCallback; BigInteger maxRounds; Mode mode; int rows; int cols; int size; }; #endif // !TYPES_H
[ "michael.schmidt82@gmail.com" ]
michael.schmidt82@gmail.com
f051023bc4d083e5729e7ad6188de47af8696f40
af5120fc23e8a7d5176b2577bd00fcaca6d0a568
/packages/work1/src/main.cc
f2b84e650a52044f5eb5095be403ec6b1afd84b7
[]
no_license
WaMonk/OtusCPP
313d37f0e69249c9c6ff114eadca6552681ed226
71bb39a38bc8dec1f09137ac8e1640844853fed8
refs/heads/master
2020-06-03T10:20:33.053934
2019-09-27T13:47:15
2019-09-27T13:47:15
191,534,343
0
0
null
null
null
null
UTF-8
C++
false
false
124
cc
#include <iostream> #include <version.h> int main() { std::cout<<"Hello World. Version: "<<OTUS_VERSION<<std::endl; }
[ "besshiro@gmail.com" ]
besshiro@gmail.com
0b19e77758828d8acc361ee14df9d9ea78b0b8c5
6c6378908b56e241afc864b15da5a268ff608bf2
/TokenizerParser.h
0eb6cacb822bdf02887d0f44cf3f38a461d058cd
[]
no_license
TimParkSource/Reverse-Polish-Notation-Converter
2220932a347e0f2f856863a98a95882c2b645135
3c706504b67fbfb6abece89c934661d24ad7f455
refs/heads/master
2021-01-10T15:13:18.792081
2016-03-26T23:42:00
2016-03-26T23:42:00
54,804,034
0
0
null
null
null
null
UTF-8
C++
false
false
4,463
h
#ifndef TOKENIZER_PARSER_H #define TOKENIZER_PARSER_H #include <string> #include <cstring> // for strchr #include <list> #include <map> #include <iostream> #include <cassert> #include <cctype> #include <cmath> #include <cstdlib> using namespace std; /** *@author Satish Singhal Ph. D. *@version 1.0<BR><BR> *<B>Class Description</B><BR> *The class TokenizerParser has some basic static functions *that will help you to reduce the amount of code you will need to *write in experiment 4. The documentation gives you the *details of various member functions. The functions either *tokenize a STL string and return to you the number of space *delimited tokens in your postfix espression or parse the *neumeric strings for you. An example of using the class *TokenizerParser is show below.<BR> *<B>The main function</B><BR><BR> *#include "TokenizerParser.h"<BR> *const int MAX = 200;<BR> *void main()<BR> *{<BR> string num = string("-.33");<BR> double val = TokenizerParser::parseDouble(num);<BR> cout<<val<<endl;<BR> int value = TokenizerParser::parseInt(string("-35"));<BR> cout<<value<<endl;<BR> long num1 = TokenizerParser::parseLong(string("-200000000"));<BR> cout<<num1<<endl;<BR> string Str_Arr[MAX];<BR> string exp = " 4 2 + 3 5 1 - * + ";<BR> int count = 0;<BR> TokenizerParser::getStringArray(Str_Arr,exp,MAX,count);<BR> for(int index=0; index<count; index++)<BR> cout<<Str_Arr[index]<<endl;<BR> cout<<endl;<BR> }<BR><BR> <B> Output From Above main</B><BR> -0.33<BR> -35<BR> -200000000<BR> 4<BR> 2<BR> +<BR> 3<BR> 5<BR> 1<BR> -<BR> *<BR> +<BR> */ class TokenizerParser { protected: /** *Function is protected. So it is not to be called by the client. */ static void stringtok (list<string> &l, string const &s, char const * const ws = " \t\n"); public: /** *The function takes a string expression as an argument and returns *an array of tokens after stripping the white spaces from it. *Whitespaces may be tabs, newlines and blank characters. *For example if a string such as "Hello World I am here + you are there" is *sent to the function to be tokenized, then it will return by reference *an array with following strings in them:<BR> *Hello<BR> *World<BR> *I<BR> *am<BR> *here<BR> *+<BR> *you<BR> *are<BR> *there<BR> *The description of various parameters is as follows:<BR> *@param Str_Arr is the array of strings that contains the tokens extracted *from the string expression exp. *@param exp is the string to be tokenized. It may contain words or *alphanumeric characters and mathematical or logical operators. *@param MAX is the physical length of the array. <B>It is client's respnsibilty *to ascertain that number of tokens in the expression exp are smaller than *the physical length of the array Str_Arr. If physical length MAX is *smaller than the number of tokens to be extracted from the expression exp, then *token loss will take place.</B> *@param count is the number of tokens extracted from the string exp. The *maximum value of count is MAX. count is also the logical length of array * Str_Arr. */ static void getStringArray(string Str_Arr[], const string exp,int MAX, int&count); /** *The function parses the string form of a double type number passed to it *and returns its double value. *<B>It is client's responsibility to make sure that string passed to *the function contains a valid double data type. Invalid data type will *give unpredictable results</B>. *@param val is the string to be parsed into a double value. *@return the double value of string val. */ static double parseDouble(string val); /** *The function parses the string form of a integer type number passed to it *and returns its int value. *<B>It is client's responsibility to make sure that string passed to *the function contains a valid int data type. Invalid data type will *give unpredictable results</B>. *@param val is the string to be parsed into a int value. *@return the int value of string val. */ static int parseInt(string val); /** *The function parses the string form of a long type number passed to it *and returns its long value. *<B>It is client's responsibility to make sure that string passed to *the function contains a valid long data type. Invalid data type will *give unpredictable results</B>. *@param val is the string to be parsed into a long value. *@return the long value of string val. */ static long parseLong(string val); }; #endif
[ "timothy_park@outlook.com" ]
timothy_park@outlook.com
52c06dddc1f6e9c11e4b3399129a91a3043abbdb
9a2d6d19a98b4bd5e2017de04b63eb754c80b922
/src/libtsduck/tsPluginSharedLibrary.h
e9a81241ea1c0372a2727d10da56f24f725d295f
[ "WTFPL", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
jco1904/tsduck
dcc81083ae9362cbe2310451b41e4368eb51d197
cbd8859e71c93e809b2a8e1b52e07f8be1f8f78e
refs/heads/master
2020-05-15T18:42:33.421803
2019-04-20T16:28:18
2019-04-20T16:28:18
182,436,399
1
0
NOASSERTION
2019-04-20T17:40:29
2019-04-20T17:40:29
null
UTF-8
C++
false
false
3,695
h
//---------------------------------------------------------------------------- // // TSDuck - The MPEG Transport Stream Toolkit // Copyright (c) 2005-2019, Thierry Lelegard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. // //---------------------------------------------------------------------------- //! //! @file //! TSP plugin shared libraries //! //---------------------------------------------------------------------------- #pragma once #include "tsPlugin.h" #include "tsApplicationSharedLibrary.h" #include "tsCerrReport.h" #include "tsNullMutex.h" #include "tsSafePtr.h" namespace ts { //! //! Representation of a TSP plugin shared library. //! @ingroup plugin //! class TSDUCKDLL PluginSharedLibrary: public ApplicationSharedLibrary { public: //! //! Constructor. //! //! When the load is successful, the API version has been successfully checked //! and the tsp plugin API has been located. //! //! @param [in] filename Share library file name. Directory, "tsplugin_" prefix and suffix are optional. //! @param [in,out] report Where to report errors. //! explicit PluginSharedLibrary(const UString& filename, Report& report = CERR); //! //! Virtual destructor //! virtual ~PluginSharedLibrary(); //! //! Input plugin allocation function. //! If null, the plugin either does not provide input capability or is not a valid TSP plugin. //! NewInputProfile new_input; //! //! Output plugin allocation function. //! If null, the plugin either does not provide output capability or is not a valid TSP plugin. //! NewOutputProfile new_output; //! //! Packet processing plugin allocation function. //! If null, the plugin either does not provide packet processing capability or is not a valid TSP plugin. //! NewProcessorProfile new_processor; private: // Unreachable operations. PluginSharedLibrary() = delete; PluginSharedLibrary(const PluginSharedLibrary&) = delete; PluginSharedLibrary& operator=(const PluginSharedLibrary&) = delete; }; //! //! Safe pointer for PluginSharedLibrary (not thread-safe). //! typedef SafePtr <PluginSharedLibrary, NullMutex> PluginSharedLibraryPtr; }
[ "thierry@lelegard.fr" ]
thierry@lelegard.fr
5fc2b250daedfdcf21b4bbbd92216abb7d0bed74
4da447ec6b3541f205ea2191870a3133a4f6c772
/chrome/browser/ui/ash/holding_space/holding_space_downloads_delegate.cc
f29186ac2ffd69081272ca1c4bf286013a09b20d
[ "BSD-3-Clause" ]
permissive
SheffieldXie/chromium
7335468a01b9e7f3f11c6d92581bc20263fef987
92037961faa00056e1575ef0853d23cabc3a26bb
refs/heads/master
2022-12-09T19:33:26.603386
2020-10-07T11:46:41
2020-10-07T11:46:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,501
cc
// Copyright 2020 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/ui/ash/holding_space/holding_space_downloads_delegate.h" #include <vector> #include "ash/public/cpp/holding_space/holding_space_constants.h" #include "ash/public/cpp/holding_space/holding_space_prefs.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/ash/holding_space/holding_space_util.h" #include "content/public/browser/browser_context.h" namespace ash { namespace { content::DownloadManager* download_manager_for_testing = nullptr; // Helpers --------------------------------------------------------------------- // Returns true if `download` is sufficiently recent, false otherwise. bool IsRecentEnough(Profile* profile, const download::DownloadItem* download) { const base::Time end_time = download->GetEndTime(); // A `download` must be more recent than the time of the holding space feature // first becoming available. PrefService* prefs = profile->GetPrefs(); if (end_time < holding_space_prefs::GetTimeOfFirstAvailability(prefs).value()) return false; // A `download` must be more recent that `kMaxFileAge`. return end_time >= base::Time::Now() - kMaxFileAge; } } // namespace // HoldingSpaceDownloadsDelegate ----------------------------------------------- HoldingSpaceDownloadsDelegate::HoldingSpaceDownloadsDelegate( Profile* profile, HoldingSpaceModel* model, ItemDownloadedCallback item_downloaded_callback, DownloadsRestoredCallback downloads_restored_callback) : HoldingSpaceKeyedServiceDelegate(profile, model), item_downloaded_callback_(item_downloaded_callback), downloads_restored_callback_(std::move(downloads_restored_callback)) {} HoldingSpaceDownloadsDelegate::~HoldingSpaceDownloadsDelegate() = default; // static void HoldingSpaceDownloadsDelegate::SetDownloadManagerForTesting( content::DownloadManager* download_manager) { download_manager_for_testing = download_manager; } void HoldingSpaceDownloadsDelegate::Init() { download_manager_observer_.Add( download_manager_for_testing ? download_manager_for_testing : content::BrowserContext::GetDownloadManager(profile())); } void HoldingSpaceDownloadsDelegate::Shutdown() { RemoveObservers(); } void HoldingSpaceDownloadsDelegate::OnPersistenceRestored() { content::DownloadManager* download_manager = download_manager_for_testing ? download_manager_for_testing : content::BrowserContext::GetDownloadManager(profile()); if (download_manager->IsManagerInitialized()) OnManagerInitialized(); } void HoldingSpaceDownloadsDelegate::OnManagerInitialized() { if (is_restoring_persistence()) return; content::DownloadManager* download_manager = download_manager_for_testing ? download_manager_for_testing : content::BrowserContext::GetDownloadManager(profile()); DCHECK(download_manager->IsManagerInitialized()); download::SimpleDownloadManager::DownloadVector downloads; download_manager->GetAllDownloads(&downloads); std::vector<base::FilePath> file_paths; for (auto* download : downloads) { switch (download->GetState()) { case download::DownloadItem::COMPLETE: if (IsRecentEnough(profile(), download)) file_paths.push_back(download->GetFullPath()); break; case download::DownloadItem::IN_PROGRESS: download_item_observer_.Add(download); break; case download::DownloadItem::CANCELLED: case download::DownloadItem::INTERRUPTED: case download::DownloadItem::MAX_DOWNLOAD_STATE: break; } } holding_space_util::PartitionFilePathsByExistence( profile(), file_paths, base::BindOnce( [](const base::WeakPtr<HoldingSpaceDownloadsDelegate>& weak_ptr, std::vector<base::FilePath> existing_file_paths, std::vector<base::FilePath> non_existing_file_paths) { if (weak_ptr) { for (const auto& existing_file_path : existing_file_paths) weak_ptr->OnDownloadCompleted(existing_file_path); std::move(weak_ptr->downloads_restored_callback_).Run(); } }, weak_factory_.GetWeakPtr())); } void HoldingSpaceDownloadsDelegate::ManagerGoingDown( content::DownloadManager* manager) { RemoveObservers(); } void HoldingSpaceDownloadsDelegate::OnDownloadCreated( content::DownloadManager* manager, download::DownloadItem* item) { download_item_observer_.Add(item); } void HoldingSpaceDownloadsDelegate::OnDownloadUpdated( download::DownloadItem* item) { switch (item->GetState()) { case download::DownloadItem::COMPLETE: OnDownloadCompleted(item->GetFullPath()); FALLTHROUGH; case download::DownloadItem::CANCELLED: case download::DownloadItem::INTERRUPTED: download_item_observer_.Remove(item); break; case download::DownloadItem::IN_PROGRESS: case download::DownloadItem::MAX_DOWNLOAD_STATE: break; } } void HoldingSpaceDownloadsDelegate::OnDownloadCompleted( const base::FilePath& file_path) { if (!is_restoring_persistence()) item_downloaded_callback_.Run(file_path); } void HoldingSpaceDownloadsDelegate::RemoveObservers() { download_manager_observer_.RemoveAll(); download_item_observer_.RemoveAll(); } } // namespace ash
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
387f6fb5be532b1f93c3a44667b5c56ddbe22229
478f36652e30a544bb4d7c15329d4386bf2f0e5e
/src/slipif.cpp
a13eaad8146d015504c8304267b94df1543487d4
[ "BSD-3-Clause", "MIT" ]
permissive
cyrex562/Net-Loom
10d6035ad5ec72d1bb5d9665afd977dde15e28cc
df436c5b084722fb747283863fa8fbb8056e5c35
refs/heads/master
2020-06-10T01:28:31.422581
2019-08-18T21:50:46
2019-08-18T21:50:46
193,542,811
0
0
null
null
null
null
UTF-8
C++
false
false
16,792
cpp
/** * @file * SLIP Interface * */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the Institute 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 INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE 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 built upon the file: src/arch/rtxc/sioslip.c * * Author: Magnus Ivarsson <magnus.ivarsson(at)volvo.com> * Simon Goldschmidt */ /** * @defgroup slipif SLIP * @ingroup netifs * * This is an arch independent SLIP netif. The specific serial hooks must be * provided by another file. They are sio_open, sio_read/sio_tryread and sio_send * * Usage: This netif can be used in three ways:\n * 1) For NO_SYS==0, an RX thread can be used which blocks on sio_read() * until data is received.\n * 2) In your main loop, call slipif_poll() to check for new RX bytes, * completed packets are fed into netif->input().\n * 3) Call slipif_received_byte[s]() from your serial RX ISR and * slipif_process_rxqueue() from your main loop. ISR level decodes * packets and puts completed packets on a queue which is fed into * the stack from the main loop (needs SYS_LIGHTWEIGHT_PROT for * pbuf_alloc to work on ISR level!). * */ #include <slipif.h> #include <opt.h> #include <def.h> #include <packet_buffer.h> //#include <snmp.h> #include <sys.h> #include <sio.h> #include <lwip_debug.h> #define SLIP_END 0xC0 /* 0300: start and end of every packet */ #define SLIP_ESC 0xDB /* 0333: escape start (one byte escaped data follows) */ #define SLIP_ESC_END 0xDC /* 0334: following escape: original byte is 0xC0 (END) */ #define SLIP_ESC_ESC 0xDD /* 0335: following escape: original byte is 0xDB (ESC) */ /** Maximum packet size that is received by this netif */ constexpr auto SLIP_MAX_SIZE = 1500; enum SlipifRecvState { SLIP_RECV_NORMAL, SLIP_RECV_ESCAPE }; struct SlipifPriv { SioFd sd; /* q is the whole PacketBuffer chain for a packet, p is the current PacketBuffer in the chain */ // struct PacketBuffer *p, *q; uint8_t state; uint16_t i, recved; // struct PacketBuffer* rxpackets; }; /** * Send a PacketBuffer doing the necessary SLIP encapsulation * * Uses the serial layer's sio_send() * * @param netif the lwip network interface structure for this slipif * @param p the PacketBuffer chain packet to send * @return always returns ERR_OK since the serial layer does not provide return values */ static LwipStatus slipif_output(NetworkInterface* netif, struct PacketBuffer* p) { lwip_assert("netif != NULL", (netif != nullptr)); lwip_assert("netif->state != NULL", (netif->state != nullptr)); lwip_assert("p != NULL", (p != nullptr)); // Logf(true, ("slipif_output: sending %d bytes\n", p->tot_len)); struct SlipifPriv* priv = (struct SlipifPriv *)netif->state; /* Send PacketBuffer out on the serial I/O device. */ /* Start with packet delimiter. */ sio_send(SLIP_END, priv->sd); for (struct PacketBuffer* q = p; q != nullptr; q = q->next) { for (uint16_t i = 0; i < q->len; i++) { uint8_t c = ((uint8_t *)q->payload)[i]; switch (c) { case SLIP_END: /* need to escape this byte (0xC0 -> 0xDB, 0xDC) */ sio_send( SLIP_ESC, priv->sd); sio_send(SLIP_ESC_END, priv->sd); break; case SLIP_ESC: /* need to escape this byte (0xDB -> 0xDB, 0xDD) */ sio_send( SLIP_ESC, priv->sd); sio_send(SLIP_ESC_ESC, priv->sd); break; default: /* normal byte - no need for escaping */ sio_send(c, priv->sd); break; } } } /* End with packet delimiter. */ sio_send(SLIP_END, priv->sd); return STATUS_SUCCESS; } /** * Send a PacketBuffer doing the necessary SLIP encapsulation * * Uses the serial layer's sio_send() * * @param netif the lwip network interface structure for this slipif * @param p the PacketBuffer chain packet to send * @param ipaddr the ip address to send the packet to (not used for slipif) * @return always returns ERR_OK since the serial layer does not provide return values */ static LwipStatus slipif_output_v4(NetworkInterface* netif, struct PacketBuffer* p, const Ip4Addr* ipaddr) { return slipif_output(netif, p); } /** * Send a PacketBuffer doing the necessary SLIP encapsulation * * Uses the serial layer's sio_send() * * @param netif the lwip network interface structure for this slipif * @param p the PacketBuffer chain packet to send * @param ipaddr the ip address to send the packet to (not used for slipif) * @return always returns ERR_OK since the serial layer does not provide return values */ static LwipStatus slipif_output_v6(NetworkInterface* netif, struct PacketBuffer* p, const Ip6Addr* ipaddr) { return slipif_output(netif, p); } /** * Handle the incoming SLIP stream character by character * * @param netif the lwip network interface structure for this slipif * @param c received character (multiple calls to this function will * return a complete packet, NULL is returned before - used for polling) * @return The IP packet when SLIP_END is received */ static struct PacketBuffer* slipif_rxbyte(NetworkInterface* netif, uint8_t c) { lwip_assert("netif != NULL", (netif != nullptr)); lwip_assert("netif->state != NULL", (netif->state != nullptr)); struct SlipifPriv* priv = (struct SlipifPriv *)netif->state; switch (priv->state) { case SLIP_RECV_NORMAL: switch (c) { case SLIP_END: if (priv->recved > 0) { /* Received whole packet. */ /* Trim the PacketBuffer to the size of the received packet. */ // pbuf_realloc(priv->q); // LINK_STATS_INC(link.recv); // Logf(true, ("slipif: Got packet (%d bytes)\n", priv->recved)); struct PacketBuffer* t = priv->q; priv->pkt_buf = priv->q = nullptr; priv->i = priv->recved = 0; return t; } return nullptr; case SLIP_ESC: priv->state = SLIP_RECV_ESCAPE; return nullptr; default: break; } /* end switch (c) */ break; case SLIP_RECV_ESCAPE: /* un-escape END or ESC bytes, leave other bytes (although that would be a protocol error) */ switch (c) { case SLIP_ESC_END: c = SLIP_END; break; case SLIP_ESC_ESC: c = SLIP_ESC; break; default: break; } priv->state = SLIP_RECV_NORMAL; break; default: break; } /* end switch (priv->state) */ /* byte received, packet not yet completely received */ if (priv->pkt_buf == nullptr) { /* allocate a new PacketBuffer */ Logf(true, ("slipif_input: alloc\n")); // priv->p = pbuf_alloc(); if (priv->pkt_buf == nullptr) { Logf(true, ("slipif_input: no new PacketBuffer! (DROP)\n")); /* don't process any further since we got no PacketBuffer to receive to */ return nullptr; } if (priv->q != nullptr) { /* 'chain' the PacketBuffer to the existing chain */ // pbuf_cat(priv->q, priv->p); } else { /* p is the first PacketBuffer in the chain */ priv->q = priv->pkt_buf; } } /* this automatically drops bytes if > SLIP_MAX_SIZE */ if ((priv->pkt_buf != nullptr) && (priv->recved <= SLIP_MAX_SIZE)) { ((uint8_t *)priv->pkt_buf->payload)[priv->i] = c; priv->recved++; priv->i++; if (priv->i >= priv->pkt_buf->len) { /* on to the next PacketBuffer */ priv->i = 0; if (priv->pkt_buf->next != nullptr && priv->pkt_buf->next->len > 0) { /* p is a chain, on to the next in the chain */ priv->pkt_buf = priv->pkt_buf->next; } else { /* p is a single PacketBuffer, set it to NULL so next time a new * PacketBuffer is allocated */ priv->pkt_buf = nullptr; } } } return nullptr; } /** Like slipif_rxbyte, but passes completed packets to netif->input * * @param netif The lwip network interface structure for this slipif * @param c received character */ static void slipif_rxbyte_input(NetworkInterface* netif, uint8_t c) { struct PacketBuffer* p = slipif_rxbyte(netif, c); if (p != nullptr) { if (netif->input(p, netif) != STATUS_SUCCESS) { free_pkt_buf(p); } } } /** * The SLIP input thread. * * Feed the IP layer with incoming packets * * @param nf the lwip network interface structure for this slipif */ static void slipif_loop_thread(uint8_t* nf) { uint8_t c; NetworkInterface* netif = (NetworkInterface*)nf; struct SlipifPriv* priv = (struct SlipifPriv *)netif->state; while (true) { if (sio_read(priv->sd, &c, 1) > 0) { slipif_rxbyte_input(netif, c); } } } /** * @ingroup slipif * SLIP netif initialization * * Call the arch specific sio_open and remember * the opened device in the state field of the netif. * * @param netif the lwip network interface structure for this slipif * @return ERR_OK if serial line could be opened, * ERR_MEM if no memory could be allocated, * ERR_IF is serial line couldn't be opened * * @note If netif->state is interpreted as an uint8_t serial port number. * */ LwipStatus slipif_init(NetworkInterface* netif) { lwip_assert("slipif needs an input callback", netif->input != nullptr); /* netif->state contains serial port number */ uint8_t sio_num = (uint8_t)netif->state; // Logf(true, ("slipif_init: netif->num=%d\n", (uint16_t)sio_num)); /* Allocate private data */ struct SlipifPriv* priv = new struct SlipifPriv; if (!priv) { return ERR_MEM; } netif->name[0] = 's'; netif->name[1] = 'l'; netif->output = slipif_output_v4; netif->output_ip6 = slipif_output_v6; netif->mtu = SLIP_MAX_SIZE; /* Try to open the serial port. */ priv->sd = sio_open(sio_num); if (!priv->sd) { /* Opening the serial port failed. */ delete priv; return ERR_IF; } /* Initialize private data */ priv->pkt_buf = nullptr; priv->q = nullptr; priv->state = SLIP_RECV_NORMAL; priv->i = 0; priv->recved = 0; priv->rxpackets = nullptr; netif->state = priv; /* initialize the snmp variables and counters inside the NetworkInterface*/ // MIB2_INIT_NETIF(netif, snmp_ifType_slip, SLIP_SIO_SPEED(priv->sd)); /* Create a thread to poll the serial line. */ // fixme: // sys_thread_new(SLIPIF_THREAD_NAME, slipif_loop_thread, netif, // SLIPIF_THREAD_STACKSIZE, SLIPIF_THREAD_PRIO),; return STATUS_SUCCESS; } /** * @ingroup slipif * Polls the serial device and feeds the IP layer with incoming packets. * * @param netif The lwip network interface structure for this slipif */ void slipif_poll(NetworkInterface* netif) { uint8_t c; lwip_assert("netif != NULL", (netif != nullptr)); lwip_assert("netif->state != NULL", (netif->state != nullptr)); struct SlipifPriv* priv = (struct SlipifPriv *)netif->state; while (sio_tryread(priv->sd, &c, 1) > 0) { slipif_rxbyte_input(netif, c); } } /** * @ingroup slipif * Feeds the IP layer with incoming packets that were receive * * @param netif The lwip network interface structure for this slipif */ void slipif_process_rxqueue(NetworkInterface* netif) { lwip_assert("netif != NULL", (netif != nullptr)); lwip_assert("netif->state != NULL", (netif->state != nullptr)); struct SlipifPriv* priv = (struct SlipifPriv *)netif->state; // SYS_ARCH_PROTECT(old_level); while (priv->rxpackets != nullptr) { struct PacketBuffer* p = priv->rxpackets; /* dequeue packet */ struct PacketBuffer* q = p; while ((q->len != q->tot_len) && (q->next != nullptr)) { q = q->next; } priv->rxpackets = q->next; q->next = nullptr; // SYS_ARCH_UNPROTECT(old_level); if (netif->input(p, netif) != STATUS_SUCCESS) { free_pkt_buf(p); } // SYS_ARCH_PROTECT(old_level); while (priv->rxpackets != nullptr) { struct PacketBuffer* p = priv->rxpackets; /* dequeue packet */ struct PacketBuffer* q = p; while ((q->len != q->tot_len) && (q->next != nullptr)) { q = q->next; } priv->rxpackets = q->next; q->next = nullptr; // sys_arch_unprotect(old_level); if (netif->input(p, netif) != STATUS_SUCCESS) { free_pkt_buf(p); } // SYS_ARCH_PROTECT(old_level); } // sys_arch_unprotect(old_level); } } /** Like slipif_rxbyte, but queues completed packets. * * @param netif The lwip network interface structure for this slipif * @param data Received serial byte */ static void slipif_rxbyte_enqueue(NetworkInterface* netif, uint8_t data) { struct SlipifPriv* priv = (struct SlipifPriv *)netif->state; sys_prot_t old_level; struct PacketBuffer* p = slipif_rxbyte(netif, data); if (p != nullptr) { SYS_ARCH_PROTECT(old_level); if (priv->rxpackets != nullptr) { /* queue multiple pbufs */ struct PacketBuffer* q = p; while (q->next != nullptr) { q = q->next; } q->next = p; } else { priv->rxpackets = p; } SYS_ARCH_UNPROTECT(old_level); } } /** * @ingroup slipif * Process a received byte, completed packets are put on a queue that is * fed into IP through slipif_process_rxqueue(). * * This function can be called from ISR if SYS_LIGHTWEIGHT_PROT is enabled. * * @param netif The lwip network interface structure for this slipif * @param data received character */ void slipif_received_byte(NetworkInterface* netif, uint8_t data) { lwip_assert("netif != NULL", (netif != nullptr)); lwip_assert("netif->state != NULL", (netif->state != nullptr)); slipif_rxbyte_enqueue(netif, data); } /** * @ingroup slipif * Process multiple received byte, completed packets are put on a queue that is * fed into IP through slipif_process_rxqueue(). * * This function can be called from ISR if SYS_LIGHTWEIGHT_PROT is enabled. * * @param netif The lwip network interface structure for this slipif * @param data received character * @param len Number of received characters */ void slipif_received_bytes(NetworkInterface* netif, uint8_t* data, uint8_t len) { uint8_t* rxdata = data; lwip_assert("netif != NULL", (netif != nullptr)); lwip_assert("netif->state != NULL", (netif->state != nullptr)); for (uint8_t i = 0; i < len; i++, rxdata++) { slipif_rxbyte_enqueue(netif, *rxdata); } }
[ "cyrex562@gmail.com" ]
cyrex562@gmail.com
0e1773725be65955df9f89f12fc924470e336e10
b5e9ee331d96d9b5b43fe8653a96301af67cc95b
/opencv/src/external/qwt/qwt_system_clock.h
a9da1509102b3b525548f6b57a88b88f72f62f15
[]
no_license
joonhwan/study
531d3b0f3cb2c26dae9953f05a56a12305215f4a
e79490820e7c03bbfad58e7f9fd02a3f72783e67
refs/heads/master
2023-01-23T22:31:59.364783
2020-02-23T14:01:28
2020-02-23T14:01:28
4,001,896
9
2
null
2023-01-14T00:56:35
2012-04-12T06:19:31
C++
UTF-8
C++
false
false
1,364
h
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the Qwt License, Version 1.0 *****************************************************************************/ #ifndef QWT_SYSTEM_CLOCK_H #define QWT_SYSTEM_CLOCK_H #include "qwt_global.h" /*! \brief QwtSystemClock provides high resolution clock time functions. Sometimes the resolution offered by QTime ( millisecond ) is not accurate enough for implementing time measurements ( f.e. sampling ). QwtSystemClock offers a subset of the QTime functionality using higher resolution timers ( if possible ). Precision and time intervals are multiples of milliseconds (ms). \note The implementation uses high-resolution performance counter on Windows, mach_absolute_time() on the Mac or POSIX timers on other systems. If none is available it falls back on QTimer. */ class QWT_EXPORT QwtSystemClock { public: QwtSystemClock(); virtual ~QwtSystemClock(); bool isNull() const; void start(); double restart(); double elapsed() const; static double precision(); private: class PrivateData; PrivateData *d_data; }; #endif
[ "joonhwan.lee@gmail.com" ]
joonhwan.lee@gmail.com
3c947b24080d459fad44c1041c813d2c56a5289a
06e205fa8ce85d308b382eaf8ffbd24a0c965d80
/Dynamic Programming/LongestCommonSubsequence.cpp
8cbe75b79cfe5e82be71f5d4ddb47bea6581889b
[]
no_license
MSuha/Algorithms
5e1864cc016cb9c98498d0311236c9eb041d17b0
28480a0fc693b61fe95095b7b39de4e753e0c6a5
refs/heads/master
2020-07-27T08:37:20.537230
2019-10-10T20:54:41
2019-10-10T20:54:41
209,032,468
0
0
null
null
null
null
UTF-8
C++
false
false
708
cpp
#include <iostream> #include <string> using namespace std; int max(int a, int b){ if (a > b) return a; return b; } int LCS(string W, string V, int n, int m){ int CS[n+1][m+1]; for(int i = 0; i <= n; i++){ for(int j = 0; j <= m; j++){ if(i == 0 || j == 0){ CS[i][j] = 0; } else if(W[i] == V[j]){ CS[i][j] = CS[i-1][j-1] + 1; } else{ CS[i][j] = max(CS[i-1][j], CS[i][j-1]); } } } return CS[n][m]; } int main() { string a, b; int l, k, res; cin >> a >> b >> l >> k; res = LCS(a,b,l,k); cout << res; return res; }
[ "msuhademirel@gmail.com" ]
msuhademirel@gmail.com
7dba8ac45c0ca59091e38ee8b0039d0744b9b0bf
f1c51881adcec6a09cac6804f74f318081f1c928
/Renderer/src/renderer/CameraSystem.cpp
fd8d8b2e542639e475312844159f9e03d541b8c2
[]
no_license
haferflocken/ConductorEngine
aeffc7a4ddef9694e289faed387859756a00a5cf
4914e419e5a736275e96d76eaa19b7aa56d69345
refs/heads/master
2021-04-06T01:07:07.286785
2019-06-08T18:14:32
2019-06-08T18:14:36
124,838,006
0
0
null
null
null
null
UTF-8
C++
false
false
2,145
cpp
#include <renderer/CameraSystem.h> #include <bgfx/bgfx.h> #include <bx/math.h> namespace Renderer { void CameraSystem::Update(const Unit::Time::Millisecond delta, const Collection::ArrayView<ECSGroupType>& ecsGroups, Collection::Vector<std::function<void(ECS::EntityManager&)>>& deferredFunctions) { // Construct and apply a default camera for the scene view. { constexpr float k_defaultNearDistance = 0.1f; constexpr float k_defaultFarDistance = 100.0f; constexpr float k_defaultVerticalFOV = 60.0f; SubmitCamera( k_sceneViewID, Math::Matrix4x4(), k_defaultNearDistance, k_defaultFarDistance, k_defaultVerticalFOV); m_sceneViewFrustum = Math::Frustum(Math::Matrix4x4(), k_defaultNearDistance, k_defaultFarDistance, k_defaultVerticalFOV * bx::kPi / 180.0f, m_aspectRatio); } // Loop over all cameras in the scene and apply them. for (const auto& ecsGroup : ecsGroups) { const auto& transformComponent = ecsGroup.Get<const Scene::SceneTransformComponent>(); const auto& cameraComponent = ecsGroup.Get<const CameraComponent>(); SubmitCamera(cameraComponent.m_viewID, transformComponent.m_modelToWorldMatrix, cameraComponent.m_nearDistance, cameraComponent.m_farDistance, cameraComponent.m_verticalFieldOfView); if (cameraComponent.m_viewID == k_sceneViewID) { m_sceneViewFrustum = Math::Frustum(transformComponent.m_modelToWorldMatrix, cameraComponent.m_nearDistance, cameraComponent.m_farDistance, cameraComponent.m_verticalFieldOfView * bx::kPi / 180.0f, m_aspectRatio); } } } void CameraSystem::SubmitCamera(uint16_t viewID, const Math::Matrix4x4& cameraToWorldMatrix, float nearDistance, float farDistance, float verticalFOV) const { const bool homogeneousDepth = bgfx::getCaps()->homogeneousDepth; float viewMatrix[16]; bx::mtxInverse(viewMatrix, cameraToWorldMatrix.GetData()); float projectionMatrix[16]; bx::mtxProj(projectionMatrix, verticalFOV, m_aspectRatio, nearDistance, farDistance, homogeneousDepth); bgfx::setViewTransform(viewID, viewMatrix, projectionMatrix); bgfx::setViewRect(viewID, 0, 0, m_widthPixels, m_heightPixels); } }
[ "mooilo.ueu@gmail.com" ]
mooilo.ueu@gmail.com
285ab868659d006438be4461587bfce636f4b5c1
e4eb41b4640f9566f9c440e17ccf178f87323ac7
/App/Il2CppOutputProject/Source/lumpedcpp/Lump_libil2cpp_vm-utils.cpp
f27bd4b248ed83f6c99e36afffc7b46d8f5ba00f
[]
no_license
B17055/MRBreedingSimulator
b07aab0c83d29dcc5989a4da3e5710ea13ba6cc6
95e2a11296c9c4dc9a364cb075b12d5e5a4d3dbd
refs/heads/master
2023-03-03T20:38:35.515176
2021-02-11T09:09:06
2021-02-11T09:09:06
323,351,839
0
0
null
null
null
null
UTF-8
C++
false
false
690
cpp
#include "il2cpp-config.h" #include "C:\Users\Owner\Documents\Unity\Breeding Simulator MR\App\Il2CppOutputProject\IL2CPP\libil2cpp\vm-utils\BlobReader.cpp" #include "C:\Users\Owner\Documents\Unity\Breeding Simulator MR\App\Il2CppOutputProject\IL2CPP\libil2cpp\vm-utils\Debugger.cpp" #include "C:\Users\Owner\Documents\Unity\Breeding Simulator MR\App\Il2CppOutputProject\IL2CPP\libil2cpp\vm-utils\NativeDelegateMethodCache.cpp" #include "C:\Users\Owner\Documents\Unity\Breeding Simulator MR\App\Il2CppOutputProject\IL2CPP\libil2cpp\vm-utils\NativeSymbol.cpp" #include "C:\Users\Owner\Documents\Unity\Breeding Simulator MR\App\Il2CppOutputProject\IL2CPP\libil2cpp\vm-utils\VmStringUtils.cpp"
[ "e1b17055@oit.ac.jp" ]
e1b17055@oit.ac.jp
3d1e1f8b61fdfe28f78403a2d276da6dc8e8f1f2
12b0490737789f12296177bb8642c32f1158ebcb
/CppBasics/MD5/md5class.cpp
400214348a0e5648262a8b3e9344f0d24507c481
[]
no_license
dinodragon/mygooglecode
ef2775f09bed4fd583eec4524e3675bca150e5e3
1a5525ec6ef1b88f94af55a101d520e1aab83100
refs/heads/master
2021-01-10T12:05:09.301836
2013-03-25T04:02:32
2013-03-25T04:02:32
36,418,668
2
1
null
null
null
null
GB18030
C++
false
false
2,952
cpp
// md5class.cpp: implementation of the CMD5 class. //See internet RFC 1321, "The MD5 Message-Digest Algorithm" // //Use this code as you see fit. It is provided "as is" //without express or implied warranty of any kind. ////////////////////////////////////////////////////////////////////// #include "md5class.h" #include "md5.h" //declarations from RFC 1321 #include <string.h> #include <stdio.h> ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CMD5::CMD5() { m_digestValid = false; //we don't have a plaintext string yet m_digestString[32]=0; //the digest string is always 32 characters, so put a null in position 32 } CMD5::~CMD5() { } CMD5::CMD5(const char* plainText) { m_plainText = const_cast<char*>(plainText); //get a pointer to the plain text. If casting away the const-ness worries you, //you could make a local copy of the plain text string. m_digestString[32]=0; m_digestValid = calcDigest(); } ////////////////////////////////////////////////////////////////////// // Implementation ////////////////////////////////////////////////////////////////////// void CMD5::setPlainText(const char* plainText) { //set plaintext with a mutator, it's ok to //to call this multiple times. If casting away the const-ness of plainText //worries you, you could either make a local copy of the plain //text string instead of just pointing at the user's string, or //modify the RFC 1321 code to take 'const' plaintext, see example below. m_plainText = const_cast<char*>(plainText); m_digestValid = calcDigest(); } /* Use a function of this type with your favorite string class if casting away the const-ness of the user's text buffer violates you coding standards. void CMD5::setPlainText(CString& strPlainText) { static CString plaintext(strPlainText); m_plainText = strPlainText.GetBuffer(); m_digestValid = calcDigest(); } */ const char* CMD5::getMD5Digest() { //access message digest (aka hash), return 0 if plaintext has not been set if(m_digestValid) { return m_digestString; } else return 0; } bool CMD5::calcDigest() { //See RFC 1321 for details on how MD5Init, MD5Update, and MD5Final //calculate a digest for the plain text MD5_CTX context; MD5Init(&context); //the alternative to these ugly casts is to go into the RFC code and change the declarations MD5Update(&context, reinterpret_cast<unsigned char *>(m_plainText), ::strlen(m_plainText)); MD5Final(reinterpret_cast <unsigned char *>(m_digest),&context); //make a string version of the numeric digest value int p=0; for (int i = 0; i<16; i++) { //这一个方法一般就不用.yangfei. ::sprintf(&m_digestString[p],"%02x", m_digest[i]); p+=2; } return true; }
[ "yfsuoyou@3338bcd4-1a09-11de-8120-8d224146dbbc" ]
yfsuoyou@3338bcd4-1a09-11de-8120-8d224146dbbc
ba634a9ec6c832e88d9d281bf0f7f4e1d7ff8a19
9bcc292ded6290951daab9ec9bf0000df7677a85
/CT6024AdvancedAI/Source/CT6024AdvancedAI/Private/HealthKit.cpp
f88cd55550f5ed5e3463809f65dc7b58ce7df740
[]
no_license
MorganHJames/Unreal-Ai
1cf19aaf1270df8203e4e3ce07e95eb33640b90b
c245fd750e1de35d93169575e7d513205786c3a2
refs/heads/master
2022-03-30T18:43:13.441062
2019-12-24T13:00:57
2019-12-24T13:00:57
228,460,434
0
0
null
null
null
null
UTF-8
C++
false
false
2,514
cpp
//////////////////////////////////////////////////////////// // File: HealthKit.cpp // Author: Morgan Henry James // Date Created: ‎15 December ‎2019, ‏‎18:00:57 // Brief: Controls how health kits can be interacted with. //////////////////////////////////////////////////////////// #include "HealthKit.h" #include "Components/StaticMeshComponent.h" #include "Humanoid.h" // Sets default values. AHealthKit::AHealthKit() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; // The horizontal mesh of the health kit. horizontalMesh = CreateDefaultSubobject<UStaticMeshComponent>("horizontalMesh"); // Set the root. SetRootComponent(horizontalMesh); // The vertical mesh of the health kit. verticalMesh = CreateDefaultSubobject<UStaticMeshComponent>("verticalMesh"); } // Called when the game starts or when spawned. void AHealthKit::BeginPlay() { // Add the on health kit hit event to the health kit. OnActorHit.AddDynamic(this, &AHealthKit::OnHealthKitHit); // Set the starting location of the health kit. startingLocation = GetActorLocation(); Super::BeginPlay(); } // Called every frame. void AHealthKit::Tick(float a_deltaTime) { Super::Tick(a_deltaTime); // Sets the new location to the actors current location. FVector NewLocation = GetActorLocation(); // If the health should be going up. if (goingUp) { // Move the health kit up. NewLocation.Z += (a_deltaTime * floatingSpeed); // If the health kit is too high. if (NewLocation.Z - startingLocation.Z > floatingDistance) { // Indicate for the health kit to go down. goingUp = false; } } else { // Move the health kit down. NewLocation.Z -= (a_deltaTime * floatingSpeed); // If the health kit is too low. if (NewLocation.Z - startingLocation.Z < -floatingDistance) { // Indicate for the health kit to go up. goingUp = true; } } // Set the actors location to the new location. SetActorLocation(NewLocation); } // Heal the player if they collide with the health kit. void AHealthKit::OnHealthKitHit(AActor* a_selfActor, AActor* a_otherActor, FVector a_normalImpulse, const FHitResult& a_hit) { // Check if it hits something. if (a_otherActor) { // Check if it hits a human. AHumanoid* humanoid = Cast<AHumanoid>(a_otherActor); // If the actor is a humanoid. if (humanoid) { // Increase the hit humans health. humanoid->ChangeHealth(100.0f); } } }
[ "mojo@morganhjames.com" ]
mojo@morganhjames.com
3c56df6de4b42be9896c646280c532168c3d7df3
37695821fea740c507e60701a2781df027377212
/servicioSubdominio.h
755a5389c32a4f72a497aa8e8341d691d4af05c3
[]
no_license
rorra/phcp-cgi
25f16fbce411fb3c327a3bf4df9b26e398563a30
7588ba1c3f76c92a7509ffd2b7bc4e43519eae3c
refs/heads/master
2021-01-21T19:28:24.869430
2012-09-17T12:28:22
2012-09-17T12:28:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
897
h
#ifndef _SERVICIOSUBDOMINIO_H #define _SERVICIOSUBDOMINIO_H #include "servicio.h" #include "dominio.h" class cServicioSubdominio:public cServicio { public: //Constructor e iniciador cServicioSubdominio(cDominio *dominio); bool iniciar(); //Agrega un subdominio al sistema int agregarSubdominio(const std::string &, cDominio &, const std::string &); //Agrega un subdominio en la base de datos int agregarSubdominioDB(const std::string &, cDominio &); //Quita un subdominio del sistema int quitarSubdominio(const std::string &, cDominio &); //Quita un subdominio en la base de datos int quitarSubdominioDB(const std::string &, cDominio &); //Trae la cantidad del servicio std::string traerCantidad(); //Verifica la existencia de un Subdominio en la base de datos int verificarExisteSubdominioDB(const std::string &, cDominio &); }; #endif // _SERVICIOSUBDOMINIO_H
[ "rorra@rorra.com.ar" ]
rorra@rorra.com.ar
fa9aa74da3c3ba8f79f7af2e803c8c4f1a7b7d1a
c776476e9d06b3779d744641e758ac3a2c15cddc
/examples/litmus/c/run-scripts/tmp_1/SB+dmb.sy+rfi-addr-data-rfi.c.cbmc.cpp
823111c5bcf2e606ec48f3b07d8b4d1ea4287066
[]
no_license
ashutosh0gupta/llvm_bmc
aaac7961c723ba6f7ffd77a39559e0e52432eade
0287c4fb180244e6b3c599a9902507f05c8a7234
refs/heads/master
2023-08-02T17:14:06.178723
2023-07-31T10:46:53
2023-07-31T10:46:53
143,100,825
3
4
null
2023-05-25T05:50:55
2018-08-01T03:47:00
C++
UTF-8
C++
false
false
42,581
cpp
// 0:vars:3 // 3:atom_0_X2_0:1 // 4:atom_1_X2_1:1 // 5:atom_1_X8_1:1 // 6:thr0:1 // 7:thr1:1 #define ADDRSIZE 8 #define NPROC 3 #define NCONTEXT 1 #define ASSUME(stmt) __CPROVER_assume(stmt) #define ASSERT(stmt) __CPROVER_assert(stmt, "error") #define max(a,b) (a>b?a:b) char __get_rng(); char get_rng( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } char get_rng_th( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } int main(int argc, char **argv) { // declare arrays for intial value version in contexts int meminit_[ADDRSIZE*NCONTEXT]; #define meminit(x,k) meminit_[(x)*NCONTEXT+k] int coinit_[ADDRSIZE*NCONTEXT]; #define coinit(x,k) coinit_[(x)*NCONTEXT+k] int deltainit_[ADDRSIZE*NCONTEXT]; #define deltainit(x,k) deltainit_[(x)*NCONTEXT+k] // declare arrays for running value version in contexts int mem_[ADDRSIZE*NCONTEXT]; #define mem(x,k) mem_[(x)*NCONTEXT+k] int co_[ADDRSIZE*NCONTEXT]; #define co(x,k) co_[(x)*NCONTEXT+k] int delta_[ADDRSIZE*NCONTEXT]; #define delta(x,k) delta_[(x)*NCONTEXT+k] // declare arrays for local buffer and observed writes int buff_[NPROC*ADDRSIZE]; #define buff(x,k) buff_[(x)*ADDRSIZE+k] int pw_[NPROC*ADDRSIZE]; #define pw(x,k) pw_[(x)*ADDRSIZE+k] // declare arrays for context stamps char cr_[NPROC*ADDRSIZE]; #define cr(x,k) cr_[(x)*ADDRSIZE+k] char iw_[NPROC*ADDRSIZE]; #define iw(x,k) iw_[(x)*ADDRSIZE+k] char cw_[NPROC*ADDRSIZE]; #define cw(x,k) cw_[(x)*ADDRSIZE+k] char cx_[NPROC*ADDRSIZE]; #define cx(x,k) cx_[(x)*ADDRSIZE+k] char is_[NPROC*ADDRSIZE]; #define is(x,k) is_[(x)*ADDRSIZE+k] char cs_[NPROC*ADDRSIZE]; #define cs(x,k) cs_[(x)*ADDRSIZE+k] char crmax_[NPROC*ADDRSIZE]; #define crmax(x,k) crmax_[(x)*ADDRSIZE+k] char sforbid_[ADDRSIZE*NCONTEXT]; #define sforbid(x,k) sforbid_[(x)*NCONTEXT+k] // declare arrays for synchronizations int cl[NPROC]; int cdy[NPROC]; int cds[NPROC]; int cdl[NPROC]; int cisb[NPROC]; int caddr[NPROC]; int cctrl[NPROC]; int cstart[NPROC]; int creturn[NPROC]; // declare arrays for contexts activity int active[NCONTEXT]; int ctx_used[NCONTEXT]; __LOCALS__ buff(0,0) = 0; pw(0,0) = 0; cr(0,0) = 0; iw(0,0) = 0; cw(0,0) = 0; cx(0,0) = 0; is(0,0) = 0; cs(0,0) = 0; crmax(0,0) = 0; buff(0,1) = 0; pw(0,1) = 0; cr(0,1) = 0; iw(0,1) = 0; cw(0,1) = 0; cx(0,1) = 0; is(0,1) = 0; cs(0,1) = 0; crmax(0,1) = 0; buff(0,2) = 0; pw(0,2) = 0; cr(0,2) = 0; iw(0,2) = 0; cw(0,2) = 0; cx(0,2) = 0; is(0,2) = 0; cs(0,2) = 0; crmax(0,2) = 0; buff(0,3) = 0; pw(0,3) = 0; cr(0,3) = 0; iw(0,3) = 0; cw(0,3) = 0; cx(0,3) = 0; is(0,3) = 0; cs(0,3) = 0; crmax(0,3) = 0; buff(0,4) = 0; pw(0,4) = 0; cr(0,4) = 0; iw(0,4) = 0; cw(0,4) = 0; cx(0,4) = 0; is(0,4) = 0; cs(0,4) = 0; crmax(0,4) = 0; buff(0,5) = 0; pw(0,5) = 0; cr(0,5) = 0; iw(0,5) = 0; cw(0,5) = 0; cx(0,5) = 0; is(0,5) = 0; cs(0,5) = 0; crmax(0,5) = 0; buff(0,6) = 0; pw(0,6) = 0; cr(0,6) = 0; iw(0,6) = 0; cw(0,6) = 0; cx(0,6) = 0; is(0,6) = 0; cs(0,6) = 0; crmax(0,6) = 0; buff(0,7) = 0; pw(0,7) = 0; cr(0,7) = 0; iw(0,7) = 0; cw(0,7) = 0; cx(0,7) = 0; is(0,7) = 0; cs(0,7) = 0; crmax(0,7) = 0; cl[0] = 0; cdy[0] = 0; cds[0] = 0; cdl[0] = 0; cisb[0] = 0; caddr[0] = 0; cctrl[0] = 0; cstart[0] = get_rng(0,NCONTEXT-1); creturn[0] = get_rng(0,NCONTEXT-1); buff(1,0) = 0; pw(1,0) = 0; cr(1,0) = 0; iw(1,0) = 0; cw(1,0) = 0; cx(1,0) = 0; is(1,0) = 0; cs(1,0) = 0; crmax(1,0) = 0; buff(1,1) = 0; pw(1,1) = 0; cr(1,1) = 0; iw(1,1) = 0; cw(1,1) = 0; cx(1,1) = 0; is(1,1) = 0; cs(1,1) = 0; crmax(1,1) = 0; buff(1,2) = 0; pw(1,2) = 0; cr(1,2) = 0; iw(1,2) = 0; cw(1,2) = 0; cx(1,2) = 0; is(1,2) = 0; cs(1,2) = 0; crmax(1,2) = 0; buff(1,3) = 0; pw(1,3) = 0; cr(1,3) = 0; iw(1,3) = 0; cw(1,3) = 0; cx(1,3) = 0; is(1,3) = 0; cs(1,3) = 0; crmax(1,3) = 0; buff(1,4) = 0; pw(1,4) = 0; cr(1,4) = 0; iw(1,4) = 0; cw(1,4) = 0; cx(1,4) = 0; is(1,4) = 0; cs(1,4) = 0; crmax(1,4) = 0; buff(1,5) = 0; pw(1,5) = 0; cr(1,5) = 0; iw(1,5) = 0; cw(1,5) = 0; cx(1,5) = 0; is(1,5) = 0; cs(1,5) = 0; crmax(1,5) = 0; buff(1,6) = 0; pw(1,6) = 0; cr(1,6) = 0; iw(1,6) = 0; cw(1,6) = 0; cx(1,6) = 0; is(1,6) = 0; cs(1,6) = 0; crmax(1,6) = 0; buff(1,7) = 0; pw(1,7) = 0; cr(1,7) = 0; iw(1,7) = 0; cw(1,7) = 0; cx(1,7) = 0; is(1,7) = 0; cs(1,7) = 0; crmax(1,7) = 0; cl[1] = 0; cdy[1] = 0; cds[1] = 0; cdl[1] = 0; cisb[1] = 0; caddr[1] = 0; cctrl[1] = 0; cstart[1] = get_rng(0,NCONTEXT-1); creturn[1] = get_rng(0,NCONTEXT-1); buff(2,0) = 0; pw(2,0) = 0; cr(2,0) = 0; iw(2,0) = 0; cw(2,0) = 0; cx(2,0) = 0; is(2,0) = 0; cs(2,0) = 0; crmax(2,0) = 0; buff(2,1) = 0; pw(2,1) = 0; cr(2,1) = 0; iw(2,1) = 0; cw(2,1) = 0; cx(2,1) = 0; is(2,1) = 0; cs(2,1) = 0; crmax(2,1) = 0; buff(2,2) = 0; pw(2,2) = 0; cr(2,2) = 0; iw(2,2) = 0; cw(2,2) = 0; cx(2,2) = 0; is(2,2) = 0; cs(2,2) = 0; crmax(2,2) = 0; buff(2,3) = 0; pw(2,3) = 0; cr(2,3) = 0; iw(2,3) = 0; cw(2,3) = 0; cx(2,3) = 0; is(2,3) = 0; cs(2,3) = 0; crmax(2,3) = 0; buff(2,4) = 0; pw(2,4) = 0; cr(2,4) = 0; iw(2,4) = 0; cw(2,4) = 0; cx(2,4) = 0; is(2,4) = 0; cs(2,4) = 0; crmax(2,4) = 0; buff(2,5) = 0; pw(2,5) = 0; cr(2,5) = 0; iw(2,5) = 0; cw(2,5) = 0; cx(2,5) = 0; is(2,5) = 0; cs(2,5) = 0; crmax(2,5) = 0; buff(2,6) = 0; pw(2,6) = 0; cr(2,6) = 0; iw(2,6) = 0; cw(2,6) = 0; cx(2,6) = 0; is(2,6) = 0; cs(2,6) = 0; crmax(2,6) = 0; buff(2,7) = 0; pw(2,7) = 0; cr(2,7) = 0; iw(2,7) = 0; cw(2,7) = 0; cx(2,7) = 0; is(2,7) = 0; cs(2,7) = 0; crmax(2,7) = 0; cl[2] = 0; cdy[2] = 0; cds[2] = 0; cdl[2] = 0; cisb[2] = 0; caddr[2] = 0; cctrl[2] = 0; cstart[2] = get_rng(0,NCONTEXT-1); creturn[2] = get_rng(0,NCONTEXT-1); // Dumping initializations mem(0+0,0) = 0; mem(0+1,0) = 0; mem(0+2,0) = 0; mem(3+0,0) = 0; mem(4+0,0) = 0; mem(5+0,0) = 0; mem(6+0,0) = 0; mem(7+0,0) = 0; // Dumping context matching equalities co(0,0) = 0; delta(0,0) = -1; co(1,0) = 0; delta(1,0) = -1; co(2,0) = 0; delta(2,0) = -1; co(3,0) = 0; delta(3,0) = -1; co(4,0) = 0; delta(4,0) = -1; co(5,0) = 0; delta(5,0) = -1; co(6,0) = 0; delta(6,0) = -1; co(7,0) = 0; delta(7,0) = -1; // Dumping thread 1 int ret_thread_1 = 0; cdy[1] = get_rng(0,NCONTEXT-1); ASSUME(cdy[1] >= cstart[1]); T1BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !37, metadata !DIExpression()), !dbg !52 // br label %label_1, !dbg !53 goto T1BLOCK1; T1BLOCK1: // call void @llvm.dbg.label(metadata !51), !dbg !54 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !38, metadata !DIExpression()), !dbg !55 // call void @llvm.dbg.value(metadata i64 2, metadata !41, metadata !DIExpression()), !dbg !55 // store atomic i64 2, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !56 // ST: Guess iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,0); cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // Check ASSUME(active[iw(1,0)] == 1); ASSUME(active[cw(1,0)] == 1); ASSUME(sforbid(0,cw(1,0))== 0); ASSUME(iw(1,0) >= 0); ASSUME(iw(1,0) >= 0); ASSUME(cw(1,0) >= iw(1,0)); ASSUME(cw(1,0) >= old_cw); ASSUME(cw(1,0) >= cr(1,0)); ASSUME(cw(1,0) >= cl[1]); ASSUME(cw(1,0) >= cisb[1]); ASSUME(cw(1,0) >= cdy[1]); ASSUME(cw(1,0) >= cdl[1]); ASSUME(cw(1,0) >= cds[1]); ASSUME(cw(1,0) >= cctrl[1]); ASSUME(cw(1,0) >= caddr[1]); // Update caddr[1] = max(caddr[1],0); buff(1,0) = 2; mem(0,cw(1,0)) = 2; co(0,cw(1,0))+=1; delta(0,cw(1,0)) = -1; ASSUME(creturn[1] >= cw(1,0)); // call void (...) @dmbsy(), !dbg !57 // dumbsy: Guess old_cdy = cdy[1]; cdy[1] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[1] >= old_cdy); ASSUME(cdy[1] >= cisb[1]); ASSUME(cdy[1] >= cdl[1]); ASSUME(cdy[1] >= cds[1]); ASSUME(cdy[1] >= cctrl[1]); ASSUME(cdy[1] >= cw(1,0+0)); ASSUME(cdy[1] >= cw(1,0+1)); ASSUME(cdy[1] >= cw(1,0+2)); ASSUME(cdy[1] >= cw(1,3+0)); ASSUME(cdy[1] >= cw(1,4+0)); ASSUME(cdy[1] >= cw(1,5+0)); ASSUME(cdy[1] >= cw(1,6+0)); ASSUME(cdy[1] >= cw(1,7+0)); ASSUME(cdy[1] >= cr(1,0+0)); ASSUME(cdy[1] >= cr(1,0+1)); ASSUME(cdy[1] >= cr(1,0+2)); ASSUME(cdy[1] >= cr(1,3+0)); ASSUME(cdy[1] >= cr(1,4+0)); ASSUME(cdy[1] >= cr(1,5+0)); ASSUME(cdy[1] >= cr(1,6+0)); ASSUME(cdy[1] >= cr(1,7+0)); ASSUME(creturn[1] >= cdy[1]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !44, metadata !DIExpression()), !dbg !58 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !59 // LD: Guess old_cr = cr(1,0+1*1); cr(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN LDCOM // Check ASSUME(active[cr(1,0+1*1)] == 1); ASSUME(cr(1,0+1*1) >= iw(1,0+1*1)); ASSUME(cr(1,0+1*1) >= 0); ASSUME(cr(1,0+1*1) >= cdy[1]); ASSUME(cr(1,0+1*1) >= cisb[1]); ASSUME(cr(1,0+1*1) >= cdl[1]); ASSUME(cr(1,0+1*1) >= cl[1]); // Update creg_r0 = cr(1,0+1*1); crmax(1,0+1*1) = max(crmax(1,0+1*1),cr(1,0+1*1)); caddr[1] = max(caddr[1],0); if(cr(1,0+1*1) < cw(1,0+1*1)) { r0 = buff(1,0+1*1); } else { if(pw(1,0+1*1) != co(0+1*1,cr(1,0+1*1))) { ASSUME(cr(1,0+1*1) >= old_cr); } pw(1,0+1*1) = co(0+1*1,cr(1,0+1*1)); r0 = mem(0+1*1,cr(1,0+1*1)); } ASSUME(creturn[1] >= cr(1,0+1*1)); // call void @llvm.dbg.value(metadata i64 %0, metadata !46, metadata !DIExpression()), !dbg !58 // %conv = trunc i64 %0 to i32, !dbg !60 // call void @llvm.dbg.value(metadata i32 %conv, metadata !42, metadata !DIExpression()), !dbg !52 // %cmp = icmp eq i32 %conv, 0, !dbg !61 // %conv1 = zext i1 %cmp to i32, !dbg !61 // call void @llvm.dbg.value(metadata i32 %conv1, metadata !47, metadata !DIExpression()), !dbg !52 // call void @llvm.dbg.value(metadata i64* @atom_0_X2_0, metadata !48, metadata !DIExpression()), !dbg !62 // %1 = zext i32 %conv1 to i64 // call void @llvm.dbg.value(metadata i64 %1, metadata !50, metadata !DIExpression()), !dbg !62 // store atomic i64 %1, i64* @atom_0_X2_0 seq_cst, align 8, !dbg !63 // ST: Guess iw(1,3) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,3); cw(1,3) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // Check ASSUME(active[iw(1,3)] == 1); ASSUME(active[cw(1,3)] == 1); ASSUME(sforbid(3,cw(1,3))== 0); ASSUME(iw(1,3) >= max(creg_r0,0)); ASSUME(iw(1,3) >= 0); ASSUME(cw(1,3) >= iw(1,3)); ASSUME(cw(1,3) >= old_cw); ASSUME(cw(1,3) >= cr(1,3)); ASSUME(cw(1,3) >= cl[1]); ASSUME(cw(1,3) >= cisb[1]); ASSUME(cw(1,3) >= cdy[1]); ASSUME(cw(1,3) >= cdl[1]); ASSUME(cw(1,3) >= cds[1]); ASSUME(cw(1,3) >= cctrl[1]); ASSUME(cw(1,3) >= caddr[1]); // Update caddr[1] = max(caddr[1],0); buff(1,3) = (r0==0); mem(3,cw(1,3)) = (r0==0); co(3,cw(1,3))+=1; delta(3,cw(1,3)) = -1; ASSUME(creturn[1] >= cw(1,3)); // ret i8* null, !dbg !64 ret_thread_1 = (- 1); // Dumping thread 2 int ret_thread_2 = 0; cdy[2] = get_rng(0,NCONTEXT-1); ASSUME(cdy[2] >= cstart[2]); T2BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !67, metadata !DIExpression()), !dbg !98 // br label %label_2, !dbg !71 goto T2BLOCK1; T2BLOCK1: // call void @llvm.dbg.label(metadata !97), !dbg !100 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !68, metadata !DIExpression()), !dbg !101 // call void @llvm.dbg.value(metadata i64 1, metadata !70, metadata !DIExpression()), !dbg !101 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !74 // ST: Guess iw(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,0+1*1); cw(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,0+1*1)] == 2); ASSUME(active[cw(2,0+1*1)] == 2); ASSUME(sforbid(0+1*1,cw(2,0+1*1))== 0); ASSUME(iw(2,0+1*1) >= 0); ASSUME(iw(2,0+1*1) >= 0); ASSUME(cw(2,0+1*1) >= iw(2,0+1*1)); ASSUME(cw(2,0+1*1) >= old_cw); ASSUME(cw(2,0+1*1) >= cr(2,0+1*1)); ASSUME(cw(2,0+1*1) >= cl[2]); ASSUME(cw(2,0+1*1) >= cisb[2]); ASSUME(cw(2,0+1*1) >= cdy[2]); ASSUME(cw(2,0+1*1) >= cdl[2]); ASSUME(cw(2,0+1*1) >= cds[2]); ASSUME(cw(2,0+1*1) >= cctrl[2]); ASSUME(cw(2,0+1*1) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,0+1*1) = 1; mem(0+1*1,cw(2,0+1*1)) = 1; co(0+1*1,cw(2,0+1*1))+=1; delta(0+1*1,cw(2,0+1*1)) = -1; ASSUME(creturn[2] >= cw(2,0+1*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !72, metadata !DIExpression()), !dbg !103 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !76 // LD: Guess old_cr = cr(2,0+1*1); cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,0+1*1)] == 2); ASSUME(cr(2,0+1*1) >= iw(2,0+1*1)); ASSUME(cr(2,0+1*1) >= 0); ASSUME(cr(2,0+1*1) >= cdy[2]); ASSUME(cr(2,0+1*1) >= cisb[2]); ASSUME(cr(2,0+1*1) >= cdl[2]); ASSUME(cr(2,0+1*1) >= cl[2]); // Update creg_r1 = cr(2,0+1*1); crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1)); caddr[2] = max(caddr[2],0); if(cr(2,0+1*1) < cw(2,0+1*1)) { r1 = buff(2,0+1*1); } else { if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) { ASSUME(cr(2,0+1*1) >= old_cr); } pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1)); r1 = mem(0+1*1,cr(2,0+1*1)); } ASSUME(creturn[2] >= cr(2,0+1*1)); // call void @llvm.dbg.value(metadata i64 %0, metadata !74, metadata !DIExpression()), !dbg !103 // %conv = trunc i64 %0 to i32, !dbg !77 // call void @llvm.dbg.value(metadata i32 %conv, metadata !71, metadata !DIExpression()), !dbg !98 // %xor = xor i32 %conv, %conv, !dbg !78 creg_r2 = max(creg_r1,creg_r1); ASSUME(active[creg_r2] == 2); r2 = r1 ^ r1; // call void @llvm.dbg.value(metadata i32 %xor, metadata !75, metadata !DIExpression()), !dbg !98 // %add = add nsw i32 2, %xor, !dbg !79 creg_r3 = max(0,creg_r2); ASSUME(active[creg_r3] == 2); r3 = 2 + r2; // %idxprom = sext i32 %add to i64, !dbg !79 // %arrayidx = getelementptr inbounds [3 x i64], [3 x i64]* @vars, i64 0, i64 %idxprom, !dbg !79 r4 = 0+r3*1; ASSUME(creg_r4 >= 0); ASSUME(creg_r4 >= creg_r3); ASSUME(active[creg_r4] == 2); // call void @llvm.dbg.value(metadata i64* %arrayidx, metadata !77, metadata !DIExpression()), !dbg !108 // %1 = load atomic i64, i64* %arrayidx monotonic, align 8, !dbg !79 // LD: Guess old_cr = cr(2,r4); cr(2,r4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,r4)] == 2); ASSUME(cr(2,r4) >= iw(2,r4)); ASSUME(cr(2,r4) >= creg_r4); ASSUME(cr(2,r4) >= cdy[2]); ASSUME(cr(2,r4) >= cisb[2]); ASSUME(cr(2,r4) >= cdl[2]); ASSUME(cr(2,r4) >= cl[2]); // Update creg_r5 = cr(2,r4); crmax(2,r4) = max(crmax(2,r4),cr(2,r4)); caddr[2] = max(caddr[2],creg_r4); if(cr(2,r4) < cw(2,r4)) { r5 = buff(2,r4); } else { if(pw(2,r4) != co(r4,cr(2,r4))) { ASSUME(cr(2,r4) >= old_cr); } pw(2,r4) = co(r4,cr(2,r4)); r5 = mem(r4,cr(2,r4)); } ASSUME(creturn[2] >= cr(2,r4)); // call void @llvm.dbg.value(metadata i64 %1, metadata !79, metadata !DIExpression()), !dbg !108 // %conv4 = trunc i64 %1 to i32, !dbg !81 // call void @llvm.dbg.value(metadata i32 %conv4, metadata !76, metadata !DIExpression()), !dbg !98 // %xor5 = xor i32 %conv4, %conv4, !dbg !82 creg_r6 = max(creg_r5,creg_r5); ASSUME(active[creg_r6] == 2); r6 = r5 ^ r5; // call void @llvm.dbg.value(metadata i32 %xor5, metadata !80, metadata !DIExpression()), !dbg !98 // %add6 = add nsw i32 %xor5, 1, !dbg !83 creg_r7 = max(creg_r6,0); ASSUME(active[creg_r7] == 2); r7 = r6 + 1; // call void @llvm.dbg.value(metadata i32 %add6, metadata !81, metadata !DIExpression()), !dbg !98 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !82, metadata !DIExpression()), !dbg !112 // %conv9 = sext i32 %add6 to i64, !dbg !85 // call void @llvm.dbg.value(metadata i64 %conv9, metadata !84, metadata !DIExpression()), !dbg !112 // store atomic i64 %conv9, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !85 // ST: Guess iw(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,0); cw(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,0)] == 2); ASSUME(active[cw(2,0)] == 2); ASSUME(sforbid(0,cw(2,0))== 0); ASSUME(iw(2,0) >= creg_r7); ASSUME(iw(2,0) >= 0); ASSUME(cw(2,0) >= iw(2,0)); ASSUME(cw(2,0) >= old_cw); ASSUME(cw(2,0) >= cr(2,0)); ASSUME(cw(2,0) >= cl[2]); ASSUME(cw(2,0) >= cisb[2]); ASSUME(cw(2,0) >= cdy[2]); ASSUME(cw(2,0) >= cdl[2]); ASSUME(cw(2,0) >= cds[2]); ASSUME(cw(2,0) >= cctrl[2]); ASSUME(cw(2,0) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,0) = r7; mem(0,cw(2,0)) = r7; co(0,cw(2,0))+=1; delta(0,cw(2,0)) = -1; ASSUME(creturn[2] >= cw(2,0)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !86, metadata !DIExpression()), !dbg !114 // %2 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !87 // LD: Guess old_cr = cr(2,0); cr(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,0)] == 2); ASSUME(cr(2,0) >= iw(2,0)); ASSUME(cr(2,0) >= 0); ASSUME(cr(2,0) >= cdy[2]); ASSUME(cr(2,0) >= cisb[2]); ASSUME(cr(2,0) >= cdl[2]); ASSUME(cr(2,0) >= cl[2]); // Update creg_r8 = cr(2,0); crmax(2,0) = max(crmax(2,0),cr(2,0)); caddr[2] = max(caddr[2],0); if(cr(2,0) < cw(2,0)) { r8 = buff(2,0); } else { if(pw(2,0) != co(0,cr(2,0))) { ASSUME(cr(2,0) >= old_cr); } pw(2,0) = co(0,cr(2,0)); r8 = mem(0,cr(2,0)); } ASSUME(creturn[2] >= cr(2,0)); // call void @llvm.dbg.value(metadata i64 %2, metadata !88, metadata !DIExpression()), !dbg !114 // %conv13 = trunc i64 %2 to i32, !dbg !88 // call void @llvm.dbg.value(metadata i32 %conv13, metadata !85, metadata !DIExpression()), !dbg !98 // %cmp = icmp eq i32 %conv, 1, !dbg !89 // %conv14 = zext i1 %cmp to i32, !dbg !89 // call void @llvm.dbg.value(metadata i32 %conv14, metadata !89, metadata !DIExpression()), !dbg !98 // call void @llvm.dbg.value(metadata i64* @atom_1_X2_1, metadata !90, metadata !DIExpression()), !dbg !118 // %3 = zext i32 %conv14 to i64 // call void @llvm.dbg.value(metadata i64 %3, metadata !92, metadata !DIExpression()), !dbg !118 // store atomic i64 %3, i64* @atom_1_X2_1 seq_cst, align 8, !dbg !91 // ST: Guess iw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,4); cw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,4)] == 2); ASSUME(active[cw(2,4)] == 2); ASSUME(sforbid(4,cw(2,4))== 0); ASSUME(iw(2,4) >= max(creg_r1,0)); ASSUME(iw(2,4) >= 0); ASSUME(cw(2,4) >= iw(2,4)); ASSUME(cw(2,4) >= old_cw); ASSUME(cw(2,4) >= cr(2,4)); ASSUME(cw(2,4) >= cl[2]); ASSUME(cw(2,4) >= cisb[2]); ASSUME(cw(2,4) >= cdy[2]); ASSUME(cw(2,4) >= cdl[2]); ASSUME(cw(2,4) >= cds[2]); ASSUME(cw(2,4) >= cctrl[2]); ASSUME(cw(2,4) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,4) = (r1==1); mem(4,cw(2,4)) = (r1==1); co(4,cw(2,4))+=1; delta(4,cw(2,4)) = -1; ASSUME(creturn[2] >= cw(2,4)); // %cmp18 = icmp eq i32 %conv13, 1, !dbg !92 // %conv19 = zext i1 %cmp18 to i32, !dbg !92 // call void @llvm.dbg.value(metadata i32 %conv19, metadata !93, metadata !DIExpression()), !dbg !98 // call void @llvm.dbg.value(metadata i64* @atom_1_X8_1, metadata !94, metadata !DIExpression()), !dbg !121 // %4 = zext i32 %conv19 to i64 // call void @llvm.dbg.value(metadata i64 %4, metadata !96, metadata !DIExpression()), !dbg !121 // store atomic i64 %4, i64* @atom_1_X8_1 seq_cst, align 8, !dbg !94 // ST: Guess iw(2,5) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,5); cw(2,5) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,5)] == 2); ASSUME(active[cw(2,5)] == 2); ASSUME(sforbid(5,cw(2,5))== 0); ASSUME(iw(2,5) >= max(creg_r8,0)); ASSUME(iw(2,5) >= 0); ASSUME(cw(2,5) >= iw(2,5)); ASSUME(cw(2,5) >= old_cw); ASSUME(cw(2,5) >= cr(2,5)); ASSUME(cw(2,5) >= cl[2]); ASSUME(cw(2,5) >= cisb[2]); ASSUME(cw(2,5) >= cdy[2]); ASSUME(cw(2,5) >= cdl[2]); ASSUME(cw(2,5) >= cds[2]); ASSUME(cw(2,5) >= cctrl[2]); ASSUME(cw(2,5) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,5) = (r8==1); mem(5,cw(2,5)) = (r8==1); co(5,cw(2,5))+=1; delta(5,cw(2,5)) = -1; ASSUME(creturn[2] >= cw(2,5)); // ret i8* null, !dbg !95 ret_thread_2 = (- 1); // Dumping thread 0 int ret_thread_0 = 0; cdy[0] = get_rng(0,NCONTEXT-1); ASSUME(cdy[0] >= cstart[0]); T0BLOCK0: // %thr0 = alloca i64, align 8 // %thr1 = alloca i64, align 8 // call void @llvm.dbg.value(metadata i32 %argc, metadata !131, metadata !DIExpression()), !dbg !182 // call void @llvm.dbg.value(metadata i8** %argv, metadata !132, metadata !DIExpression()), !dbg !182 // %0 = bitcast i64* %thr0 to i8*, !dbg !94 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !94 // call void @llvm.dbg.declare(metadata i64* %thr0, metadata !133, metadata !DIExpression()), !dbg !184 // %1 = bitcast i64* %thr1 to i8*, !dbg !96 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !96 // call void @llvm.dbg.declare(metadata i64* %thr1, metadata !137, metadata !DIExpression()), !dbg !186 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !138, metadata !DIExpression()), !dbg !187 // call void @llvm.dbg.value(metadata i64 0, metadata !140, metadata !DIExpression()), !dbg !187 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !99 // ST: Guess iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0+2*1); cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0+2*1)] == 0); ASSUME(active[cw(0,0+2*1)] == 0); ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(cw(0,0+2*1) >= iw(0,0+2*1)); ASSUME(cw(0,0+2*1) >= old_cw); ASSUME(cw(0,0+2*1) >= cr(0,0+2*1)); ASSUME(cw(0,0+2*1) >= cl[0]); ASSUME(cw(0,0+2*1) >= cisb[0]); ASSUME(cw(0,0+2*1) >= cdy[0]); ASSUME(cw(0,0+2*1) >= cdl[0]); ASSUME(cw(0,0+2*1) >= cds[0]); ASSUME(cw(0,0+2*1) >= cctrl[0]); ASSUME(cw(0,0+2*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+2*1) = 0; mem(0+2*1,cw(0,0+2*1)) = 0; co(0+2*1,cw(0,0+2*1))+=1; delta(0+2*1,cw(0,0+2*1)) = -1; ASSUME(creturn[0] >= cw(0,0+2*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !141, metadata !DIExpression()), !dbg !189 // call void @llvm.dbg.value(metadata i64 0, metadata !143, metadata !DIExpression()), !dbg !189 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !101 // ST: Guess iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0+1*1); cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0+1*1)] == 0); ASSUME(active[cw(0,0+1*1)] == 0); ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(cw(0,0+1*1) >= iw(0,0+1*1)); ASSUME(cw(0,0+1*1) >= old_cw); ASSUME(cw(0,0+1*1) >= cr(0,0+1*1)); ASSUME(cw(0,0+1*1) >= cl[0]); ASSUME(cw(0,0+1*1) >= cisb[0]); ASSUME(cw(0,0+1*1) >= cdy[0]); ASSUME(cw(0,0+1*1) >= cdl[0]); ASSUME(cw(0,0+1*1) >= cds[0]); ASSUME(cw(0,0+1*1) >= cctrl[0]); ASSUME(cw(0,0+1*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+1*1) = 0; mem(0+1*1,cw(0,0+1*1)) = 0; co(0+1*1,cw(0,0+1*1))+=1; delta(0+1*1,cw(0,0+1*1)) = -1; ASSUME(creturn[0] >= cw(0,0+1*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !144, metadata !DIExpression()), !dbg !191 // call void @llvm.dbg.value(metadata i64 0, metadata !146, metadata !DIExpression()), !dbg !191 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !103 // ST: Guess iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0); cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0)] == 0); ASSUME(active[cw(0,0)] == 0); ASSUME(sforbid(0,cw(0,0))== 0); ASSUME(iw(0,0) >= 0); ASSUME(iw(0,0) >= 0); ASSUME(cw(0,0) >= iw(0,0)); ASSUME(cw(0,0) >= old_cw); ASSUME(cw(0,0) >= cr(0,0)); ASSUME(cw(0,0) >= cl[0]); ASSUME(cw(0,0) >= cisb[0]); ASSUME(cw(0,0) >= cdy[0]); ASSUME(cw(0,0) >= cdl[0]); ASSUME(cw(0,0) >= cds[0]); ASSUME(cw(0,0) >= cctrl[0]); ASSUME(cw(0,0) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0) = 0; mem(0,cw(0,0)) = 0; co(0,cw(0,0))+=1; delta(0,cw(0,0)) = -1; ASSUME(creturn[0] >= cw(0,0)); // call void @llvm.dbg.value(metadata i64* @atom_0_X2_0, metadata !147, metadata !DIExpression()), !dbg !193 // call void @llvm.dbg.value(metadata i64 0, metadata !149, metadata !DIExpression()), !dbg !193 // store atomic i64 0, i64* @atom_0_X2_0 monotonic, align 8, !dbg !105 // ST: Guess iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,3); cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,3)] == 0); ASSUME(active[cw(0,3)] == 0); ASSUME(sforbid(3,cw(0,3))== 0); ASSUME(iw(0,3) >= 0); ASSUME(iw(0,3) >= 0); ASSUME(cw(0,3) >= iw(0,3)); ASSUME(cw(0,3) >= old_cw); ASSUME(cw(0,3) >= cr(0,3)); ASSUME(cw(0,3) >= cl[0]); ASSUME(cw(0,3) >= cisb[0]); ASSUME(cw(0,3) >= cdy[0]); ASSUME(cw(0,3) >= cdl[0]); ASSUME(cw(0,3) >= cds[0]); ASSUME(cw(0,3) >= cctrl[0]); ASSUME(cw(0,3) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,3) = 0; mem(3,cw(0,3)) = 0; co(3,cw(0,3))+=1; delta(3,cw(0,3)) = -1; ASSUME(creturn[0] >= cw(0,3)); // call void @llvm.dbg.value(metadata i64* @atom_1_X2_1, metadata !150, metadata !DIExpression()), !dbg !195 // call void @llvm.dbg.value(metadata i64 0, metadata !152, metadata !DIExpression()), !dbg !195 // store atomic i64 0, i64* @atom_1_X2_1 monotonic, align 8, !dbg !107 // ST: Guess iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,4); cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,4)] == 0); ASSUME(active[cw(0,4)] == 0); ASSUME(sforbid(4,cw(0,4))== 0); ASSUME(iw(0,4) >= 0); ASSUME(iw(0,4) >= 0); ASSUME(cw(0,4) >= iw(0,4)); ASSUME(cw(0,4) >= old_cw); ASSUME(cw(0,4) >= cr(0,4)); ASSUME(cw(0,4) >= cl[0]); ASSUME(cw(0,4) >= cisb[0]); ASSUME(cw(0,4) >= cdy[0]); ASSUME(cw(0,4) >= cdl[0]); ASSUME(cw(0,4) >= cds[0]); ASSUME(cw(0,4) >= cctrl[0]); ASSUME(cw(0,4) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,4) = 0; mem(4,cw(0,4)) = 0; co(4,cw(0,4))+=1; delta(4,cw(0,4)) = -1; ASSUME(creturn[0] >= cw(0,4)); // call void @llvm.dbg.value(metadata i64* @atom_1_X8_1, metadata !153, metadata !DIExpression()), !dbg !197 // call void @llvm.dbg.value(metadata i64 0, metadata !155, metadata !DIExpression()), !dbg !197 // store atomic i64 0, i64* @atom_1_X8_1 monotonic, align 8, !dbg !109 // ST: Guess iw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,5); cw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,5)] == 0); ASSUME(active[cw(0,5)] == 0); ASSUME(sforbid(5,cw(0,5))== 0); ASSUME(iw(0,5) >= 0); ASSUME(iw(0,5) >= 0); ASSUME(cw(0,5) >= iw(0,5)); ASSUME(cw(0,5) >= old_cw); ASSUME(cw(0,5) >= cr(0,5)); ASSUME(cw(0,5) >= cl[0]); ASSUME(cw(0,5) >= cisb[0]); ASSUME(cw(0,5) >= cdy[0]); ASSUME(cw(0,5) >= cdl[0]); ASSUME(cw(0,5) >= cds[0]); ASSUME(cw(0,5) >= cctrl[0]); ASSUME(cw(0,5) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,5) = 0; mem(5,cw(0,5)) = 0; co(5,cw(0,5))+=1; delta(5,cw(0,5)) = -1; ASSUME(creturn[0] >= cw(0,5)); // %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !110 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[1] >= cdy[0]); // %call11 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !111 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[2] >= cdy[0]); // %2 = load i64, i64* %thr0, align 8, !dbg !112, !tbaa !113 // LD: Guess old_cr = cr(0,6); cr(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,6)] == 0); ASSUME(cr(0,6) >= iw(0,6)); ASSUME(cr(0,6) >= 0); ASSUME(cr(0,6) >= cdy[0]); ASSUME(cr(0,6) >= cisb[0]); ASSUME(cr(0,6) >= cdl[0]); ASSUME(cr(0,6) >= cl[0]); // Update creg_r10 = cr(0,6); crmax(0,6) = max(crmax(0,6),cr(0,6)); caddr[0] = max(caddr[0],0); if(cr(0,6) < cw(0,6)) { r10 = buff(0,6); } else { if(pw(0,6) != co(6,cr(0,6))) { ASSUME(cr(0,6) >= old_cr); } pw(0,6) = co(6,cr(0,6)); r10 = mem(6,cr(0,6)); } ASSUME(creturn[0] >= cr(0,6)); // %call12 = call i32 @pthread_join(i64 noundef %2, i8** noundef null), !dbg !117 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[1]); // %3 = load i64, i64* %thr1, align 8, !dbg !118, !tbaa !113 // LD: Guess old_cr = cr(0,7); cr(0,7) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,7)] == 0); ASSUME(cr(0,7) >= iw(0,7)); ASSUME(cr(0,7) >= 0); ASSUME(cr(0,7) >= cdy[0]); ASSUME(cr(0,7) >= cisb[0]); ASSUME(cr(0,7) >= cdl[0]); ASSUME(cr(0,7) >= cl[0]); // Update creg_r11 = cr(0,7); crmax(0,7) = max(crmax(0,7),cr(0,7)); caddr[0] = max(caddr[0],0); if(cr(0,7) < cw(0,7)) { r11 = buff(0,7); } else { if(pw(0,7) != co(7,cr(0,7))) { ASSUME(cr(0,7) >= old_cr); } pw(0,7) = co(7,cr(0,7)); r11 = mem(7,cr(0,7)); } ASSUME(creturn[0] >= cr(0,7)); // %call13 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !119 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[2]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !157, metadata !DIExpression()), !dbg !209 // %4 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) seq_cst, align 8, !dbg !121 // LD: Guess old_cr = cr(0,0); cr(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,0)] == 0); ASSUME(cr(0,0) >= iw(0,0)); ASSUME(cr(0,0) >= 0); ASSUME(cr(0,0) >= cdy[0]); ASSUME(cr(0,0) >= cisb[0]); ASSUME(cr(0,0) >= cdl[0]); ASSUME(cr(0,0) >= cl[0]); // Update creg_r12 = cr(0,0); crmax(0,0) = max(crmax(0,0),cr(0,0)); caddr[0] = max(caddr[0],0); if(cr(0,0) < cw(0,0)) { r12 = buff(0,0); } else { if(pw(0,0) != co(0,cr(0,0))) { ASSUME(cr(0,0) >= old_cr); } pw(0,0) = co(0,cr(0,0)); r12 = mem(0,cr(0,0)); } ASSUME(creturn[0] >= cr(0,0)); // call void @llvm.dbg.value(metadata i64 %4, metadata !159, metadata !DIExpression()), !dbg !209 // %conv = trunc i64 %4 to i32, !dbg !122 // call void @llvm.dbg.value(metadata i32 %conv, metadata !156, metadata !DIExpression()), !dbg !182 // %cmp = icmp eq i32 %conv, 2, !dbg !123 // %conv14 = zext i1 %cmp to i32, !dbg !123 // call void @llvm.dbg.value(metadata i32 %conv14, metadata !160, metadata !DIExpression()), !dbg !182 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !162, metadata !DIExpression()), !dbg !213 // %5 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) seq_cst, align 8, !dbg !125 // LD: Guess old_cr = cr(0,0+1*1); cr(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,0+1*1)] == 0); ASSUME(cr(0,0+1*1) >= iw(0,0+1*1)); ASSUME(cr(0,0+1*1) >= 0); ASSUME(cr(0,0+1*1) >= cdy[0]); ASSUME(cr(0,0+1*1) >= cisb[0]); ASSUME(cr(0,0+1*1) >= cdl[0]); ASSUME(cr(0,0+1*1) >= cl[0]); // Update creg_r13 = cr(0,0+1*1); crmax(0,0+1*1) = max(crmax(0,0+1*1),cr(0,0+1*1)); caddr[0] = max(caddr[0],0); if(cr(0,0+1*1) < cw(0,0+1*1)) { r13 = buff(0,0+1*1); } else { if(pw(0,0+1*1) != co(0+1*1,cr(0,0+1*1))) { ASSUME(cr(0,0+1*1) >= old_cr); } pw(0,0+1*1) = co(0+1*1,cr(0,0+1*1)); r13 = mem(0+1*1,cr(0,0+1*1)); } ASSUME(creturn[0] >= cr(0,0+1*1)); // call void @llvm.dbg.value(metadata i64 %5, metadata !164, metadata !DIExpression()), !dbg !213 // %conv18 = trunc i64 %5 to i32, !dbg !126 // call void @llvm.dbg.value(metadata i32 %conv18, metadata !161, metadata !DIExpression()), !dbg !182 // %cmp19 = icmp eq i32 %conv18, 1, !dbg !127 // %conv20 = zext i1 %cmp19 to i32, !dbg !127 // call void @llvm.dbg.value(metadata i32 %conv20, metadata !165, metadata !DIExpression()), !dbg !182 // call void @llvm.dbg.value(metadata i64* @atom_0_X2_0, metadata !167, metadata !DIExpression()), !dbg !217 // %6 = load atomic i64, i64* @atom_0_X2_0 seq_cst, align 8, !dbg !129 // LD: Guess old_cr = cr(0,3); cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,3)] == 0); ASSUME(cr(0,3) >= iw(0,3)); ASSUME(cr(0,3) >= 0); ASSUME(cr(0,3) >= cdy[0]); ASSUME(cr(0,3) >= cisb[0]); ASSUME(cr(0,3) >= cdl[0]); ASSUME(cr(0,3) >= cl[0]); // Update creg_r14 = cr(0,3); crmax(0,3) = max(crmax(0,3),cr(0,3)); caddr[0] = max(caddr[0],0); if(cr(0,3) < cw(0,3)) { r14 = buff(0,3); } else { if(pw(0,3) != co(3,cr(0,3))) { ASSUME(cr(0,3) >= old_cr); } pw(0,3) = co(3,cr(0,3)); r14 = mem(3,cr(0,3)); } ASSUME(creturn[0] >= cr(0,3)); // call void @llvm.dbg.value(metadata i64 %6, metadata !169, metadata !DIExpression()), !dbg !217 // %conv24 = trunc i64 %6 to i32, !dbg !130 // call void @llvm.dbg.value(metadata i32 %conv24, metadata !166, metadata !DIExpression()), !dbg !182 // call void @llvm.dbg.value(metadata i64* @atom_1_X2_1, metadata !171, metadata !DIExpression()), !dbg !220 // %7 = load atomic i64, i64* @atom_1_X2_1 seq_cst, align 8, !dbg !132 // LD: Guess old_cr = cr(0,4); cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,4)] == 0); ASSUME(cr(0,4) >= iw(0,4)); ASSUME(cr(0,4) >= 0); ASSUME(cr(0,4) >= cdy[0]); ASSUME(cr(0,4) >= cisb[0]); ASSUME(cr(0,4) >= cdl[0]); ASSUME(cr(0,4) >= cl[0]); // Update creg_r15 = cr(0,4); crmax(0,4) = max(crmax(0,4),cr(0,4)); caddr[0] = max(caddr[0],0); if(cr(0,4) < cw(0,4)) { r15 = buff(0,4); } else { if(pw(0,4) != co(4,cr(0,4))) { ASSUME(cr(0,4) >= old_cr); } pw(0,4) = co(4,cr(0,4)); r15 = mem(4,cr(0,4)); } ASSUME(creturn[0] >= cr(0,4)); // call void @llvm.dbg.value(metadata i64 %7, metadata !173, metadata !DIExpression()), !dbg !220 // %conv28 = trunc i64 %7 to i32, !dbg !133 // call void @llvm.dbg.value(metadata i32 %conv28, metadata !170, metadata !DIExpression()), !dbg !182 // call void @llvm.dbg.value(metadata i64* @atom_1_X8_1, metadata !175, metadata !DIExpression()), !dbg !223 // %8 = load atomic i64, i64* @atom_1_X8_1 seq_cst, align 8, !dbg !135 // LD: Guess old_cr = cr(0,5); cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,5)] == 0); ASSUME(cr(0,5) >= iw(0,5)); ASSUME(cr(0,5) >= 0); ASSUME(cr(0,5) >= cdy[0]); ASSUME(cr(0,5) >= cisb[0]); ASSUME(cr(0,5) >= cdl[0]); ASSUME(cr(0,5) >= cl[0]); // Update creg_r16 = cr(0,5); crmax(0,5) = max(crmax(0,5),cr(0,5)); caddr[0] = max(caddr[0],0); if(cr(0,5) < cw(0,5)) { r16 = buff(0,5); } else { if(pw(0,5) != co(5,cr(0,5))) { ASSUME(cr(0,5) >= old_cr); } pw(0,5) = co(5,cr(0,5)); r16 = mem(5,cr(0,5)); } ASSUME(creturn[0] >= cr(0,5)); // call void @llvm.dbg.value(metadata i64 %8, metadata !177, metadata !DIExpression()), !dbg !223 // %conv32 = trunc i64 %8 to i32, !dbg !136 // call void @llvm.dbg.value(metadata i32 %conv32, metadata !174, metadata !DIExpression()), !dbg !182 // %and = and i32 %conv28, %conv32, !dbg !137 creg_r17 = max(creg_r15,creg_r16); ASSUME(active[creg_r17] == 0); r17 = r15 & r16; // call void @llvm.dbg.value(metadata i32 %and, metadata !178, metadata !DIExpression()), !dbg !182 // %and33 = and i32 %conv24, %and, !dbg !138 creg_r18 = max(creg_r14,creg_r17); ASSUME(active[creg_r18] == 0); r18 = r14 & r17; // call void @llvm.dbg.value(metadata i32 %and33, metadata !179, metadata !DIExpression()), !dbg !182 // %and34 = and i32 %conv20, %and33, !dbg !139 creg_r19 = max(max(creg_r13,0),creg_r18); ASSUME(active[creg_r19] == 0); r19 = (r13==1) & r18; // call void @llvm.dbg.value(metadata i32 %and34, metadata !180, metadata !DIExpression()), !dbg !182 // %and35 = and i32 %conv14, %and34, !dbg !140 creg_r20 = max(max(creg_r12,0),creg_r19); ASSUME(active[creg_r20] == 0); r20 = (r12==2) & r19; // call void @llvm.dbg.value(metadata i32 %and35, metadata !181, metadata !DIExpression()), !dbg !182 // %cmp36 = icmp eq i32 %and35, 1, !dbg !141 // br i1 %cmp36, label %if.then, label %if.end, !dbg !143 old_cctrl = cctrl[0]; cctrl[0] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[0] >= old_cctrl); ASSUME(cctrl[0] >= creg_r20); ASSUME(cctrl[0] >= 0); if((r20==1)) { goto T0BLOCK1; } else { goto T0BLOCK2; } T0BLOCK1: // call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([112 x i8], [112 x i8]* @.str.1, i64 0, i64 0), i32 noundef 74, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !144 // unreachable, !dbg !144 r21 = 1; T0BLOCK2: // %9 = bitcast i64* %thr1 to i8*, !dbg !147 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %9) #7, !dbg !147 // %10 = bitcast i64* %thr0 to i8*, !dbg !147 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %10) #7, !dbg !147 // ret i32 0, !dbg !148 ret_thread_0 = 0; ASSERT(r21== 0); }
[ "tuan-phong.ngo@it.uu.se" ]
tuan-phong.ngo@it.uu.se
e14d3f0392a8d29724cac77f81f9b02d38e50581
596cf6c2e73ab8ef53773f198ec9b0ed61e612f6
/src/vm/dbginterface.h
fb3e167374b75f1d2cf8825627ba1aeb78e429aa
[ "MIT" ]
permissive
kangaroo/coreclr
7387d38671eb127da84c39e763a960f81607670b
6f1c48b59908a797313777d792c51413db43afcd
refs/heads/master
2021-01-17T10:28:18.821450
2015-03-01T06:16:02
2015-03-01T06:28:09
30,268,501
2
1
null
2015-02-03T22:40:02
2015-02-03T22:39:58
null
UTF-8
C++
false
false
19,167
h
// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // // // COM+99 Debug Interface Header // #ifndef _dbgInterface_h_ #define _dbgInterface_h_ #include "common.h" #include "eedbginterface.h" #include "corjit.h" #include "../debug/inc/dbgipcevents.h" #include "primitives.h" typedef DPTR(struct ICorDebugInfo::NativeVarInfo) PTR_NativeVarInfo; typedef void (*FAVORCALLBACK)(void *); // // The purpose of this object is to serve as an entry point to the // debugger, which used to reside in a seperate DLL. // class DebugInterface { VPTR_BASE_VTABLE_CLASS(DebugInterface); public: // // Functions exported from the debugger to the EE. // #ifndef DACCESS_COMPILE virtual HRESULT Startup(void) = 0; virtual HRESULT StartupPhase2(Thread * pThread) = 0; // Some callers into the debugger (e.g., ETW rundown) know they will need the lazy // data initialized but cannot afford to have it initialized unpredictably or inside a // lock. They can use this function to force the data to be initialized at a // controlled point in time virtual void InitializeLazyDataIfNecessary() = 0; virtual void SetEEInterface(EEDebugInterface* i) = 0; virtual void StopDebugger(void) = 0; virtual BOOL IsStopped(void) = 0; virtual void ThreadCreated(Thread* pRuntimeThread) = 0; virtual void ThreadStarted(Thread* pRuntimeThread) = 0; virtual void DetachThread(Thread *pRuntimeThread) = 0; // Called when a module is being loaded into an AppDomain. // This includes when a domain neutral module is loaded into a new AppDomain. // This is called only when a debugger is attached, and will occur after the // related LoadAssembly and AddAppDomainToIPCBlock calls and before any // LoadClass calls for this module. virtual void LoadModule(Module * pRuntimeModule, // the module being loaded LPCWSTR psModuleName, // module file name DWORD dwModuleName, // number of characters in file name excludign null Assembly * pAssembly, // the assembly the module belongs to AppDomain * pAppDomain, // the AppDomain the module is being loaded into DomainFile * pDomainFile, BOOL fAttaching) = 0; // true if this notification is due to a debugger // being attached to the process // Called AFTER LoadModule, and after the module has reached FILE_LOADED. This lets // dbgapi do any processing that needs to wait until the FILE_LOADED stage (e.g., // binding breakpoints in NGENd generics). virtual void LoadModuleFinished(Module * pModule, AppDomain * pAppDomain) = 0; // Called for all modules in an AppDomain when the AppDomain is unloaded. // This includes domain neutral modules that are also loaded into other domains. // This is called only when a debugger is attached, and will occur after all UnloadClass // calls and before any UnloadAssembly or RemoveAppDomainFromIPCBlock calls realted // to this module. On CLR shutdown, we are not guarenteed to get UnloadModule calls for // all outstanding loaded modules. virtual void UnloadModule(Module* pRuntimeModule, AppDomain *pAppDomain) = 0; // Called when a Module* is being destroyed. // Specifically, the Module has completed unloading (which may have been done asyncronously), all resources // associated are being freed, and the Module* is about to become invalid. The debugger should remove all // references to this Module*. // NOTE: This is called REGARDLESS of whether a debugger is attached or not, and will occur after any other // notifications about this module (including any RemoveAppDomainFromIPCBlock call indicating the module's // domain has been unloaded). virtual void DestructModule(Module *pModule) = 0; virtual BOOL LoadClass(TypeHandle th, mdTypeDef classMetadataToken, Module *classModule, AppDomain *pAppDomain) = 0; virtual void UnloadClass(mdTypeDef classMetadataToken, Module *classModule, AppDomain *pAppDomain) = 0; // Filter we call in 1st-pass to dispatch a CHF callback. // pCatchStackAddress really should be a Frame* onto the stack. That way the CHF stack address // and the debugger's stacktrace Frames will match up. // This is only called by stubs. virtual LONG NotifyOfCHFFilter(EXCEPTION_POINTERS* pExceptionPointers, PVOID pCatchStackAddr) = 0; virtual bool FirstChanceNativeException(EXCEPTION_RECORD *exception, CONTEXT *context, DWORD code, Thread *thread) = 0; // pThread is thread that exception is on. // currentSP is stack frame of the throw site. // currentIP is ip of the throw site. // pStubFrame = NULL if the currentSp is for a non-stub frame (ie, a regular JITed catched). // For stub-based throws, pStubFrame is the EE Frame of the stub. virtual bool FirstChanceManagedException(Thread *pThread, SIZE_T currentIP, SIZE_T currentSP) = 0; virtual void FirstChanceManagedExceptionCatcherFound(Thread *pThread, MethodDesc *pMD, TADDR pMethodAddr, BYTE *currentSP, EE_ILEXCEPTION_CLAUSE *pEHClause) = 0; virtual LONG LastChanceManagedException(EXCEPTION_POINTERS * pExceptionInfo, Thread *thread, BOOL jitAttachRequested) = 0; virtual void ManagedExceptionUnwindBegin(Thread *pThread) = 0; virtual void DeleteInterceptContext(void *pContext) = 0; virtual void ExceptionFilter(MethodDesc *fd, TADDR pMethodAddr, SIZE_T offset, BYTE *pStack) = 0; virtual void ExceptionHandle(MethodDesc *fd, TADDR pMethodAddr, SIZE_T offset, BYTE *pStack) = 0; virtual void SendUserBreakpoint(Thread *thread) = 0; // Send an UpdateModuleSyms event, and block waiting for the debugger to continue it. virtual void SendUpdateModuleSymsEventAndBlock(Module *pRuntimeModule, AppDomain *pAppDomain) = 0; // // RequestFavor gets the debugger helper thread to call a function. It's // typically called when the current thread can't call the function directly, // e.g, there isn't enough stack space. // // RequestFavor ensures that the helper thread has been initialized to // execute favors and then calls Debugger:DoFavor. It blocks until the // favor callback completes. // // Parameters: // fp - Favour callback function // pData - the parameter passed to the favor callback function. // // Return values: // S_OK if the function succeeds, else a failure HRESULT // virtual HRESULT RequestFavor(FAVORCALLBACK fp, void * pData) = 0; #endif // #ifndef DACCESS_COMPILE // JITComplete() is called after a method is jit-compiled, successfully or not #ifndef DACCESS_COMPILE virtual void JITComplete(MethodDesc* fd, TADDR newAddress) = 0; // // EnC functions // #ifdef EnC_SUPPORTED // Notify that an existing method has been edited in a loaded type virtual HRESULT UpdateFunction(MethodDesc* md, SIZE_T enCVersion) = 0; // Notify that a new method has been added to a loaded type virtual HRESULT AddFunction(MethodDesc* md, SIZE_T enCVersion) = 0; virtual HRESULT UpdateNotYetLoadedFunction(mdMethodDef token, Module * pModule, SIZE_T enCVersion) = 0; // Notify that a field has been added virtual HRESULT AddField(FieldDesc* fd, SIZE_T enCVersion) = 0; // Notify that the EE has completed the remap and is about to resume execution virtual HRESULT RemapComplete(MethodDesc *pMd, TADDR addr, SIZE_T nativeOffset) = 0; // Used by the codemanager FixContextForEnC() to update virtual HRESULT MapILInfoToCurrentNative(MethodDesc *pMD, SIZE_T ilOffset, TADDR nativeFnxStart, SIZE_T *nativeOffset) = 0; #endif // EnC_SUPPORTED // Get debugger variable information for a specific version of a method virtual void GetVarInfo(MethodDesc * fd, // [IN] method of interest void *DebuggerVersionToken, // [IN] which edit version SIZE_T * cVars, // [OUT] size of 'vars' const ICorDebugInfo::NativeVarInfo **vars // [OUT] map telling where local vars are stored ) = 0; virtual void getBoundaries(MethodDesc * ftn, unsigned int *cILOffsets, DWORD **pILOffsets, ICorDebugInfo::BoundaryTypes* implictBoundaries) = 0; virtual void getVars(MethodDesc * ftn, ULONG32 *cVars, ICorDebugInfo::ILVarInfo **vars, bool *extendOthers) = 0; virtual BOOL CheckGetPatchedOpcode(CORDB_ADDRESS_TYPE *address, /*OUT*/ PRD_TYPE *pOpcode) = 0; virtual PRD_TYPE GetPatchedOpcode(CORDB_ADDRESS_TYPE *ip) = 0; virtual void TraceCall(const BYTE *target) = 0; virtual bool ThreadsAtUnsafePlaces(void) = 0; virtual HRESULT LaunchDebuggerForUser(Thread * pThread, EXCEPTION_POINTERS * pExceptionInfo, BOOL sendManagedEvent, BOOL explicitUserRequest) = 0; // Launches a debugger and waits for it to attach virtual void JitAttach(Thread * pThread, EXCEPTION_POINTERS * pExceptionInfo, BOOL willSendManagedEvent, BOOL explicitUserRequest) = 0; // Prepares for a jit attach and decides which of several potentially // racing threads get to launch the debugger virtual BOOL PreJitAttach(BOOL willSendManagedEvent, BOOL willLaunchDebugger, BOOL explicitUserRequest) = 0; // Waits for a jit attach to complete virtual void WaitForDebuggerAttach() = 0; // Completes the jit attach, unblocking all threads waiting for attach, // regardless of whether or not the debugger actually attached virtual void PostJitAttach() = 0; virtual void SendUserBreakpointAndSynchronize(Thread * pThread) = 0; virtual void SendLogMessage(int iLevel, SString * pSwitchName, SString * pMessage) = 0; // send a custom notification from the target to the RS. This will become an ICorDebugThread and // ICorDebugAppDomain on the RS. virtual void SendCustomDebuggerNotification(Thread * pThread, DomainFile * pDomainFile, mdTypeDef classToken) = 0; // Send an MDA notification. This ultimately translates to an ICorDebugMDA object on the Right-Side. virtual void SendMDANotification( Thread * pThread, // may be NULL. Lets us send on behalf of other threads. SString * szName, SString * szDescription, SString * szXML, CorDebugMDAFlags flags, BOOL bAttach ) = 0; virtual bool IsJMCMethod(Module* pModule, mdMethodDef tkMethod) = 0; // Given a method, get's its EnC version number. 1 if the method is not EnCed. // Note that MethodDescs are reused between versions so this will give us // the most recent EnC number. virtual int GetMethodEncNumber(MethodDesc * pMethod) = 0; virtual void SendLogSwitchSetting (int iLevel, int iReason, __in_z LPCWSTR pLogSwitchName, __in_z LPCWSTR pParentSwitchName) = 0; virtual bool IsLoggingEnabled (void) = 0; virtual bool GetILOffsetFromNative (MethodDesc *PFD, const BYTE *pbAddr, DWORD nativeOffset, DWORD *ilOffset) = 0; virtual HRESULT GetILToNativeMapping(MethodDesc *pMD, ULONG32 cMap, ULONG32 *pcMap, COR_DEBUG_IL_TO_NATIVE_MAP map[]) = 0; virtual HRESULT GetILToNativeMappingIntoArrays( MethodDesc * pMD, USHORT cMapMax, USHORT * pcMap, UINT ** prguiILOffset, UINT ** prguiNativeOffset) = 0; virtual DWORD GetHelperThreadID(void ) = 0; // Called whenever a new AppDomain is created, regardless of whether a debugger is attached. // This will be called before any LoadAssembly calls for assemblies in this domain. virtual HRESULT AddAppDomainToIPC (AppDomain *pAppDomain) = 0; // Called whenever an AppDomain is unloaded, regardless of whether a Debugger is attached // This will occur after any UnloadAssembly and UnloadModule callbacks for this domain (if any). virtual HRESULT RemoveAppDomainFromIPC (AppDomain *pAppDomain) = 0; virtual HRESULT UpdateAppDomainEntryInIPC (AppDomain *pAppDomain) = 0; // Called when an assembly is being loaded into an AppDomain. // This includes when a domain neutral assembly is loaded into a new AppDomain. // This is called only when a debugger is attached, and will occur after the // related AddAppDomainToIPCBlock call and before any LoadModule or // LoadClass calls for this assembly. virtual void LoadAssembly(DomainAssembly * pDomainAssembly) = 0; // the assembly being loaded // Called for all assemblies in an AppDomain when the AppDomain is unloaded. // This includes domain neutral assemblies that are also loaded into other domains. // This is called only when a debugger is attached, and will occur after all UnloadClass // and UnloadModule calls and before any RemoveAppDomainFromIPCBlock calls realted // to this assembly. On CLR shutdown, we are not guarenteed to get UnloadAssembly calls for // all outstanding loaded assemblies. virtual void UnloadAssembly(DomainAssembly * pDomainAssembly) = 0; virtual HRESULT SetILInstrumentedCodeMap(MethodDesc *fd, BOOL fStartJit, ULONG32 cILMapEntries, COR_IL_MAP rgILMapEntries[]) = 0; virtual void EarlyHelperThreadDeath(void) = 0; virtual void ShutdownBegun(void) = 0; virtual void LockDebuggerForShutdown(void) = 0; virtual void DisableDebugger(void) = 0; virtual HRESULT NameChangeEvent(AppDomain *pAppDomain, Thread *pThread) = 0; // send an event to the RS indicating that there's a Ctrl-C or Ctrl-Break virtual BOOL SendCtrlCToDebugger(DWORD dwCtrlType) = 0; // Allows the debugger to keep an up to date list of special threads virtual HRESULT UpdateSpecialThreadList(DWORD cThreadArrayLength, DWORD *rgdwThreadIDArray) = 0; // Updates the pointer for the debugger services virtual void SetIDbgThreadControl(IDebuggerThreadControl *pIDbgThreadControl) = 0; virtual DWORD GetRCThreadId(void) = 0; virtual HRESULT GetVariablesFromOffset(MethodDesc *pMD, UINT varNativeInfoCount, ICorDebugInfo::NativeVarInfo *varNativeInfo, SIZE_T offsetFrom, CONTEXT *pCtx, SIZE_T *rgVal1, SIZE_T *rgVal2, UINT uRgValSize, BYTE ***rgpVCs) = 0; virtual HRESULT SetVariablesAtOffset(MethodDesc *pMD, UINT varNativeInfoCount, ICorDebugInfo::NativeVarInfo *varNativeInfo, SIZE_T offsetTo, CONTEXT *pCtx, SIZE_T *rgVal1, SIZE_T *rgVal2, BYTE **rgpVCs) = 0; virtual BOOL IsThreadContextInvalid(Thread *pThread) = 0; // For Just-My-Code (aka Just-User-Code). // The jit inserts probes that look like. // if (*pAddr != 0) call g_pDebugInterface->OnMethodEnter() // Invoked when we enter a user method. // pIP is an ip within the method, right after the prolog. virtual void OnMethodEnter(void * pIP) = 0; // Given a method, the debugger provides the address of the flag. // This allows the debugger to store the flag whereever it wants // and with whatever granularity (per-module, per-class, per-function, etc). virtual DWORD* GetJMCFlagAddr(Module * pModule) = 0; // notification for SQL fiber debugging support virtual void CreateConnection(CONNID dwConnectionId, __in_z WCHAR *wzName) = 0; virtual void DestroyConnection(CONNID dwConnectionId) = 0; virtual void ChangeConnection(CONNID dwConnectionId) = 0; // // This function is used to identify the helper thread. // virtual bool ThisIsHelperThread(void) = 0; virtual HRESULT ReDaclEvents(PSECURITY_DESCRIPTOR securityDescriptor) = 0; virtual BOOL ShouldAutoAttach() = 0; virtual BOOL FallbackJITAttachPrompt() = 0; virtual HRESULT SetFiberMode(bool isFiberMode) = 0; #ifdef FEATURE_INTEROP_DEBUGGING virtual LONG FirstChanceSuspendHijackWorker(PCONTEXT pContext, PEXCEPTION_RECORD pExceptionRecord) = 0; #endif #endif // #ifndef DACCESS_COMPILE #ifdef DACCESS_COMPILE virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags) = 0; virtual void EnumMemoryRegionsIfFuncEvalFrame(CLRDataEnumMemoryFlags flags, Frame * pFrame) = 0; #endif }; #ifndef DACCESS_COMPILE // Helper to make GCC compile. GCC can't handle putting a virtual call in a filter. struct NotifyOfCHFFilterWrapperParam { void *pFrame; }; LONG NotifyOfCHFFilterWrapper(EXCEPTION_POINTERS *pExceptionInfo, PVOID pNotifyOfCHFFilterWrapperParam); #endif #endif // _dbgInterface_h_
[ "dotnet-bot@microsoft.com" ]
dotnet-bot@microsoft.com
7b6f444e2a5cadd7d615fe699e9472d795283b39
bac0d41c91c476fc50a2ab5578cf40895d00db4f
/D3D9 Test/VisEntityQuad.h
006e41c751244724e7f663d759ce30a0b0a63a97
[]
no_license
Norcinu/D3D9-Test
525a4a404b51d43bbac87f85ce1a7b4e32ee6192
33dc225899e33d86e0a2bc773e0599078d6c9e72
refs/heads/master
2016-09-06T13:11:40.476120
2012-07-22T21:06:43
2012-07-22T21:06:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
361
h
#ifndef VIS_ENTITY_TRIANGLE_H #define VIS_ENTITY_TRIANGLE_H #include "visentity.h" #define TRIANGLE_FVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE) class VisEntityQuad : public VisEntity { public: VisEntityQuad(void); ~VisEntityQuad(void); bool Load(const char * filename, IDirect3DDevice9 * device); void Render(IDirect3DDevice9 * device); }; #endif
[ "ledbybyson@gmail.com" ]
ledbybyson@gmail.com
1fbf8bf4ada087ffdc2b94831bf27ac322b97992
0c7d3128a4bacf120f0994e35cc6946e32816b27
/src/glm/BACKUP/core/intrinsic_geometric.hpp
422f19f2cf0479125ea3c67739e5134e86298f0b
[]
no_license
Funto/Tohoku-Engine
12061d4ae727a28814918002fa97544cfcbb6947
0d52cd6c23308ee422397765e199d24868701e03
refs/heads/master
2022-05-26T13:41:35.732165
2022-05-14T14:48:43
2022-05-14T14:48:43
2,401,966
4
1
null
null
null
null
UTF-8
C++
false
false
1,165
hpp
/////////////////////////////////////////////////////////////////////////////////////////////////// // OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2009-05-08 // Updated : 2009-05-08 // Licence : This source is under MIT License // File : glm/core/intrinsic_geometric.hpp /////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef glm_core_intrinsic_geometric #define glm_core_intrinsic_geometric #include "intrinsic_common.hpp" //length __m128 _mm_len_ps(__m128 x); //distance __m128 _mm_dst_ps(__m128 p0, __m128 p1); //dot __m128 _mm_dot_ps(__m128 v1, __m128 v2); // SSE1 __m128 _mm_dot_ss(__m128 v1, __m128 v2); //cross __m128 _mm_xpd_ps(__m128 v1, __m128 v2); //normalize __m128 _mm_nrm_ps(__m128 v); //faceforward __m128 _mm_ffd_ps(__m128 N, __m128 I, __m128 Nref); //reflect __m128 _mm_rfe_ps(__m128 I, __m128 N); //refract __m128 _mm_rfa_ps(__m128 I, __m128 N, __m128 eta); #include "intrinsic_geometric.inl" #endif//glm_core_intrinsic_geometric
[ "funto66@gmail.com" ]
funto66@gmail.com
aedd9179364a1347520ce423b63d52607d1777a3
4f70dcdbd6e40499b3fd5fbcb68299d231d0c815
/go/go.cpp
b5c2657f0d2bced6dd80978b4a5ea6ee322e422d
[]
no_license
phong9h/CP
d8268db64655e61b03e26af29d1a855864c2903e
e2bcc426c8f4da112581807a225f36e5f13e101b
refs/heads/master
2021-08-17T00:00:10.295810
2017-11-20T15:00:48
2017-11-20T15:00:48
111,384,674
0
0
null
null
null
null
UTF-8
C++
false
false
2,238
cpp
#include <iostream> #include <stdio.h> #include <algorithm> #include <queue> #include <vector> #include <stack> #include <cmath> #include <memory.h> #include <iomanip> #include <cassert> using namespace std; #define maxn #define FOR(i, l, r) for (int i=l; i<=r; ++i) #define FORD(i, r, l) for (int i=r; i>=l; --i) #define REP(i, r) for (int i=0; i<(int)r; ++i) #define REPD(i, r) for (int i=(int)r-1; i>=0; --i) #define fi first #define se second #define mk make_pair #define nil NULL #define y0 __y0 #define y1 __y1 #define x0 __x0 #define x1 __x1 #define next asdfa #define sz size #define DB(X) {cerr << #X << " = " << X << '\n';} #define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';} #define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';} typedef long long ll; typedef double db; typedef pair<int, int> ii; typedef vector<int> vi; const int inf = 1e9; template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;} template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));} template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));} template<class T> T sqr(T a) {return a*a;} stack<ii> st; int read_int() { int res = 0; bool start = false; char r; while (true) { r = getchar(); if ((r<'0' || r>'9') && !start) continue; if ((r<'0' || r>'9') && start) break; if (start) res *= 10; start = true; res += r-'0'; } return res; } int main() { freopen("go.inp", "r", stdin); freopen("go.out", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); int T; T = read_int(); while (T--) { int n; n = read_int(); FOR(i, 1, n) { int x; x = read_int(); if (st.empty()) {st.push(ii(x, 1)); continue;} if (i%2) { if (x==st.top().fi) st.top().se++; else st.push(ii(x, 1)); } else { if (x==st.top().fi) st.top().se++; else { int tmp = 0; REP(j, 2) { if (st.sz()) {tmp += st.top().se; st.pop();} } st.push(ii(x, tmp+1)); } } //if (i==4) { // while (st.sz()) {DB(st.top().fi); DB(st.top().se); st.pop();} //} } int res = 0; while (st.sz()) { if (st.top().fi==0) res += st.top().se; st.pop(); } cout << res << '\n'; } }
[ "tranthephong33@gmail.com" ]
tranthephong33@gmail.com
d6f228331f64cb9ec74da2f79fed7adf42fc3bc8
e7e497b20442a4220296dea1550091a457df5a38
/main_project/feed/FeedDispatchNew/src/DbHelper.h
191dbaf049d6e3f8e9647ee032f3d7c95616e6f9
[]
no_license
gunner14/old_rr_code
cf17a2dedf8dfcdcf441d49139adaadc770c0eea
bb047dc88fa7243ded61d840af0f8bad22d68dee
refs/heads/master
2021-01-17T18:23:28.154228
2013-12-02T23:45:33
2013-12-02T23:45:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,084
h
/* * DBHelper.h * * Created on: Dec 24, 2009 * Author: antonio */ #ifndef DBHELPER_H_ #define DBHELPER_H_ #include "QueryRunner.h" #include "Singleton.h" #include "RFeed.h" #include "IceLogger.h" #include "Common.h" namespace xce { namespace feed { const int DB_CONTENT_ZONE=1000000000; const static int DB_ZONE_SPLIT=18; const int DB_TASK_LEVEL = 1004; using namespace com::xiaonei::xce; using namespace MyUtil; static string DB_INSTANCE = "feed_db"; static string DB_BC_INSTANCE = "feed_content_db"; static string DB_ZONE_CONTENT_INSTANCE = "feed_content_db"; const string GROUP_DB_INSTANCE = "feed_minigroup"; const string TAB_ID_SEQ = "feed_id_seq"; #define COL_FEED "feed" #define COL_SOURCE "source" #define COL_SMALLTYPE "small_type" #define COL_PSOURCE "psource" #define COL_PTYPE "ptype" #define COL_BIG_TYPE "big_type" #define COL_ACTOR "actor" #define COL_NEWS_MERGE "news_merge" #define COL_MINI_MERGE "mini_merge" #define COL_TIME "time" const int LOAD_TIMEOUT = 1000; //200ms const int ID_SEQ_STEP=1000; class DbHelper: public MyUtil::Singleton<DbHelper> { public: DbHelper():_curIndex(-1), _topIndex(-1) {}; FeedIndexSeq getFeedIndex(int stype, Ice::Long source, int actor); FeedIndexSeq getFeedIndexByTime(Ice::Long source, int stype, int actor, int time); FeedIndexSeq getFeedIndexBySource(int stype, Ice::Long source); FeedIndexSeq getFeedIndexByPsource(int ptype, Ice::Long psource); FeedIndexPtr getFeedIndex(Ice::Long feed); FeedIndexSeq getFeedIndexBC(int stype,Ice::Long source,int actor); map<string,string> getFeedContent(Ice::Long feed_id); map<string,string> getFeedZoneContent(Ice::Long feed_id); bool copyFeedContent(Ice::Long old_feed_id, Ice::Long new_feed_id, int new_type, const string& new_props); bool copyFeedZoneContent(Ice::Long old_feed_id, Ice::Long new_feed_id, int new_type, const string& new_props); map<string,string> getFeedConfigProp(Ice::Long fid); map<string,string> getFeedZoneConfigProp(Ice::Long fid); bool isNewFeedidForDb(long feedid) { return (feedid / DB_CONTENT_ZONE) >= DB_ZONE_SPLIT || feedid < 0; } //拆分新旧新鲜事feedid列表 void SplitFeedidsForDb(const MyUtil::LongSeq & feedids, MyUtil::LongSeq & oldids, MyUtil::LongSeq & newids) { for(MyUtil::LongSeq::const_iterator it = feedids.begin(); it != feedids.end(); ++it) { if (isNewFeedidForDb(*it)) { newids.push_back(*it); } else { oldids.push_back(*it); } } } string getIndexTab(Ice::Long feed) { ostringstream tab; tab << "feed_index_" << feed % 10; return tab.str(); } string getIndexBCTab(Ice::Long feed) { ostringstream tab; tab << "feed_index_bc_" << (-feed) % 10; return tab.str(); } string getContentTab(Ice::Long feed) { ostringstream tab; tab << "feed_content_" << feed % 100; return tab.str(); } string getZoneContentTab(Ice::Long feed) { ostringstream tab; //tab << "feed_content_" << feed % 100 << "_" << feed/DB_CONTENT_ZONE; if (feed > 0) { tab << "feed_content_" << feed % 100 << "_" << feed/DB_CONTENT_ZONE; } else { tab << "feed_content_bc_" << abs(feed)%100 << "_" << abs(feed)/DB_CONTENT_ZONE; } MCE_DEBUG("DbHelper::getZoneContentTable --> feed:" << feed << " tab:"<< tab.str()); return tab.str(); } string getZoneContentTab(int mod, int zone) { ostringstream tab; //tab << "feed_content_" << mod << "_" << zone; if (zone > 0) { tab << "feed_content_" << mod << "_" << zone; } else { tab << "feed_content_bc_" << abs(mod) << "_" << abs(zone); } MCE_DEBUG("DbHelper::getZoneContentTable --> mod:" << mod << " zone:" << zone << " tab:"<< tab.str()); return tab.str(); } string getMiniTab(int user,bool after_2009) { ostringstream tab; tab << "feed_mini_"; if(!after_2009) { tab<<"bc_"; } tab<< user % 100; return tab.str(); } string getMiniDB(bool after_2009) { if(after_2009) return "feed_db"; else return "feed_content_db"; } string getSchoolTab(int schoolid) { ostringstream tab; tab << "feed_school_" << schoolid % 10; return tab.str(); } string getGroupTab(int groupid) { ostringstream tab; tab << "feed_group_" << groupid % 100; return tab.str(); } Ice::Long _curIndex; Ice::Long _topIndex; IceUtil::Mutex _mutex; }; class IndexLoader; typedef IceUtil::Handle<IndexLoader> IndexLoaderPtr; class IndexLoader: public IceUtil::Shared, public IceUtil::Monitor< IceUtil::Mutex> { public: IndexLoader() : _count(0) { } ; FeedIndexSeq query(); void addQuery(const string& dbInstance, const string& sql, const string& pattern, bool isSelect = true); void finish(FeedIndexSeq& indexSeq) { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); _indexSeq.insert(_indexSeq.end(), indexSeq.begin(), indexSeq.end()); if (--_count == 0) { //MCE_INFO("IndexLoader --> finish res.size:"<<_indexSeq.size()); notify(); }; } void finish() { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); if (--_count == 0) { notify(); }; } private: int _count; vector<MyUtil::TaskPtr> _taskSeq; FeedIndexSeq _indexSeq; class SqlExecuteTask: public MyUtil::Task { public: SqlExecuteTask(const IndexLoaderPtr& loader, bool isSelect) : Task(DB_TASK_LEVEL), _loader(loader), _isSelect(isSelect) { } ; void init(const string& dbInstance, const string& sql, const string& pattern) { _sql << sql; _dbInstance = dbInstance; _pattern = pattern; } ; virtual void handle(); private: IndexLoaderPtr _loader; bool _isSelect; Statement _sql; string _dbInstance; string _pattern; }; }; } ; } ; #endif /* DBHELPER_H_ */
[ "liyong19861014@gmail.com" ]
liyong19861014@gmail.com
83234fc3fc2051ea0ad19d8eb789caf03fcd2401
3438e8c139a5833836a91140af412311aebf9e86
/chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views.cc
c31f0fa70b96223a7fceaafa31c14376f4f1358f
[ "BSD-3-Clause" ]
permissive
Exstream-OpenSource/Chromium
345b4336b2fbc1d5609ac5a67dbf361812b84f54
718ca933938a85c6d5548c5fad97ea7ca1128751
refs/heads/master
2022-12-21T20:07:40.786370
2016-10-18T04:53:43
2016-10-18T04:53:43
71,210,435
0
2
BSD-3-Clause
2022-12-18T12:14:22
2016-10-18T04:58:13
null
UTF-8
C++
false
false
7,731
cc
// Copyright 2014 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/ui/views/apps/app_info_dialog/app_info_dialog_views.h" #include <memory> #include "base/bind.h" #include "base/command_line.h" #include "build/build_config.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_container.h" #include "chrome/browser/ui/views/apps/app_info_dialog/app_info_footer_panel.h" #include "chrome/browser/ui/views/apps/app_info_dialog/app_info_header_panel.h" #include "chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_panel.h" #include "chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/features.h" #include "components/constrained_window/constrained_window_views.h" #include "content/public/browser/web_contents.h" #include "extensions/browser/extension_registry.h" #include "extensions/common/extension.h" #include "extensions/common/manifest.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/size.h" #include "ui/views/border.h" #include "ui/views/controls/scroll_view.h" #include "ui/views/layout/box_layout.h" #include "ui/views/layout/layout_constants.h" #include "ui/views/widget/widget.h" #include "ui/views/window/dialog_delegate.h" #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/arc/arc_auth_service.h" #include "chrome/browser/ui/views/apps/app_info_dialog/arc_app_info_links_panel.h" #endif namespace { // The color of the separator used inside the dialog - should match the app // list's app_list::kDialogSeparatorColor const SkColor kDialogSeparatorColor = SkColorSetRGB(0xD1, 0xD1, 0xD1); #if defined(OS_MACOSX) bool IsAppInfoDialogMacEnabled() { const base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kDisableAppInfoDialogMac)) return false; if (command_line->HasSwitch(switches::kEnableAppInfoDialogMac)) return true; return false; // Current default. } #endif } // namespace bool CanShowAppInfoDialog() { #if defined(OS_MACOSX) static const bool can_show = IsAppInfoDialogMacEnabled(); return can_show; #else return true; #endif } gfx::Size GetAppInfoNativeDialogSize() { return gfx::Size(380, 490); } #if BUILDFLAG(ENABLE_APP_LIST) void ShowAppInfoInAppList(gfx::NativeWindow parent, const gfx::Rect& app_list_bounds, Profile* profile, const extensions::Extension* app, const base::Closure& close_callback) { views::View* app_info_view = new AppInfoDialog(parent, profile, app); views::DialogDelegate* dialog = CreateAppListContainerForView(app_info_view, close_callback); views::Widget* dialog_widget = constrained_window::CreateBrowserModalDialogViews(dialog, parent); dialog_widget->SetBounds(app_list_bounds); dialog_widget->Show(); } #endif void ShowAppInfoInNativeDialog(content::WebContents* web_contents, const gfx::Size& size, Profile* profile, const extensions::Extension* app, const base::Closure& close_callback) { gfx::NativeWindow window = web_contents->GetTopLevelNativeWindow(); views::View* app_info_view = new AppInfoDialog(window, profile, app); views::DialogDelegate* dialog = CreateDialogContainerForView(app_info_view, size, close_callback); views::Widget* dialog_widget; if (dialog->GetModalType() == ui::MODAL_TYPE_CHILD) { dialog_widget = constrained_window::ShowWebModalDialogViews(dialog, web_contents); } else { dialog_widget = constrained_window::CreateBrowserModalDialogViews(dialog, window); dialog_widget->Show(); } } AppInfoDialog::AppInfoDialog(gfx::NativeWindow parent_window, Profile* profile, const extensions::Extension* app) : dialog_header_(NULL), dialog_body_(NULL), dialog_footer_(NULL), profile_(profile), app_id_(app->id()), extension_registry_(NULL) { views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); SetLayoutManager(layout); const int kHorizontalSeparatorHeight = 1; dialog_header_ = new AppInfoHeaderPanel(profile, app); dialog_header_->SetBorder(views::Border::CreateSolidSidedBorder( 0, 0, kHorizontalSeparatorHeight, 0, kDialogSeparatorColor)); dialog_footer_ = new AppInfoFooterPanel(parent_window, profile, app); dialog_footer_->SetBorder(views::Border::CreateSolidSidedBorder( kHorizontalSeparatorHeight, 0, 0, 0, kDialogSeparatorColor)); if (!dialog_footer_->has_children()) { // If there are no controls in the footer, don't add it to the dialog. delete dialog_footer_; dialog_footer_ = NULL; } // Make a vertically stacked view of all the panels we want to display in the // dialog. views::View* dialog_body_contents = new views::View(); dialog_body_contents->SetLayoutManager( new views::BoxLayout(views::BoxLayout::kVertical, views::kButtonHEdgeMarginNew, views::kPanelVertMargin, views::kUnrelatedControlVerticalSpacing)); dialog_body_contents->AddChildView(new AppInfoSummaryPanel(profile, app)); dialog_body_contents->AddChildView(new AppInfoPermissionsPanel(profile, app)); #if defined(OS_CHROMEOS) // When ARC is enabled, show the "Manage supported links" link for Chrome. if (arc::ArcAuthService::Get()->IsArcEnabled() && app->id() == extension_misc::kChromeAppId) dialog_body_contents->AddChildView(new ArcAppInfoLinksPanel(profile, app)); #endif // Clip the scrollable view so that the scrollbar appears. As long as this // is larger than the height of the dialog, it will be resized to the dialog's // actual height. // TODO(sashab): Add ClipHeight() as a parameter-less method to // views::ScrollView() to mimic this behaviour. const int kMaxDialogHeight = 1000; dialog_body_ = new views::ScrollView(); dialog_body_->ClipHeightTo(kMaxDialogHeight, kMaxDialogHeight); dialog_body_->SetContents(dialog_body_contents); AddChildView(dialog_header_); AddChildView(dialog_body_); layout->SetFlexForView(dialog_body_, 1); if (dialog_footer_) AddChildView(dialog_footer_); // Close the dialog if the app is uninstalled, or if the profile is destroyed. StartObservingExtensionRegistry(); } AppInfoDialog::~AppInfoDialog() { StopObservingExtensionRegistry(); } void AppInfoDialog::Close() { GetWidget()->Close(); } void AppInfoDialog::StartObservingExtensionRegistry() { DCHECK(!extension_registry_); extension_registry_ = extensions::ExtensionRegistry::Get(profile_); extension_registry_->AddObserver(this); } void AppInfoDialog::StopObservingExtensionRegistry() { if (extension_registry_) extension_registry_->RemoveObserver(this); extension_registry_ = NULL; } void AppInfoDialog::OnExtensionUninstalled( content::BrowserContext* browser_context, const extensions::Extension* extension, extensions::UninstallReason reason) { if (extension->id() != app_id_) return; Close(); } void AppInfoDialog::OnShutdown(extensions::ExtensionRegistry* registry) { DCHECK_EQ(extension_registry_, registry); StopObservingExtensionRegistry(); Close(); }
[ "support@opentext.com" ]
support@opentext.com
0ec9dc19685179436b7271f316ccc15cc0d79019
90047daeb462598a924d76ddf4288e832e86417c
/third_party/WebKit/Source/bindings/tests/results/core/test_interface_3.h
ce4b771b80de11cc2d09f1a7b143322c82ca3a27
[ "BSD-3-Clause", "LGPL-2.0-or-later", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "GPL-1.0-or-later", "GPL-2.0-only", "LGPL-2.0-only", "BSD-2-Clause", "LicenseRef-scancode-other-copyleft", "MIT", "Apache-2.0" ]
permissive
massbrowser/android
99b8c21fa4552a13c06bbedd0f9c88dd4a4ad080
a9c4371682c9443d6e1d66005d4db61a24a9617c
refs/heads/master
2022-11-04T21:15:50.656802
2017-06-08T12:31:39
2017-06-08T12:31:39
93,747,579
2
2
BSD-3-Clause
2022-10-31T10:34:25
2017-06-08T12:36:07
null
UTF-8
C++
false
false
1,047
h
// Copyright 2014 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. // This file has been auto-generated by code_generator_web_agent_api.py. // DO NOT MODIFY! // This file has been generated from the Jinja2 template in // third_party/WebKit/Source/bindings/templates/web_agent_api_interface.h.tmpl // clang-format off #ifndef WEB_API_TEST_INTERFACE_3_H #define WEB_API_TEST_INTERFACE_3_H #include "platform/heap/Handle.h" namespace blink { class TestInterface3; } namespace web { class TestInterface3 : public blink::GarbageCollected<TestInterface3> { public: virtual ~TestInterface3() = default; static TestInterface3* Create(blink::TestInterface3*); DECLARE_TRACE(); protected: explicit TestInterface3(blink::TestInterface3* test_interface_3); blink::TestInterface3* test_interface_3() const; private: blink::Member<blink::TestInterface3> test_interface_3_; }; } // namespace web #endif // WEB_API_TEST_INTERFACE_3_H
[ "xElvis89x@gmail.com" ]
xElvis89x@gmail.com
0c5ef97677d764a2cacc40e8920f8603fb9ba59a
0932a1d94a15ef74294acde30e1bc3267084e3f4
/OJ/LOJ/1080.cpp
5a7a342775640fa4e5cb2e713f0a98d3a8968f3f
[]
no_license
wuzhen247/ACM-ICPC
9e585cb425cb0a5d2698f4c603f04a04ade84b88
65b5ab5e86c07e9f1d7c5c8e42f704bbabc8c20d
refs/heads/master
2020-05-17T19:51:48.804361
2016-09-03T12:21:59
2016-09-03T12:21:59
33,580,771
0
0
null
null
null
null
UTF-8
C++
false
false
325
cpp
#include <iostream> using namespace std; int main() { int a[100][3]; int n; while(cin>>n) { for(int i;i<n;i++) { for(int j=0;j<3;j++) { cin>>a[i][j]; } if(a[i][0]+a[i][1]>a[i][2]&&a[i][1]+a[i][2]>a[i][0]&&a[i][0]+a[i][2]>a[i][1]) cout<<'Y'<<endl; else cout<<'N'<<endl; } } return 1; }
[ "aaronzark@163.com" ]
aaronzark@163.com
b49eb0b8757f059812d30266af8843f5c9c02a9f
5d44c4dbbeccf48a4b789bca37fce483abe5cf16
/src/ast_to_hir/Desugar.h
d200ce18d3fb2d74a752a593d18d689f39c9f9b7
[]
no_license
pbiggar/phc
13ec82817db6854e8541758a1f7e57da292ff1f1
96adc7bef3e222532196846c1f11ea4b2bc7930e
refs/heads/master
2023-03-10T18:06:00.905163
2021-07-08T14:55:32
2021-07-08T14:55:32
2,450,161
121
41
null
2021-07-08T14:55:33
2011-09-24T14:54:32
C++
UTF-8
C++
false
false
1,195
h
/* * phc -- the open source PHP compiler * See doc/license/README.license for licensing information * * Reduce the amount of statement types needed by adding temporaries where * there were none before. */ #ifndef PHC_DESUGAR_H #define PHC_DESUGAR_H #include "AST_transform.h" class Desugar : public AST::Transform, virtual public GC_obj { AST::CLASS_NAME* current_class; AST::CLASS_NAME* parent_class; AST::INTERFACE_NAME* current_interface; AST::Expr* pre_unary_op(AST::Unary_op* in); void pre_declare (AST::Declare*, AST::Statement_list*); void pre_nop(AST::Nop*, AST::Statement_list*); void pre_return(AST::Return*, AST::Statement_list*); AST::OP* pre_op (AST::OP* in); AST::CAST* pre_cast (AST::CAST* in); void pre_method (AST::Method* in, AST::Method_list* out); AST::METHOD_NAME* pre_method_name (AST::METHOD_NAME* in); AST::Expr* pre_constant (AST::Constant* in); void pre_class_def (AST::Class_def* in, AST::Statement_list* out); AST::CLASS_NAME* pre_class_name (AST::CLASS_NAME* in); void pre_interface (AST::Interface_def* in, AST::Statement_list* out); AST::INTERFACE_NAME* pre_interface_name (AST::INTERFACE_NAME* in); }; #endif // PHC_DESUGAR_H
[ "paul.biggar@gmail.com" ]
paul.biggar@gmail.com
fe9c48a13c57aa1a94b3b15df00cb761eaf9a043
6c3a8aa11aa1b8377819948832424bab23848aad
/AsrServiceProxy/config/src/config_util.cpp
f1e5d1c238b4e7a6c8df9e5167a52c630212c744
[]
no_license
Lance-Gao/OneThingAssist
ba1dba04b403b17982a65058b88045e3c9744142
6a761e992e05b800dc20911d53d0c90a2c0d5e06
refs/heads/master
2023-08-04T06:02:56.809040
2021-09-13T10:58:10
2021-09-13T10:58:10
380,262,801
0
0
null
null
null
null
UTF-8
C++
false
false
500
cpp
#include "config_util.hpp" #include "detail/config_impl_util.hpp" namespace config { ConfigUtil::ConfigUtil() { // private } std::string ConfigUtil::quote_string(const std::string& s) { return ConfigImplUtil::render_json_string(s); } std::string ConfigUtil::join_path(const VectorString& elements) { return ConfigImplUtil::join_path(elements); } VectorString ConfigUtil::split_path(const std::string& path) { return ConfigImplUtil::split_path(path); } }
[ "gaozhili01@baidu.com" ]
gaozhili01@baidu.com
e547013700c4d2f72664b640a2f02bdb45046fa8
e995045f93726a1c51ee5c8eac32516d21206503
/libraries/systemlib/startup/icxxabi.cpp
755762540a5fe3379c93933b08ac264f5ae08fe4
[ "MIT" ]
permissive
pdpdds/CyanOS
9b4d3c497a9b7fc8a1d9a8cce7cb8f0029f54513
1e42772911299a40aab0e7aac50181b180941800
refs/heads/master
2023-08-28T17:30:23.864817
2021-10-11T15:07:07
2021-10-11T15:07:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,034
cpp
extern "C" { #include "icxxabi.h" #include "../Types.h" atexitFuncEntry_t __atexitFuncs[ATEXIT_FUNC_MAX]; uarch_t __atexitFuncCount = 0; void* __dso_handle = 0; int __cxa_atexit(void (*f)(void*), void* objptr, void* dso) { if (__atexitFuncCount >= ATEXIT_FUNC_MAX) { return -1; } __atexitFuncs[__atexitFuncCount].destructorFunc = f; __atexitFuncs[__atexitFuncCount].objPtr = objptr; __atexitFuncs[__atexitFuncCount].dsoHandle = dso; __atexitFuncCount++; return 0; } void __cxa_finalize(void* f) { signed i = __atexitFuncCount; if (!f) { while (i--) { if (__atexitFuncs[i].destructorFunc) { (*__atexitFuncs[i].destructorFunc)(__atexitFuncs[i].objPtr); } } return; } for (; i >= 0; i--) { if (reinterpret_cast<void*>(__atexitFuncs[i].destructorFunc) == f) { (*__atexitFuncs[i].destructorFunc)(__atexitFuncs[i].objPtr); __atexitFuncs[i].destructorFunc = 0; } } } void __cxa_pure_virtual() { // PANIC("Virtual function has no implementation!"); } void atexit() { // PANIC("Exiting!"); } }
[ "Aymen.sekhri@live.fr" ]
Aymen.sekhri@live.fr
4bad1b4f9b827129c32ed845b012e474edb07ac0
5e8d200078e64b97e3bbd1e61f83cb5bae99ab6e
/main/source/src/protocols/antibody/grafting/scs_subst_mat.fwd.hh
c84ce10c304be875c4810e25c510b858c7d5eebe
[]
no_license
MedicaicloudLink/Rosetta
3ee2d79d48b31bd8ca898036ad32fe910c9a7a28
01affdf77abb773ed375b83cdbbf58439edd8719
refs/heads/master
2020-12-07T17:52:01.350906
2020-01-10T08:24:09
2020-01-10T08:24:09
232,757,729
2
6
null
null
null
null
UTF-8
C++
false
false
1,346
hh
// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*- // vi: set ts=2 noet: // // (c) Copyright Rosetta Commons Member Institutions. // (c) This file is part of the Rosetta software suite and is made available under license. // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons. // (c) For more information, see http://www.rosettacommons.org. Questions about this can be // (c) addressed to University of Washington CoMotion, email: license@uw.edu. /// @file src/protocols/antibody/grafting/scs_subst_mat.fwd.hh /// @brief Structural Component Selector (SCS) implementation using substition matrices /// @author Brian D. Weitzner #ifndef INCLUDED_protocols_antibody_grafting_scs_subst_mat_fwd_hh #define INCLUDED_protocols_antibody_grafting_scs_subst_mat_fwd_hh #include <utility/pointer/owning_ptr.hh> namespace protocols { namespace antibody { namespace grafting { struct SCS_SubstitutionMatrixResult; typedef utility::pointer::shared_ptr< SCS_SubstitutionMatrixResult > SCS_SubstitutionMatrixResultOP; typedef utility::pointer::shared_ptr< SCS_SubstitutionMatrixResult const > SCS_SubstitutionMatrixResultCOP; } // namespace grafting } // namespace antibody } // namespace protocols #endif // INCLUDED_protocols_antibody_grafting_scs_subst_mat_fwd_hh
[ "36790013+MedicaicloudLink@users.noreply.github.com" ]
36790013+MedicaicloudLink@users.noreply.github.com
b8cd4444e940c08e61a79938a4501d8f06ea210f
020a257f44bc7bf60e5f0a3974a1e194375fd393
/990. Satisfiability of Equality Equations.cpp
d1a40f911ee96c14117af48866e7e6b531e8d368
[]
no_license
rajeevpodar/leetCodeSolutions
3374bd2e16285f3b579b82aeee4d817263a86ec1
2d6e15006df5ee6121005517eeb2050309f804e3
refs/heads/master
2020-08-15T04:40:49.307732
2019-11-14T13:47:51
2019-11-14T13:47:51
215,281,456
0
0
null
null
null
null
UTF-8
C++
false
false
2,790
cpp
//https://leetcode.com/problems/satisfiability-of-equality-equations/ /** 1. Create a nodes for each char and if the equation is == then make them children of each other. 2. Update there uid, all different connected components have unique uid associated with them. 3. For each != equation check if those char belongs to same uid then result is False. **/ class Solution { struct Node { char _ch; list<Node*> _kids; int _uid{0}; Node(char ch):_ch(ch) {} }; map<char,Node*> _nodes; void printNodes() const { for(auto it = _nodes.begin(); it != _nodes.end(); ++it) { cout<<it->first<<" : "<<it->second->_uid<<endl; } } void createGraph(const vector<string>& equations) { for(auto word: equations) { auto it1 = _nodes.find(word[0]); auto it2 = _nodes.find(word[3]); Node* n1 = (it1 == _nodes.end()) ? new Node(word[0]): it1->second; Node* n2 = (it2 == _nodes.end()) ? new Node(word[3]): it2->second; // Connect nodes if they has to be ==, // else they need to be part of different connected components. if ( word[1] != '!') { n1->_kids.push_back(n2); n2->_kids.push_back(n1); } _nodes[word[0]] = n1; _nodes[word[3]] = n2; } } void updateColoringComponents() { int uid = 0; for(auto it = _nodes.begin(); it != _nodes.end(); ++it) { ++uid; if ( it->second->_uid > 0 ) { continue; } stack<Node*> myStack; myStack.push(it->second); while(!myStack.empty()) { auto cNode = myStack.top(); myStack.pop(); cNode->_uid = uid; for(auto kid : cNode->_kids) { if ( kid->_uid == 0) { myStack.push(kid); kid->_uid = uid; } } } } } public: bool equationsPossible(vector<string>& equations) { bool result = true; createGraph(equations); updateColoringComponents(); //printNodes(); // Check for != equations. for(auto word: equations) { if ( word[1] == '=') { continue; } auto it1 = _nodes.find(word[0]); auto it2 = _nodes.find(word[3]); if ( it1 != _nodes.end() && it2 != _nodes.end()) { if ( it1->second->_uid == it2->second->_uid) { result = false; break; } } } return result; } };
[ "noreply@github.com" ]
noreply@github.com
789f82fc1c95610e8f739ed38ac668010a1400a7
297497957c531d81ba286bc91253fbbb78b4d8be
/third_party/jpeg-xl/lib/jxl/quantizer_test.cc
ad50997f2b052227626b82e5ff362c31acf776e9
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "LicenseRef-scancode-generic-cla" ]
permissive
marco-c/gecko-dev-comments-removed
7a9dd34045b07e6b22f0c636c0a836b9e639f9d3
61942784fb157763e65608e5a29b3729b0aa66fa
refs/heads/master
2023-08-09T18:55:25.895853
2023-08-01T00:40:39
2023-08-01T00:40:39
211,297,481
0
0
NOASSERTION
2019-09-29T01:27:49
2019-09-27T10:44:24
C++
UTF-8
C++
false
false
2,530
cc
#include "lib/jxl/quantizer.h" #include "lib/jxl/base/span.h" #include "lib/jxl/common.h" #include "lib/jxl/dec_bit_reader.h" #include "lib/jxl/enc_fields.h" #include "lib/jxl/image_ops.h" #include "lib/jxl/image_test_utils.h" #include "lib/jxl/testing.h" namespace jxl { namespace { void TestEquivalence(int qxsize, int qysize, const Quantizer& quantizer1, const Quantizer& quantizer2) { ASSERT_NEAR(quantizer1.inv_quant_dc(), quantizer2.inv_quant_dc(), 1e-7); } TEST(QuantizerTest, QuantizerParams) { for (uint32_t i = 1; i < 10000; ++i) { QuantizerParams p; p.global_scale = i; size_t extension_bits = 0, total_bits = 0; EXPECT_TRUE(Bundle::CanEncode(p, &extension_bits, &total_bits)); EXPECT_EQ(0u, extension_bits); EXPECT_GE(total_bits, 4u); } } TEST(QuantizerTest, BitStreamRoundtripSameQuant) { const int qxsize = 8; const int qysize = 8; DequantMatrices dequant; Quantizer quantizer1(&dequant); ImageI raw_quant_field(qxsize, qysize); quantizer1.SetQuant(0.17f, 0.17f, &raw_quant_field); BitWriter writer; QuantizerParams params = quantizer1.GetParams(); EXPECT_TRUE(WriteQuantizerParams(params, &writer, 0, nullptr)); writer.ZeroPadToByte(); const size_t bits_written = writer.BitsWritten(); Quantizer quantizer2(&dequant); BitReader reader(writer.GetSpan()); EXPECT_TRUE(quantizer2.Decode(&reader)); EXPECT_TRUE(reader.JumpToByteBoundary()); EXPECT_EQ(reader.TotalBitsConsumed(), bits_written); EXPECT_TRUE(reader.Close()); TestEquivalence(qxsize, qysize, quantizer1, quantizer2); } TEST(QuantizerTest, BitStreamRoundtripRandomQuant) { const int qxsize = 8; const int qysize = 8; DequantMatrices dequant; Quantizer quantizer1(&dequant); ImageI raw_quant_field(qxsize, qysize); quantizer1.SetQuant(0.17f, 0.17f, &raw_quant_field); float quant_dc = 0.17f; ImageF qf(qxsize, qysize); RandomFillImage(&qf, 0.0f, 1.0f); quantizer1.SetQuantField(quant_dc, qf, &raw_quant_field); BitWriter writer; QuantizerParams params = quantizer1.GetParams(); EXPECT_TRUE(WriteQuantizerParams(params, &writer, 0, nullptr)); writer.ZeroPadToByte(); const size_t bits_written = writer.BitsWritten(); Quantizer quantizer2(&dequant); BitReader reader(writer.GetSpan()); EXPECT_TRUE(quantizer2.Decode(&reader)); EXPECT_TRUE(reader.JumpToByteBoundary()); EXPECT_EQ(reader.TotalBitsConsumed(), bits_written); EXPECT_TRUE(reader.Close()); TestEquivalence(qxsize, qysize, quantizer1, quantizer2); } } }
[ "mcastelluccio@mozilla.com" ]
mcastelluccio@mozilla.com
586a64b3c1f71091c44361fe2cac4a1ecfe5ac95
f844b0a742fd728dbf74053e779d6547a0a9fec3
/VTIL-Common/math/bitwise.hpp
7ee651cca4b37575a3d7fe0caa8a6094fbb1ffab
[]
permissive
sparkyparrot/VTIL-Core
cf60387470dde8a8df98a80d9d09b772e576633f
6469f59686e66353a4415f74cd95f2255dc33356
refs/heads/master
2023-01-14T13:27:19.543367
2020-11-16T19:42:05
2020-11-16T19:42:05
313,408,718
0
0
BSD-3-Clause
2020-11-16T19:42:06
2020-11-16T19:40:42
null
UTF-8
C++
false
false
18,142
hpp
// Copyright (c) 2020 Can Boluk and contributors of the VTIL Project // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of VTIL Project nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // #pragma once #include <stdint.h> #include <math.h> #include <optional> #include <type_traits> #include <numeric> #include "../util/reducable.hpp" #include "../io/asserts.hpp" #include "../util/type_helpers.hpp" // Declare the type we will used for bit lenghts of data. // - We are using int instead of char since most operations will end up casting // this value to an integer anyway and since char does not provide us any intrinsic // safety either this only hurts us in terms of performance. // using bitcnt_t = int; namespace vtil::math { // Narrows the given type in a safe manner. // template<Integral T, Integral T2> static constexpr T narrow_cast( T2 o ) { static_assert( sizeof( T ) <= sizeof( T2 ), "Narrow cast is extending." ); if constexpr ( std::is_signed_v<T2> ^ std::is_signed_v<T> ) dassert( 0 <= o && o <= std::numeric_limits<T>::max() ); else dassert( std::numeric_limits<T>::min() <= o && o <= std::numeric_limits<T>::max() ); return ( T ) o; } // Extracts the sign bit from the given value. // template<Integral T> static constexpr bool sgn( T type ) { return bool( type >> ( ( sizeof( T ) * 8 ) - 1 ) ); } // Implement platform-indepdenent bitwise operations. // static constexpr bitcnt_t popcnt( uint64_t x ) { // Optimized using intrinsic on MSVC, Clang should be smart enough to do this on its own. // #ifdef _MSC_VER if ( !std::is_constant_evaluated() ) { return ( bitcnt_t ) __popcnt64( x ); } #endif bitcnt_t count = 0; for ( bitcnt_t i = 0; i < 64; i++, x >>= 1 ) count += ( bitcnt_t ) ( x & 1 ); return count; } static constexpr bitcnt_t msb( uint64_t x ) { // Optimized using intrinsic on MSVC, Clang should be smart enough to do this on its own. // #ifdef _MSC_VER if ( !std::is_constant_evaluated() ) { unsigned long idx = 0; return _BitScanReverse64( &idx, x ) ? ( bitcnt_t ) idx + 1 : 0; } #endif // Return index + 1 on success: // for ( bitcnt_t i = 63; i >= 0; i-- ) if ( x & ( 1ull << i ) ) return i + 1; // Zero otherwise. // return 0; } static constexpr bitcnt_t lsb( uint64_t x ) { // Optimized using intrinsic on MSVC, Clang should be smart enough to do this on its own. // #ifdef _MSC_VER if ( !std::is_constant_evaluated() ) { unsigned long idx = 0; return _BitScanForward64( &idx, x ) ? ( bitcnt_t ) idx + 1 : 0; } #endif // Return index + 1 on success: // for ( bitcnt_t i = 0; i <= 63; i++ ) if ( x & ( 1ull << i ) ) return i + 1; // Zero otherwise. // return 0; } static constexpr bool bit_test( uint64_t value, bitcnt_t n ) { // Optimized using intrinsic on MSVC, Clang should be smart enough to do this on its own. // #ifdef _MSC_VER if ( !std::is_constant_evaluated() ) return _bittest64( ( long long* ) &value, n ); #endif return value & ( 1ull << n ); } static constexpr bool bit_set( uint64_t& value, bitcnt_t n ) { // Optimized using intrinsic on MSVC, Clang should be smart enough to do this on its own. // #ifdef _MSC_VER if ( !std::is_constant_evaluated() ) return _bittestandset64( ( long long* ) &value, n ); #endif uint64_t mask = ( 1ull << ( n & 63 ) ); bool is_set = value & mask; value |= mask; return is_set; } static constexpr bool bit_reset( uint64_t& value, bitcnt_t n ) { // Optimized using intrinsic on MSVC, Clang should be smart enough to do this on its own. // #ifdef _MSC_VER if ( !std::is_constant_evaluated() ) return _bittestandreset64( ( long long* ) &value, n ); #endif uint64_t mask = ( 1ull << ( n & 63 ) ); bool is_set = value & mask; value &= ~mask; return is_set; } // Used to find a bit with a specific value in a linear memory region. // static constexpr size_t bit_npos = ( size_t ) -1; template<typename T> static constexpr size_t bit_find( const T* begin, const T* end, bool value, bool reverse = false ) { constexpr size_t bit_size = sizeof( T ) * 8; using uint_t = std::make_unsigned_t<T>; using int_t = std::make_signed_t<T>; const auto scanner = reverse ? msb : lsb; // Generate the xor mask, if we're looking for 1, -!1 will evaluate to 0, // otherwise -!0 will evaluate to 0xFF.. in order to flip all bits. // uint_t xor_mask = ( uint_t ) ( -( ( int_t ) !value ) ); // Loop each block: // size_t n = 0; for ( auto it = begin; it != end; it++, n += bit_size ) { // If we could find the bit in the block: // if ( bitcnt_t i = scanner( *it ^ xor_mask ) ) { // Return after adjusting the index. // return n + i - 1; } } // Return invalid index. // return bit_npos; } // Used to enumerate each set bit in the integer. // template<typename T> static constexpr void bit_enum( uint64_t mask, T&& fn, bool reverse = false ) { const auto scanner = reverse ? msb : lsb; while ( true ) { // If scanner returns 0, break. // bitcnt_t idx = scanner( mask ); if ( idx == 0 ) return; // Adjust the index, reset the bit and invoke the callback. // bit_reset( mask, --idx ); fn( idx ); } } // Generate a mask for the given variable size and offset. // static constexpr uint64_t fill( bitcnt_t bit_count, bitcnt_t bit_offset = 0 ) { // If bit count is not a positive value, return zero. // if ( bit_count <= 0 ) return 0; // Determine shift direction and magnitude. // - Could have used calculated [sgn] instead of second comparison but // this makes it easier for the compiler to optimize into cmovcc. // bool is_shl = bit_offset >= 0; bitcnt_t abs_shift = is_shl ? bit_offset : -bit_offset; // Shifting beyond the variable size cause unexpected (mod) behaviour // on x64, check the shift count first. // if ( abs_shift >= 64 ) return 0; // Fill with [bit_count] x [1] starting from the lowest bit. // uint64_t abs_value = ( ~0ull ) >> ( 64 - bit_count ); // Shift accordingly. // if( is_shl ) return abs_value << abs_shift; else return abs_value >> abs_shift; } // Fills the bits of the uint64_t type after the given offset with the sign bit. // - We accept an [uint64_t] as the sign "bit" instead of a for // the sake of a further trick we use to avoid branches. // static constexpr uint64_t fill_sign( uint64_t sign, bitcnt_t bit_offset = 0 ) { // The XOR operation with 0b1 flips the sign bit, after which when we subtract // one to create 0xFF... for (1) and 0x00... for (0). // return ( ( sign ^ 1 ) - 1 ) << bit_offset; } // Extends the given integral type into uint64_t or int64_t. // template<Integral T> static constexpr auto imm_extend( T imm ) { if constexpr ( std::is_signed_v<T> ) return ( int64_t ) imm; else return ( uint64_t ) imm; } // Implement the jump-table based, compiler optimized sign/zero extension. // namespace impl { // For all N except 0 / 1 / 64: // template<auto N> struct integer_resizer { static_assert( N <= 63, "Invalid table generation." ); union zx_t { uint64_t input; struct { unsigned long long result : N; }; }; union sx_t { uint64_t input; struct { signed long long result : N; }; }; static constexpr uint64_t zx( uint64_t value ) { return zx_t{ value }.result; } static constexpr int64_t sx( uint64_t value ) { return sx_t{ value }.result; } }; // N = 64 should return as is. // template<> struct integer_resizer<64> { static constexpr uint64_t zx( uint64_t value ) { return value; } static constexpr int64_t sx( uint64_t value ) { return value; } }; // N = 1 should not perform sign extension as it's intended for boolean use. // template<> struct integer_resizer<1> { static constexpr uint64_t zx( uint64_t value ) { return value & 1; } static constexpr int64_t sx( uint64_t value ) { return value & 1; } }; // N = 0 should throw upon invokation. // template<> struct integer_resizer<0> { static uint64_t zx( uint64_t value ) { unreachable(); } static int64_t sx( uint64_t value ) { unreachable(); } }; // Generate entire table. // static constexpr std::array zx_table = make_visitor_series<65, integer_resizer>( [ ] ( auto tag ) { return &decltype( tag )::type::zx; } ); static constexpr std::array sx_table = make_visitor_series<65, integer_resizer>( [ ] ( auto tag ) { return &decltype( tag )::type::sx; } ); }; // Zero extends the given integer. // static constexpr uint64_t zero_extend( uint64_t value, bitcnt_t bcnt_src ) { dassert( 0 < bcnt_src && bcnt_src <= 64 ); return impl::zx_table[ bcnt_src ]( value ); } // Sign extends the given integer. // static constexpr int64_t sign_extend( uint64_t value, bitcnt_t bcnt_src ) { dassert( 0 < bcnt_src && bcnt_src <= 64 ); return impl::sx_table[ bcnt_src ]( value ); } // Return value from bit-vector lookup where the result can be either unknown or constant 0/1. // enum class bit_state : int8_t { zero = -1, unknown = 0, one = +1, }; // Bit-vector holding 0 to 64 bits of value with optional unknowns. // class bit_vector : public reducable<bit_vector> { // Value of the known bits, mask of it can be found by [::known_mask()] // - Guaranteed to hold 0 for unknown bits. // uint64_t known_bits = 0; // Mask for the bit that we do not know. // - Guaranteed to hold 0 for known bits and for all bits above bit_count. // uint64_t unknown_bits = 0; // Number of bits this vector contains. // bitcnt_t bit_count = 0; public: // Default constructor, will result in invalid bit-vector. // constexpr bit_vector() = default; // Constructs a bit-vector where all bits are set according to the state. // - Declared explicit to avoid construction from integers. // constexpr explicit bit_vector( bitcnt_t bit_count ) : bit_count( bit_count ), unknown_bits( fill( bit_count ) ), known_bits( 0 ) {} // Constructs a bit-vector where all bits are known. // constexpr bit_vector( uint64_t value, bitcnt_t bit_count ) : bit_count( bit_count ), unknown_bits( 0 ), known_bits( value & fill( bit_count ) ) {} // Constructs a bit-vector where bits are partially known. // constexpr bit_vector( uint64_t known_bits, uint64_t unknown_bits, bitcnt_t bit_count ) : bit_count( bit_count ), unknown_bits( unknown_bits & fill( bit_count ) ), known_bits( known_bits & ( ~unknown_bits ) & fill( bit_count ) ) {} // Some helpers to access the internal state. // constexpr uint64_t value_mask() const { return fill( bit_count ); } constexpr uint64_t unknown_mask() const { return unknown_bits; } constexpr uint64_t known_mask() const { return fill( bit_count ) & ~unknown_bits; } constexpr uint64_t known_one() const { return known_bits; } constexpr uint64_t known_zero() const { return ~( unknown_bits | known_bits ); } constexpr bool all_zero() const { return unknown_bits == 0 && !known_bits; } constexpr bool all_one() const { return unknown_bits == 0 && ( known_bits == fill( bit_count ) ); } constexpr bool is_valid() const { return bit_count != 0; } constexpr bool is_known() const { return bit_count && unknown_bits == 0; } constexpr bool is_unknown() const { return !bit_count || unknown_bits != 0; } constexpr bitcnt_t size() const { return bit_count; } // Gets the value represented, and nullopt if vector has unknown bits. // template<typename type> constexpr std::optional<type> get() const { if ( is_known() ) { if constexpr ( std::is_signed_v<type> ) return ( type ) sign_extend( known_bits, bit_count ); else return ( type ) zero_extend( known_bits, bit_count ); } return std::nullopt; } template<bool as_signed = false, typename type = std::conditional_t<as_signed, int64_t, uint64_t>> constexpr std::optional<type> get() const { return get<type>(); } // Extends or shrinks the the vector. // constexpr bit_vector& resize( bitcnt_t new_size, bool signed_cast = false ) { fassert( 0 < new_size && new_size <= 64 ); if( signed_cast && new_size > bit_count ) { bit_state sign_bit = at( bit_count - 1 ); bool sign_bit_unk = at( bit_count - 1 ) == bit_state::unknown; if ( sign_bit == bit_state::unknown ) unknown_bits |= fill( 64, bit_count ); else if ( sign_bit == bit_state::one ) known_bits |= fill( 64, bit_count ); } bit_count = new_size; known_bits &= fill( new_size ); unknown_bits &= fill( new_size ); return *this; } // Gets the state of the bit at the index given. // constexpr bit_state at( bitcnt_t n ) const { if ( unknown_bits & ( 1ull << n ) ) return bit_state::unknown; return bit_state( ( ( ( known_bits >> n ) & 1 ) << 1 ) - 1 ); } constexpr bit_state operator[]( bitcnt_t n ) const { return at( n ); } // Conversion to human-readable format. // std::string to_string() const { std::string out; for ( int n = bit_count - 1; n >= 0; n-- ) { uint64_t mask = 1ull << n; out += ( unknown_bits & mask ) ? '?' : ( known_bits & mask ) ? '1' : '0'; } return out; } // Declare reduction. // REDUCE_TO( unknown_bits, known_bits, bit_count ); }; };
[ "can.boluk89@gmail.com" ]
can.boluk89@gmail.com
8623aa538a38136c3097b627b6011de5e8187f01
b715ddf5a16c8c4bdb2698cc1d86a6aba134ad00
/src/libs/NoWaveLib/app.cpp
8e90ef0a9c15ec8086c779ff57c107c8d5f266b8
[ "MIT" ]
permissive
Adnn/NoWave
df5de4fd69911dbdce5d1cf1ad59f40b365c37bc
edf3c97a9b352b64e93c7f72dbf515ffd29ebae4
refs/heads/master
2016-09-10T18:34:35.353318
2015-02-02T10:31:02
2015-02-02T10:31:02
18,642,767
0
0
null
null
null
null
UTF-8
C++
false
false
1,997
cpp
#include "app.h" #include "Factories.h" #include "SystemZReorder.h" #include "SystemDisplay.h" #include "SystemMove.h" #include "InputSystem.h" #include "SystemAnimation.h" #include "SystemMoveAnimation.h" #include "SystemScaling.h" #include "SystemCollision.h" #include "SystemConversation.h" #include "SystemInteraction.h" #include "SystemDisplayDialog.h" #include "SystemKeyboardControl.h" #include "SystemGameStatePolling.h" using namespace aunteater; void HardCore::init() { Polycode::CoreServices::getInstance()->getRenderer()->setTextureFilteringMode(Polycode::Renderer::TEX_FILTERING_NEAREST); Entity player = createPlayer(mScreen); mEngine.addEntity("player", player); std::vector<Entity> bgs = createBackground(mScreen); for (Entity bg : bgs) { mEngine.addEntity(bg); } std::vector<Entity> pngs = createPnj(mScreen); // Quick hack so a 'meuf' is actually addressable bool first = true; for (Entity png : pngs) { if (first) { first = false; mEngine.addEntity("meuf", png); } { mEngine.addEntity(png); } } std::vector<Entity> barriers = createBarriers(); for (Entity barrier : barriers) { mEngine.addEntity(barrier); } Entity videur = createVideur(mScreen); mEngine.addEntity("videur", videur); Entity inter = createInteractionVideur(mEngine); mEngine.addEntity(inter); new SystemDisplay(mEngine,*mScreen); new SystemKeyboardControl(mEngine); new SystemMove(mEngine); new InputSystem(mEngine); new SystemAnimation(mEngine); new SystemMoveAnimation(mEngine); new SystemScaling(mEngine); new SystemCollision(mEngine); new SystemZReorder(mEngine); new SystemConversation(mEngine, mScreen, BASE_PATH "scenarios/accroche.txt", BASE_PATH "scenarios/conversation.txt"); new SystemInteraction(mEngine); new SystemDisplayDialog(mEngine); new SystemGameStatePolling(mEngine); }
[ "adrien@astutegraphics.co.uk" ]
adrien@astutegraphics.co.uk
3a50a7fcaa3ff39797a831df571fb60aff0da641
f66d08afc3a54a78f6fdb7c494bc2624d70c5d25
/Code/CLN/src/rational/input/cl_RA_read.cc
58e9507aa3ff1d9d487732bd28b211df7431047d
[]
no_license
NBAlexis/GiNaCToolsVC
46310ae48cff80b104cc4231de0ed509116193d9
62a25e0b201436316ddd3d853c8c5e738d66f436
refs/heads/master
2021-04-26T23:56:43.627861
2018-03-09T19:15:53
2018-03-09T19:15:53
123,883,542
1
0
null
null
null
null
UTF-8
C++
false
false
5,394
cc
// read_rational(). // This file contains a slimmed down version of read_real(). // It does not pull in all the floating-point, complex and transcendental // function code. // General includes. #include "cln_private.h" // Specification. #include "cln/rational_io.h" // Implementation. #include <cstring> #include <sstream> #include "cln/input.h" #include "cln/integer.h" #include "cln/integer_io.h" #include "integer/cl_I.h" #include "cln/exception.h" namespace cln { // Step forward over all digits, to the end of string or to the next non-digit. static const char * skip_digits (const char * ptr, const char * string_limit, unsigned int base) { for ( ; ptr != string_limit; ptr++) { var char ch = *ptr; if ((ch >= '0') && (ch <= '9')) if (ch < '0' + (int)base) continue; else break; else { if (base <= 10) break; if (((ch >= 'A') && (ch < 'A'-10+(int)base)) || ((ch >= 'a') && (ch < 'a'-10+(int)base)) ) continue; else break; } } return ptr; } #define at_end_of_parse(ptr) \ if (end_of_parse) \ { *end_of_parse = (ptr); } \ else \ { if ((ptr) != string_limit) { throw read_number_junk_exception((ptr),string,string_limit); } } const cl_RA read_rational (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse) { ASSERT((flags.syntax & ~(syntax_rational|syntax_maybe_bad)) == 0); // If no string_limit is given, it defaults to the end of the string. if (!string_limit) string_limit = string + ::strlen(string); if (flags.syntax & syntax_rational) { // Check for rational number syntax. var unsigned int rational_base = flags.rational_base; var const char * ptr = string; if (flags.lsyntax & lsyntax_commonlisp) { if (ptr == string_limit) goto not_rational_syntax; if (*ptr == '#') { // Check for #b, #o, #x, #nR syntax. ptr++; if (ptr == string_limit) goto not_rational_syntax; switch (*ptr) { case 'b': case 'B': rational_base = 2; break; case 'o': case 'O': rational_base = 8; break; case 'x': case 'X': rational_base = 16; break; default: var const char * base_end_ptr = skip_digits(ptr,string_limit,10); if (base_end_ptr == ptr) goto not_rational_syntax; if (base_end_ptr == string_limit) goto not_rational_syntax; if (!((*base_end_ptr == 'r') || (*base_end_ptr == 'R'))) goto not_rational_syntax; var cl_I base = read_integer(10,0,ptr,0, static_cast<uintC>(base_end_ptr-ptr)); if (!((base >= 2) && (base <= 36))) { std::ostringstream buf; fprint(buf, "Base must be an integer in the range from 2 to 36, not "); fprint(buf, base); throw runtime_exception(buf.str()); } rational_base = static_cast<unsigned int>(FN_to_UV(base)); ptr = base_end_ptr; break; } ptr++; } } var const char * ptr_after_prefix = ptr; var cl_signean sign = 0; if (ptr == string_limit) goto not_rational_syntax; switch (*ptr) { case '-': sign = ~sign; case '+': ptr++; default: break; } var const char * ptr_after_sign = ptr; if (flags.syntax & syntax_integer) { // Check for integer syntax: {'+'|'-'|} {digit}+ {'.'|} // Allow final dot only in Common Lisp syntax if there was no #<base> prefix. if ((flags.lsyntax & lsyntax_commonlisp) && (ptr_after_prefix == string)) { ptr = skip_digits(ptr_after_sign,string_limit,10); if (ptr != ptr_after_sign) if (ptr != string_limit) if (*ptr == '.') { ptr++; if ((ptr == string_limit) || !(((*ptr >= '0') && (*ptr <= '9')) || ((*ptr >= 'A') && (*ptr <= 'Z') && (*ptr != 'I')) || ((*ptr >= 'a') && (*ptr <= 'z') && (*ptr != 'i')) || (*ptr == '.') || (*ptr == '_') || (*ptr == '/'))) { at_end_of_parse(ptr); return read_integer(10,sign,ptr_after_sign,0, static_cast<uintC>(ptr-ptr_after_sign)); } } } ptr = skip_digits(ptr_after_sign,string_limit,rational_base); if ((ptr == string_limit) || !(((*ptr >= '0') && (*ptr <= '9')) || ((*ptr >= 'A') && (*ptr <= 'Z') && (*ptr != 'I')) || ((*ptr >= 'a') && (*ptr <= 'z') && (*ptr != 'i')) || (*ptr == '.') || (*ptr == '_') || (*ptr == '/'))) { at_end_of_parse(ptr); return read_integer(rational_base,sign,ptr_after_sign,0, static_cast<uintC>(ptr-ptr_after_sign)); } } if (flags.syntax & syntax_ratio) { // Check for ratio syntax: {'+'|'-'|} {digit}+ '/' {digit}+ ptr = skip_digits(ptr_after_sign,string_limit,rational_base); if (ptr != ptr_after_sign) if (ptr != string_limit) if (*ptr == '/') { var const char * ptr_at_slash = ptr; ptr = skip_digits(ptr_at_slash+1,string_limit,rational_base); if (ptr != ptr_at_slash+1) if ((ptr == string_limit) || !(((*ptr >= '0') && (*ptr <= '9')) || ((*ptr >= 'A') && (*ptr <= 'Z') && (*ptr != 'I')) || ((*ptr >= 'a') && (*ptr <= 'z') && (*ptr != 'i')) || (*ptr == '.') || (*ptr == '_') || (*ptr == '/'))) { at_end_of_parse(ptr); return read_rational(rational_base,sign,ptr_after_sign,0, static_cast<uintC>(ptr_at_slash-ptr_after_sign), static_cast<uintC>(ptr-ptr_after_sign)); } } } } not_rational_syntax: if (flags.syntax & syntax_maybe_bad) { ASSERT(end_of_parse); *end_of_parse = string; return 0; // dummy return } throw read_number_bad_syntax_exception(string,string_limit); } } // namespace cln
[ "nbalexis@gmail.com" ]
nbalexis@gmail.com
e7339e6bb9d09ddc61f4bb0bde7e0043226b4dbf
cae3a6afa0346c1bb2b7668e704ee2a948f0e78f
/test/integration/material.cc
ff872e067d117cfedc5856c1dc3f89641ed91508
[ "Apache-2.0" ]
permissive
vatanaksoytezer/sdformat
8f193a1e638ce7365667822850babf86736dc82e
d8f841526d86c411ffd7c16b7386a0e616234bc8
refs/heads/main
2023-06-15T23:12:43.252303
2021-06-30T16:35:01
2021-06-30T16:35:01
385,698,320
0
0
NOASSERTION
2021-07-13T18:21:51
2021-07-13T18:21:50
null
UTF-8
C++
false
false
5,571
cc
/* * Copyright 2021 Open Source Robotics Foundation * * 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 <string> #include <gtest/gtest.h> #include <ignition/math/Color.hh> #include "sdf/sdf.hh" #include "test_config.h" void ExpectInvalidWithMessage(sdf::Errors &_errors, std::string _compType) { for (const auto &e : _errors) { if (e.Message().find(_compType) != std::string::npos) { EXPECT_EQ(e.Code(), sdf::ErrorCode::ELEMENT_INVALID); break; } } } ////////////////////////////////////////////////// TEST(Material, InvalidColors) { std::string testFile = sdf::testing::TestFile("sdf", "material_invalid.sdf"); sdf::Root root; sdf::Errors errors = root.Load(testFile); std::cout << errors << std::endl; ASSERT_FALSE(errors.empty()); ExpectInvalidWithMessage(errors, "ambient"); // since the above test will break at //ambient, it doesn't test the other // invalid cases. Below tests these other invalid cases // less than 3 values std::string testSDF = R"( <?xml version="1.0" ?> <sdf version="1.8"> <model name="model"> <link name="link"> <visual name="material"> <material> <specular>0 0.1</specular> </material> </visual> </link> </model> </sdf>)"; errors.clear(); errors = root.LoadSdfString(testSDF); std::cout << errors << std::endl; ASSERT_FALSE(errors.empty()); ExpectInvalidWithMessage(errors, "specular"); // negative value testSDF = R"( <?xml version="1.0" ?> <sdf version="1.8"> <model name="model"> <link name="link"> <visual name="material"> <material> <emissive>0.1 0.2 -1</emissive> </material> </visual> </link> </model> </sdf>)"; errors.clear(); errors = root.LoadSdfString(testSDF); std::cout << errors << std::endl; ASSERT_FALSE(errors.empty()); ExpectInvalidWithMessage(errors, "emissive"); // more than 4 values testSDF = R"( <?xml version="1.0" ?> <sdf version="1.8"> <model name="model"> <link name="link"> <visual name="material"> <material> <diffuse>0.1 0.2 0.3 0.4 0.5</diffuse> </material> </visual> </link> </model> </sdf>)"; errors.clear(); errors = root.LoadSdfString(testSDF); std::cout << errors << std::endl; ASSERT_FALSE(errors.empty()); ExpectInvalidWithMessage(errors, "diffuse"); // invalid string value testSDF = R"( <?xml version="1.0" ?> <sdf version="1.8"> <model name="model"> <link name="link"> <visual name="material"> <material> <ambient>0.1 0.2 test</ambient> </material> </visual> </link> </model> </sdf>)"; errors.clear(); errors = root.LoadSdfString(testSDF); std::cout << errors << std::endl; ASSERT_FALSE(errors.empty()); ExpectInvalidWithMessage(errors, "ambient"); } ////////////////////////////////////////////////// TEST(Material, ValidColors) { std::string testFile = sdf::testing::TestFile("sdf", "material_valid.sdf"); sdf::Root root; sdf::Errors errors = root.Load(testFile); std::cout << errors << std::endl; ASSERT_TRUE(errors.empty()); sdf::ElementPtr elem = root.Element()->GetElement("model") ->GetElement("link") ->GetElement("visual") ->GetElement("material"); ASSERT_NE(elem, nullptr); EXPECT_EQ(elem->Get<ignition::math::Color>("diffuse"), ignition::math::Color(0, 0.1f, 0.2f, 1)); EXPECT_EQ(elem->Get<ignition::math::Color>("specular"), ignition::math::Color(0, 0.1f, 0.2f, 0.3f)); EXPECT_EQ(elem->Get<ignition::math::Color>("emissive"), ignition::math::Color(0.12f, 0.23f, 0.34f, 0.56f)); EXPECT_EQ(elem->Get<ignition::math::Color>("ambient"), ignition::math::Color(0, 0, 0, 1)); } ////////////////////////////////////////////////// TEST(Material, URDFValidColors) { std::string testFile = sdf::testing::TestFile("sdf", "material_valid.urdf"); sdf::Root root; sdf::Errors errors = root.Load(testFile); std::cout << errors << std::endl; ASSERT_TRUE(errors.empty()); sdf::ElementPtr elem = root.Element()->GetElement("model") ->GetElement("link") ->GetElement("visual") ->GetElement("material"); ASSERT_NE(elem, nullptr); EXPECT_EQ(elem->Get<ignition::math::Color>("diffuse"), ignition::math::Color(0.0, 1.0f, 1.0f, 1)); EXPECT_EQ(elem->Get<ignition::math::Color>("specular"), ignition::math::Color(0.0, 0.0f, 0.0f, 1)); EXPECT_EQ(elem->Get<ignition::math::Color>("emissive"), ignition::math::Color(0, 0, 0, 1)); EXPECT_EQ(elem->Get<ignition::math::Color>("ambient"), ignition::math::Color(0.0, 1.0f, 1.0f, 1)); }
[ "noreply@github.com" ]
noreply@github.com
5c4368a9010c62c2dcb6678b273ae9a875b64788
5518d877732cf61f8a85163e999e539072cf6bf2
/cio/app/src/main/jni/net/Socket.h
a0a2a4e6bb27a8060f72f4b120f2bce002332fef
[]
no_license
lymons/cioforandroid
b4f4c8db7e8d4d27a07dc24cbb93949c091de1f3
31f52098a7c3bd4791d75ff2152b06f894d7cfda
refs/heads/master
2021-01-12T21:37:46.914880
2015-10-08T10:06:20
2015-10-08T10:06:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,322
h
// // Socket.h // cio // // Created by chenjianjun on 15/9/22. // Copyright © 2015年 cio. All rights reserved. // #ifndef __Socket_h_ #define __Socket_h_ #include "../base/Common.h" #include "./SocketAddress.h" namespace NAME_SPACE { inline bool IsBlockingError(int e) { return (e == EWOULDBLOCK) || (e == EAGAIN) || (e == EINPROGRESS); } class Socket { public: virtual ~Socket() {} virtual SocketAddress GetLocalAddress() const = 0; virtual SocketAddress GetRemoteAddress() const = 0; virtual int Bind(const SocketAddress& addr) = 0; virtual int Connect(const SocketAddress& addr) = 0; virtual int Send(const void *pv, size_t cb) = 0; virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr) = 0; virtual int Recv(void *pv, size_t cb) = 0; virtual int RecvFrom(void *pv, size_t cb, SocketAddress *paddr) = 0; virtual int Listen(int backlog) = 0; virtual Socket *Accept(SocketAddress *paddr) = 0; virtual int Close() = 0; virtual int GetError() const = 0; virtual void SetError(int error) = 0; inline bool IsBlocking() const { return IsBlockingError(GetError()); } enum ConnState { CS_CLOSED, CS_CONNECTING, CS_CONNECTED }; virtual ConnState GetState() const = 0; virtual int EstimateMTU(uint16* mtu) = 0; enum Option { OPT_DONTFRAGMENT, OPT_RCVBUF, // receive buffer size OPT_SNDBUF, // send buffer size OPT_NODELAY, // whether Nagle algorithm is enabled OPT_IPV6_V6ONLY, // Whether the socket is IPv6 only. OPT_DSCP, // DSCP code OPT_RTP_SENDTIME_EXTN_ID, // This is a non-traditional socket option param. // This is specific to libjingle and will be used // if SendTime option is needed at socket level. }; virtual int GetOption(Option opt, int* value) = 0; virtual int SetOption(Option opt, int value) = 0; protected: Socket(){} private: DISALLOW_EVIL_CONSTRUCTORS(Socket); }; } #endif /* __Socket_h_ */
[ "chenjianjun571@gmail.com" ]
chenjianjun571@gmail.com
4b78e935922743efdbddd8e089f41cca3c46cc73
fd7d1350eefac8a9bbd952568f074284663f2794
/ace/MMAP_Memory_Pool.cpp
259b58575deb20837ebbd967a82e7f2227e25ee6
[ "MIT" ]
permissive
binary42/OCI
4ceb7c4ed2150b4edd0496b2a06d80f623a71a53
08191bfe4899f535ff99637d019734ed044f479d
refs/heads/master
2020-06-02T08:58:51.021571
2015-09-06T03:25:05
2015-09-06T03:25:05
41,980,019
1
0
null
null
null
null
UTF-8
C++
false
false
18,440
cpp
// $Id: MMAP_Memory_Pool.cpp 2622 2015-08-13 18:30:00Z mitza $ // MMAP_Memory_Pool.cpp #include "ace/MMAP_Memory_Pool.h" #include "ace/OS_NS_sys_mman.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_sys_stat.h" #include "ace/Log_Category.h" #include "ace/Truncate.h" #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) #include "ace/Based_Pointer_T.h" #include "ace/Based_Pointer_Repository.h" #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */ #if !defined (__ACE_INLINE__) #include "ace/MMAP_Memory_Pool.inl" #endif /* __ACE_INLINE__ */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_ALLOC_HOOK_DEFINE(ACE_MMAP_Memory_Pool) void ACE_MMAP_Memory_Pool::dump (void) const { #if defined (ACE_HAS_DUMP) ACE_TRACE ("ACE_MMAP_Memory_Pool::dump"); #endif /* ACE_HAS_DUMP */ } int ACE_MMAP_Memory_Pool::release (int destroy) { ACE_TRACE ("ACE_MMAP_Memory_Pool::release"); #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) ACE_BASED_POINTER_REPOSITORY::instance ()->unbind (this->mmap_.addr ()); #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */ if (destroy) this->mmap_.remove (); else this->mmap_.close (); return 0; } int ACE_MMAP_Memory_Pool::sync (size_t len, int flags) { ACE_TRACE ("ACE_MMAP_Memory_Pool::sync"); return this->mmap_.sync (len, flags); } int ACE_MMAP_Memory_Pool::sync (int flags) { ACE_TRACE ("ACE_MMAP_Memory_Pool::sync"); size_t const len = ACE_Utils::truncate_cast<size_t> ( ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END)); return this->mmap_.sync (len, flags); } /// Sync @a len bytes of the memory region to the backing store starting /// at <addr_>. int ACE_MMAP_Memory_Pool::sync (void *addr, size_t len, int flags) { ACE_TRACE ("ACE_MMAP_Memory_Pool::sync"); return ACE_OS::msync (addr, len, flags); } // Change the protection of the pages of the mapped region to <prot> // starting at <this->base_addr_> up to <len> bytes. // Change protection of all pages in the mapped region. int ACE_MMAP_Memory_Pool::protect (size_t len, int prot) { ACE_TRACE ("ACE_MMAP_Memory_Pool::protect"); return this->mmap_.protect (len, prot); } int ACE_MMAP_Memory_Pool::protect (int prot) { ACE_TRACE ("ACE_MMAP_Memory_Pool::protect"); size_t const len = ACE_Utils::truncate_cast<size_t> ( ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END)); return this->mmap_.protect (len, prot); } // Change the protection of the pages of the mapped region to <prot> // starting at <addr> up to <len> bytes. int ACE_MMAP_Memory_Pool::protect (void *addr, size_t len, int prot) { ACE_TRACE ("ACE_MMAP_Memory_Pool::protect"); return ACE_OS::mprotect (addr, len, prot); } ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool ( const ACE_TCHAR *backing_store_name, const OPTIONS *options) : base_addr_ (0), use_fixed_addr_(0), flags_ (MAP_SHARED), write_each_page_ (false), minimum_bytes_ (0), sa_ (0), file_mode_ (ACE_DEFAULT_FILE_PERMS), install_signal_handler_ (true) { ACE_TRACE ("ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool"); #if (defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR)) || defined (ACE_WIN32) // For plaforms that give the faulting address. guess_on_fault_ = false; #else // For plaforms that do NOT give the faulting address, let the // options decide whether to guess or not. if (options) guess_on_fault_ = options->guess_on_fault_; else // If no options are specified, default to true. guess_on_fault_ = true; #endif /* (defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR)) || defined (ACE_WIN32) */ // Only change the defaults if <options> != 0. if (options) { if (options->flags_ != 0) this->flags_ = options->flags_; use_fixed_addr_ = options->use_fixed_addr_; if (use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::ALWAYS_FIXED) { this->base_addr_ = const_cast<void *> (options->base_addr_); ACE_SET_BITS (flags_, MAP_FIXED); } this->write_each_page_ = options->write_each_page_; this->minimum_bytes_ = options->minimum_bytes_; if (options->sa_ != 0) this->sa_ = options->sa_; this->file_mode_ = options->file_mode_; this->install_signal_handler_ = options->install_signal_handler_; } if (backing_store_name == 0) { // Only create a new unique filename for the backing store file // if the user didn't supply one... #if defined (ACE_DEFAULT_BACKING_STORE) // Create a temporary file. ACE_OS::strcpy (this->backing_store_name_, ACE_DEFAULT_BACKING_STORE); #else /* ACE_DEFAULT_BACKING_STORE */ if (ACE::get_temp_dir (this->backing_store_name_, MAXPATHLEN - 17) == -1) // -17 for ace-malloc-XXXXXX { ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("Temporary path too long, ") ACE_TEXT ("defaulting to current directory\n"))); this->backing_store_name_[0] = 0; } // Add the filename to the end ACE_OS::strcat (this->backing_store_name_, ACE_TEXT ("ace-malloc-XXXXXX")); // If requested an unique filename, use mktemp to get a random file. if (options && options->unique_) # if defined (ACE_DISABLE_MKTEMP) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("mktemp disabled; ") ACE_TEXT ("can't generate unique name"))); this->backing_store_name_[0] = 0; } # else ACE_OS::mktemp(this->backing_store_name_); # endif /* ACE_DISABLE_MKTEMP */ #endif /* ACE_DEFAULT_BACKING_STORE */ } else ACE_OS::strsncpy (this->backing_store_name_, backing_store_name, (sizeof this->backing_store_name_ / sizeof (ACE_TCHAR))); #if !defined (ACE_WIN32) if (this->install_signal_handler_) { if (this->signal_handler_.register_handler (SIGSEGV, this) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT("%p\n"), this->backing_store_name_)); } #endif /* ACE_WIN32 */ } ACE_MMAP_Memory_Pool::~ACE_MMAP_Memory_Pool (void) { } // Compute the new map_size of the backing store and commit the // memory. int ACE_MMAP_Memory_Pool::commit_backing_store_name (size_t rounded_bytes, size_t & map_size) { ACE_TRACE ("ACE_MMAP_Memory_Pool::commit_backing_store_name"); #if defined (__Lynx__) map_size = rounded_bytes; #else size_t seek_len; if (this->write_each_page_) // Write to the end of every block to ensure that we have enough // space in the backing store. seek_len = this->round_up (1); // round_up(1) is one page. else // We're willing to risk it all in the name of efficiency... seek_len = rounded_bytes; // The following loop will execute multiple times (if // this->write_each_page == 1) or just once (if // this->write_each_page == 0). for (size_t cur_block = 0; cur_block < rounded_bytes; cur_block += seek_len) { map_size = ACE_Utils::truncate_cast<size_t> ( ACE_OS::lseek (this->mmap_.handle (), static_cast<ACE_OFF_T> (seek_len - 1), SEEK_END)); if (map_size == static_cast<size_t> (-1) || ACE_OS::write (this->mmap_.handle (), "", 1) == -1) ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), this->backing_store_name_), -1); } #if defined (ACE_OPENVMS) ::fsync(this->mmap_.handle()); #endif // Increment by one to put us at the beginning of the next chunk... ++map_size; #endif /* __Lynx__ */ return 0; } // Memory map the file up to <map_size> bytes. int ACE_MMAP_Memory_Pool::map_file (size_t map_size) { ACE_TRACE ("ACE_MMAP_Memory_Pool::map_file"); #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) void* obase_addr = this->base_addr_; #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */ // Unmap the existing mapping. this->mmap_.unmap (); #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) if (use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::NEVER_FIXED) this->base_addr_ = 0; #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */ // Remap the file; try to stay at the same location as a previous mapping // but do not force it with MAP_FIXED. Doing so will give the OS permission // to map locations currently holding other things (such as the heap, or // the C library) into the map file, producing very unexpected results. if (this->mmap_.map (map_size, PROT_RDWR, this->flags_, this->base_addr_, 0, this->sa_) == -1 || (this->base_addr_ != 0 #ifdef ACE_HAS_WINCE && this->mmap_.addr () == 0)) // WinCE does not allow users to specify alloc addr. #else && this->mmap_.addr () != this->base_addr_)) #endif // ACE_HAS_WINCE { #if 0 ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) addr = %@, base_addr = %@, map_size = %B, %p\n"), this->mmap_.addr (), this->base_addr_, map_size, this->backing_store_name_)); #endif /* 0 */ return -1; } else { #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) this->base_addr_ = this->mmap_.addr (); if (obase_addr && this->base_addr_ != obase_addr) { ACE_BASED_POINTER_REPOSITORY::instance ()->unbind (obase_addr); } ACE_BASED_POINTER_REPOSITORY::instance ()->bind (this->base_addr_, map_size); #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */ return 0; } } // Ask operating system for more shared memory, increasing the mapping // accordingly. Note that this routine assumes that the appropriate // locks are held when it is called. void * ACE_MMAP_Memory_Pool::acquire (size_t nbytes, size_t &rounded_bytes) { ACE_TRACE ("ACE_MMAP_Memory_Pool::acquire"); rounded_bytes = this->round_up (nbytes); // ACELIB_DEBUG ((LM_DEBUG, "(%P|%t) acquiring more chunks, nbytes = // %B, rounded_bytes = %B\n", nbytes, rounded_bytes)); size_t map_size; if (this->commit_backing_store_name (rounded_bytes, map_size) == -1) return 0; else if (this->map_file (map_size) == -1) return 0; // ACELIB_DEBUG ((LM_DEBUG, "(%P|%t) acquired more chunks, nbytes = %B, // rounded_bytes = %B, map_size = %B\n", nbytes, rounded_bytes, // map_size)); return (void *) ((char *) this->mmap_.addr () + (this->mmap_.size () - rounded_bytes)); } // Ask system for initial chunk of shared memory. void * ACE_MMAP_Memory_Pool::init_acquire (size_t nbytes, size_t &rounded_bytes, int &first_time) { ACE_TRACE ("ACE_MMAP_Memory_Pool::init_acquire"); first_time = 0; if (nbytes < static_cast <size_t> (this->minimum_bytes_)) nbytes = static_cast <size_t> (this->minimum_bytes_); if (this->mmap_.open (this->backing_store_name_, O_RDWR | O_CREAT | O_TRUNC | O_EXCL, this->file_mode_, this->sa_) != -1) { // First time in, so need to acquire memory. first_time = 1; void *result = this->acquire (nbytes, rounded_bytes); // After the first time, reset the flag so that subsequent calls // will use MAP_FIXED if (this->use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::FIRSTCALL_FIXED) { ACE_SET_BITS (flags_, MAP_FIXED); } return result; } else if (errno == EEXIST) { errno = 0; // Reopen file *without* using O_EXCL... if (this->mmap_.map (this->backing_store_name_, static_cast<size_t> (-1), O_RDWR, this->file_mode_, PROT_RDWR, this->flags_, this->base_addr_, 0, this->sa_) == -1) ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("MMAP_Memory_Pool::init_acquire, EEXIST")), 0); // After the first time, reset the flag so that subsequent calls // will use MAP_FIXED if (use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::FIRSTCALL_FIXED) { ACE_SET_BITS (flags_, MAP_FIXED); } #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) // Update the mapped segment information ACE_BASED_POINTER_REPOSITORY::instance ()->bind (this->mmap_.addr(), this->mmap_.size()); #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */ return this->mmap_.addr (); } else ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("MMAP_Memory_Pool::init_acquire")), 0); } #if defined (ACE_WIN32) int ACE_MMAP_Memory_Pool::seh_selector (void *ep) { DWORD const ecode = ((EXCEPTION_POINTERS *) ep)->ExceptionRecord->ExceptionCode; if (ecode == EXCEPTION_ACCESS_VIOLATION) { void * fault_addr = (void *) ((EXCEPTION_POINTERS *) ep)->ExceptionRecord->ExceptionInformation[1]; if (this->remap (fault_addr) == 0) return 1; } return 0; } #endif /* ACE_WIN32 */ int ACE_MMAP_Memory_Pool::remap (void *addr) { ACE_TRACE ("ACE_MMAP_Memory_Pool::remap"); // ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("Remapping with fault address at: %@\n"), addr)); size_t const current_map_size = ACE_Utils::truncate_cast<size_t> (ACE_OS::filesize (this->mmap_.handle ())); // ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END); if (!(addr < (void *) ((char *) this->mmap_.addr () + current_map_size) && addr >= this->mmap_.addr ())) return -1; // Extend the mapping to cover the size of the backing store. return this->map_file (current_map_size); } ACE_MMAP_Memory_Pool_Options::ACE_MMAP_Memory_Pool_Options ( const void *base_addr, int use_fixed_addr, bool write_each_page, size_t minimum_bytes, u_int flags, bool guess_on_fault, LPSECURITY_ATTRIBUTES sa, mode_t file_mode, bool unique, bool install_signal_handler) : base_addr_ (base_addr), use_fixed_addr_ (use_fixed_addr), write_each_page_ (write_each_page), minimum_bytes_ (minimum_bytes), flags_ (flags), guess_on_fault_ (guess_on_fault), sa_ (sa), file_mode_ (file_mode), unique_ (unique), install_signal_handler_ (install_signal_handler) { ACE_TRACE ("ACE_MMAP_Memory_Pool_Options::ACE_MMAP_Memory_Pool_Options"); // for backwards compatibility if (base_addr_ == 0 && use_fixed_addr_ == ALWAYS_FIXED) use_fixed_addr_ = FIRSTCALL_FIXED; } #if !defined (ACE_WIN32) int ACE_MMAP_Memory_Pool::handle_signal (int signum, siginfo_t *siginfo, ucontext_t *) { if (signum != SIGSEGV) return -1; #if 0 else ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) received %S\n"), signum)); #endif // ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) new mapping address = %@\n"), (char *) this->base_addr_ + current_map_size)); #if defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR) // Make sure that the pointer causing the problem is within the // range of the backing store. if (siginfo != 0) { // ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) si_signo = %d, si_code = %d, addr = %@\n"), siginfo->si_signo, siginfo->si_code, siginfo->si_addr)); if (this->remap ((void *) siginfo->si_addr) == -1) return -1; // ACELIB_ERROR_RETURN ((LM_ERROR, "(%P|%t) address %@ out of range\n", // siginfo->si_addr), -1); return 0; } #else ACE_UNUSED_ARG(siginfo); #endif /* ACE_HAS_SIGINFO_T && !defined ACE_LACKS_SI_ADDR */ // If guess_on_fault_ is true, then we want to try to remap without // knowing the faulting address. guess_on_fault_ can only be true // on platforms that do not provide the faulting address through // signals or exceptions. We check to see if the mapping is up to // date. If it is, then this fault isn't due to this mapping and we // pass it on. if (guess_on_fault_) { // Check if the current mapping is up to date. size_t const current_map_size = ACE_Utils::truncate_cast<size_t> (ACE_OS::filesize (this->mmap_.handle ())); if (static_cast<size_t> (current_map_size) == this->mmap_.size ()) { // The mapping is up to date so this really is a bad // address. Thus, remove current signal handler so process // will fail with default action and core file will be // written. this->signal_handler_.remove_handler (SIGSEGV); return 0; } // Extend the mapping to cover the size of the backing store. return this->map_file (current_map_size); } else return -1; } #endif void * ACE_MMAP_Memory_Pool::base_addr (void) const { ACE_TRACE ("ACE_MMAP_Memory_Pool::base_addr"); return this->base_addr_; } size_t ACE_MMAP_Memory_Pool::round_up (size_t nbytes) { ACE_TRACE ("ACE_MMAP_Memory_Pool::round_up"); return ACE::round_to_pagesize (nbytes); } ACE_ALLOC_HOOK_DEFINE(ACE_Lite_MMAP_Memory_Pool) ACE_Lite_MMAP_Memory_Pool::ACE_Lite_MMAP_Memory_Pool (const ACE_TCHAR *backing_store_name, const OPTIONS *options) : ACE_MMAP_Memory_Pool (backing_store_name, options) { ACE_TRACE ("ACE_Lite_MMAP_Memory_Pool::ACE_Lite_MMAP_Memory_Pool"); } ACE_Lite_MMAP_Memory_Pool::~ACE_Lite_MMAP_Memory_Pool (void) { } int ACE_Lite_MMAP_Memory_Pool::sync (size_t, int) { ACE_TRACE ("ACE_Lite_MMAP_Memory_Pool::sync"); return 0; } int ACE_Lite_MMAP_Memory_Pool::sync (int) { ACE_TRACE ("ACE_Lite_MMAP_Memory_Pool::sync"); return 0; } int ACE_Lite_MMAP_Memory_Pool::sync (void *, size_t, int) { ACE_TRACE ("ACE_Lite_MMAP_Memory_Pool::sync"); return 0; } ACE_END_VERSIONED_NAMESPACE_DECL
[ "jimbolysses@gmail.com" ]
jimbolysses@gmail.com
7cf940a982201cc2c2aa073167aa704858b81ec8
686ff7d8be9af5505572bbc240228574aa6e89f6
/client/haveibeenpwned.cpp
3af4bda8110fa9266fa220858dac7ebee5a803f3
[]
no_license
ac999/qt-cms-client
6738aa98d6f72c943bf9d77782c31601a028dd1d
b87db2a622b5e28cd573f518214cf493da589f5c
refs/heads/master
2022-11-11T09:30:34.612553
2019-10-06T11:34:12
2019-10-06T11:34:12
275,583,489
0
0
null
null
null
null
UTF-8
C++
false
false
2,288
cpp
#include "haveibeenpwned.h" #include<QDebug> bool haveibeenpwned::getStatus() { return this->status ; }; int haveibeenpwned::getCount() { return this->count ; }; haveibeenpwned::haveibeenpwned(QString password) { this->password = password ; this->passwordHash = SHA1(password) ; this->checkPassword(); }; void haveibeenpwned::setCount(int count) { this->count = count ; }; void haveibeenpwned::setStatus(bool value) { this->status = value ; }; void haveibeenpwned::checkPassword() { // First 5 characters of hash: QStringRef SHA1_5char(&this->passwordHash,0,5) ; QString url = HIBPURL + SHA1_5char ; try { QStringList hashList = QString(sendRequest(url) ) .split("\r\n"); this->setCount( searchHash( this->passwordHash , hashList ) ) ; this->getCount()>0 ?this->setStatus(true) :this->setStatus(false) ; } catch (...) { this->setCount(-1) ; this->setStatus(false) ; } }; // SHA1 of parameter in uppercase QString SHA1(QString password) { QCryptographicHash* hash = new QCryptographicHash(QCryptographicHash::Sha1) ; hash->addData(password.toUtf8() ) ; return QString::fromLatin1(hash->result().toHex()).toUpper() ; }; // hash is uppercase & hashList is of format "SHA1:nr_of_apparitions" int searchHash(QString hash, QStringList hashList) { QString re_rule = "^"+hash.mid(5,hash.length())+".+$" ; QStringList filteredHashes=hashList.filter(QRegExp(re_rule)); if (!filteredHashes.count()) { return 0; } return filteredHashes[0].split(':')[1].toInt(); }; QByteArray sendRequest(QString url) { QNetworkAccessManager* manager = new QNetworkAccessManager() ; QNetworkRequest request; QNetworkReply* reply = nullptr ; QSslConfiguration config = QSslConfiguration::defaultConfiguration() ; config.setProtocol(QSsl::TlsV1_3) ; request.setSslConfiguration(config) ; request.setUrl(QUrl(url) ) ; reply = manager->get(request) ; while(!reply->isFinished() ) { qApp->processEvents() ; } QByteArray result = reply->readAll() ; reply->deleteLater() ; return result ; };
[ "andreicristian6@protonmail.com" ]
andreicristian6@protonmail.com
6f9df71e3b5de5b7b8d6bf3d5257e9e4a56fa8a5
d2c59879cbaa8f657da7124594607293a9ea2761
/rtsp_fd_fr/src/host/play_mjpeg.cpp
cc4bce5c1157a5089c3b56421f0882c05d7c884b
[]
no_license
freewind2016/bm1880-ai-demo-program
9032cb2845a79b3bfebf270f8771ea6ee3f1e102
d1634e5c314e346a1229c4df96efe9c37401cdd7
refs/heads/master
2022-06-01T02:39:57.883696
2020-03-20T01:56:43
2020-03-20T01:56:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
890
cpp
#include <memory> #include <opencv2/opencv.hpp> #include "bt.hpp" #include "image.hpp" #include "fdfr_version.h" using namespace std; using namespace cv; int main(int argc, char* argv[]) { google::InitGoogleLogging(argv[0]); FDFRVersion::dump_version(); signal(SIGSEGV, [] (int sig) -> void { print_backtrace(); }); signal(SIGABRT, [] (int sig) -> void { print_backtrace(); }); if (argc != 2) { printf("usage: %s stream\n", argv[0]); return 0; } auto video_src = make_shared<VideoCapture>(argv[1]); cv::Mat frame; cv::namedWindow( "Output", cv::WINDOW_AUTOSIZE ); while (video_src->read(frame)) { cv::imshow("Output", frame); int k = cv::waitKey(1); // esc if (k == 27) { break; } } fprintf(stderr, "terminating\n"); cv::destroyWindow("Output"); return 0; }
[ "45759281+bmswjh@users.noreply.github.com" ]
45759281+bmswjh@users.noreply.github.com
345f3022624ad63099c22795598062856d1a9417
617481ca053d866f341622430962c5641f6b15ee
/Tetris/Tetris/State.h
3acb3ae7078df9fd7dbf395d21aeb29852e35f20
[]
no_license
tehbullda/TetrisByBullda
7f4fadd28c21b7baf17307e18994e3b63c58c7b3
0e6979ff79a0d6e87a53ae4df4e1e088a12cf76e
refs/heads/master
2016-09-10T08:26:57.565127
2014-08-04T20:08:52
2014-08-04T20:08:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
338
h
#pragma once #include <string> using namespace std; class State { public: virtual ~State() {}; virtual bool Enter() = 0; virtual void Exit() = 0; virtual bool Update(float deltatime) = 0; virtual bool UpdateEvents() = 0; virtual void Draw() = 0; virtual std::string Next() = 0; virtual bool IsType(std::string check) = 0; };
[ "bullda_94@hotmail.com" ]
bullda_94@hotmail.com
55c3523d2c25ac2f94858c78a83114a9d5b574a3
4491c0af003d37c0e3b8f2018e65478619f84f9b
/zad7.cpp
253c2d42186f09a96411929d39e468f18aa60266
[]
no_license
datejer/cpp
f91b805697129cb67aa5d29623f79fa0e0738c87
b63f6fd3df3306c8fd0c0bb9f3cfc93d2f722eb3
refs/heads/master
2023-03-12T11:25:58.486268
2021-02-22T17:23:05
2021-02-22T17:23:05
307,696,105
3
0
null
null
null
null
UTF-8
C++
false
false
340
cpp
#include <iostream> using namespace std; int main() { int liczba, przeciwna; cout << "Wpisz liczbe: "; cin >> liczba; if (liczba == 0) { cout << "Liczba nie moze byc 0"; return 1; } przeciwna = 0 - liczba; cout << "Liczba przeciwna do " << liczba << " to " << przeciwna; return 0; }
[ "ejer.priv@wp.pl" ]
ejer.priv@wp.pl
5a36df1d6b6bd0a89b47aa30d490c3624467f9cd
35644073e261202f3c392d2043e759bb859ebe94
/otfft-11.5e/otfft/otfft_avxdif8.h
25f0d4fb8b6ad41aa0caf523597fe697a620881e
[ "LicenseRef-scancode-takuya-ooura", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
ixchow/freiscale
5882fd7d992dec18b403c9839cbaa0de1239fdc5
0a7d4224ac0fc1f255c930403388b9ecdc7ed30d
refs/heads/master
2023-04-07T04:00:02.656296
2023-04-03T19:49:07
2023-04-03T19:49:07
240,640,840
11
2
null
2020-04-02T01:19:12
2020-02-15T03:49:23
C++
UTF-8
C++
false
false
41,077
h
/****************************************************************************** * OTFFT AVXDIF(Radix-8) Version 11.5e * * Copyright (c) 2019 OK Ojisan(Takuya OKAHISA) * Released under the MIT license * http://opensource.org/licenses/mit-license.php ******************************************************************************/ #ifndef otfft_avxdif8_h #define otfft_avxdif8_h #include "otfft_misc.h" #include "otfft_avxdif4.h" #include "otfft_avxdif8omp.h" #include "otfft_avxdif8exp.h" namespace OTFFT_AVXDIF8 { ///////////////////////////////////////////////////// using namespace OTFFT_MISC; #ifdef DO_SINGLE_THREAD constexpr int OMP_THRESHOLD = 1<<30; #else constexpr int OMP_THRESHOLD = 1<<11; #endif constexpr int EXP_THRESHOLD = 1<<18; /////////////////////////////////////////////////////////////////////////////// // Forward Buffterfly Operation /////////////////////////////////////////////////////////////////////////////// template <int n, int s> struct fwdcore { static constexpr int m = n/8; static constexpr int N = n*s; static constexpr int N0 = 0; static constexpr int N1 = N/8; static constexpr int N2 = N1*2; static constexpr int N3 = N1*3; static constexpr int N4 = N1*4; static constexpr int N5 = N1*5; static constexpr int N6 = N1*6; static constexpr int N7 = N1*7; void operator()( complex_vector x, complex_vector y, const_complex_vector W) const noexcept { for (int p = 0; p < m; p++) { const int sp = s*p; const int s8p = 8*sp; const emm w1p = dupez5(*twidT<8,N,1>(W,sp)); const emm w2p = dupez5(*twidT<8,N,2>(W,sp)); const emm w3p = dupez5(*twidT<8,N,3>(W,sp)); const emm w4p = dupez5(*twidT<8,N,4>(W,sp)); const emm w5p = dupez5(*twidT<8,N,5>(W,sp)); const emm w6p = dupez5(*twidT<8,N,6>(W,sp)); const emm w7p = dupez5(*twidT<8,N,7>(W,sp)); for (int q = 0; q < s; q += 4) { complex_vector xq_sp = x + q + sp; complex_vector yq_s8p = y + q + s8p; const emm x0 = getez4(xq_sp+N0); const emm x1 = getez4(xq_sp+N1); const emm x2 = getez4(xq_sp+N2); const emm x3 = getez4(xq_sp+N3); const emm x4 = getez4(xq_sp+N4); const emm x5 = getez4(xq_sp+N5); const emm x6 = getez4(xq_sp+N6); const emm x7 = getez4(xq_sp+N7); const emm a04 = addez4(x0, x4); const emm s04 = subez4(x0, x4); const emm a26 = addez4(x2, x6); const emm js26 = jxez4(subez4(x2, x6)); const emm a15 = addez4(x1, x5); const emm s15 = subez4(x1, x5); const emm a37 = addez4(x3, x7); const emm js37 = jxez4(subez4(x3, x7)); const emm a04_p1_a26 = addez4(a04, a26); const emm s04_mj_s26 = subez4(s04, js26); const emm a04_m1_a26 = subez4(a04, a26); const emm s04_pj_s26 = addez4(s04, js26); const emm a15_p1_a37 = addez4(a15, a37); const emm w8_s15_mj_s37 = w8xez4(subez4(s15, js37)); const emm j_a15_m1_a37 = jxez4(subez4(a15, a37)); const emm v8_s15_pj_s37 = v8xez4(addez4(s15, js37)); setez4(yq_s8p+s*0, addez4(a04_p1_a26, a15_p1_a37)); setez4(yq_s8p+s*1, mulez4(w1p, addez4(s04_mj_s26, w8_s15_mj_s37))); setez4(yq_s8p+s*2, mulez4(w2p, subez4(a04_m1_a26, j_a15_m1_a37))); setez4(yq_s8p+s*3, mulez4(w3p, subez4(s04_pj_s26, v8_s15_pj_s37))); setez4(yq_s8p+s*4, mulez4(w4p, subez4(a04_p1_a26, a15_p1_a37))); setez4(yq_s8p+s*5, mulez4(w5p, subez4(s04_mj_s26, w8_s15_mj_s37))); setez4(yq_s8p+s*6, mulez4(w6p, addez4(a04_m1_a26, j_a15_m1_a37))); setez4(yq_s8p+s*7, mulez4(w7p, addez4(s04_pj_s26, v8_s15_pj_s37))); } } } }; template <int N> struct fwdcore<N,1> { static constexpr int N0 = 0; static constexpr int N1 = N/8; static constexpr int N2 = N1*2; static constexpr int N3 = N1*3; static constexpr int N4 = N1*4; static constexpr int N5 = N1*5; static constexpr int N6 = N1*6; static constexpr int N7 = N1*7; void operator()( complex_vector x, complex_vector y, const_complex_vector W) const noexcept { for (int p = 0; p < N1; p += 2) { complex_vector x_p = x + p; complex_vector y_8p = y + 8*p; const ymm x0 = getpz2(x_p+N0); const ymm x1 = getpz2(x_p+N1); const ymm x2 = getpz2(x_p+N2); const ymm x3 = getpz2(x_p+N3); const ymm x4 = getpz2(x_p+N4); const ymm x5 = getpz2(x_p+N5); const ymm x6 = getpz2(x_p+N6); const ymm x7 = getpz2(x_p+N7); const ymm a04 = addpz2(x0, x4); const ymm s04 = subpz2(x0, x4); const ymm a26 = addpz2(x2, x6); const ymm js26 = jxpz2(subpz2(x2, x6)); const ymm a15 = addpz2(x1, x5); const ymm s15 = subpz2(x1, x5); const ymm a37 = addpz2(x3, x7); const ymm js37 = jxpz2(subpz2(x3, x7)); const ymm a04_p1_a26 = addpz2(a04, a26); const ymm s04_mj_s26 = subpz2(s04, js26); const ymm a04_m1_a26 = subpz2(a04, a26); const ymm s04_pj_s26 = addpz2(s04, js26); const ymm a15_p1_a37 = addpz2(a15, a37); const ymm w8_s15_mj_s37 = w8xpz2(subpz2(s15, js37)); const ymm j_a15_m1_a37 = jxpz2(subpz2(a15, a37)); const ymm v8_s15_pj_s37 = v8xpz2(addpz2(s15, js37)); const ymm w1p = getpz2(twid<8,N,1>(W,p)); const ymm w2p = getpz2(twid<8,N,2>(W,p)); const ymm w3p = getpz2(twid<8,N,3>(W,p)); const ymm w4p = getpz2(twid<8,N,4>(W,p)); const ymm w5p = getpz2(twid<8,N,5>(W,p)); const ymm w6p = getpz2(twid<8,N,6>(W,p)); const ymm w7p = getpz2(twid<8,N,7>(W,p)); #if 0 setpz3<8>(y_8p+0, addpz2(a04_p1_a26, a15_p1_a37)); setpz3<8>(y_8p+1, mulpz2(w1p, addpz2(s04_mj_s26, w8_s15_mj_s37))); setpz3<8>(y_8p+2, mulpz2(w2p, subpz2(a04_m1_a26, j_a15_m1_a37))); setpz3<8>(y_8p+3, mulpz2(w3p, subpz2(s04_pj_s26, v8_s15_pj_s37))); setpz3<8>(y_8p+4, mulpz2(w4p, subpz2(a04_p1_a26, a15_p1_a37))); setpz3<8>(y_8p+5, mulpz2(w5p, subpz2(s04_mj_s26, w8_s15_mj_s37))); setpz3<8>(y_8p+6, mulpz2(w6p, addpz2(a04_m1_a26, j_a15_m1_a37))); setpz3<8>(y_8p+7, mulpz2(w7p, addpz2(s04_pj_s26, v8_s15_pj_s37))); #else const ymm aA = addpz2(a04_p1_a26, a15_p1_a37); const ymm bB = mulpz2(w1p, addpz2(s04_mj_s26, w8_s15_mj_s37)); const ymm cC = mulpz2(w2p, subpz2(a04_m1_a26, j_a15_m1_a37)); const ymm dD = mulpz2(w3p, subpz2(s04_pj_s26, v8_s15_pj_s37)); const ymm eE = mulpz2(w4p, subpz2(a04_p1_a26, a15_p1_a37)); const ymm fF = mulpz2(w5p, subpz2(s04_mj_s26, w8_s15_mj_s37)); const ymm gG = mulpz2(w6p, addpz2(a04_m1_a26, j_a15_m1_a37)); const ymm hH = mulpz2(w7p, addpz2(s04_pj_s26, v8_s15_pj_s37)); const ymm ab = catlo(aA, bB); setpz2(y_8p+ 0, ab); const ymm cd = catlo(cC, dD); setpz2(y_8p+ 2, cd); const ymm ef = catlo(eE, fF); setpz2(y_8p+ 4, ef); const ymm gh = catlo(gG, hH); setpz2(y_8p+ 6, gh); const ymm AB = cathi(aA, bB); setpz2(y_8p+ 8, AB); const ymm CD = cathi(cC, dD); setpz2(y_8p+10, CD); const ymm EF = cathi(eE, fF); setpz2(y_8p+12, EF); const ymm GH = cathi(gG, hH); setpz2(y_8p+14, GH); #endif } } }; /////////////////////////////////////////////////////////////////////////////// template <int n, int s, bool eo, int mode> struct fwdend; //----------------------------------------------------------------------------- template <int s, bool eo, int mode> struct fwdend<8,s,eo,mode> { static constexpr int N = 8*s; void operator()(complex_vector x, complex_vector y) const noexcept { complex_vector z = eo ? y : x; for (int q = 0; q < s; q += 2) { complex_vector xq = x + q; complex_vector zq = z + q; const ymm x0 = scalepz2<N,mode>(getpz2(xq+s*0)); const ymm x1 = scalepz2<N,mode>(getpz2(xq+s*1)); const ymm x2 = scalepz2<N,mode>(getpz2(xq+s*2)); const ymm x3 = scalepz2<N,mode>(getpz2(xq+s*3)); const ymm x4 = scalepz2<N,mode>(getpz2(xq+s*4)); const ymm x5 = scalepz2<N,mode>(getpz2(xq+s*5)); const ymm x6 = scalepz2<N,mode>(getpz2(xq+s*6)); const ymm x7 = scalepz2<N,mode>(getpz2(xq+s*7)); const ymm a04 = addpz2(x0, x4); const ymm s04 = subpz2(x0, x4); const ymm a26 = addpz2(x2, x6); const ymm js26 = jxpz2(subpz2(x2, x6)); const ymm a15 = addpz2(x1, x5); const ymm s15 = subpz2(x1, x5); const ymm a37 = addpz2(x3, x7); const ymm js37 = jxpz2(subpz2(x3, x7)); const ymm a04_p1_a26 = addpz2(a04, a26); const ymm s04_mj_s26 = subpz2(s04, js26); const ymm a04_m1_a26 = subpz2(a04, a26); const ymm s04_pj_s26 = addpz2(s04, js26); const ymm a15_p1_a37 = addpz2(a15, a37); const ymm w8_s15_mj_s37 = w8xpz2(subpz2(s15, js37)); const ymm j_a15_m1_a37 = jxpz2(subpz2(a15, a37)); const ymm v8_s15_pj_s37 = v8xpz2(addpz2(s15, js37)); setpz2(zq+s*0, addpz2(a04_p1_a26, a15_p1_a37)); setpz2(zq+s*1, addpz2(s04_mj_s26, w8_s15_mj_s37)); setpz2(zq+s*2, subpz2(a04_m1_a26, j_a15_m1_a37)); setpz2(zq+s*3, subpz2(s04_pj_s26, v8_s15_pj_s37)); setpz2(zq+s*4, subpz2(a04_p1_a26, a15_p1_a37)); setpz2(zq+s*5, subpz2(s04_mj_s26, w8_s15_mj_s37)); setpz2(zq+s*6, addpz2(a04_m1_a26, j_a15_m1_a37)); setpz2(zq+s*7, addpz2(s04_pj_s26, v8_s15_pj_s37)); } } }; template <bool eo, int mode> struct fwdend<8,1,eo,mode> { inline void operator()(complex_vector x, complex_vector y) const noexcept { zeroupper(); complex_vector z = eo ? y : x; const xmm x0 = scalepz<8,mode>(getpz(x[0])); const xmm x1 = scalepz<8,mode>(getpz(x[1])); const xmm x2 = scalepz<8,mode>(getpz(x[2])); const xmm x3 = scalepz<8,mode>(getpz(x[3])); const xmm x4 = scalepz<8,mode>(getpz(x[4])); const xmm x5 = scalepz<8,mode>(getpz(x[5])); const xmm x6 = scalepz<8,mode>(getpz(x[6])); const xmm x7 = scalepz<8,mode>(getpz(x[7])); const xmm a04 = addpz(x0, x4); const xmm s04 = subpz(x0, x4); const xmm a26 = addpz(x2, x6); const xmm js26 = jxpz(subpz(x2, x6)); const xmm a15 = addpz(x1, x5); const xmm s15 = subpz(x1, x5); const xmm a37 = addpz(x3, x7); const xmm js37 = jxpz(subpz(x3, x7)); const xmm a04_p1_a26 = addpz(a04, a26); const xmm s04_mj_s26 = subpz(s04, js26); const xmm a04_m1_a26 = subpz(a04, a26); const xmm s04_pj_s26 = addpz(s04, js26); const xmm a15_p1_a37 = addpz(a15, a37); const xmm w8_s15_mj_s37 = w8xpz(subpz(s15, js37)); const xmm j_a15_m1_a37 = jxpz(subpz(a15, a37)); const xmm v8_s15_pj_s37 = v8xpz(addpz(s15, js37)); setpz(z[0], addpz(a04_p1_a26, a15_p1_a37)); setpz(z[1], addpz(s04_mj_s26, w8_s15_mj_s37)); setpz(z[2], subpz(a04_m1_a26, j_a15_m1_a37)); setpz(z[3], subpz(s04_pj_s26, v8_s15_pj_s37)); setpz(z[4], subpz(a04_p1_a26, a15_p1_a37)); setpz(z[5], subpz(s04_mj_s26, w8_s15_mj_s37)); setpz(z[6], addpz(a04_m1_a26, j_a15_m1_a37)); setpz(z[7], addpz(s04_pj_s26, v8_s15_pj_s37)); } }; /////////////////////////////////////////////////////////////////////////////// // Forward FFT /////////////////////////////////////////////////////////////////////////////// template <int n, int s, bool eo, int mode> struct fwdfft { inline void operator()( complex_vector x, complex_vector y, const_complex_vector W) const noexcept { fwdcore<n,s>()(x, y, W); fwdfft<n/8,8*s,!eo,mode>()(y, x, W); } }; template <int s, bool eo, int mode> struct fwdfft<8,s,eo,mode> { inline void operator()( complex_vector x, complex_vector y, const_complex_vector) const noexcept { fwdend<8,s,eo,mode>()(x, y); } }; template <int s, bool eo, int mode> struct fwdfft<4,s,eo,mode> { inline void operator()( complex_vector x, complex_vector y, const_complex_vector) const noexcept { OTFFT_AVXDIF4::fwdend<4,s,eo,mode>()(x, y); } }; template <int s, bool eo, int mode> struct fwdfft<2,s,eo,mode> { inline void operator()( complex_vector x, complex_vector y, const_complex_vector) const noexcept { OTFFT_AVXDIF4::fwdend<2,s,eo,mode>()(x, y); } }; /////////////////////////////////////////////////////////////////////////////// // Inverse Butterfly Operation /////////////////////////////////////////////////////////////////////////////// template <int n, int s> struct invcore { static constexpr int m = n/8; static constexpr int N = n*s; static constexpr int N0 = 0; static constexpr int N1 = N/8; static constexpr int N2 = N1*2; static constexpr int N3 = N1*3; static constexpr int N4 = N1*4; static constexpr int N5 = N1*5; static constexpr int N6 = N1*6; static constexpr int N7 = N1*7; void operator()( complex_vector x, complex_vector y, const_complex_vector W) const noexcept { for (int p = 0; p < m; p++) { const int sp = s*p; const int s8p = 8*sp; #if 0 const emm w1p = cnjez4(dupez5(*twidT<8,N,1>(W,sp))); const emm w2p = cnjez4(dupez5(*twidT<8,N,2>(W,sp))); const emm w3p = cnjez4(dupez5(*twidT<8,N,3>(W,sp))); const emm w4p = cnjez4(dupez5(*twidT<8,N,4>(W,sp))); const emm w5p = cnjez4(dupez5(*twidT<8,N,5>(W,sp))); const emm w6p = cnjez4(dupez5(*twidT<8,N,6>(W,sp))); const emm w7p = cnjez4(dupez5(*twidT<8,N,7>(W,sp))); #else const emm w1p = dupez5(conj(*twidT<8,N,1>(W,sp))); const emm w2p = dupez5(conj(*twidT<8,N,2>(W,sp))); const emm w3p = dupez5(conj(*twidT<8,N,3>(W,sp))); const emm w4p = dupez5(conj(*twidT<8,N,4>(W,sp))); const emm w5p = dupez5(conj(*twidT<8,N,5>(W,sp))); const emm w6p = dupez5(conj(*twidT<8,N,6>(W,sp))); const emm w7p = dupez5(conj(*twidT<8,N,7>(W,sp))); #endif for (int q = 0; q < s; q += 4) { complex_vector xq_sp = x + q + sp; complex_vector yq_s8p = y + q + s8p; const emm x0 = getez4(xq_sp+N0); const emm x1 = getez4(xq_sp+N1); const emm x2 = getez4(xq_sp+N2); const emm x3 = getez4(xq_sp+N3); const emm x4 = getez4(xq_sp+N4); const emm x5 = getez4(xq_sp+N5); const emm x6 = getez4(xq_sp+N6); const emm x7 = getez4(xq_sp+N7); const emm a04 = addez4(x0, x4); const emm s04 = subez4(x0, x4); const emm a26 = addez4(x2, x6); const emm js26 = jxez4(subez4(x2, x6)); const emm a15 = addez4(x1, x5); const emm s15 = subez4(x1, x5); const emm a37 = addez4(x3, x7); const emm js37 = jxez4(subez4(x3, x7)); const emm a04_p1_a26 = addez4(a04, a26); const emm s04_pj_s26 = addez4(s04, js26); const emm a04_m1_a26 = subez4(a04, a26); const emm s04_mj_s26 = subez4(s04, js26); const emm a15_p1_a37 = addez4(a15, a37); const emm v8_s15_pj_s37 = v8xez4(addez4(s15, js37)); const emm j_a15_m1_a37 = jxez4(subez4(a15, a37)); const emm w8_s15_mj_s37 = w8xez4(subez4(s15, js37)); setez4(yq_s8p+s*0, addez4(a04_p1_a26, a15_p1_a37)); setez4(yq_s8p+s*1, mulez4(w1p, addez4(s04_pj_s26, v8_s15_pj_s37))); setez4(yq_s8p+s*2, mulez4(w2p, addez4(a04_m1_a26, j_a15_m1_a37))); setez4(yq_s8p+s*3, mulez4(w3p, subez4(s04_mj_s26, w8_s15_mj_s37))); setez4(yq_s8p+s*4, mulez4(w4p, subez4(a04_p1_a26, a15_p1_a37))); setez4(yq_s8p+s*5, mulez4(w5p, subez4(s04_pj_s26, v8_s15_pj_s37))); setez4(yq_s8p+s*6, mulez4(w6p, subez4(a04_m1_a26, j_a15_m1_a37))); setez4(yq_s8p+s*7, mulez4(w7p, addez4(s04_mj_s26, w8_s15_mj_s37))); } } } }; template <int N> struct invcore<N,1> { static constexpr int N0 = 0; static constexpr int N1 = N/8; static constexpr int N2 = N1*2; static constexpr int N3 = N1*3; static constexpr int N4 = N1*4; static constexpr int N5 = N1*5; static constexpr int N6 = N1*6; static constexpr int N7 = N1*7; void operator()( complex_vector x, complex_vector y, const_complex_vector W) const noexcept { for (int p = 0; p < N1; p += 2) { complex_vector x_p = x + p; complex_vector y_8p = y + 8*p; const ymm x0 = getpz2(x_p+N0); const ymm x1 = getpz2(x_p+N1); const ymm x2 = getpz2(x_p+N2); const ymm x3 = getpz2(x_p+N3); const ymm x4 = getpz2(x_p+N4); const ymm x5 = getpz2(x_p+N5); const ymm x6 = getpz2(x_p+N6); const ymm x7 = getpz2(x_p+N7); const ymm a04 = addpz2(x0, x4); const ymm s04 = subpz2(x0, x4); const ymm a26 = addpz2(x2, x6); const ymm js26 = jxpz2(subpz2(x2, x6)); const ymm a15 = addpz2(x1, x5); const ymm s15 = subpz2(x1, x5); const ymm a37 = addpz2(x3, x7); const ymm js37 = jxpz2(subpz2(x3, x7)); const ymm a04_p1_a26 = addpz2(a04, a26); const ymm s04_pj_s26 = addpz2(s04, js26); const ymm a04_m1_a26 = subpz2(a04, a26); const ymm s04_mj_s26 = subpz2(s04, js26); const ymm a15_p1_a37 = addpz2(a15, a37); const ymm v8_s15_pj_s37 = v8xpz2(addpz2(s15, js37)); const ymm j_a15_m1_a37 = jxpz2(subpz2(a15, a37)); const ymm w8_s15_mj_s37 = w8xpz2(subpz2(s15, js37)); const ymm w1p = cnjpz2(getpz2(twid<8,N,1>(W,p))); const ymm w2p = cnjpz2(getpz2(twid<8,N,2>(W,p))); const ymm w3p = cnjpz2(getpz2(twid<8,N,3>(W,p))); const ymm w4p = cnjpz2(getpz2(twid<8,N,4>(W,p))); const ymm w5p = cnjpz2(getpz2(twid<8,N,5>(W,p))); const ymm w6p = cnjpz2(getpz2(twid<8,N,6>(W,p))); const ymm w7p = cnjpz2(getpz2(twid<8,N,7>(W,p))); #if 0 setpz3<8>(y_8p+0, addpz2(a04_p1_a26, a15_p1_a37)); setpz3<8>(y_8p+1, mulpz2(w1p, addpz2(s04_pj_s26, v8_s15_pj_s37))); setpz3<8>(y_8p+2, mulpz2(w2p, addpz2(a04_m1_a26, j_a15_m1_a37))); setpz3<8>(y_8p+3, mulpz2(w3p, subpz2(s04_mj_s26, w8_s15_mj_s37))); setpz3<8>(y_8p+4, mulpz2(w4p, subpz2(a04_p1_a26, a15_p1_a37))); setpz3<8>(y_8p+5, mulpz2(w5p, subpz2(s04_pj_s26, v8_s15_pj_s37))); setpz3<8>(y_8p+6, mulpz2(w6p, subpz2(a04_m1_a26, j_a15_m1_a37))); setpz3<8>(y_8p+7, mulpz2(w7p, addpz2(s04_mj_s26, w8_s15_mj_s37))); #else const ymm aA = addpz2(a04_p1_a26, a15_p1_a37); const ymm bB = mulpz2(w1p, addpz2(s04_pj_s26, v8_s15_pj_s37)); const ymm cC = mulpz2(w2p, addpz2(a04_m1_a26, j_a15_m1_a37)); const ymm dD = mulpz2(w3p, subpz2(s04_mj_s26, w8_s15_mj_s37)); const ymm eE = mulpz2(w4p, subpz2(a04_p1_a26, a15_p1_a37)); const ymm fF = mulpz2(w5p, subpz2(s04_pj_s26, v8_s15_pj_s37)); const ymm gG = mulpz2(w6p, subpz2(a04_m1_a26, j_a15_m1_a37)); const ymm hH = mulpz2(w7p, addpz2(s04_mj_s26, w8_s15_mj_s37)); const ymm ab = catlo(aA, bB); setpz2(y_8p+ 0, ab); const ymm cd = catlo(cC, dD); setpz2(y_8p+ 2, cd); const ymm ef = catlo(eE, fF); setpz2(y_8p+ 4, ef); const ymm gh = catlo(gG, hH); setpz2(y_8p+ 6, gh); const ymm AB = cathi(aA, bB); setpz2(y_8p+ 8, AB); const ymm CD = cathi(cC, dD); setpz2(y_8p+10, CD); const ymm EF = cathi(eE, fF); setpz2(y_8p+12, EF); const ymm GH = cathi(gG, hH); setpz2(y_8p+14, GH); #endif } } }; /////////////////////////////////////////////////////////////////////////////// template <int n, int s, bool eo, int mode> struct invend; //----------------------------------------------------------------------------- template <int s, bool eo, int mode> struct invend<8,s,eo,mode> { static constexpr int N = 8*s; void operator()(complex_vector x, complex_vector y) const noexcept { complex_vector z = eo ? y : x; for (int q = 0; q < s; q += 2) { complex_vector xq = x + q; complex_vector zq = z + q; const ymm x0 = scalepz2<N,mode>(getpz2(xq+s*0)); const ymm x1 = scalepz2<N,mode>(getpz2(xq+s*1)); const ymm x2 = scalepz2<N,mode>(getpz2(xq+s*2)); const ymm x3 = scalepz2<N,mode>(getpz2(xq+s*3)); const ymm x4 = scalepz2<N,mode>(getpz2(xq+s*4)); const ymm x5 = scalepz2<N,mode>(getpz2(xq+s*5)); const ymm x6 = scalepz2<N,mode>(getpz2(xq+s*6)); const ymm x7 = scalepz2<N,mode>(getpz2(xq+s*7)); const ymm a04 = addpz2(x0, x4); const ymm s04 = subpz2(x0, x4); const ymm a26 = addpz2(x2, x6); const ymm js26 = jxpz2(subpz2(x2, x6)); const ymm a15 = addpz2(x1, x5); const ymm s15 = subpz2(x1, x5); const ymm a37 = addpz2(x3, x7); const ymm js37 = jxpz2(subpz2(x3, x7)); const ymm a04_p1_a26 = addpz2(a04, a26); const ymm s04_pj_s26 = addpz2(s04, js26); const ymm a04_m1_a26 = subpz2(a04, a26); const ymm s04_mj_s26 = subpz2(s04, js26); const ymm a15_p1_a37 = addpz2(a15, a37); const ymm v8_s15_pj_s37 = v8xpz2(addpz2(s15, js37)); const ymm j_a15_m1_a37 = jxpz2(subpz2(a15, a37)); const ymm w8_s15_mj_s37 = w8xpz2(subpz2(s15, js37)); setpz2(zq+s*0, addpz2(a04_p1_a26, a15_p1_a37)); setpz2(zq+s*1, addpz2(s04_pj_s26, v8_s15_pj_s37)); setpz2(zq+s*2, addpz2(a04_m1_a26, j_a15_m1_a37)); setpz2(zq+s*3, subpz2(s04_mj_s26, w8_s15_mj_s37)); setpz2(zq+s*4, subpz2(a04_p1_a26, a15_p1_a37)); setpz2(zq+s*5, subpz2(s04_pj_s26, v8_s15_pj_s37)); setpz2(zq+s*6, subpz2(a04_m1_a26, j_a15_m1_a37)); setpz2(zq+s*7, addpz2(s04_mj_s26, w8_s15_mj_s37)); } } }; template <bool eo, int mode> struct invend<8,1,eo,mode> { inline void operator()(complex_vector x, complex_vector y) const noexcept { zeroupper(); complex_vector z = eo ? y : x; const xmm x0 = scalepz<8,mode>(getpz(x[0])); const xmm x1 = scalepz<8,mode>(getpz(x[1])); const xmm x2 = scalepz<8,mode>(getpz(x[2])); const xmm x3 = scalepz<8,mode>(getpz(x[3])); const xmm x4 = scalepz<8,mode>(getpz(x[4])); const xmm x5 = scalepz<8,mode>(getpz(x[5])); const xmm x6 = scalepz<8,mode>(getpz(x[6])); const xmm x7 = scalepz<8,mode>(getpz(x[7])); const xmm a04 = addpz(x0, x4); const xmm s04 = subpz(x0, x4); const xmm a26 = addpz(x2, x6); const xmm js26 = jxpz(subpz(x2, x6)); const xmm a15 = addpz(x1, x5); const xmm s15 = subpz(x1, x5); const xmm a37 = addpz(x3, x7); const xmm js37 = jxpz(subpz(x3, x7)); const xmm a04_p1_a26 = addpz(a04, a26); const xmm s04_pj_s26 = addpz(s04, js26); const xmm a04_m1_a26 = subpz(a04, a26); const xmm s04_mj_s26 = subpz(s04, js26); const xmm a15_p1_a37 = addpz(a15, a37); const xmm v8_s15_pj_s37 = v8xpz(addpz(s15, js37)); const xmm j_a15_m1_a37 = jxpz(subpz(a15, a37)); const xmm w8_s15_mj_s37 = w8xpz(subpz(s15, js37)); setpz(z[0], addpz(a04_p1_a26, a15_p1_a37)); setpz(z[1], addpz(s04_pj_s26, v8_s15_pj_s37)); setpz(z[2], addpz(a04_m1_a26, j_a15_m1_a37)); setpz(z[3], subpz(s04_mj_s26, w8_s15_mj_s37)); setpz(z[4], subpz(a04_p1_a26, a15_p1_a37)); setpz(z[5], subpz(s04_pj_s26, v8_s15_pj_s37)); setpz(z[6], subpz(a04_m1_a26, j_a15_m1_a37)); setpz(z[7], addpz(s04_mj_s26, w8_s15_mj_s37)); } }; /////////////////////////////////////////////////////////////////////////////// // Inverse FFT /////////////////////////////////////////////////////////////////////////////// template <int n, int s, bool eo, int mode> struct invfft { inline void operator()( complex_vector x, complex_vector y, const_complex_vector W) const noexcept { invcore<n,s>()(x, y, W); invfft<n/8,8*s,!eo,mode>()(y, x, W); } }; template <int s, bool eo, int mode> struct invfft<8,s,eo,mode> { inline void operator()( complex_vector x, complex_vector y, const_complex_vector) const noexcept { invend<8,s,eo,mode>()(x, y); } }; template <int s, bool eo, int mode> struct invfft<4,s,eo,mode> { inline void operator()( complex_vector x, complex_vector y, const_complex_vector) const noexcept { OTFFT_AVXDIF4::invend<4,s,eo,mode>()(x, y); } }; template <int s, bool eo, int mode> struct invfft<2,s,eo,mode> { inline void operator()( complex_vector x, complex_vector y, const_complex_vector) const noexcept { OTFFT_AVXDIF4::invend<2,s,eo,mode>()(x, y); } }; /////////////////////////////////////////////////////////////////////////////// // FFT object /////////////////////////////////////////////////////////////////////////////// struct FFT0 { int N, log_N; simd_array<complex_t> weight; complex_t* __restrict W; FFT0() noexcept : N(0), log_N(0), W(0) {} FFT0(const int n) { setup(n); } void setup(int n) { for (log_N = 0; n > 1; n >>= 1) log_N++; setup2(log_N); } inline void setup2(const int n) { log_N = n; N = 1 << n; if (N <= 8) W = 0; else if (N < OMP_THRESHOLD) { weight.setup(2*N); W = &weight; init_Wt(8, N, W); } else if (N < EXP_THRESHOLD) { weight.setup(N/8); W = &weight; init_Wr1(8, N, W); } else W = 0; } /////////////////////////////////////////////////////////////////////////// void fwd(complex_vector x, complex_vector y) const noexcept { constexpr int mode = scale_length; if (N < OMP_THRESHOLD) { switch (log_N) { case 0: break; case 1: fwdfft<(1<< 1),1,0,mode>()(x, y, W); break; case 2: fwdfft<(1<< 2),1,0,mode>()(x, y, W); break; case 3: fwdfft<(1<< 3),1,0,mode>()(x, y, W); break; case 4: fwdfft<(1<< 4),1,0,mode>()(x, y, W); break; case 5: fwdfft<(1<< 5),1,0,mode>()(x, y, W); break; case 6: fwdfft<(1<< 6),1,0,mode>()(x, y, W); break; case 7: fwdfft<(1<< 7),1,0,mode>()(x, y, W); break; case 8: fwdfft<(1<< 8),1,0,mode>()(x, y, W); break; case 9: fwdfft<(1<< 9),1,0,mode>()(x, y, W); break; case 10: fwdfft<(1<<10),1,0,mode>()(x, y, W); break; case 11: fwdfft<(1<<11),1,0,mode>()(x, y, W); break; case 12: fwdfft<(1<<12),1,0,mode>()(x, y, W); break; case 13: fwdfft<(1<<13),1,0,mode>()(x, y, W); break; case 14: fwdfft<(1<<14),1,0,mode>()(x, y, W); break; case 15: fwdfft<(1<<15),1,0,mode>()(x, y, W); break; case 16: fwdfft<(1<<16),1,0,mode>()(x, y, W); break; case 17: fwdfft<(1<<17),1,0,mode>()(x, y, W); break; case 18: fwdfft<(1<<18),1,0,mode>()(x, y, W); break; case 19: fwdfft<(1<<19),1,0,mode>()(x, y, W); break; case 20: fwdfft<(1<<20),1,0,mode>()(x, y, W); break; case 21: fwdfft<(1<<21),1,0,mode>()(x, y, W); break; case 22: fwdfft<(1<<22),1,0,mode>()(x, y, W); break; case 23: fwdfft<(1<<23),1,0,mode>()(x, y, W); break; case 24: fwdfft<(1<<24),1,0,mode>()(x, y, W); break; } } else if (N < EXP_THRESHOLD) OTFFT_AVXDIF8omp::fwd(log_N, x, y, W); else OTFFT_AVXDIF8exp::fwd(log_N, x, y); } void fwd0(complex_vector x, complex_vector y) const noexcept { constexpr int mode = scale_1; if (N < OMP_THRESHOLD) { switch (log_N) { case 0: break; case 1: fwdfft<(1<< 1),1,0,mode>()(x, y, W); break; case 2: fwdfft<(1<< 2),1,0,mode>()(x, y, W); break; case 3: fwdfft<(1<< 3),1,0,mode>()(x, y, W); break; case 4: fwdfft<(1<< 4),1,0,mode>()(x, y, W); break; case 5: fwdfft<(1<< 5),1,0,mode>()(x, y, W); break; case 6: fwdfft<(1<< 6),1,0,mode>()(x, y, W); break; case 7: fwdfft<(1<< 7),1,0,mode>()(x, y, W); break; case 8: fwdfft<(1<< 8),1,0,mode>()(x, y, W); break; case 9: fwdfft<(1<< 9),1,0,mode>()(x, y, W); break; case 10: fwdfft<(1<<10),1,0,mode>()(x, y, W); break; case 11: fwdfft<(1<<11),1,0,mode>()(x, y, W); break; case 12: fwdfft<(1<<12),1,0,mode>()(x, y, W); break; case 13: fwdfft<(1<<13),1,0,mode>()(x, y, W); break; case 14: fwdfft<(1<<14),1,0,mode>()(x, y, W); break; case 15: fwdfft<(1<<15),1,0,mode>()(x, y, W); break; case 16: fwdfft<(1<<16),1,0,mode>()(x, y, W); break; case 17: fwdfft<(1<<17),1,0,mode>()(x, y, W); break; case 18: fwdfft<(1<<18),1,0,mode>()(x, y, W); break; case 19: fwdfft<(1<<19),1,0,mode>()(x, y, W); break; case 20: fwdfft<(1<<20),1,0,mode>()(x, y, W); break; case 21: fwdfft<(1<<21),1,0,mode>()(x, y, W); break; case 22: fwdfft<(1<<22),1,0,mode>()(x, y, W); break; case 23: fwdfft<(1<<23),1,0,mode>()(x, y, W); break; case 24: fwdfft<(1<<24),1,0,mode>()(x, y, W); break; } } else if (N < EXP_THRESHOLD) OTFFT_AVXDIF8omp::fwd0(log_N, x, y, W); else OTFFT_AVXDIF8exp::fwd0(log_N, x, y); } void fwdu(complex_vector x, complex_vector y) const noexcept { constexpr int mode = scale_unitary; if (N < OMP_THRESHOLD) { switch (log_N) { case 0: break; case 1: fwdfft<(1<< 1),1,0,mode>()(x, y, W); break; case 2: fwdfft<(1<< 2),1,0,mode>()(x, y, W); break; case 3: fwdfft<(1<< 3),1,0,mode>()(x, y, W); break; case 4: fwdfft<(1<< 4),1,0,mode>()(x, y, W); break; case 5: fwdfft<(1<< 5),1,0,mode>()(x, y, W); break; case 6: fwdfft<(1<< 6),1,0,mode>()(x, y, W); break; case 7: fwdfft<(1<< 7),1,0,mode>()(x, y, W); break; case 8: fwdfft<(1<< 8),1,0,mode>()(x, y, W); break; case 9: fwdfft<(1<< 9),1,0,mode>()(x, y, W); break; case 10: fwdfft<(1<<10),1,0,mode>()(x, y, W); break; case 11: fwdfft<(1<<11),1,0,mode>()(x, y, W); break; case 12: fwdfft<(1<<12),1,0,mode>()(x, y, W); break; case 13: fwdfft<(1<<13),1,0,mode>()(x, y, W); break; case 14: fwdfft<(1<<14),1,0,mode>()(x, y, W); break; case 15: fwdfft<(1<<15),1,0,mode>()(x, y, W); break; case 16: fwdfft<(1<<16),1,0,mode>()(x, y, W); break; case 17: fwdfft<(1<<17),1,0,mode>()(x, y, W); break; case 18: fwdfft<(1<<18),1,0,mode>()(x, y, W); break; case 19: fwdfft<(1<<19),1,0,mode>()(x, y, W); break; case 20: fwdfft<(1<<20),1,0,mode>()(x, y, W); break; case 21: fwdfft<(1<<21),1,0,mode>()(x, y, W); break; case 22: fwdfft<(1<<22),1,0,mode>()(x, y, W); break; case 23: fwdfft<(1<<23),1,0,mode>()(x, y, W); break; case 24: fwdfft<(1<<24),1,0,mode>()(x, y, W); break; } } else if (N < EXP_THRESHOLD) OTFFT_AVXDIF8omp::fwdu(log_N, x, y, W); else OTFFT_AVXDIF8exp::fwdu(log_N, x, y); } inline void fwdn(complex_vector x, complex_vector y) const noexcept { fwd(x, y); } /////////////////////////////////////////////////////////////////////////// void inv(complex_vector x, complex_vector y) const noexcept { constexpr int mode = scale_1; if (N < OMP_THRESHOLD) { switch (log_N) { case 0: break; case 1: invfft<(1<< 1),1,0,mode>()(x, y, W); break; case 2: invfft<(1<< 2),1,0,mode>()(x, y, W); break; case 3: invfft<(1<< 3),1,0,mode>()(x, y, W); break; case 4: invfft<(1<< 4),1,0,mode>()(x, y, W); break; case 5: invfft<(1<< 5),1,0,mode>()(x, y, W); break; case 6: invfft<(1<< 6),1,0,mode>()(x, y, W); break; case 7: invfft<(1<< 7),1,0,mode>()(x, y, W); break; case 8: invfft<(1<< 8),1,0,mode>()(x, y, W); break; case 9: invfft<(1<< 9),1,0,mode>()(x, y, W); break; case 10: invfft<(1<<10),1,0,mode>()(x, y, W); break; case 11: invfft<(1<<11),1,0,mode>()(x, y, W); break; case 12: invfft<(1<<12),1,0,mode>()(x, y, W); break; case 13: invfft<(1<<13),1,0,mode>()(x, y, W); break; case 14: invfft<(1<<14),1,0,mode>()(x, y, W); break; case 15: invfft<(1<<15),1,0,mode>()(x, y, W); break; case 16: invfft<(1<<16),1,0,mode>()(x, y, W); break; case 17: invfft<(1<<17),1,0,mode>()(x, y, W); break; case 18: invfft<(1<<18),1,0,mode>()(x, y, W); break; case 19: invfft<(1<<19),1,0,mode>()(x, y, W); break; case 20: invfft<(1<<20),1,0,mode>()(x, y, W); break; case 21: invfft<(1<<21),1,0,mode>()(x, y, W); break; case 22: invfft<(1<<22),1,0,mode>()(x, y, W); break; case 23: invfft<(1<<23),1,0,mode>()(x, y, W); break; case 24: invfft<(1<<24),1,0,mode>()(x, y, W); break; } } else if (N < EXP_THRESHOLD) OTFFT_AVXDIF8omp::inv(log_N, x, y, W); else OTFFT_AVXDIF8exp::inv(log_N, x, y); } inline void inv0(complex_vector x, complex_vector y) const noexcept { inv(x, y); } void invu(complex_vector x, complex_vector y) const noexcept { constexpr int mode = scale_unitary; if (N < OMP_THRESHOLD) { switch (log_N) { case 0: break; case 1: invfft<(1<< 1),1,0,mode>()(x, y, W); break; case 2: invfft<(1<< 2),1,0,mode>()(x, y, W); break; case 3: invfft<(1<< 3),1,0,mode>()(x, y, W); break; case 4: invfft<(1<< 4),1,0,mode>()(x, y, W); break; case 5: invfft<(1<< 5),1,0,mode>()(x, y, W); break; case 6: invfft<(1<< 6),1,0,mode>()(x, y, W); break; case 7: invfft<(1<< 7),1,0,mode>()(x, y, W); break; case 8: invfft<(1<< 8),1,0,mode>()(x, y, W); break; case 9: invfft<(1<< 9),1,0,mode>()(x, y, W); break; case 10: invfft<(1<<10),1,0,mode>()(x, y, W); break; case 11: invfft<(1<<11),1,0,mode>()(x, y, W); break; case 12: invfft<(1<<12),1,0,mode>()(x, y, W); break; case 13: invfft<(1<<13),1,0,mode>()(x, y, W); break; case 14: invfft<(1<<14),1,0,mode>()(x, y, W); break; case 15: invfft<(1<<15),1,0,mode>()(x, y, W); break; case 16: invfft<(1<<16),1,0,mode>()(x, y, W); break; case 17: invfft<(1<<17),1,0,mode>()(x, y, W); break; case 18: invfft<(1<<18),1,0,mode>()(x, y, W); break; case 19: invfft<(1<<19),1,0,mode>()(x, y, W); break; case 20: invfft<(1<<20),1,0,mode>()(x, y, W); break; case 21: invfft<(1<<21),1,0,mode>()(x, y, W); break; case 22: invfft<(1<<22),1,0,mode>()(x, y, W); break; case 23: invfft<(1<<23),1,0,mode>()(x, y, W); break; case 24: invfft<(1<<24),1,0,mode>()(x, y, W); break; } } else if (N < EXP_THRESHOLD) OTFFT_AVXDIF8omp::invu(log_N, x, y, W); else OTFFT_AVXDIF8exp::invu(log_N, x, y); } void invn(complex_vector x, complex_vector y) const noexcept { constexpr int mode = scale_length; if (N < OMP_THRESHOLD) { switch (log_N) { case 0: break; case 1: invfft<(1<< 1),1,0,mode>()(x, y, W); break; case 2: invfft<(1<< 2),1,0,mode>()(x, y, W); break; case 3: invfft<(1<< 3),1,0,mode>()(x, y, W); break; case 4: invfft<(1<< 4),1,0,mode>()(x, y, W); break; case 5: invfft<(1<< 5),1,0,mode>()(x, y, W); break; case 6: invfft<(1<< 6),1,0,mode>()(x, y, W); break; case 7: invfft<(1<< 7),1,0,mode>()(x, y, W); break; case 8: invfft<(1<< 8),1,0,mode>()(x, y, W); break; case 9: invfft<(1<< 9),1,0,mode>()(x, y, W); break; case 10: invfft<(1<<10),1,0,mode>()(x, y, W); break; case 11: invfft<(1<<11),1,0,mode>()(x, y, W); break; case 12: invfft<(1<<12),1,0,mode>()(x, y, W); break; case 13: invfft<(1<<13),1,0,mode>()(x, y, W); break; case 14: invfft<(1<<14),1,0,mode>()(x, y, W); break; case 15: invfft<(1<<15),1,0,mode>()(x, y, W); break; case 16: invfft<(1<<16),1,0,mode>()(x, y, W); break; case 17: invfft<(1<<17),1,0,mode>()(x, y, W); break; case 18: invfft<(1<<18),1,0,mode>()(x, y, W); break; case 19: invfft<(1<<19),1,0,mode>()(x, y, W); break; case 20: invfft<(1<<20),1,0,mode>()(x, y, W); break; case 21: invfft<(1<<21),1,0,mode>()(x, y, W); break; case 22: invfft<(1<<22),1,0,mode>()(x, y, W); break; case 23: invfft<(1<<23),1,0,mode>()(x, y, W); break; case 24: invfft<(1<<24),1,0,mode>()(x, y, W); break; } } else if (N < EXP_THRESHOLD) OTFFT_AVXDIF8omp::invn(log_N, x, y, W); else OTFFT_AVXDIF8exp::invn(log_N, x, y); } }; } ///////////////////////////////////////////////////////////////////////////// #endif // otfft_avxdif8_h
[ "ix@tchow.com" ]
ix@tchow.com
3c80142bc2089b477d8a66b4e4a3b7f8b1dc6c21
484fc712fba5881094b92228ae1e38998704552a
/Copy Control/HasPtr2.cpp
ecc1b173a063659dff7e24375d2affdaf5161884
[]
no_license
naruto-f/Cplusplus-prime
b86037e6a85b8b5b709a26c3599a7270245d4615
ecca0f4f56a3817ad68a69300ec7b8118436991f
refs/heads/master
2023-07-09T22:30:09.419283
2021-08-08T12:22:25
2021-08-08T12:22:25
364,495,222
0
0
null
null
null
null
UTF-8
C++
false
false
538
cpp
// // Created by 123456 on 2021/5/7. // #include "HasPtr2.h" HasPtr2& HasPtr2::operator=(const HasPtr2 &rhs) { ++(*rhs.use); //先递增右侧运算对象的引用计数,可以解决自赋值问题 if(--*use == 0) { delete ps; ps = nullptr; delete use; use = nullptr; } ps = rhs.ps; i = rhs.i; use = rhs.use; return *this; } HasPtr2::~HasPtr2() { if(--*use == 0) { delete ps; ps = nullptr; delete use; use = nullptr; } }
[ "476971219@qq.com" ]
476971219@qq.com
4335f57fed67f7faa7643997c58814e7959b8f94
9a3fc0a5abe3bf504a63a643e6501a2f3452ba6d
/tc/testprograms/PermissionTree.cpp
c9db8f51c05065161e692606947a687ce1ec812f
[]
no_license
rodolfo15625/algorithms
7034f856487c69553205198700211d7afb885d4c
9e198ff0c117512373ca2d9d706015009dac1d65
refs/heads/master
2021-01-18T08:30:19.777193
2014-10-20T13:15:09
2014-10-20T13:15:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,870
cpp
#include <vector> #include <map> #include <set> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cstring> #include <ctime> using namespace std; typedef vector<int> vi; typedef vector<string> vs; typedef pair<int, int> pii; typedef long long ll; #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define sz size() #define REP(i,a,b) for(int i=int(a);i<int(b);i++) #define fill(x,i) memset(x,i,sizeof(x)) #define foreach(c,it) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++) map<int,vector<string> >M; int P[55]; bool check(int ubi, int node){ do{ if(ubi==node)return 1; ubi=P[ubi]; }while(ubi!=0); return 0; } class PermissionTree { public:vector <int> findHome(vector <string> folders, vector <string> users) { REP(i,0,55)P[i]=i; REP(i,0,folders.sz){ REP(j,0,folders[i].sz)if(folders[i][j]==',')folders[i][j]=' '; int root; string user; istringstream is(folders[i]); is>>root; while(is>>user)M[i].push_back(user); P[i]=root; sort(all(M[i])); } vector<int> peki; REP(i,0,users.sz){ vector<int> v; REP(j,0,folders.sz) if(binary_search(all(M[j]),users[i])) v.push_back(j); if(v.sz==0)peki.push_back(-1); else{ int ubi=v[0]; cout<<ubi<<endl; bool ok=0; while(ubi!=0 && !ok){ ok=1; REP(j,1,v.sz) if(!check(v[j],ubi))ok=0; if(ok)break; ubi=P[ubi]; } peki.push_back(ubi); } } return peki; } //Powered by [Ziklon] }; // BEGIN KAWIGIEDIT TESTING // Generated by KawigiEdit 2.1.8 (beta) modified by pivanof #include <iostream> #include <string> #include <vector> using namespace std; bool KawigiEdit_RunTest(int testNum, vector <string> p0, vector <string> p1, bool hasAnswer, vector <int> p2) { cout << "Test " << testNum << ": [" << "{"; for (int i = 0; int(p0.size()) > i; ++i) { if (i > 0) { cout << ","; } cout << "\"" << p0[i] << "\""; } cout << "}" << "," << "{"; for (int i = 0; int(p1.size()) > i; ++i) { if (i > 0) { cout << ","; } cout << "\"" << p1[i] << "\""; } cout << "}"; cout << "]" << endl; PermissionTree *obj; vector <int> answer; obj = new PermissionTree(); clock_t startTime = clock(); answer = obj->findHome(p0, p1); clock_t endTime = clock(); delete obj; bool res; res = true; cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl; if (hasAnswer) { cout << "Desired answer:" << endl; cout << "\t" << "{"; for (int i = 0; int(p2.size()) > i; ++i) { if (i > 0) { cout << ","; } cout << p2[i]; } cout << "}" << endl; } cout << "Your answer:" << endl; cout << "\t" << "{"; for (int i = 0; int(answer.size()) > i; ++i) { if (i > 0) { cout << ","; } cout << answer[i]; } cout << "}" << endl; if (hasAnswer) { if (answer.size() != p2.size()) { res = false; } else { for (int i = 0; int(answer.size()) > i; ++i) { if (answer[i] != p2[i]) { res = false; } } } } if (!res) { cout << "DOESN'T MATCH!!!!" << endl; } else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) { cout << "FAIL the timeout" << endl; res = false; } else if (hasAnswer) { cout << "Match :-)" << endl; } else { cout << "OK, but is it right?" << endl; } cout << "" << endl; return res; } int main() { bool all_right; all_right = true; vector <string> p0; vector <string> p1; vector <int> p2; { // ----- test 0 ----- string t0[] = {"0 Admin","0 Joe,Phil","0 Joe"}; p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0])); string t1[] = {"Admin","Joe","Phil"}; p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0])); int t2[] = {0,0,1}; p2.assign(t2, t2 + sizeof(t2) / sizeof(t2[0])); all_right = KawigiEdit_RunTest(0, p0, p1, true, p2) && all_right; // ------------------ } { // ----- test 1 ----- string t0[] = {"0 Admin"}; p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0])); string t1[] = {"Peter","Paul","Mary"}; p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0])); int t2[] = {-1,-1,-1}; p2.assign(t2, t2 + sizeof(t2) / sizeof(t2[0])); all_right = KawigiEdit_RunTest(1, p0, p1, true, p2) && all_right; // ------------------ } { // ----- test 2 ----- string t0[] = {"0 Admin","2 John","0 Peter,John","0 Tim","1 John"}; p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0])); string t1[] = {"John"}; p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0])); int t2[] = {2}; p2.assign(t2, t2 + sizeof(t2) / sizeof(t2[0])); all_right = KawigiEdit_RunTest(2, p0, p1, true, p2) && all_right; // ------------------ } { // ----- test 3 ----- string t0[] = {"0 Admin","0 Jeff","1 Mark,Tim","1 Tim,Jeff","0 Dan","4 Ed","4 Tom","4 Kyle,Ed","0 Ben","8 Rich","8 Sam","8 Tim"}; p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0])); string t1[] = {"Jeff","Ed","Tim","Steve"}; p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0])); int t2[] = {1,4,0,-1}; p2.assign(t2, t2 + sizeof(t2) / sizeof(t2[0])); all_right = KawigiEdit_RunTest(3, p0, p1, true, p2) && all_right; // ------------------ } { // ----- test 4 ----- string t0[] = {"0 Admin","0 Bob,Joe,Bob","0 Joe"}; p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0])); string t1[] = {"Joe","Bob"}; p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0])); int t2[] = {0,1}; p2.assign(t2, t2 + sizeof(t2) / sizeof(t2[0])); all_right = KawigiEdit_RunTest(4, p0, p1, true, p2) && all_right; // ------------------ } if (all_right) { cout << "You're a stud (at least on the example cases)!" << endl; } else { cout << "Some of the test cases had errors." << endl; } return 0; } // END KAWIGIEDIT TESTING //Powered by KawigiEdit 2.1.8 (beta) modified by pivanof!
[ "winftc@gmail.com" ]
winftc@gmail.com
e1b29eacafbde227ad4c614eb120c5d76a459d3d
c6936565b8bda1da36a9a6929e4877377abb8f51
/Iterator Method/Aggregate.cpp
cdd587f96a0e015b5fd1e5697a3ef5dcd061667f
[]
no_license
413405872/Design-Patterns
cbe5ca5fb2b37698f2040451fd461c8cf8dd4595
5e309860e680e8fd5f54994fcef555efd2d83e91
refs/heads/master
2021-01-01T05:41:22.163231
2015-07-02T14:42:36
2015-07-02T14:42:38
38,413,550
4
0
null
null
null
null
GB18030
C++
false
false
813
cpp
#pragma once #include"Aggregate.h" Aggregate::Aggregate() { cout<<"Aggregate::Aggregate()"<<endl; } Aggregate::~Aggregate() { cout<<"Aggregate::~Aggregate()"<<endl; } ConcreteAggregate::ConcreteAggregate() { cout<<"ConcreteAggregate::ConcreteAggregate()"<<endl; for(int i=0;i<SIZE;i++) objs[i]=i; } ConcreteAggregate::~ConcreteAggregate() { cout<<"ConcreteAggregate::~ConcreteAggregate()"<<endl; } Iterator* ConcreteAggregate::createiterator()//这个生产一个迭代器 { return new ConcreteIterator(this,0);//并且把你具体的聚合对象给我迭代器,这样我才好访问你的元素啊,通过聚合对象访问聚合类中的元素啊 } int ConcreteAggregate::getsize() { return SIZE; } object ConcreteAggregate::getitem(int id) { if(id>=SIZE) return -1; else return objs[id]; }
[ "413405872@qq.com" ]
413405872@qq.com
0d894846400c9e0109b1273bfdb8bf3c7288b22a
4d0abde037b0f663ef5547787c72d54b12f0bb2a
/tests/Unit/Design/copy_functions_array_arrayview.cpp
e9466e0b2cbc57256988cfc5e016cc3efd658b51
[ "LicenseRef-scancode-unknown-license-reference", "NCSA" ]
permissive
LonghronShen/kalmar
5275e051f62cd45830d57ee25642007a6fd624a4
0a1a49d60e50b70aa94c97ab3521c0dc7f72a7f2
refs/heads/master
2023-03-16T03:36:35.297060
2015-05-08T00:21:35
2015-05-08T00:21:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,008
cpp
// RUN: %gtest_amp %s -o %t && %t #include <stdlib.h> #include <vector> #include <amp.h> using namespace concurrency; #define SIZE 1024 #include <gtest/gtest.h> void copyBetweenArray() { //copy data between one-dimensional array_view and one-dimensional array array<float, 1> arr1(SIZE), arr2(SIZE); for(int i = 0; i < SIZE; ++i) { index<1> idx(i); arr1[idx] = rand() / (float)RAND_MAX; arr2[idx] = 0.0f; } copy(arr1, arr2); for(int i = 0; i < SIZE; ++i) { index<1> idx(i); EXPECT_EQ(arr2[idx], arr1[idx]); } //copy data between two-dimensional array_view and two-dimensional array Concurrency::extent<2> e(SIZE, SIZE); array<float, 2> arr3(e), arr4(e); for(int i = 0; i < SIZE; ++i) { for(int j = 0; j < SIZE; ++j) { index<2> idx(i, j); arr3[idx] = rand() / (float)RAND_MAX; arr4[idx] = 0.0f; } } copy(arr3, arr4); for(int i = 0; i < SIZE; ++i) { for(int j = 0; j < SIZE; ++j) { EXPECT_EQ(arr3(i, j), arr4(i, j)); } } } void copyBetweenArrayView() { //copy data between one-dimensional array_view and one-dimensional array array<float, 1> arr1(SIZE), arr2(SIZE); array_view<float, 1> av1(arr1),av2(arr2); for(int i = 0; i < SIZE; ++i) { arr1(i) = 0.0f; arr2(i) = rand() / (float)RAND_MAX; } copy(av1, av2); for(int i = 0; i < SIZE; ++i) { EXPECT_EQ(av1(i), av2(i)); } //copy data between two-dimensional array_view and two-dimensional array Concurrency::extent<2> e(SIZE, SIZE); array<float, 2> arr3(e), arr4(e); array_view<float, 2> av3(arr3), av4(arr4); for(int i = 0; i < SIZE; ++i) { for(int j = 0; j < SIZE; ++j) { arr3(i, j) = rand() / (float)RAND_MAX; arr4(i, j) = 0.0f; } } copy(arr3, arr4); for(int i = 0; i < SIZE; ++i) { for(int j = 0; j < SIZE; ++j) { EXPECT_EQ(arr3(i, j), arr4(i, j)); } } } void copyBetweenArrayAndArrayView() { //copy data between one-dimensional array_view and one-dimensional array array<float, 1> arr1(SIZE), arr2(SIZE), arr3(SIZE); array_view<float, 1> av(arr1); for(int i = 0; i < SIZE; ++i) { arr1(i) = 0.0f; arr2(i) = rand() / (float)RAND_MAX; arr3(i) = 0.0f; } copy(arr2, av); copy(av, arr3); for(int i = 0; i < SIZE; ++i) { EXPECT_EQ(arr2(i), arr3(i)); } //copy data between two-dimensional array_view and two-dimensional array Concurrency::extent<2> e(SIZE, SIZE); array<float, 2> arr4(e), arr5(e), arr6(e); array_view<float, 2> av2(arr4); for(int i = 0; i < SIZE; ++i) { for(int j = 0; j < SIZE; ++j) { arr4(i, j) = 0.0f; arr5(i, j) = rand() / (float)RAND_MAX; arr6(i, j) =0.0f; } } copy(arr5, av2); copy(av2, arr6); for(int i = 0; i < SIZE; ++i) { for(int j = 0; j < SIZE; ++j) { EXPECT_EQ(arr5(i, j), arr6(i, j)); } } } TEST(Copy, ArrayViewAndArray) { copyBetweenArrayAndArrayView(); } TEST(Copy, Array) { copyBetweenArray(); } TEST(Copy, ArrayView) { copyBetweenArrayView(); }
[ "devnull@localhost" ]
devnull@localhost
ab9b20a57caccace35388705554b4cfde3d31d85
18a23fdcb5c65e2a452cbdb34f522cb45648cd8c
/main/main.cpp
383b6afd8903fae020ecf9a23b70019be7b68840
[]
no_license
r043v/gdl2.wdows
82a11639660a31c5d785992e19b40e415ada07d9
3d6dcd101de01caed2d2be6851f5ca25846f5b3e
refs/heads/master
2016-09-08T01:58:53.433422
2014-01-28T03:16:38
2014-01-28T03:16:38
16,300,847
1
0
null
null
null
null
WINDOWS-1250
C++
false
false
5,159
cpp
/* Gdl˛ - test */ #include "../Gdl/Gdl.h" // the lib.. // include gfx #include "./gfx/flashfont.h" #include "./gfx/tileset.h" // kobog tileset //#include "./gfx/cursor.h" // the yellow animated cursor #include "./gfx/zeldaTiles.h" #include "./gfx/zeldaTiles.map.h" #include "./gfx/tile54.h" #include "./gfx/tile10.h" //#include "./gfx/przs.h" //#include "./gfx/PRZYSTAN.map.h" #include "./gfx/zzz.h" #include "./gfx/sky.h" #include "./gfx/sky.map.h" #include "./array.h" // the map array.. #include "./mymap.h" // the map array.. #include "data.rar.h" //#include "./kial_Tiles.h" // uncrunch data... void uncrunchData(void) { // uncrunch gfx from 4b gfm to 32b gfm unCrunchGfm(zzz,zzzFrmNb); unCrunchGfm(zeldaTiles,zeldaTilesFrmNb); unCrunchGfm(tile54,tile54FrmNb); unCrunchGfm(tile10,tile10FrmNb); unCrunchGfm(sky,skyFrmNb); //unCrunchGfm(tileset,tilesetFrmNb); unCrunchGfm(flashfont,flashfontFrmNb); //log("uncrunched"); } void drawOutZone(outzone*out) { ligne(out->x,out->y,out->x+out->width,out->y,pixel); ligne(out->x,out->y,out->x,out->y+out->height,pixel); ligne(out->x+out->width,out->y,out->x+out->width,out->y+out->height,pixel); ligne(out->x,out->y+out->height,out->x+out->width,out->y+out->height,pixel); } int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { u32 size; u8 * as = loadFile("asm.s",&size); u32 asmOff=0, outOff=0; if(as) { u8 * out = (u8*)malloc(102400); while(asmOff<size) { while(asmOff<size && (as[asmOff]==' ' || as[asmOff]=='\n')) asmOff++; if(asmOff<size) { const char * str = "\n\t\"\t"; u32 s = strlen(str); memcpy(&out[outOff],str,s); outOff += s; } while(asmOff<size && as[asmOff]!='\n') { static u32 cpy=1; if(as[asmOff] == '/' && as[asmOff+1] == '*') { asmOff+=2; cpy=0; } // comment start if(as[asmOff] == '*' && as[asmOff+1] == '/') { asmOff+=2; cpy=1; } // comment end if(cpy) out[outOff++] = as[asmOff]; asmOff++; } asmOff++; outOff--; //memcpy(&out[outOff],,strlen("\t\\n\"")); if(asmOff<size) { const char * str = "\t\\n\""; u32 s = strlen(str); memcpy(&out[outOff],str,s); outOff += s; } }; writeFile("out.c",out,outOff); } Gdl_init("[gdlMap]",640,480); // init the framebuffer if(!Gdl_playSong("data.rar|song.xm")) Gdl_playSong(data,dataSize,"darkchip.xm"); //setGdlfont(greenfont,greenfontFrmNb); uncrunchData(); setGdlfont(flashfont); map myMap, myMap2, lapin, prz; outzone * out = createOutzone(10,10,296,296); outzone * out2 = createOutzone(320,320,194,150); outzone * out3 = createOutzone(320,10,312,296); outzone * out4 = createOutzone(10,310,300,164); lapin.set((u16*)skymap,sky,skyFrmNb,8,8,50,80,0,0,out,0); myMap2.set(maparray,zzz,zzzFrmNb,8,8,64,64,0,0,out2,0); myMap.set((u16*)zeldaTilesMap,zeldaTiles,zeldaTilesFrmNb,16,16,80,60,0,0,out3,0); prz.set((u16*)array,tileset,tilesetFrmNb,16,16,64,64,0,0,out4,0); anim * myanim = setAnim(zzz,zzzFrmNb,100); //anim * myanim2 = setAnim(&tileset[4],8,100); anim * flowerAnm = setAnim(tile54,tile54FrmNb,200); anim * flowerAnm2= setAnim(tile10,tile10FrmNb,150); myMap2.setAnimatedTile(1,myanim); myMap.setAnimatedTile(54,flowerAnm); myMap.setAnimatedTile(10,flowerAnm2); u32 px = 320; int pxw = 1; u32 modSize = 0; u8 * sfx = loadFile("test.mod",&modSize); Gdl_setSfx(sfx,modSize); myMap.setScroll(150,150); while(1) { clrScr(0); memset(pixel,0xff,WIDTH*4); static u32 hway=2, wway=8, hway2=2, wway2=8, hway3=2, wway3=8, hway4=2, wway4=8; u32 rtn = myMap.scroll(hway|wway,1); if(rtn) { if(rtn&1) hway=2; if(rtn&2) hway=1; if(rtn&4) wway=8; if(rtn&8) wway=4; } rtn = myMap2.scroll(hway2|wway2,1); if(rtn) { if(rtn&1) hway2=2; if(rtn&2) hway2=1; if(rtn&4) wway2=8; if(rtn&8) wway2=4; } rtn = lapin.scroll(hway3|wway3,1); if(rtn) { if(rtn&1) hway3=2; if(rtn&2) hway3=1; if(rtn&4) wway3=8; if(rtn&8) wway3=4; } rtn = prz.scroll(hway4|wway4,2); if(rtn) { if(rtn&1) hway4=2; if(rtn&2) hway4=1; if(rtn&4) wway4=8; if(rtn&8) wway4=4; } myMap2.moveOutZone(px,320); px += pxw; if(pxw<0 && px<=320) pxw = 1; if(pxw>0 && px>=440) pxw = -1; myMap.draw(); myMap2.draw(); lapin.draw(); prz.draw(); drawOutZone(out); drawOutZone(out2); drawOutZone(out3); drawOutZone(out4); if(keyPush(kleft)) { Gdl_playSfx(4,100); } u32 crttile = 0xffff; crttile = lapin.getScreenTile(mousex,mousey); if(crttile == 0xffff) crttile = myMap.getScreenTile(mousex,mousey); if(crttile == 0xffff) crttile = myMap2.getScreenTile(mousex,mousey); if(crttile == 0xffff) crttile = prz.getScreenTile(mousex,mousey); if(isMouseHere) if(crttile != 0xffff) prints(mousex+10,mousey+10,"%i",crttile); prints(10,20,"%i.%i",mousex,mousey); Gdl_flip(); }; Gdl_exit(); return 0; }
[ "noferov@gmail.com" ]
noferov@gmail.com