text
stringlengths
1
1.05M
;================================================= ; Name: Adrian Harminto ; Email: aharm002@ucr.edu ; ; Lab: lab 4 ; Lab section: 24 ; TA: Bryan Marsh ; ;================================================= .orig x3000 ;------------ ;Instruction ;------------ LEA R0, intro PUTS LD R6, size LD R3, ptr Loop ; scanning 10 characters GETC OUT STR R0, R3, #0 ADD R3, R3, #1 ADD R6, R6, #-1 BRp Loop LD R6, size ;resetting R3 and R6 LD R3, ptr ;NEWLINE - exercise 3 LEA R0, NEWLINE PUTS LEA R0, output PUTS ;Loop2 ; printing those 10 characters ;LDR R0, R3, #0 ;OUT ;ADD R3, R3, #1 ;ADD R6, R6, #-1 ;BRp Loop2 LD R0, ptr ; OR we can simply do this PUTS HALT ;------------ ;Local data ;------------ intro .STRINGZ "Enter exactly 10 characters:\n" output .STRINGZ "You entered:\n" NEWLINE .STRINGZ "\n" size .FILL #10 ptr .FILL x4000 .orig x4000 new_ptr .BLKW #10 .end
; A215097: a(n) = n^3 - a(n-2) for n >= 2 and a(0)=0, a(1)=1. ; 0,1,8,26,56,99,160,244,352,485,648,846,1080,1351,1664,2024,2432,2889,3400,3970,4600,5291,6048,6876,7776,8749,9800,10934,12152,13455,14848,16336,17920,19601,21384,23274,25272,27379,29600,31940,34400,36981,39688,42526 mov $15,$0 mov $17,$0 lpb $17,1 clr $0,15 mov $0,$15 sub $17,1 sub $0,$17 mov $12,$0 mov $14,$0 lpb $14,1 clr $0,12 mov $0,$12 sub $14,1 sub $0,$14 mov $9,$0 mov $11,$0 lpb $11,1 mov $0,$9 sub $11,1 sub $0,$11 mul $0,2 mov $6,7 add $6,$0 lpb $0,1 mod $0,2 pow $6,2 mov $8,5 mul $8,$6 mov $1,$8 div $1,2 mod $1,8 mul $1,4 lpe div $1,4 sub $1,1 add $10,$1 lpe add $13,$10 lpe add $16,$13 lpe mov $1,$16
; A025724: Index of 7^n within sequence of numbers of form 6^i*7^j. ; 1,3,6,10,15,21,28,36,45,55,66,78,92,107,123,140,158,177,197,218,240,263,287,312,339,367,396,426,457,489,522,556,591,627,664,703,743,784,826,869,913,958,1004,1051,1099,1148,1198,1250,1303,1357,1412,1468,1525,1583 mov $3,$0 add $3,1 mov $6,$0 lpb $3 mov $0,$6 sub $3,1 sub $0,$3 mov $11,$0 mov $12,0 mov $13,$0 add $13,1 lpb $13 mov $0,$11 sub $13,1 sub $0,$13 mov $7,$0 mov $9,2 lpb $9 mov $0,$7 mov $2,0 sub $9,1 add $0,$9 sub $0,1 add $2,$0 mul $0,2 sub $0,3 div $0,2 mov $5,1 add $5,$2 add $5,$0 div $5,23 mov $4,$5 mov $10,$9 lpb $10 mov $8,$4 sub $10,1 lpe lpe lpb $7 mov $7,0 sub $8,$4 lpe mov $4,$8 add $4,1 add $12,$4 lpe add $1,$12 lpe mov $0,$1
// index_create.cpp /** * Copyright (C) 2008-2014 MongoDB Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the GNU Affero General Public License in all respects for * all of the code used other than as permitted herein. If you modify file(s) * with this exception, you may extend this exception to your version of the * file(s), but you are not obligated to do so. If you do not wish to do so, * delete this exception statement from your version. If you delete this * exception statement from all source files in the program, then also delete * it in the license file. */ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kIndex #include "mongo/platform/basic.h" #include "mongo/db/catalog/index_create.h" #include "mongo/base/error_codes.h" #include "mongo/client/dbclientinterface.h" #include "mongo/db/audit.h" #include "mongo/db/background.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/client.h" #include "mongo/db/clientcursor.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/curop.h" #include "mongo/db/exec/working_set_common.h" #include "mongo/db/query/internal_plans.h" #include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/operation_context.h" #include "mongo/stdx/mutex.h" #include "mongo/util/log.h" #include "mongo/util/processinfo.h" #include "mongo/util/progress_meter.h" namespace mongo { using std::unique_ptr; using std::string; using std::endl; /** * On rollback sets MultiIndexBlock::_needToCleanup to true. */ class MultiIndexBlock::SetNeedToCleanupOnRollback : public RecoveryUnit::Change { public: explicit SetNeedToCleanupOnRollback(MultiIndexBlock* indexer) : _indexer(indexer) {} virtual void commit() {} virtual void rollback() { _indexer->_needToCleanup = true; } private: MultiIndexBlock* const _indexer; }; /** * On rollback in init(), cleans up _indexes so that ~MultiIndexBlock doesn't try to clean * up _indexes manually (since the changes were already rolled back). * Due to this, it is thus legal to call init() again after it fails. */ class MultiIndexBlock::CleanupIndexesVectorOnRollback : public RecoveryUnit::Change { public: explicit CleanupIndexesVectorOnRollback(MultiIndexBlock* indexer) : _indexer(indexer) {} virtual void commit() {} virtual void rollback() { _indexer->_indexes.clear(); } private: MultiIndexBlock* const _indexer; }; MultiIndexBlock::MultiIndexBlock(OperationContext* txn, Collection* collection) : _collection(collection), _txn(txn), _buildInBackground(false), _allowInterruption(false), _ignoreUnique(false), _needToCleanup(true) {} MultiIndexBlock::~MultiIndexBlock() { if (!_needToCleanup || _indexes.empty()) return; while (true) { try { WriteUnitOfWork wunit(_txn); // This cleans up all index builds. // Because that may need to write, it is done inside // of a WUOW. Nothing inside this block can fail, and it is made fatal if it does. for (size_t i = 0; i < _indexes.size(); i++) { _indexes[i].block->fail(); } wunit.commit(); return; } catch (const WriteConflictException& e) { continue; } catch (const std::exception& e) { error() << "Caught exception while cleaning up partially built indexes: " << e.what(); } catch (...) { error() << "Caught unknown exception while cleaning up partially built indexes."; } fassertFailed(18644); } } void MultiIndexBlock::removeExistingIndexes(std::vector<BSONObj>* specs) const { for (size_t i = 0; i < specs->size(); i++) { Status status = _collection->getIndexCatalog()->prepareSpecForCreate(_txn, (*specs)[i]).getStatus(); if (status.code() == ErrorCodes::IndexAlreadyExists) { specs->erase(specs->begin() + i); i--; } // intentionally ignoring other error codes } } Status MultiIndexBlock::init(const std::vector<BSONObj>& indexSpecs) { WriteUnitOfWork wunit(_txn); invariant(_indexes.empty()); _txn->recoveryUnit()->registerChange(new CleanupIndexesVectorOnRollback(this)); const string& ns = _collection->ns().ns(); Status status = _collection->getIndexCatalog()->checkUnfinished(); if (!status.isOK()) return status; for (size_t i = 0; i < indexSpecs.size(); i++) { BSONObj info = indexSpecs[i]; string pluginName = IndexNames::findPluginName(info["key"].Obj()); if (pluginName.size()) { Status s = _collection->getIndexCatalog()->_upgradeDatabaseMinorVersionIfNeeded( _txn, pluginName); if (!s.isOK()) return s; } // Any foreground indexes make all indexes be built in the foreground. _buildInBackground = (_buildInBackground && info["background"].trueValue()); } for (size_t i = 0; i < indexSpecs.size(); i++) { BSONObj info = indexSpecs[i]; StatusWith<BSONObj> statusWithInfo = _collection->getIndexCatalog()->prepareSpecForCreate(_txn, info); Status status = statusWithInfo.getStatus(); if (!status.isOK()) return status; info = statusWithInfo.getValue(); IndexToBuild index; index.block.reset(new IndexCatalog::IndexBuildBlock(_txn, _collection, info)); status = index.block->init(); if (!status.isOK()) return status; index.real = index.block->getEntry()->accessMethod(); status = index.real->initializeAsEmpty(_txn); if (!status.isOK()) return status; if (!_buildInBackground) { // Bulk build process requires foreground building as it assumes nothing is changing // under it. index.bulk = index.real->initiateBulk(); } const IndexDescriptor* descriptor = index.block->getEntry()->descriptor(); index.options.logIfError = false; // logging happens elsewhere if needed. index.options.dupsAllowed = !descriptor->unique() || _ignoreUnique || repl::getGlobalReplicationCoordinator()->shouldIgnoreUniqueIndex(descriptor); log() << "build index on: " << ns << " properties: " << descriptor->toString(); if (index.bulk) log() << "\t building index using bulk method"; index.filterExpression = index.block->getEntry()->getFilterExpression(); // TODO SERVER-14888 Suppress this in cases we don't want to audit. audit::logCreateIndex(_txn->getClient(), &info, descriptor->indexName(), ns); _indexes.push_back(std::move(index)); } if (_buildInBackground) _backgroundOperation.reset(new BackgroundOperation(ns)); wunit.commit(); return Status::OK(); } Status MultiIndexBlock::insertAllDocumentsInCollection(std::set<RecordId>* dupsOut) { const char* curopMessage = _buildInBackground ? "Index Build (background)" : "Index Build"; const auto numRecords = _collection->numRecords(_txn); stdx::unique_lock<Client> lk(*_txn->getClient()); ProgressMeterHolder progress(*_txn->setMessage_inlock(curopMessage, curopMessage, numRecords)); lk.unlock(); Timer t; unsigned long long n = 0; unique_ptr<PlanExecutor> exec(InternalPlanner::collectionScan( _txn, _collection->ns().ns(), _collection, PlanExecutor::YIELD_MANUAL)); if (_buildInBackground) { invariant(_allowInterruption); exec->setYieldPolicy(PlanExecutor::YIELD_AUTO); } else { exec->setYieldPolicy(PlanExecutor::WRITE_CONFLICT_RETRY_ONLY); } Snapshotted<BSONObj> objToIndex; RecordId loc; PlanExecutor::ExecState state; int retries = 0; // non-zero when retrying our last document. while (retries || (PlanExecutor::ADVANCED == (state = exec->getNextSnapshotted(&objToIndex, &loc)))) { try { if (_allowInterruption) _txn->checkForInterrupt(); // Make sure we are working with the latest version of the document. if (objToIndex.snapshotId() != _txn->recoveryUnit()->getSnapshotId() && !_collection->findDoc(_txn, loc, &objToIndex)) { // doc was deleted so don't index it. retries = 0; continue; } // Done before insert so we can retry document if it WCEs. progress->setTotalWhileRunning(_collection->numRecords(_txn)); WriteUnitOfWork wunit(_txn); Status ret = insert(objToIndex.value(), loc); if (_buildInBackground) exec->saveState(); if (ret.isOK()) { wunit.commit(); } else if (dupsOut && ret.code() == ErrorCodes::DuplicateKey) { // If dupsOut is non-null, we should only fail the specific insert that // led to a DuplicateKey rather than the whole index build. dupsOut->insert(loc); } else { // Fail the index build hard. return ret; } if (_buildInBackground) exec->restoreState(); // Handles any WCEs internally. // Go to the next document progress->hit(); n++; retries = 0; } catch (const WriteConflictException& wce) { CurOp::get(_txn)->debug().writeConflicts++; retries++; // logAndBackoff expects this to be 1 on first call. wce.logAndBackoff(retries, "index creation", _collection->ns().ns()); // Can't use WRITE_CONFLICT_RETRY_LOOP macros since we need to save/restore exec // around call to abandonSnapshot. exec->saveState(); _txn->recoveryUnit()->abandonSnapshot(); exec->restoreState(); // Handles any WCEs internally. } } uassert(28550, "Unable to complete index build due to collection scan failure: " + WorkingSetCommon::toStatusString(objToIndex.value()), state == PlanExecutor::IS_EOF); progress->finished(); Status ret = doneInserting(dupsOut); if (!ret.isOK()) return ret; log() << "build index done. scanned " << n << " total records. " << t.seconds() << " secs" << endl; return Status::OK(); } Status MultiIndexBlock::insert(const BSONObj& doc, const RecordId& loc) { for (size_t i = 0; i < _indexes.size(); i++) { if (_indexes[i].filterExpression && !_indexes[i].filterExpression->matchesBSON(doc)) { continue; } int64_t unused; Status idxStatus(ErrorCodes::InternalError, ""); if (_indexes[i].bulk) { idxStatus = _indexes[i].bulk->insert(_txn, doc, loc, _indexes[i].options, &unused); } else { idxStatus = _indexes[i].real->insert(_txn, doc, loc, _indexes[i].options, &unused); } if (!idxStatus.isOK()) return idxStatus; } return Status::OK(); } Status MultiIndexBlock::doneInserting(std::set<RecordId>* dupsOut) { for (size_t i = 0; i < _indexes.size(); i++) { if (_indexes[i].bulk == NULL) continue; LOG(1) << "\t bulk commit starting for index: " << _indexes[i].block->getEntry()->descriptor()->indexName(); Status status = _indexes[i].real->commitBulk(_txn, std::move(_indexes[i].bulk), _allowInterruption, _indexes[i].options.dupsAllowed, dupsOut); if (!status.isOK()) { return status; } } return Status::OK(); } void MultiIndexBlock::abortWithoutCleanup() { _indexes.clear(); _needToCleanup = false; } void MultiIndexBlock::commit() { for (size_t i = 0; i < _indexes.size(); i++) { _indexes[i].block->success(); } _txn->recoveryUnit()->registerChange(new SetNeedToCleanupOnRollback(this)); _needToCleanup = false; } } // namespace mongo
#include "envoy/admin/v3alpha/config_dump.pb.h" #include "envoy/config/bootstrap/v3alpha/bootstrap.pb.h" #include "envoy/config/cluster/v3alpha/cluster.pb.h" #include "envoy/config/cluster/v3alpha/cluster.pb.validate.h" #include "envoy/config/core/v3alpha/base.pb.h" #include "test/common/upstream/test_cluster_manager.h" using testing::_; using testing::Eq; using testing::InSequence; using testing::Invoke; using testing::Mock; using testing::NiceMock; using testing::Return; using testing::ReturnNew; using testing::SaveArg; namespace Envoy { namespace Upstream { namespace { envoy::config::bootstrap::v3alpha::Bootstrap parseBootstrapFromV2Yaml(const std::string& yaml) { envoy::config::bootstrap::v3alpha::Bootstrap bootstrap; TestUtility::loadFromYaml(yaml, bootstrap); return bootstrap; } std::string clustersJson(const std::vector<std::string>& clusters) { return fmt::sprintf("\"clusters\": [%s]", absl::StrJoin(clusters, ",")); } class ClusterManagerImplTest : public testing::Test { public: ClusterManagerImplTest() : api_(Api::createApiForTest()), http_context_(factory_.stats_.symbolTable()) {} void create(const envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) { cluster_manager_ = std::make_unique<TestClusterManagerImpl>( bootstrap, factory_, factory_.stats_, factory_.tls_, factory_.runtime_, factory_.random_, factory_.local_info_, log_manager_, factory_.dispatcher_, admin_, validation_context_, *api_, http_context_); } void createWithLocalClusterUpdate(const bool enable_merge_window = true) { std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: STATIC lb_policy: ROUND_ROBIN hosts: - socket_address: address: "127.0.0.1" port_value: 11001 - socket_address: address: "127.0.0.1" port_value: 11002 )EOF"; const std::string merge_window_enabled = R"EOF( common_lb_config: update_merge_window: 3s )EOF"; const std::string merge_window_disabled = R"EOF( common_lb_config: update_merge_window: 0s )EOF"; yaml += enable_merge_window ? merge_window_enabled : merge_window_disabled; const auto& bootstrap = parseBootstrapFromV2Yaml(yaml); cluster_manager_ = std::make_unique<MockedUpdatedClusterManagerImpl>( bootstrap, factory_, factory_.stats_, factory_.tls_, factory_.runtime_, factory_.random_, factory_.local_info_, log_manager_, factory_.dispatcher_, admin_, validation_context_, *api_, local_cluster_update_, local_hosts_removed_, http_context_); } void checkStats(uint64_t added, uint64_t modified, uint64_t removed, uint64_t active, uint64_t warming) { EXPECT_EQ(added, factory_.stats_.counter("cluster_manager.cluster_added").value()); EXPECT_EQ(modified, factory_.stats_.counter("cluster_manager.cluster_modified").value()); EXPECT_EQ(removed, factory_.stats_.counter("cluster_manager.cluster_removed").value()); EXPECT_EQ(active, factory_.stats_ .gauge("cluster_manager.active_clusters", Stats::Gauge::ImportMode::NeverImport) .value()); EXPECT_EQ(warming, factory_.stats_ .gauge("cluster_manager.warming_clusters", Stats::Gauge::ImportMode::NeverImport) .value()); } void checkConfigDump(const std::string& expected_dump_yaml) { auto message_ptr = admin_.config_tracker_.config_tracker_callbacks_["clusters"](); const auto& clusters_config_dump = dynamic_cast<const envoy::admin::v3alpha::ClustersConfigDump&>(*message_ptr); envoy::admin::v3alpha::ClustersConfigDump expected_clusters_config_dump; TestUtility::loadFromYaml(expected_dump_yaml, expected_clusters_config_dump); EXPECT_EQ(expected_clusters_config_dump.DebugString(), clusters_config_dump.DebugString()); } envoy::config::core::v3alpha::Metadata buildMetadata(const std::string& version) const { envoy::config::core::v3alpha::Metadata metadata; if (!version.empty()) { Envoy::Config::Metadata::mutableMetadataValue( metadata, Config::MetadataFilters::get().ENVOY_LB, "version") .set_string_value(version); } return metadata; } Event::SimulatedTimeSystem time_system_; Api::ApiPtr api_; NiceMock<TestClusterManagerFactory> factory_; NiceMock<ProtobufMessage::MockValidationContext> validation_context_; std::unique_ptr<TestClusterManagerImpl> cluster_manager_; AccessLog::MockAccessLogManager log_manager_; NiceMock<Server::MockAdmin> admin_; MockLocalClusterUpdate local_cluster_update_; MockLocalHostsRemoved local_hosts_removed_; Http::ContextImpl http_context_; }; envoy::config::bootstrap::v3alpha::Bootstrap defaultConfig() { const std::string yaml = R"EOF( static_resources: clusters: [] )EOF"; return parseBootstrapFromV2Yaml(yaml); } TEST_F(ClusterManagerImplTest, MultipleProtocolClusterFail) { const std::string yaml = R"EOF( static_resources: clusters: - name: http12_cluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN http2_protocol_options: {} http_protocol_options: {} )EOF"; EXPECT_THROW_WITH_MESSAGE( create(parseBootstrapFromV2Yaml(yaml)), EnvoyException, "cluster: Both HTTP1 and HTTP2 options may only be configured with non-default " "'protocol_selection' values"); } TEST_F(ClusterManagerImplTest, MultipleHealthCheckFail) { const std::string yaml = R"EOF( static_resources: clusters: - name: service_google connect_timeout: 0.25s health_checks: - timeout: 1s interval: 1s http_health_check: path: "/blah" - timeout: 1s interval: 1s http_health_check: path: "/" )EOF"; EXPECT_THROW_WITH_MESSAGE(create(parseBootstrapFromV2Yaml(yaml)), EnvoyException, "Multiple health checks not supported"); } TEST_F(ClusterManagerImplTest, MultipleProtocolCluster) { time_system_.setSystemTime(std::chrono::milliseconds(1234567891234)); const std::string yaml = R"EOF( static_resources: clusters: - name: http12_cluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN http2_protocol_options: {} http_protocol_options: {} protocol_selection: USE_DOWNSTREAM_PROTOCOL )EOF"; create(parseBootstrapFromV2Yaml(yaml)); checkConfigDump(R"EOF( static_clusters: - cluster: name: http12_cluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN http2_protocol_options: {} http_protocol_options: {} protocol_selection: USE_DOWNSTREAM_PROTOCOL last_updated: seconds: 1234567891 nanos: 234000000 dynamic_active_clusters: dynamic_warming_clusters: )EOF"); } TEST_F(ClusterManagerImplTest, OutlierEventLog) { const std::string json = R"EOF( { "cluster_manager": { "outlier_detection": { "event_log_path": "foo" } }, "static_resources": { "clusters": [] } } )EOF"; EXPECT_CALL(log_manager_, createAccessLog("foo")); create(parseBootstrapFromV2Json(json)); } TEST_F(ClusterManagerImplTest, NoSdsConfig) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: eds lb_policy: round_robin )EOF"; EXPECT_THROW_WITH_MESSAGE(create(parseBootstrapFromV2Yaml(yaml)), EnvoyException, "cannot create an EDS cluster without an EDS config"); } TEST_F(ClusterManagerImplTest, UnknownClusterType) { const std::string json = R"EOF( { "static_resources": { "clusters": [ { "name": "cluster_1", "connect_timeout": "0.250s", "type": "foo", "lb_policy": "round_robin" }] } } )EOF"; EXPECT_THROW_WITH_REGEX(create(parseBootstrapFromV2Json(json)), EnvoyException, "invalid value \"foo\" for type TYPE_ENUM"); } TEST_F(ClusterManagerImplTest, LocalClusterNotDefined) { const std::string json = fmt::sprintf( R"EOF( { "cluster_manager": { "local_cluster_name": "new_cluster", }, "static_resources": { %s } } )EOF", clustersJson({defaultStaticClusterJson("cluster_1"), defaultStaticClusterJson("cluster_2")})); EXPECT_THROW(create(parseBootstrapFromV2Json(json)), EnvoyException); } TEST_F(ClusterManagerImplTest, BadClusterManagerConfig) { const std::string json = R"EOF( { "cluster_manager": { "outlier_detection": { "event_log_path": "foo" }, "fake_property" : "fake_property" }, "static_resources": { "clusters": [] } } )EOF"; EXPECT_THROW_WITH_REGEX(create(parseBootstrapFromV2Json(json)), EnvoyException, "fake_property: Cannot find field"); } TEST_F(ClusterManagerImplTest, LocalClusterDefined) { const std::string json = fmt::sprintf( R"EOF( { "cluster_manager": { "local_cluster_name": "new_cluster", }, "static_resources": { %s } } )EOF", clustersJson({defaultStaticClusterJson("cluster_1"), defaultStaticClusterJson("cluster_2"), defaultStaticClusterJson("new_cluster")})); create(parseBootstrapFromV2Json(json)); checkStats(3 /*added*/, 0 /*modified*/, 0 /*removed*/, 3 /*active*/, 0 /*warming*/); factory_.tls_.shutdownThread(); } TEST_F(ClusterManagerImplTest, DuplicateCluster) { const std::string json = fmt::sprintf( "{\"static_resources\":{%s}}", clustersJson({defaultStaticClusterJson("cluster_1"), defaultStaticClusterJson("cluster_1")})); const auto config = parseBootstrapFromV2Json(json); EXPECT_THROW(create(config), EnvoyException); } TEST_F(ClusterManagerImplTest, ValidClusterName) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster:name connect_timeout: 0.250s type: static lb_policy: round_robin load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 )EOF"; create(parseBootstrapFromV2Yaml(yaml)); cluster_manager_->clusters() .find("cluster:name") ->second.get() .info() ->statsScope() .counter("foo") .inc(); EXPECT_EQ(1UL, factory_.stats_.counter("cluster.cluster_name.foo").value()); } TEST_F(ClusterManagerImplTest, OriginalDstLbRestriction) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: original_dst lb_policy: round_robin )EOF"; EXPECT_THROW_WITH_MESSAGE( create(parseBootstrapFromV2Yaml(yaml)), EnvoyException, "cluster: LB policy ROUND_ROBIN is not valid for Cluster type ORIGINAL_DST. Only " "'CLUSTER_PROVIDED' or 'ORIGINAL_DST_LB' is allowed with cluster type 'ORIGINAL_DST'"); } TEST_F(ClusterManagerImplTest, OriginalDstLbRestriction2) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: static lb_policy: original_dst_lb load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 )EOF"; EXPECT_THROW_WITH_MESSAGE(create(parseBootstrapFromV2Yaml(yaml)), EnvoyException, "cluster: LB policy hidden_envoy_deprecated_ORIGINAL_DST_LB is not " "valid for Cluster type STATIC. " "'ORIGINAL_DST_LB' is allowed only with cluster type 'ORIGINAL_DST'"); } class ClusterManagerSubsetInitializationTest : public ClusterManagerImplTest, public testing::WithParamInterface<envoy::config::cluster::v3alpha::Cluster::LbPolicy> { public: ClusterManagerSubsetInitializationTest() = default; static std::vector<envoy::config::cluster::v3alpha::Cluster::LbPolicy> lbPolicies() { int first = static_cast<int>(envoy::config::cluster::v3alpha::Cluster::LbPolicy_MIN); int last = static_cast<int>(envoy::config::cluster::v3alpha::Cluster::LbPolicy_MAX); ASSERT(first < last); std::vector<envoy::config::cluster::v3alpha::Cluster::LbPolicy> policies; for (int i = first; i <= last; i++) { if (envoy::config::cluster::v3alpha::Cluster::LbPolicy_IsValid(i)) { auto policy = static_cast<envoy::config::cluster::v3alpha::Cluster::LbPolicy>(i); if (policy != envoy::config::cluster::v3alpha::Cluster::LOAD_BALANCING_POLICY_CONFIG) { policies.push_back(policy); } } } return policies; } static std::string paramName(const testing::TestParamInfo<ParamType>& info) { const std::string& name = envoy::config::cluster::v3alpha::Cluster::LbPolicy_Name(info.param); return absl::StrReplaceAll(name, {{"_", ""}}); } }; // Test initialization of subset load balancer with every possible load balancer policy. TEST_P(ClusterManagerSubsetInitializationTest, SubsetLoadBalancerInitialization) { const std::string yamlPattern = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s {} lb_policy: "{}" lb_subset_config: fallback_policy: ANY_ENDPOINT subset_selectors: - keys: [ "x" ] load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 8000 - endpoint: address: socket_address: address: 127.0.0.1 port_value: 8001 )EOF"; const std::string& policy_name = envoy::config::cluster::v3alpha::Cluster::LbPolicy_Name(GetParam()); std::string cluster_type = "type: STATIC"; if (GetParam() == envoy::config::cluster::v3alpha::Cluster::hidden_envoy_deprecated_ORIGINAL_DST_LB) { cluster_type = "type: ORIGINAL_DST"; } else if (GetParam() == envoy::config::cluster::v3alpha::Cluster::CLUSTER_PROVIDED) { // This custom cluster type is registered by linking test/integration/custom/static_cluster.cc. cluster_type = "cluster_type: { name: envoy.clusters.custom_static_with_lb }"; } const std::string yaml = fmt::format(yamlPattern, cluster_type, policy_name); if (GetParam() == envoy::config::cluster::v3alpha::Cluster::hidden_envoy_deprecated_ORIGINAL_DST_LB || GetParam() == envoy::config::cluster::v3alpha::Cluster::CLUSTER_PROVIDED) { EXPECT_THROW_WITH_MESSAGE( create(parseBootstrapFromV2Yaml(yaml)), EnvoyException, fmt::format("cluster: LB policy {} cannot be combined with lb_subset_config", envoy::config::cluster::v3alpha::Cluster::LbPolicy_Name(GetParam()))); } else { create(parseBootstrapFromV2Yaml(yaml)); checkStats(1 /*added*/, 0 /*modified*/, 0 /*removed*/, 1 /*active*/, 0 /*warming*/); Upstream::ThreadLocalCluster* tlc = cluster_manager_->get("cluster_1"); EXPECT_NE(nullptr, tlc); if (tlc) { Upstream::LoadBalancer& lb = tlc->loadBalancer(); EXPECT_NE(nullptr, dynamic_cast<Upstream::SubsetLoadBalancer*>(&lb)); } factory_.tls_.shutdownThread(); } } INSTANTIATE_TEST_SUITE_P(ClusterManagerSubsetInitializationTest, ClusterManagerSubsetInitializationTest, testing::ValuesIn(ClusterManagerSubsetInitializationTest::lbPolicies()), ClusterManagerSubsetInitializationTest::paramName); TEST_F(ClusterManagerImplTest, SubsetLoadBalancerOriginalDstRestriction) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: original_dst lb_policy: original_dst_lb lb_subset_config: fallback_policy: ANY_ENDPOINT subset_selectors: - keys: [ "x" ] )EOF"; EXPECT_THROW_WITH_MESSAGE(create(parseBootstrapFromV2Yaml(yaml)), EnvoyException, "cluster: LB policy hidden_envoy_deprecated_ORIGINAL_DST_LB cannot be " "combined with lb_subset_config"); } TEST_F(ClusterManagerImplTest, SubsetLoadBalancerClusterProvidedLbRestriction) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: static lb_policy: cluster_provided lb_subset_config: fallback_policy: ANY_ENDPOINT subset_selectors: - keys: [ "x" ] )EOF"; EXPECT_THROW_WITH_MESSAGE( create(parseBootstrapFromV2Yaml(yaml)), EnvoyException, "cluster: LB policy CLUSTER_PROVIDED cannot be combined with lb_subset_config"); } TEST_F(ClusterManagerImplTest, SubsetLoadBalancerLocalityAware) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: STATIC lb_policy: ROUND_ROBIN lb_subset_config: fallback_policy: ANY_ENDPOINT subset_selectors: - keys: [ "x" ] locality_weight_aware: true load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 8000 - endpoint: address: socket_address: address: 127.0.0.1 port_value: 8001 )EOF"; EXPECT_THROW_WITH_MESSAGE(create(parseBootstrapFromV2Yaml(yaml)), EnvoyException, "Locality weight aware subset LB requires that a " "locality_weighted_lb_config be set in cluster_1"); } TEST_F(ClusterManagerImplTest, RingHashLoadBalancerInitialization) { const std::string yaml = R"EOF( static_resources: clusters: - name: redis_cluster lb_policy: RING_HASH ring_hash_lb_config: minimum_ring_size: 125 connect_timeout: 0.250s type: STATIC load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 8000 - endpoint: address: socket_address: address: 127.0.0.1 port_value: 8001 )EOF"; create(parseBootstrapFromV2Yaml(yaml)); } TEST_F(ClusterManagerImplTest, RingHashLoadBalancerV2Initialization) { const std::string yaml = R"EOF( static_resources: clusters: - name: redis_cluster connect_timeout: 0.250s lb_policy: RING_HASH load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 8000 - endpoint: address: socket_address: address: 127.0.0.1 port_value: 8001 dns_lookup_family: V4_ONLY ring_hash_lb_config: minimum_ring_size: 125 )EOF"; create(parseBootstrapFromV2Yaml(yaml)); } // Verify EDS clusters have EDS config. TEST_F(ClusterManagerImplTest, EdsClustersRequireEdsConfig) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_0 type: EDS )EOF"; EXPECT_THROW_WITH_MESSAGE(create(parseBootstrapFromV2Yaml(yaml)), EnvoyException, "cannot create an EDS cluster without an EDS config"); } // Verify that specifying a cluster provided LB, but the cluster doesn't provide one is an error. TEST_F(ClusterManagerImplTest, ClusterProvidedLbNoLb) { const std::string json = fmt::sprintf("{\"static_resources\":{%s}}", clustersJson({defaultStaticClusterJson("cluster_0")})); std::shared_ptr<MockClusterMockPrioritySet> cluster1(new NiceMock<MockClusterMockPrioritySet>()); cluster1->info_->name_ = "cluster_0"; cluster1->info_->lb_type_ = LoadBalancerType::ClusterProvided; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); EXPECT_THROW_WITH_MESSAGE(create(parseBootstrapFromV2Json(json)), EnvoyException, "cluster manager: cluster provided LB specified but cluster " "'cluster_0' did not provide one. Check cluster documentation."); } // Verify that not specifying a cluster provided LB, but the cluster does provide one is an error. TEST_F(ClusterManagerImplTest, ClusterProvidedLbNotConfigured) { const std::string json = fmt::sprintf("{\"static_resources\":{%s}}", clustersJson({defaultStaticClusterJson("cluster_0")})); std::shared_ptr<MockClusterMockPrioritySet> cluster1(new NiceMock<MockClusterMockPrioritySet>()); cluster1->info_->name_ = "cluster_0"; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, new MockThreadAwareLoadBalancer()))); EXPECT_THROW_WITH_MESSAGE(create(parseBootstrapFromV2Json(json)), EnvoyException, "cluster manager: cluster provided LB not specified but cluster " "'cluster_0' provided one. Check cluster documentation."); } class ClusterManagerImplThreadAwareLbTest : public ClusterManagerImplTest { public: void doTest(LoadBalancerType lb_type) { const std::string json = fmt::sprintf("{\"static_resources\":{%s}}", clustersJson({defaultStaticClusterJson("cluster_0")})); std::shared_ptr<MockClusterMockPrioritySet> cluster1( new NiceMock<MockClusterMockPrioritySet>()); cluster1->info_->name_ = "cluster_0"; cluster1->info_->lb_type_ = lb_type; InSequence s; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); ON_CALL(*cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); create(parseBootstrapFromV2Json(json)); EXPECT_EQ(nullptr, cluster_manager_->get("cluster_0")->loadBalancer().chooseHost(nullptr)); cluster1->prioritySet().getMockHostSet(0)->hosts_ = { makeTestHost(cluster1->info_, "tcp://127.0.0.1:80")}; cluster1->prioritySet().getMockHostSet(0)->runCallbacks( cluster1->prioritySet().getMockHostSet(0)->hosts_, {}); cluster1->initialize_callback_(); EXPECT_EQ(cluster1->prioritySet().getMockHostSet(0)->hosts_[0], cluster_manager_->get("cluster_0")->loadBalancer().chooseHost(nullptr)); } }; // Test that the cluster manager correctly re-creates the worker local LB when there is a host // set change. TEST_F(ClusterManagerImplThreadAwareLbTest, RingHashLoadBalancerThreadAwareUpdate) { doTest(LoadBalancerType::RingHash); } // Test that the cluster manager correctly re-creates the worker local LB when there is a host // set change. TEST_F(ClusterManagerImplThreadAwareLbTest, MaglevLoadBalancerThreadAwareUpdate) { doTest(LoadBalancerType::Maglev); } TEST_F(ClusterManagerImplTest, TcpHealthChecker) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: STATIC lb_policy: ROUND_ROBIN load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 health_checks: - timeout: 1s interval: 1s unhealthy_threshold: 2 healthy_threshold: 2 tcp_health_check: send: text: '01' receive: - text: '02' )EOF"; Network::MockClientConnection* connection = new NiceMock<Network::MockClientConnection>(); EXPECT_CALL(factory_.dispatcher_, createClientConnection_( PointeesEq(Network::Utility::resolveUrl("tcp://127.0.0.1:11001")), _, _, _)) .WillOnce(Return(connection)); create(parseBootstrapFromV2Yaml(yaml)); factory_.tls_.shutdownThread(); } TEST_F(ClusterManagerImplTest, HttpHealthChecker) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: STATIC lb_policy: ROUND_ROBIN load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 health_checks: - timeout: 1s interval: 1s unhealthy_threshold: 2 healthy_threshold: 2 http_health_check: path: "/healthcheck" )EOF"; Network::MockClientConnection* connection = new NiceMock<Network::MockClientConnection>(); EXPECT_CALL(factory_.dispatcher_, createClientConnection_( PointeesEq(Network::Utility::resolveUrl("tcp://127.0.0.1:11001")), _, _, _)) .WillOnce(Return(connection)); create(parseBootstrapFromV2Yaml(yaml)); factory_.tls_.shutdownThread(); } TEST_F(ClusterManagerImplTest, UnknownCluster) { const std::string json = fmt::sprintf("{\"static_resources\":{%s}}", clustersJson({defaultStaticClusterJson("cluster_1")})); create(parseBootstrapFromV2Json(json)); EXPECT_EQ(nullptr, cluster_manager_->get("hello")); EXPECT_EQ(nullptr, cluster_manager_->httpConnPoolForCluster("hello", ResourcePriority::Default, Http::Protocol::Http2, nullptr)); EXPECT_EQ(nullptr, cluster_manager_->tcpConnPoolForCluster("hello", ResourcePriority::Default, nullptr)); EXPECT_THROW(cluster_manager_->tcpConnForCluster("hello", nullptr), EnvoyException); NiceMock<MockLoadBalancerContext> example_com_context; ON_CALL(example_com_context, upstreamTransportSocketOptions()) .WillByDefault(Return(std::make_shared<Network::TransportSocketOptionsImpl>("example.com"))); EXPECT_EQ(nullptr, cluster_manager_->tcpConnPoolForCluster("hello", ResourcePriority::Default, &example_com_context)); EXPECT_THROW(cluster_manager_->tcpConnForCluster("hello", &example_com_context), EnvoyException); EXPECT_THROW(cluster_manager_->httpAsyncClientForCluster("hello"), EnvoyException); factory_.tls_.shutdownThread(); } /** * Test that buffer limits are set on new TCP connections. */ TEST_F(ClusterManagerImplTest, VerifyBufferLimits) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: static lb_policy: round_robin per_connection_buffer_limit_bytes: 8192 load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 )EOF"; create(parseBootstrapFromV2Yaml(yaml)); Network::MockClientConnection* connection = new NiceMock<Network::MockClientConnection>(); EXPECT_CALL(*connection, setBufferLimits(8192)); EXPECT_CALL(factory_.tls_.dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce(Return(connection)); auto conn_data = cluster_manager_->tcpConnForCluster("cluster_1", nullptr); EXPECT_EQ(connection, conn_data.connection_.get()); factory_.tls_.shutdownThread(); } TEST_F(ClusterManagerImplTest, ShutdownOrder) { const std::string json = fmt::sprintf("{\"static_resources\":{%s}}", clustersJson({defaultStaticClusterJson("cluster_1")})); create(parseBootstrapFromV2Json(json)); Cluster& cluster = cluster_manager_->activeClusters().begin()->second; EXPECT_EQ("cluster_1", cluster.info()->name()); EXPECT_EQ(cluster.info(), cluster_manager_->get("cluster_1")->info()); EXPECT_EQ( 1UL, cluster_manager_->get("cluster_1")->prioritySet().hostSetsPerPriority()[0]->hosts().size()); EXPECT_EQ(cluster.prioritySet().hostSetsPerPriority()[0]->hosts()[0], cluster_manager_->get("cluster_1")->loadBalancer().chooseHost(nullptr)); // Local reference, primary reference, thread local reference, host reference, async client // reference. EXPECT_EQ(5U, cluster.info().use_count()); // Thread local reference should be gone. factory_.tls_.shutdownThread(); EXPECT_EQ(3U, cluster.info().use_count()); } TEST_F(ClusterManagerImplTest, InitializeOrder) { time_system_.setSystemTime(std::chrono::milliseconds(1234567891234)); const std::string json = fmt::sprintf( R"EOF( { "dynamic_resources": { "cds_config": { "api_config_source": { "api_type": "UNSUPPORTED_REST_LEGACY", "refresh_delay": "30s", "cluster_names": ["cds_cluster"] } } }, "static_resources": { %s } } )EOF", clustersJson({defaultStaticClusterJson("cds_cluster"), defaultStaticClusterJson("fake_cluster"), defaultStaticClusterJson("fake_cluster2")})); MockCdsApi* cds = new MockCdsApi(); std::shared_ptr<MockClusterMockPrioritySet> cds_cluster( new NiceMock<MockClusterMockPrioritySet>()); cds_cluster->info_->name_ = "cds_cluster"; std::shared_ptr<MockClusterMockPrioritySet> cluster1(new NiceMock<MockClusterMockPrioritySet>()); std::shared_ptr<MockClusterMockPrioritySet> cluster2(new NiceMock<MockClusterMockPrioritySet>()); cluster2->info_->name_ = "fake_cluster2"; cluster2->info_->lb_type_ = LoadBalancerType::RingHash; // This part tests static init. InSequence s; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cds_cluster, nullptr))); ON_CALL(*cds_cluster, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); ON_CALL(*cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster2, nullptr))); ON_CALL(*cluster2, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Secondary)); EXPECT_CALL(factory_, createCds_()).WillOnce(Return(cds)); EXPECT_CALL(*cds, setInitializedCb(_)); EXPECT_CALL(*cds_cluster, initialize(_)); EXPECT_CALL(*cluster1, initialize(_)); create(parseBootstrapFromV2Json(json)); ReadyWatcher initialized; cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); EXPECT_CALL(*cluster2, initialize(_)); cds_cluster->initialize_callback_(); cluster1->initialize_callback_(); EXPECT_CALL(*cds, initialize()); cluster2->initialize_callback_(); // This part tests CDS init. std::shared_ptr<MockClusterMockPrioritySet> cluster3(new NiceMock<MockClusterMockPrioritySet>()); cluster3->info_->name_ = "cluster3"; std::shared_ptr<MockClusterMockPrioritySet> cluster4(new NiceMock<MockClusterMockPrioritySet>()); cluster4->info_->name_ = "cluster4"; std::shared_ptr<MockClusterMockPrioritySet> cluster5(new NiceMock<MockClusterMockPrioritySet>()); cluster5->info_->name_ = "cluster5"; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster3, nullptr))); ON_CALL(*cluster3, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Secondary)); cluster_manager_->addOrUpdateCluster(defaultStaticCluster("cluster3"), "version1"); EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster4, nullptr))); ON_CALL(*cluster4, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); EXPECT_CALL(*cluster4, initialize(_)); cluster_manager_->addOrUpdateCluster(defaultStaticCluster("cluster4"), "version2"); EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster5, nullptr))); ON_CALL(*cluster5, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Secondary)); cluster_manager_->addOrUpdateCluster(defaultStaticCluster("cluster5"), "version3"); cds->initialized_callback_(); EXPECT_CALL(*cds, versionInfo()).WillOnce(Return("version3")); checkConfigDump(R"EOF( version_info: version3 static_clusters: - cluster: name: "cds_cluster" type: "STATIC" connect_timeout: 0.25s hosts: - socket_address: address: "127.0.0.1" port_value: 11001 last_updated: seconds: 1234567891 nanos: 234000000 - cluster: name: "fake_cluster" type: "STATIC" connect_timeout: 0.25s hosts: - socket_address: address: "127.0.0.1" port_value: 11001 last_updated: seconds: 1234567891 nanos: 234000000 - cluster: name: "fake_cluster2" type: "STATIC" connect_timeout: 0.25s hosts: - socket_address: address: "127.0.0.1" port_value: 11001 last_updated: seconds: 1234567891 nanos: 234000000 dynamic_active_clusters: - version_info: "version1" cluster: name: "cluster3" type: "STATIC" connect_timeout: 0.25s hosts: - socket_address: address: "127.0.0.1" port_value: 11001 last_updated: seconds: 1234567891 nanos: 234000000 - version_info: "version2" cluster: name: "cluster4" type: "STATIC" connect_timeout: 0.25s hosts: - socket_address: address: "127.0.0.1" port_value: 11001 last_updated: seconds: 1234567891 nanos: 234000000 - version_info: "version3" cluster: name: "cluster5" type: "STATIC" connect_timeout: 0.25s hosts: - socket_address: address: "127.0.0.1" port_value: 11001 last_updated: seconds: 1234567891 nanos: 234000000 dynamic_warming_clusters: )EOF"); EXPECT_CALL(*cluster3, initialize(_)); cluster4->initialize_callback_(); // Test cluster 5 getting removed before everything is initialized. cluster_manager_->removeCluster("cluster5"); EXPECT_CALL(initialized, ready()); cluster3->initialize_callback_(); factory_.tls_.shutdownThread(); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cds_cluster.get())); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster1.get())); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster2.get())); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster3.get())); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster4.get())); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster5.get())); } TEST_F(ClusterManagerImplTest, DynamicRemoveWithLocalCluster) { InSequence s; // Setup a cluster manager with a static local cluster. const std::string json = fmt::sprintf(R"EOF( { "cluster_manager": { "local_cluster_name": "foo" }, "static_resources": { %s } } )EOF", clustersJson({defaultStaticClusterJson("fake")})); std::shared_ptr<MockClusterMockPrioritySet> foo(new NiceMock<MockClusterMockPrioritySet>()); foo->info_->name_ = "foo"; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, false)) .WillOnce(Return(std::make_pair(foo, nullptr))); ON_CALL(*foo, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); EXPECT_CALL(*foo, initialize(_)); create(parseBootstrapFromV2Json(json)); foo->initialize_callback_(); // Now add a dynamic cluster. This cluster will have a member update callback from the local // cluster in its load balancer. std::shared_ptr<MockClusterMockPrioritySet> cluster1(new NiceMock<MockClusterMockPrioritySet>()); cluster1->info_->name_ = "cluster1"; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, true)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); ON_CALL(*cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); EXPECT_CALL(*cluster1, initialize(_)); cluster_manager_->addOrUpdateCluster(defaultStaticCluster("cluster1"), ""); // Add another update callback on foo so we make sure callbacks keep working. ReadyWatcher membership_updated; foo->prioritySet().addPriorityUpdateCb( [&membership_updated](uint32_t, const HostVector&, const HostVector&) -> void { membership_updated.ready(); }); // Remove the new cluster. cluster_manager_->removeCluster("cluster1"); // Fire a member callback on the local cluster, which should not call any update callbacks on // the deleted cluster. foo->prioritySet().getMockHostSet(0)->hosts_ = {makeTestHost(foo->info_, "tcp://127.0.0.1:80")}; EXPECT_CALL(membership_updated, ready()); foo->prioritySet().getMockHostSet(0)->runCallbacks(foo->prioritySet().getMockHostSet(0)->hosts_, {}); factory_.tls_.shutdownThread(); EXPECT_TRUE(Mock::VerifyAndClearExpectations(foo.get())); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster1.get())); } TEST_F(ClusterManagerImplTest, RemoveWarmingCluster) { time_system_.setSystemTime(std::chrono::milliseconds(1234567891234)); create(defaultConfig()); InSequence s; ReadyWatcher initialized; EXPECT_CALL(initialized, ready()); cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); std::shared_ptr<MockClusterMockPrioritySet> cluster1(new NiceMock<MockClusterMockPrioritySet>()); EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); EXPECT_CALL(*cluster1, initializePhase()).Times(0); EXPECT_CALL(*cluster1, initialize(_)); EXPECT_TRUE( cluster_manager_->addOrUpdateCluster(defaultStaticCluster("fake_cluster"), "version1")); checkStats(1 /*added*/, 0 /*modified*/, 0 /*removed*/, 0 /*active*/, 1 /*warming*/); EXPECT_EQ(nullptr, cluster_manager_->get("fake_cluster")); checkConfigDump(R"EOF( dynamic_warming_clusters: - version_info: "version1" cluster: name: "fake_cluster" type: STATIC connect_timeout: 0.25s hosts: - socket_address: address: "127.0.0.1" port_value: 11001 last_updated: seconds: 1234567891 nanos: 234000000 )EOF"); EXPECT_TRUE(cluster_manager_->removeCluster("fake_cluster")); checkStats(1 /*added*/, 0 /*modified*/, 1 /*removed*/, 0 /*active*/, 0 /*warming*/); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster1.get())); } TEST_F(ClusterManagerImplTest, ModifyWarmingCluster) { time_system_.setSystemTime(std::chrono::milliseconds(1234567891234)); create(defaultConfig()); InSequence s; ReadyWatcher initialized; EXPECT_CALL(initialized, ready()); cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); // Add a "fake_cluster" in warming state. std::shared_ptr<MockClusterMockPrioritySet> cluster1 = std::make_shared<NiceMock<MockClusterMockPrioritySet>>(); EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); EXPECT_CALL(*cluster1, initializePhase()).Times(0); EXPECT_CALL(*cluster1, initialize(_)); EXPECT_TRUE( cluster_manager_->addOrUpdateCluster(defaultStaticCluster("fake_cluster"), "version1")); checkStats(1 /*added*/, 0 /*modified*/, 0 /*removed*/, 0 /*active*/, 1 /*warming*/); EXPECT_EQ(nullptr, cluster_manager_->get("fake_cluster")); checkConfigDump(R"EOF( dynamic_warming_clusters: - version_info: "version1" cluster: name: "fake_cluster" type: STATIC connect_timeout: 0.25s hosts: - socket_address: address: "127.0.0.1" port_value: 11001 last_updated: seconds: 1234567891 nanos: 234000000 )EOF"); // Update the warming cluster that was just added. std::shared_ptr<MockClusterMockPrioritySet> cluster2 = std::make_shared<NiceMock<MockClusterMockPrioritySet>>(); EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster2, nullptr))); EXPECT_CALL(*cluster2, initializePhase()).Times(0); EXPECT_CALL(*cluster2, initialize(_)); EXPECT_TRUE(cluster_manager_->addOrUpdateCluster( parseClusterFromV2Json(fmt::sprintf(kDefaultStaticClusterTmpl, "fake_cluster", R"EOF( "socket_address": { "address": "127.0.0.1", "port_value": 11002 })EOF")), "version2")); checkStats(1 /*added*/, 1 /*modified*/, 0 /*removed*/, 0 /*active*/, 1 /*warming*/); checkConfigDump(R"EOF( dynamic_warming_clusters: - version_info: "version2" cluster: name: "fake_cluster" type: STATIC connect_timeout: 0.25s hosts: - socket_address: address: "127.0.0.1" port_value: 11002 last_updated: seconds: 1234567891 nanos: 234000000 )EOF"); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster1.get())); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster2.get())); } // Verify that shutting down the cluster manager destroys warming clusters. TEST_F(ClusterManagerImplTest, ShutdownWithWarming) { create(defaultConfig()); InSequence s; ReadyWatcher initialized; EXPECT_CALL(initialized, ready()); cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); std::shared_ptr<MockClusterMockPrioritySet> cluster1(new NiceMock<MockClusterMockPrioritySet>()); EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); EXPECT_CALL(*cluster1, initializePhase()).Times(0); EXPECT_CALL(*cluster1, initialize(_)); EXPECT_TRUE( cluster_manager_->addOrUpdateCluster(defaultStaticCluster("fake_cluster"), "version1")); checkStats(1 /*added*/, 0 /*modified*/, 0 /*removed*/, 0 /*active*/, 1 /*warming*/); cluster_manager_->shutdown(); checkStats(1 /*added*/, 0 /*modified*/, 0 /*removed*/, 0 /*active*/, 0 /*warming*/); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster1.get())); } TEST_F(ClusterManagerImplTest, DynamicAddRemove) { create(defaultConfig()); InSequence s; ReadyWatcher initialized; EXPECT_CALL(initialized, ready()); cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); std::unique_ptr<MockClusterUpdateCallbacks> callbacks(new NiceMock<MockClusterUpdateCallbacks>()); ClusterUpdateCallbacksHandlePtr cb = cluster_manager_->addThreadLocalClusterUpdateCallbacks(*callbacks); std::shared_ptr<MockClusterMockPrioritySet> cluster1(new NiceMock<MockClusterMockPrioritySet>()); EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); EXPECT_CALL(*cluster1, initializePhase()).Times(0); EXPECT_CALL(*cluster1, initialize(_)); EXPECT_CALL(*callbacks, onClusterAddOrUpdate(_)).Times(1); EXPECT_TRUE(cluster_manager_->addOrUpdateCluster(defaultStaticCluster("fake_cluster"), "")); checkStats(1 /*added*/, 0 /*modified*/, 0 /*removed*/, 0 /*active*/, 1 /*warming*/); EXPECT_EQ(1, cluster_manager_->warmingClusterCount()); EXPECT_EQ(nullptr, cluster_manager_->get("fake_cluster")); cluster1->initialize_callback_(); EXPECT_EQ(cluster1->info_, cluster_manager_->get("fake_cluster")->info()); checkStats(1 /*added*/, 0 /*modified*/, 0 /*removed*/, 1 /*active*/, 0 /*warming*/); EXPECT_EQ(0, cluster_manager_->warmingClusterCount()); // Now try to update again but with the same hash. EXPECT_FALSE(cluster_manager_->addOrUpdateCluster(defaultStaticCluster("fake_cluster"), "")); // Now do it again with a different hash. auto update_cluster = defaultStaticCluster("fake_cluster"); update_cluster.mutable_per_connection_buffer_limit_bytes()->set_value(12345); std::shared_ptr<MockClusterMockPrioritySet> cluster2(new NiceMock<MockClusterMockPrioritySet>()); cluster2->prioritySet().getMockHostSet(0)->hosts_ = { makeTestHost(cluster2->info_, "tcp://127.0.0.1:80")}; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster2, nullptr))); EXPECT_CALL(*cluster2, initializePhase()).Times(0); EXPECT_CALL(*cluster2, initialize(_)) .WillOnce(Invoke([cluster1](std::function<void()> initialize_callback) { // Test inline init. initialize_callback(); })); EXPECT_CALL(*callbacks, onClusterAddOrUpdate(_)).Times(1); EXPECT_TRUE(cluster_manager_->addOrUpdateCluster(update_cluster, "")); EXPECT_EQ(cluster2->info_, cluster_manager_->get("fake_cluster")->info()); EXPECT_EQ(1UL, cluster_manager_->clusters().size()); Http::ConnectionPool::MockInstance* cp = new Http::ConnectionPool::MockInstance(); EXPECT_CALL(factory_, allocateConnPool_(_, _, _)).WillOnce(Return(cp)); EXPECT_EQ(cp, cluster_manager_->httpConnPoolForCluster("fake_cluster", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); Tcp::ConnectionPool::MockInstance* cp2 = new Tcp::ConnectionPool::MockInstance(); EXPECT_CALL(factory_, allocateTcpConnPool_(_)).WillOnce(Return(cp2)); EXPECT_EQ(cp2, cluster_manager_->tcpConnPoolForCluster("fake_cluster", ResourcePriority::Default, nullptr)); Network::MockClientConnection* connection = new Network::MockClientConnection(); ON_CALL(*cluster2->info_, features()) .WillByDefault(Return(ClusterInfo::Features::CLOSE_CONNECTIONS_ON_HOST_HEALTH_FAILURE)); EXPECT_CALL(factory_.tls_.dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce(Return(connection)); EXPECT_CALL(*connection, setBufferLimits(_)); EXPECT_CALL(*connection, addConnectionCallbacks(_)); auto conn_info = cluster_manager_->tcpConnForCluster("fake_cluster", nullptr); EXPECT_EQ(conn_info.connection_.get(), connection); // Now remove the cluster. This should drain the connection pools, but not affect // tcp connections. Http::ConnectionPool::Instance::DrainedCb drained_cb; Tcp::ConnectionPool::Instance::DrainedCb drained_cb2; EXPECT_CALL(*callbacks, onClusterRemoval(_)).Times(1); EXPECT_CALL(*cp, addDrainedCallback(_)).WillOnce(SaveArg<0>(&drained_cb)); EXPECT_CALL(*cp2, addDrainedCallback(_)).WillOnce(SaveArg<0>(&drained_cb2)); EXPECT_TRUE(cluster_manager_->removeCluster("fake_cluster")); EXPECT_EQ(nullptr, cluster_manager_->get("fake_cluster")); EXPECT_EQ(0UL, cluster_manager_->clusters().size()); // Close the TCP connection. Success is no ASSERT or crash due to referencing // the removed cluster. EXPECT_CALL(*connection, dispatcher()); connection->raiseEvent(Network::ConnectionEvent::LocalClose); // Remove an unknown cluster. EXPECT_FALSE(cluster_manager_->removeCluster("foo")); drained_cb(); drained_cb2(); checkStats(1 /*added*/, 1 /*modified*/, 1 /*removed*/, 0 /*active*/, 0 /*warming*/); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster1.get())); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster2.get())); EXPECT_TRUE(Mock::VerifyAndClearExpectations(callbacks.get())); } TEST_F(ClusterManagerImplTest, addOrUpdateClusterStaticExists) { const std::string json = fmt::sprintf("{\"static_resources\":{%s}}", clustersJson({defaultStaticClusterJson("fake_cluster")})); std::shared_ptr<MockClusterMockPrioritySet> cluster1(new NiceMock<MockClusterMockPrioritySet>()); InSequence s; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); ON_CALL(*cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); EXPECT_CALL(*cluster1, initialize(_)); create(parseBootstrapFromV2Json(json)); ReadyWatcher initialized; cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); EXPECT_CALL(initialized, ready()); cluster1->initialize_callback_(); EXPECT_FALSE(cluster_manager_->addOrUpdateCluster(defaultStaticCluster("fake_cluster"), "")); // Attempt to remove a static cluster. EXPECT_FALSE(cluster_manager_->removeCluster("fake_cluster")); factory_.tls_.shutdownThread(); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster1.get())); } // Verifies that we correctly propagate the host_set state to the TLS clusters. TEST_F(ClusterManagerImplTest, HostsPostedToTlsCluster) { const std::string json = fmt::sprintf("{\"static_resources\":{%s}}", clustersJson({defaultStaticClusterJson("fake_cluster")})); std::shared_ptr<MockClusterRealPrioritySet> cluster1(new NiceMock<MockClusterRealPrioritySet>()); InSequence s; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); ON_CALL(*cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); EXPECT_CALL(*cluster1, initialize(_)); create(parseBootstrapFromV2Json(json)); ReadyWatcher initialized; cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); EXPECT_CALL(initialized, ready()); cluster1->initialize_callback_(); // Set up the HostSet with 1 healthy, 1 degraded and 1 unhealthy. HostSharedPtr host1 = makeTestHost(cluster1->info_, "tcp://127.0.0.1:80"); host1->healthFlagSet(HostImpl::HealthFlag::DEGRADED_ACTIVE_HC); HostSharedPtr host2 = makeTestHost(cluster1->info_, "tcp://127.0.0.1:80"); host2->healthFlagSet(HostImpl::HealthFlag::FAILED_ACTIVE_HC); HostSharedPtr host3 = makeTestHost(cluster1->info_, "tcp://127.0.0.1:80"); HostVector hosts{host1, host2, host3}; auto hosts_ptr = std::make_shared<HostVector>(hosts); cluster1->priority_set_.updateHosts( 0, HostSetImpl::partitionHosts(hosts_ptr, HostsPerLocalityImpl::empty()), nullptr, hosts, {}, 100); auto* tls_cluster = cluster_manager_->get(cluster1->info_->name()); EXPECT_EQ(1, tls_cluster->prioritySet().hostSetsPerPriority().size()); EXPECT_EQ(1, tls_cluster->prioritySet().hostSetsPerPriority()[0]->degradedHosts().size()); EXPECT_EQ(host1, tls_cluster->prioritySet().hostSetsPerPriority()[0]->degradedHosts()[0]); EXPECT_EQ(1, tls_cluster->prioritySet().hostSetsPerPriority()[0]->healthyHosts().size()); EXPECT_EQ(host3, tls_cluster->prioritySet().hostSetsPerPriority()[0]->healthyHosts()[0]); EXPECT_EQ(3, tls_cluster->prioritySet().hostSetsPerPriority()[0]->hosts().size()); EXPECT_EQ(100, tls_cluster->prioritySet().hostSetsPerPriority()[0]->overprovisioningFactor()); factory_.tls_.shutdownThread(); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster1.get())); } // Test that we close all HTTP connection pool connections when there is a host health failure. TEST_F(ClusterManagerImplTest, CloseHttpConnectionsOnHealthFailure) { const std::string json = fmt::sprintf("{\"static_resources\":{%s}}", clustersJson({defaultStaticClusterJson("some_cluster")})); std::shared_ptr<MockClusterMockPrioritySet> cluster1(new NiceMock<MockClusterMockPrioritySet>()); cluster1->info_->name_ = "some_cluster"; HostSharedPtr test_host = makeTestHost(cluster1->info_, "tcp://127.0.0.1:80"); cluster1->prioritySet().getMockHostSet(0)->hosts_ = {test_host}; ON_CALL(*cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); MockHealthChecker health_checker; ON_CALL(*cluster1, healthChecker()).WillByDefault(Return(&health_checker)); Outlier::MockDetector outlier_detector; ON_CALL(*cluster1, outlierDetector()).WillByDefault(Return(&outlier_detector)); Http::ConnectionPool::MockInstance* cp1 = new Http::ConnectionPool::MockInstance(); Http::ConnectionPool::MockInstance* cp2 = new Http::ConnectionPool::MockInstance(); { InSequence s; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); EXPECT_CALL(health_checker, addHostCheckCompleteCb(_)); EXPECT_CALL(outlier_detector, addChangedStateCb(_)); EXPECT_CALL(*cluster1, initialize(_)) .WillOnce(Invoke([cluster1](std::function<void()> initialize_callback) { // Test inline init. initialize_callback(); })); create(parseBootstrapFromV2Json(json)); EXPECT_CALL(factory_, allocateConnPool_(_, _, _)).WillOnce(Return(cp1)); cluster_manager_->httpConnPoolForCluster("some_cluster", ResourcePriority::Default, Http::Protocol::Http11, nullptr); outlier_detector.runCallbacks(test_host); health_checker.runCallbacks(test_host, HealthTransition::Unchanged); EXPECT_CALL(*cp1, drainConnections()); test_host->healthFlagSet(Host::HealthFlag::FAILED_OUTLIER_CHECK); outlier_detector.runCallbacks(test_host); EXPECT_CALL(factory_, allocateConnPool_(_, _, _)).WillOnce(Return(cp2)); cluster_manager_->httpConnPoolForCluster("some_cluster", ResourcePriority::High, Http::Protocol::Http11, nullptr); } // Order of these calls is implementation dependent, so can't sequence them! EXPECT_CALL(*cp1, drainConnections()); EXPECT_CALL(*cp2, drainConnections()); test_host->healthFlagSet(Host::HealthFlag::FAILED_ACTIVE_HC); health_checker.runCallbacks(test_host, HealthTransition::Changed); test_host->healthFlagClear(Host::HealthFlag::FAILED_OUTLIER_CHECK); outlier_detector.runCallbacks(test_host); test_host->healthFlagClear(Host::HealthFlag::FAILED_ACTIVE_HC); health_checker.runCallbacks(test_host, HealthTransition::Changed); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster1.get())); } // Test that we close all TCP connection pool connections when there is a host health failure. TEST_F(ClusterManagerImplTest, CloseTcpConnectionPoolsOnHealthFailure) { const std::string json = fmt::sprintf("{\"static_resources\":{%s}}", clustersJson({defaultStaticClusterJson("some_cluster")})); std::shared_ptr<MockClusterMockPrioritySet> cluster1(new NiceMock<MockClusterMockPrioritySet>()); cluster1->info_->name_ = "some_cluster"; HostSharedPtr test_host = makeTestHost(cluster1->info_, "tcp://127.0.0.1:80"); cluster1->prioritySet().getMockHostSet(0)->hosts_ = {test_host}; ON_CALL(*cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); MockHealthChecker health_checker; ON_CALL(*cluster1, healthChecker()).WillByDefault(Return(&health_checker)); Outlier::MockDetector outlier_detector; ON_CALL(*cluster1, outlierDetector()).WillByDefault(Return(&outlier_detector)); Tcp::ConnectionPool::MockInstance* cp1 = new Tcp::ConnectionPool::MockInstance(); Tcp::ConnectionPool::MockInstance* cp2 = new Tcp::ConnectionPool::MockInstance(); { InSequence s; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); EXPECT_CALL(health_checker, addHostCheckCompleteCb(_)); EXPECT_CALL(outlier_detector, addChangedStateCb(_)); EXPECT_CALL(*cluster1, initialize(_)) .WillOnce(Invoke([cluster1](std::function<void()> initialize_callback) { // Test inline init. initialize_callback(); })); create(parseBootstrapFromV2Json(json)); EXPECT_CALL(factory_, allocateTcpConnPool_(_)).WillOnce(Return(cp1)); cluster_manager_->tcpConnPoolForCluster("some_cluster", ResourcePriority::Default, nullptr); outlier_detector.runCallbacks(test_host); health_checker.runCallbacks(test_host, HealthTransition::Unchanged); EXPECT_CALL(*cp1, drainConnections()); test_host->healthFlagSet(Host::HealthFlag::FAILED_OUTLIER_CHECK); outlier_detector.runCallbacks(test_host); EXPECT_CALL(factory_, allocateTcpConnPool_(_)).WillOnce(Return(cp2)); cluster_manager_->tcpConnPoolForCluster("some_cluster", ResourcePriority::High, nullptr); } // Order of these calls is implementation dependent, so can't sequence them! EXPECT_CALL(*cp1, drainConnections()); EXPECT_CALL(*cp2, drainConnections()); test_host->healthFlagSet(Host::HealthFlag::FAILED_ACTIVE_HC); health_checker.runCallbacks(test_host, HealthTransition::Changed); test_host->healthFlagClear(Host::HealthFlag::FAILED_OUTLIER_CHECK); outlier_detector.runCallbacks(test_host); test_host->healthFlagClear(Host::HealthFlag::FAILED_ACTIVE_HC); health_checker.runCallbacks(test_host, HealthTransition::Changed); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster1.get())); } // Test that we close all TCP connection pool connections when there is a host health failure, // when configured to do so. TEST_F(ClusterManagerImplTest, CloseTcpConnectionsOnHealthFailure) { const std::string yaml = R"EOF( static_resources: clusters: - name: some_cluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN close_connections_on_host_health_failure: true )EOF"; std::shared_ptr<MockClusterMockPrioritySet> cluster1(new NiceMock<MockClusterMockPrioritySet>()); EXPECT_CALL(*cluster1->info_, features()) .WillRepeatedly(Return(ClusterInfo::Features::CLOSE_CONNECTIONS_ON_HOST_HEALTH_FAILURE)); cluster1->info_->name_ = "some_cluster"; HostSharedPtr test_host = makeTestHost(cluster1->info_, "tcp://127.0.0.1:80"); cluster1->prioritySet().getMockHostSet(0)->hosts_ = {test_host}; ON_CALL(*cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); MockHealthChecker health_checker; ON_CALL(*cluster1, healthChecker()).WillByDefault(Return(&health_checker)); Outlier::MockDetector outlier_detector; ON_CALL(*cluster1, outlierDetector()).WillByDefault(Return(&outlier_detector)); Network::MockClientConnection* connection1 = new NiceMock<Network::MockClientConnection>(); Network::MockClientConnection* connection2 = new NiceMock<Network::MockClientConnection>(); Host::CreateConnectionData conn_info1, conn_info2; { InSequence s; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); EXPECT_CALL(health_checker, addHostCheckCompleteCb(_)); EXPECT_CALL(outlier_detector, addChangedStateCb(_)); EXPECT_CALL(*cluster1, initialize(_)) .WillOnce(Invoke([cluster1](std::function<void()> initialize_callback) { // Test inline init. initialize_callback(); })); create(parseBootstrapFromV2Yaml(yaml)); EXPECT_CALL(factory_.tls_.dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce(Return(connection1)); conn_info1 = cluster_manager_->tcpConnForCluster("some_cluster", nullptr); outlier_detector.runCallbacks(test_host); health_checker.runCallbacks(test_host, HealthTransition::Unchanged); EXPECT_CALL(*connection1, close(Network::ConnectionCloseType::NoFlush)); test_host->healthFlagSet(Host::HealthFlag::FAILED_OUTLIER_CHECK); outlier_detector.runCallbacks(test_host); connection1 = new NiceMock<Network::MockClientConnection>(); EXPECT_CALL(factory_.tls_.dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce(Return(connection1)); conn_info1 = cluster_manager_->tcpConnForCluster("some_cluster", nullptr); EXPECT_CALL(factory_.tls_.dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce(Return(connection2)); conn_info2 = cluster_manager_->tcpConnForCluster("some_cluster", nullptr); } // Order of these calls is implementation dependent, so can't sequence them! EXPECT_CALL(*connection1, close(Network::ConnectionCloseType::NoFlush)); EXPECT_CALL(*connection2, close(Network::ConnectionCloseType::NoFlush)); test_host->healthFlagSet(Host::HealthFlag::FAILED_ACTIVE_HC); health_checker.runCallbacks(test_host, HealthTransition::Changed); test_host->healthFlagClear(Host::HealthFlag::FAILED_OUTLIER_CHECK); outlier_detector.runCallbacks(test_host); test_host->healthFlagClear(Host::HealthFlag::FAILED_ACTIVE_HC); health_checker.runCallbacks(test_host, HealthTransition::Changed); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster1.get())); } // Test that we do not close TCP connection pool connections when there is a host health failure, // when not configured to do so. TEST_F(ClusterManagerImplTest, DoNotCloseTcpConnectionsOnHealthFailure) { const std::string yaml = R"EOF( static_resources: clusters: - name: some_cluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN close_connections_on_host_health_failure: false )EOF"; std::shared_ptr<MockClusterMockPrioritySet> cluster1(new NiceMock<MockClusterMockPrioritySet>()); EXPECT_CALL(*cluster1->info_, features()).WillRepeatedly(Return(0)); cluster1->info_->name_ = "some_cluster"; HostSharedPtr test_host = makeTestHost(cluster1->info_, "tcp://127.0.0.1:80"); cluster1->prioritySet().getMockHostSet(0)->hosts_ = {test_host}; ON_CALL(*cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); MockHealthChecker health_checker; ON_CALL(*cluster1, healthChecker()).WillByDefault(Return(&health_checker)); Outlier::MockDetector outlier_detector; ON_CALL(*cluster1, outlierDetector()).WillByDefault(Return(&outlier_detector)); Network::MockClientConnection* connection1 = new NiceMock<Network::MockClientConnection>(); Host::CreateConnectionData conn_info1; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, _)) .WillOnce(Return(std::make_pair(cluster1, nullptr))); EXPECT_CALL(health_checker, addHostCheckCompleteCb(_)); EXPECT_CALL(outlier_detector, addChangedStateCb(_)); EXPECT_CALL(*cluster1, initialize(_)) .WillOnce(Invoke([cluster1](std::function<void()> initialize_callback) { // Test inline init. initialize_callback(); })); create(parseBootstrapFromV2Yaml(yaml)); EXPECT_CALL(factory_.tls_.dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce(Return(connection1)); conn_info1 = cluster_manager_->tcpConnForCluster("some_cluster", nullptr); outlier_detector.runCallbacks(test_host); health_checker.runCallbacks(test_host, HealthTransition::Unchanged); EXPECT_CALL(*connection1, close(_)).Times(0); test_host->healthFlagSet(Host::HealthFlag::FAILED_OUTLIER_CHECK); outlier_detector.runCallbacks(test_host); EXPECT_TRUE(Mock::VerifyAndClearExpectations(cluster1.get())); } TEST_F(ClusterManagerImplTest, DynamicHostRemove) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: STRICT_DNS lb_policy: ROUND_ROBIN dns_resolvers: - socket_address: address: 1.2.3.4 port_value: 80 load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 )EOF"; std::shared_ptr<Network::MockDnsResolver> dns_resolver(new Network::MockDnsResolver()); EXPECT_CALL(factory_.dispatcher_, createDnsResolver(_, _)).WillOnce(Return(dns_resolver)); Network::DnsResolver::ResolveCb dns_callback; Event::MockTimer* dns_timer_ = new NiceMock<Event::MockTimer>(&factory_.dispatcher_); Network::MockActiveDnsQuery active_dns_query; EXPECT_CALL(*dns_resolver, resolve(_, _, _)) .WillRepeatedly(DoAll(SaveArg<2>(&dns_callback), Return(&active_dns_query))); create(parseBootstrapFromV2Yaml(yaml)); EXPECT_FALSE(cluster_manager_->get("cluster_1")->info()->addedViaApi()); // Test for no hosts returning the correct values before we have hosts. EXPECT_EQ(nullptr, cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); EXPECT_EQ(nullptr, cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); EXPECT_EQ(nullptr, cluster_manager_->tcpConnForCluster("cluster_1", nullptr).connection_); EXPECT_EQ(3UL, factory_.stats_.counter("cluster.cluster_1.upstream_cx_none_healthy").value()); // Set up for an initialize callback. ReadyWatcher initialized; cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); EXPECT_CALL(initialized, ready()); dns_callback(TestUtility::makeDnsResponse({"127.0.0.1", "127.0.0.2"})); // After we are initialized, we should immediately get called back if someone asks for an // initialize callback. EXPECT_CALL(initialized, ready()); cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); EXPECT_CALL(factory_, allocateConnPool_(_, _, _)) .Times(4) .WillRepeatedly(ReturnNew<Http::ConnectionPool::MockInstance>()); // This should provide us a CP for each of the above hosts. Http::ConnectionPool::MockInstance* cp1 = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); Http::ConnectionPool::MockInstance* cp2 = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); Http::ConnectionPool::MockInstance* cp1_high = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::High, Http::Protocol::Http11, nullptr)); Http::ConnectionPool::MockInstance* cp2_high = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::High, Http::Protocol::Http11, nullptr)); EXPECT_NE(cp1, cp2); EXPECT_NE(cp1_high, cp2_high); EXPECT_NE(cp1, cp1_high); Http::ConnectionPool::Instance::DrainedCb drained_cb; EXPECT_CALL(*cp1, addDrainedCallback(_)).WillOnce(SaveArg<0>(&drained_cb)); Http::ConnectionPool::Instance::DrainedCb drained_cb_high; EXPECT_CALL(*cp1_high, addDrainedCallback(_)).WillOnce(SaveArg<0>(&drained_cb_high)); EXPECT_CALL(factory_, allocateTcpConnPool_(_)) .Times(4) .WillRepeatedly(ReturnNew<Tcp::ConnectionPool::MockInstance>()); // This should provide us a CP for each of the above hosts. Tcp::ConnectionPool::MockInstance* tcp1 = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); Tcp::ConnectionPool::MockInstance* tcp2 = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); Tcp::ConnectionPool::MockInstance* tcp1_high = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::High, nullptr)); Tcp::ConnectionPool::MockInstance* tcp2_high = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::High, nullptr)); EXPECT_NE(tcp1, tcp2); EXPECT_NE(tcp1_high, tcp2_high); EXPECT_NE(tcp1, tcp1_high); Tcp::ConnectionPool::Instance::DrainedCb tcp_drained_cb; EXPECT_CALL(*tcp1, addDrainedCallback(_)).WillOnce(SaveArg<0>(&tcp_drained_cb)); Tcp::ConnectionPool::Instance::DrainedCb tcp_drained_cb_high; EXPECT_CALL(*tcp1_high, addDrainedCallback(_)).WillOnce(SaveArg<0>(&tcp_drained_cb_high)); // Remove the first host, this should lead to the first cp being drained. dns_timer_->invokeCallback(); dns_callback(TestUtility::makeDnsResponse({"127.0.0.2"})); drained_cb(); drained_cb = nullptr; tcp_drained_cb(); tcp_drained_cb = nullptr; EXPECT_CALL(factory_.tls_.dispatcher_, deferredDelete_(_)).Times(4); drained_cb_high(); drained_cb_high = nullptr; tcp_drained_cb_high(); tcp_drained_cb_high = nullptr; // Make sure we get back the same connection pool for the 2nd host as we did before the change. Http::ConnectionPool::MockInstance* cp3 = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); Http::ConnectionPool::MockInstance* cp3_high = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::High, Http::Protocol::Http11, nullptr)); EXPECT_EQ(cp2, cp3); EXPECT_EQ(cp2_high, cp3_high); Tcp::ConnectionPool::MockInstance* tcp3 = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); Tcp::ConnectionPool::MockInstance* tcp3_high = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::High, nullptr)); EXPECT_EQ(tcp2, tcp3); EXPECT_EQ(tcp2_high, tcp3_high); // Now add and remove a host that we never have a conn pool to. This should not lead to any // drain callbacks, etc. dns_timer_->invokeCallback(); dns_callback(TestUtility::makeDnsResponse({"127.0.0.2", "127.0.0.3"})); factory_.tls_.shutdownThread(); } TEST_F(ClusterManagerImplTest, DynamicHostRemoveWithTls) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: STRICT_DNS dns_resolvers: - socket_address: address: 1.2.3.4 port_value: 80 lb_policy: ROUND_ROBIN load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 )EOF"; std::shared_ptr<Network::MockDnsResolver> dns_resolver(new Network::MockDnsResolver()); EXPECT_CALL(factory_.dispatcher_, createDnsResolver(_, _)).WillOnce(Return(dns_resolver)); Network::DnsResolver::ResolveCb dns_callback; Event::MockTimer* dns_timer_ = new NiceMock<Event::MockTimer>(&factory_.dispatcher_); Network::MockActiveDnsQuery active_dns_query; EXPECT_CALL(*dns_resolver, resolve(_, _, _)) .WillRepeatedly(DoAll(SaveArg<2>(&dns_callback), Return(&active_dns_query))); create(parseBootstrapFromV2Yaml(yaml)); EXPECT_FALSE(cluster_manager_->get("cluster_1")->info()->addedViaApi()); NiceMock<MockLoadBalancerContext> example_com_context; ON_CALL(example_com_context, upstreamTransportSocketOptions()) .WillByDefault(Return(std::make_shared<Network::TransportSocketOptionsImpl>("example.com"))); NiceMock<MockLoadBalancerContext> ibm_com_context; ON_CALL(ibm_com_context, upstreamTransportSocketOptions()) .WillByDefault(Return(std::make_shared<Network::TransportSocketOptionsImpl>("ibm.com"))); // Test for no hosts returning the correct values before we have hosts. EXPECT_EQ(nullptr, cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); EXPECT_EQ(nullptr, cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); EXPECT_EQ(nullptr, cluster_manager_->tcpConnForCluster("cluster_1", nullptr).connection_); EXPECT_EQ(nullptr, cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, &example_com_context)); EXPECT_EQ(nullptr, cluster_manager_->tcpConnForCluster("cluster_1", &ibm_com_context).connection_); EXPECT_EQ(nullptr, cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, &ibm_com_context)); EXPECT_EQ(nullptr, cluster_manager_->tcpConnForCluster("cluster_1", &ibm_com_context).connection_); EXPECT_EQ(7UL, factory_.stats_.counter("cluster.cluster_1.upstream_cx_none_healthy").value()); // Set up for an initialize callback. ReadyWatcher initialized; cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); EXPECT_CALL(initialized, ready()); dns_callback(TestUtility::makeDnsResponse({"127.0.0.1", "127.0.0.2"})); // After we are initialized, we should immediately get called back if someone asks for an // initialize callback. EXPECT_CALL(initialized, ready()); cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); EXPECT_CALL(factory_, allocateConnPool_(_, _, _)) .Times(4) .WillRepeatedly(ReturnNew<Http::ConnectionPool::MockInstance>()); // This should provide us a CP for each of the above hosts. Http::ConnectionPool::MockInstance* cp1 = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); Http::ConnectionPool::MockInstance* cp2 = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); Http::ConnectionPool::MockInstance* cp1_high = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::High, Http::Protocol::Http11, nullptr)); Http::ConnectionPool::MockInstance* cp2_high = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::High, Http::Protocol::Http11, nullptr)); EXPECT_NE(cp1, cp2); EXPECT_NE(cp1_high, cp2_high); EXPECT_NE(cp1, cp1_high); Http::ConnectionPool::Instance::DrainedCb drained_cb; EXPECT_CALL(*cp1, addDrainedCallback(_)).WillOnce(SaveArg<0>(&drained_cb)); Http::ConnectionPool::Instance::DrainedCb drained_cb_high; EXPECT_CALL(*cp1_high, addDrainedCallback(_)).WillOnce(SaveArg<0>(&drained_cb_high)); EXPECT_CALL(factory_, allocateTcpConnPool_(_)) .Times(8) .WillRepeatedly(ReturnNew<Tcp::ConnectionPool::MockInstance>()); // This should provide us a CP for each of the above hosts, and for different SNIs Tcp::ConnectionPool::MockInstance* tcp1 = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); Tcp::ConnectionPool::MockInstance* tcp2 = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); Tcp::ConnectionPool::MockInstance* tcp1_high = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::High, nullptr)); Tcp::ConnectionPool::MockInstance* tcp2_high = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::High, nullptr)); Tcp::ConnectionPool::MockInstance* tcp1_example_com = dynamic_cast<Tcp::ConnectionPool::MockInstance*>(cluster_manager_->tcpConnPoolForCluster( "cluster_1", ResourcePriority::Default, &example_com_context)); Tcp::ConnectionPool::MockInstance* tcp2_example_com = dynamic_cast<Tcp::ConnectionPool::MockInstance*>(cluster_manager_->tcpConnPoolForCluster( "cluster_1", ResourcePriority::Default, &example_com_context)); Tcp::ConnectionPool::MockInstance* tcp1_ibm_com = dynamic_cast<Tcp::ConnectionPool::MockInstance*>(cluster_manager_->tcpConnPoolForCluster( "cluster_1", ResourcePriority::Default, &ibm_com_context)); Tcp::ConnectionPool::MockInstance* tcp2_ibm_com = dynamic_cast<Tcp::ConnectionPool::MockInstance*>(cluster_manager_->tcpConnPoolForCluster( "cluster_1", ResourcePriority::Default, &ibm_com_context)); EXPECT_NE(tcp1, tcp2); EXPECT_NE(tcp1_high, tcp2_high); EXPECT_NE(tcp1, tcp1_high); EXPECT_NE(tcp1_ibm_com, tcp2_ibm_com); EXPECT_NE(tcp1_ibm_com, tcp1); EXPECT_NE(tcp1_ibm_com, tcp2); EXPECT_NE(tcp1_ibm_com, tcp1_high); EXPECT_NE(tcp1_ibm_com, tcp2_high); EXPECT_NE(tcp1_ibm_com, tcp1_example_com); EXPECT_NE(tcp1_ibm_com, tcp2_example_com); EXPECT_NE(tcp2_ibm_com, tcp1); EXPECT_NE(tcp2_ibm_com, tcp2); EXPECT_NE(tcp2_ibm_com, tcp1_high); EXPECT_NE(tcp2_ibm_com, tcp2_high); EXPECT_NE(tcp2_ibm_com, tcp1_example_com); EXPECT_NE(tcp2_ibm_com, tcp2_example_com); EXPECT_NE(tcp1_example_com, tcp1); EXPECT_NE(tcp1_example_com, tcp2); EXPECT_NE(tcp1_example_com, tcp1_high); EXPECT_NE(tcp1_example_com, tcp2_high); EXPECT_NE(tcp1_example_com, tcp2_example_com); EXPECT_NE(tcp2_example_com, tcp1); EXPECT_NE(tcp2_example_com, tcp2); EXPECT_NE(tcp2_example_com, tcp1_high); EXPECT_NE(tcp2_example_com, tcp2_high); EXPECT_CALL(factory_.tls_.dispatcher_, deferredDelete_(_)).Times(6); Tcp::ConnectionPool::Instance::DrainedCb tcp_drained_cb; EXPECT_CALL(*tcp1, addDrainedCallback(_)).WillOnce(SaveArg<0>(&tcp_drained_cb)); Tcp::ConnectionPool::Instance::DrainedCb tcp_drained_cb_high; EXPECT_CALL(*tcp1_high, addDrainedCallback(_)).WillOnce(SaveArg<0>(&tcp_drained_cb_high)); Tcp::ConnectionPool::Instance::DrainedCb tcp_drained_cb_example_com; EXPECT_CALL(*tcp1_example_com, addDrainedCallback(_)) .WillOnce(SaveArg<0>(&tcp_drained_cb_example_com)); Tcp::ConnectionPool::Instance::DrainedCb tcp_drained_cb_ibm_com; EXPECT_CALL(*tcp1_ibm_com, addDrainedCallback(_)).WillOnce(SaveArg<0>(&tcp_drained_cb_ibm_com)); // Remove the first host, this should lead to the first cp being drained. dns_timer_->invokeCallback(); dns_callback(TestUtility::makeDnsResponse({"127.0.0.2"})); drained_cb(); drained_cb = nullptr; tcp_drained_cb(); tcp_drained_cb = nullptr; drained_cb_high(); drained_cb_high = nullptr; tcp_drained_cb_high(); tcp_drained_cb_high = nullptr; tcp_drained_cb_example_com(); tcp_drained_cb_example_com = nullptr; tcp_drained_cb_ibm_com(); tcp_drained_cb_ibm_com = nullptr; // Make sure we get back the same connection pool for the 2nd host as we did before the change. Http::ConnectionPool::MockInstance* cp3 = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); Http::ConnectionPool::MockInstance* cp3_high = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::High, Http::Protocol::Http11, nullptr)); EXPECT_EQ(cp2, cp3); EXPECT_EQ(cp2_high, cp3_high); Tcp::ConnectionPool::MockInstance* tcp3 = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); Tcp::ConnectionPool::MockInstance* tcp3_high = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::High, nullptr)); Tcp::ConnectionPool::MockInstance* tcp3_example_com = dynamic_cast<Tcp::ConnectionPool::MockInstance*>(cluster_manager_->tcpConnPoolForCluster( "cluster_1", ResourcePriority::Default, &example_com_context)); Tcp::ConnectionPool::MockInstance* tcp3_ibm_com = dynamic_cast<Tcp::ConnectionPool::MockInstance*>(cluster_manager_->tcpConnPoolForCluster( "cluster_1", ResourcePriority::Default, &ibm_com_context)); EXPECT_EQ(tcp2, tcp3); EXPECT_EQ(tcp2_high, tcp3_high); EXPECT_EQ(tcp2_example_com, tcp3_example_com); EXPECT_EQ(tcp2_ibm_com, tcp3_ibm_com); // Now add and remove a host that we never have a conn pool to. This should not lead to any // drain callbacks, etc. dns_timer_->invokeCallback(); dns_callback(TestUtility::makeDnsResponse({"127.0.0.2", "127.0.0.3"})); factory_.tls_.shutdownThread(); } // Test that default DNS resolver with TCP lookups is used, when there are no DNS custom resolvers // configured per cluster and `use_tcp_for_dns_lookups` is set in bootstrap config. TEST_F(ClusterManagerImplTest, UseTcpInDefaultDnsResolver) { const std::string yaml = R"EOF( use_tcp_for_dns_lookups: true static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: STRICT_DNS )EOF"; std::shared_ptr<Network::MockDnsResolver> dns_resolver(new Network::MockDnsResolver()); // As custom resolvers are not specified in config, this method should not be called, // resolver from context should be used instead. EXPECT_CALL(factory_.dispatcher_, createDnsResolver(_, _)).Times(0); Network::DnsResolver::ResolveCb dns_callback; Network::MockActiveDnsQuery active_dns_query; EXPECT_CALL(*dns_resolver, resolve(_, _, _)) .WillRepeatedly(DoAll(SaveArg<2>(&dns_callback), Return(&active_dns_query))); create(parseBootstrapFromV2Yaml(yaml)); factory_.tls_.shutdownThread(); } // Test that custom DNS resolver with UDP lookups is used, when custom resolver is configured // per cluster and `use_tcp_for_dns_lookups` is not specified. TEST_F(ClusterManagerImplTest, UseUdpWithCustomDnsResolver) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: STRICT_DNS dns_resolvers: - socket_address: address: 1.2.3.4 port_value: 80 )EOF"; std::shared_ptr<Network::MockDnsResolver> dns_resolver(new Network::MockDnsResolver()); // `false` here stands for using udp EXPECT_CALL(factory_.dispatcher_, createDnsResolver(_, false)).WillOnce(Return(dns_resolver)); Network::DnsResolver::ResolveCb dns_callback; Network::MockActiveDnsQuery active_dns_query; EXPECT_CALL(*dns_resolver, resolve(_, _, _)) .WillRepeatedly(DoAll(SaveArg<2>(&dns_callback), Return(&active_dns_query))); create(parseBootstrapFromV2Yaml(yaml)); factory_.tls_.shutdownThread(); } // Test that custom DNS resolver with TCP lookups is used, when custom resolver is configured // per cluster and `use_tcp_for_dns_lookups` is enabled for that cluster. TEST_F(ClusterManagerImplTest, UseTcpWithCustomDnsResolver) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 use_tcp_for_dns_lookups: true connect_timeout: 0.250s type: STRICT_DNS dns_resolvers: - socket_address: address: 1.2.3.4 port_value: 80 )EOF"; std::shared_ptr<Network::MockDnsResolver> dns_resolver(new Network::MockDnsResolver()); // `true` here stands for using tcp EXPECT_CALL(factory_.dispatcher_, createDnsResolver(_, true)).WillOnce(Return(dns_resolver)); Network::DnsResolver::ResolveCb dns_callback; Network::MockActiveDnsQuery active_dns_query; EXPECT_CALL(*dns_resolver, resolve(_, _, _)) .WillRepeatedly(DoAll(SaveArg<2>(&dns_callback), Return(&active_dns_query))); create(parseBootstrapFromV2Yaml(yaml)); factory_.tls_.shutdownThread(); } // This is a regression test for a use-after-free in // ClusterManagerImpl::ThreadLocalClusterManagerImpl::drainConnPools(), where a removal at one // priority from the ConnPoolsContainer would delete the ConnPoolsContainer mid-iteration over the // pool. TEST_F(ClusterManagerImplTest, DynamicHostRemoveDefaultPriority) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: STRICT_DNS dns_resolvers: - socket_address: address: 1.2.3.4 port_value: 80 lb_policy: ROUND_ROBIN load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 )EOF"; std::shared_ptr<Network::MockDnsResolver> dns_resolver(new Network::MockDnsResolver()); EXPECT_CALL(factory_.dispatcher_, createDnsResolver(_, _)).WillOnce(Return(dns_resolver)); Network::DnsResolver::ResolveCb dns_callback; Event::MockTimer* dns_timer_ = new NiceMock<Event::MockTimer>(&factory_.dispatcher_); Network::MockActiveDnsQuery active_dns_query; EXPECT_CALL(*dns_resolver, resolve(_, _, _)) .WillRepeatedly(DoAll(SaveArg<2>(&dns_callback), Return(&active_dns_query))); create(parseBootstrapFromV2Yaml(yaml)); EXPECT_FALSE(cluster_manager_->get("cluster_1")->info()->addedViaApi()); dns_callback(TestUtility::makeDnsResponse({"127.0.0.2"})); EXPECT_CALL(factory_, allocateConnPool_(_, _, _)) .WillOnce(ReturnNew<Http::ConnectionPool::MockInstance>()); EXPECT_CALL(factory_, allocateTcpConnPool_(_)) .WillOnce(ReturnNew<Tcp::ConnectionPool::MockInstance>()); Http::ConnectionPool::MockInstance* cp = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); Tcp::ConnectionPool::MockInstance* tcp = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); // Immediate drain, since this can happen with the HTTP codecs. EXPECT_CALL(*cp, addDrainedCallback(_)) .WillOnce(Invoke([](Http::ConnectionPool::Instance::DrainedCb cb) { cb(); })); EXPECT_CALL(*tcp, addDrainedCallback(_)) .WillOnce(Invoke([](Tcp::ConnectionPool::Instance::DrainedCb cb) { cb(); })); // Remove the first host, this should lead to the cp being drained, without // crash. dns_timer_->invokeCallback(); dns_callback(TestUtility::makeDnsResponse({})); factory_.tls_.shutdownThread(); } class MockConnPoolWithDestroy : public Http::ConnectionPool::MockInstance { public: ~MockConnPoolWithDestroy() override { onDestroy(); } MOCK_METHOD0(onDestroy, void()); }; class MockTcpConnPoolWithDestroy : public Tcp::ConnectionPool::MockInstance { public: ~MockTcpConnPoolWithDestroy() override { onDestroy(); } MOCK_METHOD0(onDestroy, void()); }; // Regression test for https://github.com/envoyproxy/envoy/issues/3518. Make sure we handle a // drain callback during CP destroy. TEST_F(ClusterManagerImplTest, ConnPoolDestroyWithDraining) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s type: STRICT_DNS dns_resolvers: - socket_address: address: 1.2.3.4 port_value: 80 lb_policy: ROUND_ROBIN load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 )EOF"; std::shared_ptr<Network::MockDnsResolver> dns_resolver(new Network::MockDnsResolver()); EXPECT_CALL(factory_.dispatcher_, createDnsResolver(_, _)).WillOnce(Return(dns_resolver)); Network::DnsResolver::ResolveCb dns_callback; Event::MockTimer* dns_timer_ = new NiceMock<Event::MockTimer>(&factory_.dispatcher_); Network::MockActiveDnsQuery active_dns_query; EXPECT_CALL(*dns_resolver, resolve(_, _, _)) .WillRepeatedly(DoAll(SaveArg<2>(&dns_callback), Return(&active_dns_query))); create(parseBootstrapFromV2Yaml(yaml)); EXPECT_FALSE(cluster_manager_->get("cluster_1")->info()->addedViaApi()); dns_callback(TestUtility::makeDnsResponse({"127.0.0.2"})); MockConnPoolWithDestroy* mock_cp = new MockConnPoolWithDestroy(); EXPECT_CALL(factory_, allocateConnPool_(_, _, _)).WillOnce(Return(mock_cp)); MockTcpConnPoolWithDestroy* mock_tcp = new MockTcpConnPoolWithDestroy(); EXPECT_CALL(factory_, allocateTcpConnPool_(_)).WillOnce(Return(mock_tcp)); Http::ConnectionPool::MockInstance* cp = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); Tcp::ConnectionPool::MockInstance* tcp = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); // Remove the first host, this should lead to the cp being drained. Http::ConnectionPool::Instance::DrainedCb drained_cb; EXPECT_CALL(*cp, addDrainedCallback(_)).WillOnce(SaveArg<0>(&drained_cb)); Tcp::ConnectionPool::Instance::DrainedCb tcp_drained_cb; EXPECT_CALL(*tcp, addDrainedCallback(_)).WillOnce(SaveArg<0>(&tcp_drained_cb)); dns_timer_->invokeCallback(); dns_callback(TestUtility::makeDnsResponse({})); // The drained callback might get called when the CP is being destroyed. EXPECT_CALL(*mock_cp, onDestroy()).WillOnce(Invoke(drained_cb)); EXPECT_CALL(*mock_tcp, onDestroy()).WillOnce(Invoke(tcp_drained_cb)); factory_.tls_.shutdownThread(); } TEST_F(ClusterManagerImplTest, OriginalDstInitialization) { const std::string yaml = R"EOF( { "static_resources": { "clusters": [ { "name": "cluster_1", "connect_timeout": "0.250s", "type": "original_dst", "lb_policy": "original_dst_lb" } ] } } )EOF"; ReadyWatcher initialized; EXPECT_CALL(initialized, ready()); create(parseBootstrapFromV2Yaml(yaml)); // Set up for an initialize callback. cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); EXPECT_FALSE(cluster_manager_->get("cluster_1")->info()->addedViaApi()); // Test for no hosts returning the correct values before we have hosts. EXPECT_EQ(nullptr, cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); EXPECT_EQ(nullptr, cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); EXPECT_EQ(nullptr, cluster_manager_->tcpConnForCluster("cluster_1", nullptr).connection_); EXPECT_EQ(3UL, factory_.stats_.counter("cluster.cluster_1.upstream_cx_none_healthy").value()); factory_.tls_.shutdownThread(); } // Tests that all the HC/weight/metadata changes are delivered in one go, as long as // there's no hosts changes in between. // Also tests that if hosts are added/removed between mergeable updates, delivery will // happen and the scheduled update will be cancelled. TEST_F(ClusterManagerImplTest, MergedUpdates) { createWithLocalClusterUpdate(); // Ensure we see the right set of added/removed hosts on every call. EXPECT_CALL(local_cluster_update_, post(_, _, _)) .WillOnce(Invoke([](uint32_t priority, const HostVector& hosts_added, const HostVector& hosts_removed) -> void { // 1st removal. EXPECT_EQ(0, priority); EXPECT_EQ(0, hosts_added.size()); EXPECT_EQ(1, hosts_removed.size()); })) .WillOnce(Invoke([](uint32_t priority, const HostVector& hosts_added, const HostVector& hosts_removed) -> void { // Triggered by the 2 HC updates, it's a merged update so no added/removed // hosts. EXPECT_EQ(0, priority); EXPECT_EQ(0, hosts_added.size()); EXPECT_EQ(0, hosts_removed.size()); })) .WillOnce(Invoke([](uint32_t priority, const HostVector& hosts_added, const HostVector& hosts_removed) -> void { // 1st removed host added back. EXPECT_EQ(0, priority); EXPECT_EQ(1, hosts_added.size()); EXPECT_EQ(0, hosts_removed.size()); })) .WillOnce(Invoke([](uint32_t priority, const HostVector& hosts_added, const HostVector& hosts_removed) -> void { // 1st removed host removed again, plus the 3 HC/weight/metadata updates that were // waiting for delivery. EXPECT_EQ(0, priority); EXPECT_EQ(0, hosts_added.size()); EXPECT_EQ(1, hosts_removed.size()); })); EXPECT_CALL(local_hosts_removed_, post(_)) .Times(2) .WillRepeatedly( Invoke([](const auto& hosts_removed) { EXPECT_EQ(1, hosts_removed.size()); })); Event::MockTimer* timer = new NiceMock<Event::MockTimer>(&factory_.dispatcher_); Cluster& cluster = cluster_manager_->activeClusters().begin()->second; HostVectorSharedPtr hosts( new HostVector(cluster.prioritySet().hostSetsPerPriority()[0]->hosts())); HostsPerLocalitySharedPtr hosts_per_locality = std::make_shared<HostsPerLocalityImpl>(); HostVector hosts_added; HostVector hosts_removed; // The first update should be applied immediately, since it's not mergeable. hosts_removed.push_back((*hosts)[0]); cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.cluster_updated").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.cluster_updated_via_merge").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.update_merge_cancelled").value()); // These calls should be merged, since there are no added/removed hosts. hosts_removed.clear(); cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.cluster_updated").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.cluster_updated_via_merge").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.update_merge_cancelled").value()); // Ensure the merged updates were applied. timer->invokeCallback(); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.cluster_updated").value()); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.cluster_updated_via_merge").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.update_merge_cancelled").value()); // Add the host back, the update should be immediately applied. hosts_removed.clear(); hosts_added.push_back((*hosts)[0]); cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); EXPECT_EQ(2, factory_.stats_.counter("cluster_manager.cluster_updated").value()); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.cluster_updated_via_merge").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.update_merge_cancelled").value()); // Now emit 3 updates that should be scheduled: metadata, HC, and weight. hosts_added.clear(); (*hosts)[0]->metadata(buildMetadata("v1")); cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); (*hosts)[0]->healthFlagSet(Host::HealthFlag::FAILED_EDS_HEALTH); cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); (*hosts)[0]->weight(100); cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); // Updates not delivered yet. EXPECT_EQ(2, factory_.stats_.counter("cluster_manager.cluster_updated").value()); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.cluster_updated_via_merge").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.update_merge_cancelled").value()); // Remove the host again, should cancel the scheduled update and be delivered immediately. hosts_removed.push_back((*hosts)[0]); cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); EXPECT_EQ(3, factory_.stats_.counter("cluster_manager.cluster_updated").value()); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.cluster_updated_via_merge").value()); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.update_merge_cancelled").value()); } // Tests that mergeable updates outside of a window get applied immediately. TEST_F(ClusterManagerImplTest, MergedUpdatesOutOfWindow) { createWithLocalClusterUpdate(); // Ensure we see the right set of added/removed hosts on every call. EXPECT_CALL(local_cluster_update_, post(_, _, _)) .WillOnce(Invoke([](uint32_t priority, const HostVector& hosts_added, const HostVector& hosts_removed) -> void { // HC update, immediately delivered. EXPECT_EQ(0, priority); EXPECT_EQ(0, hosts_added.size()); EXPECT_EQ(0, hosts_removed.size()); })); Cluster& cluster = cluster_manager_->activeClusters().begin()->second; HostVectorSharedPtr hosts( new HostVector(cluster.prioritySet().hostSetsPerPriority()[0]->hosts())); HostsPerLocalitySharedPtr hosts_per_locality = std::make_shared<HostsPerLocalityImpl>(); HostVector hosts_added; HostVector hosts_removed; // The first update should be applied immediately, because even though it's mergeable // it's outside the default merge window of 3 seconds (found in debugger as value of // cluster.info()->lbConfig().update_merge_window() in ClusterManagerImpl::scheduleUpdate. time_system_.sleep(std::chrono::seconds(60)); cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.cluster_updated").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.cluster_updated_via_merge").value()); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.update_out_of_merge_window").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.update_merge_cancelled").value()); } // Tests that mergeable updates inside of a window are not applied immediately. TEST_F(ClusterManagerImplTest, MergedUpdatesInsideWindow) { createWithLocalClusterUpdate(); Cluster& cluster = cluster_manager_->activeClusters().begin()->second; HostVectorSharedPtr hosts( new HostVector(cluster.prioritySet().hostSetsPerPriority()[0]->hosts())); HostsPerLocalitySharedPtr hosts_per_locality = std::make_shared<HostsPerLocalityImpl>(); HostVector hosts_added; HostVector hosts_removed; // The first update will not be applied, as we make it inside the default mergeable window of // 3 seconds (found in debugger as value of cluster.info()->lbConfig().update_merge_window() // in ClusterManagerImpl::scheduleUpdate. Note that initially the update-time is // default-initialized to a monotonic time of 0, as is SimulatedTimeSystem::monotonic_time_. time_system_.sleep(std::chrono::seconds(2)); cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.cluster_updated").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.cluster_updated_via_merge").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.update_out_of_merge_window").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.update_merge_cancelled").value()); } // Tests that mergeable updates outside of a window get applied immediately when // merging is disabled, and that the counters are correct. TEST_F(ClusterManagerImplTest, MergedUpdatesOutOfWindowDisabled) { createWithLocalClusterUpdate(false); // Ensure we see the right set of added/removed hosts on every call. EXPECT_CALL(local_cluster_update_, post(_, _, _)) .WillOnce(Invoke([](uint32_t priority, const HostVector& hosts_added, const HostVector& hosts_removed) -> void { // HC update, immediately delivered. EXPECT_EQ(0, priority); EXPECT_EQ(0, hosts_added.size()); EXPECT_EQ(0, hosts_removed.size()); })); Cluster& cluster = cluster_manager_->activeClusters().begin()->second; HostVectorSharedPtr hosts( new HostVector(cluster.prioritySet().hostSetsPerPriority()[0]->hosts())); HostsPerLocalitySharedPtr hosts_per_locality = std::make_shared<HostsPerLocalityImpl>(); HostVector hosts_added; HostVector hosts_removed; // The first update should be applied immediately, because even though it's mergeable // and outside a merge window, merging is disabled. cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.cluster_updated").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.cluster_updated_via_merge").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.update_out_of_merge_window").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.update_merge_cancelled").value()); } TEST_F(ClusterManagerImplTest, MergedUpdatesDestroyedOnUpdate) { // We create the default cluster, although for this test we won't use it since // we can only update dynamic clusters. createWithLocalClusterUpdate(); // Ensure we see the right set of added/removed hosts on every call, for the // dynamically added/updated cluster. EXPECT_CALL(local_cluster_update_, post(_, _, _)) .WillOnce(Invoke([](uint32_t priority, const HostVector& hosts_added, const HostVector& hosts_removed) -> void { // 1st add, when the cluster is added. EXPECT_EQ(0, priority); EXPECT_EQ(1, hosts_added.size()); EXPECT_EQ(0, hosts_removed.size()); })) .WillOnce(Invoke([](uint32_t priority, const HostVector& hosts_added, const HostVector& hosts_removed) -> void { // 1st removal. EXPECT_EQ(0, priority); EXPECT_EQ(0, hosts_added.size()); EXPECT_EQ(1, hosts_removed.size()); })); EXPECT_CALL(local_hosts_removed_, post(_)).WillOnce(Invoke([](const auto& hosts_removed) { // 1st removal. EXPECT_EQ(1, hosts_removed.size()); })); Event::MockTimer* timer = new NiceMock<Event::MockTimer>(&factory_.dispatcher_); // We can't used the bootstrap cluster, so add one dynamically. const std::string yaml = R"EOF( name: new_cluster connect_timeout: 0.250s type: STATIC lb_policy: ROUND_ROBIN load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 12001 common_lb_config: update_merge_window: 3s )EOF"; EXPECT_TRUE(cluster_manager_->addOrUpdateCluster(parseClusterFromV2Yaml(yaml), "version1")); Cluster& cluster = cluster_manager_->activeClusters().find("new_cluster")->second; HostVectorSharedPtr hosts( new HostVector(cluster.prioritySet().hostSetsPerPriority()[0]->hosts())); HostsPerLocalitySharedPtr hosts_per_locality = std::make_shared<HostsPerLocalityImpl>(); HostVector hosts_added; HostVector hosts_removed; // The first update should be applied immediately, since it's not mergeable. hosts_removed.push_back((*hosts)[0]); cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.cluster_updated").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.cluster_updated_via_merge").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.update_merge_cancelled").value()); // These calls should be merged, since there are no added/removed hosts. hosts_removed.clear(); cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); cluster.prioritySet().updateHosts( 0, updateHostsParams(hosts, hosts_per_locality, std::make_shared<const HealthyHostVector>(*hosts), hosts_per_locality), {}, hosts_added, hosts_removed, absl::nullopt); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.cluster_updated").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.cluster_updated_via_merge").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.update_merge_cancelled").value()); // Update the cluster, which should cancel the pending updates. std::shared_ptr<MockClusterMockPrioritySet> updated(new NiceMock<MockClusterMockPrioritySet>()); updated->info_->name_ = "new_cluster"; EXPECT_CALL(factory_, clusterFromProto_(_, _, _, true)) .WillOnce(Return(std::make_pair(updated, nullptr))); const std::string yaml_updated = R"EOF( name: new_cluster connect_timeout: 0.250s type: STATIC lb_policy: ROUND_ROBIN load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 12001 common_lb_config: update_merge_window: 4s )EOF"; // Add the updated cluster. EXPECT_EQ(2, factory_.stats_ .gauge("cluster_manager.active_clusters", Stats::Gauge::ImportMode::NeverImport) .value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.cluster_modified").value()); EXPECT_EQ(0, factory_.stats_ .gauge("cluster_manager.warming_clusters", Stats::Gauge::ImportMode::NeverImport) .value()); EXPECT_TRUE( cluster_manager_->addOrUpdateCluster(parseClusterFromV2Yaml(yaml_updated), "version2")); EXPECT_EQ(2, factory_.stats_ .gauge("cluster_manager.active_clusters", Stats::Gauge::ImportMode::NeverImport) .value()); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.cluster_modified").value()); EXPECT_EQ(1, factory_.stats_ .gauge("cluster_manager.warming_clusters", Stats::Gauge::ImportMode::NeverImport) .value()); // Promote the updated cluster from warming to active & assert the old timer was disabled // and it won't be called on version1 of new_cluster. EXPECT_CALL(*timer, disableTimer()); updated->initialize_callback_(); EXPECT_EQ(2, factory_.stats_ .gauge("cluster_manager.active_clusters", Stats::Gauge::ImportMode::NeverImport) .value()); EXPECT_EQ(0, factory_.stats_ .gauge("cluster_manager.warming_clusters", Stats::Gauge::ImportMode::NeverImport) .value()); } TEST_F(ClusterManagerImplTest, UpstreamSocketOptionsPassedToConnPool) { createWithLocalClusterUpdate(); NiceMock<MockLoadBalancerContext> context; Http::ConnectionPool::MockInstance* to_create = new Http::ConnectionPool::MockInstance(); Network::Socket::OptionsSharedPtr options_to_return = Network::SocketOptionFactory::buildIpTransparentOptions(); EXPECT_CALL(context, upstreamSocketOptions()).WillOnce(Return(options_to_return)); EXPECT_CALL(factory_, allocateConnPool_(_, _, _)).WillOnce(Return(to_create)); Http::ConnectionPool::Instance* cp = cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, &context); EXPECT_NE(nullptr, cp); } TEST_F(ClusterManagerImplTest, UpstreamSocketOptionsUsedInConnPoolHash) { createWithLocalClusterUpdate(); NiceMock<MockLoadBalancerContext> context1; NiceMock<MockLoadBalancerContext> context2; Http::ConnectionPool::MockInstance* to_create1 = new Http::ConnectionPool::MockInstance(); Http::ConnectionPool::MockInstance* to_create2 = new Http::ConnectionPool::MockInstance(); Network::Socket::OptionsSharedPtr options1 = Network::SocketOptionFactory::buildIpTransparentOptions(); Network::Socket::OptionsSharedPtr options2 = Network::SocketOptionFactory::buildSocketMarkOptions(3); EXPECT_CALL(context1, upstreamSocketOptions()).WillRepeatedly(Return(options1)); EXPECT_CALL(context2, upstreamSocketOptions()).WillRepeatedly(Return(options2)); EXPECT_CALL(factory_, allocateConnPool_(_, _, _)).WillOnce(Return(to_create1)); Http::ConnectionPool::Instance* cp1 = cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, &context1); EXPECT_CALL(factory_, allocateConnPool_(_, _, _)).WillOnce(Return(to_create2)); Http::ConnectionPool::Instance* cp2 = cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, &context2); Http::ConnectionPool::Instance* should_be_cp1 = cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, &context1); Http::ConnectionPool::Instance* should_be_cp2 = cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, &context2); // The different upstream options should lead to different hashKeys, thus different pools. EXPECT_NE(cp1, cp2); // Reusing the same options should lead to the same connection pools. EXPECT_EQ(cp1, should_be_cp1); EXPECT_EQ(cp2, should_be_cp2); } TEST_F(ClusterManagerImplTest, UpstreamSocketOptionsNullIsOkay) { createWithLocalClusterUpdate(); NiceMock<MockLoadBalancerContext> context; Http::ConnectionPool::MockInstance* to_create = new Http::ConnectionPool::MockInstance(); Network::Socket::OptionsSharedPtr options_to_return = nullptr; EXPECT_CALL(context, upstreamSocketOptions()).WillOnce(Return(options_to_return)); EXPECT_CALL(factory_, allocateConnPool_(_, _, _)).WillOnce(Return(to_create)); Http::ConnectionPool::Instance* cp = cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, &context); EXPECT_NE(nullptr, cp); } class TestUpstreamNetworkFilter : public Network::WriteFilter { public: Network::FilterStatus onWrite(Buffer::Instance&, bool) override { return Network::FilterStatus::Continue; } }; class TestUpstreamNetworkFilterConfigFactory : public Server::Configuration::NamedUpstreamNetworkFilterConfigFactory { public: Network::FilterFactoryCb createFilterFactoryFromProto(const Protobuf::Message&, Server::Configuration::CommonFactoryContext&) override { return [](Network::FilterManager& filter_manager) -> void { filter_manager.addWriteFilter(std::make_shared<TestUpstreamNetworkFilter>()); }; } ProtobufTypes::MessagePtr createEmptyConfigProto() override { return std::make_unique<Envoy::ProtobufWkt::Empty>(); } std::string name() override { return "envoy.test.filter"; } }; // Verify that configured upstream filters are added to client connections. TEST_F(ClusterManagerImplTest, AddUpstreamFilters) { TestUpstreamNetworkFilterConfigFactory factory; Registry::InjectFactory<Server::Configuration::NamedUpstreamNetworkFilterConfigFactory> registry( factory); const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC hosts: - socket_address: address: "127.0.0.1" port_value: 11001 filters: - name: envoy.test.filter )EOF"; create(parseBootstrapFromV2Yaml(yaml)); Network::MockClientConnection* connection = new NiceMock<Network::MockClientConnection>(); EXPECT_CALL(*connection, addReadFilter(_)).Times(0); EXPECT_CALL(*connection, addWriteFilter(_)).Times(1); EXPECT_CALL(*connection, addFilter(_)).Times(0); EXPECT_CALL(factory_.tls_.dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce(Return(connection)); auto conn_data = cluster_manager_->tcpConnForCluster("cluster_1", nullptr); EXPECT_EQ(connection, conn_data.connection_.get()); factory_.tls_.shutdownThread(); } class ClusterManagerInitHelperTest : public testing::Test { public: MOCK_METHOD1(onClusterInit, void(Cluster& cluster)); NiceMock<MockClusterManager> cm_; ClusterManagerInitHelper init_helper_{cm_, [this](Cluster& cluster) { onClusterInit(cluster); }}; }; TEST_F(ClusterManagerInitHelperTest, ImmediateInitialize) { InSequence s; NiceMock<MockClusterMockPrioritySet> cluster1; ON_CALL(cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); EXPECT_CALL(cluster1, initialize(_)); init_helper_.addCluster(cluster1); EXPECT_CALL(*this, onClusterInit(Ref(cluster1))); cluster1.initialize_callback_(); init_helper_.onStaticLoadComplete(); ReadyWatcher cm_initialized; EXPECT_CALL(cm_initialized, ready()); init_helper_.setInitializedCb([&]() -> void { cm_initialized.ready(); }); } TEST_F(ClusterManagerInitHelperTest, StaticSdsInitialize) { InSequence s; NiceMock<MockClusterMockPrioritySet> sds; ON_CALL(sds, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); EXPECT_CALL(sds, initialize(_)); init_helper_.addCluster(sds); EXPECT_CALL(*this, onClusterInit(Ref(sds))); sds.initialize_callback_(); NiceMock<MockClusterMockPrioritySet> cluster1; ON_CALL(cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Secondary)); init_helper_.addCluster(cluster1); EXPECT_CALL(cluster1, initialize(_)); init_helper_.onStaticLoadComplete(); ReadyWatcher cm_initialized; init_helper_.setInitializedCb([&]() -> void { cm_initialized.ready(); }); EXPECT_CALL(*this, onClusterInit(Ref(cluster1))); EXPECT_CALL(cm_initialized, ready()); cluster1.initialize_callback_(); } TEST_F(ClusterManagerInitHelperTest, UpdateAlreadyInitialized) { InSequence s; ReadyWatcher cm_initialized; init_helper_.setInitializedCb([&]() -> void { cm_initialized.ready(); }); NiceMock<MockClusterMockPrioritySet> cluster1; ON_CALL(cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); EXPECT_CALL(cluster1, initialize(_)); init_helper_.addCluster(cluster1); NiceMock<MockClusterMockPrioritySet> cluster2; ON_CALL(cluster2, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); EXPECT_CALL(cluster2, initialize(_)); init_helper_.addCluster(cluster2); init_helper_.onStaticLoadComplete(); EXPECT_CALL(*this, onClusterInit(Ref(cluster1))); cluster1.initialize_callback_(); init_helper_.removeCluster(cluster1); EXPECT_CALL(*this, onClusterInit(Ref(cluster2))); EXPECT_CALL(cm_initialized, ready()); cluster2.initialize_callback_(); } // If secondary clusters initialization triggered outside of CdsApiImpl::onConfigUpdate()'s // callback flows, sending ClusterLoadAssignment should not be paused before calling // ClusterManagerInitHelper::maybeFinishInitialize(). This case tests that // ClusterLoadAssignment request is paused and resumed properly. TEST_F(ClusterManagerInitHelperTest, InitSecondaryWithoutEdsPaused) { InSequence s; ReadyWatcher cm_initialized; init_helper_.setInitializedCb([&]() -> void { cm_initialized.ready(); }); NiceMock<MockClusterMockPrioritySet> cluster1; ON_CALL(cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Secondary)); init_helper_.addCluster(cluster1); EXPECT_CALL(cluster1, initialize(_)); init_helper_.onStaticLoadComplete(); EXPECT_CALL(*this, onClusterInit(Ref(cluster1))); EXPECT_CALL(cm_initialized, ready()); cluster1.initialize_callback_(); } // If secondary clusters initialization triggered inside of CdsApiImpl::onConfigUpdate()'s // callback flows, that's, the CDS response didn't have any primary cluster, sending // ClusterLoadAssignment should be already paused by CdsApiImpl::onConfigUpdate(). // This case tests that ClusterLoadAssignment request isn't paused again. TEST_F(ClusterManagerInitHelperTest, InitSecondaryWithEdsPaused) { InSequence s; ReadyWatcher cm_initialized; init_helper_.setInitializedCb([&]() -> void { cm_initialized.ready(); }); NiceMock<MockClusterMockPrioritySet> cluster1; ON_CALL(cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Secondary)); init_helper_.addCluster(cluster1); EXPECT_CALL(cluster1, initialize(_)); init_helper_.onStaticLoadComplete(); EXPECT_CALL(*this, onClusterInit(Ref(cluster1))); EXPECT_CALL(cm_initialized, ready()); cluster1.initialize_callback_(); } TEST_F(ClusterManagerInitHelperTest, AddSecondaryAfterSecondaryInit) { InSequence s; ReadyWatcher cm_initialized; init_helper_.setInitializedCb([&]() -> void { cm_initialized.ready(); }); NiceMock<MockClusterMockPrioritySet> cluster1; ON_CALL(cluster1, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Primary)); EXPECT_CALL(cluster1, initialize(_)); init_helper_.addCluster(cluster1); NiceMock<MockClusterMockPrioritySet> cluster2; ON_CALL(cluster2, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Secondary)); init_helper_.addCluster(cluster2); init_helper_.onStaticLoadComplete(); EXPECT_CALL(*this, onClusterInit(Ref(cluster1))); EXPECT_CALL(cluster2, initialize(_)); cluster1.initialize_callback_(); NiceMock<MockClusterMockPrioritySet> cluster3; ON_CALL(cluster3, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Secondary)); EXPECT_CALL(cluster3, initialize(_)); init_helper_.addCluster(cluster3); EXPECT_CALL(*this, onClusterInit(Ref(cluster3))); cluster3.initialize_callback_(); EXPECT_CALL(*this, onClusterInit(Ref(cluster2))); EXPECT_CALL(cm_initialized, ready()); cluster2.initialize_callback_(); } // Tests the scenario encountered in Issue 903: The cluster was removed from // the secondary init list while traversing the list. TEST_F(ClusterManagerInitHelperTest, RemoveClusterWithinInitLoop) { InSequence s; NiceMock<MockClusterMockPrioritySet> cluster; ON_CALL(cluster, initializePhase()).WillByDefault(Return(Cluster::InitializePhase::Secondary)); init_helper_.addCluster(cluster); // Set up the scenario seen in Issue 903 where initialize() ultimately results // in the removeCluster() call. In the real bug this was a long and complex call // chain. EXPECT_CALL(cluster, initialize(_)).WillOnce(Invoke([&](std::function<void()>) -> void { init_helper_.removeCluster(cluster); })); // Now call onStaticLoadComplete which will exercise maybeFinishInitialize() // which calls initialize() on the members of the secondary init list. init_helper_.onStaticLoadComplete(); } // Validate that when options are set in the ClusterManager and/or Cluster, we see the socket option // propagated to setsockopt(). This is as close to an end-to-end test as we have for this feature, // due to the complexity of creating an integration test involving the network stack. We only test // the IPv4 case here, as the logic around IPv4/IPv6 handling is tested generically in // socket_option_impl_test.cc. class SockoptsTest : public ClusterManagerImplTest { public: void initialize(const std::string& yaml) { create(parseBootstrapFromV2Yaml(yaml)); } void TearDown() override { factory_.tls_.shutdownThread(); } // TODO(tschroed): Extend this to support socket state as well. void expectSetsockopts(const std::vector<std::pair<Network::SocketOptionName, int>>& names_vals) { NiceMock<Api::MockOsSysCalls> os_sys_calls; TestThreadsafeSingletonInjector<Api::OsSysCallsImpl> os_calls(&os_sys_calls); bool expect_success = true; for (const auto& name_val : names_vals) { if (!name_val.first.has_value()) { expect_success = false; continue; } EXPECT_CALL(os_sys_calls, setsockopt_(_, name_val.first.level(), name_val.first.option(), _, sizeof(int))) .WillOnce(Invoke([&name_val](int, int, int, const void* optval, socklen_t) -> int { EXPECT_EQ(name_val.second, *static_cast<const int*>(optval)); return 0; })); } EXPECT_CALL(factory_.tls_.dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce(Invoke([this, &names_vals, expect_success]( Network::Address::InstanceConstSharedPtr, Network::Address::InstanceConstSharedPtr, Network::TransportSocketPtr&, const Network::ConnectionSocket::OptionsSharedPtr& options) -> Network::ClientConnection* { EXPECT_NE(nullptr, options.get()) << "Unexpected null options"; if (options.get() != nullptr) { // Don't crash the entire test. EXPECT_EQ(names_vals.size(), options->size()); } NiceMock<Network::MockConnectionSocket> socket; if (expect_success) { EXPECT_TRUE((Network::Socket::applyOptions( options, socket, envoy::config::core::v3alpha::SocketOption::STATE_PREBIND))); } else { EXPECT_FALSE((Network::Socket::applyOptions( options, socket, envoy::config::core::v3alpha::SocketOption::STATE_PREBIND))); } return connection_; })); cluster_manager_->tcpConnForCluster("SockoptsCluster", nullptr); } void expectSetsockoptFreebind() { std::vector<std::pair<Network::SocketOptionName, int>> names_vals{ {ENVOY_SOCKET_IP_FREEBIND, 1}}; expectSetsockopts(names_vals); } void expectNoSocketOptions() { EXPECT_CALL(factory_.tls_.dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce( Invoke([this](Network::Address::InstanceConstSharedPtr, Network::Address::InstanceConstSharedPtr, Network::TransportSocketPtr&, const Network::ConnectionSocket::OptionsSharedPtr& options) -> Network::ClientConnection* { EXPECT_EQ(nullptr, options.get()); return connection_; })); auto conn_data = cluster_manager_->tcpConnForCluster("SockoptsCluster", nullptr); EXPECT_EQ(connection_, conn_data.connection_.get()); } Network::MockClientConnection* connection_ = new NiceMock<Network::MockClientConnection>(); }; TEST_F(SockoptsTest, SockoptsUnset) { const std::string yaml = R"EOF( static_resources: clusters: - name: SockoptsCluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 )EOF"; initialize(yaml); expectNoSocketOptions(); } TEST_F(SockoptsTest, FreebindClusterOnly) { const std::string yaml = R"EOF( static_resources: clusters: - name: SockoptsCluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 upstream_bind_config: freebind: true )EOF"; initialize(yaml); expectSetsockoptFreebind(); } TEST_F(SockoptsTest, FreebindClusterManagerOnly) { const std::string yaml = R"EOF( static_resources: clusters: - name: SockoptsCluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 cluster_manager: upstream_bind_config: freebind: true )EOF"; initialize(yaml); expectSetsockoptFreebind(); } TEST_F(SockoptsTest, FreebindClusterOverride) { const std::string yaml = R"EOF( static_resources: clusters: - name: SockoptsCluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 upstream_bind_config: freebind: true cluster_manager: upstream_bind_config: freebind: false )EOF"; initialize(yaml); expectSetsockoptFreebind(); } TEST_F(SockoptsTest, SockoptsClusterOnly) { const std::string yaml = R"EOF( static_resources: clusters: - name: SockoptsCluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 upstream_bind_config: socket_options: [ { level: 1, name: 2, int_value: 3, state: STATE_PREBIND }, { level: 4, name: 5, int_value: 6, state: STATE_PREBIND }] )EOF"; initialize(yaml); std::vector<std::pair<Network::SocketOptionName, int>> names_vals{ {ENVOY_MAKE_SOCKET_OPTION_NAME(1, 2), 3}, {ENVOY_MAKE_SOCKET_OPTION_NAME(4, 5), 6}}; expectSetsockopts(names_vals); } TEST_F(SockoptsTest, SockoptsClusterManagerOnly) { const std::string yaml = R"EOF( static_resources: clusters: - name: SockoptsCluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 cluster_manager: upstream_bind_config: socket_options: [ { level: 1, name: 2, int_value: 3, state: STATE_PREBIND }, { level: 4, name: 5, int_value: 6, state: STATE_PREBIND }] )EOF"; initialize(yaml); std::vector<std::pair<Network::SocketOptionName, int>> names_vals{ {ENVOY_MAKE_SOCKET_OPTION_NAME(1, 2), 3}, {ENVOY_MAKE_SOCKET_OPTION_NAME(4, 5), 6}}; expectSetsockopts(names_vals); } TEST_F(SockoptsTest, SockoptsClusterOverride) { const std::string yaml = R"EOF( static_resources: clusters: - name: SockoptsCluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 upstream_bind_config: socket_options: [ { level: 1, name: 2, int_value: 3, state: STATE_PREBIND }, { level: 4, name: 5, int_value: 6, state: STATE_PREBIND }] cluster_manager: upstream_bind_config: socket_options: [{ level: 7, name: 8, int_value: 9, state: STATE_PREBIND }] )EOF"; initialize(yaml); std::vector<std::pair<Network::SocketOptionName, int>> names_vals{ {ENVOY_MAKE_SOCKET_OPTION_NAME(1, 2), 3}, {ENVOY_MAKE_SOCKET_OPTION_NAME(4, 5), 6}}; expectSetsockopts(names_vals); } // Validate that when tcp keepalives are set in the Cluster, we see the socket // option propagated to setsockopt(). This is as close to an end-to-end test as we have for this // feature, due to the complexity of creating an integration test involving the network stack. We // only test the IPv4 case here, as the logic around IPv4/IPv6 handling is tested generically in // tcp_keepalive_option_impl_test.cc. class TcpKeepaliveTest : public ClusterManagerImplTest { public: void initialize(const std::string& yaml) { create(parseBootstrapFromV2Yaml(yaml)); } void TearDown() override { factory_.tls_.shutdownThread(); } void expectSetsockoptSoKeepalive(absl::optional<int> keepalive_probes, absl::optional<int> keepalive_time, absl::optional<int> keepalive_interval) { if (!ENVOY_SOCKET_SO_KEEPALIVE.has_value()) { EXPECT_CALL(factory_.tls_.dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce( Invoke([this](Network::Address::InstanceConstSharedPtr, Network::Address::InstanceConstSharedPtr, Network::TransportSocketPtr&, const Network::ConnectionSocket::OptionsSharedPtr& options) -> Network::ClientConnection* { EXPECT_NE(nullptr, options.get()); EXPECT_EQ(1, options->size()); NiceMock<Network::MockConnectionSocket> socket; EXPECT_FALSE((Network::Socket::applyOptions( options, socket, envoy::config::core::v3alpha::SocketOption::STATE_PREBIND))); return connection_; })); cluster_manager_->tcpConnForCluster("TcpKeepaliveCluster", nullptr); return; } NiceMock<Api::MockOsSysCalls> os_sys_calls; TestThreadsafeSingletonInjector<Api::OsSysCallsImpl> os_calls(&os_sys_calls); EXPECT_CALL(factory_.tls_.dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce( Invoke([this](Network::Address::InstanceConstSharedPtr, Network::Address::InstanceConstSharedPtr, Network::TransportSocketPtr&, const Network::ConnectionSocket::OptionsSharedPtr& options) -> Network::ClientConnection* { EXPECT_NE(nullptr, options.get()); NiceMock<Network::MockConnectionSocket> socket; EXPECT_TRUE((Network::Socket::applyOptions( options, socket, envoy::config::core::v3alpha::SocketOption::STATE_PREBIND))); return connection_; })); EXPECT_CALL(os_sys_calls, setsockopt_(_, ENVOY_SOCKET_SO_KEEPALIVE.level(), ENVOY_SOCKET_SO_KEEPALIVE.option(), _, sizeof(int))) .WillOnce(Invoke([](int, int, int, const void* optval, socklen_t) -> int { EXPECT_EQ(1, *static_cast<const int*>(optval)); return 0; })); if (keepalive_probes.has_value()) { EXPECT_CALL(os_sys_calls, setsockopt_(_, ENVOY_SOCKET_TCP_KEEPCNT.level(), ENVOY_SOCKET_TCP_KEEPCNT.option(), _, sizeof(int))) .WillOnce( Invoke([&keepalive_probes](int, int, int, const void* optval, socklen_t) -> int { EXPECT_EQ(keepalive_probes.value(), *static_cast<const int*>(optval)); return 0; })); } if (keepalive_time.has_value()) { EXPECT_CALL(os_sys_calls, setsockopt_(_, ENVOY_SOCKET_TCP_KEEPIDLE.level(), ENVOY_SOCKET_TCP_KEEPIDLE.option(), _, sizeof(int))) .WillOnce(Invoke([&keepalive_time](int, int, int, const void* optval, socklen_t) -> int { EXPECT_EQ(keepalive_time.value(), *static_cast<const int*>(optval)); return 0; })); } if (keepalive_interval.has_value()) { EXPECT_CALL(os_sys_calls, setsockopt_(_, ENVOY_SOCKET_TCP_KEEPINTVL.level(), ENVOY_SOCKET_TCP_KEEPINTVL.option(), _, sizeof(int))) .WillOnce( Invoke([&keepalive_interval](int, int, int, const void* optval, socklen_t) -> int { EXPECT_EQ(keepalive_interval.value(), *static_cast<const int*>(optval)); return 0; })); } auto conn_data = cluster_manager_->tcpConnForCluster("TcpKeepaliveCluster", nullptr); EXPECT_EQ(connection_, conn_data.connection_.get()); } void expectNoSocketOptions() { EXPECT_CALL(factory_.tls_.dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce( Invoke([this](Network::Address::InstanceConstSharedPtr, Network::Address::InstanceConstSharedPtr, Network::TransportSocketPtr&, const Network::ConnectionSocket::OptionsSharedPtr& options) -> Network::ClientConnection* { EXPECT_EQ(nullptr, options.get()); return connection_; })); auto conn_data = cluster_manager_->tcpConnForCluster("TcpKeepaliveCluster", nullptr); EXPECT_EQ(connection_, conn_data.connection_.get()); } Network::MockClientConnection* connection_ = new NiceMock<Network::MockClientConnection>(); }; TEST_F(TcpKeepaliveTest, TcpKeepaliveUnset) { const std::string yaml = R"EOF( static_resources: clusters: - name: TcpKeepaliveCluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 )EOF"; initialize(yaml); expectNoSocketOptions(); } TEST_F(TcpKeepaliveTest, TcpKeepaliveCluster) { const std::string yaml = R"EOF( static_resources: clusters: - name: TcpKeepaliveCluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 upstream_connection_options: tcp_keepalive: {} )EOF"; initialize(yaml); expectSetsockoptSoKeepalive({}, {}, {}); } TEST_F(TcpKeepaliveTest, TcpKeepaliveClusterProbes) { const std::string yaml = R"EOF( static_resources: clusters: - name: TcpKeepaliveCluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 upstream_connection_options: tcp_keepalive: keepalive_probes: 7 )EOF"; initialize(yaml); expectSetsockoptSoKeepalive(7, {}, {}); } TEST_F(TcpKeepaliveTest, TcpKeepaliveWithAllOptions) { const std::string yaml = R"EOF( static_resources: clusters: - name: TcpKeepaliveCluster connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC load_assignment: endpoints: - lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.1 port_value: 11001 upstream_connection_options: tcp_keepalive: keepalive_probes: 7 keepalive_time: 4 keepalive_interval: 1 )EOF"; initialize(yaml); expectSetsockoptSoKeepalive(7, 4, 1); } TEST_F(ClusterManagerImplTest, ConnPoolsDrainedOnHostSetChange) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC common_lb_config: close_connections_on_host_set_change: true )EOF"; ReadyWatcher initialized; EXPECT_CALL(initialized, ready()); create(parseBootstrapFromV2Yaml(yaml)); // Set up for an initialize callback. cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); std::unique_ptr<MockClusterUpdateCallbacks> callbacks(new NiceMock<MockClusterUpdateCallbacks>()); ClusterUpdateCallbacksHandlePtr cb = cluster_manager_->addThreadLocalClusterUpdateCallbacks(*callbacks); EXPECT_FALSE(cluster_manager_->get("cluster_1")->info()->addedViaApi()); // Verify that we get no hosts when the HostSet is empty. EXPECT_EQ(nullptr, cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); EXPECT_EQ(nullptr, cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); EXPECT_EQ(nullptr, cluster_manager_->tcpConnForCluster("cluster_1", nullptr).connection_); Cluster& cluster = cluster_manager_->activeClusters().begin()->second; // Set up the HostSet. HostSharedPtr host1 = makeTestHost(cluster.info(), "tcp://127.0.0.1:80"); HostSharedPtr host2 = makeTestHost(cluster.info(), "tcp://127.0.0.1:81"); HostVector hosts{host1, host2}; auto hosts_ptr = std::make_shared<HostVector>(hosts); // Sending non-mergeable updates. cluster.prioritySet().updateHosts( 0, HostSetImpl::partitionHosts(hosts_ptr, HostsPerLocalityImpl::empty()), nullptr, hosts, {}, 100); EXPECT_EQ(1, factory_.stats_.counter("cluster_manager.cluster_updated").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.cluster_updated_via_merge").value()); EXPECT_EQ(0, factory_.stats_.counter("cluster_manager.update_merge_cancelled").value()); EXPECT_CALL(factory_, allocateConnPool_(_, _, _)) .Times(3) .WillRepeatedly(ReturnNew<Http::ConnectionPool::MockInstance>()); EXPECT_CALL(factory_, allocateTcpConnPool_(_)) .Times(3) .WillRepeatedly(ReturnNew<Tcp::ConnectionPool::MockInstance>()); // This should provide us a CP for each of the above hosts. Http::ConnectionPool::MockInstance* cp1 = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); // Create persistent connection for host2. Http::ConnectionPool::MockInstance* cp2 = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http2, nullptr)); Tcp::ConnectionPool::MockInstance* tcp1 = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); Tcp::ConnectionPool::MockInstance* tcp2 = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); EXPECT_NE(cp1, cp2); EXPECT_NE(tcp1, tcp2); EXPECT_CALL(*cp2, addDrainedCallback(_)) .WillOnce(Invoke([](Http::ConnectionPool::Instance::DrainedCb cb) { cb(); })); EXPECT_CALL(*cp1, addDrainedCallback(_)) .WillOnce(Invoke([](Http::ConnectionPool::Instance::DrainedCb cb) { cb(); })); EXPECT_CALL(*tcp1, addDrainedCallback(_)) .WillOnce(Invoke([](Tcp::ConnectionPool::Instance::DrainedCb cb) { cb(); })); EXPECT_CALL(*tcp2, addDrainedCallback(_)) .WillOnce(Invoke([](Tcp::ConnectionPool::Instance::DrainedCb cb) { cb(); })); HostVector hosts_removed; hosts_removed.push_back(host2); // This update should drain all connection pools (host1, host2). cluster.prioritySet().updateHosts( 0, HostSetImpl::partitionHosts(hosts_ptr, HostsPerLocalityImpl::empty()), nullptr, {}, hosts_removed, 100); // Recreate connection pool for host1. cp1 = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); tcp1 = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); HostSharedPtr host3 = makeTestHost(cluster.info(), "tcp://127.0.0.1:82"); HostVector hosts_added; hosts_added.push_back(host3); EXPECT_CALL(*cp1, addDrainedCallback(_)) .WillOnce(Invoke([](Http::ConnectionPool::Instance::DrainedCb cb) { cb(); })); EXPECT_CALL(*tcp1, addDrainedCallback(_)) .WillOnce(Invoke([](Tcp::ConnectionPool::Instance::DrainedCb cb) { cb(); })); // Adding host3 should drain connection pool for host1. cluster.prioritySet().updateHosts( 0, HostSetImpl::partitionHosts(hosts_ptr, HostsPerLocalityImpl::empty()), nullptr, hosts_added, {}, 100); } TEST_F(ClusterManagerImplTest, ConnPoolsNotDrainedOnHostSetChange) { const std::string yaml = R"EOF( static_resources: clusters: - name: cluster_1 connect_timeout: 0.250s lb_policy: ROUND_ROBIN type: STATIC )EOF"; ReadyWatcher initialized; EXPECT_CALL(initialized, ready()); create(parseBootstrapFromV2Yaml(yaml)); // Set up for an initialize callback. cluster_manager_->setInitializedCb([&]() -> void { initialized.ready(); }); std::unique_ptr<MockClusterUpdateCallbacks> callbacks(new NiceMock<MockClusterUpdateCallbacks>()); ClusterUpdateCallbacksHandlePtr cb = cluster_manager_->addThreadLocalClusterUpdateCallbacks(*callbacks); Cluster& cluster = cluster_manager_->activeClusters().begin()->second; // Set up the HostSet. HostSharedPtr host1 = makeTestHost(cluster.info(), "tcp://127.0.0.1:80"); HostVector hosts{host1}; auto hosts_ptr = std::make_shared<HostVector>(hosts); // Sending non-mergeable updates. cluster.prioritySet().updateHosts( 0, HostSetImpl::partitionHosts(hosts_ptr, HostsPerLocalityImpl::empty()), nullptr, hosts, {}, 100); EXPECT_CALL(factory_, allocateConnPool_(_, _, _)) .Times(1) .WillRepeatedly(ReturnNew<Http::ConnectionPool::MockInstance>()); EXPECT_CALL(factory_, allocateTcpConnPool_(_)) .Times(1) .WillRepeatedly(ReturnNew<Tcp::ConnectionPool::MockInstance>()); // This should provide us a CP for each of the above hosts. Http::ConnectionPool::MockInstance* cp1 = dynamic_cast<Http::ConnectionPool::MockInstance*>(cluster_manager_->httpConnPoolForCluster( "cluster_1", ResourcePriority::Default, Http::Protocol::Http11, nullptr)); Tcp::ConnectionPool::MockInstance* tcp1 = dynamic_cast<Tcp::ConnectionPool::MockInstance*>( cluster_manager_->tcpConnPoolForCluster("cluster_1", ResourcePriority::Default, nullptr)); HostSharedPtr host2 = makeTestHost(cluster.info(), "tcp://127.0.0.1:82"); HostVector hosts_added; hosts_added.push_back(host2); // No connection pools should be drained. EXPECT_CALL(*cp1, drainConnections()).Times(0); EXPECT_CALL(*tcp1, drainConnections()).Times(0); // No connection pools should be drained. cluster.prioritySet().updateHosts( 0, HostSetImpl::partitionHosts(hosts_ptr, HostsPerLocalityImpl::empty()), nullptr, hosts_added, {}, 100); } TEST_F(ClusterManagerImplTest, InvalidPriorityLocalClusterNameStatic) { std::string yaml = R"EOF( static_resources: clusters: - name: new_cluster connect_timeout: 4s type: STATIC load_assignment: cluster_name: "domains" endpoints: - priority: 10 lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.2 port_value: 11001 cluster_manager: local_cluster_name: new_cluster )EOF"; EXPECT_THROW_WITH_MESSAGE(create(parseBootstrapFromV2Yaml(yaml)), EnvoyException, "Unexpected non-zero priority for local cluster 'new_cluster'."); } TEST_F(ClusterManagerImplTest, InvalidPriorityLocalClusterNameStrictDns) { std::string yaml = R"EOF( static_resources: clusters: - name: new_cluster connect_timeout: 4s type: STRICT_DNS load_assignment: cluster_name: "domains" endpoints: - priority: 10 lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.2 port_value: 11001 cluster_manager: local_cluster_name: new_cluster )EOF"; EXPECT_THROW_WITH_MESSAGE(create(parseBootstrapFromV2Yaml(yaml)), EnvoyException, "Unexpected non-zero priority for local cluster 'new_cluster'."); } TEST_F(ClusterManagerImplTest, InvalidPriorityLocalClusterNameLogicalDns) { std::string yaml = R"EOF( static_resources: clusters: - name: new_cluster connect_timeout: 4s type: LOGICAL_DNS load_assignment: cluster_name: "domains" endpoints: - priority: 10 lb_endpoints: - endpoint: address: socket_address: address: 127.0.0.2 port_value: 11001 cluster_manager: local_cluster_name: new_cluster )EOF"; // The priority for LOGICAL_DNS endpoints are written, so we just verify that there is only a // single priority even if the endpoint was configured to be priority 10. create(parseBootstrapFromV2Yaml(yaml)); const auto cluster = cluster_manager_->get("new_cluster"); EXPECT_EQ(1, cluster->prioritySet().hostSetsPerPriority().size()); } } // namespace } // namespace Upstream } // namespace Envoy
#include <iostream> #include <string> #include <vector> #include <stdio.h> #include <signal.h> #include <stdlib.h> #include <msgpack.hpp> #include "hiredis/hiredis.h" #include "hiredis/async.h" #include "hiredis/adapters/libevent.h" using namespace std; using namespace msgpack; int main() { redisContext *c; void *reply; c = redisConnect("127.0.0.1", 6379); if(c!=NULL && c->err) { printf("Error: %s\n", c->errstr); } char str[] = "Hello World!!"; vector<unsigned char> data; for (unsigned i = 0; i < 10; ++i) data.push_back(i * 2); cout << "The size of array 'data' is: "<<sizeof(str)<<endl; sbuffer sbuf; //string text = std::to_string(pack(sbuf, str)); pack(sbuf, data); //pack(sbuf, str); cout << "The size of packed is: " << sbuf.size() <<endl; reply = redisCommand(c,"SET %s %s", "foo", sbuf.data()); void *size = redisCommand(c, "DBSIZE"); int size_of_db = *((int *)size); cout << "The size of key in RedisDB is: "<< size_of_db << endl; //void *al = redisCommand(c,"SET %s %s", to_string(size_of_db), "Aa"); //printf("SET: %s\n", reply->str); freeReplyObject(reply); //void *bl = redisCommand(c,"GET foo"); string getstr = "GET "; getstr = getstr + to_String(size_of_db); reply = redisCommand(c, getstr); //printf("GET foo: %s\n", reply->str); freeReplyObject(reply); redisFree(c); return 0; unpacked msg; unpack(&msg, sbuf.data(), sbuf.size()); object obj = msg.get(); cout<<"The size of unpacked object is: "<<sizeof(obj)<<endl; cout << "The object is: "<<endl; cout << obj << endl; }
kp_song kp_reloc dc.w kp_song_registers dc.w kp_speed dc.w kp_grooveboxpos dc.w kp_grooveboxlen dc.w kp_groovebox dc.w kp_patternlen dc.w kp_patternmap_lo dc.w kp_patternmap_hi dc.w kp_insmap_lo dc.w kp_insmap_hi dc.w kp_volmap_lo dc.w kp_volmap_hi dc.w kp_sequence kp_song_registers kp_speed dc.b $02 kp_grooveboxpos dc.b $00 kp_grooveboxlen dc.b $04 kp_groovebox dc.b $06 dc.b $05 dc.b $07 dc.b $06 dc.b $05 dc.b $04 dc.b $06 dc.b $04 kp_patternlen dc.b $3F kp_patternmap_lo dc.b #<patnil dc.b #<pat1 dc.b #<pat2 dc.b #<pat3 dc.b #<pat4 dc.b #<pat5 dc.b #<pat6 dc.b #<pat7 dc.b #<pat8 dc.b #<pat9 dc.b #<pat10 dc.b #<pat11 dc.b #<pat12 dc.b #<pat13 kp_patternmap_hi dc.b #>patnil dc.b #>pat1 dc.b #>pat2 dc.b #>pat3 dc.b #>pat4 dc.b #>pat5 dc.b #>pat6 dc.b #>pat7 dc.b #>pat8 dc.b #>pat9 dc.b #>pat10 dc.b #>pat11 dc.b #>pat12 dc.b #>pat13 patnil kp_setinstrument 8,0 kp_settrackregister 0,16 kp_rewind $00 pat1 pat1loop kp_settrackregister $01,$10 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$10 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$10 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$03 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$10 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$10 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$10 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$10 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$03 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$10 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_setinstrument $01,$02 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_rewind [pat1loop-pat1] pat2 pat2loop kp_settrackregister $01,$70 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$68 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$70 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$7C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$78 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_settrackregister $01,$68 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_settrackregister $01,$5C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$68 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$70 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$5C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$70 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$68 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$70 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$7C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$78 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_settrackregister $01,$68 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_settrackregister $01,$54 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$84 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$7C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$78 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$40 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_rewind [pat2loop-pat2] pat3 pat3loop kp_settrackregister $01,$10 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$10 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$10 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$03 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$10 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$10 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$00 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$00 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$00 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$03 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$00 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$00 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_rewind [pat3loop-pat3] pat4 pat4loop kp_settrackregister $01,$70 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$68 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$70 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$7C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$78 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_settrackregister $01,$68 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_settrackregister $01,$5C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$68 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$70 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$5C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$70 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$68 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$70 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$7C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$78 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_settrackregister $01,$68 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_settrackregister $01,$54 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$84 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$8C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$78 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$54 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_rewind [pat4loop-pat4] pat5 pat5loop kp_settrackregister $01,$08 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$08 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$08 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$03 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$08 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$08 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$24 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$24 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$24 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$03 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$24 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$24 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_rewind [pat5loop-pat5] pat6 pat6loop kp_settrackregister $01,$70 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $01,$78 kp_setinstrument $02,$04 kp_settrackregister $01,$7C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$06 kp_settrackregister $01,$84 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $01,$8C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$84 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$7C kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$84 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$90 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$8C kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$7C kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$70 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$60 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$7C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$84 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$02 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$7C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_rewind [pat6loop-pat6] pat7 pat7loop kp_settrackregister $01,$98 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $01,$90 kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$8C kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$84 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$90 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$8C kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$84 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$7C kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $01,$84 kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$14 kp_settrackregister $01,$8C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$7C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_settrackregister $01,$78 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_rewind [pat7loop-pat7] pat8 pat8loop kp_settrackregister $01,$08 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$08 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$08 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$03 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$08 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$08 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$24 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$24 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $03,$0F kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$24 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$03 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_setinstrument $02,$02 kp_setinstrument $02,$02 kp_setinstrument $02,$02 kp_settrackregister $01,$24 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$30 kp_settrackregister $03,$0F kp_setinstrument $02,$02 kp_settrackregister $01,$24 kp_setinstrument $01,$01 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_rewind [pat8loop-pat8] pat9 pat9loop kp_settrackregister $01,$A0 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $01,$8C kp_setinstrument $02,$04 kp_settrackregister $01,$7C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$06 kp_settrackregister $01,$84 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $01,$8C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$84 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$7C kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$84 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$98 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$90 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$7C kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$84 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$70 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$7C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$84 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$02 kp_settrackregister $03,$09 kp_settrackregister $00,$01 kp_settrackregister $01,$78 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_rewind [pat9loop-pat9] pat10 pat10loop kp_settrackregister $01,$98 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $01,$90 kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$8C kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$98 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$90 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$8C kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$84 kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$02 kp_settrackregister $01,$7C kp_settrackregister $03,$0C kp_setinstrument $02,$04 kp_settrackregister $01,$84 kp_setinstrument $02,$04 kp_settrackregister $03,$09 kp_settrackregister $00,$14 kp_settrackregister $01,$70 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$8C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$7C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_settrackregister $01,$78 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_rewind [pat10loop-pat10] pat11 pat11loop kp_settrackregister $01,$8C kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$7C kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$70 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$68 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $01,$70 kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$7C kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $01,$90 kp_setinstrument $02,$05 kp_settrackregister $01,$8C kp_setinstrument $02,$05 kp_settrackregister $01,$84 kp_setinstrument $02,$05 kp_settrackregister $01,$7C kp_setinstrument $02,$05 kp_settrackregister $01,$90 kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$7C kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$70 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$68 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $01,$70 kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$7C kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$70 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $01,$68 kp_setinstrument $02,$05 kp_settrackregister $01,$70 kp_setinstrument $02,$05 kp_settrackregister $01,$7C kp_setinstrument $02,$05 kp_settrackregister $01,$78 kp_setinstrument $02,$05 kp_rewind [pat11loop-pat11] pat12 pat12loop kp_settrackregister $01,$84 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$78 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$70 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$68 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $01,$70 kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$78 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$68 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $01,$70 kp_setinstrument $02,$05 kp_settrackregister $01,$78 kp_setinstrument $02,$05 kp_settrackregister $01,$84 kp_setinstrument $02,$05 kp_settrackregister $01,$8C kp_setinstrument $02,$05 kp_settrackregister $01,$84 kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$04 kp_settrackregister $03,$0C kp_settrackregister $00,$0C kp_settrackregister $01,$7C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$84 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$78 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_settrackregister $01,$70 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_rewind [pat12loop-pat12] pat13 pat13loop kp_settrackregister $01,$98 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$90 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$8C kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$84 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $01,$90 kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$8C kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$02 kp_settrackregister $01,$68 kp_settrackregister $03,$0C kp_setinstrument $02,$05 kp_settrackregister $01,$70 kp_setinstrument $02,$05 kp_settrackregister $01,$78 kp_setinstrument $02,$05 kp_settrackregister $01,$84 kp_setinstrument $02,$05 kp_settrackregister $01,$8C kp_setinstrument $02,$05 kp_settrackregister $01,$84 kp_setinstrument $02,$05 kp_settrackregister $03,$0D kp_settrackregister $00,$04 kp_settrackregister $03,$0C kp_settrackregister $00,$0C kp_settrackregister $01,$68 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$01 kp_settrackregister $01,$7C kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_settrackregister $01,$78 kp_settrackregister $03,$0B kp_setinstrument $01,$03 kp_settrackregister $03,$0A kp_settrackregister $00,$03 kp_rewind [pat13loop-pat13] kp_insmap_lo dc.b #<insnil dc.b #<ins1 dc.b #<ins2 dc.b #<ins3 dc.b #<ins4 dc.b #<ins5 kp_insmap_hi dc.b #>insnil dc.b #>ins1 dc.b #>ins2 dc.b #>ins3 dc.b #>ins4 dc.b #>ins5 kp_volmap_lo dc.b #<volnil dc.b #<vol1 dc.b #<vol2 dc.b #<vol3 dc.b #<vol4 dc.b #<vol5 kp_volmap_hi dc.b #>volnil dc.b #>vol1 dc.b #>vol2 dc.b #>vol3 dc.b #>vol4 dc.b #>vol5 insnil KP_OSCV 0,0,0,0,15 KP_OSCJ 0 volnil KP_VOLV 0,15 KP_VOLJ 0 ins1 KP_OSCV $00,0,1,1,$05 ins1loop KP_OSCV $00,0,1,1,$03 KP_OSCJ [ins1loop-ins1] vol1 KP_VOLV $07,$02 KP_VOLV $06,$01 KP_VOLV $05,$00 vol1loop KP_VOLV $02,$00 KP_VOLJ [vol1loop-vol1] ins2 KP_OSCV $CE,1,0,0,$00 KP_OSCV $58,0,1,0,$00 KP_OSCV $48,0,1,0,$00 ins2loop KP_OSCV $D4,1,0,0,$00 KP_OSCV $D2,1,0,0,$00 KP_OSCJ [ins2loop-ins2] vol2 KP_VOLV $0E,$00 KP_VOLV $0C,$00 KP_VOLV $0A,$00 KP_VOLV $08,$00 KP_VOLV $06,$00 KP_VOLV $04,$00 KP_VOLV $02,$00 KP_VOLV $01,$00 vol2loop KP_VOLV $00,$00 KP_VOLJ [vol2loop-vol2] ins3 ins3loop KP_OSCV $00,0,1,1,$01 KP_OSCV $30,0,1,1,$01 KP_OSCV $90,0,1,1,$01 KP_OSCJ [ins3loop-ins3] vol3 KP_VOLV $0A,$01 KP_VOLV $08,$01 KP_VOLV $07,$01 vol3loop KP_VOLV $06,$01 KP_VOLJ [vol3loop-vol3] ins4 KP_OSCV $24,0,1,1,$01 KP_OSCV $00,0,1,1,$00 ins4loop KP_OSCV $00,0,1,1,$00 KP_OSCJ [ins4loop-ins4] vol4 KP_VOLV $08,$00 vol4loop KP_VOLV $07,$00 KP_VOLJ [vol4loop-vol4] ins5 ins5loop KP_OSCV $00,0,1,1,$00 KP_OSCJ [ins5loop-ins5] vol5 KP_VOLV $0E,$00 KP_VOLV $0C,$00 KP_VOLV $0A,$00 KP_VOLV $09,$00 KP_VOLV $06,$00 KP_VOLV $04,$00 vol5loop KP_VOLV $03,$01 KP_VOLJ [vol5loop-vol5] kp_sequence dc.b $00,$00,$01,$00 dc.b $00,$02,$03,$00 dc.b $00,$04,$05,$00 dc.b $00,$02,$03,$00 dc.b $00,$04,$05,$00 dc.b $00,$06,$03,$00 dc.b $00,$07,$08,$00 dc.b $00,$09,$03,$00 dc.b $00,$0A,$05,$00 dc.b $00,$0B,$03,$00 dc.b $00,$0C,$05,$00 dc.b $00,$0B,$03,$00 dc.b $00,$0D,$05,$00 dc.b $ff dc.w $0030
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r14 push %r15 push %rbp push %rcx push %rsi lea addresses_A_ht+0xe625, %r13 dec %r15 mov (%r13), %si nop nop nop nop xor %rbp, %rbp lea addresses_D_ht+0x16485, %r10 nop nop nop nop and %rcx, %rcx and $0xffffffffffffffc0, %r10 movntdqa (%r10), %xmm6 vpextrq $1, %xmm6, %r14 nop nop nop nop nop xor $38853, %rbp pop %rsi pop %rcx pop %rbp pop %r15 pop %r14 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r14 push %r8 push %rbp push %rcx push %rsi // Store lea addresses_PSE+0xba7d, %r14 nop nop nop nop and %r11, %r11 mov $0x5152535455565758, %rcx movq %rcx, (%r14) nop nop nop nop nop cmp %r11, %r11 // Faulty Load lea addresses_PSE+0x3a7d, %rbp add %r8, %r8 movb (%rbp), %cl lea oracles, %r14 and $0xff, %rcx shlq $12, %rcx mov (%r14,%rcx,1), %rcx pop %rsi pop %rcx pop %rbp pop %r8 pop %r14 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False, 'NT': True, 'congruent': 3, 'same': False}} {'33': 5082} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
db DEX_SLOWBRO ; pokedex id db 95 ; base hp db 75 ; base attack db 110 ; base defense db 30 ; base speed db 80 ; base special db WATER ; species type 1 db PSYCHIC ; species type 2 db 75 ; catch rate db 164 ; base exp yield INCBIN "pic/bmon/slowbro.pic",0,1 ; 77, sprite dimensions dw SlowbroPicFront dw SlowbroPicBack ; attacks known at lvl 0 db CONFUSION db DISABLE db HEADBUTT db 0 db 0 ; growth rate ; learnset tmlearn 1,5,6,8 tmlearn 9,10,11,12,13,14,15,16 tmlearn 17,18,19,20 tmlearn 26,27,28,29,30,31,32 tmlearn 33,34,38,39,40 tmlearn 44,45,46 tmlearn 49,50,53,54,55 db 0 ; padding
; lookup table for output format specifiers ; 05.2008 aralbrec XLIB jumptbl_printf ; output format specifiers: "bcdeEfFiIMnopPsuxX" ; place most common first, library alternatives in comments .jumptbl_printf defb 'd', 195 ; signed integer LIB stdio_out_ld ; stdio_out_d defw stdio_out_ld defb 'c', 195 ; character LIB stdio_out_c defw stdio_out_c defb 's', 195 ; string LIB stdio_out_s defw stdio_out_s defb 'u', 195 ; unsigned integer LIB stdio_out_lu ; stdio_out_u defw stdio_out_lu defb 'x', 195 ; unsigned hexadecimal integer LIB stdio_out_lx ; stdio_out_x defw stdio_out_lx defb 'i', 195 ; signed integer LIB stdio_out_ld ; stdio_out_d defw stdio_out_ld defb 'X', 195 ; unsigned hexadecimal integer using capitals LIB stdio_out_caplx ; stdio_out_capx defw stdio_out_caplx defb 'b', 195 ; unsigned binary integer LIB stdio_out_lb ; stdio_out_b defw stdio_out_lb defb 'o', 195 ; unsigned octal integer LIB stdio_out_lo ; stdio_out_o defw stdio_out_lo defb 'p', 195 ; pointer value LIB stdio_out_lp ; stdio_out_p defw stdio_out_lp defb 'P', 195 ; pointer value using capitals LIB stdio_out_caplp ; stdio_out_capp defw stdio_out_caplp defb 'n', 195 ; store number of bytes output thus far LIB stdio_out_n defw stdio_out_n ; defb 'f', 195 ; defw ; defb 'e', 195 ; defw ; defb 'F', 195 ; defw ; defb 'E', 195 ; defw defb 'I', 195 ; IPv4 address LIB stdio_out_capi defw stdio_out_capi defb 'M', 195 ; EUI-48 / MAC-48 address LIB stdio_out_capm defw stdio_out_capm defb 0 ; end of table
; A006007: 4-dimensional analog of centered polygonal numbers: a(n) = n(n+1)*(n^2+n+4)/12. ; 0,1,5,16,40,85,161,280,456,705,1045,1496,2080,2821,3745,4880,6256,7905,9861,12160,14840,17941,21505,25576,30200,35425,41301,47880,55216,63365,72385,82336,93280,105281,118405,132720,148296,165205,183521,203320,224680,247681,272405,298936,327360,357765,390241,424880,461776,501025,542725,586976,633880,683541,736065,791560,850136,911905,976981,1045480,1117520,1193221,1272705,1356096,1443520,1535105,1630981,1731280,1836136,1945685,2060065,2179416,2303880,2433601,2568725,2709400,2855776,3008005,3166241,3330640,3501360,3678561,3862405,4053056,4250680,4455445,4667521,4887080,5114296,5349345,5592405,5843656,6103280,6371461,6648385,6934240,7229216,7533505,7847301,8170800 add $0,1 bin $0,2 add $0,1 pow $0,2 div $0,3
; A138425: a(n) = (prime(n)^5 - prime(n))/3. ; 10,80,1040,5600,53680,123760,473280,825360,2145440,6837040,9543040,23114640,38618720,49002800,76448320,139398480,238308080,281532080,450041680,601409760,691023840,1025685440,1313013520,1861353120,2862446720,3503366800,3864246880,4675172400,5128746480,6141450560,11012789760,12859829840,16087241440,17296281520,24479925200,26167575200,31796330800,38354538960,43297328480,51654630640,61255332240,64754748240,84731633920,89261728000,98903093520,104026533600,139409067280,183824359040,200912996560 seq $0,40 ; The prime numbers. sub $1,$0 pow $0,5 add $1,$0 div $1,3 mov $0,$1
/*************************************************************************** * Copyright (C) by GFZ Potsdam * * * * You can redistribute and/or modify this program under the * * terms of the SeisComP Public License. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * SeisComP Public License for more details. * ***************************************************************************/ template <class TYPE> int minmax(int n, const TYPE *f, int i1, int i2, TYPE *fmin, TYPE *fmax) { int i; /* if(i2<i1) { i=i1; i1=i2; i2=i; } */ if(i1<0) i1=0; if(i2>n) i2=n; *fmin = *fmax = f[i1]; f += i1+1; for (i=i1+1; i<i2; i++, f++) { if(*f > *fmax) *fmax = *f; if(*f < *fmin) *fmin = *f; } return 0; } template <class TYPE> int find_max(int n, const TYPE *f, int i1, int i2, int *imax, TYPE *fmax) { int i; if(i1<0) i1=0; if(i2>n) i2=n; *fmax = f[i1]; *imax = i1; f += i1+1; for (i=i1+1; i<i2; i++, f++) { if(*f > *fmax) { *imax = i; *fmax = *f; } } return 0; } template <typename TYPE> int find_absmax(int n, const TYPE *f, int i1, int i2, TYPE offset=0) { int i; if(i1<0) i1=0; if(i2>n) i2=n; double fmax = fabs(f[i1]-offset); int imax = i1; for (i=i1+1; i<i2; i++) { double ff = fabs(f[i]-offset); if(ff > fmax) { imax = i; fmax = ff; } } return imax; } template <class TYPE> void find_minmax(int &lmin, int &lmax, int n, const TYPE *f, int i1, int i2, TYPE offset=0) { int i; if(i1<0) i1=0; if(i2>n) i2=n; TYPE fmax = (f[i1]-offset); TYPE fmin = fmax; lmin = i1; lmax = i1; for (i=i1+1; i<i2; i++) { TYPE ff = f[i]-offset; if (ff > fmax) { lmax = i; fmax = ff; } else if (ff < fmin) { lmin = i; fmin = ff; } } } template <class TYPE> int minmax(std::vector<TYPE> const &f, int i1, int i2, TYPE *fmin, TYPE *fmax) { const TYPE *f0 = &f[0]; int n = f.size(); return minmax(n, f0, i1, i2, fmin, fmax); } template <class TYPE> int find_max(std::vector<TYPE> const &f, int i1, int i2, int *imax, TYPE *fmax) { const TYPE *f0 = &f[0]; int n = f.size(); return find_max(n, f0, i1, i2, imax, fmax); }
78_Header: sHeaderInit ; Z80 offset is $CB7F sHeaderPatch 78_Patches sHeaderTick $01 sHeaderCh $01 sHeaderSFX $80, $05, 78_FM5, $F2, $04 78_FM5: sPatFM $00 dc.b nCs3 78_Loop1: dc.b $02, sHold, nB2, $01, sHold saTranspose $02 sLoop $00, $26, 78_Loop1 sStop 78_Patches: ; Patch $00 ; $3B ; $3C, $39, $30, $31, $DF, $1F, $1F, $DF ; $04, $05, $04, $01, $04, $04, $04, $02 ; $FF, $0F, $1F, $AF, $29, $20, $0F, $80 spAlgorithm $03 spFeedback $07 spDetune $03, $03, $03, $03 spMultiple $0C, $00, $09, $01 spRateScale $03, $00, $00, $03 spAttackRt $1F, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $04, $04, $05, $01 spSustainLv $0F, $01, $00, $0A spDecayRt $04, $04, $04, $02 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $29, $0F, $20, $00
#include "column1D.h" #include "ui_column1D.h" #include <QDebug> #include <iostream> #include <QFileInfo> #include <QFileDialog> #include <fstream> #include <sstream> column1D::column1D(QWidget *parent) : QWidget(parent), ui(new Ui::column1D) { ui->setupUi(this); // connect(this->ui->load1DFile_PB, SIGNAL(clicked()), this, SLOT(on_load1DFile_PB_clicked())); scatterStyleList<<QCPScatterStyle::ssNone<<QCPScatterStyle::ssDot <<QCPScatterStyle::ssCross<<QCPScatterStyle::ssPlus<<QCPScatterStyle::ssCircle<<QCPScatterStyle::ssDisc<<QCPScatterStyle::ssSquare<<QCPScatterStyle::ssDiamond<<QCPScatterStyle::ssStar<<QCPScatterStyle::ssTriangle<<QCPScatterStyle::ssTriangleInverted<<QCPScatterStyle::ssCrossSquare<<QCPScatterStyle::ssPlusSquare<<QCPScatterStyle::ssCrossCircle<<QCPScatterStyle::ssPlusCircle; lineStyleList<<Qt::PenStyle::SolidLine<<Qt::PenStyle::DashLine<<Qt::PenStyle::DotLine<<Qt::PenStyle::DashDotLine<<Qt::PenStyle::DashDotDotLine; this->ui->plot1DFileX_Combo->setView(new QListView); this->ui->plot1DFile_Table->setColumnWidth(0, 60); this->ui->plot1DFile_Table->setColumnWidth(1, 60); this->ui->plot1DFile_Table->setColumnWidth(2, 60); this->ui->plot1DRelationFile_Table->setColumnWidth(0, 60); this->ui->plot1DRelationFile_Table->setColumnWidth(1, 60); this->ui->plot1DRelationFile_Table->setColumnWidth(2, 60); } column1D::~column1D() { delete ui; } int column1D::getColumns(){ return columns; } QVector<double> column1D::returnX(){ int dataRows=dataFiltered.count(); int colX=this->ui->plot1DFileX_Combo->currentIndex(); QVector<double> x(dataRows); qDebug()<<xmin1D<<xmax1D<<dataRows<<"xminmax"<<colX; if (dataRows>0) { xmin1D=dataFiltered[0][colX]; xmax1D=dataFiltered[0][colX]; } qDebug()<<xmin1D<<xmax1D<<dataRows<<"xminmax"; for (int i=0; i<dataRows; i++) { x[i]=dataFiltered[i][colX]; if(x[i]<=xmin1D) xmin1D=x[i]; if(x[i]>=xmax1D) xmax1D=x[i]; } qDebug()<<xmin1D<<xmax1D<<dataRows<<"xminmax"; return x; } double column1D::returnXMin(){ return xmin1D; } double column1D::returnXMax(){ return xmax1D; } QVector<double> column1D::returnY(int colY){ int dataRows=dataFiltered.count(); QVector<double> y(dataRows); qDebug()<<ymin1D<<ymax1D<<dataRows<<"yminmax"<<colY; if (dataRows>0) { ymin1D=dataFiltered[0][colY]; ymax1D=dataFiltered[0][colY]; } qDebug()<<ymin1D<<ymax1D<<dataRows<<"yminmax"; for (int i=0; i<dataRows; i++) { y[i]=dataFiltered[i][colY]; if(y[i]<=ymin1D) ymin1D=y[i]; if(y[i]>=ymax1D) {ymax1D=y[i];qDebug()<<y[i];} } qDebug()<<ymin1D<<ymax1D<<dataRows<<"yminmax"; // qDebug()<<xmin1D<<xmax1D<<dataRows<<"yminmax"; return y; } double column1D::returnYMin(){ return ymin1D; } double column1D::returnYMax(){ return ymax1D; } int column1D::filter(){ if(dataFiltered.count()!=0){ dataFiltered.clear(); } std::ofstream output1; std::ofstream output2; std::ofstream output3; std::string str; //str="filter_before.txt"; //const char *outdir1=str.c_str(); //output1.open(outdir1); //output1 << "size" << "\n"; //output1 << sizeof(vtkData)<<"\n"; //for(int i=0;i<rows;i++){ //output1 << "i:" << i << ", vtkData:"<<vtkData[i][0] << "\n"; //} //output1.close(); //str="filter.txt"; //const char *outdir=str.c_str(); //output2.open(outdir); for(int i=0;i<rows;i++){ //output2 << "i:" << i << ", vtkData:"<<vtkData[i][1] << "\n"; if(filter1DData(vtkData[i])){ dataFiltered.append(vtkData[i]); } } //output2.close(); qDebug()<<"rows:"<<rows; return dataFiltered.count(); } int column1D::getFilteredCount(){ if (loaded) { filter(); return dataFiltered.count(); } return 0; } void column1D::on_load1DFile_PB_clicked(){ QFileDialog filedialog; filedialog.setFileMode(QFileDialog::AnyFile); filedialog.setNameFilter(tr("Input (*.*)")); filedialog.setOption(QFileDialog::ReadOnly); QString load=filedialog.getOpenFileName(); qDebug()<<"Filename:"<<load; if (!load.isEmpty()) { columns=loadData1D(load); loaded = true; double *dataHold= new double[rows]; QFileInfo filehold(load); // outputScalar(0,xmax,ymax,zmax); while(this->ui->plot1DFileX_Combo->count()>0){ this->ui->plot1DFileX_Combo->removeItem(0); } for (int i=0; i<columns; i++) { this->ui->plot1DFileX_Combo->addItem(QString::fromStdString(std::to_string(i+1))); } while(this->ui->plot1DFileY_LW->count()>0){ this->ui->plot1DFileY_LW->takeItem(0); } for (int i = 0; i < columns; ++i) { this->ui->plot1DFileY_LW->addItem(QString::fromStdString(std::to_string(i+1))); this->ui->plot1DFileY_LW->item(i)->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsSelectable ); this->ui->plot1DFileY_LW->item(i)->setCheckState(Qt::Unchecked); } this->ui->plot1DFileY_LW->sortItems(); this->ui->plot1DRelationFile_Combo->setEnabled(true); this->ui->plot1DRelationValueFile_LE->setEnabled(true); while(this->ui->plot1DColFile_Combo->count()>0){ this->ui->plot1DColFile_Combo->removeItem(0); } for (int i = 0; i < columns; ++i) { this->ui->plot1DColFile_Combo->addItem(QString::fromStdString(std::to_string(i+1))); } while (this->ui->plot1DLines_LW->count() > 0) { this->ui->plot1DLines_LW->takeItem(0); } while (this->ui->plot1DRelationFile_Table->rowCount() > 0) { this->ui->plot1DRelationFile_Table->removeRow(0); } this->ui->plot1DFileName_LE->setText(filehold.fileName()); printstatus = QString::fromStdString(std::to_string(columns)); this->ui->plot1DFileColNum_LE->setText(printstatus); // printstatus = QString::fromStdString("0 - "+std::to_string(xmax)); // this->ui->plot1Dxminxmax_LE->setText(printstatus); // // printstatus = QString::fromStdString("0 - "+std::to_string(ymax)); // this->ui->plot1Dyminymax_LE->setText(printstatus); // // printstatus = QString::fromStdString("0 - "+std::to_string(zmax)); // this->ui->plot1Dzminzmax_LE->setText(printstatus); // this->ui->plot1DFile_Table->clearContents(); while(this->ui->plot1DFile_Table->rowCount()>0) { this->ui->plot1DFile_Table->removeRow(0); } for(int i=0;i<columns;++i){ for (int j=0;j<rows;++j){ dataHold[j]=vtkData[j][i]; } this->ui->plot1DFile_Table->insertRow(this->ui->plot1DFile_Table->rowCount()); printstatus = QString::fromStdString(std::to_string(getMin(dataHold,rows))); qDebug()<<"column:"<<i<<rows<<this->ui->plot1DFile_Table->rowCount(); qDebug()<<"min:"<<printstatus; this->ui->plot1DFile_Table->setItem(this->ui->plot1DFile_Table->rowCount()-1,0,new QTableWidgetItem(printstatus)); printstatus = QString::fromStdString(std::to_string(getMax(dataHold,rows))); qDebug()<<"max:"<<printstatus; this->ui->plot1DFile_Table->setItem(this->ui->plot1DFile_Table->rowCount()-1,1,new QTableWidgetItem(printstatus)); printstatus = QString::fromStdString(std::to_string(getAvg(dataHold,rows))); qDebug()<<"avg:"<<printstatus; this->ui->plot1DFile_Table->setItem(this->ui->plot1DFile_Table->rowCount()-1,2,new QTableWidgetItem(printstatus)); } // this->ui->plot1DFile_Table->sortItems(0); delete[] dataHold; } } int column1D::loadData1D(QString filedir){ //First we need to decide whether the first line of the file needs to be kept std::ifstream input; std::ofstream output; std::string a; int i=0,x=0,y=0,z=0,columnNumber=0; float test=0; long rowNumber=0; int count1=0; int count2=0; QFileInfo filehold(filedir); QByteArray dir1=filedir.toLatin1(); const char *dir=dir1.data(); qDebug()<<dir; input.open(dir); std::string str,line,line1,line2; std::getline(input,line1); std::getline(input,line2); std::istringstream iss1(line1); std::istringstream iss2(line2); input.close(); while(iss1 >> a){ count1++; } while(iss2 >> a){ qDebug()<<QString::fromStdString(a); count2++; } columnNumber=count2; for (int k=0;k<columnNumber;++k){ iss2 >> std::scientific; iss2 >> test; qDebug()<< "test:"<<test; } input.open(dir); for (rowNumber=0; std::getline(input, line); rowNumber++) { } input.close(); qDebug()<<"Rownumber"<<rowNumber<<count1<<count2; if (count1!=count2){ // input.open(dir); // std::getline(input,line1); // std::istringstream iss1(line1); // iss1 >> x >> y >> z; // // input.close(); rowNumber--; }else{ iss1 >> x; qDebug()<<"x:"<<x; if(x==0){ rowNumber--; } // std::ifstream read(dir, std::ios_base::ate );//open file // int length = 0; // // char c = '\0'; // // if( read ) // { // length = read.tellg();//Get file size // // // loop backward over the file // // for(int i = length-2; i > 0; i-- ) // { // read.seekg(i); // c = read.get(); // if( c == '\r' || c == '\n' )//new line? // break; // } // std::getline(read, line1);//read last line // std::istringstream iss1(line1); // iss1 >> x >> y >> z; // read.close(); // // } } vtkData= new double*[rowNumber]; for (i=0;i<rowNumber;++i){ vtkData[i] = new double[columnNumber]; } input.open(dir); if (count1!=count2){ std::getline(input,line1); std::istringstream iss1(line1); }else{ iss1 >> x; qDebug()<<"x:"<<x; // if(isnan(x)){ // std::getline(input,line1); // std::istringstream iss1(line1); // } } for (int j=0;j<rowNumber;++j){ std::getline(input,line); std::istringstream iss(line); std::cout << line <<"\n"; for (int k=0;k<columnNumber;++k){ iss >> a; std::istringstream iss1(a); iss1 >> std::scientific; iss1 >> vtkData[j][k]; if(iss1.fail()){ std::cout << "fail,"; // iss.ignore(256,' '); }else{ //std::cout << vtkData[j][k] <<","; } } std::cout<<"\n"; } input.close(); //str="load.txt"; //const char *outdir=str.c_str(); // //output.open(outdir); //for(int i=0;i<rowNumber;i++){ // output << "i:" << i << ", vtkData:"; // for(int j=0;j<columnNumber;j++){ // output<<vtkData[i][j] << " "; // } // output << "\n"; //} //output.close(); // xmax=x; // ymax=y; // zmax=z; rows = rowNumber; return columnNumber; } bool column1D::filter1DData(double *data){ bool flagHolder=true; qDebug()<<"data:"<<*data<<data[0]<<data[1]<<data[2]; for(int i=0;i<this->ui->plot1DRelationFile_Table->rowCount();i++){ int relationCol=this->ui->plot1DRelationFile_Table->item(i, 0)->text().toInt()-1; double value=this->ui->plot1DRelationFile_Table->item(i, 2)->text().toDouble(); std::string relation=this->ui->plot1DRelationFile_Table->item(i,1)->text().toStdString(); // qDebug()<<"relation:"<<relationCol<<relation.c_str()<<value; if(relation=="="){ if (data[relationCol]==value) { // flagHolder*=true; }else{ flagHolder=false; } }else if(relation==">"){ if (data[relationCol]>value) { // flagHolder*=true; }else{ flagHolder=false; } }else if(relation==">="){ if (data[relationCol]>=value) { // flagHolder*=true; }else{ flagHolder=false; } }else if(relation=="<"){ if (data[relationCol]<value) { // flagHolder*=true; }else{ flagHolder=false; } }else if(relation=="<="){ if (data[relationCol]<=value) { // flagHolder*=true; }else{ flagHolder=false; } } } return flagHolder; } void column1D::on_plot1DAddRelationFile_PB_released(){ QString item; int row; qDebug()<<"Add button pushed"; if ((this->ui->plot1DColFile_Combo->count()==0) | this->ui->plot1DRelationValueFile_LE->text().isEmpty()){ }else{ this->ui->plot1DRelationFile_Table->setEnabled(true); row=this->ui->plot1DRelationFile_Table->rowCount(); qDebug()<<row; this->ui->plot1DRelationFile_Table->insertRow(row); // row=row; item=this->ui->plot1DColFile_Combo->currentText(); this->ui->plot1DRelationFile_Table->setItem(row,0,new QTableWidgetItem(item)); item=this->ui->plot1DRelationFile_Combo->currentText(); this->ui->plot1DRelationFile_Table->setItem(row,1,new QTableWidgetItem(item)); item=this->ui->plot1DRelationValueFile_LE->text(); this->ui->plot1DRelationFile_Table->setItem(row,2,new QTableWidgetItem(item)); // item=this->ui->RGBA_LE->text(); // this->ui->RGBScalar_Table->setItem(row,4,new QTableWidgetItem(item)); this->ui->plot1DRelationFile_Table->sortItems(0,Qt::AscendingOrder); } } void column1D::on_plot1DFileY_LW_itemClicked(QListWidgetItem* item){ if(item->checkState()){ this->ui->plot1DLines_LW->addItem(item->text()); // this->ui->plot1DLines_LW->sortItems(); lineStyle.push_back(QPen()); scatterStyle.push_back(int()); lineName.push_back(QString()); this->ui->plot1DLines_LW->setCurrentItem(this->ui->plot1DLines_LW->findItems(item->text(), Qt::MatchExactly).first()); this->ui->plot1DLineRGBR_LE->setText("0"); this->ui->plot1DLineRGBG_LE->setText("0"); this->ui->plot1DLineRGBB_LE->setText("0"); this->ui->plot1DLineWeight_LE->setText("2"); this->ui->plot1DScatterStyle_Combo->setCurrentIndex(0); this->ui->plot1DLineStyle_Combo->setCurrentIndex(0); this->ui->plot1DLineName_LE->setText(QString::fromStdString("line"+std::to_string(lineStyle.count()))); on_plot1DSetLine_PB_released(); }else{ if(!(this->ui->plot1DLines_LW->findItems(item->text(), Qt::MatchExactly).isEmpty())){ int rownum=this->ui->plot1DLines_LW->row(this->ui->plot1DLines_LW->findItems(item->text(), Qt::MatchExactly).first()); this->ui->plot1DLines_LW->takeItem(rownum); lineName.remove(rownum); lineStyle.remove(rownum); scatterStyle.remove(rownum); qDebug()<<"rownum" << rownum; } } if (this->ui->plot1DLines_LW->count()==0) { this->ui->plot1DSetLine_PB->setEnabled(false); }else{ this->ui->plot1DSetLine_PB->setEnabled(true); } qDebug()<<"check:"<<item->checkState(); // emit figureReplot(); } void column1D::on_plot1DSetLine_PB_released(){ int R=this->ui->plot1DLineRGBR_LE->text().toDouble(); int G=this->ui->plot1DLineRGBG_LE->text().toDouble(); int B=this->ui->plot1DLineRGBB_LE->text().toDouble(); int weight=this->ui->plot1DLineWeight_LE->text().toDouble(); int index=this->ui->plot1DLines_LW->currentRow(); int psIndex=this->ui->plot1DLineStyle_Combo->currentIndex(); int sIndex=this->ui->plot1DScatterStyle_Combo->currentIndex(); QString name=this->ui->plot1DLineName_LE->text(); lineStyle[index].setBrush(QColor(R,G,B)); lineStyle[index].setWidth(weight); lineStyle[index].setStyle(lineStyleList[psIndex]); scatterStyle[index]=sIndex; lineName[index]=name; qDebug()<< "index:" << index << weight << R << G << B << name; } void column1D::on_plot1DLines_LW_currentRowChanged(int rowNum){ if(rowNum!=-1){ this->ui->plot1DLineRGBR_LE->setText(QString::fromStdString(std::to_string(lineStyle[rowNum].color().red()))); this->ui->plot1DLineRGBG_LE->setText(QString::fromStdString(std::to_string(lineStyle[rowNum].color().green()))); this->ui->plot1DLineRGBB_LE->setText(QString::fromStdString(std::to_string(lineStyle[rowNum].color().blue()))); this->ui->plot1DLineWeight_LE->setText(QString::fromStdString(std::to_string(lineStyle[rowNum].width()))); this->ui->plot1DScatterStyle_Combo->setCurrentIndex(scatterStyle[rowNum]); this->ui->plot1DLineStyle_Combo->setCurrentIndex(lineStyleList.indexOf(lineStyle[rowNum].style())); this->ui->plot1DLineName_LE->setText(lineName[rowNum]); } } void column1D::on_plot1DRemoveRelationFile_PB_released(){ if(this->ui->plot1DRelationFile_Table->rowCount()>0){ this->ui->plot1DRelationFile_Table->removeRow(this->ui->plot1DRelationFile_Table->currentRow()); } } QPen column1D::getLineStyle(int rowNumber){ return lineStyle[rowNumber]; } QCPScatterStyle column1D::getScatterStyle(int rowNumber){ return scatterStyleList[scatterStyle[rowNumber]]; } QString column1D::getLineName(int rowNumber){ return lineName[rowNumber]; } double column1D::getMin(double *list,int length){ double minValue; minValue=list[0]; for(int i=0;i<length;++i){ if(list[i]<minValue){ minValue=list[i]; } } return minValue; } double column1D::getMax(double *list,int length){ double maxValue; maxValue=list[0]; for(int i=0;i<length;++i){ if(list[i]>maxValue){ maxValue=list[i]; } } return maxValue; } double column1D::getAvg(double *list,int length){ double avgValue; avgValue=0; for(int i=0;i<length;++i){ avgValue=avgValue+list[i]; } avgValue=avgValue/length; return avgValue; } void column1D::paintEvent(QPaintEvent *) { QStyleOption opt; opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); // qDebug()<<"painting border"; }
#include "pf/base/log.h" #include "pf/sys/memory/dynamic_allocator.h" namespace pf_sys { namespace memory { DynamicAllocator::DynamicAllocator() { __ENTER_FUNCTION pointer_ = NULL; size_ = 0; __LEAVE_FUNCTION } DynamicAllocator::~DynamicAllocator() { __ENTER_FUNCTION free(); __LEAVE_FUNCTION } void *DynamicAllocator::malloc(size_t size) { __ENTER_FUNCTION if (size_ == size) return pointer_; void *pointer = reinterpret_cast<void *>(new char[size]); if (NULL == pointer) { Assert(false); return NULL; } memset(pointer, 0, size); if (pointer_ != NULL) { size_t copysize = size > size_ ? size_ : size; memcpy(pointer, pointer_, copysize); free(); } pointer_ = pointer; if (pointer_ != NULL) size_ = size; return pointer_; __LEAVE_FUNCTION return NULL; } size_t DynamicAllocator::getsize() const { return size_; } void DynamicAllocator::free() { __ENTER_FUNCTION char *pointer = reinterpret_cast<char*>(pointer_); SAFE_DELETE_ARRAY(pointer); size_ = 0; __LEAVE_FUNCTION } void *DynamicAllocator::getpointer() { __ENTER_FUNCTION return pointer_; __LEAVE_FUNCTION return NULL; } }; //namespace memory }; //namespace pf_sys
; A229611: Expansion of 1/((1-x)^3*(1-11x)) ; 1,14,160,1770,19485,214356,2357944,25937420,285311665,3138428370,34522712136,379749833574,4177248169405,45949729863560,505447028499280,5559917313492216,61159090448414529,672749994932559990,7400249944258160080,81402749386839761090,895430243255237372221,9849732675807611094684,108347059433883722041800,1191817653772720942460100,13109994191499930367061425,144209936106499234037676026,1586309297171491574414436664,17449402268886407318558803710,191943424957750480504146841245 lpb $0 mov $2,$0 seq $2,14881 ; a(1)=1, a(n) = 11*a(n-1)+n. add $3,$2 mov $4,$2 min $4,1 sub $0,$4 lpe mov $0,$3 add $0,1
; ; Devilishly simple Spectrum Routines ; ; getk() Read key status ; ; 17/5/99 djm ; ; ; $Id: getk.asm,v 1.6 2016/03/09 22:25:54 dom Exp $ ; SECTION code_clib PUBLIC getk PUBLIC _getk .getk ._getk ld h,0 ld a,(23560) ld l,a and a ret z xor a ld (23560),a ret
copyright zengfr site:http://github.com/zengfr/romhack 036C82 move.b #$12, ($d1,A0) [enemy+C2] 036C88 jsr $62ee.w [enemy+D1] 036C92 bmi $36ca0 [enemy+D1] 036CA4 move.b #$1a, ($d1,A0) [enemy+C2] 036CAA movea.l #$83e04, A4 [enemy+D1] 036D0C bmi $36d1c [enemy+D1] copyright zengfr site:http://github.com/zengfr/romhack
; A240437: Number of non-palindromic n-tuples of 5 distinct elements. ; 0,20,100,600,3000,15500,77500,390000,1950000,9762500,48812500,244125000,1220625000,6103437500,30517187500,152587500000,762937500000,3814695312500,19073476562500,95367421875000,476837109375000,2384185742187500,11920928710937500,59604644531250000 mov $3,$0 div $0,2 mov $1,5 pow $1,$3 mov $2,5 pow $2,$0 sub $1,$2 div $1,4 mul $1,20
/* * Copyright 2021 Google LLC * * 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 <gtest/gtest.h> #include <stdio.h> #include "bitpattern.h" TEST(BitPattern, Neighbors) { BitPattern p = ParsePattern("X--X---X" "--------" "--------" "X-------" "-------X" "--------" "-------X" "XXX-----"); BitPattern expected = ParsePattern("-XX-X-X-" "XXXXX-XX" "XX------" "-X----XX" "XX----X-" "------XX" "XXXX--X-" "XXXX--XX"); EXPECT_EQ(Neighbors(p), expected); } TEST(BitPattern, UniqueInEdges) { BitPattern p1 = ParsePattern("XXXX-XXX" "--------" "X------X" "X-------" "X------X" "-------X" "X------X" "XXXXXXXX"); BitPattern expected1 = ParsePattern("----X---" "--------" "--------" "--------" "--------" "--------" "--------" "--------"); BitPattern expectedFirstLast = ParsePattern("----X---" "X------X" "--------" "-------X" "--------" "X-------" "--------" "--------"); EXPECT_EQ(FirstLastInEdges(~p1), expectedFirstLast); EXPECT_EQ(UniqueInEdges(~p1), expected1); BitPattern p2 = ParsePattern("X-XXXXXX" "X-------" "X------X" "X------X" "X------X" "-------X" "X------X" "XXXXXXX-"); BitPattern expected2 = ParsePattern("-X------" "--------" "--------" "--------" "--------" "X-------" "--------" "-------X"); EXPECT_EQ(UniqueInEdges(~p2), expected2); } TEST(BitPattern, RowToFirstRow) { for (int i = 0; i < 1000; ++i) { BitPattern p = RandomPattern(); Move move = rand() % 64; BitPattern row = GetRow(move); LastRow result = RowToLastRow(p, row, move & 56); EXPECT_TRUE(result < 256); EXPECT_EQ((p & row), LastRowToRow(result, move & 56)); } } TEST(BitPattern, ColumnToFirstRow) { for (int i = 0; i < 1000; ++i) { BitPattern p = RandomPattern(); Move move = rand() % 64; BitPattern column = GetColumn(move); LastRow result = ColumnToLastRow(p, column, move & 7); EXPECT_TRUE(result < 256); EXPECT_EQ((p & column), LastRowToColumn(result, move & 7)); } } TEST(BitPattern, DiagonalToFirstRow) { for (int i = 0; i < 1000; ++i) { BitPattern p = RandomPattern(); Move move = rand() % 64; BitPattern diagonal = rand() % 2 ? GetDiag7(move) : GetDiag9(move); LastRow result = DiagonalToLastRow(p, diagonal); EXPECT_TRUE(result < 256); EXPECT_EQ((p & diagonal), LastRowToDiagonal(result, diagonal)); } }
.data .code bar proc mov rax, rcx ret bar endp end
DATA SEGMENT NUM1 DB ? NUM2 DB ? RESULT DB ? MSG1 DB 10,13,"Enter num 1 : $" MSG2 DB 10,13,"Enter num 2 : $" MSG3 DB 10,13,"Sum : $" ENDS CODE SEGMENT ASSUME DS:DATA CS:CODE START: MOV AX,DATA MOV DS,AX LEA DX,MSG1 MOV AH,9 INT 21H MOV CX,2 MOV AH,1 INT 21H ADD AL,30H MOV NUM1,AL LEA DX,MSG2 MOV AH,9 INT 21H MOV CX,2 MOV AH,1 INT 21H ADD AL,30H MOV NUM2,AL ADD AL,NUM1 MOV RESULT,AL MOV AH,0 AAA ADD AH,30H ADD AL,30H MOV BX,AX LEA DX,MSG3 MOV AH,9 INT 21H MOV AH,2 MOV DL,BH INT 21H MOV AH,2 MOV DL,BL INT 21H MOV AH,4CH INT 21H ENDS END START
; A225612: Partial sums of the binomial coefficients C(4*n,n). ; 1,5,33,253,2073,17577,152173,1336213,11854513,105997793,953658321,8622997453,78291531921,713305091521,6518037055321,59712126248041,548239063327621,5043390644753269,46475480410336709,428936432074181109,3964252574286355429,36683487291377014309,339836921193302223049,3151501991054384330449,29253220344161136838549,271772490064498257854053,2526873986952417716748469,23511581938654184889681341,218915762884320927909038421,2039615580664021750974064501,19014154341461430660434138597 lpb $0 mov $2,4 mul $2,$0 bin $2,$0 sub $0,1 add $3,$2 lpe mov $0,$3 add $0,1
/******************************************************************************* Copyright(c) 2015-2019 LORD Corporation. All rights reserved. MIT Licensed. See the included LICENSE.txt for a copy of the full MIT License. *******************************************************************************/ #include "stdafx.h" #include "InertialNode.h" #include "mscl/Types.h" #include "mscl/Communication/SerialConnection.h" #include "mscl/MicroStrain/MIP/Commands/MIP_Commands.h" #include "mscl/MicroStrain/MIP/MipNodeFeatures.h" #include "mscl/MicroStrain/MIP/Packets/MipPacket.h" #include "mscl/MicroStrain/MIP/MipNode_Impl.h" #include <algorithm> namespace mscl { InertialNode::InertialNode(Connection connection): m_impl(std::make_shared<MipNode_Impl>(connection)) { } InertialNode::InertialNode(std::shared_ptr<MipNode_Impl> impl) : m_impl(impl) { } const MipNodeFeatures& InertialNode::features() const { return m_impl->features(); } MipDataPackets InertialNode::getDataPackets(uint32 timeout, uint32 maxPackets) { MipDataPackets packets; m_impl->getDataPackets(packets, timeout, maxPackets); return packets; } GenericMipCmdResponse InertialNode::doCommand(GenericMipCommand::Response& response, const ByteStream& command, bool verifySupported) const { return m_impl->doCommand(response, command, verifySupported); } std::string InertialNode::deviceName(const std::string& serial) { //replace any unsupported sensorcloud characters std::string sensorcloudFilteredName = "inertial-" + serial; Utils::filterSensorcloudName(sensorcloudFilteredName); return sensorcloudFilteredName; } Connection& InertialNode::connection() { return m_impl->connection(); } const Timestamp& InertialNode::lastCommunicationTime() const { return m_impl->lastCommunicationTime(); } DeviceState InertialNode::lastDeviceState() const { return m_impl->lastDeviceState(); } Version InertialNode::firmwareVersion() const { return m_impl->firmwareVersion(); } InertialModels::NodeModel InertialNode::model() const { return InertialModels::nodeFromModelString(modelNumber()); } std::string InertialNode::modelName() const { return m_impl->modelName(); } std::string InertialNode::modelNumber() const { return m_impl->modelNumber(); } std::string InertialNode::serialNumber() const { return m_impl->serialNumber(); } std::string InertialNode::lotNumber() const { return m_impl->lotNumber(); } std::string InertialNode::deviceOptions() const { return m_impl->deviceOptions(); } uint32 InertialNode::totalPackets() { return m_impl->totalPackets(); } void InertialNode::timeout(uint64 timeout) { m_impl->timeout(timeout); } uint64 InertialNode::timeout() const { return m_impl->timeout(); } std::string InertialNode::name() { return deviceName(serialNumber()); } bool InertialNode::ping() { return m_impl->ping(); } void InertialNode::setToIdle() { m_impl->setToIdle(); } bool InertialNode::cyclePower() { return m_impl->cyclePower(); } void InertialNode::resume() { m_impl->resume(); } void InertialNode::saveSettingsAsStartup() { return m_impl->saveSettingsAsStartup(); } void InertialNode::loadStartupSettings() { return m_impl->loadStartupSettings(); } void InertialNode::loadFactoryDefaultSettings() { return m_impl->loadFactoryDefaultSettings(); } void InertialNode::pollData(MipTypes::DataClass dataClass, const MipTypes::MipChannelFields& fields /*= MipTypes::MipChannelFields()*/) { m_impl->pollData(dataClass, fields); } MipCommandSet InertialNode::getConfigCommandBytes() { return m_impl->getConfigCommandBytes(); } void InertialNode::sendCommandBytes(MipCommandSet& cmds) { m_impl->sendCommandBytes(cmds); } void InertialNode::sendCommandBytes(MipCommandBytes& cmd) { m_impl->sendCommandBytes(cmd); } uint16 InertialNode::getDataRateBase(MipTypes::DataClass dataClass) { return m_impl->getDataRateBase(dataClass); } MipChannels InertialNode::getActiveChannelFields(MipTypes::DataClass dataClass) { return m_impl->getMessageFormat(dataClass); } void InertialNode::setActiveChannelFields(MipTypes::DataClass dataClass, const MipChannels& channels) { m_impl->setMessageFormat(dataClass, channels); } void InertialNode::saveActiveChannelFields(MipTypes::DataClass dataClass) { m_impl->saveMessageFormat(dataClass); } uint8 InertialNode::getCommunicationMode() { return m_impl->getCommunicationMode(); } void InertialNode::setCommunicationMode(uint8 communicationMode) { m_impl->setCommunicationMode(communicationMode); } void InertialNode::enableDataStream(MipTypes::DataClass dataClass, bool enable) { m_impl->enableDataStream(dataClass, enable); } void InertialNode::resetFilter() { m_impl->resetFilter(); } bool InertialNode::getAltitudeAid() { return m_impl->getAltitudeAid(); } void InertialNode::setAltitudeAid(bool enable) { m_impl->setAltitudeAid(enable); } bool InertialNode::getPitchRollAid() { return m_impl->getPitchRollAid(); } void InertialNode::setPitchRollAid(bool enable) { m_impl->setPitchRollAid(enable); } ZUPTSettingsData InertialNode::getVelocityZUPT() { return m_impl->getVelocityZUPT(); } void InertialNode::setVelocityZUPT(const ZUPTSettingsData& ZUPTSettings) { m_impl->setVelocityZUPT(ZUPTSettings); } ZUPTSettingsData InertialNode::getAngularRateZUPT() { return m_impl->getAngularRateZUPT(); } void InertialNode::setAngularRateZUPT(const ZUPTSettingsData& ZUPTSettings) { m_impl->setAngularRateZUPT(ZUPTSettings); } bool InertialNode::getAutoInitialization() { return m_impl->getAutoInitialization(); } void InertialNode::setAutoInitialization(bool enable) { m_impl->setAutoInitialization(enable); } void InertialNode::setInitialAttitude(const EulerAngles& attitude) { m_impl->setInitialAttitude(attitude); } void InertialNode::setInitialHeading(float heading) { m_impl->setInitialHeading(heading); } EulerAngles InertialNode::getSensorToVehicleTransformation() { return m_impl->getSensorToVehicleTransformation(); } void InertialNode::setSensorToVehicleTransformation(const EulerAngles& angles) { m_impl->setSensorToVehicleTransformation(angles); } PositionOffset InertialNode::getSensorToVehicleOffset() { return m_impl->getSensorToVehicleOffset(); } void InertialNode::setSensorToVehicleOffset(const PositionOffset& offset) { m_impl->setSensorToVehicleOffset(offset); } PositionOffset InertialNode::getAntennaOffset() { return m_impl->getAntennaOffset(); } void InertialNode::setAntennaOffset(const PositionOffset& offset) { m_impl->setAntennaOffset(offset); } bool InertialNode::getGNSSAssistedFixControl() { return m_impl->getGNSSAssistedFixControl(); } void InertialNode::setGNSSAssistedFixControl(bool enableAssistedFix) { m_impl->setGNSSAssistedFixControl(enableAssistedFix); } TimeUpdate InertialNode::getGNSSAssistTimeUpdate() { return m_impl->getGNSSAssistTimeUpdate(); } void InertialNode::setGNSSAssistTimeUpdate(const TimeUpdate& timeUpdate) { m_impl->setGNSSAssistTimeUpdate(timeUpdate); } mscl::uint32 InertialNode::getGPSTimeUpdate(MipTypes::TimeFrame timeFrame) { switch (timeFrame) { case MipTypes::TIME_FRAME_WEEKS: return m_impl->getGPSTimeUpdateWeeks(); case MipTypes::TIME_FRAME_SECONDS: return m_impl->getGPSTimeUpdateSeconds(); default: throw Error_MipCmdFailed("InertialNode::getGPSTimeUpdate Unknown timeframe"); } } void InertialNode::setGPSTimeUpdate(MipTypes::TimeFrame timeFrame, mscl::uint32 time) { m_impl->setGPSTimeUpdate(timeFrame, time); } void InertialNode::setConstellationSettings(const ConstellationSettingsData& dataToUse) { m_impl->setConstellationSettings(dataToUse); } ConstellationSettingsData InertialNode::getConstellationSettings() { return m_impl->getConstellationSettings(); } void InertialNode::setSBASSettings(const SBASSettingsData& dataToUse) { m_impl->setSBASSettings(dataToUse); } SBASSettingsData InertialNode::getSBASSettings() { return m_impl->getSBASSettings(); } void InertialNode::setAccelerometerBias(const GeometricVector& biasVector) { m_impl->setAccelerometerBias(biasVector); } GeometricVector InertialNode::getAccelerometerBias() { return m_impl->getAccelerometerBias(); } void InertialNode::setGyroBias(const GeometricVector& biasVector) { m_impl->setGyroBias(biasVector); } GeometricVector InertialNode::getGyroBias() { return m_impl->getGyroBias(); } GeometricVector InertialNode::captureGyroBias(const uint16& samplingTime) { return m_impl->captureGyroBias(samplingTime); } void InertialNode::setMagnetometerSoftIronMatrix(const Matrix_3x3& matrix) { m_impl->setMagnetometerSoftIronMatrix(matrix); } Matrix_3x3 InertialNode::getMagnetometerSoftIronMatrix() { return m_impl->getMagnetometerSoftIronMatrix(); } void InertialNode::setMagnetometerHardIronOffset(const GeometricVector& offsetVector) { m_impl->setMagnetometerHardIronOffset(offsetVector); } GeometricVector InertialNode::getMagnetometerHardIronOffset() { return m_impl->getMagnetometerHardIronOffset(); } void InertialNode::setConingAndScullingEnable(bool enable) { m_impl->setConingAndScullingEnable(enable); } bool InertialNode::getConingAndScullingEnable() { return m_impl->getConingAndScullingEnable(); } void InertialNode::setUARTBaudRate(uint32 baudRate) { m_impl->setUARTBaudRate(baudRate); } uint32 InertialNode::getUARTBaudRate() { return m_impl->getUARTBaudRate(); } void InertialNode::setAdvancedLowPassFilterSettings(const AdvancedLowPassFilterConfig& data) { for (size_t i = 0; i < data.size(); i++) { m_impl->setAdvancedLowPassFilterSettings(data[i]); } } AdvancedLowPassFilterConfig InertialNode::getAdvancedLowPassFilterSettings(const MipTypes::MipChannelFields& dataDescriptors) { AdvancedLowPassFilterConfig data; for (size_t i = 0; i < dataDescriptors.size(); i++) { data.push_back(m_impl->getAdvancedLowPassFilterSettings(dataDescriptors[i])); } return data; } void InertialNode::setComplementaryFilterSettings(const ComplementaryFilterData& data) { m_impl->setComplementaryFilterSettings(data); } ComplementaryFilterData InertialNode::getComplementaryFilterSettings() { return m_impl->getComplementaryFilterSettings(); } DeviceStatusData InertialNode::getBasicDeviceStatus() { return m_impl->getBasicDeviceStatus(); } DeviceStatusData InertialNode::getDiagnosticDeviceStatus() { return m_impl->getDiagnosticDeviceStatus(); } void InertialNode::sendRawRTCM_2_3Message(const RTCMMessage& theMessage) { m_impl->sendRawRTCM_2_3Message(theMessage); } void InertialNode::setVehicleDynamicsMode(const InertialTypes::VehicleModeType& mode) { m_impl->setVehicleDynamicsMode(mode); } InertialTypes::VehicleModeType InertialNode::getVehicleDynamicsMode() { return m_impl->getVehicleDynamicsMode(); } void InertialNode::setEstimationControlFlags(const EstimationControlOptions& flags) { m_impl->setEstimationControlFlags(flags); } EstimationControlOptions InertialNode::getEstimationControlFlags() { return m_impl->getEstimationControlFlags(); } void InertialNode::setInclinationSource(const GeographicSourceOptions& options) { m_impl->setInclinationSource(options); } GeographicSourceOptions InertialNode::getInclinationSource() { return m_impl->getInclinationSource(); } void InertialNode::setDeclinationSource(const GeographicSourceOptions& options) { m_impl->setDeclinationSource(options); } GeographicSourceOptions InertialNode::getDeclinationSource() { return m_impl->getDeclinationSource(); } void InertialNode::setMagneticFieldMagnitudeSource(const GeographicSourceOptions& options) { m_impl->setMagneticFieldMagnitudeSource(options); } GeographicSourceOptions InertialNode::getMagneticFieldMagnitudeSource() { return m_impl->getMagneticFieldMagnitudeSource(); } void InertialNode::setGNSS_SourceControl(const InertialTypes::GNSS_Source& gnssSource) { m_impl->setGNSS_SourceControl(gnssSource); } InertialTypes::GNSS_Source InertialNode::getGNSS_SourceControl() { return m_impl->getGNSS_SourceControl(); } void InertialNode::sendExternalGNSSUpdate(const ExternalGNSSUpdateData& gnssUpdateData) { m_impl->sendExternalGNSSUpdate(gnssUpdateData); } void InertialNode::setHeadingUpdateControl(const HeadingUpdateOptions& headingUpdateOptions) { m_impl->setHeadingUpdateControl(headingUpdateOptions); } HeadingUpdateOptions InertialNode::getHeadingUpdateControl() { return m_impl->getHeadingUpdateControl(); } void InertialNode::setGravityErrorAdaptiveMeasurement(const AdaptiveMeasurementData& data) { m_impl->setAdaptiveMeasurement(MipTypes::Command::CMD_EF_GRAV_MAGNITUDE_ERR_ADAPT_MEASURE, data); } AdaptiveMeasurementData InertialNode::getGravityErrorAdaptiveMeasurement() { return m_impl->getAdaptiveMeasurement(MipTypes::Command::CMD_EF_GRAV_MAGNITUDE_ERR_ADAPT_MEASURE); } void InertialNode::setMagnetometerErrorAdaptiveMeasurement(const AdaptiveMeasurementData& data) { m_impl->setAdaptiveMeasurement(MipTypes::Command::CMD_EF_MAG_MAGNITUDE_ERR_ADAPT_MEASURE, data); } AdaptiveMeasurementData InertialNode::getMagnetometerErrorAdaptiveMeasurement() { return m_impl->getAdaptiveMeasurement(MipTypes::Command::CMD_EF_MAG_MAGNITUDE_ERR_ADAPT_MEASURE); } void InertialNode::setMagDipAngleErrorAdaptiveMeasurement(const AdaptiveMeasurementData& data) { m_impl->setAdaptiveMeasurement(MipTypes::Command::CMD_EF_MAG_DIP_ANGLE_ERR_ADAPT_MEASURE, data); } AdaptiveMeasurementData InertialNode::getMagDipAngleErrorAdaptiveMeasurement() { return m_impl->getAdaptiveMeasurement(MipTypes::Command::CMD_EF_MAG_DIP_ANGLE_ERR_ADAPT_MEASURE); } void InertialNode::setMagNoiseStandardDeviation(const GeometricVector& data) { GeometricVectors collection; collection.push_back(data); m_impl->setGeometricVectors(MipTypes::Command::CMD_EF_MAG_NOISE_STD_DEV, collection); } GeometricVector InertialNode::getMagNoiseStandardDeviation() { return m_impl->getGeometricVectors(MipTypes::Command::CMD_EF_MAG_NOISE_STD_DEV)[0]; } void InertialNode::setGravNoiseStandardDeviation(const GeometricVector& data) { GeometricVectors collection; collection.push_back(data); m_impl->setGeometricVectors(MipTypes::Command::CMD_EF_GRAVITY_NOISE_STD_DEV, collection); } GeometricVector InertialNode::getGravNoiseStandardDeviation() { return m_impl->getGeometricVectors(MipTypes::Command::CMD_EF_GRAVITY_NOISE_STD_DEV)[0]; } void InertialNode::setAccelNoiseStandardDeviation(const GeometricVector& data) { GeometricVectors collection; collection.push_back(data); m_impl->setGeometricVectors(MipTypes::Command::CMD_EF_ACCEL_WHT_NSE_STD_DEV, collection); } GeometricVector InertialNode::getAccelNoiseStandardDeviation() { return m_impl->getGeometricVectors(MipTypes::Command::CMD_EF_ACCEL_WHT_NSE_STD_DEV)[0]; } void InertialNode::setGyroNoiseStandardDeviation(const GeometricVector& data) { GeometricVectors collection; collection.push_back(data); m_impl->setGeometricVectors(MipTypes::Command::CMD_EF_GYRO_WHT_NSE_STD_DEV, collection); } GeometricVector InertialNode::getGyroNoiseStandardDeviation() { return m_impl->getGeometricVectors(MipTypes::Command::CMD_EF_GYRO_WHT_NSE_STD_DEV)[0]; } void InertialNode::setPressureAltNoiseStandardDeviation(const float& data) { std::vector<float> collection; collection.push_back(data); m_impl->setFloats(MipTypes::Command::CMD_EF_PRESS_ALT_NOISE_STD_DEV, collection); } float InertialNode::getPressureAltNoiseStandardDeviation() { return m_impl->getFloats(MipTypes::Command::CMD_EF_PRESS_ALT_NOISE_STD_DEV)[0]; } void InertialNode::setHardIronOffsetProcessNoise(const GeometricVector& data) { GeometricVectors collection; collection.push_back(data); m_impl->setGeometricVectors(MipTypes::Command::CMD_EF_HARD_IRON_OFFSET_PROCESS_NOISE, collection); } GeometricVector InertialNode::getHardIronOffsetProcessNoise() { return m_impl->getGeometricVectors(MipTypes::Command::CMD_EF_HARD_IRON_OFFSET_PROCESS_NOISE)[0]; } void InertialNode::setAccelBiasModelParams(const GeometricVectors& data) { m_impl->setGeometricVectors(MipTypes::Command::CMD_EF_ACCEL_BIAS_MODEL_PARAMS, data); } GeometricVectors InertialNode::getAccelBiasModelParams() { return m_impl->getGeometricVectors(MipTypes::Command::CMD_EF_ACCEL_BIAS_MODEL_PARAMS); } void InertialNode::setGyroBiasModelParams(const GeometricVectors& data) { m_impl->setGeometricVectors(MipTypes::Command::CMD_EF_GYRO_BIAS_MODEL_PARAMS, data); } GeometricVectors InertialNode::getGyroBiasModelParams() { return m_impl->getGeometricVectors(MipTypes::Command::CMD_EF_GYRO_BIAS_MODEL_PARAMS); } void InertialNode::setSoftIronMatrixProcessNoise(const Matrix_3x3& data) { Matrix_3x3s collection; collection.push_back(data); m_impl->setMatrix3x3s(MipTypes::Command::CMD_EF_SOFT_IRON_OFFSET_PROCESS_NOISE, collection); } Matrix_3x3 InertialNode::getSoftIronMatrixProcessNoise() { return m_impl->getMatrix3x3s(MipTypes::Command::CMD_EF_SOFT_IRON_OFFSET_PROCESS_NOISE)[0]; } void InertialNode::setFixedReferencePosition(const FixedReferencePositionData& data) { m_impl->setFixedReferencePosition(data); } FixedReferencePositionData InertialNode::getFixedReferencePosition() { return m_impl->getFixedReferencePosition(); } void InertialNode::setGPSDynamicsMode(const InertialTypes::GPSDynamicsMode& data) { std::vector<uint8> collection; collection.push_back(static_cast<uint8>(data)); m_impl->setUint8s(MipTypes::Command::CMD_GPS_DYNAMICS_MODE, collection); } InertialTypes::GPSDynamicsMode InertialNode::getGPSDynamicsMode() const { uint8 mode = m_impl->getUint8s(MipTypes::Command::CMD_GPS_DYNAMICS_MODE)[0]; return static_cast<InertialTypes::GPSDynamicsMode>(mode); } void InertialNode::setDevicePowerState(const InertialTypes::DeviceSelector& device, const InertialTypes::PowerState& data) { std::vector<uint8> collection; collection.push_back(static_cast<uint8>(device)); collection.push_back(static_cast<uint8>(data)); m_impl->setUint8s(MipTypes::Command::CMD_POWER_STATES, collection); } InertialTypes::PowerState InertialNode::getDevicePowerState(const InertialTypes::DeviceSelector& device) const { std::vector<uint8> params; params.push_back(static_cast<uint8>(device)); uint8 data = m_impl->getUint8s(MipTypes::Command::CMD_POWER_STATES, params)[1]; return static_cast<InertialTypes::PowerState>(data); } void InertialNode::setDeviceStreamFormat(const InertialTypes::DeviceSelector& device, const InertialTypes::StreamFormat& data) { std::vector<uint8> collection; collection.push_back(static_cast<uint8>(device)); collection.push_back(static_cast<uint8>(data)); m_impl->setUint8s(MipTypes::Command::CMD_DATA_STREAM_FORMAT, collection); } InertialTypes::StreamFormat InertialNode::getDeviceStreamFormat(const InertialTypes::DeviceSelector& device) const { std::vector<uint8> params; params.push_back(static_cast<uint8>(device)); uint8 data = m_impl->getUint8s(MipTypes::Command::CMD_DATA_STREAM_FORMAT, params)[1]; return static_cast<InertialTypes::StreamFormat>(data); } void InertialNode::setSignalConditioningSettings(const SignalConditioningValues& data) { m_impl->setSignalConditioningSettings(data); } SignalConditioningValues InertialNode::getSignalConditioningSettings() const { return m_impl->getSignalConditioningSettings(); } void InertialNode::setEnableDisableMeasurements(const EnableDisableMeasurements& data) { std::vector<uint16> collection; collection.push_back(data.measurementOptions); m_impl->setUint16s(MipTypes::Command::CMD_EF_ENABLE_DISABLE_MEASUREMENTS, collection); } EnableDisableMeasurements InertialNode::getEnableDisableMeasurements() const { EnableDisableMeasurements r; r.measurementOptions = m_impl->getUint16s(MipTypes::Command::CMD_EF_ENABLE_DISABLE_MEASUREMENTS)[0]; return r; } void InertialNode::sendExternalHeadingUpdate(const HeadingData& headingData) { m_impl->sendExternalHeadingUpdate(headingData); } void InertialNode::sendExternalHeadingUpdate(const HeadingData& headingData, const TimeUpdate& timestamp) { m_impl->sendExternalHeadingUpdate(headingData, timestamp); } }
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/autofill/core/browser/form_parsing/travel_field.h" #include <memory> #include <utility> #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_regex_constants.h" namespace autofill { TravelField::~TravelField() = default; // static std::unique_ptr<FormField> TravelField::Parse(AutofillScanner* scanner, const LanguageCode& page_language, LogManager* log_manager) { if (!scanner || scanner->IsEnd()) return nullptr; const std::vector<MatchingPattern>& passport_patterns = PatternProvider::GetInstance().GetMatchPatterns("PASSPORT", page_language); const std::vector<MatchingPattern>& travel_origin_patterns = PatternProvider::GetInstance().GetMatchPatterns("TRAVEL_ORIGIN", page_language); const std::vector<MatchingPattern>& travel_destination_patterns = PatternProvider::GetInstance().GetMatchPatterns("TRAVEL_DESTINATION", page_language); const std::vector<MatchingPattern>& flight_patterns = PatternProvider::GetInstance().GetMatchPatterns("FLIGHT", page_language); auto travel_field = std::make_unique<TravelField>(); if (ParseField(scanner, base::UTF8ToUTF16(kPassportRe), passport_patterns, &travel_field->passport_, {log_manager, "kPassportRe"}) || ParseField(scanner, base::UTF8ToUTF16(kTravelOriginRe), travel_origin_patterns, &travel_field->origin_, {log_manager, "kTravelOriginRe"}) || ParseField(scanner, base::UTF8ToUTF16(kTravelDestinationRe), travel_destination_patterns, &travel_field->destination_, {log_manager, "kTravelDestinationRe"}) || ParseField(scanner, base::UTF8ToUTF16(kFlightRe), flight_patterns, &travel_field->flight_, {log_manager, "kFlightRe"})) { // If any regex matches, then we found a travel field. return std::move(travel_field); } return nullptr; } void TravelField::AddClassifications( FieldCandidatesMap* field_candidates) const { // Simply tag all the fields as unknown types. Travel is currently used as // filter. AddClassification(passport_, UNKNOWN_TYPE, kBaseTravelParserScore, field_candidates); AddClassification(origin_, UNKNOWN_TYPE, kBaseTravelParserScore, field_candidates); AddClassification(destination_, UNKNOWN_TYPE, kBaseTravelParserScore, field_candidates); AddClassification(flight_, UNKNOWN_TYPE, kBaseTravelParserScore, field_candidates); } } // namespace autofill
; A151672: G.f.: Product_{k>=0} (1 + 4*x^(3^k)). ; Submitted by Christian Krause ; 1,4,0,4,16,0,0,0,0,4,16,0,16,64,0,0,0,0,0,0,0,0,0,0,0,0,0,4,16,0,16,64,0,0,0,0,16,64,0,64,256,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,16,0,16,64,0,0,0,0,16,64,0,64,256,0 mov $2,1 lpb $0 mov $1,$0 div $0,3 add $1,1 mod $1,3 mul $2,$1 lpe pow $2,2 mov $0,$2
; A057723: Sum of positive divisors of n that are divisible by every prime that divides n. ; Submitted by Jon Maiga ; 1,2,3,6,5,6,7,14,12,10,11,18,13,14,15,30,17,24,19,30,21,22,23,42,30,26,39,42,29,30,31,62,33,34,35,72,37,38,39,70,41,42,43,66,60,46,47,90,56,60,51,78,53,78,55,98,57,58,59,90,61,62,84,126,65,66,67,102,69,70,71,168,73,74,90,114,77,78,79,150,120,82,83,126,85,86,87,154,89,120,91,138,93,94,95,186,97,112,132,180 add $0,1 mov $1,1 lpb $0 mov $3,$0 lpb $3 mov $4,$0 mov $6,$2 cmp $6,0 add $2,$6 mod $4,$2 cmp $4,0 cmp $4,0 mov $5,$2 add $2,1 cmp $5,1 max $4,$5 sub $3,$4 lpe mov $5,1 lpb $0 dif $0,$2 mul $5,$2 add $5,$4 lpe sub $5,1 mul $1,$5 lpe mov $0,$1
copyright zengfr site:http://github.com/zengfr/romhack 001590 lea ($20,A0), A0 0017B6 andi.w #$6, D0 [123p+ 72, enemy+72] 008072 move.w (A3)+, ($72,A1) [123p+ 16] 008076 bpl $807a [123p+ 72, enemy+72] 0082DA clr.w ($72,A1) [enemy+7E] 0082DE move.l #$2020000, ($28,A1) [enemy+72] 008380 beq $8386 [123p+ 72, enemy+72] 00874C bpl $8750 [123p+ 72, enemy+72] 0096C2 move.w D5, ($72,A1) 0096C6 move.b #$10, ($31,A1) 011AC2 btst #$4, ($72,A0) [123p+ 0, enemy+ 0] 011AC8 beq $11aea [123p+ 72, enemy+72] 011CC4 beq $11ccc [123p+ 72, enemy+72] 01203A beq $12042 [123p+ 72, enemy+72] 01216A move.w D0, D1 [123p+ 72, enemy+72] 012284 move.l (A2)+, (A3)+ [enemy+6C, enemy+6E] 012286 move.l (A2)+, (A3)+ [enemy+70, enemy+72] 01A75E dbra D4, $1a75c 022CE8 move.w D0, ($72,A0) 022CEC move.b D0, ($79,A0) copyright zengfr site:http://github.com/zengfr/romhack
; A160037: Numerator of Hermite(n, 11/25). ; Submitted by Christian Krause ; 1,22,-766,-71852,1291756,387678632,455454904,-2897569732112,-67731764516464,27485598501757792,1366665517848891424,-313503339879296788672,-25688724347766786430784,4137398162538582528602752,508464530227059095129500544,-61218248179429894157699148032,-10880511401704815705147516456704,984993712751091937640737598592512,252880728966751356362480951873995264,-16598982499631038756942015027103624192,-6371094927952227566261646937603667252224,274810474075826962465794143050309925251072 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 mov $3,$1 mov $1,$2 mul $2,22 mul $3,-50 mul $3,$0 add $2,$3 mul $3,24 lpe mov $0,$1
; pasmo -I ../danagy -d test_fsqrt.asm 24576.bin > test.asm ; grep "BREAKPOINT" test.asm ; randomize usr 57344 INCLUDE "finit.asm" color_flow_warning EQU 1 carry_flow_warning EQU 1 DATA_ADR EQU $6000 ; 24576 TEXT_ADR EQU $E000 ; 57344 ORG DATA_ADR dw FP9, FP3 INCLUDE "test_fsqrt.dat" dw $BABE , $DEAD ; Stop MARK ; Subroutines INCLUDE "fsqrt.asm" INCLUDE "fequals.asm" INCLUDE "print_txt.asm" INCLUDE "print_hex.asm" ; Lookup tables INCLUDE "fsqrt.tab" if ( $ > TEXT_ADR ) .ERROR "Prilis dlouha data!" endif ORG TEXT_ADR LD HL, DATA_ADR PUSH HL READ_DATA: POP HL LD BC, $0004 LD DE, OP1 LDIR PUSH HL ; HL = HL + DE ; HL = HL - DE ; HL = BC * DE ; HL = BC % HL ; HL = BC / HL ; HL = HL * HL ; HL = HL % 1 ; HL = HL^0.5 LD HL, (OP1) BREAKPOINT: ; FUSE Debugger ; br 0xE015 PUSH HL CALL FSQRT ; HL = HL^0.5 POP BC ; kontrola LD BC, (RESULT) IGNORE EQU $+1 LD A, $00 OR A LD A, $00 LD (IGNORE), A JR nz, READ_DATA CALL FEQUALS if 1 JR nc, READ_DATA JR z, PRINT_OK else JR z, PRINT_OK endif CALL PRINT_DATA if 1 OR A LD HL, $DEAD SBC HL, BC JR nz, READ_DATA endif POP HL RET ; exit PRINT_OK: CALL PRINT_DATA JR READ_DATA OP1: defs 2 RESULT: defs 2 ; BC = kontrolni ; HL = spocitana PRINT_DATA: LD (DATA_COL), A LD DE, DATA_4 CALL WRITE_HEX LD HL, (OP1) LD DE, DATA_1 CALL WRITE_HEX LD H, B LD L, C LD DE, DATA_3 CALL WRITE_HEX CALL PRINT_TXT defb INK, COL_WHITE, '$' DATA_1: defs 4 defb ' ', $5E, '0.5 = $' DATA_3: defs 4 defb ' ? ', INK DATA_COL: defb COL_WHITE, '$' DATA_4: defs 4 defb NEW_LINE defb STOP_MARK
; A120949: 2n+3^n+5^n. ; 2,10,38,158,714,3378,16366,80326,397202,1972826,9824694,49005294,244672090,1222297474,6108298622,30531927062,152630937378,763068593322,3815084686150,19074648589630,95370918425066,476847618556370,2384217172075278,11921023098256998,59604927204927154,298024071165562618,1490118661250594006,7450588222521313166,37252925861411595642,186264583553473068066,931322780506610610334,4656613490750788862134,23283066218407151742530,116415327385995381008714,582076625811855771932262,2910383095704915460327902,14551915378461487103639818,72759576592118164924200562,363797882060023012839007790,1818989407598411628849054470,9094947029886947838207319506,45474735125119408272922739610,227373675552651048610272124918,1136868377544417264788335905838,5684341887065572389152605373594,28421709433358320141395804401858,142108547160882975293877354611646,710542735786689000230081770866006,3552713678880267372432493847754082,17763568394241803976008724219043306,88817841970730421221582386036035974,444089209852216310132528225002638974 mov $1,3 pow $1,$0 mov $2,5 pow $2,$0 add $1,$2 sub $1,2 div $1,2 add $1,1 add $1,$0 mul $1,2 mov $0,$1
/* * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/xe_hpc_core/hw_cmds_pvc.h" #include "level_zero/core/source/helpers/l0_populate_factory.h" #include "level_zero/core/source/hw_helpers/l0_hw_helper_base.inl" #include "level_zero/core/source/hw_helpers/l0_hw_helper_pvc_and_later.inl" #include "hw_cmds.h" namespace L0 { using Family = NEO::XE_HPC_COREFamily; static auto gfxCore = IGFX_XE_HPC_CORE; template <> void populateFactoryTable<L0HwHelperHw<Family>>() { extern L0HwHelper *l0HwHelperFactory[IGFX_MAX_CORE]; l0HwHelperFactory[gfxCore] = &L0HwHelperHw<Family>::get(); } template <> bool L0HwHelperHw<Family>::isIpSamplingSupported(const NEO::HardwareInfo &hwInfo) const { return NEO::PVC::isXt(hwInfo); } template class L0HwHelperHw<Family>; } // namespace L0
; A128988: a(n) = (n^3 - n^2)*5^n. ; Submitted by Jamie Morken(s2.) ; 0,100,2250,30000,312500,2812500,22968750,175000000,1265625000,8789062500,59082031250,386718750000,2475585937500,15551757812500,96130371093750,585937500000000,3527832031250000,21011352539062500,123939514160156250,724792480468750000,4205703735351562500,24232864379882812500,138735771179199218750,789642333984375000000,4470348358154296875000,25182962417602539062500,141218304634094238281250,788569450378417968750000,4386156797409057617187500,24307519197463989257812500,134250149130821228027343750 mov $2,5 pow $2,$0 mul $2,$0 add $0,1 pow $0,2 mul $0,$2 mul $0,5
#pragma once /****************************************** * Project: MCT-TFE * File: config.hpp * By: ProgrammingIncluded * Website: ProgrammingIncluded.github.io *******************************************/ #include <map> #include "types_macros.hpp" extern uint MONTE_CARLO; // Grid is always square. extern const uint GRID_WIDTH; extern const uint GRID_SIZE; // Win requirement extern uint WIN_REQ; // Heuristics extern bool VAL_H; extern long long int LEAF_WEIGHT; extern double UCB_COEFF; // Directions extern char DIR[4]; extern uint DIR_SIZE; extern std::map<char, int> DIR_TO_NUM;
; A128986: a(n) = (n^3 - n^2)*3^n. ; 0,36,486,3888,24300,131220,642978,2939328,12754584,53144100,214347870,841802544,3233287044,12187005012,45199057050,165299408640,597144113712,2133912053412,7552375012566,26499561447600,92260315250460,318957089865876,1095638315188626,3741626499300288 mov $1,3 pow $1,$0 mov $2,$0 add $2,$0 add $2,2 pow $2,2 mul $2,$0 mul $1,$2 div $1,24 mul $1,18
; A226264: Number of additive Z_2 Z_8 codes of a certain type (see Siap-Aydogdu for precise definition). ; 36,84,180,372,756,1524,3060,6132,12276,24564,49140,98292,196596,393204,786420,1572852,3145716,6291444,12582900,25165812,50331636,100663284,201326580,402653172,805306356,1610612724,3221225460,6442450932,12884901876,25769803764,51539607540,103079215092,206158430196,412316860404,824633720820,1649267441652,3298534883316,6597069766644,13194139533300,26388279066612,52776558133236,105553116266484,211106232532980,422212465065972,844424930131956,1688849860263924,3377699720527860,6755399441055732,13510798882111476,27021597764222964,54043195528445940,108086391056891892,216172782113783796,432345564227567604,864691128455135220,1729382256910270452,3458764513820540916,6917529027641081844,13835058055282163700,27670116110564327412,55340232221128654836,110680464442257309684,221360928884514619380,442721857769029238772,885443715538058477556,1770887431076116955124,3541774862152233910260,7083549724304467820532,14167099448608935641076,28334198897217871282164,56668397794435742564340,113336795588871485128692,226673591177742970257396,453347182355485940514804,906694364710971881029620,1813388729421943762059252,3626777458843887524118516,7253554917687775048237044,14507109835375550096474100,29014219670751100192948212,58028439341502200385896436,116056878683004400771792884,232113757366008801543585780,464227514732017603087171572,928455029464035206174343156,1856910058928070412348686324,3713820117856140824697372660,7427640235712281649394745332,14855280471424563298789490676,29710560942849126597578981364,59421121885698253195157962740,118842243771396506390315925492,237684487542793012780631850996,475368975085586025561263702004,950737950171172051122527404020,1901475900342344102245054808052,3802951800684688204490109616116,7605903601369376408980219232244,15211807202738752817960438464500,30423614405477505635920876929012 mov $1,2 pow $1,$0 sub $1,1 mul $1,48 add $1,36 mov $0,$1
FocusEnergyEffect_: ld hl, wPlayerBattleStatus2 ldh a, [hWhoseTurn] and a jr z, .notEnemy ld hl, wEnemyBattleStatus2 .notEnemy bit GETTING_PUMPED, [hl] ; is mon already using focus energy? jr nz, .alreadyUsing set GETTING_PUMPED, [hl] ; mon is now using focus energy callfar PlayCurrentMoveAnimation ld hl, GettingPumpedText jp PrintText .alreadyUsing ld c, 50 call DelayFrames jpfar PrintButItFailedText_ GettingPumpedText: text_pause text_far _GettingPumpedText text_end
_zombie: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(void) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 51 push %ecx e: 83 ec 04 sub $0x4,%esp if(fork() > 0) 11: e8 64 02 00 00 call 27a <fork> 16: 85 c0 test %eax,%eax 18: 7e 0d jle 27 <main+0x27> sleep(5); // Let child exit before parent. 1a: 83 ec 0c sub $0xc,%esp 1d: 6a 05 push $0x5 1f: e8 ee 02 00 00 call 312 <sleep> 24: 83 c4 10 add $0x10,%esp exit(); 27: e8 56 02 00 00 call 282 <exit> 2c: 66 90 xchg %ax,%ax 2e: 66 90 xchg %ax,%ax 00000030 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 30: 55 push %ebp 31: 89 e5 mov %esp,%ebp 33: 53 push %ebx 34: 8b 45 08 mov 0x8(%ebp),%eax 37: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 3a: 89 c2 mov %eax,%edx 3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 40: 83 c1 01 add $0x1,%ecx 43: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 47: 83 c2 01 add $0x1,%edx 4a: 84 db test %bl,%bl 4c: 88 5a ff mov %bl,-0x1(%edx) 4f: 75 ef jne 40 <strcpy+0x10> ; return os; } 51: 5b pop %ebx 52: 5d pop %ebp 53: c3 ret 54: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 5a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000060 <strcmp>: int strcmp(const char *p, const char *q) { 60: 55 push %ebp 61: 89 e5 mov %esp,%ebp 63: 53 push %ebx 64: 8b 55 08 mov 0x8(%ebp),%edx 67: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 6a: 0f b6 02 movzbl (%edx),%eax 6d: 0f b6 19 movzbl (%ecx),%ebx 70: 84 c0 test %al,%al 72: 75 1c jne 90 <strcmp+0x30> 74: eb 2a jmp a0 <strcmp+0x40> 76: 8d 76 00 lea 0x0(%esi),%esi 79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 80: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 83: 0f b6 02 movzbl (%edx),%eax p++, q++; 86: 83 c1 01 add $0x1,%ecx 89: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) 8c: 84 c0 test %al,%al 8e: 74 10 je a0 <strcmp+0x40> 90: 38 d8 cmp %bl,%al 92: 74 ec je 80 <strcmp+0x20> return (uchar)*p - (uchar)*q; 94: 29 d8 sub %ebx,%eax } 96: 5b pop %ebx 97: 5d pop %ebp 98: c3 ret 99: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi a0: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; a2: 29 d8 sub %ebx,%eax } a4: 5b pop %ebx a5: 5d pop %ebp a6: c3 ret a7: 89 f6 mov %esi,%esi a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000000b0 <strlen>: uint strlen(const char *s) { b0: 55 push %ebp b1: 89 e5 mov %esp,%ebp b3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) b6: 80 39 00 cmpb $0x0,(%ecx) b9: 74 15 je d0 <strlen+0x20> bb: 31 d2 xor %edx,%edx bd: 8d 76 00 lea 0x0(%esi),%esi c0: 83 c2 01 add $0x1,%edx c3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) c7: 89 d0 mov %edx,%eax c9: 75 f5 jne c0 <strlen+0x10> ; return n; } cb: 5d pop %ebp cc: c3 ret cd: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) d0: 31 c0 xor %eax,%eax } d2: 5d pop %ebp d3: c3 ret d4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi da: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000000e0 <memset>: void* memset(void *dst, int c, uint n) { e0: 55 push %ebp e1: 89 e5 mov %esp,%ebp e3: 57 push %edi e4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : e7: 8b 4d 10 mov 0x10(%ebp),%ecx ea: 8b 45 0c mov 0xc(%ebp),%eax ed: 89 d7 mov %edx,%edi ef: fc cld f0: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } f2: 89 d0 mov %edx,%eax f4: 5f pop %edi f5: 5d pop %ebp f6: c3 ret f7: 89 f6 mov %esi,%esi f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000100 <strchr>: char* strchr(const char *s, char c) { 100: 55 push %ebp 101: 89 e5 mov %esp,%ebp 103: 53 push %ebx 104: 8b 45 08 mov 0x8(%ebp),%eax 107: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 10a: 0f b6 10 movzbl (%eax),%edx 10d: 84 d2 test %dl,%dl 10f: 74 1d je 12e <strchr+0x2e> if(*s == c) 111: 38 d3 cmp %dl,%bl 113: 89 d9 mov %ebx,%ecx 115: 75 0d jne 124 <strchr+0x24> 117: eb 17 jmp 130 <strchr+0x30> 119: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 120: 38 ca cmp %cl,%dl 122: 74 0c je 130 <strchr+0x30> for(; *s; s++) 124: 83 c0 01 add $0x1,%eax 127: 0f b6 10 movzbl (%eax),%edx 12a: 84 d2 test %dl,%dl 12c: 75 f2 jne 120 <strchr+0x20> return (char*)s; return 0; 12e: 31 c0 xor %eax,%eax } 130: 5b pop %ebx 131: 5d pop %ebp 132: c3 ret 133: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 139: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000140 <gets>: char* gets(char *buf, int max) { 140: 55 push %ebp 141: 89 e5 mov %esp,%ebp 143: 57 push %edi 144: 56 push %esi 145: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 146: 31 f6 xor %esi,%esi 148: 89 f3 mov %esi,%ebx { 14a: 83 ec 1c sub $0x1c,%esp 14d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 150: eb 2f jmp 181 <gets+0x41> 152: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 158: 8d 45 e7 lea -0x19(%ebp),%eax 15b: 83 ec 04 sub $0x4,%esp 15e: 6a 01 push $0x1 160: 50 push %eax 161: 6a 00 push $0x0 163: e8 32 01 00 00 call 29a <read> if(cc < 1) 168: 83 c4 10 add $0x10,%esp 16b: 85 c0 test %eax,%eax 16d: 7e 1c jle 18b <gets+0x4b> break; buf[i++] = c; 16f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 173: 83 c7 01 add $0x1,%edi 176: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 179: 3c 0a cmp $0xa,%al 17b: 74 23 je 1a0 <gets+0x60> 17d: 3c 0d cmp $0xd,%al 17f: 74 1f je 1a0 <gets+0x60> for(i=0; i+1 < max; ){ 181: 83 c3 01 add $0x1,%ebx 184: 3b 5d 0c cmp 0xc(%ebp),%ebx 187: 89 fe mov %edi,%esi 189: 7c cd jl 158 <gets+0x18> 18b: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 18d: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 190: c6 03 00 movb $0x0,(%ebx) } 193: 8d 65 f4 lea -0xc(%ebp),%esp 196: 5b pop %ebx 197: 5e pop %esi 198: 5f pop %edi 199: 5d pop %ebp 19a: c3 ret 19b: 90 nop 19c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1a0: 8b 75 08 mov 0x8(%ebp),%esi 1a3: 8b 45 08 mov 0x8(%ebp),%eax 1a6: 01 de add %ebx,%esi 1a8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 1aa: c6 03 00 movb $0x0,(%ebx) } 1ad: 8d 65 f4 lea -0xc(%ebp),%esp 1b0: 5b pop %ebx 1b1: 5e pop %esi 1b2: 5f pop %edi 1b3: 5d pop %ebp 1b4: c3 ret 1b5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001c0 <stat>: int stat(const char *n, struct stat *st) { 1c0: 55 push %ebp 1c1: 89 e5 mov %esp,%ebp 1c3: 56 push %esi 1c4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 1c5: 83 ec 08 sub $0x8,%esp 1c8: 6a 00 push $0x0 1ca: ff 75 08 pushl 0x8(%ebp) 1cd: e8 f0 00 00 00 call 2c2 <open> if(fd < 0) 1d2: 83 c4 10 add $0x10,%esp 1d5: 85 c0 test %eax,%eax 1d7: 78 27 js 200 <stat+0x40> return -1; r = fstat(fd, st); 1d9: 83 ec 08 sub $0x8,%esp 1dc: ff 75 0c pushl 0xc(%ebp) 1df: 89 c3 mov %eax,%ebx 1e1: 50 push %eax 1e2: e8 f3 00 00 00 call 2da <fstat> close(fd); 1e7: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 1ea: 89 c6 mov %eax,%esi close(fd); 1ec: e8 b9 00 00 00 call 2aa <close> return r; 1f1: 83 c4 10 add $0x10,%esp } 1f4: 8d 65 f8 lea -0x8(%ebp),%esp 1f7: 89 f0 mov %esi,%eax 1f9: 5b pop %ebx 1fa: 5e pop %esi 1fb: 5d pop %ebp 1fc: c3 ret 1fd: 8d 76 00 lea 0x0(%esi),%esi return -1; 200: be ff ff ff ff mov $0xffffffff,%esi 205: eb ed jmp 1f4 <stat+0x34> 207: 89 f6 mov %esi,%esi 209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000210 <atoi>: int atoi(const char *s) { 210: 55 push %ebp 211: 89 e5 mov %esp,%ebp 213: 53 push %ebx 214: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 217: 0f be 11 movsbl (%ecx),%edx 21a: 8d 42 d0 lea -0x30(%edx),%eax 21d: 3c 09 cmp $0x9,%al n = 0; 21f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 224: 77 1f ja 245 <atoi+0x35> 226: 8d 76 00 lea 0x0(%esi),%esi 229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 230: 8d 04 80 lea (%eax,%eax,4),%eax 233: 83 c1 01 add $0x1,%ecx 236: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 23a: 0f be 11 movsbl (%ecx),%edx 23d: 8d 5a d0 lea -0x30(%edx),%ebx 240: 80 fb 09 cmp $0x9,%bl 243: 76 eb jbe 230 <atoi+0x20> return n; } 245: 5b pop %ebx 246: 5d pop %ebp 247: c3 ret 248: 90 nop 249: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000250 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 250: 55 push %ebp 251: 89 e5 mov %esp,%ebp 253: 56 push %esi 254: 53 push %ebx 255: 8b 5d 10 mov 0x10(%ebp),%ebx 258: 8b 45 08 mov 0x8(%ebp),%eax 25b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 25e: 85 db test %ebx,%ebx 260: 7e 14 jle 276 <memmove+0x26> 262: 31 d2 xor %edx,%edx 264: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 268: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 26c: 88 0c 10 mov %cl,(%eax,%edx,1) 26f: 83 c2 01 add $0x1,%edx while(n-- > 0) 272: 39 d3 cmp %edx,%ebx 274: 75 f2 jne 268 <memmove+0x18> return vdst; } 276: 5b pop %ebx 277: 5e pop %esi 278: 5d pop %ebp 279: c3 ret 0000027a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 27a: b8 01 00 00 00 mov $0x1,%eax 27f: cd 40 int $0x40 281: c3 ret 00000282 <exit>: SYSCALL(exit) 282: b8 02 00 00 00 mov $0x2,%eax 287: cd 40 int $0x40 289: c3 ret 0000028a <wait>: SYSCALL(wait) 28a: b8 03 00 00 00 mov $0x3,%eax 28f: cd 40 int $0x40 291: c3 ret 00000292 <pipe>: SYSCALL(pipe) 292: b8 04 00 00 00 mov $0x4,%eax 297: cd 40 int $0x40 299: c3 ret 0000029a <read>: SYSCALL(read) 29a: b8 05 00 00 00 mov $0x5,%eax 29f: cd 40 int $0x40 2a1: c3 ret 000002a2 <write>: SYSCALL(write) 2a2: b8 10 00 00 00 mov $0x10,%eax 2a7: cd 40 int $0x40 2a9: c3 ret 000002aa <close>: SYSCALL(close) 2aa: b8 15 00 00 00 mov $0x15,%eax 2af: cd 40 int $0x40 2b1: c3 ret 000002b2 <kill>: SYSCALL(kill) 2b2: b8 06 00 00 00 mov $0x6,%eax 2b7: cd 40 int $0x40 2b9: c3 ret 000002ba <exec>: SYSCALL(exec) 2ba: b8 07 00 00 00 mov $0x7,%eax 2bf: cd 40 int $0x40 2c1: c3 ret 000002c2 <open>: SYSCALL(open) 2c2: b8 0f 00 00 00 mov $0xf,%eax 2c7: cd 40 int $0x40 2c9: c3 ret 000002ca <mknod>: SYSCALL(mknod) 2ca: b8 11 00 00 00 mov $0x11,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <unlink>: SYSCALL(unlink) 2d2: b8 12 00 00 00 mov $0x12,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <fstat>: SYSCALL(fstat) 2da: b8 08 00 00 00 mov $0x8,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <link>: SYSCALL(link) 2e2: b8 13 00 00 00 mov $0x13,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <mkdir>: SYSCALL(mkdir) 2ea: b8 14 00 00 00 mov $0x14,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <chdir>: SYSCALL(chdir) 2f2: b8 09 00 00 00 mov $0x9,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <dup>: SYSCALL(dup) 2fa: b8 0a 00 00 00 mov $0xa,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <getpid>: SYSCALL(getpid) 302: b8 0b 00 00 00 mov $0xb,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <sbrk>: SYSCALL(sbrk) 30a: b8 0c 00 00 00 mov $0xc,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <sleep>: SYSCALL(sleep) 312: b8 0d 00 00 00 mov $0xd,%eax 317: cd 40 int $0x40 319: c3 ret 0000031a <uptime>: SYSCALL(uptime) 31a: b8 0e 00 00 00 mov $0xe,%eax 31f: cd 40 int $0x40 321: c3 ret 322: 66 90 xchg %ax,%ax 324: 66 90 xchg %ax,%ax 326: 66 90 xchg %ax,%ax 328: 66 90 xchg %ax,%ax 32a: 66 90 xchg %ax,%ax 32c: 66 90 xchg %ax,%ax 32e: 66 90 xchg %ax,%ax 00000330 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 330: 55 push %ebp 331: 89 e5 mov %esp,%ebp 333: 57 push %edi 334: 56 push %esi 335: 53 push %ebx 336: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 339: 85 d2 test %edx,%edx { 33b: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 33e: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 340: 79 76 jns 3b8 <printint+0x88> 342: f6 45 08 01 testb $0x1,0x8(%ebp) 346: 74 70 je 3b8 <printint+0x88> x = -xx; 348: f7 d8 neg %eax neg = 1; 34a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 351: 31 f6 xor %esi,%esi 353: 8d 5d d7 lea -0x29(%ebp),%ebx 356: eb 0a jmp 362 <printint+0x32> 358: 90 nop 359: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 360: 89 fe mov %edi,%esi 362: 31 d2 xor %edx,%edx 364: 8d 7e 01 lea 0x1(%esi),%edi 367: f7 f1 div %ecx 369: 0f b6 92 30 07 00 00 movzbl 0x730(%edx),%edx }while((x /= base) != 0); 370: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 372: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 375: 75 e9 jne 360 <printint+0x30> if(neg) 377: 8b 45 c4 mov -0x3c(%ebp),%eax 37a: 85 c0 test %eax,%eax 37c: 74 08 je 386 <printint+0x56> buf[i++] = '-'; 37e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 383: 8d 7e 02 lea 0x2(%esi),%edi 386: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 38a: 8b 7d c0 mov -0x40(%ebp),%edi 38d: 8d 76 00 lea 0x0(%esi),%esi 390: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 393: 83 ec 04 sub $0x4,%esp 396: 83 ee 01 sub $0x1,%esi 399: 6a 01 push $0x1 39b: 53 push %ebx 39c: 57 push %edi 39d: 88 45 d7 mov %al,-0x29(%ebp) 3a0: e8 fd fe ff ff call 2a2 <write> while(--i >= 0) 3a5: 83 c4 10 add $0x10,%esp 3a8: 39 de cmp %ebx,%esi 3aa: 75 e4 jne 390 <printint+0x60> putc(fd, buf[i]); } 3ac: 8d 65 f4 lea -0xc(%ebp),%esp 3af: 5b pop %ebx 3b0: 5e pop %esi 3b1: 5f pop %edi 3b2: 5d pop %ebp 3b3: c3 ret 3b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 3b8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 3bf: eb 90 jmp 351 <printint+0x21> 3c1: eb 0d jmp 3d0 <printf> 3c3: 90 nop 3c4: 90 nop 3c5: 90 nop 3c6: 90 nop 3c7: 90 nop 3c8: 90 nop 3c9: 90 nop 3ca: 90 nop 3cb: 90 nop 3cc: 90 nop 3cd: 90 nop 3ce: 90 nop 3cf: 90 nop 000003d0 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 3d0: 55 push %ebp 3d1: 89 e5 mov %esp,%ebp 3d3: 57 push %edi 3d4: 56 push %esi 3d5: 53 push %ebx 3d6: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 3d9: 8b 75 0c mov 0xc(%ebp),%esi 3dc: 0f b6 1e movzbl (%esi),%ebx 3df: 84 db test %bl,%bl 3e1: 0f 84 b3 00 00 00 je 49a <printf+0xca> ap = (uint*)(void*)&fmt + 1; 3e7: 8d 45 10 lea 0x10(%ebp),%eax 3ea: 83 c6 01 add $0x1,%esi state = 0; 3ed: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 3ef: 89 45 d4 mov %eax,-0x2c(%ebp) 3f2: eb 2f jmp 423 <printf+0x53> 3f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 3f8: 83 f8 25 cmp $0x25,%eax 3fb: 0f 84 a7 00 00 00 je 4a8 <printf+0xd8> write(fd, &c, 1); 401: 8d 45 e2 lea -0x1e(%ebp),%eax 404: 83 ec 04 sub $0x4,%esp 407: 88 5d e2 mov %bl,-0x1e(%ebp) 40a: 6a 01 push $0x1 40c: 50 push %eax 40d: ff 75 08 pushl 0x8(%ebp) 410: e8 8d fe ff ff call 2a2 <write> 415: 83 c4 10 add $0x10,%esp 418: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 41b: 0f b6 5e ff movzbl -0x1(%esi),%ebx 41f: 84 db test %bl,%bl 421: 74 77 je 49a <printf+0xca> if(state == 0){ 423: 85 ff test %edi,%edi c = fmt[i] & 0xff; 425: 0f be cb movsbl %bl,%ecx 428: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 42b: 74 cb je 3f8 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 42d: 83 ff 25 cmp $0x25,%edi 430: 75 e6 jne 418 <printf+0x48> if(c == 'd'){ 432: 83 f8 64 cmp $0x64,%eax 435: 0f 84 05 01 00 00 je 540 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 43b: 81 e1 f7 00 00 00 and $0xf7,%ecx 441: 83 f9 70 cmp $0x70,%ecx 444: 74 72 je 4b8 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 446: 83 f8 73 cmp $0x73,%eax 449: 0f 84 99 00 00 00 je 4e8 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 44f: 83 f8 63 cmp $0x63,%eax 452: 0f 84 08 01 00 00 je 560 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 458: 83 f8 25 cmp $0x25,%eax 45b: 0f 84 ef 00 00 00 je 550 <printf+0x180> write(fd, &c, 1); 461: 8d 45 e7 lea -0x19(%ebp),%eax 464: 83 ec 04 sub $0x4,%esp 467: c6 45 e7 25 movb $0x25,-0x19(%ebp) 46b: 6a 01 push $0x1 46d: 50 push %eax 46e: ff 75 08 pushl 0x8(%ebp) 471: e8 2c fe ff ff call 2a2 <write> 476: 83 c4 0c add $0xc,%esp 479: 8d 45 e6 lea -0x1a(%ebp),%eax 47c: 88 5d e6 mov %bl,-0x1a(%ebp) 47f: 6a 01 push $0x1 481: 50 push %eax 482: ff 75 08 pushl 0x8(%ebp) 485: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 488: 31 ff xor %edi,%edi write(fd, &c, 1); 48a: e8 13 fe ff ff call 2a2 <write> for(i = 0; fmt[i]; i++){ 48f: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 493: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 496: 84 db test %bl,%bl 498: 75 89 jne 423 <printf+0x53> } } } 49a: 8d 65 f4 lea -0xc(%ebp),%esp 49d: 5b pop %ebx 49e: 5e pop %esi 49f: 5f pop %edi 4a0: 5d pop %ebp 4a1: c3 ret 4a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 4a8: bf 25 00 00 00 mov $0x25,%edi 4ad: e9 66 ff ff ff jmp 418 <printf+0x48> 4b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 4b8: 83 ec 0c sub $0xc,%esp 4bb: b9 10 00 00 00 mov $0x10,%ecx 4c0: 6a 00 push $0x0 4c2: 8b 7d d4 mov -0x2c(%ebp),%edi 4c5: 8b 45 08 mov 0x8(%ebp),%eax 4c8: 8b 17 mov (%edi),%edx 4ca: e8 61 fe ff ff call 330 <printint> ap++; 4cf: 89 f8 mov %edi,%eax 4d1: 83 c4 10 add $0x10,%esp state = 0; 4d4: 31 ff xor %edi,%edi ap++; 4d6: 83 c0 04 add $0x4,%eax 4d9: 89 45 d4 mov %eax,-0x2c(%ebp) 4dc: e9 37 ff ff ff jmp 418 <printf+0x48> 4e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 4e8: 8b 45 d4 mov -0x2c(%ebp),%eax 4eb: 8b 08 mov (%eax),%ecx ap++; 4ed: 83 c0 04 add $0x4,%eax 4f0: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 4f3: 85 c9 test %ecx,%ecx 4f5: 0f 84 8e 00 00 00 je 589 <printf+0x1b9> while(*s != 0){ 4fb: 0f b6 01 movzbl (%ecx),%eax state = 0; 4fe: 31 ff xor %edi,%edi s = (char*)*ap; 500: 89 cb mov %ecx,%ebx while(*s != 0){ 502: 84 c0 test %al,%al 504: 0f 84 0e ff ff ff je 418 <printf+0x48> 50a: 89 75 d0 mov %esi,-0x30(%ebp) 50d: 89 de mov %ebx,%esi 50f: 8b 5d 08 mov 0x8(%ebp),%ebx 512: 8d 7d e3 lea -0x1d(%ebp),%edi 515: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 518: 83 ec 04 sub $0x4,%esp s++; 51b: 83 c6 01 add $0x1,%esi 51e: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 521: 6a 01 push $0x1 523: 57 push %edi 524: 53 push %ebx 525: e8 78 fd ff ff call 2a2 <write> while(*s != 0){ 52a: 0f b6 06 movzbl (%esi),%eax 52d: 83 c4 10 add $0x10,%esp 530: 84 c0 test %al,%al 532: 75 e4 jne 518 <printf+0x148> 534: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 537: 31 ff xor %edi,%edi 539: e9 da fe ff ff jmp 418 <printf+0x48> 53e: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 540: 83 ec 0c sub $0xc,%esp 543: b9 0a 00 00 00 mov $0xa,%ecx 548: 6a 01 push $0x1 54a: e9 73 ff ff ff jmp 4c2 <printf+0xf2> 54f: 90 nop write(fd, &c, 1); 550: 83 ec 04 sub $0x4,%esp 553: 88 5d e5 mov %bl,-0x1b(%ebp) 556: 8d 45 e5 lea -0x1b(%ebp),%eax 559: 6a 01 push $0x1 55b: e9 21 ff ff ff jmp 481 <printf+0xb1> putc(fd, *ap); 560: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 563: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 566: 8b 07 mov (%edi),%eax write(fd, &c, 1); 568: 6a 01 push $0x1 ap++; 56a: 83 c7 04 add $0x4,%edi putc(fd, *ap); 56d: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 570: 8d 45 e4 lea -0x1c(%ebp),%eax 573: 50 push %eax 574: ff 75 08 pushl 0x8(%ebp) 577: e8 26 fd ff ff call 2a2 <write> ap++; 57c: 89 7d d4 mov %edi,-0x2c(%ebp) 57f: 83 c4 10 add $0x10,%esp state = 0; 582: 31 ff xor %edi,%edi 584: e9 8f fe ff ff jmp 418 <printf+0x48> s = "(null)"; 589: bb 28 07 00 00 mov $0x728,%ebx while(*s != 0){ 58e: b8 28 00 00 00 mov $0x28,%eax 593: e9 72 ff ff ff jmp 50a <printf+0x13a> 598: 66 90 xchg %ax,%ax 59a: 66 90 xchg %ax,%ax 59c: 66 90 xchg %ax,%ax 59e: 66 90 xchg %ax,%ax 000005a0 <free>: static Header base; static Header *freep; void free(void *ap) { 5a0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5a1: a1 d4 09 00 00 mov 0x9d4,%eax { 5a6: 89 e5 mov %esp,%ebp 5a8: 57 push %edi 5a9: 56 push %esi 5aa: 53 push %ebx 5ab: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 5ae: 8d 4b f8 lea -0x8(%ebx),%ecx 5b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5b8: 39 c8 cmp %ecx,%eax 5ba: 8b 10 mov (%eax),%edx 5bc: 73 32 jae 5f0 <free+0x50> 5be: 39 d1 cmp %edx,%ecx 5c0: 72 04 jb 5c6 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5c2: 39 d0 cmp %edx,%eax 5c4: 72 32 jb 5f8 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 5c6: 8b 73 fc mov -0x4(%ebx),%esi 5c9: 8d 3c f1 lea (%ecx,%esi,8),%edi 5cc: 39 fa cmp %edi,%edx 5ce: 74 30 je 600 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 5d0: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 5d3: 8b 50 04 mov 0x4(%eax),%edx 5d6: 8d 34 d0 lea (%eax,%edx,8),%esi 5d9: 39 f1 cmp %esi,%ecx 5db: 74 3a je 617 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 5dd: 89 08 mov %ecx,(%eax) freep = p; 5df: a3 d4 09 00 00 mov %eax,0x9d4 } 5e4: 5b pop %ebx 5e5: 5e pop %esi 5e6: 5f pop %edi 5e7: 5d pop %ebp 5e8: c3 ret 5e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5f0: 39 d0 cmp %edx,%eax 5f2: 72 04 jb 5f8 <free+0x58> 5f4: 39 d1 cmp %edx,%ecx 5f6: 72 ce jb 5c6 <free+0x26> { 5f8: 89 d0 mov %edx,%eax 5fa: eb bc jmp 5b8 <free+0x18> 5fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 600: 03 72 04 add 0x4(%edx),%esi 603: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 606: 8b 10 mov (%eax),%edx 608: 8b 12 mov (%edx),%edx 60a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 60d: 8b 50 04 mov 0x4(%eax),%edx 610: 8d 34 d0 lea (%eax,%edx,8),%esi 613: 39 f1 cmp %esi,%ecx 615: 75 c6 jne 5dd <free+0x3d> p->s.size += bp->s.size; 617: 03 53 fc add -0x4(%ebx),%edx freep = p; 61a: a3 d4 09 00 00 mov %eax,0x9d4 p->s.size += bp->s.size; 61f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 622: 8b 53 f8 mov -0x8(%ebx),%edx 625: 89 10 mov %edx,(%eax) } 627: 5b pop %ebx 628: 5e pop %esi 629: 5f pop %edi 62a: 5d pop %ebp 62b: c3 ret 62c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000630 <malloc>: return freep; } void* malloc(uint nbytes) { 630: 55 push %ebp 631: 89 e5 mov %esp,%ebp 633: 57 push %edi 634: 56 push %esi 635: 53 push %ebx 636: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 639: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 63c: 8b 15 d4 09 00 00 mov 0x9d4,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 642: 8d 78 07 lea 0x7(%eax),%edi 645: c1 ef 03 shr $0x3,%edi 648: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 64b: 85 d2 test %edx,%edx 64d: 0f 84 9d 00 00 00 je 6f0 <malloc+0xc0> 653: 8b 02 mov (%edx),%eax 655: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 658: 39 cf cmp %ecx,%edi 65a: 76 6c jbe 6c8 <malloc+0x98> 65c: 81 ff 00 10 00 00 cmp $0x1000,%edi 662: bb 00 10 00 00 mov $0x1000,%ebx 667: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 66a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 671: eb 0e jmp 681 <malloc+0x51> 673: 90 nop 674: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 678: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 67a: 8b 48 04 mov 0x4(%eax),%ecx 67d: 39 f9 cmp %edi,%ecx 67f: 73 47 jae 6c8 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 681: 39 05 d4 09 00 00 cmp %eax,0x9d4 687: 89 c2 mov %eax,%edx 689: 75 ed jne 678 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 68b: 83 ec 0c sub $0xc,%esp 68e: 56 push %esi 68f: e8 76 fc ff ff call 30a <sbrk> if(p == (char*)-1) 694: 83 c4 10 add $0x10,%esp 697: 83 f8 ff cmp $0xffffffff,%eax 69a: 74 1c je 6b8 <malloc+0x88> hp->s.size = nu; 69c: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 69f: 83 ec 0c sub $0xc,%esp 6a2: 83 c0 08 add $0x8,%eax 6a5: 50 push %eax 6a6: e8 f5 fe ff ff call 5a0 <free> return freep; 6ab: 8b 15 d4 09 00 00 mov 0x9d4,%edx if((p = morecore(nunits)) == 0) 6b1: 83 c4 10 add $0x10,%esp 6b4: 85 d2 test %edx,%edx 6b6: 75 c0 jne 678 <malloc+0x48> return 0; } } 6b8: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 6bb: 31 c0 xor %eax,%eax } 6bd: 5b pop %ebx 6be: 5e pop %esi 6bf: 5f pop %edi 6c0: 5d pop %ebp 6c1: c3 ret 6c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 6c8: 39 cf cmp %ecx,%edi 6ca: 74 54 je 720 <malloc+0xf0> p->s.size -= nunits; 6cc: 29 f9 sub %edi,%ecx 6ce: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 6d1: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 6d4: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 6d7: 89 15 d4 09 00 00 mov %edx,0x9d4 } 6dd: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 6e0: 83 c0 08 add $0x8,%eax } 6e3: 5b pop %ebx 6e4: 5e pop %esi 6e5: 5f pop %edi 6e6: 5d pop %ebp 6e7: c3 ret 6e8: 90 nop 6e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 6f0: c7 05 d4 09 00 00 d8 movl $0x9d8,0x9d4 6f7: 09 00 00 6fa: c7 05 d8 09 00 00 d8 movl $0x9d8,0x9d8 701: 09 00 00 base.s.size = 0; 704: b8 d8 09 00 00 mov $0x9d8,%eax 709: c7 05 dc 09 00 00 00 movl $0x0,0x9dc 710: 00 00 00 713: e9 44 ff ff ff jmp 65c <malloc+0x2c> 718: 90 nop 719: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; 720: 8b 08 mov (%eax),%ecx 722: 89 0a mov %ecx,(%edx) 724: eb b1 jmp 6d7 <malloc+0xa7>
#ruledef test { ld {x: s8} => 0x55 @ x } ld 0x7f ; = 0x557f
; _________________ ; // \\ ; || HOW TO COMPILE IT || ; \\_________________// ; ; ------ x86_64 ------ ; nasm -f elf64 meaning.asm ; ld -s -o meaning meaning.o ; ; _________________ ; // \\ ; || DESCRIPTION || ; \\_________________// ; ; Modify the registry content ; using indirect directions ; ; LEVEL: 04 ; ASM: NASM 64-bit ; ENVS: Linux ; AUTHOR: CosasDePuma ; DATE: August, 8rd 2017 [BITS 64] section .data name db 'Pink Panter', 0xA name_l equ $ - name section .bss %macro sys_write 2 mov rax, 1 mov rdi, 1 mov rsi, %1 mov rdx, %2 syscall %endmacro %macro sys_exit 1 mov rax, 60 mov rdi, %1 syscall %endmacro section .text global _start _start: sys_write name, name_l mov [name + 5], DWORD 'Panz' ; modify the following 4 bits in ; [name + 5] direction ; ; P I N K P A N T E R ; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ; | | | | | | | | | | | ; 0 1 2 3 4 5 6 7 8 9 10 ; (______) ; 4-bit [name + 5] sys_write name, name_l sys_exit 0
/* * Copyright (C) 2019 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. * */ #ifndef IGNITION_GAZEBO_MARKERMANAGER_HH_ #define IGNITION_GAZEBO_MARKERMANAGER_HH_ #include <memory> #include <string> #include "ignition/rendering/RenderTypes.hh" namespace ignition { namespace gazebo { inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE { // Forward declare private data class. class MarkerManagerPrivate; /// \brief Creates, deletes, and maintains marker visuals. Only the /// Scene class should instantiate and use this class. class IGNITION_GAZEBO_VISIBLE MarkerManager { /// \brief Constructor public: MarkerManager(); /// \brief Destructor public: virtual ~MarkerManager(); /// \brief Set the simulation time. /// \param[in] _time The provided time. public: void SetSimTime(const std::chrono::steady_clock::duration &_time); /// \brief Set the scene to manage /// \param[in] _scene Scene pointer. public: void SetScene(rendering::ScenePtr _scene); /// \brief Get the scene /// \return Pointer to scene public: rendering::ScenePtr Scene() const; /// \brief Update MarkerManager public: void Update(); /// \brief Initialize the marker manager. /// \param[in] _scene Reference to the scene. /// \return True on success public: bool Init(const ignition::rendering::ScenePtr &_scene); /// \brief Set the marker service topic name. /// \param[in] _name Name of service public: void SetTopic(const std::string &_name); /// \internal /// \brief Private data pointer private: std::unique_ptr<MarkerManagerPrivate> dataPtr; }; } } } #endif
* WMAN version error message v0.00  Jun 1988 J.R.Oakley QJUMP * include 'dev8_mac_text' * section language * mktext wver,{Window Manager zu alt\} * end
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r13 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_normal_ht+0x8393, %r13 nop nop nop xor %rbx, %rbx mov $0x6162636465666768, %rcx movq %rcx, %xmm3 movups %xmm3, (%r13) nop and $28765, %r11 lea addresses_WT_ht+0x1ed3, %rsi lea addresses_WC_ht+0x1e191, %rdi nop dec %rbx mov $77, %rcx rep movsw cmp %r11, %r11 lea addresses_D_ht+0x6c33, %r11 nop nop nop nop xor %rsi, %rsi mov $0x6162636465666768, %r13 movq %r13, %xmm6 movups %xmm6, (%r11) nop nop nop nop dec %rbx lea addresses_UC_ht+0x7243, %rsi lea addresses_UC_ht+0xd93, %rdi and $27036, %rbp mov $106, %rcx rep movsw nop nop nop nop nop sub $8675, %rdi lea addresses_D_ht+0x6153, %r11 add $13655, %r13 vmovups (%r11), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $1, %xmm6, %rbx nop nop xor $25917, %r13 lea addresses_A_ht+0x7fc3, %rsi lea addresses_UC_ht+0xda43, %rdi xor $39644, %r10 mov $23, %rcx rep movsw mfence lea addresses_A_ht+0x10f93, %r10 nop cmp %rbx, %rbx movups (%r10), %xmm7 vpextrq $0, %xmm7, %r13 nop nop nop nop nop cmp $28156, %rdi lea addresses_WC_ht+0xb193, %rsi lea addresses_WC_ht+0x15953, %rdi clflush (%rsi) sub %r10, %r10 mov $43, %rcx rep movsq add $37310, %r11 lea addresses_normal_ht+0x13373, %rsi nop xor %rcx, %rcx mov $0x6162636465666768, %r13 movq %r13, %xmm4 vmovups %ymm4, (%rsi) nop nop nop cmp $30765, %rbx lea addresses_A_ht+0xa9e7, %rsi lea addresses_A_ht+0x11a53, %rdi nop inc %rbp mov $50, %rcx rep movsw nop nop nop xor $19516, %rsi lea addresses_A_ht+0x2193, %rbp add %rsi, %rsi mov $0x6162636465666768, %rbx movq %rbx, %xmm3 movups %xmm3, (%rbp) nop nop nop nop nop sub %r11, %r11 lea addresses_A_ht+0x8f93, %rsi lea addresses_WT_ht+0x13061, %rdi nop nop nop nop sub $51345, %rbx mov $22, %rcx rep movsw nop nop cmp %rbp, %rbp lea addresses_normal_ht+0x19793, %rbp nop nop nop nop nop cmp $35392, %rsi movb $0x61, (%rbp) add %rbx, %rbx lea addresses_WT_ht+0x15793, %rdi nop xor %r13, %r13 movb $0x61, (%rdi) nop nop nop inc %r13 lea addresses_UC_ht+0x19a13, %r10 nop nop sub %rbx, %rbx mov (%r10), %esi nop xor %rbx, %rbx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r13 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r8 push %r9 push %rbp push %rbx // Store mov $0x693, %r8 clflush (%r8) nop and %r9, %r9 movb $0x51, (%r8) nop nop nop nop cmp $53177, %r8 // Store lea addresses_A+0xe083, %rbx nop nop nop xor $53182, %r10 mov $0x5152535455565758, %r11 movq %r11, %xmm7 vmovups %ymm7, (%rbx) nop nop nop nop nop sub %r9, %r9 // Store lea addresses_WC+0x1793, %rbx add %r11, %r11 movw $0x5152, (%rbx) nop nop nop and $19086, %rbp // Store lea addresses_WT+0xaf93, %r9 nop nop add $36316, %r13 movb $0x51, (%r9) nop nop nop dec %rbx // Store lea addresses_A+0x5c83, %r11 nop xor %r10, %r10 mov $0x5152535455565758, %rbp movq %rbp, %xmm6 movups %xmm6, (%r11) nop nop sub $54104, %rbx // Faulty Load lea addresses_PSE+0xcf93, %r13 nop nop nop nop nop dec %r11 mov (%r13), %r9 lea oracles, %rbp and $0xff, %r9 shlq $12, %r9 mov (%rbp,%r9,1), %r9 pop %rbx pop %rbp pop %r9 pop %r8 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': True, 'size': 1, 'NT': False, 'same': False, 'congruent': 8}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 3}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 4}} [Faulty Load] {'src': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 8, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 10}} {'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 4}} {'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}} {'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 5}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}} {'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 7}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 5}} {'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 9}} {'src': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 11}} {'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4, 'NT': True, 'same': False, 'congruent': 7}, 'OP': 'LOAD'} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
; A033593: a(n) = (n-1)*(2*n-1)*(3*n-1)*(4*n-1). ; 1,0,105,880,3465,9576,21505,42120,74865,123760,193401,288960,416185,581400,791505,1053976,1376865,1768800,2238985,2797200,3453801,4219720,5106465,6126120,7291345,8615376,10112025,11795680,13681305,15784440,18121201,20708280,23562945,26703040,30146985,33913776,38022985,42494760,47349825,52609480,58295601,64430640,71037625,78140160,85762425,93929176,102665745,111998040,121952545,132556320,143837001,155822800,168542505,182025480,196301665,211401576,227356305,244197520,261957465,280668960,300365401 mov $1,$0 mul $1,2 mul $1,$0 mov $2,3 mul $2,$0 sub $2,1 sub $0,$2 mul $0,$2 add $1,$0 mul $0,11 mul $0,$1 div $0,11
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r9 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x1c0cc, %r9 clflush (%r9) nop nop nop xor $22524, %rbx movb (%r9), %al nop and %rcx, %rcx lea addresses_WT_ht+0x14dbb, %rsi lea addresses_WT_ht+0xe79b, %rdi nop nop cmp %r10, %r10 mov $32, %rcx rep movsb nop nop nop nop xor $12401, %rax lea addresses_A_ht+0x18cd, %rcx nop nop nop nop nop inc %rax mov $0x6162636465666768, %rsi movq %rsi, (%rcx) nop nop nop xor $6503, %rbx lea addresses_WC_ht+0x1ac3b, %rsi lea addresses_normal_ht+0xea3b, %rdi clflush (%rsi) clflush (%rdi) nop nop nop and $61645, %rdx mov $80, %rcx rep movsl nop nop cmp $5911, %rcx lea addresses_D_ht+0xddbb, %rsi lea addresses_A_ht+0x19e1b, %rdi nop add %rax, %rax mov $24, %rcx rep movsw nop nop nop nop lfence lea addresses_WT_ht+0x14f7b, %rsi lea addresses_WT_ht+0x24fb, %rdi nop nop xor $50877, %rdx mov $119, %rcx rep movsq xor $63530, %rax lea addresses_UC_ht+0xecee, %rsi nop cmp $50296, %rdx movups (%rsi), %xmm7 vpextrq $0, %xmm7, %r9 and $4422, %rcx lea addresses_D_ht+0x159bb, %rsi lea addresses_WT_ht+0x19fbb, %rdi xor $22156, %rax mov $5, %rcx rep movsw nop nop nop nop sub $41664, %rcx lea addresses_A_ht+0x421b, %rsi lea addresses_D_ht+0x10c3b, %rdi nop nop nop nop add $21409, %rax mov $11, %rcx rep movsb nop nop nop cmp $10121, %rbx lea addresses_A_ht+0x1c5ef, %rdi clflush (%rdi) dec %r9 mov $0x6162636465666768, %rax movq %rax, %xmm2 vmovups %ymm2, (%rdi) nop xor %rax, %rax lea addresses_A_ht+0xf5bb, %rsi lea addresses_normal_ht+0x1cdbb, %rdi nop nop xor $3570, %r10 mov $26, %rcx rep movsq nop cmp %rsi, %rsi lea addresses_normal_ht+0x1469b, %rdi clflush (%rdi) nop nop nop nop nop add $61983, %rax mov (%rdi), %cx nop nop sub %r10, %r10 lea addresses_A_ht+0x15f1b, %rsi lea addresses_WT_ht+0x179bb, %rdi nop nop nop and $29365, %rax mov $66, %rcx rep movsq nop nop inc %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r9 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %rbx push %rcx push %rdi push %rdx // Store lea addresses_WC+0x1fb, %rbx nop nop nop nop nop cmp %rcx, %rcx mov $0x5152535455565758, %r12 movq %r12, %xmm3 vmovntdq %ymm3, (%rbx) nop nop nop nop and %rcx, %rcx // Store lea addresses_US+0x165bb, %r10 nop nop nop add $48934, %rdi mov $0x5152535455565758, %rdx movq %rdx, %xmm4 movups %xmm4, (%r10) nop cmp $574, %r12 // Store lea addresses_WT+0x66ab, %rcx nop cmp %rbx, %rbx mov $0x5152535455565758, %rdx movq %rdx, (%rcx) cmp $55992, %rdi // Faulty Load mov $0x7699d200000005bb, %r12 nop nop nop nop sub $5690, %r11 movups (%r12), %xmm6 vpextrq $0, %xmm6, %rcx lea oracles, %r11 and $0xff, %rcx shlq $12, %rcx mov (%r11,%rcx,1), %rcx pop %rdx pop %rdi pop %rcx pop %rbx pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': True, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_US', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 4}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_NC', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 11}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': True, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 11}, 'dst': {'same': True, 'type': 'addresses_A_ht', 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 6}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 11}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 9}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 10}} {'b0': 66, '00': 171, '58': 21592} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 00 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 b0 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 b0 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 00 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 00 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 00 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 00 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. #include "ui/compositor/debug_utils.h" #include <cmath> #include <iomanip> #include <iostream> #include <string> #include "base/logging.h" #include "base/strings/utf_string_conversions.h" #include "ui/compositor/layer.h" #include "ui/gfx/interpolated_transform.h" #include "ui/gfx/point.h" #include "ui/gfx/point_conversions.h" #include "ui/gfx/transform.h" using base::UTF8ToWide; namespace ui { namespace { void PrintLayerHierarchyImp(const Layer* layer, int indent, gfx::Point mouse_location, std::wostringstream* out) { std::string indent_str(indent, ' '); layer->transform().TransformPointReverse(&mouse_location); bool mouse_inside_layer_bounds = layer->bounds().Contains(mouse_location); mouse_location.Offset(-layer->bounds().x(), -layer->bounds().y()); *out << UTF8ToWide(indent_str); if (mouse_inside_layer_bounds) *out << L'*'; else *out << L' '; *out << UTF8ToWide(layer->name()) << L' ' << layer; switch (layer->type()) { case ui::LAYER_NOT_DRAWN: *out << L" not_drawn"; break; case ui::LAYER_TEXTURED: *out << L" textured"; if (layer->fills_bounds_opaquely()) *out << L" opaque"; break; case ui::LAYER_SOLID_COLOR: *out << L" solid"; break; } if (!layer->visible()) *out << L" !visible"; std::string property_indent_str(indent+3, ' '); *out << L'\n' << UTF8ToWide(property_indent_str); *out << L"bounds: " << layer->bounds().x() << L',' << layer->bounds().y(); *out << L' ' << layer->bounds().width() << L'x' << layer->bounds().height(); if (layer->opacity() != 1.0f) { *out << L'\n' << UTF8ToWide(property_indent_str); *out << L"opacity: " << std::setprecision(2) << layer->opacity(); } gfx::DecomposedTransform decomp; if (!layer->transform().IsIdentity() && gfx::DecomposeTransform(&decomp, layer->transform())) { *out << L'\n' << UTF8ToWide(property_indent_str); *out << L"translation: " << std::fixed << decomp.translate[0]; *out << L", " << decomp.translate[1]; *out << L'\n' << UTF8ToWide(property_indent_str); *out << L"rotation: "; *out << std::acos(decomp.quaternion[3]) * 360.0 / M_PI; *out << L'\n' << UTF8ToWide(property_indent_str); *out << L"scale: " << decomp.scale[0]; *out << L", " << decomp.scale[1]; } *out << L'\n'; for (size_t i = 0, count = layer->children().size(); i < count; ++i) { PrintLayerHierarchyImp( layer->children()[i], indent + 3, mouse_location, out); } } } // namespace void PrintLayerHierarchy(const Layer* layer, gfx::Point mouse_location) { std::wostringstream out; out << L"Layer hierarchy:\n"; PrintLayerHierarchyImp(layer, 0, mouse_location, &out); // Error so logs can be collected from end-users. LOG(ERROR) << out.str(); } } // namespace ui
<% from pwnlib.shellcraft.powerpc.linux import syscall %> <%page args="fd, buf, n, flags, addr, addr_len"/> <%docstring> Invokes the syscall recvfrom. See 'man 2 recvfrom' for more information. Arguments: fd(int): fd buf(void): buf n(size_t): n flags(int): flags addr(SOCKADDR_ARG): addr addr_len(socklen_t): addr_len </%docstring> ${syscall('SYS_recvfrom', fd, buf, n, flags, addr, addr_len)}
Snd_MHZ2_Header: smpsHeaderStartSong 3 smpsHeaderVoice Snd_MHZ2_Voices smpsHeaderChan $06, $03 smpsHeaderTempo $01, $30 smpsHeaderDAC Snd_MHZ2_DAC smpsHeaderFM Snd_MHZ2_FM1, $00, $0D smpsHeaderFM Snd_MHZ2_FM2, $00, $0F smpsHeaderFM Snd_MHZ2_FM3, $00, $0A smpsHeaderFM Snd_MHZ2_FM4, $00, $0A smpsHeaderFM Snd_MHZ2_FM5, $00, $13 smpsHeaderPSG Snd_MHZ2_PSG1, $E8, $02, $00, $00 smpsHeaderPSG Snd_MHZ2_PSG2, $E8, $02, $00, $00 smpsHeaderPSG Snd_MHZ2_PSG3, $E8, $02, $00, $00 ; FM1 Data Snd_MHZ2_FM1: dc.b nRst, $60 Snd_MHZ2_Jump05: smpsSetvoice $00 smpsModSet $0D, $01, $02, $06 smpsPan panCenter, $00 dc.b nRst, $60, nRst, nRst smpsSetvoice $00 dc.b nB5, $04, nBb5, nG5, nA5, nFs5, nAb5, nF5, nG5, nE5, nFs5, nEb5 dc.b nF5, nD5, nE5, nCs5, nEb5, nC5, nD5, nB4, nCs5, nBb4, nC5, nA4 dc.b nB4 Snd_MHZ2_Loop08: smpsSetvoice $02 dc.b nB4, $01, nC5, $3B, nD5, $06, nRst, nF5, nRst, nG5, nRst, nE5 dc.b $01, nF5, $06, nRst, $05, nCs5, $06, nRst, nC5, nBb4, nRst, nG4 dc.b $36, nRst, $0C, nBb4, $18, nC5, $06, nBb4, $05, nC5, $01, nCs5 dc.b $06, nRst, nC5, nRst, nEb5, nD5, nRst, nBb4, nRst, $60 smpsLoop $00, $02, Snd_MHZ2_Loop08 dc.b nRst, $0C, nBb4, $18, nC5, $06, nBb4, nCs5, nRst, nC5, nRst, nBb4 dc.b nC5, nRst, nBb4, nRst, $60, nRst, $0C, nBb4, $18, nC5, $06, nBb4 dc.b $05, nCs5, $01, nD5, nEb5, $06, nRst, $05, nD5, $06, nRst, nC5 dc.b nD5, nRst, nBb4, nRst, $60, nD5, $01, nEb5, $3B, nF5, $06, nRst dc.b $05, nF5, $02, nG5, $06, nRst, $05, nEb5, $06, nRst, nF5, $12 dc.b nRst, $06, nCs5, $12, nBb4, $36, nRst, $0B, nA4, $01, nBb4, $18 dc.b nC5, $06, nBb4, $05, nB4, $01, nC5, nCs5, $06, nRst, $05, nC5 dc.b $06, nRst, nBb4, nC5, nRst, nBb4, nRst, $60 smpsJump Snd_MHZ2_Jump05 ; FM2 Data Snd_MHZ2_FM2: dc.b nRst, $60 Snd_MHZ2_Jump04: smpsSetvoice $01 smpsModSet $0D, $01, $02, $06 smpsPan panCenter, $00 Snd_MHZ2_Loop06: dc.b nG2, $06, nA2, nD3, nF3, nRst, nE3, nRst, nD3, nRst, nC3, nRst dc.b nC3, nD3, nD3, $01, nRst, $05, nE3, $0C, nC3, $06, nBb2, nRst dc.b nBb2, nBb2, $02, nRst, $04, nBb2, $02, nRst, $04, nC3, $06, nBb2 dc.b nRst, nBb2, nRst, nBb2, $02, nRst, $04, nC3, $0C, nBb2 smpsLoop $00, $06, Snd_MHZ2_Loop06 Snd_MHZ2_Loop07: dc.b nFs2, $06, nFs3, nFs2, nRst, nFs2, nRst, nFs2, nRst, nAb2, nRst, nAb2 dc.b nRst, nAb2, nRst, nAb2, nAb2, nRst, nBb2, $12, nBb2, $06, nRst, $12 dc.b nBb2, $06, nAb2, nA2, nBb2, nRst, $18 smpsLoop $00, $02, Snd_MHZ2_Loop07 dc.b nC3, $06, nRst, nC3, nRst, nC3, nRst, nC3, nC3, nC3, nRst, nC3 dc.b nRst, nC3, nRst, nC3, nC3, nBb2, nRst, nBb2, nRst, nBb2, nRst, nBb2 dc.b nBb2, nBb2, nRst, nBb2, nRst, nBb2, nRst, nBb2, nBb2, nFs2, nFs3, nFs2 dc.b nRst, nFs2, nRst, nFs2, nRst, nAb2, nRst, nAb2, nRst, nAb2, nRst, nAb2 dc.b nAb2, nRst, nBb2, $12, nBb2, $06, nRst, $12, nBb2, $06, nAb2, nA2 dc.b nBb2, nRst, $18 smpsJump Snd_MHZ2_Jump04 ; FM3 Data Snd_MHZ2_FM3: dc.b nRst, $60 Snd_MHZ2_Jump03: smpsSetvoice $03 smpsModSet $0D, $01, $02, $06 smpsPan panLeft, $00 Snd_MHZ2_Loop04: dc.b nRst, $0C, nG4, $06, nG4, nG4, nG4, nRst, $0C, nG4, $06, nG4 dc.b nG4, nG4, nRst, $0C, nG4, $06, nG4, nRst, $60 smpsLoop $00, $02, Snd_MHZ2_Loop04 Snd_MHZ2_Loop05: dc.b nRst, $0C, nE4, $06, nE4, nE4, nE4, nRst, $0C, nE4, $06, nE4 dc.b nE4, nE4, nRst, $0C, nE4, $06, nE4, nRst, $60, nRst, $0C, nFs4 dc.b $06, nFs4, nFs4, nFs4, nRst, $0C, nF4, $06, nF4, nF4, nF4, nRst dc.b $0C, nF4, $06, nF4, nRst, $60 smpsLoop $00, $02, Snd_MHZ2_Loop05 smpsSetvoice $04 dc.b nRst, $06, nFs5, $12, nFs5, $06, nRst, nFs5, nRst, nAb5, nG5, nAb5 dc.b nC6, nRst, $18 smpsSetvoice $05 dc.b nRst, $06, nF4, $12, nF4, $06, nRst, $12, nF4, $06, nEb4, nE4 dc.b nF4, nRst smpsSetvoice $06 dc.b nBb4, $0C, nC5, $06 smpsSetvoice $04 dc.b nRst, nFs5, $12, nFs5, $06, nRst, nFs5, nRst, nAb5, nG5, nAb5, nC6 dc.b nRst, $18 smpsSetvoice $05 dc.b nRst, $06, nF4, $12, nF4, $06, nRst, $12, nF4, $06, nEb4, nE4 dc.b nF4 smpsSetvoice $06 dc.b nE4, nEb4, nD4, nCs4, nC4, $30, nC4, $06, nRst, nEb4, nRst, nF4 dc.b nG4, nRst, nEb4, nRst, nF4, $12, nF4, $06, nRst, nF4, nRst, nF4 dc.b nCs4, nRst, nEb4, nRst, nF4, $12 smpsSetvoice $03 dc.b nRst, $0C, nFs4, $18, nAb4, $06, nFs4, nBb4, nRst, nAb4, nRst, nFs4 dc.b nAb4, nRst, nF4, nRst, $60 smpsJump Snd_MHZ2_Jump03 ; FM4 Data Snd_MHZ2_FM4: dc.b nRst, $60 Snd_MHZ2_Jump02: smpsSetvoice $03 smpsModSet $0D, $01, $02, $06 smpsPan panRight, $00 Snd_MHZ2_Loop02: dc.b nRst, $0C, nE4, $06, nE4, nE4, nE4, nRst, $0C, nE4, $06, nE4 dc.b nE4, nE4, nRst, $0C, nE4, $06, nE4, nRst, $60 smpsLoop $00, $02, Snd_MHZ2_Loop02 Snd_MHZ2_Loop03: dc.b nRst, $0C, nC4, $06, nC4, nC4, nC4, nRst, $0C, nC4, $06, nC4 dc.b nC4, nC4, nRst, $0C, nC4, $06, nC4, nRst, $60, nRst, $0C, nCs4 dc.b $06, nCs4, nCs4, nCs4, nRst, $0C, nD4, $06, nD4, nD4, nD4, nRst dc.b $0C, nD4, $06, nD4, nRst, $60 smpsLoop $00, $02, Snd_MHZ2_Loop03 smpsSetvoice $04 dc.b nRst, $06, nFs4, $12, nFs4, $06, nRst, nFs4, nRst, nAb4, nG4, nAb4 dc.b nC5, nRst, $18 smpsSetvoice $05 dc.b nRst, $06, nD4, $12, nD4, $06, nRst, $12, nD4, $06, nC4, nCs4 dc.b nD4, nRst smpsSetvoice $06 dc.b nFs4, $0C, nAb4, $06 smpsSetvoice $04 dc.b nRst, nFs4, $12, nFs4, $06, nRst, nFs4, nRst, nAb4, nG4, nAb4, nC5 dc.b nRst, $18 smpsSetvoice $05 dc.b nRst, $06, nD4, $12, nD4, $06, nRst, $12, nD4, $06, nC4, nCs4 dc.b nD4 smpsSetvoice $06 dc.b nCs4, nC4, nB3, nBb3, nG3, $30, nG3, $06, nRst, nC4, nRst, nD4 dc.b nEb4, nRst, nC4, nRst, nD4, $12, nD4, $06, nRst, nD4, nRst, nD4 dc.b nBb3, nRst, nC4, nRst, nD4, $12 smpsSetvoice $03 dc.b nRst, $0C, nEb4, $18, nEb4, $06, nEb4, nF4, nRst, nEb4, nRst, nD4 dc.b nEb4, nRst, nD4, nRst, $60 smpsJump Snd_MHZ2_Jump02 ; FM5 Data Snd_MHZ2_FM5: dc.b nRst, $60, nRst, $0E Snd_MHZ2_Jump01: smpsSetvoice $00 smpsModSet $0D, $01, $02, $06 smpsPan panCenter, $00 dc.b nRst, $60, nRst, nRst smpsSetvoice $00 dc.b nB5, $04, nBb5, nG5, nA5, nFs5, nAb5, nF5, nG5, nE5, nFs5, nEb5 dc.b nF5, nD5, nE5, nCs5, nEb5, nC5, nD5, nB4, nCs5, nBb4, nC5, nA4 dc.b nB4 Snd_MHZ2_Loop01: smpsSetvoice $02 dc.b nB4, $01, nC5, $3B, nD5, $06, nRst, nF5, nRst, nG5, nRst, nE5 dc.b $01, nF5, $06, nRst, $05, nCs5, $06, nRst, nC5, nBb4, nRst, nG4 dc.b $36, nRst, $0C, nBb4, $18, nC5, $06, nBb4, $05, nC5, $01, nCs5 dc.b $06, nRst, nC5, nRst, nEb5, nD5, nRst, nBb4, nRst, $60 smpsLoop $00, $02, Snd_MHZ2_Loop01 dc.b nRst, $0C, nBb4, $18, nC5, $06, nBb4, nCs5, nRst, nC5, nRst, nBb4 dc.b nC5, nRst, nBb4, nRst, $60, nRst, $0C, nBb4, $18, nC5, $06, nBb4 dc.b $05, nCs5, $01, nD5, nEb5, $06, nRst, $05, nD5, $06, nRst, nC5 dc.b nD5, nRst, nBb4, nRst, $60, nD5, $01, nEb5, $3B, nF5, $06, nRst dc.b $05, nF5, $02, nG5, $06, nRst, $05, nEb5, $06, nRst, nF5, $12 dc.b nRst, $06, nCs5, $12, nBb4, $36, nRst, $0B, nA4, $01, nBb4, $18 dc.b nC5, $06, nBb4, $05, nB4, $01, nC5, nCs5, $06, nRst, $05, nC5 dc.b $06, nRst, nBb4, nC5, nRst, nBb4, nRst, $60 smpsJump Snd_MHZ2_Jump01 ; DAC Data Snd_MHZ2_DAC: dc.b dKickS3, $0C, dSnareS3, dKickS3, dSnareS3, dKickS3, $04, dKickS3, dKickS3, dSnareS3, $0C, dSnareS3 dc.b dSnareS3, $06, dSnareS3 Snd_MHZ2_Jump00: dc.b dKickS3, $18, dKickS3, dKickS3, dKickS3, $0C, dSnareS3, $06, dKickS3, dSnareS3, dKickS3, $0C dc.b dKickS3, $12, dSnareS3, $06, dKickS3, $0C, dKickS3, dKickS3, $06, dSnareS3, $0C, dKickS3 dc.b dKickS3, $18, dKickS3, dKickS3, dKickS3, $0C, dSnareS3, $06, dKickS3, dSnareS3, dKickS3, $0C dc.b dKickS3, $12, dSnareS3, $06, dKickS3, dSnareS3, $0C, dSnareS3, dSnareS3, $06, dSnareS3, dSnareS3 dc.b $0C Snd_MHZ2_Loop00: dc.b dKickS3, $0C, dSnareS3, dSnareS3, dKickS3, dKickS3, dKickS3, dSnareS3, $18, dSnareS3, $06, dKickS3 dc.b $0C, dKickS3, $12, dSnareS3, $06, dKickS3, $0C, dKickS3, dKickS3, $06, dSnareS3, $0C dc.b dKickS3 smpsLoop $00, $03, Snd_MHZ2_Loop00 dc.b dKickS3, $0C, dSnareS3, dSnareS3, dKickS3, dKickS3, dKickS3, dSnareS3, $18, dSnareS3, $06, dKickS3 dc.b $0C, dKickS3, $12, dSnareS3, $06, dKickS3, $0C, dKickS3, dKickS3, $06, dSnareS3, dSnareS3 dc.b dSnareS3, dSnareS3, dKickS3, $0C, dSnareS3, dKickS3, dSnareS3, dKickS3, dSnareS3, dSnareS3, dSnareS3, dKickS3 dc.b $06, dSnareS3, $12, dSnareS3, $18, dSnareS3, $06, dKickS3, dKickS3, dSnareS3, $0C, dSnareS3 dc.b dSnareS3, $06, dKickS3, $0C, dSnareS3, dKickS3, dSnareS3, dKickS3, dSnareS3, dSnareS3, dSnareS3, dKickS3 dc.b $06, dSnareS3, $12, dSnareS3, $18, dSnareS3, $06, dKickS3, dKickS3, dKickS3, dSnareS3, dSnareS3 dc.b dSnareS3, dSnareS3, dKickS3, $0C, dKickS3, dSnareS3, dKickS3, dKickS3, dKickS3, dSnareS3, dKickS3, dKickS3 dc.b dSnareS3, dSnareS3, dKickS3, dSnareS3, dKickS3, $06, dSnareS3, $0C, dSnareS3, dSnareS3, $06, dKickS3 dc.b $0C, dSnareS3, dKickS3, dSnareS3, dKickS3, dSnareS3, dSnareS3, dSnareS3, dKickS3, $06, dSnareS3, $12 dc.b dSnareS3, $18, dSnareS3, $0C, dKickS3, $04, dKickS3, dKickS3, dSnareS3, $18 smpsJump Snd_MHZ2_Jump00 ; PSG1 Data Snd_MHZ2_PSG1: smpsStop ; PSG2 Data Snd_MHZ2_PSG2: smpsStop ; PSG3 Data Snd_MHZ2_PSG3: smpsStop Snd_MHZ2_Voices: ; Voice $00 ; $38 ; $4C, $33, $74, $41, $1F, $1F, $1F, $1F, $11, $0F, $0D, $0D ; $00, $0F, $00, $00, $FF, $FF, $FF, $FF, $21, $16, $26, $81 smpsVcAlgorithm $00 smpsVcFeedback $07 smpsVcUnusedBits $00 smpsVcDetune $04, $07, $03, $04 smpsVcCoarseFreq $01, $04, $03, $0C smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $1F, $1F, $1F, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $0D, $0D, $0F, $11 smpsVcDecayRate2 $00, $00, $0F, $00 smpsVcDecayLevel $0F, $0F, $0F, $0F smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $01, $26, $16, $21 ; Voice $01 ; $35 ; $40, $30, $50, $30, $18, $1F, $1F, $1F, $0D, $0B, $09, $09 ; $00, $00, $00, $00, $EF, $EF, $EF, $EF, $14, $85, $85, $85 smpsVcAlgorithm $05 smpsVcFeedback $06 smpsVcUnusedBits $00 smpsVcDetune $03, $05, $03, $04 smpsVcCoarseFreq $00, $00, $00, $00 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $1F, $1F, $1F, $18 smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $09, $09, $0B, $0D smpsVcDecayRate2 $00, $00, $00, $00 smpsVcDecayLevel $0E, $0E, $0E, $0E smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $05, $05, $05, $14 ; Voice $02 ; $3B ; $71, $12, $13, $71, $11, $10, $14, $1A, $0C, $09, $0A, $02 ; $00, $06, $04, $07, $1F, $EF, $FF, $EF, $1B, $24, $24, $81 smpsVcAlgorithm $03 smpsVcFeedback $07 smpsVcUnusedBits $00 smpsVcDetune $07, $01, $01, $07 smpsVcCoarseFreq $01, $03, $02, $01 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $1A, $14, $10, $11 smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $02, $0A, $09, $0C smpsVcDecayRate2 $07, $04, $06, $00 smpsVcDecayLevel $0E, $0F, $0E, $01 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $01, $24, $24, $1B ; Voice $03 ; $34 ; $61, $03, $00, $61, $1F, $1E, $51, $D0, $0C, $08, $01, $01 ; $08, $00, $09, $00, $8F, $FF, $FF, $FF, $11, $85, $19, $86 smpsVcAlgorithm $04 smpsVcFeedback $06 smpsVcUnusedBits $00 smpsVcDetune $06, $00, $00, $06 smpsVcCoarseFreq $01, $00, $03, $01 smpsVcRateScale $03, $01, $00, $00 smpsVcAttackRate $10, $11, $1E, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $01, $01, $08, $0C smpsVcDecayRate2 $00, $09, $00, $08 smpsVcDecayLevel $0F, $0F, $0F, $08 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $06, $19, $05, $11 ; Voice $04 ; $1B ; $63, $50, $21, $41, $15, $0F, $16, $13, $10, $01, $06, $05 ; $05, $01, $05, $01, $CF, $0F, $DF, $CF, $21, $12, $2A, $81 smpsVcAlgorithm $03 smpsVcFeedback $03 smpsVcUnusedBits $00 smpsVcDetune $04, $02, $05, $06 smpsVcCoarseFreq $01, $01, $00, $03 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $13, $16, $0F, $15 smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $05, $06, $01, $10 smpsVcDecayRate2 $01, $05, $01, $05 smpsVcDecayLevel $0C, $0D, $00, $0C smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $01, $2A, $12, $21 ; Voice $05 ; $34 ; $31, $30, $71, $31, $16, $1B, $13, $1F, $13, $06, $08, $08 ; $08, $0B, $0C, $0D, $9F, $8F, $9F, $8F, $0F, $8C, $12, $83 smpsVcAlgorithm $04 smpsVcFeedback $06 smpsVcUnusedBits $00 smpsVcDetune $03, $07, $03, $03 smpsVcCoarseFreq $01, $01, $00, $01 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $1F, $13, $1B, $16 smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $08, $08, $06, $13 smpsVcDecayRate2 $0D, $0C, $0B, $08 smpsVcDecayLevel $08, $09, $08, $09 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $03, $12, $0C, $0F ; Voice $06 ; $07 ; $14, $76, $72, $71, $9F, $9F, $1F, $1F, $0C, $0C, $0C, $0C ; $0E, $0E, $03, $02, $0F, $0F, $DF, $DF, $81, $81, $81, $81 smpsVcAlgorithm $07 smpsVcFeedback $00 smpsVcUnusedBits $00 smpsVcDetune $07, $07, $07, $01 smpsVcCoarseFreq $01, $02, $06, $04 smpsVcRateScale $00, $00, $02, $02 smpsVcAttackRate $1F, $1F, $1F, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $0C, $0C, $0C, $0C smpsVcDecayRate2 $02, $03, $0E, $0E smpsVcDecayLevel $0D, $0D, $00, $00 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $01, $01, $01, $01
dnl Alpha mpn_copyi -- copy, incrementing. dnl Copyright 2002, 2003 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C cycles/limb C EV4: 4 C EV5: 1.75 C EV6: 1 C INPUT PARAMETERS C rp r16 C up r17 C n r18 ASM_START() PROLOGUE(mpn_copyi) lda r18,-8(r18) C E0 blt r18,$Lend C E1 $Loop: ldq r0,0(r17) C E0 ldq r1,8(r17) C E1 ldq r2,16(r17) C E0 ldq r3,24(r17) C E1 ldq r4,32(r17) C E0 ldq r5,40(r17) C E1 ldq r6,48(r17) C E0 ldq r7,56(r17) C E1 stq r0,0(r16) C E0 lda r17,64(r17) C E1 stq r1,8(r16) C E0 bis r31, r31, r31 C E1 stq r2,16(r16) C E0 lda r18,-8(r18) C E1 stq r3,24(r16) C E0 bis r31, r31, r31 C E1 stq r4,32(r16) C E0 bis r31, r31, r31 C E1 stq r5,40(r16) C E0 bis r31, r31, r31 C E1 stq r6,48(r16) C E0 bis r31, r31, r31 C E1 stq r7,56(r16) C E0 lda r16,64(r16) C E1 bge r18,$Loop C E1 $Lend: lda r18,7(r18) C E0 blt r18,$Lret C E1 ldq r0,0(r17) C E0 beq r18,$Lend0 C E1 $Loop0: stq r0,0(r16) C E0 lda r16,8(r16) C E1 ldq r0,8(r17) C E0 lda r18,-1(r18) C E1 lda r17,8(r17) C E0 bgt r18,$Loop0 C E1 $Lend0: stq r0,0(r16) C E0 $Lret: ret r31,(r26),1 C E1 EPILOGUE(mpn_copyi) ASM_END()
%define ARCH_ARM 0 %define ARCH_MIPS 0 %define ARCH_X86 1 %define ARCH_X86_64 0 %define HAVE_EDSP 0 %define HAVE_MEDIA 0 %define HAVE_NEON 0 %define HAVE_NEON_ASM 0 %define HAVE_MIPS32 0 %define HAVE_DSPR2 0 %define HAVE_MSA 0 %define HAVE_MIPS64 0 %define HAVE_MMX 1 %define HAVE_SSE 1 %define HAVE_SSE2 1 %define HAVE_SSE3 1 %define HAVE_SSSE3 1 %define HAVE_SSE4_1 1 %define HAVE_AVX 1 %define HAVE_AVX2 1 %define HAVE_VPX_PORTS 1 %define HAVE_STDINT_H 0 %define HAVE_PTHREAD_H 0 %define HAVE_SYS_MMAN_H 0 %define HAVE_UNISTD_H 0 %define CONFIG_DEPENDENCY_TRACKING 1 %define CONFIG_EXTERNAL_BUILD 1 %define CONFIG_INSTALL_DOCS 0 %define CONFIG_INSTALL_BINS 1 %define CONFIG_INSTALL_LIBS 1 %define CONFIG_INSTALL_SRCS 0 %define CONFIG_USE_X86INC 1 %define CONFIG_DEBUG 0 %define CONFIG_GPROF 0 %define CONFIG_GCOV 0 %define CONFIG_RVCT 0 %define CONFIG_GCC 0 %define CONFIG_MSVS 1 %define CONFIG_PIC 0 %define CONFIG_BIG_ENDIAN 0 %define CONFIG_CODEC_SRCS 0 %define CONFIG_DEBUG_LIBS 0 %define CONFIG_DEQUANT_TOKENS 0 %define CONFIG_DC_RECON 0 %define CONFIG_RUNTIME_CPU_DETECT 1 %define CONFIG_POSTPROC 1 %define CONFIG_VP9_POSTPROC 1 %define CONFIG_MULTITHREAD 1 %define CONFIG_INTERNAL_STATS 0 %define CONFIG_VP8_ENCODER 1 %define CONFIG_VP8_DECODER 1 %define CONFIG_VP9_ENCODER 1 %define CONFIG_VP9_DECODER 1 %define CONFIG_VP10_ENCODER 0 %define CONFIG_VP10_DECODER 0 %define CONFIG_VP8 1 %define CONFIG_VP9 1 %define CONFIG_VP10 0 %define CONFIG_ENCODERS 1 %define CONFIG_DECODERS 1 %define CONFIG_STATIC_MSVCRT 0 %define CONFIG_SPATIAL_RESAMPLING 1 %define CONFIG_REALTIME_ONLY 1 %define CONFIG_ONTHEFLY_BITPACKING 0 %define CONFIG_ERROR_CONCEALMENT 0 %define CONFIG_SHARED 0 %define CONFIG_STATIC 1 %define CONFIG_SMALL 0 %define CONFIG_POSTPROC_VISUALIZER 0 %define CONFIG_OS_SUPPORT 1 %define CONFIG_UNIT_TESTS 0 %define CONFIG_WEBM_IO 1 %define CONFIG_LIBYUV 1 %define CONFIG_DECODE_PERF_TESTS 0 %define CONFIG_ENCODE_PERF_TESTS 0 %define CONFIG_MULTI_RES_ENCODING 1 %define CONFIG_TEMPORAL_DENOISING 1 %define CONFIG_VP9_TEMPORAL_DENOISING 1 %define CONFIG_COEFFICIENT_RANGE_CHECKING 0 %define CONFIG_VP9_HIGHBITDEPTH 0 %define CONFIG_EXPERIMENTAL 0 %define CONFIG_SIZE_LIMIT 1 %define CONFIG_SPATIAL_SVC 0 %define CONFIG_FP_MB_STATS 0 %define CONFIG_EMULATE_HARDWARE 0 %define CONFIG_MISC_FIXES 0 %define DECODE_WIDTH_LIMIT 16384 %define DECODE_HEIGHT_LIMIT 16384
/* * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ #include <AK/StringBuilder.h> #include <LibJS/Runtime/Error.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/IteratorOperations.h> #include <LibJS/Runtime/StringIterator.h> #include <LibJS/Runtime/StringIteratorPrototype.h> namespace JS { StringIteratorPrototype::StringIteratorPrototype(GlobalObject& global_object) : Object(*global_object.iterator_prototype()) { } void StringIteratorPrototype::initialize(GlobalObject& global_object) { auto& vm = this->vm(); Object::initialize(global_object); define_native_function(vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 22.1.5.1.2 %StringIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%stringiteratorprototype%-@@tostringtag define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "String Iterator"), Attribute::Configurable); } StringIteratorPrototype::~StringIteratorPrototype() { } // 22.1.5.1.1 %StringIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next JS_DEFINE_NATIVE_FUNCTION(StringIteratorPrototype::next) { auto this_value = vm.this_value(global_object); if (!this_value.is_object() || !is<StringIterator>(this_value.as_object())) { vm.throw_exception<TypeError>(global_object, ErrorType::NotA, "String Iterator"); return {}; } auto& this_object = this_value.as_object(); auto& iterator = static_cast<StringIterator&>(this_object); if (iterator.done()) return create_iterator_result_object(global_object, js_undefined(), true); auto& utf8_iterator = iterator.iterator(); if (utf8_iterator.done()) { iterator.m_done = true; return create_iterator_result_object(global_object, js_undefined(), true); } StringBuilder builder; builder.append_code_point(*utf8_iterator); ++utf8_iterator; return create_iterator_result_object(global_object, js_string(vm, builder.to_string()), false); } }
OPTION DOTNAME .text$ SEGMENT ALIGN(256) 'CODE' ALIGN 32 $L$one:: DQ 1,0,0,0,0,0,0,0 PUBLIC eucl_inverse_mod_384 ALIGN 32 eucl_inverse_mod_384 PROC PUBLIC DB 243,15,30,250 mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov r11,rsp $L$SEH_begin_eucl_inverse_mod_384:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 push rbp push rbx push r12 push r13 push r14 push r15 sub rsp,216 $L$SEH_body_eucl_inverse_mod_384:: mov QWORD PTR[rsp],rdi lea rbp,QWORD PTR[$L$one] cmp rcx,0 cmove rcx,rbp mov rax,QWORD PTR[rsi] mov r9,QWORD PTR[8+rsi] mov r10,QWORD PTR[16+rsi] mov r11,QWORD PTR[24+rsi] mov r12,QWORD PTR[32+rsi] mov r13,QWORD PTR[40+rsi] mov r8,rax or rax,r9 or rax,r10 or rax,r11 or rax,r12 or rax,r13 jz $L$abort lea rsi,QWORD PTR[16+rsp] mov r14,QWORD PTR[rcx] mov r15,QWORD PTR[8+rcx] mov rax,QWORD PTR[16+rcx] mov rbx,QWORD PTR[24+rcx] mov rbp,QWORD PTR[32+rcx] mov rdi,QWORD PTR[40+rcx] mov QWORD PTR[rsi],r8 mov QWORD PTR[8+rsi],r9 mov QWORD PTR[16+rsi],r10 mov QWORD PTR[24+rsi],r11 mov QWORD PTR[32+rsi],r12 mov QWORD PTR[40+rsi],r13 lea rcx,QWORD PTR[112+rsp] mov r8,QWORD PTR[rdx] mov r9,QWORD PTR[8+rdx] mov r10,QWORD PTR[16+rdx] mov r11,QWORD PTR[24+rdx] mov r12,QWORD PTR[32+rdx] mov r13,QWORD PTR[40+rdx] mov QWORD PTR[48+rsi],r14 mov QWORD PTR[56+rsi],r15 mov QWORD PTR[64+rsi],rax mov QWORD PTR[72+rsi],rbx mov QWORD PTR[80+rsi],rbp mov QWORD PTR[88+rsi],rdi mov QWORD PTR[rcx],r8 mov QWORD PTR[8+rcx],r9 mov QWORD PTR[16+rcx],r10 mov QWORD PTR[24+rcx],r11 mov QWORD PTR[32+rcx],r12 mov QWORD PTR[40+rcx],r13 xor eax,eax mov QWORD PTR[48+rcx],rax mov QWORD PTR[56+rcx],rax mov QWORD PTR[64+rcx],rax mov QWORD PTR[72+rcx],rax mov QWORD PTR[80+rcx],rax mov QWORD PTR[88+rcx],rax jmp $L$oop_inv ALIGN 32 $L$oop_inv:: lea rsi,QWORD PTR[112+rsp] call __remove_powers_of_2 lea rsi,QWORD PTR[16+rsp] call __remove_powers_of_2 lea rcx,QWORD PTR[112+rsp] sub r8,QWORD PTR[((112+0))+rsp] sbb r9,QWORD PTR[8+rcx] sbb r10,QWORD PTR[16+rcx] sbb r11,QWORD PTR[24+rcx] sbb r12,QWORD PTR[32+rcx] sbb r13,QWORD PTR[40+rcx] jae $L$u_greater_than_v xchg rsi,rcx not r8 not r9 not r10 not r11 not r12 not r13 add r8,1 adc r9,0 adc r10,0 adc r11,0 adc r12,0 adc r13,0 $L$u_greater_than_v:: mov r14,QWORD PTR[48+rsi] mov r15,QWORD PTR[56+rsi] mov rax,QWORD PTR[64+rsi] mov rbx,QWORD PTR[72+rsi] mov rbp,QWORD PTR[80+rsi] mov rdi,QWORD PTR[88+rsi] sub r14,QWORD PTR[48+rcx] sbb r15,QWORD PTR[56+rcx] sbb rax,QWORD PTR[64+rcx] sbb rbx,QWORD PTR[72+rcx] sbb rbp,QWORD PTR[80+rcx] sbb rdi,QWORD PTR[88+rcx] mov QWORD PTR[rsi],r8 sbb r8,r8 mov QWORD PTR[8+rsi],r9 mov r9,r8 mov QWORD PTR[16+rsi],r10 mov r10,r8 mov QWORD PTR[24+rsi],r11 mov r11,r8 mov QWORD PTR[32+rsi],r12 mov r12,r8 mov QWORD PTR[40+rsi],r13 mov r13,r8 and r8,QWORD PTR[rdx] and r9,QWORD PTR[8+rdx] and r10,QWORD PTR[16+rdx] and r11,QWORD PTR[24+rdx] and r12,QWORD PTR[32+rdx] and r13,QWORD PTR[40+rdx] add r14,r8 adc r15,r9 adc rax,r10 adc rbx,r11 adc rbp,r12 adc rdi,r13 mov QWORD PTR[48+rsi],r14 mov QWORD PTR[56+rsi],r15 mov QWORD PTR[64+rsi],rax mov QWORD PTR[72+rsi],rbx mov QWORD PTR[80+rsi],rbp mov QWORD PTR[88+rsi],rdi mov r8,QWORD PTR[((16+0))+rsp] mov r9,QWORD PTR[((16+8))+rsp] mov r10,QWORD PTR[((16+16))+rsp] mov r11,QWORD PTR[((16+24))+rsp] or r8,r9 or r10,QWORD PTR[((16+32))+rsp] or r11,QWORD PTR[((16+40))+rsp] DB 067h or r8,r10 or r8,r11 jnz $L$oop_inv lea rsi,QWORD PTR[112+rsp] mov rdi,QWORD PTR[rsp] mov eax,1 mov r8,QWORD PTR[48+rsi] mov r9,QWORD PTR[56+rsi] mov r10,QWORD PTR[64+rsi] mov r11,QWORD PTR[72+rsi] mov r12,QWORD PTR[80+rsi] mov r13,QWORD PTR[88+rsi] $L$abort:: mov QWORD PTR[rdi],r8 mov QWORD PTR[8+rdi],r9 mov QWORD PTR[16+rdi],r10 mov QWORD PTR[24+rdi],r11 mov QWORD PTR[32+rdi],r12 mov QWORD PTR[40+rdi],r13 lea r8,QWORD PTR[216+rsp] mov r15,QWORD PTR[r8] mov r14,QWORD PTR[8+r8] mov r13,QWORD PTR[16+r8] mov r12,QWORD PTR[24+r8] mov rbx,QWORD PTR[32+r8] mov rbp,QWORD PTR[40+r8] lea rsp,QWORD PTR[48+r8] $L$SEH_epilogue_eucl_inverse_mod_384:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_eucl_inverse_mod_384:: eucl_inverse_mod_384 ENDP ALIGN 32 __remove_powers_of_2 PROC PRIVATE DB 243,15,30,250 mov r8,QWORD PTR[rsi] mov r9,QWORD PTR[8+rsi] mov r10,QWORD PTR[16+rsi] mov r11,QWORD PTR[24+rsi] mov r12,QWORD PTR[32+rsi] mov r13,QWORD PTR[40+rsi] $L$oop_of_2:: bsf rcx,r8 mov eax,63 cmovz ecx,eax cmp ecx,0 je $L$oop_of_2_done shr r8,cl mov r14,r9 shr r9,cl mov r15,r10 shr r10,cl mov rax,r11 shr r11,cl mov rbx,r12 shr r12,cl mov rbp,r13 shr r13,cl neg cl shl r14,cl shl r15,cl or r8,r14 mov r14,QWORD PTR[48+rsi] shl rax,cl or r9,r15 mov r15,QWORD PTR[56+rsi] shl rbx,cl or r10,rax mov rax,QWORD PTR[64+rsi] shl rbp,cl or r11,rbx mov rbx,QWORD PTR[72+rsi] or r12,rbp mov rbp,QWORD PTR[80+rsi] neg cl mov rdi,QWORD PTR[88+rsi] mov QWORD PTR[rsi],r8 mov QWORD PTR[8+rsi],r9 mov QWORD PTR[16+rsi],r10 mov QWORD PTR[24+rsi],r11 mov QWORD PTR[32+rsi],r12 mov QWORD PTR[40+rsi],r13 jmp $L$oop_div_by_2 ALIGN 32 $L$oop_div_by_2:: mov r13,1 mov r8,QWORD PTR[rdx] and r13,r14 mov r9,QWORD PTR[8+rdx] neg r13 mov r10,QWORD PTR[16+rdx] and r8,r13 mov r11,QWORD PTR[24+rdx] and r9,r13 mov r12,QWORD PTR[32+rdx] and r10,r13 and r11,r13 and r12,r13 and r13,QWORD PTR[40+rdx] add r14,r8 adc r15,r9 adc rax,r10 adc rbx,r11 adc rbp,r12 adc rdi,r13 sbb r13,r13 shr r14,1 mov r8,r15 shr r15,1 mov r9,rax shr rax,1 mov r10,rbx shr rbx,1 mov r11,rbp shr rbp,1 mov r12,rdi shr rdi,1 shl r8,63 shl r9,63 or r14,r8 shl r10,63 or r15,r9 shl r11,63 or rax,r10 shl r12,63 or rbx,r11 shl r13,63 or rbp,r12 or rdi,r13 dec ecx jnz $L$oop_div_by_2 mov r8,QWORD PTR[rsi] mov r9,QWORD PTR[8+rsi] mov r10,QWORD PTR[16+rsi] mov r11,QWORD PTR[24+rsi] mov r12,QWORD PTR[32+rsi] mov r13,QWORD PTR[40+rsi] mov QWORD PTR[48+rsi],r14 mov QWORD PTR[56+rsi],r15 mov QWORD PTR[64+rsi],rax mov QWORD PTR[72+rsi],rbx mov QWORD PTR[80+rsi],rbp mov QWORD PTR[88+rsi],rdi test r8,1 DB 02eh jz $L$oop_of_2 $L$oop_of_2_done:: DB 0F3h,0C3h ;repret __remove_powers_of_2 ENDP .text$ ENDS .pdata SEGMENT READONLY ALIGN(4) ALIGN 4 DD imagerel $L$SEH_begin_eucl_inverse_mod_384 DD imagerel $L$SEH_body_eucl_inverse_mod_384 DD imagerel $L$SEH_info_eucl_inverse_mod_384_prologue DD imagerel $L$SEH_body_eucl_inverse_mod_384 DD imagerel $L$SEH_epilogue_eucl_inverse_mod_384 DD imagerel $L$SEH_info_eucl_inverse_mod_384_body DD imagerel $L$SEH_epilogue_eucl_inverse_mod_384 DD imagerel $L$SEH_end_eucl_inverse_mod_384 DD imagerel $L$SEH_info_eucl_inverse_mod_384_epilogue .pdata ENDS .xdata SEGMENT READONLY ALIGN(8) ALIGN 8 $L$SEH_info_eucl_inverse_mod_384_prologue:: DB 1,0,5,00bh DB 0,074h,1,0 DB 0,064h,2,0 DB 0,003h DB 0,0 $L$SEH_info_eucl_inverse_mod_384_body:: DB 1,0,18,0 DB 000h,0f4h,01bh,000h DB 000h,0e4h,01ch,000h DB 000h,0d4h,01dh,000h DB 000h,0c4h,01eh,000h DB 000h,034h,01fh,000h DB 000h,054h,020h,000h DB 000h,074h,022h,000h DB 000h,064h,023h,000h DB 000h,001h,021h,000h $L$SEH_info_eucl_inverse_mod_384_epilogue:: DB 1,0,4,0 DB 000h,074h,001h,000h DB 000h,064h,002h,000h DB 000h,000h,000h,000h .xdata ENDS END
; void *p_stack_top(p_stack_t *s) SECTION code_clib SECTION code_adt_p_stack PUBLIC p_stack_top EXTERN asm_p_stack_top defc p_stack_top = asm_p_stack_top ; SDCC bridge for Classic IF __CLASSIC PUBLIC _p_stack_top defc _p_stack_top = p_stack_top ENDIF
SECTION code_fp_math32 PUBLIC cm32_sccz80_fsload .cm32_sccz80_fsload ; sccz80 float primitive ; Load float pointed to by HL into DEHL ; ; enter : HL = float* (sccz80_float) ; ; exit : DEHL = float (sccz80_float) ; ; uses : f, bc, de, hl ld c,(hl) inc hl ld b,(hl) inc hl ld e,(hl) inc hl ld d,(hl) ; DEBC = sccz80_float ld l,c ld h,b ret ; DEHL = sccz80_float
//------------------------------------------------------------------------------ /* Copyright (c) 2012, 2013 Ripple Labs Inc. Copyright (c) 2019 Ripple Alpha Association. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== #include <ripple/app/tx/impl/Payment.h> #include <ripple/app/paths/RippleCalc.h> #include <ripple/basics/Log.h> #include <ripple/core/Config.h> #include <ripple/protocol/Feature.h> #include <ripple/protocol/jss.h> #include <ripple/protocol/st.h> #include <ripple/protocol/TxFlags.h> namespace ripple { // See https://ripple.com/wiki/Transaction_Format#Payment_.280.29 XRPAmount Payment::calculateMaxSpend(STTx const& tx) { if (tx.isFieldPresent(sfSendMax)) { auto const& sendMax = tx[sfSendMax]; return sendMax.native() ? sendMax.xrp() : beast::zero; } /* If there's no sfSendMax in XRP, and the sfAmount isn't in XRP, then the transaction can not send XRP. */ auto const& saDstAmount = tx.getFieldAmount(sfAmount); return saDstAmount.native() ? saDstAmount.xrp() : beast::zero; } NotTEC Payment::preflight (PreflightContext const& ctx) { auto const ret = preflight1 (ctx); if (!isTesSuccess (ret)) return ret; auto& tx = ctx.tx; auto& j = ctx.j; std::uint32_t const uTxFlags = tx.getFlags (); if (uTxFlags & tfPaymentMask) { JLOG(j.trace()) << "Malformed transaction: " << "Invalid flags set."; return temINVALID_FLAG; } bool const partialPaymentAllowed = uTxFlags & tfPartialPayment; bool const limitQuality = uTxFlags & tfLimitQuality; bool const defaultPathsAllowed = !(uTxFlags & tfNoRippleDirect); bool const bPaths = tx.isFieldPresent (sfPaths); bool const bMax = tx.isFieldPresent (sfSendMax); STAmount const saDstAmount (tx.getFieldAmount (sfAmount)); STAmount maxSourceAmount; auto const account = tx.getAccountID(sfAccount); if (bMax) maxSourceAmount = tx.getFieldAmount (sfSendMax); else if (saDstAmount.native ()) maxSourceAmount = saDstAmount; else maxSourceAmount = STAmount ( { saDstAmount.getCurrency (), account }, saDstAmount.mantissa(), saDstAmount.exponent (), saDstAmount < beast::zero); auto const& uSrcCurrency = maxSourceAmount.getCurrency (); auto const& uDstCurrency = saDstAmount.getCurrency (); // isZero() is XRP. FIX! bool const bXRPDirect = uSrcCurrency.isZero () && uDstCurrency.isZero (); if (!isLegalNet (saDstAmount) || !isLegalNet (maxSourceAmount)) return temBAD_AMOUNT; auto const uDstAccountID = tx.getAccountID (sfDestination); if (!uDstAccountID) { JLOG(j.trace()) << "Malformed transaction: " << "Payment destination account not specified."; return temDST_NEEDED; } if (bMax && maxSourceAmount <= beast::zero) { JLOG(j.trace()) << "Malformed transaction: " << "bad max amount: " << maxSourceAmount.getFullText (); return temBAD_AMOUNT; } if (saDstAmount <= beast::zero) { JLOG(j.trace()) << "Malformed transaction: "<< "bad dst amount: " << saDstAmount.getFullText (); return temBAD_AMOUNT; } if (badCurrency() == uSrcCurrency || badCurrency() == uDstCurrency) { JLOG(j.trace()) <<"Malformed transaction: " << "Bad currency."; return temBAD_CURRENCY; } if (account == uDstAccountID && uSrcCurrency == uDstCurrency && !bPaths) { // You're signing yourself a payment. // If bPaths is true, you might be trying some arbitrage. JLOG(j.trace()) << "Malformed transaction: " << "Redundant payment from " << to_string (account) << " to self without path for " << to_string (uDstCurrency); return temREDUNDANT; } if (bXRPDirect && bMax) { // Consistent but redundant transaction. JLOG(j.trace()) << "Malformed transaction: " << "SendMax specified for XLA to XLA."; return temBAD_SEND_XLA_MAX; } if (bXRPDirect && bPaths) { // XLA is sent without paths. JLOG(j.trace()) << "Malformed transaction: " << "Paths specified for XLA to XLA."; return temBAD_SEND_XLA_PATHS; } if (bXRPDirect && partialPaymentAllowed) { // Consistent but redundant transaction. JLOG(j.trace()) << "Malformed transaction: " << "Partial payment specified for XLA to XLA."; return temBAD_SEND_XLA_PARTIAL; } if (bXRPDirect && limitQuality) { // Consistent but redundant transaction. JLOG(j.trace()) << "Malformed transaction: " << "Limit quality specified for XLA to XLA."; return temBAD_SEND_XLA_LIMIT; } if (bXRPDirect && !defaultPathsAllowed) { // Consistent but redundant transaction. JLOG(j.trace()) << "Malformed transaction: " << "No ripple direct specified for XLA to XLA."; return temBAD_SEND_XLA_NO_DIRECT; } auto const deliverMin = tx[~sfDeliverMin]; if (deliverMin) { if (! partialPaymentAllowed) { JLOG(j.trace()) << "Malformed transaction: Partial payment not " "specified for " << jss::DeliverMin.c_str() << "."; return temBAD_AMOUNT; } auto const dMin = *deliverMin; if (!isLegalNet(dMin) || dMin <= beast::zero) { JLOG(j.trace()) << "Malformed transaction: Invalid " << jss::DeliverMin.c_str() << " amount. " << dMin.getFullText(); return temBAD_AMOUNT; } if (dMin.issue() != saDstAmount.issue()) { JLOG(j.trace()) << "Malformed transaction: Dst issue differs " "from " << jss::DeliverMin.c_str() << ". " << dMin.getFullText(); return temBAD_AMOUNT; } if (dMin > saDstAmount) { JLOG(j.trace()) << "Malformed transaction: Dst amount less than " << jss::DeliverMin.c_str() << ". " << dMin.getFullText(); return temBAD_AMOUNT; } } return preflight2 (ctx); } TER Payment::preclaim(PreclaimContext const& ctx) { // Ripple if source or destination is non-native or if there are paths. std::uint32_t const uTxFlags = ctx.tx.getFlags(); bool const partialPaymentAllowed = uTxFlags & tfPartialPayment; auto const paths = ctx.tx.isFieldPresent(sfPaths); auto const sendMax = ctx.tx[~sfSendMax]; AccountID const uDstAccountID(ctx.tx[sfDestination]); STAmount const saDstAmount(ctx.tx[sfAmount]); auto const k = keylet::account(uDstAccountID); auto const sleDst = ctx.view.read(k); if (!sleDst) { // Destination account does not exist. if (!saDstAmount.native()) { JLOG(ctx.j.trace()) << "Delay transaction: Destination account does not exist."; // Another transaction could create the account and then this // transaction would succeed. return tecNO_DST; } else if (ctx.view.open() && partialPaymentAllowed) { // You cannot fund an account with a partial payment. // Make retry work smaller, by rejecting this. JLOG(ctx.j.trace()) << "Delay transaction: Partial payment not allowed to create account."; // Another transaction could create the account and then this // transaction would succeed. return telNO_DST_PARTIAL; } else if (saDstAmount < STAmount(ctx.view.fees().accountReserve(0))) { // accountReserve is the minimum amount that an account can have. // Reserve is not scaled by load. JLOG(ctx.j.trace()) << "Delay transaction: Destination account does not exist. " << "Insufficent payment to create account."; // TODO: dedupe // Another transaction could create the account and then this // transaction would succeed. return tecNO_DST_INSUF_XLA; } } else if ((sleDst->getFlags() & lsfRequireDestTag) && !ctx.tx.isFieldPresent(sfDestinationTag)) { // The tag is basically account-specific information we don't // understand, but we can require someone to fill it in. // We didn't make this test for a newly-formed account because there's // no way for this field to be set. JLOG(ctx.j.trace()) << "Malformed transaction: DestinationTag required."; return tecDST_TAG_NEEDED; } if (paths || sendMax || !saDstAmount.native()) { // Ripple payment with at least one intermediate step and uses // transitive balances. // Copy paths into an editable class. STPathSet const spsPaths = ctx.tx.getFieldPathSet(sfPaths); auto pathTooBig = spsPaths.size() > MaxPathSize; if(!pathTooBig) for (auto const& path : spsPaths) if (path.size() > MaxPathLength) { pathTooBig = true; break; } if (ctx.view.open() && pathTooBig) { return telBAD_PATH_COUNT; // Too many paths for proposed ledger. } } return tesSUCCESS; } TER Payment::doApply () { auto const deliverMin = ctx_.tx[~sfDeliverMin]; // Ripple if source or destination is non-native or if there are paths. std::uint32_t const uTxFlags = ctx_.tx.getFlags (); bool const partialPaymentAllowed = uTxFlags & tfPartialPayment; bool const limitQuality = uTxFlags & tfLimitQuality; bool const defaultPathsAllowed = !(uTxFlags & tfNoRippleDirect); auto const paths = ctx_.tx.isFieldPresent(sfPaths); auto const sendMax = ctx_.tx[~sfSendMax]; AccountID const uDstAccountID (ctx_.tx.getAccountID (sfDestination)); STAmount const saDstAmount (ctx_.tx.getFieldAmount (sfAmount)); STAmount maxSourceAmount; if (sendMax) maxSourceAmount = *sendMax; else if (saDstAmount.native ()) maxSourceAmount = saDstAmount; else maxSourceAmount = STAmount ( {saDstAmount.getCurrency (), account_}, saDstAmount.mantissa(), saDstAmount.exponent (), saDstAmount < beast::zero); JLOG(j_.trace()) << "maxSourceAmount=" << maxSourceAmount.getFullText () << " saDstAmount=" << saDstAmount.getFullText (); // Open a ledger for editing. auto const k = keylet::account(uDstAccountID); SLE::pointer sleDst = view().peek (k); if (!sleDst) { std::uint32_t const seqno { view().rules().enabled(featureDeletableAccounts) ? view().seq() : 1}; // Create the account. sleDst = std::make_shared<SLE>(k); sleDst->setAccountID(sfAccount, uDstAccountID); sleDst->setFieldU32(sfSequence, seqno); view().insert(sleDst); } else { // Tell the engine that we are intending to change the destination // account. The source account gets always charged a fee so it's always // marked as modified. view().update (sleDst); } // Determine whether the destination requires deposit authorization. bool const reqDepositAuth = sleDst->getFlags() & lsfDepositAuth && view().rules().enabled(featureDepositAuth); bool const depositPreauth = view().rules().enabled(featureDepositPreauth); bool const bRipple = paths || sendMax || !saDstAmount.native (); // If the destination has lsfDepositAuth set, then only direct XRP // payments (no intermediate steps) are allowed to the destination. if (!depositPreauth && bRipple && reqDepositAuth) return tecNO_PERMISSION; if (bRipple) { // Ripple payment with at least one intermediate step and uses // transitive balances. if (depositPreauth && reqDepositAuth) { // If depositPreauth is enabled, then an account that requires // authorization has two ways to get an IOU Payment in: // 1. If Account == Destination, or // 2. If Account is deposit preauthorized by destination. if (uDstAccountID != account_) { if (! view().exists ( keylet::depositPreauth (uDstAccountID, account_))) return tecNO_PERMISSION; } } // Copy paths into an editable class. STPathSet spsPaths = ctx_.tx.getFieldPathSet (sfPaths); path::RippleCalc::Input rcInput; rcInput.partialPaymentAllowed = partialPaymentAllowed; rcInput.defaultPathsAllowed = defaultPathsAllowed; rcInput.limitQuality = limitQuality; rcInput.isLedgerOpen = view().open(); path::RippleCalc::Output rc; { PaymentSandbox pv(&view()); JLOG(j_.debug()) << "Entering RippleCalc in payment: " << ctx_.tx.getTransactionID(); rc = path::RippleCalc::rippleCalculate ( pv, maxSourceAmount, saDstAmount, uDstAccountID, account_, spsPaths, ctx_.app.logs(), &rcInput); // VFALCO NOTE We might not need to apply, depending // on the TER. But always applying *should* // be safe. pv.apply(ctx_.rawView()); } // TODO: is this right? If the amount is the correct amount, was // the delivered amount previously set? if (rc.result () == tesSUCCESS && rc.actualAmountOut != saDstAmount) { if (deliverMin && rc.actualAmountOut < *deliverMin) rc.setResult (tecPATH_PARTIAL); else ctx_.deliver (rc.actualAmountOut); } auto terResult = rc.result (); // Because of its overhead, if RippleCalc // fails with a retry code, claim a fee // instead. Maybe the user will be more // careful with their path spec next time. if (isTerRetry (terResult)) terResult = tecPATH_DRY; return terResult; } assert (saDstAmount.native ()); // Direct XRP payment. auto const sleSrc = view().peek(keylet::account(account_)); if (! sleSrc) return tefINTERNAL; // uOwnerCount is the number of entries in this ledger for this // account that require a reserve. auto const uOwnerCount = sleSrc->getFieldU32 (sfOwnerCount); // This is the total reserve in drops. auto const reserve = view().fees().accountReserve(uOwnerCount); // mPriorBalance is the balance on the sending account BEFORE the // fees were charged. We want to make sure we have enough reserve // to send. Allow final spend to use reserve for fee. auto const mmm = std::max(reserve, ctx_.tx.getFieldAmount (sfFee).xrp ()); if (mPriorBalance < saDstAmount.xrp () + mmm) { // Vote no. However the transaction might succeed, if applied in // a different order. JLOG(j_.trace()) << "Delay transaction: Insufficient funds: " << " " << to_string (mPriorBalance) << " / " << to_string (saDstAmount.xrp () + mmm) << " (" << to_string (reserve) << ")"; return tecUNFUNDED_PAYMENT; } // The source account does have enough money. Make sure the // source account has authority to deposit to the destination. if (reqDepositAuth) { // If depositPreauth is enabled, then an account that requires // authorization has three ways to get an XRP Payment in: // 1. If Account == Destination, or // 2. If Account is deposit preauthorized by destination, or // 3. If the destination's XRP balance is // a. less than or equal to the base reserve and // b. the deposit amount is less than or equal to the base reserve, // then we allow the deposit. // // Rule 3 is designed to keep an account from getting wedged // in an unusable state if it sets the lsfDepositAuth flag and // then consumes all of its XRP. Without the rule if an // account with lsfDepositAuth set spent all of its XRP, it // would be unable to acquire more XRP required to pay fees. // // We choose the base reserve as our bound because it is // a small number that seldom changes but is always sufficient // to get the account un-wedged. if (uDstAccountID != account_) { if (! view().exists ( keylet::depositPreauth (uDstAccountID, account_))) { // Get the base reserve. XRPAmount const dstReserve {view().fees().accountReserve (0)}; if (saDstAmount > dstReserve || sleDst->getFieldAmount (sfBalance) > dstReserve) return tecNO_PERMISSION; } } } // Do the arithmetic for the transfer and make the ledger change. sleSrc->setFieldAmount(sfBalance, mSourceBalance - saDstAmount); sleDst->setFieldAmount( sfBalance, sleDst->getFieldAmount(sfBalance) + saDstAmount); // Re-arm the password change fee if we can and need to. if ((sleDst->getFlags() & lsfPasswordSpent)) sleDst->clearFlag(lsfPasswordSpent); return tesSUCCESS; } } // ripple
; asm_c_call.asm print a string using printf and getenv ; Assemble: nasm -f elf64 -l asm_c_call.lst asm_c_call.asm ; Link: gcc -m64 -o asm_c_call asm_c_call.o ; Run: ./asm_c_call ; Equivalent C code ; // hello.c ; #include <stdio.h> ; int main() ; { ; char msg[] = "Hello world\n"; ; char envKey[] = "PATH"; ; // printf("%s\n", msg); ; printf("%s\n", getenv(envKey)); ; return 0; ; } ; Declare needed C functions extern printf ; the C function, to be called extern getenv ; Define data and variables section .data ; Data section, initialized variables msg: db "Hello world", 0 ; C string needs 0 fmt: db "%s", 10, 0 ; The printf format, "\n",'0' envKey: db "PATH", 0 envVal: db 5 section .text ; Code section. global main ; the standard gcc entry point main: ; the program label for the entry point push rbp ; set up stack frame, must be alligned mov rdi, envKey mov rax,0 call getenv ; this will set rax to point to a null terminated string in memory mov rdi,fmt ;mov rsi,msg mov rsi, rax ; Tells printf we want to print the result of getenv (which rax points to) mov rax,0 ; or can be xor rax,rax call printf ; Call C function pop rbp ; restore stack mov rax,0 ; normal, no error, return value ret ; return
/* For more information, please see: http://software.sci.utah.edu The MIT License Copyright (c) 2020 Scientific Computing and Imaging Institute, University of Utah. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <entity-system/GenericSystem.hpp> #include <gl-shaders/GLShader.hpp> #include <es-fs/Filesystem.hpp> #include <es-fs/fscomp/StaticFS.hpp> #include "ShaderMan.hpp" #include "comp/ShaderPromiseVF.hpp" #include "comp/StaticShaderMan.hpp" #include "comp/Shader.hpp" namespace es = spire; namespace fs = spire; namespace ren { std::string ShaderMan::mShaderHeader; ShaderMan::ShaderMan(int numRetries) : mNewUnfulfilledAssets(false), mNumRetries(numRetries) { } ShaderMan::~ShaderMan() { // Destroy all GLIDs. for (auto it = mGLToName.begin(); it != mGLToName.end(); ++it) { GL(glDeleteShader(it->first)); } } void ShaderMan::setShaderHeaderCode(const std::string& header) { mShaderHeader = header; } void ShaderMan::loadVertexAndFragmentShader( spire::CerealCore& core, uint64_t entityID, const std::string& assetName) { // Attempt to build the component from what we have in-memory. if (buildComponent(core, entityID, assetName) == false) { // Simply add a new promise component. Promise fulfillment will initiate // requests and create components as needed. ShaderPromiseVF newPromise; newPromise.requestInitiated = false; newPromise.setAssetName(assetName.c_str()); core.addComponent(entityID, newPromise); } } GLuint ShaderMan::addInMemoryVSFS( const std::string& vsSource, const std::string& fsSource, const std::string& assetName) { GLuint program = 0; if (mShaderHeader.size() > 0) { program = spire::loadShaderProgram( { spire::ShaderSource({mShaderHeader.c_str(), vsSource.c_str()}, GL_VERTEX_SHADER), spire::ShaderSource({mShaderHeader.c_str(), fsSource.c_str()}, GL_FRAGMENT_SHADER) }); } else { program = spire::loadShaderProgram( { spire::ShaderSource({vsSource.c_str()}, GL_VERTEX_SHADER), spire::ShaderSource({fsSource.c_str()}, GL_FRAGMENT_SHADER) }); } // Simply update mGLToName and mNameToGL. The fulfillment system will // handle everything else. mGLToName.insert(std::make_pair(program, assetName)); mNameToGL.insert(std::make_pair(assetName, program)); return program; } void ShaderMan::requestVSandFS(spire::ESCoreBase& core, const std::string& assetName, int32_t numRetries) { // Begin by attempting to load the vertex shader. fs::StaticFS* sfs = core.getStaticComponent<fs::StaticFS>(); std::string vertexShader = assetName + ".vs"; //sfs->instance->readFile(vertexShader, // std::bind(&ShaderMan::loadVertexShaderCB, this, // std::placeholders::_1, std::placeholders::_2, // std::placeholders::_3, std::placeholders::_4, // assetName, numRetries, std::ref(core))); /// \todo Get rid of this code when we switch to the new emscripten backend. /// std::bind is preferable to cooking up a lambda. Working bind code /// is given directly above. spire::ESCoreBase* refPtr = &core; auto callbackLambda = [this, assetName, numRetries, refPtr]( const std::string& vsName, bool error, size_t bytesRead, uint8_t* buffer) { loadVertexShaderCB(vsName, error, bytesRead, buffer, assetName, numRetries, *refPtr); }; sfs->instance->readFile(vertexShader, callbackLambda); } void ShaderMan::loadVertexShaderCB(const std::string& /* vsName */, bool error, size_t bytesRead, uint8_t* buffer, std::string assetName, int32_t numRetries, spire::ESCoreBase& core) { if (!error) { // Build a buffer 1 byte longer and terminate it with a null. // Pass the resulting string into our system. In the future, we should // add enough buffer to the beginning of the buffer to store any header // information. char* vertexSourceRaw = static_cast<char*>(std::malloc(bytesRead + 1)); std::memcpy(vertexSourceRaw , buffer, bytesRead); vertexSourceRaw[bytesRead] = '\0'; std::string vertexSource = vertexSourceRaw; std::free(vertexSourceRaw); std::string fragmentShader = assetName + ".fs"; fs::StaticFS* frag = core.getStaticComponent<fs::StaticFS>(); /// \todo Get rid of this code when we switch to the new emscripten backend. /// std::bind is preferable to cooking up a lambda. Working bind code /// is given directly below. spire::ESCoreBase* refPtr = &core; auto callbackLambda = [this, assetName, numRetries, refPtr, vertexSource]( const std::string& fsName, bool lambdaError, size_t lambdaBytesRead, uint8_t* lambdaBuffer) { loadFragmentShaderCB(fsName, lambdaError, lambdaBytesRead, lambdaBuffer, vertexSource, assetName, numRetries, *refPtr); }; frag->instance->readFile(fragmentShader, callbackLambda); } else { if (numRetries > 0) { // Reattempt the request --numRetries; requestVSandFS(core, assetName, numRetries); } else { logRendererError("ShaderMan: Failed promise for {}", assetName); logRendererError("Failed on vertex shader. Number of retries exceeded."); } } } void ShaderMan::loadFragmentShaderCB(const std::string& /* fsName */, bool error, size_t bytesRead, uint8_t* buffer, std::string vertexSource, std::string assetName, int32_t numRetries, spire::ESCoreBase& core) { // We have both the vertex shader and fragment shader source. Proceed // to compile the shader and add the appropriate component to the indicated // entityID. if (!error) { char* fragmentSourceRaw = static_cast<char*>(std::malloc(bytesRead + 1)); std::memcpy(fragmentSourceRaw , buffer, bytesRead); fragmentSourceRaw[bytesRead] = '\0'; std::string fragmentSource = fragmentSourceRaw; std::free(fragmentSourceRaw); GLuint program = 0; if (mShaderHeader.size() > 0) { program = spire::loadShaderProgram( { spire::ShaderSource({mShaderHeader.c_str(), vertexSource.c_str()}, GL_VERTEX_SHADER), spire::ShaderSource({mShaderHeader.c_str(), fragmentSource.c_str()}, GL_FRAGMENT_SHADER) }); } else { program = spire::loadShaderProgram( { spire::ShaderSource({vertexSource.c_str()}, GL_VERTEX_SHADER), spire::ShaderSource({fragmentSource.c_str()}, GL_FRAGMENT_SHADER) }); } // Simply update mGLToName and mNameToGL. The fulfillment system will // handle everything else. mGLToName.insert(std::make_pair(program, assetName)); mNameToGL.insert(std::make_pair(assetName, program)); // Set new unfulfilled assets flag so we know if a GC cycle will remove // valid assets. We can use this to disable a GC cycle if it will have // unintended side-effects. mNewUnfulfilledAssets = true; } else { if (numRetries > 0) { // Reattempt the request --numRetries; requestVSandFS(core, assetName, numRetries); } else { logRendererError("ShaderMan: Failed promise for {}", assetName); logRendererError("Failed on fragment shader. Number of retries exceeded."); } } } GLuint ShaderMan::getIDForAsset(const char* assetName) const { auto it = mNameToGL.find(std::string(assetName)); if (it != mNameToGL.end()) { return it->second; } else { return 0; } } std::string ShaderMan::getAssetFromID(GLuint id) const { auto it = mGLToName.find(id); if (it != mGLToName.end()) { return it->second; } else { return ""; } } /// Returns false if we failed to generate the component because the asset /// has not been loaded yet. bool ShaderMan::buildComponent(spire::CerealCore& core, uint64_t entityID, const std::string& assetName) { GLuint id = getIDForAsset(assetName.c_str()); if (id != 0) { // Go ahead and add a new component for the entityID. If this is the // last promise to fulfill, then systems should automatically start // rendering the data. Shader component; component.glid = id; core.addComponent(entityID, component); return true; } else { return false; } } //------------------------------------------------------------------------------ // PROMISE FULFILLMENT //------------------------------------------------------------------------------ class ShaderPromiseVFFulfillment : public spire::GenericSystem<true, ShaderPromiseVF, StaticShaderMan> { public: static const char* getName() {return "ren:ShaderPromiseVFFulfillment";} /// This is only ever touched if requestInitiated is false for any component. /// It is updated during traversal and checked at the end of traversal /// against requested assets to see if the asset is already being loaded. std::set<std::string> mAssetsAwaitingRequest; /// Names of the assets currently being processed for which an additional /// request should not be attempted. std::set<std::string> mAssetsAlreadyRequested; void preWalkComponents(spire::ESCoreBase&) override { mAssetsAwaitingRequest.clear(); mAssetsAlreadyRequested.clear(); } void postWalkComponents(spire::ESCoreBase& core) override { std::weak_ptr<ShaderMan> sm = core.getStaticComponent<StaticShaderMan>()->instance_; if (std::shared_ptr<ShaderMan> man = sm.lock()) { man->mNewUnfulfilledAssets = false; if (mAssetsAwaitingRequest.size() > 0) { std::set<std::string> assetsWithNoRequest; // Compute set difference and initiate requests for appropriate // components. std::set_difference(mAssetsAwaitingRequest.begin(), mAssetsAwaitingRequest.end(), mAssetsAlreadyRequested.begin(), mAssetsAlreadyRequested.end(), std::inserter(assetsWithNoRequest, assetsWithNoRequest.end())); for (const std::string& asset : assetsWithNoRequest) { man->requestVSandFS(core, asset, man->mNumRetries); } } } else { logRendererError("Unable to complete shader fulfillment. There is no ShaderMan."); } } void groupExecute(spire::ESCoreBase& core, uint64_t entityID, const spire::ComponentGroup<ShaderPromiseVF>& promisesGroup, const spire::ComponentGroup<StaticShaderMan>& shaderManGroup) override { std::weak_ptr<ShaderMan> sm = shaderManGroup.front().instance_; if (std::shared_ptr<ShaderMan> shaderMan = sm.lock()) { auto ourCorePtr = dynamic_cast<spire::CerealCore*>(&core); if (!ourCorePtr) { logRendererError("Unable to execute shader promise fulfillment. Bad cast."); return; } spire::CerealCore& ourCore = *ourCorePtr; int index = 0; for (const ShaderPromiseVF& p : promisesGroup) { // Check to see if this promise has been fulfilled. If it has, then // remove it and create the appropriate component for the indicated // entity. if (shaderMan->buildComponent(ourCore, entityID, p.assetName)) { // Remove this promise, and add a shader component to this promises' // entityID. It is safe to remove components while we are using a // system - addition / removal / modification doesn't happen until // a renormalization step. ourCore.removeComponentAtIndexT<ShaderPromiseVF>(entityID, index); } else { // The asset has not be loaded. Check to see if a request has // been initiated for the assets; if not, then run the request. // (this can happen when we serialize the game while we are // still waiting for assets). if (p.requestInitiated == false) { // Modify pre-existing promise to indicate that we are following // up with the promise. But, we don't initiate the request yet // since another promise may have already done so. We wait until // postWalkComponents to make a decision. ShaderPromiseVF newPromise = p; newPromise.requestInitiated = true; promisesGroup.modify(newPromise, static_cast<size_t>(index)); mAssetsAwaitingRequest.insert(std::string(newPromise.assetName)); } else { mAssetsAlreadyRequested.insert(std::string(p.assetName)); } } ++index; } } } }; const char* ShaderMan::getPromiseVFFulfillmentName() { return ShaderPromiseVFFulfillment::getName(); } //------------------------------------------------------------------------------ // GARBAGE COLLECTION //------------------------------------------------------------------------------ void ShaderMan::runGCAgainstVaidIDs(const std::set<GLuint>& validKeys) { if (mNewUnfulfilledAssets) { logRendererError("ShaderMan: Terminating garbage collection. Orphan assets that" " have yet to be associated with entity ID's would be GC'd"); return; } // Every GLuint in validKeys should be in our map. If there is not, then // there is an error in the system, and it should be reported. // The reverse is not expected to be true, and is what we are attempting to // correct with this function. auto it = mGLToName.begin(); for (const GLuint& id : validKeys) { // Find the key in the map, eliminating any keys that do not match the // current id along the way. We iterate through both the map and the set // in an ordered fashion. while (it != mGLToName.end() && it->first < id) { // Find the asset name in mNameToGL and erase. mNameToGL.erase(mNameToGL.find(it->second)); RENDERER_LOG("Shader GC: {}", it->second); // Erase our iterator and move on. Ensure we delete the program. GLuint idToErase = it->first; mGLToName.erase(it++); GL(glDeleteShader(idToErase)); } if (it == mGLToName.end()) { logRendererError("runGCAgainstVaidIDs: terminating early, validKeys contains " "elements not in Shader map."); break; } // Check to see if the valid ids contain a component that is not in // mGLToName. If an object manages its own shader, but still uses the shader // component, this is not an error. if (it->first > id) { logRendererError("runGCAgainstValidIDs: validKeys contains elements not in the Shader map."); } ++it; } // Terminate any remaining assets. while (it != mGLToName.end()) { // Find the asset name in mNameToGL and erase. mNameToGL.erase(mNameToGL.find(it->second)); RENDERER_LOG("Shader GC: ", it->second); // Erase our iterator and move on. Ensure we delete the program. GLuint idToErase = it->first; mGLToName.erase(it++); GL(glDeleteShader(idToErase)); } } class ShaderGarbageCollector : public spire::GenericSystem<false, Shader> { public: static const char* getName() {return "ren:ShaderGarbageCollector";} std::set<GLuint> mValidKeys; void preWalkComponents(spire::ESCoreBase&) override {mValidKeys.clear();} void postWalkComponents(spire::ESCoreBase& core) override { std::weak_ptr<ShaderMan> sm = core.getStaticComponent<StaticShaderMan>()->instance_; if (std::shared_ptr<ShaderMan> man = sm.lock()) { man->runGCAgainstVaidIDs(mValidKeys); mValidKeys.clear(); } else { logRendererError("Unable to complete shader garbage collection. There is no ShaderMan."); } } void execute(spire::ESCoreBase&, uint64_t /* entityID */, const Shader* shader) override { mValidKeys.insert(shader->glid); } }; const char* ShaderMan::getGCName() { return ShaderGarbageCollector::getName(); } void ShaderMan::registerSystems(spire::Acorn& core) { core.registerSystem<ShaderPromiseVFFulfillment>(); core.registerSystem<ShaderGarbageCollector>(); } void ShaderMan::runGCCycle(spire::ESCoreBase& core) { ShaderGarbageCollector gc; gc.walkComponents(core); } } // namespace ren
SECTION code_fp_math16 PUBLIC _atanf16_fastcall EXTERN atanf16 defc _atanf16_fastcall = atanf16
#include "MultiPanePhotovoltaic.hpp" #include <cassert> namespace MultiLayerOptics { /////////////////////////////////////////////////////////////////////////////////////// // CMultiPanePhotovoltaic /////////////////////////////////////////////////////////////////////////////////////// std::unique_ptr<CMultiPanePhotovoltaic> CMultiPanePhotovoltaic::create( const std::vector<std::shared_ptr<SingleLayerOptics::SpecularLayer>> & layers, const FenestrationCommon::CSeries & t_SolarRadiation, const FenestrationCommon::CSeries & t_DetectorData) { return std::unique_ptr<CMultiPanePhotovoltaic>( new CMultiPanePhotovoltaic(layers, t_SolarRadiation, t_DetectorData)); } CMultiPanePhotovoltaic::CMultiPanePhotovoltaic( const std::vector<std::shared_ptr<SingleLayerOptics::SpecularLayer>> & layers, const FenestrationCommon::CSeries & t_SolarRadiation, const FenestrationCommon::CSeries & t_DetectorData) : CMultiPaneSpecular(layers, t_SolarRadiation, t_DetectorData) {} CMultiPanePhotovoltaic::CMultiPanePhotovoltaic( std::vector<double> const & t_CommonWavelength, const FenestrationCommon::CSeries & t_SolarRadiation, const std::shared_ptr<SingleLayerOptics::SpecularLayer> & t_Layer) : CMultiPaneSpecular(t_CommonWavelength, t_SolarRadiation, t_Layer) {} double CMultiPanePhotovoltaic::AbsHeat(const size_t Index, const double t_Angle, const double minLambda, const double maxLambda, const FenestrationCommon::IntegrationType t_IntegrationType, const double normalizationCoefficient) { return Abs( Index, t_Angle, minLambda, maxLambda, t_IntegrationType, normalizationCoefficient) - AbsElectricity( Index, t_Angle, minLambda, maxLambda, t_IntegrationType, normalizationCoefficient); } double CMultiPanePhotovoltaic::AbsElectricity(size_t Index, double t_Angle, double minLambda, double maxLambda, FenestrationCommon::IntegrationType t_IntegrationType, double normalizationCoefficient) { if(dynamic_cast<SingleLayerOptics::PhotovoltaicLayer *>(m_Layers[Index - 1].get()) != nullptr) { const double totalSolar = m_SolarRadiation.integrate(t_IntegrationType, normalizationCoefficient) ->sum(minLambda, maxLambda); CEquivalentLayerSingleComponentMWAngle aAngularProperties = getAngular(t_Angle); auto aLayer = dynamic_cast<SingleLayerOptics::PhotovoltaicLayer *>(m_Layers[Index - 1].get()); auto frontJscPrime = aLayer->jscPrime(FenestrationCommon::Side::Front); // auto backJscPrime = aLayer->jscPrime(FenestrationCommon::Side::Back); // auto IPlus = aAngularProperties.iplus(Index - 1); auto IMinus = aAngularProperties.iminus(Index - 1); auto frontJsc = frontJscPrime * IMinus; auto JscIntegrated = frontJsc.integrate(t_IntegrationType, normalizationCoefficient); auto jsc{JscIntegrated->sum() * totalSolar}; const auto voc{aLayer->voc(jsc)}; const auto ff{aLayer->ff(jsc)}; const auto power{jsc * voc * ff}; assert(totalSolar > 0); return power / totalSolar; } return 0; } } // namespace MultiLayerOptics
; A020647: Least positive integer k for which 8^n divides k!. ; 1,4,8,12,16,16,20,24,28,32,32,36,40,42,46,48,52,56,58,62,64,64,68,72,76,80,80,84,88,92,96,96,100,104,106,110,112,116,120,122,126,128,128,132,136,138,142,144,148,152,154,158,160,162,166,168,172,176,178,182,184,188,192,192,196,200,202,206,208,212,216,218,222,224,226,230,232,236,240,242,246,248,252,256,256,256,260,264,268,272,272,276,280,284,288,288,292,296,298,302,304,308,312,314,318,320,320,324,328,332,336,336,340,344,348,352,352,356,360,362,366,368,372,376,378,382,384,384,388,392,394,398,400,404,408,410,414,416,418,422,424,428,432,434,438,440,444,448,448,452,456,458,462,464,468,472,474,478,480,482,486,488,492,496,498,502,504,508,512,512,512,516,520,522,526,528,532,536,538,542,544,546,550,552,556,560,562,566,568,572,576,576,580,584,586,590,592,596,600,602,606,608,610,614,616,620,624,626,630,632,636,640,640,642,646,648,652,656,658,662,664,668,672,672,676,680,684,688,688,692,696,700,704,704,706,710,712,716,720,722,726,728,732,736,736,740,744,748,752,752 mul $0,3 cal $0,7843 ; Least positive integer k for which 2^n divides k!. mov $1,$0
; Copyright 2015-2020 Matt "MateoConLechuga" Waltz ; ; 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. squish_program: ld hl,return_asm_error call ti.PushErrorHandler ld (persistent_sp),sp call util_move_prgm_name_to_op1 ld de,ti.basic_prog ld hl,ti.OP1 call ti.Mov9b ld hl,ti.OP1 ld de,backup_prgm_name call ti.Mov9b ld bc,(prgm_real_size) dec bc dec bc push bc bit 0,c jp nz,ti.ErrSyntax srl b rr c push bc push bc pop hl call ti.EnoughMem pop hl pop bc jp c,ti.ErrMemory push bc ld de,ti.userMem ld (ti.asm_prgm_size),hl call ti.InsertMem ld hl,(prgm_data_ptr) ld a,(prgm_data_ptr + 2) cp a,$d0 jr c,.not_in_ram call util_move_prgm_name_to_op1 call ti.ChkFindSym ex de,hl inc hl inc hl .not_in_ram: inc hl inc hl ld (ti.begPC),hl ld (ti.curPC),hl ld de,ti.userMem pop bc .squish_me: ld a,b or a,c jp z,execute_assembly_program push hl ld hl,(ti.curPC) inc hl ld (ti.curPC),hl pop hl dec bc ld a,(hl) inc hl cp a,$3f jr z,.squish_me push de call .squishy_check_byte ld d,a ld a,(hl) inc hl call .squishy_check_byte ld e,a call .squishy_convert_byte pop de ld (de),a inc de dec bc jr .squish_me .squishy_convert_byte: push bc push hl ld a,d call ti.ShlACC add a,e pop hl pop bc ret .squishy_check_byte: cp a,$30 jp c,ti.ErrSyntax cp a,$3A jr nc,.skip sub a,$30 ret .skip: cp a,$41 jp c,ti.ErrSyntax cp a,$47 jp nc,ti.ErrSyntax sub a,$37 ret
; A014993: a(n) = (1 - (-11)^n)/12. ; 1,-10,111,-1220,13421,-147630,1623931,-17863240,196495641,-2161452050,23775972551,-261535698060,2876892678661,-31645819465270,348104014117971,-3829144155297680,42120585708274481,-463326442791019290,5096590870701212191,-56062499577713334100,616687495354846675101,-6783562448903313426110,74619186937936447687211,-820811056317300924559320,9028921619490310170152521,-99318137814393411871677730,1092499515958327530588455031,-12017494675541602836473005340,132192441430957631201203058741 add $0,1 lpb $0 sub $0,1 sub $1,11 mul $1,-11 lpe div $1,121 mov $0,$1
;#########################################################; ; ; ; @description : KMP inplementation, find str_a in str_b ; ; @author : XQChen ; ; @email : chenxiaoquan233@gmail.com ; ; ; ;#########################################################; ASSUME DS:DATA,SS:STACK,CS:CODE DATA SEGMENT STRING STRUC MAX DB 255 ; the max length of the string LEN DB 0 ; the actual length inputed STR DB 254 DUP ('$') ; the string buffer STRING ENDS STRA STRING <> STRB STRING <> HINT DB 'PLEASE INPUT A STRING:$' FOUND DB 'FOUND','$' NFOUND DB 'NOT FOUND','$' NEWLINE DB 0DH,0AH,'$' ; end of line: '\r','\n' NEXT DB 256 DUP(0) ; next array in KMP DATA ENDS STACK SEGMENT STACK DB 64 DUP (0) STACK ENDS CODE SEGMENT START: MOV AX,DATA MOV DS,AX MOV ES,AX MOV AX,STACK MOV SS,AX MOV SP,40H CALL PH LEA DX,STRB CALL INPUT CALL ENDL CALL PH LEA DX,STRA CALL INPUT CALL ENDL MOV AH,STRA.LEN MOV AL,STRB.LEN CMP AL,AH JB NF CMP AH,0 JE F CMP AL,0 JE NF CALL GETN MOV DX,0 ; use DX to store the postion CALL KMP CMP DX,0FFFFH JE NF F: LEA DX,FOUND CALL PRINT JMP ENDPRO NF: LEA DX,NFOUND CALL PRINT JMP ENDPRO ENDPRO: MOV AX,4C00H INT 21H ;################################################; ; @ input function ; ; description: read a string ended with enter ; ;################################################; INPUT: PUSH AX MOV AH,0AH INT 21H POP AX RET ;##########################################################################; ; @ print function ; ; description: print the string from the pointed buffer(begin at DS:DX) ; ;##########################################################################; PRINT: PUSH AX PUSH BX XOR BX,BX MOV AH,09H INT 21H POP BX POP AX RET ;#################################; ; @ end of line functin ; ; description: print '\r','\n' ; ;#################################; ENDL: PUSH DX MOV DX,OFFSET NEWLINE CALL PRINT POP DX RET ;################################################; ; @ print hint function ; ; description: print "PLEASE INPUT A STRING:" ; ;################################################; PH: PUSH DX MOV DX,OFFSET HINT CALL PRINT POP DX RET ;#################################################; ; @ get next function ; ; description: calculate the next array in KMP ; ;#################################################; GETN: PUSH AX PUSH BX PUSH CX MOV NEXT[0],0FFH XOR BX,BX XOR CX,CX MOV DI,0FFFFH XOR SI,SI LOOPN: MOV BL,STRA.LEN CMP SI,BX JNB ENDGN CMP DI,0FFFFH JE EN MOV AH,STRA.STR[SI] MOV AL,STRA.STR[DI] CMP AH,AL JE EN NEN: MOV BL,NEXT[DI] MOV DI,BX MOV AX,DI XOR AX,0FFH ; DI is a 16-bit register, but next[DI] is a 8-bit memory unit JNZ LOOPN ; so if DI get 0xFF from next[DI] MOV DI,0FFFFH ; DI should be set to 0xFFFF EN: MOV AX,DI MOV NEXT[SI],AL INC DI INC SI JMP LOOPN ENDGN: POP CX POP BX POP AX RET ;#####################################; ; @ KMP function ; ; description: find str_a in str_b ; ;#####################################; KMP: PUSH AX PUSH BX PUSH CX XOR BX,BX XOR SI,SI XOR DI,DI FIND: MOV BL,STRA.LEN CMP DI,BX JGE KMPCMP MOV BL,STRB.LEN CMP SI,BX JNB KMPCMP CMP DI,0FFFFH JE KMPIF MOV AH,STRA.STR[SI] MOV AL,STRB.STR[DI] CMP AH,AL JE KMPIF MOV BL,NEXT[DI] MOV DI,BX MOV AX,DI XOR AX,0FFH JNZ KMPNZ MOV DI,0FFFFH KMPNZ: JMP FIND KMPIF: INC SI INC DI JMP FIND KMPCMP: MOV BL,STRA.LEN CMP SI,BX JGE KMPE MOV DX,0FFFFH JMP KMPEND KMPE: MOV BL,STRA.LEN SUB SI,BX MOV DX,SI KMPEND: POP CX POP BX POP AX RET CODE ENDS END START
SECTION code_clib SECTION code_fp_math48 PUBLIC ___fs2sint_callee EXTERN cm48_sdccixp_ds2sint_callee defc ___fs2sint_callee = cm48_sdccixp_ds2sint_callee
/* * Copyright (c) 2001-2008 * DecisionSoft Limited. All rights reserved. * Copyright (c) 2004-2008 * Oracle. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * $Id$ */ #ifndef __XPATHNAMESPACEIMPL_HPP #define __XPATHNAMESPACEIMPL_HPP #include <xqilla/framework/XQillaExport.hpp> #include <xercesc/util/XercesDefs.hpp> #include <xercesc/dom/impl/DOMNodeImpl.hpp> #include <xercesc/dom/DOMXPathNamespace.hpp> XERCES_CPP_NAMESPACE_BEGIN class DOMElement; class DOMDocument; XERCES_CPP_NAMESPACE_END class XQILLA_API XPathNamespaceImpl : public XERCES_CPP_NAMESPACE_QUALIFIER DOMXPathNamespace { public: XERCES_CPP_NAMESPACE_QUALIFIER DOMNodeImpl fNode; const XMLCh *uri; const XMLCh *prefix; enum XPathObjectType { XPATH_NAMESPACE_OBJECT = 13 }; public: //Main constructor XPathNamespaceImpl(const XMLCh* const prefix, const XMLCh* const uri, XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *owner, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *docOwner); XPathNamespaceImpl(const XPathNamespaceImpl &other); virtual ~XPathNamespaceImpl(); // Declare functions from DOMNode. They all must be implemented by this class virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* appendChild(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *newChild) ; virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* cloneNode(bool deep) const ; virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNamedNodeMap* getAttributes() const ; virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNodeList* getChildNodes() const ; virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* getFirstChild() const ; virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* getLastChild() const ; virtual const XMLCh* getLocalName() const ; virtual const XMLCh* getNamespaceURI() const ; virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* getNextSibling() const ; virtual const XMLCh* getNodeName() const ; #if _XERCES_VERSION >= 30000 virtual NodeType getNodeType() const; #else virtual short getNodeType() const; #endif virtual const XMLCh* getNodeValue() const ; virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* getOwnerDocument() const ; virtual const XMLCh* getPrefix() const ; virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* getParentNode() const ; virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* getPreviousSibling() const ; virtual bool hasChildNodes() const ; virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* insertBefore(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *newChild, XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *refChild) ; virtual void normalize() ; virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* removeChild(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *oldChild) ; virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* replaceChild(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *newChild, XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *oldChild) ; virtual void setNodeValue(const XMLCh *nodeValue) ; virtual bool isSupported(const XMLCh *feature, const XMLCh *version) const ; virtual bool hasAttributes() const ; virtual void setPrefix(const XMLCh * prefix) ; virtual void* setUserData(const XMLCh* key, void* data, XERCES_CPP_NAMESPACE_QUALIFIER DOMUserDataHandler* handler) ; virtual void* getUserData(const XMLCh* key) const ; virtual bool isSameNode(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* other) const; virtual bool isEqualNode(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* arg) const; virtual const XMLCh* getBaseURI() const ; #if _XERCES_VERSION >= 30000 virtual short compareDocumentPosition(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* other) const ; #else virtual short compareTreePosition(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* other) const ; #endif virtual const XMLCh* getTextContent() const ; virtual void setTextContent(const XMLCh* textContent) ; #if _XERCES_VERSION >= 30000 virtual const XMLCh* lookupPrefix(const XMLCh* namespaceURI) const; #else virtual const XMLCh* lookupNamespacePrefix(const XMLCh* namespaceURI, bool useDefault) const ; #endif virtual bool isDefaultNamespace(const XMLCh* namespaceURI) const; virtual const XMLCh* lookupNamespaceURI(const XMLCh* prefix) const ; #if _XERCES_VERSION >= 30000 virtual void* getFeature(const XMLCh* feature, const XMLCh* version) const; #else virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* getInterface(const XMLCh* feature) ; #endif virtual void release(); virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *getOwnerElement() const; }; #endif
; A063152: Dimension of the space of weight 2n cusp forms for Gamma_0( 84 ). ; 11,42,74,106,138,170,202,234,266,298,330,362,394,426,458,490,522,554,586,618,650,682,714,746,778,810,842,874,906,938,970,1002,1034,1066,1098,1130,1162,1194,1226,1258,1290,1322,1354,1386,1418,1450,1482,1514,1546 mul $0,32 trn $0,1 add $0,11
; Pokémon locked ID table constants const_def const LOCKED_MON_ID_MAP_1 const LOCKED_MON_ID_MAP_2 const LOCKED_MON_ID_MAP_3 const LOCKED_MON_ID_MAP_4 const LOCKED_MON_ID_MAP_5 const LOCKED_MON_ID_MAP_6 const LOCKED_MON_ID_MAP_7 const LOCKED_MON_ID_MAP_8 NUM_MAP_LOCKED_MON_IDS EQU const_value + -LOCKED_MON_ID_MAP_1 const LOCKED_MON_ID_DEX_SELECTED const LOCKED_MON_ID_TRADE_SEND const LOCKED_MON_ID_TRADE_RECEIVE const LOCKED_MON_ID_BATTLE_TOWER_1 const LOCKED_MON_ID_BATTLE_TOWER_2 const LOCKED_MON_ID_BATTLE_TOWER_3 const LOCKED_MON_ID_CURRENT_MENU if const_value > MON_TABLE_LOCKED_ENTRIES fail "Too many locked Pokémon IDs" endc ; Move locked ID table constants const_def const LOCKED_MOVE_ID_BATTLE_TOWER_MON1_MOVE1 const LOCKED_MOVE_ID_BATTLE_TOWER_MON1_MOVE2 const LOCKED_MOVE_ID_BATTLE_TOWER_MON1_MOVE3 const LOCKED_MOVE_ID_BATTLE_TOWER_MON1_MOVE4 const LOCKED_MOVE_ID_BATTLE_TOWER_MON2_MOVE1 const LOCKED_MOVE_ID_BATTLE_TOWER_MON2_MOVE2 const LOCKED_MOVE_ID_BATTLE_TOWER_MON2_MOVE3 const LOCKED_MOVE_ID_BATTLE_TOWER_MON2_MOVE4 const LOCKED_MOVE_ID_BATTLE_TOWER_MON3_MOVE1 const LOCKED_MOVE_ID_BATTLE_TOWER_MON3_MOVE2 const LOCKED_MOVE_ID_BATTLE_TOWER_MON3_MOVE3 const LOCKED_MOVE_ID_BATTLE_TOWER_MON3_MOVE4 if const_value > MOVE_TABLE_LOCKED_ENTRIES fail "Too many locked move IDs" endc
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2017-2019 The DragonBallChain Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "commons/json/json_spirit_utils.h" #include "commons/json/json_spirit_value.h" #include "commons/json/json_spirit_reader.h" #include "entities/utxo.h" #include "rpc/core/rpcserver.h" #include "rpc/core/rpccommons.h" #include "main.h" #include "wallet/wallet.h" using namespace std; enum UtxoCondDirection: uint8_t { IN, OUT }; extern CWallet* pWalletMain; static void ParseUtxoCond(const Array& arr, vector<shared_ptr<CUtxoCond>>& vCond, const CKeyID& txKeyID); static void ParseUtxoInput(const Array& arr, vector<CUtxoInput>& vInput,const CKeyID& txKeyID); static void ParseUtxoOutput(const Array& arr, vector<CUtxoOutput>& vOutput,const CKeyID& txKeyID); static void CheckUtxoCondDirection(const vector<shared_ptr<CUtxoCond>>& vCond, UtxoCondDirection direction); Value genutxomultisignature(const Array& params, bool fHelp) { if (fHelp || params.size() != 2) { throw runtime_error( "genutxomultisignature \"sender\" \"utxo_content_hash\" \n" "\nGenerate a UTXO MultiSign Singature.\n" + HelpRequiringPassphrase() + "\nArguments:\n" "1.\"sender\": (string, required) the addr of signee\n" "2.\"utxo_content_hash\": (string, required) The utxo content hash\n" "\nResult:\n" "\"signature\" (string) signature hex.\n" "\nExamples:\n" + HelpExampleCli("genutxomultisignature", R"("0-5" "23ewf90203ew000ds0lwsdpoxewdokwesdxcoekdleds" )") + "\nAs json rpc call\n" + HelpExampleRpc("genutxomultisignature", R"("0-5", "23ewf90203ew000ds0lwsdpoxewdokwesdxcoekdleds")") ); } CUserID uid = RPC_PARAM::GetUserId(params[0]); CAccount account = RPC_PARAM::GetUserAccount(*pCdMan->pAccountCache, uid); uint256 hash = uint256S(params[1].get_str()); UnsignedCharArray signature; if (!pWalletMain->HasKey(account.keyid)) { throw JSONRPCError(RPC_WALLET_ERROR, "signee address not found in wallet"); } if (!pWalletMain->Sign(account.keyid, hash, signature)) { throw JSONRPCError(RPC_WALLET_ERROR, "Sign failed"); } Object obj; obj.push_back(Pair("signature", HexStr(signature.begin(), signature.end()))); return obj; } Value genutxomultisignaddr( const Array& params, bool fHelp) { if(fHelp || params.size() != 3) { throw runtime_error( "genutxomultisignaddr \"n\" \"m\" \"signee_uids\" \n" "\nGenerate a multi sign address.\n" + HelpRequiringPassphrase() + "\nArguments:\n" "1.\"n\": (numberic, required) the total signee size \n" "2.\"m\": (numberic, required) the min signee size \n" "3.\"signee_uids\": (array<string> the signee uid\n" "\nResult:\n" "\"txid\" (string) The multi address hash.\n" "\nExamples:\n" + HelpExampleCli("genutxomultisignaddr", R"(2 2 "["0-2", "0-3"]")") + "\nAs json rpc call\n" + HelpExampleRpc("genutxomultisignaddr",R"(2, 2, "["0-2", "0-3"]")") ); } uint8_t n = params[0].get_int(); uint8_t m = params[1].get_int(); Array uidStringArray = params[2].get_array(); vector<string> vAddr; for(auto v: uidStringArray){ CUserID uid = RPC_PARAM::GetUserId(v); CAccount acct; if (!pCdMan->pAccountCache->GetAccount(uid, acct)) throw JSONRPCError(RPC_INVALID_PARAMETER, "the uid is not on chain"); vAddr.push_back(acct.keyid.ToAddress()); } if( m > n) { throw JSONRPCError(RPC_INVALID_PARAMETER, "m must be not greater than n"); } if(m > 20 || n >20) { throw JSONRPCError(RPC_INVALID_PARAMETER, " m and n must be not greater than 20"); } if( n != vAddr.size()){ throw JSONRPCError(RPC_INVALID_PARAMETER, "the n must be equal to signee count"); } string redeemScript(""); CKeyID multiKeyID; if( ComputeRedeemScript(m,n,vAddr, redeemScript) && ComputeMultiSignKeyId(redeemScript, multiKeyID)) { Object o; o.push_back(Pair("multi_addr", multiKeyID.ToAddress())); return o; } else { throw JSONRPCError(RPC_INVALID_PARAMETER, "gen multi addr error"); } } Value genutxomultiinputcondhash(const Array& params, bool fHelp) { if(fHelp || params.size() != 6) { throw runtime_error( "genutxomultiinputcondhash \"n\" \"m\" \"pre_utxo_txid\" \"pre_utxo_tx_vout_index\" \"signee_uids\",\"spend_txuid\" \n" "\n Generate a hash that will be sign in IP2MA cond\n" + HelpRequiringPassphrase() + "\nArguments:\n" "1.\"n\": (numberic, required) the total signee size\n" "2.\"m\": (numberic, required) the min signee size \n" "3.\"pre_utxo_txid\": (string, required) The utxo txid you want to spend\n" "4.\"pre_utxo_tx_vout_index\": (string, required) The index of pre utxo output \n" "5.\"signee_uids\": (array<string> the signee uid\n" "6.\"spend_txuid\": (string, required) the uid that well submit utxotransfertx to spend\n" "\nResult:\n" "\"txid\" (string) The multi input cond hash.\n" "\nExamples:\n" + HelpExampleCli("genutxomultiinputcondhash", R"(2 2 "23ewf90203ew000ds0lwsdpoxewdokwesdxcoekdleds" 4 "["0-2","0-3"]" "0-2")" ) + "\nAs json rpc call\n" + HelpExampleRpc("genutxomultiinputcondhash", R"(2, 2, "23ewf90203ew000ds0lwsdpoxewdokwesdxcoekdleds", 4, "["0-2","0-3"]", "0-2")") ); } uint8_t n = params[0].get_int(); uint8_t m = params[1].get_int(); uint256 prevUtxoTxId = uint256S(params[2].get_str()); uint16_t prevUtxoTxVoutIndex = params[3].get_int(); Array uidStringArray = params[4].get_array(); CKeyID txKeyID = RPC_PARAM::GetKeyId(params[5]); CAccount txAcct; if (!pCdMan->pAccountCache->GetAccount(txKeyID, txAcct)) throw JSONRPCError(RPC_INVALID_PARAMETER, "Get Account from txKeyID failed."); vector<string> vAddr; for(auto v: uidStringArray){ CKeyID keyid = RPC_PARAM::GetKeyId(v); vAddr.push_back(keyid.ToAddress()); } if( m > n) { throw JSONRPCError(RPC_INVALID_PARAMETER, "m must be not greater than n"); } if(m > 20 || n >20) { throw JSONRPCError(RPC_INVALID_PARAMETER, " m and n must be not greater than 20"); } if( n != vAddr.size()){ throw JSONRPCError(RPC_INVALID_PARAMETER, "the n must be equal to signee count"); } string redeemScript(""); ComputeRedeemScript(m, n, vAddr, redeemScript); uint256 multiSignHash; if (!ComputeUtxoMultisignHash(prevUtxoTxId, prevUtxoTxVoutIndex, txAcct, redeemScript, multiSignHash)) throw JSONRPCError(RPC_WALLET_ERROR, "create hash error"); Object o; o.push_back(Pair("hash", multiSignHash.GetHex())); return o; } Value submitpasswordprooftx(const Array& params, bool fHelp) { if(fHelp || params.size() < 5 || params.size() > 6) { throw runtime_error( "submitpasswordprooftx \"sender\" \"utxo_txid\" \"utxo_vout_index\" \"password\" \"pre_utxo_tx_uid\" [\"fee\"] \n" "\nSubmit a password proof tx.\n" + HelpRequiringPassphrase() + "\nArguments:\n" "1.\"sender\": (string, required) the addr submit this tx\n" "2.\"prev_utxo_txid\" (string, required) The utxo txid you want to spend\n" "3.\"prev_utxo_vout_index\": (string, required) The index of utxo output \n" "4.\"password\": (symbol:amount:unit, required) password\n" "5.\"pre_utxo_tx_uid\" (string, required) the txUid of prev utxotx that provide prevOutput\n " "6.\"symbol:fee:unit\": (symbol:amount:unit, optinal) fee paid to miner\n" "\nResult:\n" "\"txid\" (string) The transaction id.\n" "\nExamples:\n" + HelpExampleCli("submitpasswordprooftx", "\"wLKf2NqwtHk3BfzK5wMDfbKYN1SC3weyR4\" \"23ewf90203ew000ds0lwsdpoxewdokwesdxcoekdleds\" " "5 \"123\" \'0-2\" \"WICC:10000:sawi\"") + "\nAs json rpc call\n" + HelpExampleRpc("submitpasswordprooftx", "\"wLKf2NqwtHk3BfzK5wMDfbKYN1SC3weyR4\", \"23ewf90203ew000ds0lwsdpoxewdokwesdxcoekdleds\"," " 5, \"123\", \"0-2\", \"WICC:10000:sawi\"") ); } EnsureWalletIsUnlocked(); CUserID txUid = RPC_PARAM::GetUserId(params[0], true ); TxID prevUtxoTxid = uint256S(params[1].get_str()); uint16_t prevUtxoVoutIndex = params[2].get_int(); string password = params[3].get_str(); CUserID preUtxoTxUid = RPC_PARAM::GetUserId(params[4]); CAccount preUtxoTxAccount = RPC_PARAM::GetUserAccount(*pCdMan->pAccountCache, preUtxoTxUid); ComboMoney fee = RPC_PARAM::GetFee(params, 5 ,TxType::UTXO_PASSWORD_PROOF_TX); CAccount account = RPC_PARAM::GetUserAccount(*pCdMan->pAccountCache, txUid); RPC_PARAM::CheckAccountBalance(account, fee.symbol, SUB_FREE, fee.GetAmountInSawi()); string text = strprintf("%s%s%s%s%d", password, preUtxoTxAccount.keyid.ToString(), account.keyid.ToString(), prevUtxoTxid.ToString(), prevUtxoVoutIndex); uint256 passwordProof = Hash(text); int32_t validHeight = chainActive.Height(); CCoinUtxoPasswordProofTx tx(txUid, validHeight, fee.symbol, fee.GetAmountInSawi(), prevUtxoTxid, prevUtxoVoutIndex, passwordProof); return SubmitTx(account.keyid, tx); } Value submitutxotransfertx(const Array& params, bool fHelp) { if(fHelp || params.size() <4 || params.size() > 6) { throw runtime_error( "submitutxotransfertx \"sender\" \"coin_symbol\" \"vins\" \"vouts\" \"symbol:fee:unit\" \"memo\" \n" "\nSubmit utxo tx.\n" + HelpRequiringPassphrase() + "\nArguments:\n" "1.\"sender\": (string, required) the addr submit this tx\n" "2.\"coin_symbol\": (string, required) The utxo transfer coin symbole\n" "3.\"vins\": (string(json), required) The utxo inputs \n" "4.\"vouts\": (string(json), required) the utxo outputs \n" "5.\"symbol:fee:unit\": (symbol:amount:unit, optional) fee paid to miner\n" "6.\"memo\": (string,optinal) tx memo\n" "\nResult:\n" "\"txid\" (string) The transaction id.\n" "\nExamples:\n" + HelpExampleCli("submitutxotransfertx", "\"wLKf2NqwtHk3BfzK5wMDfbKYN1SC3weyR4\" \"WICC\" \"[]\" " " \"[]\" \"WICC:10000:sawi\" \"xx\"") + "\nAs json rpc call\n" + HelpExampleRpc("submitutxotransfertx", "\"wLKf2NqwtHk3BfzK5wMDfbKYN1SC3weyR4\", \"WICC\", \"[]\", " "\"[]\", \"WICC:10000:sawi\", \"xx\"") ); } EnsureWalletIsUnlocked(); CUserID txUid = RPC_PARAM::GetUserId(params[0], true); TokenSymbol coinSymbol = params[1].get_str(); Array inputArray = params[2].get_array(); Array outputArray = params[3].get_array(); ComboMoney fee = RPC_PARAM::GetFee(params, 4, TxType::UTXO_TRANSFER_TX); CAccount account = RPC_PARAM::GetUserAccount(*pCdMan->pAccountCache, txUid); RPC_PARAM::CheckAccountBalance(account, fee.symbol, SUB_FREE, fee.GetAmountInSawi()); string memo; if(params.size() > 5) memo = params[5].get_str(); std::vector<CUtxoInput> vins; std::vector<CUtxoOutput> vouts; ParseUtxoInput(inputArray, vins, account.keyid); ParseUtxoOutput(outputArray, vouts, account.keyid); for (auto input : vins) { auto inCondTypes = unordered_set<UtxoCondType>(); for (auto cond: input.conds) { if (inCondTypes.count(cond.sp_utxo_cond->cond_type) > 0) throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("in cond type (%d) exists error!", cond.sp_utxo_cond->cond_type)); else inCondTypes.emplace(cond.sp_utxo_cond->cond_type); } if (inCondTypes.count(UtxoCondType::IP2SA) == 1 && inCondTypes.count(UtxoCondType::IP2MA) == 1) throw JSONRPCError(RPC_INVALID_PARAMETER, "can't have both IP2SA & IP2MA error"); } for (auto output : vouts) { auto outCondTypes = unordered_set<UtxoCondType>(); for (auto cond : output.conds) { if (outCondTypes.count(cond.sp_utxo_cond->cond_type) > 0) throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("out cond type (%d) exists error!", cond.sp_utxo_cond->cond_type)); else outCondTypes.emplace(cond.sp_utxo_cond->cond_type); } if (outCondTypes.count(UtxoCondType::OP2SA) == 1 && outCondTypes.count(UtxoCondType::OP2MA) == 1) throw JSONRPCError(RPC_INVALID_PARAMETER, "can't have both OP2SA & OP2MA error"); } int32_t validHeight = chainActive.Height(); CCoinUtxoTransferTx utxoTransferTx(txUid, validHeight, fee.symbol, fee.GetAmountInSawi(), coinSymbol, vins, vouts, memo); return SubmitTx(account.keyid, utxoTransferTx); } static void TransToStorageBean(const vector<shared_ptr<CUtxoCond>>& vCond, vector<CUtxoCondStorageBean>& vCondStorageBean) { for (auto& cond: vCond ) { auto bean = CUtxoCondStorageBean(cond); vCondStorageBean.push_back(bean); } } static void ParseUtxoInput(const Array& arr, vector<CUtxoInput>& vInput, const CKeyID& txKeyID) { for (auto obj : arr) { const Value& preTxidObj = JSON::GetObjectFieldValue(obj, "prev_utxo_txid"); TxID prevUtxoTxid = uint256S(preTxidObj.get_str()); const Value& preVoutIndexObj = JSON::GetObjectFieldValue(obj,"prev_utxo_vout_index"); uint16_t preUoutIndex = AmountToRawValue(preVoutIndexObj); const Array& condArray = JSON::GetObjectFieldValue(obj, "conds").get_array(); vector<CUtxoCondStorageBean> vCondStorageBean; vector<shared_ptr<CUtxoCond>> vCond; ParseUtxoCond(condArray, vCond,txKeyID); CheckUtxoCondDirection(vCond, UtxoCondDirection::IN); TransToStorageBean(vCond, vCondStorageBean); CUtxoInput input = CUtxoInput(prevUtxoTxid,preUoutIndex,vCondStorageBean); vInput.push_back(input); } } static void ParseUtxoOutput(const Array& arr, vector<CUtxoOutput>& vOutput,const CKeyID& txKeyID) { for (auto& obj : arr) { const Value& coinAmountObj = JSON::GetObjectFieldValue(obj, "coin_amount"); uint64_t coinAmount = AmountToRawValue(coinAmountObj); const Array& condArray = JSON::GetObjectFieldValue(obj, "conds").get_array(); vector<CUtxoCondStorageBean> vCondStorageBean; vector<shared_ptr<CUtxoCond>> vCond; ParseUtxoCond(condArray, vCond,txKeyID); CheckUtxoCondDirection(vCond, UtxoCondDirection::OUT); TransToStorageBean(vCond, vCondStorageBean); CUtxoOutput output = CUtxoOutput(coinAmount, vCondStorageBean); vOutput.push_back(output); } } static void CheckUtxoCondDirection(const vector<shared_ptr<CUtxoCond>>& vCond, UtxoCondDirection direction) { for (auto& cond:vCond) { switch (cond->cond_type) { case IP2MA: case IP2PH: case IP2SA: if(direction != UtxoCondDirection::IN){ throw JSONRPCError(RPC_INVALID_PARAMETER,"cond direction is error"); } break; case OP2MA: case OP2PH: case OP2SA: case OCLAIM_LOCK: case ORECLAIM_LOCK: if(direction != UtxoCondDirection::OUT) { throw JSONRPCError(RPC_INVALID_PARAMETER,"cond direction is error"); } break; case NULL_UTXOCOND_TYPE: default: throw JSONRPCError(RPC_INVALID_PARAMETER, "cond type is error"); } } } static void ParseUtxoCond(const Array& arr, vector<shared_ptr<CUtxoCond>>& vCond,const CKeyID& txKeyID) { for (auto& obj : arr) { const Value& typeObj = JSON::GetObjectFieldValue(obj, "cond_type"); uint8_t typeInt = AmountToRawValue(typeObj); UtxoCondType type = UtxoCondType(typeInt); switch(type){ case UtxoCondType::IP2SA: { vCond.push_back(make_shared<CSingleAddressCondIn>()); break; } case UtxoCondType::IP2PH: { const Value& passwordObj = JSON::GetObjectFieldValue(obj,"password"); string password = passwordObj.get_str(); vCond.push_back(make_shared<CPasswordHashLockCondIn>(password)); break; } case UtxoCondType::IP2MA: { const Value& mObj = JSON::GetObjectFieldValue(obj,"m"); uint8_t m = AmountToRawValue(mObj); const Value& nObj = JSON::GetObjectFieldValue(obj,"n"); uint8_t n = AmountToRawValue(nObj); const Array& uidArray = JSON::GetObjectFieldValue(obj, "uids").get_array(); vector<CUserID> vUid; for(auto u: uidArray){ CUserID uid = RPC_PARAM::GetUserId(u); vUid.push_back(uid); } const Array& signArray = JSON::GetObjectFieldValue(obj, "signatures").get_array(); vector<UnsignedCharArray> vSign; for (auto s: signArray) { UnsignedCharArray unsignedCharArray = ParseHex(s.get_str()); vSign.push_back(unsignedCharArray); } vCond.push_back(make_shared<CMultiSignAddressCondIn>(m,n,vUid,vSign)); break; } case UtxoCondType::OP2SA: { const Value& uidV = JSON::GetObjectFieldValue(obj,"uid"); CUserID uid = RPC_PARAM::GetUserId(uidV); vCond.push_back(make_shared<CSingleAddressCondOut>(uid)); break; } case UtxoCondType::OP2PH: { const Value& passwordObj = JSON::GetObjectFieldValue(obj,"password"); string password = passwordObj.get_str(); string text = strprintf("%s%s", txKeyID.ToString(), password); uint256 passwordHash = Hash(text); const Value& pwdProofRequiredObj = JSON::GetObjectFieldValue(obj, "password_proof_required"); bool password_proof_required = pwdProofRequiredObj.get_bool(); vCond.push_back(make_shared<CPasswordHashLockCondOut>(password_proof_required,passwordHash)); break; } case UtxoCondType::OP2MA: { const Value& addrV = JSON::GetObjectFieldValue(obj,"multisign_address"); CKeyID multiSignKeyId(addrV.get_str()); if (multiSignKeyId.IsNull()) { throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("the multi sign address (%s) is illegal",addrV.get_str())); } vCond.push_back(make_shared<CMultiSignAddressCondOut>(multiSignKeyId)); break; } case UtxoCondType::OCLAIM_LOCK: { uint64_t height = AmountToRawValue(JSON::GetObjectFieldValue(obj, "height")); vCond.push_back(make_shared<CClaimLockCondOut>(height)); break; } case UtxoCondType::ORECLAIM_LOCK: { uint64_t height = AmountToRawValue(JSON::GetObjectFieldValue(obj, "height")); vCond.push_back(make_shared<CReClaimLockCondOut>(height)); break; } case UtxoCondType ::NULL_UTXOCOND_TYPE: default: throw JSONRPCError(RPC_INVALID_PARAMETER, "condition type error"); } } }
; ; z88dk RS232 Function ; ; Amstrad CPC (STI) version ; ; unsigned char rs232_get(char *) ; ; $Id: rs232_get.asm,v 1.3 2015/01/19 01:33:07 pauloscustodio Exp $ ; fastcall so implicit push PUBLIC rs232_get rs232_get: ld bc,$f8e1 xor a out (c),a ld c,$ed nowort: in a,(c) bit 7,a jr z,nowort ld c,$ef in a,(c) ld c,$e1 ld e,1 out (c),e ld (hl),a ld hl,0 ; RS_ERR_OK ;;; ld hl,RS_ERR_NO_DATA ret
; A111883: Unsigned row sums of triangle A111595 (normalized rescaled squared Hermite polynomials). ; Submitted by Jon Maiga ; 1,1,4,16,100,676,5776,53824,583696,6864400,90174016,1274204416,19642583104,323196798016,5714394630400,107112895415296,2135062451773696,44858948563673344,994634863541502976,23133227941938073600,564474119626559497216,14388648533002088866816,383018196281236624543744,10613546763550619089125376,305976731203078221621760000,9154747318220746808811851776,284073232160611346199846731776,9124488003677449505828181704704,303152579564225693135839298338816,10402006251486235301040551707033600 mov $3,1 lpb $0 mul $1,$0 sub $0,1 mov $2,$3 add $3,$1 mov $1,$2 lpe pow $3,2 mov $0,$3
; A237618: a(n) = n*(n + 1)*(19*n - 16)/6. ; 0,1,22,82,200,395,686,1092,1632,2325,3190,4246,5512,7007,8750,10760,13056,15657,18582,21850,25480,29491,33902,38732,44000,49725,55926,62622,69832,77575,85870,94736,104192,114257,124950,136290,148296,160987,174382,188500,203360,218981,235382,252582,270600,289455,309166,329752,351232,373625,396950,421226,446472,472707,499950,528220,557536,587917,619382,651950,685640,720471,756462,793632,832000,871585,912406,954482,997832,1042475,1088430,1135716,1184352,1234357,1285750,1338550,1392776,1448447,1505582,1564200,1624320,1685961,1749142,1813882,1880200,1948115,2017646,2088812,2161632,2236125,2312310,2390206,2469832,2551207,2634350,2719280,2806016,2894577,2984982,3077250,3171400,3267451,3365422,3465332,3567200,3671045,3776886,3884742,3994632,4106575,4220590,4336696,4454912,4575257,4697750,4822410,4949256,5078307,5209582,5343100,5478880,5616941,5757302,5899982,6045000,6192375,6342126,6494272,6648832,6805825,6965270,7127186,7291592,7458507,7627950,7799940,7974496,8151637,8331382,8513750,8698760,8886431,9076782,9269832,9465600,9664105,9865366,10069402,10276232,10485875,10698350,10913676,11131872,11352957,11576950,11803870,12033736,12266567,12502382,12741200,12983040,13227921,13475862,13726882,13981000,14238235,14498606,14762132,15028832,15298725,15571830,15848166,16127752,16410607,16696750,16986200,17278976,17575097,17874582,18177450,18483720,18793411,19106542,19423132,19743200,20066765,20393846,20724462,21058632,21396375,21737710,22082656,22431232,22783457,23139350,23498930,23862216,24229227,24599982,24974500,25352800,25734901,26120822,26510582,26904200,27301695,27703086,28108392,28517632,28930825,29347990,29769146,30194312,30623507,31056750,31494060,31935456,32380957,32830582,33284350,33742280,34204391,34670702,35141232,35616000,36095025,36578326,37065922,37557832,38054075,38554670,39059636,39568992,40082757,40600950,41123590,41650696,42182287,42718382,43259000,43804160,44353881,44908182,45467082,46030600,46598755,47171566,47749052,48331232,48918125 mov $3,$0 lpb $0,1 sub $0,1 add $2,$3 add $1,$2 add $3,16 lpe
// Copyright Carl Pearson 2020 - 2021. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE or copy at // https://www.boost.org/LICENSE_1_0.txt) #pragma once #include <cuda_runtime.h> #include <cstdint> class Pack2DConfig { using PackFn = void (*)(void *__restrict__ outbuf, const void *__restrict__ inbuf, const unsigned incount, const unsigned count0, const unsigned count1, const unsigned stride1, const uint64_t extent); using UnpackFn = void (*)(void *__restrict__ outbuf, const void *__restrict__ inbuf, const int outcount, unsigned count0, unsigned count1, unsigned stride1, const uint64_t extent); dim3 gd_, bd_; public: PackFn packfn; UnpackFn unpackfn; //impl in pack_kernels Pack2DConfig(unsigned offset, unsigned blockLength, unsigned blockCount); dim3 dim_grid(int count) const { dim3 gd = gd_; gd.z = count; return gd; } const dim3 &dim_block() const {return bd_;} };
#include <oms/OutputSource.h> #include <ossim/base/ossimOutputSource.h> oms::OutputSource::OutputSource(ossimOutputSource* nativePointer) :Source(nativePointer) { } oms::OutputSource::~OutputSource() { } bool oms::OutputSource::setNativePointer(ossimSource* nativePointer) { if(dynamic_cast<ossimOutputSource*>(nativePointer)) { return Source::setNativePointer(nativePointer); } return false; }
disk_load: pusha push dx mov ah, 0x02 ; ah <- int 0x13 function. 0x02 = 'read' mov al, dh mov cl, 0x02 mov ch, 0x00 mov dh, 0x00 int 0x13 jc disk_error pop dx cmp al, dh jne sectors_error popa ret disk_error: mov bx, DISK_ERROR call print call print_nl jmp disk_loop sectors_error: mov bx, SECTORS_ERROR call print disk_loop: jmp $ DISK_ERROR: db 'Disk read error', 0 SECTORS_ERROR: db 'Incorrect number of sectors read', 0
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x37ca, %rsi lea addresses_UC_ht+0x1974a, %rdi nop nop and %rdx, %rdx mov $27, %rcx rep movsl nop nop and $4360, %r13 lea addresses_A_ht+0x444a, %rsi lea addresses_UC_ht+0x14f4a, %rdi clflush (%rsi) clflush (%rdi) nop nop nop nop nop add $831, %r14 mov $118, %rcx rep movsb dec %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %rax push %rbp push %rdi push %rdx // Store lea addresses_WC+0xffc2, %r10 nop nop nop sub $44067, %rdx movw $0x5152, (%r10) nop nop xor %r10, %r10 // Store mov $0x4b485f000000054a, %rdx and $17089, %rdi mov $0x5152535455565758, %rax movq %rax, %xmm4 vmovups %ymm4, (%rdx) xor $45227, %rax // Faulty Load mov $0xf4a, %r12 nop nop nop nop sub $31097, %rdi vmovntdqa (%r12), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $1, %xmm2, %rdx lea oracles, %rax and $0xff, %rdx shlq $12, %rdx mov (%rax,%rdx,1), %rdx pop %rdx pop %rdi pop %rbp pop %rax pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_P', 'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 3}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_P', 'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_UC_ht'}} {'45': 10372} 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 */
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1991 -- All Rights Reserved PROJECT: PC GEOS MODULE: VidMem video driver FILE: clr24Output.asm AUTHOR: Jim DeFrisco, Feb 21, 1992 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 2/21/92 Initial revision DESCRIPTION: rectangle drawing routines for 24-bits/pixel $Id: clr24Output.asm,v 1.1 97/04/18 11:43:03 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ COMMENT @-------------------------------------------------------------------- FUNCTION: DrawOptRect DESCRIPTION: Draw a rectangle with draw mode GR_COPY and all bits in the draw mask set CALLED BY: INTERNAL DrawSimpleRect PASS: dx - number of pixels covered by rectangle - 1 zero flag - set if rect is one word wide cx - pattern index es:di - buffer address for first left:top of rectangle ds - Window structure bp - number of lines to draw si - (left x position MOD 16) * 2 bx - (right x position MOD 16) * 2 RETURN: DESTROYED: ax, bx, cx, dx, si, di, bp REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/88 Initial version ----------------------------------------------------------------------------@ DrawOptRect proc near mov ax, {word}cs:[currentColor].RGB_red mov bl, {byte}cs:[currentColor].RGB_blue ; calculate #bytes in the middle of the line and ; offset to next line inc dx ; total #bytes in line mov cx, dx ; setup count lineLoop: push cx, di optLoop1: stosw mov es:[di], bl inc di loop optLoop1 pop cx, di ; ptr to start position dec bp ; fewer scans to do jz done NextScan di ; adj ptr to next scan line tst cs:[bm_scansNext] ; if negative, bogus jns lineLoop done: ret DrawOptRect endp COMMENT @-------------------------------------------------------------------- FUNCTION: DrawSpecialRect DESCRIPTION: Draw a rectangle with a special draw mask or draw mode clipping left and right CALLED BY: INTERNAL VidDrawRect PASS: dx - number of words covered by rectangle + 1 zero flag - set if rect is one word wide cx - pattern index es:di - buffer address for first left:top of rectangle ds - Window structure bp - number of lines to draw si - (left x position MOD 16) * 2 bx - (right x position MOD 16) * 2 RETURN: none DESTROYED: ax, bx, cx, dx, si, di, bp REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/88 Initial version Jim 02/89 Modified to do map mode right ----------------------------------------------------------------------------@ DrawSpecialRect proc near push ds segmov ds, es ; setup ah to hold a bit flag to use in testing the mask mov bl, 80h ; bit zero xchg cx, si ; cx = low three bits of x pos and cl, 7 shr bl, cl ; ah = single bit tester mov cx, si ; restore mask buffer index ; calculate #bytes in the line, offset to next line inc dx ; number of bytes mov si, cx ; mask index in si lineLoop: push di, bx ; save pointer mov cx, dx ; setup count mov bh, bl ; reload tester pixelLoop: test cs:[maskBuffer][si], bh ; skip this pixel ? jz pixelDone mov ax, {word}ds:[di] ; get screen pixel mov bl, {byte}ds:[di+2] ; al=red, ah=green, bl=blue call cs:[modeRoutine] ; apply mix mode mov {word}es:[di], ax ; store result mov {byte}es:[di+2], bl pixelDone: add di, 3 shr bh, 1 ; testing next pixel jc reloadTester haveTester: loop pixelLoop pop di, bx ; restore scan pointer dec bp ; fewer scans to do jz done inc si ; next scan line and si, 0x7 NextScan di segmov ds, es ; update source reg tst cs:[bm_scansNext] ; jns lineLoop done: pop ds ret reloadTester: mov bh, 80h jmp haveTester DrawSpecialRect endp COMMENT @-------------------------------------------------------------------- FUNCTION: ModeCLEAR, ModeCOPY, ModeNOP, ModeAND, ModeINVERT, ModeXOR, ModeSET, ModeOR DESCRIPTION: Execute draw mode specific action CALLED BY: INTERNAL SpecialOneWord, BlastSpecialRect PASS: si - pattern (data) ax - screen dx - new bits AND draw mask where: new bits = bits to write out (as in bits from a bitmap). For objects like rectangles, where newBits=all 1s, dx will hold the mask only. Also: this mask is a final mask, including any user-specified draw mask. RETURN: ax - destination (word to write out) DESTROYED: dx REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/88 Initial version Jim 02/89 Modified to do map mode right ----------------------------------------------------------------------------@ ; the comments below use the following conventions (remember ; boolean algebra?...) ; AND ^ ; OR v ; NOT ~ ModeRoutines proc near ForceRef ModeRoutines ModeCLEAR label near clr ax clr bl ModeNOP label near ret ModeCOPY label near mov ax, {word} cs:[currentColor].RGB_red mov bl, cs:[currentColor].RGB_blue ret ModeAND label near and ax, {word} cs:[currentColor].RGB_red and bl, cs:[currentColor].RGB_blue ret ModeINVERT label near xor ax, 0FFFFh xor bl, 0FFh ret ModeXOR label near xor ax, {word} cs:[currentColor].RGB_red xor bl, cs:[currentColor].RGB_blue ret ModeSET label near mov ax, 0FFFFh mov bl, 0FFh ret ModeOR label near or ax, {word} cs:[currentColor].RGB_red or bl, cs:[currentColor].RGB_blue ret ModeRoutines endp
// Copyright (c) 2011-2013 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "walletview.h" #include "bitcoingui.h" #include "transactiontablemodel.h" #include "addressbookpage.h" #include "sendcoinsdialog.h" #include "signverifymessagedialog.h" #include "clientmodel.h" #include "walletmodel.h" #include "optionsmodel.h" #include "transactionview.h" #include "overviewpage.h" #include "askpassphrasedialog.h" #include "torntpage.h" #include "ui_interface.h" #include <QHBoxLayout> #include <QVBoxLayout> #include <QAction> #if QT_VERSION < 0x050000 #include <QDesktopServices> #else #include <QStandardPaths> #endif #include <QFileDialog> #include <QPushButton> WalletView::WalletView(QWidget *parent, BitcoinGUI *_gui): QStackedWidget(parent), gui(_gui), clientModel(0), walletModel(0) { // Create tabs overviewPage = new OverviewPage(); transactionsPage = new QWidget(this); QVBoxLayout *vbox = new QVBoxLayout(); QHBoxLayout *hbox_buttons = new QHBoxLayout(); transactionView = new TransactionView(this); vbox->addWidget(transactionView); QPushButton *exportButton = new QPushButton(tr("&Export"), this); exportButton->setToolTip(tr("Export the data in the current tab to a file")); #ifndef Q_OS_MAC // Icons on push buttons are very uncommon on Mac exportButton->setIcon(QIcon(":/icons/export")); #endif hbox_buttons->addStretch(); hbox_buttons->addWidget(exportButton); vbox->addLayout(hbox_buttons); transactionsPage->setLayout(vbox); addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab); receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab); sendCoinsPage = new SendCoinsDialog(gui); signVerifyMessageDialog = new SignVerifyMessageDialog(gui); torntPage = new torntPage(); addWidget(overviewPage); addWidget(transactionsPage); addWidget(addressBookPage); addWidget(receiveCoinsPage); addWidget(sendCoinsPage); addWidget(torntPage); // Clicking on a transaction on the overview page simply sends you to transaction history page connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage())); connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex))); // Double-clicking on a transaction on the transaction history page shows details connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails())); // Clicking on "Send Coins" in the address book sends you to the send coins tab connect(addressBookPage, SIGNAL(sendCoins(QString)), this, SLOT(gotoSendCoinsPage(QString))); // Clicking on "Verify Message" in the address book opens the verify message tab in the Sign/Verify Message dialog connect(addressBookPage, SIGNAL(verifyMessage(QString)), this, SLOT(gotoVerifyMessageTab(QString))); // Clicking on "Sign Message" in the receive coins page opens the sign message tab in the Sign/Verify Message dialog connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString))); // Clicking on "Export" allows to export the transaction list connect(exportButton, SIGNAL(clicked()), transactionView, SLOT(exportClicked())); connect(torntPage, SIGNAL(doubleClicked(QModelIndex)), torntPage, SLOT(showDetails())); gotoOverviewPage(); } WalletView::~WalletView() { } void WalletView::setBitcoinGUI(BitcoinGUI *gui) { this->gui = gui; } void WalletView::setClientModel(ClientModel *clientModel) { this->clientModel = clientModel; if (clientModel) { overviewPage->setClientModel(clientModel); addressBookPage->setOptionsModel(clientModel->getOptionsModel()); receiveCoinsPage->setOptionsModel(clientModel->getOptionsModel()); //torntPage->setClientModel(clientModel); } } void WalletView::setWalletModel(WalletModel *walletModel) { this->walletModel = walletModel; if (walletModel) { // Receive and report messages from wallet thread connect(walletModel, SIGNAL(message(QString,QString,unsigned int)), gui, SLOT(message(QString,QString,unsigned int))); // Put transaction list in tabs transactionView->setModel(walletModel); overviewPage->setWalletModel(walletModel); addressBookPage->setModel(walletModel->getAddressTableModel()); receiveCoinsPage->setModel(walletModel->getAddressTableModel()); sendCoinsPage->setModel(walletModel); signVerifyMessageDialog->setModel(walletModel); torntPage->setModel(walletModel->gettorntTableModel()); setEncryptionStatus(); connect(walletModel, SIGNAL(encryptionStatusChanged(int)), gui, SLOT(setEncryptionStatus(int))); // Balloon pop-up for new transaction connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(incomingTransaction(QModelIndex,int,int))); // Ask for passphrase if needed connect(walletModel, SIGNAL(requireUnlock()), this, SLOT(unlockWallet())); } } void WalletView::incomingTransaction(const QModelIndex& parent, int start, int /*end*/) { // Prevent balloon-spam when initial block download is in progress if(!walletModel || !clientModel || clientModel->inInitialBlockDownload()) return; TransactionTableModel *ttm = walletModel->getTransactionTableModel(); QString date = ttm->index(start, TransactionTableModel::Date, parent).data().toString(); qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent).data(Qt::EditRole).toULongLong(); QString type = ttm->index(start, TransactionTableModel::Type, parent).data().toString(); QString address = ttm->index(start, TransactionTableModel::ToAddress, parent).data().toString(); gui->incomingTransaction(date, walletModel->getOptionsModel()->getDisplayUnit(), amount, type, address); } void WalletView::gotoOverviewPage() { gui->getOverviewAction()->setChecked(true); setCurrentWidget(overviewPage); } void WalletView::gotoHistoryPage() { gui->getHistoryAction()->setChecked(true); setCurrentWidget(transactionsPage); } void WalletView::gotoAddressBookPage() { gui->getAddressBookAction()->setChecked(true); setCurrentWidget(addressBookPage); } void WalletView::gotoReceiveCoinsPage() { gui->getReceiveCoinsAction()->setChecked(true); setCurrentWidget(receiveCoinsPage); } void WalletView::gotoSendCoinsPage(QString addr) { gui->getSendCoinsAction()->setChecked(true); setCurrentWidget(sendCoinsPage); if (!addr.isEmpty()) sendCoinsPage->setAddress(addr); } void WalletView::gotoSignMessageTab(QString addr) { // call show() in showTab_SM() signVerifyMessageDialog->showTab_SM(true); if (!addr.isEmpty()) signVerifyMessageDialog->setAddress_SM(addr); } void WalletView::gotoVerifyMessageTab(QString addr) { // call show() in showTab_VM() signVerifyMessageDialog->showTab_VM(true); if (!addr.isEmpty()) signVerifyMessageDialog->setAddress_VM(addr); } void WalletView::gototorntPage() { gui->gettorntPageAction()->setChecked(true); setCurrentWidget(torntPage); } bool WalletView::handleURI(const QString& strURI) { // URI has to be valid if (sendCoinsPage->handleURI(strURI)) { gotoSendCoinsPage(); emit showNormalIfMinimized(); return true; } else return false; } void WalletView::showOutOfSyncWarning(bool fShow) { overviewPage->showOutOfSyncWarning(fShow); } void WalletView::setEncryptionStatus() { gui->setEncryptionStatus(walletModel->getEncryptionStatus()); } void WalletView::encryptWallet(bool status) { if(!walletModel) return; AskPassphraseDialog dlg(status ? AskPassphraseDialog::Encrypt : AskPassphraseDialog::Decrypt, this); dlg.setModel(walletModel); dlg.exec(); setEncryptionStatus(); } void WalletView::backupWallet() { #if QT_VERSION < 0x050000 QString saveDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); #else QString saveDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); #endif QString filename = QFileDialog::getSaveFileName(this, tr("Backup Wallet"), saveDir, tr("Wallet Data (*.dat)")); if (!filename.isEmpty()) { if (!walletModel->backupWallet(filename)) { gui->message(tr("Backup Failed"), tr("There was an error trying to save the wallet data to the new location."), CClientUIInterface::MSG_ERROR); } else gui->message(tr("Backup Successful"), tr("The wallet data was successfully saved to the new location."), CClientUIInterface::MSG_INFORMATION); } } void WalletView::changePassphrase() { AskPassphraseDialog dlg(AskPassphraseDialog::ChangePass, this); dlg.setModel(walletModel); dlg.exec(); } void WalletView::unlockWallet() { if(!walletModel) return; // Unlock wallet when requested by wallet model if (walletModel->getEncryptionStatus() == WalletModel::Locked) { AskPassphraseDialog dlg(AskPassphraseDialog::Unlock, this); dlg.setModel(walletModel); dlg.exec(); } }
; Timer test ticking up a character on the screen. ; ; Expect a banner at the top and a single character that changes on the ; second line ; ; Only works on Model 3 or Model 4 org 0x4a00 video equ $3c00 count defb 11 ; init to 11 ticks d_char defb $41 ; init to ascii A msg defb 'Timer Interrupt test on the TRS-80 Model III' msg_len equ $-msg main: jmp cls ; Skip interrupt handler; jump to setup code tick: ; Only change the letter every 10 ticks. ld hl,count dec (hl) jr nz,tick_r ld (hl),11 ; reset to count down again disp: ; Display a letter, A-Z, on the screen. ld hl,d_char ld a,(hl) ld (video+64+5),a ; Next time show the next letter. inc a ld d,a ; dup the letter into reg d ; Did we just display ascii Z? if so reset to ascii A. sub a,$5a+1 ; (ascii Z) plus 1 jr nz,save_l ld d,$41 ; ascii A save_l: ld (hl),d ; next letter in the alphabet jmp tick_r cls: ; Start by clearing the screen. ld hl,video ld bc,64*16 cls_c: ld (hl),0 inc hl dec bc ld a,b or c jr nz,cls_c bannner: ; Write a message about the program to line 1 of the screen. ld hl,msg ld de,video ld bc,msg_len ldir ; Setup timer interrupt Model 3 & 4. di ld hl,(0x4013) ld (tick_r+1),hl ld hl,tick ld (0x4013),hl ei hcf: jr hcf ; Return back to ROM interrupt processing; ; the vector was set by init code above. tick_r: jp 0 ; The 0 is self-modified into the original address. end main
#include <cstdio> #include <iostream> typedef long long ll; ll cyc[11][11]; template <typename T> T read(); int main() { std::ios::sync_with_stdio(false); ll n = read<ll>(), m = read<ll>(), k = read<ll>(); ll x = n, y = m, z = 0, p = 0; if (k <= 2) { if (k == 1) { std::cout << n << '\n'; } else { std::cout << m << '\n'; } return 0; } cyc[x][y] = 2; for (int i = 3; i <= k; i++) { z = (x * y) % 10; x = y; y = z; if (cyc[x][y]) { p = i - cyc[x][y]; break; } cyc[x][y] = i; } if (p < 2) { std::cout << z << '\n'; return 0; } x = n, y = m; k %= p; k += (k ? 0 : p); for (int i = 3; i <= k; i++) { z = (x * y) % 10; x = y; y = z; } std::cout << z << '\n'; return 0; } template <typename T> T read() { T x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); } return x * f; }
; A245827: Szeged index of the grid graph P_3 X P_n. ; 4,59,216,526,1040,1809,2884,4316,6156,8455,11264,14634,18616,23261,28620,34744,41684,49491,58216,67910,78624,90409,103316,117396,132700,149279,167184,186466,207176,229365,253084,278384,305316,333931,364280,396414,430384,466241,504036,543820,585644,629559,675616,723866,774360,827149,882284,939816,999796,1062275,1127304,1194934,1265216,1338201,1413940,1492484,1573884,1658191,1745456,1835730,1929064,2025509,2125116,2227936,2334020,2443419,2556184,2672366,2792016,2915185,3041924,3172284,3306316,3444071,3585600,3730954,3880184,4033341,4190476,4351640,4516884,4686259,4859816,5037606,5219680,5406089,5596884,5792116,5991836,6196095,6404944,6618434,6836616,7059541,7287260,7519824,7757284,7999691,8247096,8499550,8757104,9019809,9287716,9560876,9839340,10123159,10412384,10707066,11007256,11313005,11624364,11941384,12264116,12592611,12926920,13267094,13613184,13965241,14323316,14687460,15057724,15434159,15816816,16205746,16601000,17002629,17410684,17825216,18246276,18673915,19108184,19549134,19996816,20451281,20912580,21380764,21855884,22337991,22827136,23323370,23826744,24337309,24855116,25380216,25912660,26452499,26999784,27554566,28116896,28686825,29264404,29849684,30442716,31043551,31652240,32268834,32893384,33525941,34166556,34815280,35472164,36137259,36810616,37492286,38182320,38880769,39587684,40303116,41027116,41759735,42501024,43251034,44009816,44777421,45553900,46339304,47133684,47937091,48749576,49571190,50401984,51242009,52091316,52949956,53817980,54695439,55582384,56478866,57384936,58300645,59226044,60161184,61106116,62060891,63025560,64000174,64984784,65979441,66984196,67999100,69024204,70059559,71105216,72161226,73227640,74304509,75391884,76489816,77598356,78717555,79847464,80988134,82139616,83301961,84475220,85659444,86854684,88060991,89278416,90507010,91746824,92997909,94260316,95534096,96819300,98115979,99424184,100743966,102075376,103418465,104773284,106139884,107518316,108908631,110310880,111725114,113151384,114589741,116040236,117502920,118977844,120465059,121964616,123476566,125000960,126537849,128087284,129649316,131223996,132811375 mov $9,$0 lpb $0 add $1,3 add $6,3 add $6,$0 sub $0,1 lpe add $3,$1 mov $1,$6 lpb $3 add $2,$1 sub $3,1 lpe add $2,4 mov $1,$2 mov $4,21 mov $8,$9 lpb $4 add $1,$8 sub $4,1 lpe mov $5,$9 lpb $5 sub $5,1 add $7,$8 lpe mov $4,15 mov $8,$7 lpb $4 add $1,$8 sub $4,1 lpe mov $5,$9 mov $7,0 lpb $5 sub $5,1 add $7,$8 lpe mov $4,7 mov $8,$7 lpb $4 add $1,$8 sub $4,1 lpe
/*========================================================================= * * Copyright Insight Software Consortium * * 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.txt * * 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 "itkFEMSolver.h" #include "itkFEMSpatialObjectReader.h" #include "itkFEMSpatialObjectWriter.h" int itkFEMElement2DC0LinearQuadrilateralMembraneTest(int argc, char *argv[]) { if(argc < 1) { std::cerr << "Missing Spatial Object Filename" << std::endl; return EXIT_FAILURE; } //Need to register default FEM object types, //and setup SpatialReader to recognize FEM types //which is all currently done as a HACK in //the initializaiton of the itk::FEMFactoryBase::GetFactory() itk::FEMFactoryBase::GetFactory()->RegisterDefaultTypes(); using Solver2DType = itk::fem::Solver<2>; Solver2DType::Pointer solver = Solver2DType::New(); using FEMSpatialObjectReaderType = itk::FEMSpatialObjectReader<2>; using FEMSpatialObjectReaderPointer = FEMSpatialObjectReaderType::Pointer; FEMSpatialObjectReaderPointer SpatialReader = FEMSpatialObjectReaderType::New(); SpatialReader->SetFileName( argv[1] ); SpatialReader->Update(); FEMSpatialObjectReaderType::ScenePointer myScene = SpatialReader->GetScene(); if( !myScene ) { std::cout << "No Scene : [FAILED]" << std::endl; return EXIT_FAILURE; } std::cout << " [PASSED]" << std::endl; // Testing the fe mesh validity using FEMObjectSpatialObjectType = itk::FEMObjectSpatialObject<2>; FEMObjectSpatialObjectType::ChildrenListType* children = SpatialReader->GetGroup()->GetChildren(); if( strcmp( (*(children->begin() ) )->GetTypeName(), "FEMObjectSpatialObject") ) { std::cout << " [FAILED]" << std::endl; return EXIT_FAILURE; } FEMObjectSpatialObjectType::Pointer femSO = dynamic_cast<FEMObjectSpatialObjectType *>( (*(children->begin() ) ).GetPointer() ); if (!femSO) { std::cout << " dynamic_cast [FAILED]" << std::endl; return EXIT_FAILURE; } delete children; femSO->GetFEMObject()->FinalizeMesh(); solver->SetInput( femSO->GetFEMObject() ); solver->Update(); // to write the deformed mesh FEMObjectSpatialObjectType::Pointer femSODef = FEMObjectSpatialObjectType::New(); femSODef->SetFEMObject(solver->GetOutput() ); using FEMSpatialObjectWriterType = itk::FEMSpatialObjectWriter<2>; using FEMSpatialObjectWriterPointer = FEMSpatialObjectWriterType::Pointer; FEMSpatialObjectWriterPointer SpatialWriter = FEMSpatialObjectWriterType::New(); SpatialWriter->SetInput(femSODef); SpatialWriter->SetFileName( argv[2] ); SpatialWriter->Update(); std::cout << "Test PASSED!" << std::endl; return EXIT_SUCCESS; }
ascii_to_uppercase: .c00: db 0 ; None .c01: db 0 ; None .c02: db 0 ; None .c03: db 0 ; None .c04: db 0 ; None .c05: db 0 ; None .c06: db 0 ; None .c07: db 0 ; None .c08: db 0 ; None .c09: db 0 ; None .c0a: db 0 ; None .c0b: db 0 ; None .c0c: db 0 ; None .c0d: db 0 ; None .c0e: db 0 ; None .c0f: db 0 ; None .c10: db 0 ; None .c11: db 0 ; None .c12: db 0 ; None .c13: db 0 ; None .c14: db 0 ; None .c15: db 0 ; None .c16: db 0 ; None .c17: db 0 ; None .c18: db 0 ; None .c19: db 0 ; None .c1a: db 0 ; None .c1b: db 0 ; None .c1c: db 0 ; None .c1d: db 0 ; None .c1e: db 0 ; None .c1f: db 0 ; None .c20: db 0 ; None .c21: db 0 ; None .c22: db 0 ; None .c23: db 0 ; None .c24: db 0 ; None .c25: db 0 ; None .c26: db 0 ; None .c27: db """ ; " .c28: db 0 ; None .c29: db 0 ; None .c2a: db 0 ; None .c2b: db 0 ; None .c2c: db "<" ; < .c2d: db "_" ; _ .c2e: db ">" ; > .c2f: db "?" ; ? .c30: db ")" ; ) .c31: db "!" ; ! .c32: db "@" ; @ .c33: db "#" ; # .c34: db "$" ; $ .c35: db "E" ; E .c36: db "^" ; ^ .c37: db "&" ; & .c38: db "*" ; * .c39: db "(" ; ( .c3a: db 0 ; None .c3b: db ":" ; : .c3c: db 0 ; None .c3d: db "+" ; + .c3e: db 0 ; None .c3f: db 0 ; None .c40: db 0 ; None .c41: db 0 ; None .c42: db 0 ; None .c43: db 0 ; None .c44: db 0 ; None .c45: db 0 ; None .c46: db 0 ; None .c47: db 0 ; None .c48: db 0 ; None .c49: db 0 ; None .c4a: db 0 ; None .c4b: db 0 ; None .c4c: db 0 ; None .c4d: db 0 ; None .c4e: db 0 ; None .c4f: db 0 ; None .c50: db 0 ; None .c51: db 0 ; None .c52: db 0 ; None .c53: db 0 ; None .c54: db 0 ; None .c55: db 0 ; None .c56: db 0 ; None .c57: db 0 ; None .c58: db 0 ; None .c59: db 0 ; None .c5a: db 0 ; None .c5b: db "{" ; { .c5c: db "|" ; | .c5d: db "}" ; } .c5e: db 0 ; None .c5f: db 0 ; None .c60: db "~" ; ~ .c61: db "A" ; A .c62: db "B" ; B .c63: db "C" ; C .c64: db "D" ; D .c65: db "E" ; E .c66: db "F" ; F .c67: db "G" ; G .c68: db "H" ; H .c69: db "I" ; I .c6a: db "J" ; J .c6b: db "K" ; K .c6c: db "L" ; L .c6d: db "M" ; M .c6e: db "N" ; N .c6f: db "O" ; O .c70: db "P" ; P .c71: db "Q" ; Q .c72: db "R" ; R .c73: db "S" ; S .c74: db "T" ; T .c75: db "U" ; U .c76: db "V" ; V .c77: db "W" ; W .c78: db "X" ; X .c79: db "Y" ; Y .c7a: db "Z" ; Z .c7b: db 0 ; None .c7c: db 0 ; None .c7d: db 0 ; None .c7e: db 0 ; None .c7f: db 0 ; None .c80: db 0 ; None .c81: db 0 ; None .c82: db 0 ; None .c83: db 0 ; None .c84: db 0 ; None .c85: db 0 ; None .c86: db 0 ; None .c87: db 0 ; None .c88: db 0 ; None .c89: db 0 ; None .c8a: db 0 ; None .c8b: db 0 ; None .c8c: db 0 ; None .c8d: db 0 ; None .c8e: db 0 ; None .c8f: db 0 ; None .c90: db 0 ; None .c91: db 0 ; None .c92: db 0 ; None .c93: db 0 ; None .c94: db 0 ; None .c95: db 0 ; None .c96: db 0 ; None .c97: db 0 ; None .c98: db 0 ; None .c99: db 0 ; None .c9a: db 0 ; None .c9b: db 0 ; None .c9c: db 0 ; None .c9d: db 0 ; None .c9e: db 0 ; None .c9f: db 0 ; None .ca0: db 0 ; None .ca1: db 0 ; None .ca2: db 0 ; None .ca3: db 0 ; None .ca4: db 0 ; None .ca5: db 0 ; None .ca6: db 0 ; None .ca7: db 0 ; None .ca8: db 0 ; None .ca9: db 0 ; None .caa: db 0 ; None .cab: db 0 ; None .cac: db 0 ; None .cad: db 0 ; None .cae: db 0 ; None .caf: db 0 ; None .cb0: db 0 ; None .cb1: db 0 ; None .cb2: db 0 ; None .cb3: db 0 ; None .cb4: db 0 ; None .cb5: db 0 ; None .cb6: db 0 ; None .cb7: db 0 ; None .cb8: db 0 ; None .cb9: db 0 ; None .cba: db 0 ; None .cbb: db 0 ; None .cbc: db 0 ; None .cbd: db 0 ; None .cbe: db 0 ; None .cbf: db 0 ; None .cc0: db 0 ; None .cc1: db 0 ; None .cc2: db 0 ; None .cc3: db 0 ; None .cc4: db 0 ; None .cc5: db 0 ; None .cc6: db 0 ; None .cc7: db 0 ; None .cc8: db 0 ; None .cc9: db 0 ; None .cca: db 0 ; None .ccb: db 0 ; None .ccc: db 0 ; None .ccd: db 0 ; None .cce: db 0 ; None .ccf: db 0 ; None .cd0: db 0 ; None .cd1: db 0 ; None .cd2: db 0 ; None .cd3: db 0 ; None .cd4: db 0 ; None .cd5: db 0 ; None .cd6: db 0 ; None .cd7: db 0 ; None .cd8: db 0 ; None .cd9: db 0 ; None .cda: db 0 ; None .cdb: db 0 ; None .cdc: db 0 ; None .cdd: db 0 ; None .cde: db 0 ; None .cdf: db 0 ; None .ce0: db 0 ; None .ce1: db 0 ; None .ce2: db 0 ; None .ce3: db 0 ; None .ce4: db 0 ; None .ce5: db 0 ; None .ce6: db 0 ; None .ce7: db 0 ; None .ce8: db 0 ; None .ce9: db 0 ; None .cea: db 0 ; None .ceb: db 0 ; None .cec: db 0 ; None .ced: db 0 ; None .cee: db 0 ; None .cef: db 0 ; None .cf0: db 0 ; None .cf1: db 0 ; None .cf2: db 0 ; None .cf3: db 0 ; None .cf4: db 0 ; None .cf5: db 0 ; None .cf6: db 0 ; None .cf7: db 0 ; None .cf8: db 0 ; None .cf9: db 0 ; None .cfa: db 0 ; None .cfb: db 0 ; None .cfc: db 0 ; None .cfd: db 0 ; None .cfe: db 0 ; None .cff: db 0 ; None
object_const_def ; object_event constants const ECRUTEAKPOKECENTER1F_NURSE const ECRUTEAKPOKECENTER1F_POKEFAN_M const ECRUTEAKPOKECENTER1F_COOLTRAINER_F const ECRUTEAKPOKECENTER1F_GYM_GUY const ECRUTEAKPOKECENTER1F_BILL EcruteakPokecenter1F_MapScripts: db 2 ; scene scripts scene_script .MeetBill ; SCENE_DEFAULT scene_script .DummyScene ; SCENE_FINISHED db 0 ; callbacks .MeetBill: prioritysjump .BillActivatesTimeCapsule end .DummyScene: end .BillActivatesTimeCapsule: pause 30 playsound SFX_EXIT_BUILDING appear ECRUTEAKPOKECENTER1F_BILL waitsfx applymovement ECRUTEAKPOKECENTER1F_BILL, EcruteakPokecenter1FBillMovement1 applymovement PLAYER, EcruteakPokecenter1FPlayerMovement1 turnobject ECRUTEAKPOKECENTER1F_NURSE, UP pause 10 turnobject ECRUTEAKPOKECENTER1F_NURSE, DOWN pause 30 turnobject ECRUTEAKPOKECENTER1F_NURSE, UP pause 10 turnobject ECRUTEAKPOKECENTER1F_NURSE, DOWN pause 20 turnobject ECRUTEAKPOKECENTER1F_BILL, DOWN pause 10 opentext writetext EcruteakPokecenter1F_BillText1 buttonsound sjump .PointlessJump .PointlessJump: writetext EcruteakPokecenter1F_BillText2 waitbutton closetext turnobject PLAYER, DOWN applymovement ECRUTEAKPOKECENTER1F_BILL, EcruteakPokecenter1FBillMovement2 playsound SFX_EXIT_BUILDING disappear ECRUTEAKPOKECENTER1F_BILL clearevent EVENT_MET_BILL setflag ENGINE_TIME_CAPSULE setscene SCENE_FINISHED waitsfx end EcruteakPokecenter1FNurseScript: jumpstd pokecenternurse EcruteakPokecenter1FPokefanMScript: special Mobile_DummyReturnFalse iftrue .mobile jumptextfaceplayer EcruteakPokecenter1FPokefanMText .mobile jumptextfaceplayer EcruteakPokecenter1FPokefanMTextMobile EcruteakPokecenter1FCooltrainerFScript: jumptextfaceplayer EcruteakPokecenter1FCooltrainerFText EcruteakPokecenter1FGymGuyScript: jumptextfaceplayer EcruteakPokecenter1FGymGuyText EcruteakPokecenter1FBillMovement1: step UP step UP step UP step UP step RIGHT step RIGHT step RIGHT turn_head UP step_end EcruteakPokecenter1FBillMovement2: step RIGHT step DOWN step DOWN step DOWN step DOWN step_end EcruteakPokecenter1FPlayerMovement1: step UP step UP step UP step_end EcruteakPokecenter1F_BillText1: text "Hi, I'm BILL. And" line "who are you?" para "Hmm, <PLAYER>, huh?" line "You've come at the" cont "right time." done EcruteakPokecenter1F_BillText2: text "I just finished" line "adjustments on my" cont "TIME CAPSULE." para "You know that" line "#MON can be" cont "traded, right?" para "My TIME CAPSULE" line "was developed to" para "enable trades with" line "the past." para "But you can't send" line "anything that" para "didn't exist in" line "the past." para "If you did, the PC" line "in the past would" cont "have a breakdown." para "So you have to" line "remove anything" para "that wasn't around" line "in the past." para "Put simply, no" line "sending new moves" para "or new #MON in" line "the TIME CAPSULE." para "Don't you worry." line "I'm done with the" cont "adjustments." para "Tomorrow, TIME" line "CAPSULES will be" para "running at all" line "#MON CENTERS." para "I have to hurry on" line "back to GOLDENROD" cont "and see my folks." para "Buh-bye!" done EcruteakPokecenter1FPokefanMText: text "The way the KIMONO" line "GIRLS dance is" para "marvelous. Just" line "like the way they" cont "use their #MON." done EcruteakPokecenter1FPokefanMTextMobile: text "You must be hoping" line "to battle more" para "people, right?" line "There's apparently" para "some place where" line "trainers gather." para "Where, you ask?" para "It's a little past" line "OLIVINE CITY." done EcruteakPokecenter1FCooltrainerFText: text "MORTY, the GYM" line "LEADER, is soooo" cont "cool." para "His #MON are" line "really tough too." done EcruteakPokecenter1FGymGuyText: text "LAKE OF RAGE…" para "The appearance of" line "a GYARADOS swarm…" para "I smell a conspir-" line "acy. I know it!" done EcruteakPokecenter1F_MapEvents: db 0, 0 ; filler db 3 ; warp events warp_event 3, 7, ECRUTEAK_CITY, 6 warp_event 4, 7, ECRUTEAK_CITY, 6 warp_event 0, 7, POKECENTER_2F, 1 db 0 ; coord events db 0 ; bg events db 5 ; object events object_event 3, 1, SPRITE_NURSE, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, EcruteakPokecenter1FNurseScript, -1 object_event 7, 6, SPRITE_POKEFAN_M, SPRITEMOVEDATA_SPINRANDOM_FAST, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, EcruteakPokecenter1FPokefanMScript, -1 object_event 1, 4, SPRITE_COOLTRAINER_F, SPRITEMOVEDATA_SPINRANDOM_SLOW, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, EcruteakPokecenter1FCooltrainerFScript, -1 object_event 7, 1, SPRITE_GYM_GUY, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_GREEN, OBJECTTYPE_SCRIPT, 0, EcruteakPokecenter1FGymGuyScript, -1 object_event 0, 7, SPRITE_BILL, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, ObjectEvent, EVENT_ECRUTEAK_POKE_CENTER_BILL
#ifndef OSRM_EXTRACTOR_FILES_HPP #define OSRM_EXTRACTOR_FILES_HPP #include "extractor/edge_based_edge.hpp" #include "extractor/node_data_container.hpp" #include "extractor/profile_properties.hpp" #include "extractor/query_node.hpp" #include "extractor/serialization.hpp" #include "extractor/turn_lane_types.hpp" #include "util/coordinate.hpp" #include "util/guidance/bearing_class.hpp" #include "util/guidance/entry_class.hpp" #include "util/guidance/turn_lanes.hpp" #include "util/packed_vector.hpp" #include "util/range_table.hpp" #include "util/serialization.hpp" #include <boost/assert.hpp> namespace osrm { namespace extractor { namespace files { // writes the .osrm.icd file template <typename IntersectionBearingsT, typename EntryClassVectorT> inline void writeIntersections(const boost::filesystem::path &path, const IntersectionBearingsT &intersection_bearings, const EntryClassVectorT &entry_classes) { static_assert(std::is_same<IntersectionBearingsContainer, IntersectionBearingsT>::value || std::is_same<IntersectionBearingsView, IntersectionBearingsT>::value, ""); storage::tar::FileWriter writer(path, storage::tar::FileWriter::GenerateFingerprint); serialization::write(writer, "/common/intersection_bearings", intersection_bearings); storage::serialization::write(writer, "/common/entry_classes", entry_classes); } // read the .osrm.icd file template <typename IntersectionBearingsT, typename EntryClassVectorT> inline void readIntersections(const boost::filesystem::path &path, IntersectionBearingsT &intersection_bearings, EntryClassVectorT &entry_classes) { static_assert(std::is_same<IntersectionBearingsContainer, IntersectionBearingsT>::value || std::is_same<IntersectionBearingsView, IntersectionBearingsT>::value, ""); storage::tar::FileReader reader(path, storage::tar::FileReader::VerifyFingerprint); serialization::read(reader, "/common/intersection_bearings", intersection_bearings); storage::serialization::read(reader, "/common/entry_classes", entry_classes); } // reads .osrm.properties inline void readProfileProperties(const boost::filesystem::path &path, ProfileProperties &properties) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; serialization::read(reader, "/common/properties", properties); } // writes .osrm.properties inline void writeProfileProperties(const boost::filesystem::path &path, const ProfileProperties &properties) { const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; serialization::write(writer, "/common/properties", properties); } template <typename EdgeBasedEdgeVector> void writeEdgeBasedGraph(const boost::filesystem::path &path, EdgeID const number_of_edge_based_nodes, const EdgeBasedEdgeVector &edge_based_edge_list, const std::uint32_t connectivity_checksum) { static_assert(std::is_same<typename EdgeBasedEdgeVector::value_type, EdgeBasedEdge>::value, ""); storage::tar::FileWriter writer(path, storage::tar::FileWriter::GenerateFingerprint); writer.WriteElementCount64("/common/number_of_edge_based_nodes", 1); writer.WriteFrom("/common/number_of_edge_based_nodes", number_of_edge_based_nodes); storage::serialization::write(writer, "/common/edge_based_edge_list", edge_based_edge_list); writer.WriteElementCount64("/common/connectivity_checksum", 1); writer.WriteFrom("/common/connectivity_checksum", connectivity_checksum); } // reads .osrm.ebg file template <typename EdgeBasedEdgeVector> void readEdgeBasedGraph(const boost::filesystem::path &path, EdgeID &number_of_edge_based_nodes, EdgeBasedEdgeVector &edge_based_edge_list, std::uint32_t &connectivity_checksum) { static_assert(std::is_same<typename EdgeBasedEdgeVector::value_type, EdgeBasedEdge>::value, ""); storage::tar::FileReader reader(path, storage::tar::FileReader::VerifyFingerprint); reader.ReadInto("/common/number_of_edge_based_nodes", number_of_edge_based_nodes); storage::serialization::read(reader, "/common/edge_based_edge_list", edge_based_edge_list); reader.ReadInto("/common/connectivity_checksum", connectivity_checksum); } // reads .osrm.nbg_nodes template <typename CoordinatesT, typename PackedOSMIDsT> inline void readNodes(const boost::filesystem::path &path, CoordinatesT &coordinates, PackedOSMIDsT &osm_node_ids) { static_assert(std::is_same<typename CoordinatesT::value_type, util::Coordinate>::value, ""); static_assert(std::is_same<typename PackedOSMIDsT::value_type, OSMNodeID>::value, ""); const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; storage::serialization::read(reader, "/common/nbn_data/coordinates", coordinates); util::serialization::read(reader, "/common/nbn_data/osm_node_ids", osm_node_ids); } // reads only coordinates from .osrm.nbg_nodes template <typename CoordinatesT> inline void readNodeCoordinates(const boost::filesystem::path &path, CoordinatesT &coordinates) { static_assert(std::is_same<typename CoordinatesT::value_type, util::Coordinate>::value, ""); const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; storage::serialization::read(reader, "/common/nbn_data/coordinates", coordinates); } // writes .osrm.nbg_nodes template <typename CoordinatesT, typename PackedOSMIDsT> inline void writeNodes(const boost::filesystem::path &path, const CoordinatesT &coordinates, const PackedOSMIDsT &osm_node_ids) { static_assert(std::is_same<typename CoordinatesT::value_type, util::Coordinate>::value, ""); static_assert(std::is_same<typename PackedOSMIDsT::value_type, OSMNodeID>::value, ""); const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; storage::serialization::write(writer, "/common/nbn_data/coordinates", coordinates); util::serialization::write(writer, "/common/nbn_data/osm_node_ids", osm_node_ids); } // reads .osrm.cnbg_to_ebg inline void readNBGMapping(const boost::filesystem::path &path, std::vector<NBGToEBG> &mapping) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; storage::serialization::read(reader, "/common/cnbg_to_ebg", mapping); } // writes .osrm.cnbg_to_ebg inline void writeNBGMapping(const boost::filesystem::path &path, const std::vector<NBGToEBG> &mapping) { const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; storage::serialization::write(writer, "/common/cnbg_to_ebg", mapping); } // reads .osrm.datasource_names inline void readDatasources(const boost::filesystem::path &path, Datasources &sources) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; serialization::read(reader, "/common/data_sources_names", sources); } // writes .osrm.datasource_names inline void writeDatasources(const boost::filesystem::path &path, Datasources &sources) { const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; serialization::write(writer, "/common/data_sources_names", sources); } // reads .osrm.geometry template <typename SegmentDataT> inline void readSegmentData(const boost::filesystem::path &path, SegmentDataT &segment_data) { static_assert(std::is_same<SegmentDataContainer, SegmentDataT>::value || std::is_same<SegmentDataView, SegmentDataT>::value, ""); const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; serialization::read(reader, "/common/segment_data", segment_data); } // writes .osrm.geometry template <typename SegmentDataT> inline void writeSegmentData(const boost::filesystem::path &path, const SegmentDataT &segment_data) { static_assert(std::is_same<SegmentDataContainer, SegmentDataT>::value || std::is_same<SegmentDataView, SegmentDataT>::value, ""); const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; serialization::write(writer, "/common/segment_data", segment_data); } // reads .osrm.ebg_nodes template <typename NodeDataT> inline void readNodeData(const boost::filesystem::path &path, NodeDataT &node_data) { static_assert(std::is_same<EdgeBasedNodeDataContainer, NodeDataT>::value || std::is_same<EdgeBasedNodeDataView, NodeDataT>::value || std::is_same<EdgeBasedNodeDataExternalContainer, NodeDataT>::value, ""); const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; serialization::read(reader, "/common/ebg_node_data", node_data); } // writes .osrm.ebg_nodes template <typename NodeDataT> inline void writeNodeData(const boost::filesystem::path &path, const NodeDataT &node_data) { static_assert(std::is_same<EdgeBasedNodeDataContainer, NodeDataT>::value || std::is_same<EdgeBasedNodeDataView, NodeDataT>::value || std::is_same<EdgeBasedNodeDataExternalContainer, NodeDataT>::value, ""); const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; serialization::write(writer, "/common/ebg_node_data", node_data); } // reads .osrm.tls template <typename OffsetsT, typename MaskT> inline void readTurnLaneDescriptions(const boost::filesystem::path &path, OffsetsT &turn_offsets, MaskT &turn_masks) { static_assert(std::is_same<typename MaskT::value_type, extractor::TurnLaneType::Mask>::value, ""); static_assert(std::is_same<typename OffsetsT::value_type, std::uint32_t>::value, ""); const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; storage::serialization::read(reader, "/common/turn_lanes/offsets", turn_offsets); storage::serialization::read(reader, "/common/turn_lanes/masks", turn_masks); } // writes .osrm.tls template <typename OffsetsT, typename MaskT> inline void writeTurnLaneDescriptions(const boost::filesystem::path &path, const OffsetsT &turn_offsets, const MaskT &turn_masks) { static_assert(std::is_same<typename MaskT::value_type, extractor::TurnLaneType::Mask>::value, ""); static_assert(std::is_same<typename OffsetsT::value_type, std::uint32_t>::value, ""); const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; storage::serialization::write(writer, "/common/turn_lanes/offsets", turn_offsets); storage::serialization::write(writer, "/common/turn_lanes/masks", turn_masks); } // reads .osrm.tld template <typename TurnLaneDataT> inline void readTurnLaneData(const boost::filesystem::path &path, TurnLaneDataT &turn_lane_data) { static_assert( std::is_same<typename TurnLaneDataT::value_type, util::guidance::LaneTupleIdPair>::value, ""); const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; storage::serialization::read(reader, "/common/turn_lanes/data", turn_lane_data); } // writes .osrm.tld template <typename TurnLaneDataT> inline void writeTurnLaneData(const boost::filesystem::path &path, const TurnLaneDataT &turn_lane_data) { static_assert( std::is_same<typename TurnLaneDataT::value_type, util::guidance::LaneTupleIdPair>::value, ""); const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; storage::serialization::write(writer, "/common/turn_lanes/data", turn_lane_data); } // reads .osrm.maneuver_overrides template <typename StorageManeuverOverrideT, typename NodeSequencesT> inline void readManeuverOverrides(const boost::filesystem::path &path, StorageManeuverOverrideT &maneuver_overrides, NodeSequencesT &node_sequences) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; storage::serialization::read( reader, "/common/maneuver_overrides/overrides", maneuver_overrides); storage::serialization::read( reader, "/common/maneuver_overrides/node_sequences", node_sequences); } // writes .osrm.maneuver_overrides inline void writeManeuverOverrides(const boost::filesystem::path &path, const std::vector<StorageManeuverOverride> &maneuver_overrides, const std::vector<NodeID> &node_sequences) { const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; storage::serialization::write( writer, "/common/maneuver_overrides/overrides", maneuver_overrides); storage::serialization::write( writer, "/common/maneuver_overrides/node_sequences", node_sequences); } // writes .osrm.turn_weight_penalties template <typename TurnPenaltyT> inline void writeTurnWeightPenalty(const boost::filesystem::path &path, const TurnPenaltyT &turn_penalty) { const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; storage::serialization::write(writer, "/common/turn_penalty/weight", turn_penalty); } // read .osrm.turn_weight_penalties template <typename TurnPenaltyT> inline void readTurnWeightPenalty(const boost::filesystem::path &path, TurnPenaltyT &turn_penalty) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; storage::serialization::read(reader, "/common/turn_penalty/weight", turn_penalty); } // writes .osrm.turn_duration_penalties template <typename TurnPenaltyT> inline void writeTurnDurationPenalty(const boost::filesystem::path &path, const TurnPenaltyT &turn_penalty) { const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; storage::serialization::write(writer, "/common/turn_penalty/duration", turn_penalty); } // read .osrm.turn_weight_penalties template <typename TurnPenaltyT> inline void readTurnDurationPenalty(const boost::filesystem::path &path, TurnPenaltyT &turn_penalty) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; storage::serialization::read(reader, "/common/turn_penalty/duration", turn_penalty); } // writes .osrm.restrictions template <typename ConditionalRestrictionsT> inline void writeConditionalRestrictions(const boost::filesystem::path &path, const ConditionalRestrictionsT &conditional_restrictions) { const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; serialization::write(writer, "/common/conditional_restrictions", conditional_restrictions); } // read .osrm.restrictions template <typename ConditionalRestrictionsT> inline void readConditionalRestrictions(const boost::filesystem::path &path, ConditionalRestrictionsT &conditional_restrictions) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; serialization::read(reader, "/common/conditional_restrictions", conditional_restrictions); } // reads .osrm file which is a temporary file of osrm-extract template <typename BarrierOutIter, typename TrafficSignalsOutIter, typename PackedOSMIDsT> void readRawNBGraph(const boost::filesystem::path &path, BarrierOutIter barriers, TrafficSignalsOutIter traffic_signals, std::vector<util::Coordinate> &coordinates, PackedOSMIDsT &osm_node_ids, std::vector<extractor::NodeBasedEdge> &edge_list, std::vector<extractor::NodeBasedEdgeAnnotation> &annotations) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; auto number_of_nodes = reader.ReadElementCount64("/extractor/nodes"); coordinates.resize(number_of_nodes); osm_node_ids.reserve(number_of_nodes); auto index = 0; auto decode = [&](const auto &current_node) { coordinates[index].lon = current_node.lon; coordinates[index].lat = current_node.lat; osm_node_ids.push_back(current_node.node_id); index++; }; reader.ReadStreaming<extractor::QueryNode>("/extractor/nodes", boost::make_function_output_iterator(decode)); reader.ReadStreaming<NodeID>("/extractor/barriers", barriers); reader.ReadStreaming<NodeID>("/extractor/traffic_lights", traffic_signals); storage::serialization::read(reader, "/extractor/edges", edge_list); storage::serialization::read(reader, "/extractor/annotations", annotations); } template <typename NameTableT> void readNames(const boost::filesystem::path &path, NameTableT &table) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; serialization::read(reader, "/common/names", table); } template <typename NameTableT> void writeNames(const boost::filesystem::path &path, const NameTableT &table) { const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; serialization::write(writer, "/common/names", table); } template <typename NodeWeightsVectorT> void readEdgeBasedNodeWeights(const boost::filesystem::path &path, NodeWeightsVectorT &weights) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; storage::serialization::read(reader, "/extractor/edge_based_node_weights", weights); } template <typename NodeDistancesVectorT> void readEdgeBasedNodeDistances(const boost::filesystem::path &path, NodeDistancesVectorT &distances) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; storage::serialization::read(reader, "/extractor/edge_based_node_distances", distances); } template <typename NodeWeightsVectorT, typename NodeDurationsVectorT, typename NodeDistancesVectorT> void writeEdgeBasedNodeWeightsDurationsDistances(const boost::filesystem::path &path, const NodeWeightsVectorT &weights, const NodeDurationsVectorT &durations, const NodeDistancesVectorT &distances) { const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; storage::serialization::write(writer, "/extractor/edge_based_node_weights", weights); storage::serialization::write(writer, "/extractor/edge_based_node_durations", durations); storage::serialization::write(writer, "/extractor/edge_based_node_distances", distances); } template <typename NodeWeightsVectorT, typename NodeDurationsVectorT> void readEdgeBasedNodeWeightsDurations(const boost::filesystem::path &path, NodeWeightsVectorT &weights, NodeDurationsVectorT &durations) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; storage::serialization::read(reader, "/extractor/edge_based_node_weights", weights); storage::serialization::read(reader, "/extractor/edge_based_node_durations", durations); } template <typename NodeWeightsVectorT, typename NodeDurationsVectorT> void writeEdgeBasedNodeWeightsDurations(const boost::filesystem::path &path, const NodeWeightsVectorT &weights, const NodeDurationsVectorT &durations) { const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; storage::serialization::write(writer, "/extractor/edge_based_node_weights", weights); storage::serialization::write(writer, "/extractor/edge_based_node_durations", durations); } template <typename RTreeT> void writeRamIndex(const boost::filesystem::path &path, const RTreeT &rtree) { const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; util::serialization::write(writer, "/common/rtree", rtree); } template <typename RTreeT> void readRamIndex(const boost::filesystem::path &path, RTreeT &rtree) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; util::serialization::read(reader, "/common/rtree", rtree); } template <typename EdgeListT> void writeCompressedNodeBasedGraph(const boost::filesystem::path &path, const EdgeListT &edge_list) { const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; storage::serialization::write(writer, "/extractor/cnbg", edge_list); } template <typename EdgeListT> void readCompressedNodeBasedGraph(const boost::filesystem::path &path, EdgeListT &edge_list) { const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; storage::serialization::read(reader, "/extractor/cnbg", edge_list); } } } } #endif
; test include asm fragment include_count: = include_count + 1 MSG "Test INCLUDE count=", include_count end
; A024212: 2nd elementary symmetric function of first n+1 positive integers congruent to 1 mod 3. ; 4,39,159,445,1005,1974,3514,5814,9090,13585,19569,27339,37219,49560,64740,83164,105264,131499,162355,198345,240009,287914,342654,404850,475150,554229,642789,741559,851295,972780,1106824,1254264,1415964,1592815,1785735,1995669,2223589,2470494,2737410,3025390,3335514,3668889,4026649,4409955,4819995,5257984,5725164,6222804,6752200,7314675,7911579,8544289,9214209,9922770,10671430,11461674,12295014,13172989,14097165,15069135,16090519,17162964,18288144,19467760,20703540,21997239,23350639,24765549,26243805,27787270,29397834,31077414,32827954,34651425,36549825,38525179,40579539,42714984,44933620,47237580,49629024,52110139,54683139,57350265,60113785,62975994,65939214,69005794,72178110,75458565,78849589,82353639,85973199,89710780,93568920,97550184,101657164,105892479,110258775,114758725,119395029,124170414,129087634,134149470,139358730,144718249,150230889,155899539,161727115,167716560,173870844,180192964,186685944,193352835,200196715,207220689,214427889,221821474,229404630,237180570,245152534,253323789,261697629,270277375,279066375,288068004,297285664,306722784,316382820,326269255,336385599,346735389,357322189,368149590,379221210,390540694,402111714,413937969,426023185,438371115,450985539,463870264,477029124,490465980,504184720,518189259,532483539,547071529,561957225,577144650,592637854,608440914,624557934,640993045,657750405,674834199,692248639,709997964,728086440,746518360,765298044,784429839,803918119,823767285,843981765,864566014,885524514,906861774,928582330,950690745,973191609,996089539,1019389179,1043095200,1067212300,1091745204,1116698664,1142077459,1167886395,1194130305,1220814049,1247942514,1275520614,1303553290,1332045510,1361002269,1390428589,1420329519,1450710135,1481575540,1512930864,1544781264,1577131924,1609988055,1643354895,1677237709,1711641789,1746572454,1782035050,1818034950,1854577554,1891668289,1929312609,1967515995,2006283955,2045622024,2085535764,2126030764,2167112640,2208787035,2251059619,2293936089,2337422169,2381523610,2426246190,2471595714,2517578014,2564198949,2611464405,2659380295,2707952559,2757187164,2807090104,2857667400,2908925100,2960869279,3013506039,3066841509,3120881845,3175633230,3231101874,3287294014,3344215914,3401873865,3460274185,3519423219,3579327339,3639992944,3701426460,3763634340,3826623064,3890399139,3954969099,4020339505,4086516945,4153508034,4221319414,4289957754,4359429750,4429742125 mul $0,3 add $0,5 bin $0,2 sub $0,1 bin $0,2 mov $1,$0 div $1,9
; ; MSX C Library ; ; Fputc_cons ; ; Stefano Bodrato - Apr. 2000 ; ; ; $Id: fputc_cons.asm,v 1.8 2016/05/15 20:15:45 dom Exp $ ; SECTION code_clib PUBLIC fputc_cons_native EXTERN msxbios IF FORmsx INCLUDE "msxbios.def" ELSE INCLUDE "svibios.def" ENDIF ; ; Entry: hl = points to char ; .fputc_cons_native ld hl,2 add hl,sp ld a,(hl) ld ix,CHPUT ; Print char IF STANDARDESCAPECHARS cp 10 ELSE cp 13 ENDIF jr nz,nocrlf call msxbios IF STANDARDESCAPECHARS ld a,13 ELSE ld a,10 ENDIF .nocrlf cp 12 ; CLS ? jr nz,nocls ld ix,CLS .nocls jp msxbios
; A087968: a(n) = gcd(1 + 2^n, n^2). ; Submitted by Christian Krause ; 1,1,9,1,1,1,1,1,27,25,1,1,1,1,9,1,1,1,1,1,9,1,1,1,1,1,81,1,1,25,1,1,9,1,1,1,1,1,9,1,1,1,1,1,27,1,1,1,1,125,9,1,1,1,121,1,9,1,1,1,1,1,27,1,1,1,1,289,9,25,1,1,1,1,9,1,1,169,1,1,243,1,1,1,1,1,9,1,1,25,1,1,9,1,1,1,1,1,27,1 add $0,1 mov $2,$0 mov $0,2 pow $0,$2 add $0,1 pow $2,2 gcd $0,$2
; A151784: 6^{wt(n)-1} where wt(n) is the binary weight of n (A000120). ; 1,1,6,1,6,6,36,1,6,6,36,6,36,36,216,1,6,6,36,6,36,36,216,6,36,36,216,36,216,216,1296,1,6,6,36,6,36,36,216,6,36,36,216,36,216,216,1296,6,36,36,216,36,216,216,1296,36,216,216,1296,216,1296,1296,7776,1,6,6,36,6,36,36 seq $0,48881 ; a(n) = A000120(n+1) - 1 = wt(n+1) - 1. mov $1,6 pow $1,$0 mov $0,$1
; A047622: Numbers that are congruent to {0, 3, 5} mod 8. ; 0,3,5,8,11,13,16,19,21,24,27,29,32,35,37,40,43,45,48,51,53,56,59,61,64,67,69,72,75,77,80,83,85,88,91,93,96,99,101,104,107,109,112,115,117,120,123,125,128,131,133,136,139,141,144,147,149,152,155,157,160,163,165,168,171,173,176,179,181,184,187,189,192,195,197,200,203,205,208,211,213,216,219,221,224,227,229,232,235,237,240,243,245,248,251,253,256,259,261,264,267,269,272,275,277,280,283,285,288,291,293,296,299,301,304,307,309,312,315,317,320,323,325,328,331,333,336,339,341,344,347,349,352,355,357,360,363,365,368,371,373,376,379,381,384,387,389,392,395,397,400,403,405,408,411,413,416,419,421,424,427,429,432,435,437,440,443,445,448,451,453,456,459,461,464,467,469,472,475,477,480,483,485,488,491,493,496,499,501,504,507,509,512,515,517,520,523,525,528,531,533,536,539,541,544,547,549,552,555,557,560,563,565,568,571,573,576,579,581,584,587,589,592,595,597,600,603,605,608,611,613,616,619,621,624,627,629,632,635,637,640,643,645,648,651,653,656,659,661,664 mul $0,8 mov $1,1 add $1,$0 div $1,3
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "google_apis/drive/drive_api_parser.h" #include <algorithm> #include "base/basictypes.h" #include "base/files/file_path.h" #include "base/json/json_value_converter.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" #include "base/values.h" #include "google_apis/drive/time_util.h" using base::Value; using base::DictionaryValue; using base::ListValue; namespace google_apis { namespace { bool CreateFileResourceFromValue(const base::Value* value, scoped_ptr<FileResource>* file) { *file = FileResource::CreateFrom(*value); return !!*file; } // Converts |url_string| to |result|. Always returns true to be used // for JSONValueConverter::RegisterCustomField method. // TODO(mukai): make it return false in case of invalid |url_string|. bool GetGURLFromString(const base::StringPiece& url_string, GURL* result) { *result = GURL(url_string.as_string()); return true; } // Converts |value| to |result|. bool GetParentsFromValue(const base::Value* value, std::vector<ParentReference>* result) { DCHECK(value); DCHECK(result); const base::ListValue* list_value = NULL; if (!value->GetAsList(&list_value)) return false; base::JSONValueConverter<ParentReference> converter; result->resize(list_value->GetSize()); for (size_t i = 0; i < list_value->GetSize(); ++i) { const base::Value* parent_value = NULL; if (!list_value->Get(i, &parent_value) || !converter.Convert(*parent_value, &(*result)[i])) return false; } return true; } // Converts |value| to |result|. The key of |value| is app_id, and its value // is URL to open the resource on the web app. bool GetOpenWithLinksFromDictionaryValue( const base::Value* value, std::vector<FileResource::OpenWithLink>* result) { DCHECK(value); DCHECK(result); const base::DictionaryValue* dictionary_value; if (!value->GetAsDictionary(&dictionary_value)) return false; result->reserve(dictionary_value->size()); for (DictionaryValue::Iterator iter(*dictionary_value); !iter.IsAtEnd(); iter.Advance()) { std::string string_value; if (!iter.value().GetAsString(&string_value)) return false; FileResource::OpenWithLink open_with_link; open_with_link.app_id = iter.key(); open_with_link.open_url = GURL(string_value); result->push_back(open_with_link); } return true; } // Drive v2 API JSON names. // Definition order follows the order of documentation in // https://developers.google.com/drive/v2/reference/ // Common const char kKind[] = "kind"; const char kId[] = "id"; const char kETag[] = "etag"; const char kItems[] = "items"; const char kLargestChangeId[] = "largestChangeId"; // About Resource // https://developers.google.com/drive/v2/reference/about const char kAboutKind[] = "drive#about"; const char kQuotaBytesTotal[] = "quotaBytesTotal"; const char kQuotaBytesUsed[] = "quotaBytesUsed"; const char kRootFolderId[] = "rootFolderId"; // App Icon // https://developers.google.com/drive/v2/reference/apps const char kCategory[] = "category"; const char kSize[] = "size"; const char kIconUrl[] = "iconUrl"; // Apps Resource // https://developers.google.com/drive/v2/reference/apps const char kAppKind[] = "drive#app"; const char kName[] = "name"; const char kObjectType[] = "objectType"; const char kProductId[] = "productId"; const char kSupportsCreate[] = "supportsCreate"; const char kSupportsImport[] = "supportsImport"; const char kInstalled[] = "installed"; const char kAuthorized[] = "authorized"; const char kRemovable[] = "removable"; const char kPrimaryMimeTypes[] = "primaryMimeTypes"; const char kSecondaryMimeTypes[] = "secondaryMimeTypes"; const char kPrimaryFileExtensions[] = "primaryFileExtensions"; const char kSecondaryFileExtensions[] = "secondaryFileExtensions"; const char kIcons[] = "icons"; const char kCreateUrl[] = "createUrl"; // Apps List // https://developers.google.com/drive/v2/reference/apps/list const char kAppListKind[] = "drive#appList"; // Parent Resource // https://developers.google.com/drive/v2/reference/parents const char kParentReferenceKind[] = "drive#parentReference"; const char kParentLink[] = "parentLink"; const char kIsRoot[] = "isRoot"; // File Resource // https://developers.google.com/drive/v2/reference/files const char kFileKind[] = "drive#file"; const char kTitle[] = "title"; const char kMimeType[] = "mimeType"; const char kCreatedDate[] = "createdDate"; const char kModificationDate[] = "modificationDate"; const char kModifiedDate[] = "modifiedDate"; const char kModifiedByMeDate[] = "modifiedByMeDate"; const char kLastViewedByMeDate[] = "lastViewedByMeDate"; const char kSharedWithMeDate[] = "sharedWithMeDate"; const char kFileExtension[] = "fileExtension"; const char kMd5Checksum[] = "md5Checksum"; const char kFileSize[] = "fileSize"; const char kAlternateLink[] = "alternateLink"; const char kParents[] = "parents"; const char kOpenWithLinks[] = "openWithLinks"; const char kLabels[] = "labels"; const char kImageMediaMetadata[] = "imageMediaMetadata"; const char kShared[] = "shared"; // These 5 flags are defined under |labels|. const char kLabelStarred[] = "starred"; const char kLabelHidden[] = "hidden"; const char kLabelTrashed[] = "trashed"; const char kLabelRestricted[] = "restricted"; const char kLabelViewed[] = "viewed"; // These 3 flags are defined under |imageMediaMetadata|. const char kImageMediaMetadataWidth[] = "width"; const char kImageMediaMetadataHeight[] = "height"; const char kImageMediaMetadataRotation[] = "rotation"; const char kDriveFolderMimeType[] = "application/vnd.google-apps.folder"; // Files List // https://developers.google.com/drive/v2/reference/files/list const char kFileListKind[] = "drive#fileList"; const char kNextPageToken[] = "nextPageToken"; const char kNextLink[] = "nextLink"; // Change Resource // https://developers.google.com/drive/v2/reference/changes const char kChangeKind[] = "drive#change"; const char kFileId[] = "fileId"; const char kDeleted[] = "deleted"; const char kFile[] = "file"; // Changes List // https://developers.google.com/drive/v2/reference/changes/list const char kChangeListKind[] = "drive#changeList"; // Maps category name to enum IconCategory. struct AppIconCategoryMap { DriveAppIcon::IconCategory category; const char* category_name; }; const AppIconCategoryMap kAppIconCategoryMap[] = { { DriveAppIcon::DOCUMENT, "document" }, { DriveAppIcon::APPLICATION, "application" }, { DriveAppIcon::SHARED_DOCUMENT, "documentShared" }, }; // Checks if the JSON is expected kind. In Drive API, JSON data structure has // |kind| property which denotes the type of the structure (e.g. "drive#file"). bool IsResourceKindExpected(const base::Value& value, const std::string& expected_kind) { const base::DictionaryValue* as_dict = NULL; std::string kind; return value.GetAsDictionary(&as_dict) && as_dict->HasKey(kKind) && as_dict->GetString(kKind, &kind) && kind == expected_kind; } } // namespace //////////////////////////////////////////////////////////////////////////////// // AboutResource implementation AboutResource::AboutResource() : largest_change_id_(0), quota_bytes_total_(0), quota_bytes_used_(0) {} AboutResource::~AboutResource() {} // static scoped_ptr<AboutResource> AboutResource::CreateFrom(const base::Value& value) { scoped_ptr<AboutResource> resource(new AboutResource()); if (!IsResourceKindExpected(value, kAboutKind) || !resource->Parse(value)) { LOG(ERROR) << "Unable to create: Invalid About resource JSON!"; return scoped_ptr<AboutResource>(); } return resource.Pass(); } // static void AboutResource::RegisterJSONConverter( base::JSONValueConverter<AboutResource>* converter) { converter->RegisterCustomField<int64>(kLargestChangeId, &AboutResource::largest_change_id_, &base::StringToInt64); converter->RegisterCustomField<int64>(kQuotaBytesTotal, &AboutResource::quota_bytes_total_, &base::StringToInt64); converter->RegisterCustomField<int64>(kQuotaBytesUsed, &AboutResource::quota_bytes_used_, &base::StringToInt64); converter->RegisterStringField(kRootFolderId, &AboutResource::root_folder_id_); } bool AboutResource::Parse(const base::Value& value) { base::JSONValueConverter<AboutResource> converter; if (!converter.Convert(value, this)) { LOG(ERROR) << "Unable to parse: Invalid About resource JSON!"; return false; } return true; } //////////////////////////////////////////////////////////////////////////////// // DriveAppIcon implementation DriveAppIcon::DriveAppIcon() : category_(UNKNOWN), icon_side_length_(0) {} DriveAppIcon::~DriveAppIcon() {} // static void DriveAppIcon::RegisterJSONConverter( base::JSONValueConverter<DriveAppIcon>* converter) { converter->RegisterCustomField<IconCategory>( kCategory, &DriveAppIcon::category_, &DriveAppIcon::GetIconCategory); converter->RegisterIntField(kSize, &DriveAppIcon::icon_side_length_); converter->RegisterCustomField<GURL>(kIconUrl, &DriveAppIcon::icon_url_, GetGURLFromString); } // static scoped_ptr<DriveAppIcon> DriveAppIcon::CreateFrom(const base::Value& value) { scoped_ptr<DriveAppIcon> resource(new DriveAppIcon()); if (!resource->Parse(value)) { LOG(ERROR) << "Unable to create: Invalid DriveAppIcon JSON!"; return scoped_ptr<DriveAppIcon>(); } return resource.Pass(); } bool DriveAppIcon::Parse(const base::Value& value) { base::JSONValueConverter<DriveAppIcon> converter; if (!converter.Convert(value, this)) { LOG(ERROR) << "Unable to parse: Invalid DriveAppIcon"; return false; } return true; } // static bool DriveAppIcon::GetIconCategory(const base::StringPiece& category, DriveAppIcon::IconCategory* result) { for (size_t i = 0; i < arraysize(kAppIconCategoryMap); i++) { if (category == kAppIconCategoryMap[i].category_name) { *result = kAppIconCategoryMap[i].category; return true; } } DVLOG(1) << "Unknown icon category " << category; return false; } //////////////////////////////////////////////////////////////////////////////// // AppResource implementation AppResource::AppResource() : supports_create_(false), supports_import_(false), installed_(false), authorized_(false), removable_(false) { } AppResource::~AppResource() {} // static void AppResource::RegisterJSONConverter( base::JSONValueConverter<AppResource>* converter) { converter->RegisterStringField(kId, &AppResource::application_id_); converter->RegisterStringField(kName, &AppResource::name_); converter->RegisterStringField(kObjectType, &AppResource::object_type_); converter->RegisterStringField(kProductId, &AppResource::product_id_); converter->RegisterBoolField(kSupportsCreate, &AppResource::supports_create_); converter->RegisterBoolField(kSupportsImport, &AppResource::supports_import_); converter->RegisterBoolField(kInstalled, &AppResource::installed_); converter->RegisterBoolField(kAuthorized, &AppResource::authorized_); converter->RegisterBoolField(kRemovable, &AppResource::removable_); converter->RegisterRepeatedString(kPrimaryMimeTypes, &AppResource::primary_mimetypes_); converter->RegisterRepeatedString(kSecondaryMimeTypes, &AppResource::secondary_mimetypes_); converter->RegisterRepeatedString(kPrimaryFileExtensions, &AppResource::primary_file_extensions_); converter->RegisterRepeatedString(kSecondaryFileExtensions, &AppResource::secondary_file_extensions_); converter->RegisterRepeatedMessage(kIcons, &AppResource::icons_); converter->RegisterCustomField<GURL>(kCreateUrl, &AppResource::create_url_, GetGURLFromString); } // static scoped_ptr<AppResource> AppResource::CreateFrom(const base::Value& value) { scoped_ptr<AppResource> resource(new AppResource()); if (!IsResourceKindExpected(value, kAppKind) || !resource->Parse(value)) { LOG(ERROR) << "Unable to create: Invalid AppResource JSON!"; return scoped_ptr<AppResource>(); } return resource.Pass(); } bool AppResource::Parse(const base::Value& value) { base::JSONValueConverter<AppResource> converter; if (!converter.Convert(value, this)) { LOG(ERROR) << "Unable to parse: Invalid AppResource"; return false; } return true; } //////////////////////////////////////////////////////////////////////////////// // AppList implementation AppList::AppList() {} AppList::~AppList() {} // static void AppList::RegisterJSONConverter( base::JSONValueConverter<AppList>* converter) { converter->RegisterStringField(kETag, &AppList::etag_); converter->RegisterRepeatedMessage<AppResource>(kItems, &AppList::items_); } // static scoped_ptr<AppList> AppList::CreateFrom(const base::Value& value) { scoped_ptr<AppList> resource(new AppList()); if (!IsResourceKindExpected(value, kAppListKind) || !resource->Parse(value)) { LOG(ERROR) << "Unable to create: Invalid AppList JSON!"; return scoped_ptr<AppList>(); } return resource.Pass(); } bool AppList::Parse(const base::Value& value) { base::JSONValueConverter<AppList> converter; if (!converter.Convert(value, this)) { LOG(ERROR) << "Unable to parse: Invalid AppList"; return false; } return true; } //////////////////////////////////////////////////////////////////////////////// // ParentReference implementation ParentReference::ParentReference() : is_root_(false) {} ParentReference::~ParentReference() {} // static void ParentReference::RegisterJSONConverter( base::JSONValueConverter<ParentReference>* converter) { converter->RegisterStringField(kId, &ParentReference::file_id_); converter->RegisterCustomField<GURL>(kParentLink, &ParentReference::parent_link_, GetGURLFromString); converter->RegisterBoolField(kIsRoot, &ParentReference::is_root_); } // static scoped_ptr<ParentReference> ParentReference::CreateFrom(const base::Value& value) { scoped_ptr<ParentReference> reference(new ParentReference()); if (!IsResourceKindExpected(value, kParentReferenceKind) || !reference->Parse(value)) { LOG(ERROR) << "Unable to create: Invalid ParentRefernce JSON!"; return scoped_ptr<ParentReference>(); } return reference.Pass(); } bool ParentReference::Parse(const base::Value& value) { base::JSONValueConverter<ParentReference> converter; if (!converter.Convert(value, this)) { LOG(ERROR) << "Unable to parse: Invalid ParentReference"; return false; } return true; } //////////////////////////////////////////////////////////////////////////////// // FileResource implementation FileResource::FileResource() : shared_(false), file_size_(0) {} FileResource::~FileResource() {} // static void FileResource::RegisterJSONConverter( base::JSONValueConverter<FileResource>* converter) { converter->RegisterStringField(kId, &FileResource::file_id_); converter->RegisterStringField(kETag, &FileResource::etag_); converter->RegisterStringField(kTitle, &FileResource::title_); converter->RegisterStringField(kMimeType, &FileResource::mime_type_); converter->RegisterNestedField(kLabels, &FileResource::labels_); converter->RegisterNestedField(kImageMediaMetadata, &FileResource::image_media_metadata_); converter->RegisterCustomField<base::Time>( kCreatedDate, &FileResource::created_date_, &util::GetTimeFromString); converter->RegisterCustomField<base::Time>( kModifiedDate, &FileResource::modified_date_, &util::GetTimeFromString); converter->RegisterCustomField<base::Time>( kModifiedByMeDate, &FileResource::modified_by_me_date_, &util::GetTimeFromString); converter->RegisterCustomField<base::Time>( kLastViewedByMeDate, &FileResource::last_viewed_by_me_date_, &util::GetTimeFromString); converter->RegisterCustomField<base::Time>( kSharedWithMeDate, &FileResource::shared_with_me_date_, &util::GetTimeFromString); converter->RegisterBoolField(kShared, &FileResource::shared_); converter->RegisterStringField(kFileExtension, &FileResource::file_extension_); converter->RegisterStringField(kMd5Checksum, &FileResource::md5_checksum_); converter->RegisterCustomField<int64>(kFileSize, &FileResource::file_size_, &base::StringToInt64); converter->RegisterCustomField<GURL>(kAlternateLink, &FileResource::alternate_link_, GetGURLFromString); converter->RegisterCustomValueField<std::vector<ParentReference> >( kParents, &FileResource::parents_, GetParentsFromValue); converter->RegisterCustomValueField<std::vector<OpenWithLink> >( kOpenWithLinks, &FileResource::open_with_links_, GetOpenWithLinksFromDictionaryValue); } // static scoped_ptr<FileResource> FileResource::CreateFrom(const base::Value& value) { scoped_ptr<FileResource> resource(new FileResource()); if (!IsResourceKindExpected(value, kFileKind) || !resource->Parse(value)) { LOG(ERROR) << "Unable to create: Invalid FileResource JSON!"; return scoped_ptr<FileResource>(); } return resource.Pass(); } bool FileResource::IsDirectory() const { return mime_type_ == kDriveFolderMimeType; } bool FileResource::Parse(const base::Value& value) { base::JSONValueConverter<FileResource> converter; if (!converter.Convert(value, this)) { LOG(ERROR) << "Unable to parse: Invalid FileResource"; return false; } return true; } //////////////////////////////////////////////////////////////////////////////// // FileList implementation FileList::FileList() {} FileList::~FileList() {} // static void FileList::RegisterJSONConverter( base::JSONValueConverter<FileList>* converter) { converter->RegisterStringField(kETag, &FileList::etag_); converter->RegisterStringField(kNextPageToken, &FileList::next_page_token_); converter->RegisterCustomField<GURL>(kNextLink, &FileList::next_link_, GetGURLFromString); converter->RegisterRepeatedMessage<FileResource>(kItems, &FileList::items_); } // static bool FileList::HasFileListKind(const base::Value& value) { return IsResourceKindExpected(value, kFileListKind); } // static scoped_ptr<FileList> FileList::CreateFrom(const base::Value& value) { scoped_ptr<FileList> resource(new FileList()); if (!HasFileListKind(value) || !resource->Parse(value)) { LOG(ERROR) << "Unable to create: Invalid FileList JSON!"; return scoped_ptr<FileList>(); } return resource.Pass(); } bool FileList::Parse(const base::Value& value) { base::JSONValueConverter<FileList> converter; if (!converter.Convert(value, this)) { LOG(ERROR) << "Unable to parse: Invalid FileList"; return false; } return true; } //////////////////////////////////////////////////////////////////////////////// // ChangeResource implementation ChangeResource::ChangeResource() : change_id_(0), deleted_(false) {} ChangeResource::~ChangeResource() {} // static void ChangeResource::RegisterJSONConverter( base::JSONValueConverter<ChangeResource>* converter) { converter->RegisterCustomField<int64>(kId, &ChangeResource::change_id_, &base::StringToInt64); converter->RegisterStringField(kFileId, &ChangeResource::file_id_); converter->RegisterBoolField(kDeleted, &ChangeResource::deleted_); converter->RegisterCustomValueField(kFile, &ChangeResource::file_, &CreateFileResourceFromValue); converter->RegisterCustomField<base::Time>( kModificationDate, &ChangeResource::modification_date_, &util::GetTimeFromString); } // static scoped_ptr<ChangeResource> ChangeResource::CreateFrom(const base::Value& value) { scoped_ptr<ChangeResource> resource(new ChangeResource()); if (!IsResourceKindExpected(value, kChangeKind) || !resource->Parse(value)) { LOG(ERROR) << "Unable to create: Invalid ChangeResource JSON!"; return scoped_ptr<ChangeResource>(); } return resource.Pass(); } bool ChangeResource::Parse(const base::Value& value) { base::JSONValueConverter<ChangeResource> converter; if (!converter.Convert(value, this)) { LOG(ERROR) << "Unable to parse: Invalid ChangeResource"; return false; } return true; } //////////////////////////////////////////////////////////////////////////////// // ChangeList implementation ChangeList::ChangeList() : largest_change_id_(0) {} ChangeList::~ChangeList() {} // static void ChangeList::RegisterJSONConverter( base::JSONValueConverter<ChangeList>* converter) { converter->RegisterStringField(kETag, &ChangeList::etag_); converter->RegisterStringField(kNextPageToken, &ChangeList::next_page_token_); converter->RegisterCustomField<GURL>(kNextLink, &ChangeList::next_link_, GetGURLFromString); converter->RegisterCustomField<int64>(kLargestChangeId, &ChangeList::largest_change_id_, &base::StringToInt64); converter->RegisterRepeatedMessage<ChangeResource>(kItems, &ChangeList::items_); } // static bool ChangeList::HasChangeListKind(const base::Value& value) { return IsResourceKindExpected(value, kChangeListKind); } // static scoped_ptr<ChangeList> ChangeList::CreateFrom(const base::Value& value) { scoped_ptr<ChangeList> resource(new ChangeList()); if (!HasChangeListKind(value) || !resource->Parse(value)) { LOG(ERROR) << "Unable to create: Invalid ChangeList JSON!"; return scoped_ptr<ChangeList>(); } return resource.Pass(); } bool ChangeList::Parse(const base::Value& value) { base::JSONValueConverter<ChangeList> converter; if (!converter.Convert(value, this)) { LOG(ERROR) << "Unable to parse: Invalid ChangeList"; return false; } return true; } //////////////////////////////////////////////////////////////////////////////// // FileLabels implementation FileLabels::FileLabels() : starred_(false), hidden_(false), trashed_(false), restricted_(false), viewed_(false) {} FileLabels::~FileLabels() {} // static void FileLabels::RegisterJSONConverter( base::JSONValueConverter<FileLabels>* converter) { converter->RegisterBoolField(kLabelStarred, &FileLabels::starred_); converter->RegisterBoolField(kLabelHidden, &FileLabels::hidden_); converter->RegisterBoolField(kLabelTrashed, &FileLabels::trashed_); converter->RegisterBoolField(kLabelRestricted, &FileLabels::restricted_); converter->RegisterBoolField(kLabelViewed, &FileLabels::viewed_); } // static scoped_ptr<FileLabels> FileLabels::CreateFrom(const base::Value& value) { scoped_ptr<FileLabels> resource(new FileLabels()); if (!resource->Parse(value)) { LOG(ERROR) << "Unable to create: Invalid FileLabels JSON!"; return scoped_ptr<FileLabels>(); } return resource.Pass(); } bool FileLabels::Parse(const base::Value& value) { base::JSONValueConverter<FileLabels> converter; if (!converter.Convert(value, this)) { LOG(ERROR) << "Unable to parse: Invalid FileLabels."; return false; } return true; } //////////////////////////////////////////////////////////////////////////////// // ImageMediaMetadata implementation ImageMediaMetadata::ImageMediaMetadata() : width_(-1), height_(-1), rotation_(-1) {} ImageMediaMetadata::~ImageMediaMetadata() {} // static void ImageMediaMetadata::RegisterJSONConverter( base::JSONValueConverter<ImageMediaMetadata>* converter) { converter->RegisterIntField(kImageMediaMetadataWidth, &ImageMediaMetadata::width_); converter->RegisterIntField(kImageMediaMetadataHeight, &ImageMediaMetadata::height_); converter->RegisterIntField(kImageMediaMetadataRotation, &ImageMediaMetadata::rotation_); } // static scoped_ptr<ImageMediaMetadata> ImageMediaMetadata::CreateFrom( const base::Value& value) { scoped_ptr<ImageMediaMetadata> resource(new ImageMediaMetadata()); if (!resource->Parse(value)) { LOG(ERROR) << "Unable to create: Invalid ImageMediaMetadata JSON!"; return scoped_ptr<ImageMediaMetadata>(); } return resource.Pass(); } bool ImageMediaMetadata::Parse(const base::Value& value) { base::JSONValueConverter<ImageMediaMetadata> converter; if (!converter.Convert(value, this)) { LOG(ERROR) << "Unable to parse: Invalid ImageMediaMetadata."; return false; } return true; } } // namespace google_apis
.include "defaults_mod.asm" table_file_jp equ "exe5-utf8.tbl" table_file_en equ "bn5-utf8.tbl" game_code_len equ 3 game_code equ 0x4252424A // BRBJ game_code_2 equ 0x42524245 // BRBE game_code_3 equ 0x42524250 // BRBP card_type equ 1 card_id equ 56 card_no equ "056" card_sub equ "Mod Card 056" card_sub_x equ 64 card_desc_len equ 2 card_desc_1 equ "Gaia" card_desc_2 equ "15MB" card_desc_3 equ "" card_name_jp_full equ "ガイアント" card_name_jp_game equ "ガイアント" card_name_en_full equ "Gaia" card_name_en_game equ "Gaia" card_address equ "" card_address_id equ 0 card_bug equ 0 card_wrote_en equ "" card_wrote_jp equ ""
; Pokémon swarms in water SwarmWaterWildMons: ; No swarms encountered while surfing in Crystal db -1 ; end
.model medium, stdcall .stack .data brickBlack byte 00d ;black brickBrown byte 185d ; brown brickSkin byte 14d ;skin .code drawBrick proc x:word, y:word push AX push BX push CX push DX push SI push DI mov AX, @data mov DS, AX mov CX, x mov DX, y ;mov CX, 160d ;mov DX, 100d push CX mov ah, 0ch mov al, brickBrown ;row1 int 10h inc CX mov al,brickBlack int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBrown int 10h inc CX mov al,brickBlack int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBrown int 10h ;row2 pop CX push CX dec DX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX int 10h ;row 3 pop CX push CX dec DX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickSkin int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h ;row 4 pop CX push CX dec DX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX mov al,brickSkin int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX ;row 5 pop CX push CX dec DX mov al,brickSkin int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h ;row 6 pop CX push CX dec DX mov al,brickBlack int 10h inc CX int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h ;row 7 pop CX push CX dec DX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h ;row 8 pop CX push CX dec DX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h ;row 9 pop CX push CX dec DX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h ;row 10 pop CX push CX dec DX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickSkin int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h ;row 11 pop CX push CX dec DX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickBrown int 10h inc CX mov al,brickBlack int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBrown int 10h ;row 12 pop CX push CX dec DX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickSkin int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickSkin int 10h ;row 13 pop CX push CX dec DX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickSkin int 10h ;row 14 pop CX push CX dec DX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickSkin int 10h ;row 15 pop CX push CX dec DX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickSkin int 10h inc CX mov al,brickBrown int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickSkin int 10h ;row 16 pop CX push CX dec DX mov al, brickBlack int 10h inc CX mov al,brickSkin int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBlack int 10h inc CX mov al,brickBrown int 10h inc CX mov al,brickSkin int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,brickBrown int 10h pop CX pop DI pop SI pop DX pop CX pop BX pop AX ret drawBrick endp end
.686p .mmx .model flat,stdcall option casemap:none option prologue:none option epilogue:none .code ECP_Zero_J proc ptrA:DWORD pushad xor eax, eax mov ecx, (16+16+16)/4 mov edi, dword ptr [esp+20h+4] cld rep stosd popad ret 4 ECP_Zero_J endp end
.include "keyboard.inc" .include "data.inc" toyourfeet: call cls ld hl, data inc hl \ inc hl \ inc hl ld a, 0 cp (hl) ld hl, .strings ld bc, 5 ld a, 3 call z, .ploopadj call looped_print .loop: call shared@screens cp keyl jp z, .lay cp keyo jp z, .look jr .loop .ploopadj: ld bc, 0 ld a, 8 ret .lay: ld hl, data ld b, 3 .loopinc: inc hl djnz .loopinc ld a, 3 cp (hl) jp z, .nomore inc (hl) dec hl \ dec hl dec (hl) ret .look: ld hl, data inc hl inc (hl) ret .nomore: call line ld hl, .nothappening call puts jr .loop .strings: .dw string2@toyourfeet, dark_prince@shared_strings, string3@toyourfeet, dark_country@shared_strings,string4@toyourfeet .dw string1@toyourfeet, shared_options, options@toyourfeet .string1: .db "You rise to your feet, leaning against a nearby wall.\n" .db "\n" .db 0 .string2: .db "As you get up, memories rush back in to your skull. Your name is " .db "Adaer Lerauk, and you are a ",'"',"covert operative",'"',". You " .db "work for RISE (RISE! Imperialism Shall End!), a group dedicated to " .db "overthrowing the dark prince " .db 0 .string3: .db " and creating peace in ",0 .string4: .db ".\n" .db "\n" .db "Your current mission is to steal a copy of the battle plans for " .db "the upcoming battle between the forces of RISE and FALL (FALL! " .db "Annihilate Loathsome Lawless!) in the Vale of Larhultz. Clearly " .db "that mission didn't go as planned, though you can't quite " .db "remember what happened. What you *do* know is that you have to " .db "escape and complete your mission - or everyone you care about " .db "will pay the price...\n" .db "\n" .db 0 .options: .db "'l' - Lay back down\n'o' - lOok around",0 .nothappening: .db "Yeah, no. I don't have time to write up an amusing " .db "scenario for all however many times you want to do that.\n" .db "Sorry, not sorry.\n" .db 0
; A140841: Primes of the form 210n + 13. ; Submitted by Jon Maiga ; 13,223,433,643,853,1063,1483,1693,2113,2953,3163,3373,3583,3793,4003,4423,5683,6733,7573,7993,8623,9043,9463,9883,10093,10303,10513,10723,11353,12613,12823,13033,13873,14083,14293,14503,14713,14923,15973 mov $1,4 mov $2,$0 add $2,2 pow $2,2 lpb $2 sub $2,2 mov $3,$1 mul $3,3 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,35 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe mov $0,$1 sub $0,39 mul $0,3 add $0,13
; A243399: a(0) = 1, a(1) = 19; for n > 1, a(n) = 19*a(n-1) + a(n-2). ; Submitted by Jamie Morken(s2) ; 1,19,362,6897,131405,2503592,47699653,908796999,17314842634,329890807045,6285240176489,119749454160336,2281524869222873,43468721969394923,828187242287726410,15779026325436196713,300629687425575463957,5727743087411370011896,109127748348241605689981,2079154961704001878121535,39613072020724277289999146,754727523355465270388105309,14379436015774564414664000017,273964011823072189149004105632,5219695660654146158245742007025,99448181564251849195818102239107,1894735145381439280878789684550058 mov $3,1 lpb $0 sub $0,1 mov $2,$3 mul $3,19 add $3,$1 mov $1,$2 lpe mov $0,$3
; A263537: Integers k such that A098531(k) is divisible by A000071(k+2). ; 1,2,13,25,31,43,55,61,73,85,91,103,115,121,133,145,151,163,175,181,193,205,211,223,235,241,253,265,271,283,295,301,313,325,331,343,355,361,373,385,391,403,415,421,433,445,451,463,475,481,493,505,511,523,535,541,553,565,571,583,595,601,613,625,631,643,655,661,673,685,691,703,715,721,733,745,751,763,775,781,793,805,811,823,835,841,853,865,871,883,895,901,913,925,931,943,955,961,973,985,991,1003,1015,1021,1033,1045,1051,1063,1075,1081,1093,1105,1111,1123,1135,1141,1153,1165,1171,1183,1195,1201,1213,1225,1231,1243,1255,1261,1273,1285,1291,1303,1315,1321,1333,1345,1351,1363,1375,1381,1393,1405,1411,1423,1435,1441,1453,1465,1471,1483,1495,1501,1513,1525,1531,1543,1555,1561,1573,1585,1591,1603,1615,1621,1633,1645,1651,1663,1675,1681,1693,1705,1711,1723,1735,1741,1753,1765,1771,1783,1795,1801,1813,1825,1831,1843,1855,1861,1873,1885,1891,1903,1915,1921,1933,1945,1951,1963,1975,1981,1993,2005,2011,2023,2035,2041,2053,2065,2071,2083,2095,2101,2113,2125,2131,2143,2155,2161,2173,2185,2191,2203,2215,2221,2233,2245,2251,2263,2275,2281,2293,2305,2311,2323,2335,2341,2353,2365,2371,2383,2395,2401,2413,2425,2431,2443,2455,2461,2473,2485 mul $0,2 trn $0,1 mov $2,$0 mov $3,$0 mul $0,2 add $0,2 sub $0,$3 mul $3,2 mov $4,5 lpb $0 sub $0,1 trn $0,2 mov $1,$4 add $2,$3 add $2,3 add $3,2 sub $1,$3 add $1,2 mov $3,3 lpe add $1,$2 sub $1,7