diff --git a/pool/shard010/C++/0111158_CompressRGB.cpp b/pool/shard010/C++/0111158_CompressRGB.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..35239c4518eb32913fdb5ee6eb2bbad7f53f6594
--- /dev/null
+++ b/pool/shard010/C++/0111158_CompressRGB.cpp
@@ -0,0 +1,140 @@
+// Copyright NVIDIA Corporation 2007 -- Ignacio Castano
+//
+// 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
+
+#include
+#include
+#include
+
+#include "CompressRGB.h"
+#include "CompressionOptions.h"
+#include "OutputOptions.h"
+
+using namespace nv;
+using namespace nvtt;
+
+namespace
+{
+
+ inline uint computePitch(uint w, uint bitsize)
+ {
+ uint p = w * ((bitsize + 7) / 8);
+
+ // Align to 32 bits.
+ return ((p + 3) / 4) * 4;
+ }
+
+ inline void convert_to_a8r8g8b8(const void * src, void * dst, uint w)
+ {
+ memcpy(dst, src, 4 * w);
+ }
+
+ inline void convert_to_x8r8g8b8(const void * src, void * dst, uint w)
+ {
+ memcpy(dst, src, 4 * w);
+ }
+
+} // namespace
+
+
+// Pixel format converter.
+void nv::compressRGB(const Image * image, const OutputOptions::Private & outputOptions, const CompressionOptions::Private & compressionOptions)
+{
+ nvCheck(image != NULL);
+
+ const uint w = image->width();
+ const uint h = image->height();
+
+ const uint bitCount = compressionOptions.bitcount;
+ nvCheck(bitCount == 8 || bitCount == 16 || bitCount == 24 || bitCount == 32);
+
+ const uint byteCount = bitCount / 8;
+
+ const uint rmask = compressionOptions.rmask;
+ uint rshift, rsize;
+ PixelFormat::maskShiftAndSize(rmask, &rshift, &rsize);
+
+ const uint gmask = compressionOptions.gmask;
+ uint gshift, gsize;
+ PixelFormat::maskShiftAndSize(gmask, &gshift, &gsize);
+
+ const uint bmask = compressionOptions.bmask;
+ uint bshift, bsize;
+ PixelFormat::maskShiftAndSize(bmask, &bshift, &bsize);
+
+ const uint amask = compressionOptions.amask;
+ uint ashift, asize;
+ PixelFormat::maskShiftAndSize(amask, &ashift, &asize);
+
+ // Determine pitch.
+ uint pitch = computePitch(w, compressionOptions.bitcount);
+
+ uint8 * dst = (uint8 *)mem::malloc(pitch + 4);
+
+ for (uint y = 0; y < h; y++)
+ {
+ const Color32 * src = image->scanline(y);
+
+ if (bitCount == 32 && rmask == 0xFF0000 && gmask == 0xFF00 && bmask == 0xFF && amask == 0xFF000000)
+ {
+ convert_to_a8r8g8b8(src, dst, w);
+ }
+ else if (bitCount == 32 && rmask == 0xFF0000 && gmask == 0xFF00 && bmask == 0xFF && amask == 0)
+ {
+ convert_to_x8r8g8b8(src, dst, w);
+ }
+ else
+ {
+ // Generic pixel format conversion.
+ for (uint x = 0; x < w; x++)
+ {
+ uint c = 0;
+ c |= PixelFormat::convert(src[x].r, 8, rsize) << rshift;
+ c |= PixelFormat::convert(src[x].g, 8, gsize) << gshift;
+ c |= PixelFormat::convert(src[x].b, 8, bsize) << bshift;
+ c |= PixelFormat::convert(src[x].a, 8, asize) << ashift;
+
+ // Output one byte at a time.
+ for (uint i = 0; i < byteCount; i++)
+ {
+ *(dst + x * byteCount + i) = (c >> (i * 8)) & 0xFF;
+ }
+ }
+
+ // Zero padding.
+ for (uint x = w * byteCount; x < pitch; x++)
+ {
+ *(dst + x) = 0;
+ }
+ }
+
+ if (outputOptions.outputHandler != NULL)
+ {
+ outputOptions.outputHandler->writeData(dst, pitch);
+ }
+ }
+
+ mem::free(dst);
+}
+
diff --git a/pool/shard010/C++/0111161_Server.cpp b/pool/shard010/C++/0111161_Server.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0bf2b641fd3313cb97aa6c0072fc71373c398a5f
--- /dev/null
+++ b/pool/shard010/C++/0111161_Server.cpp
@@ -0,0 +1,132 @@
+//Based of off WTFIAWS' code
+
+
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include "Server.h"
+#include "header.h"
+
+static const char *server_domain = "http://localhost";
+
+using boost::asio::ip::tcp;
+
+Server::Server(boost::asio::io_service& io_service, Config *conf) {
+ service_ = &io_service;
+ port_ = conf->get_port();
+ handlers_ = conf->get_handlers();
+}
+
+std::string Server::get_prefix(std::string full_path) {
+ if(full_path.at(0) != '/') {
+ return full_path;
+ } else {
+ size_t found = full_path.find("/", 1);
+ if(found != std::string::npos) {
+ return full_path.substr(0, found);
+ } else {
+ return full_path;
+ }
+ }
+}
+
+void Server::run() {
+ fprintf(stderr, "Starting server at %s:%d\n", server_domain, port_);
+ tcp::acceptor a(*service_, tcp::endpoint(tcp::v4(), port_));
+ boost::thread q(boost::bind(&Server::end, this));
+ while(true) {
+ sock_ptr sock(new tcp::socket(*service_));
+ a.accept(*sock);
+ boost::thread t(boost::bind(&Server::session, sock, this));
+ }
+}
+
+const HTTPRequest Server::parseRequest(std::istream &stream) {
+ HTTPRequest request;
+ int content_length;
+ std::string s;
+
+ stream >> request.method;
+ stream >> request.path;
+ stream >> s; // Get rid of the HTTP version
+
+ std::string header_name, header_value;
+ stream.ignore(1, '\n'); // don't care about newlines
+ while(stream.peek() != 13) { // while next character is not carriage return
+ std::pair header;
+ getline(stream, header.first, ':');
+ stream.ignore(1, ' '); // ignore whitespace
+ getline(stream, header.second, '\r');
+ stream.ignore(1, '\n'); // don't care about newlines
+ if(header.first == "Content-Length") {
+ content_length = stoi(header_value);
+ }
+ request.headers.push_back(header);
+ }
+ stream.ignore(2, '\n'); // Get rid of empty lines at the end
+ if (content_length != 0) {
+ request.request_body.resize(content_length);
+ stream.read(&request.request_body[0], content_length);
+ }
+ return request;
+}
+
+void Server::session(sock_ptr sock, Server *s) {
+ try {
+ // Read request into buffer
+ char req_buf[max_length];
+
+ boost::system::error_code error;
+ size_t length = sock->read_some(boost::asio::buffer(req_buf), error);
+ if (error)
+ throw boost::system::system_error(error);
+
+ std::stringstream stream(std::string(req_buf, length));
+
+ // Create HTTP request from read request
+ const HTTPRequest request = s->parseRequest(stream);
+ std::string prefix = s->get_prefix(request.path);
+
+ using namespace boost::asio;
+ if(s->handlers_.count(prefix) > 0) {
+ std::string response = s->handlers_[prefix]->HandleRequest(request);
+ write(*sock, buffer(response, response.size()));
+ } else {
+ write(*sock, buffer(status_strings::not_found,
+ status_strings::not_found.size()));
+ }
+
+ // 404 ERROR if we reach here
+ #ifdef DEBUG
+ fprintf(stderr, "DEBUG: Unrecognized request type.\n\n");
+ #endif
+
+ }
+ catch (std::exception& e) {
+ std::cerr << "Exception in thread: " << e.what() << "\n";
+ }
+}
+
+/**
+ * Throws an ExitErrorException which should be caught to quit all
+ * server threads.
+ */
+void Server::end()
+{
+ std::string quit;
+ while (quit != "q")
+ {
+ printf("Enter q to quit the server: ");
+ // Release control to server
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(10));
+ std::cin >> quit;
+ }
+ // If we reach here, the user entered "q"
+ throw ExitServerException();
+}
\ No newline at end of file
diff --git a/pool/shard010/C++/0111165_Base32Test.cpp b/pool/shard010/C++/0111165_Base32Test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4bc1c33d4f32b37f018c78d7e1d0adcc1e630dad
--- /dev/null
+++ b/pool/shard010/C++/0111165_Base32Test.cpp
@@ -0,0 +1,184 @@
+//
+// Base32Test.cpp
+//
+// $Id: //poco/1.4/Foundation/testsuite/src/Base32Test.cpp#1 $
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Base32Test.h"
+#include "CppUnit/TestCaller.h"
+#include "CppUnit/TestSuite.h"
+#include "Poco/Base32Encoder.h"
+#include "Poco/Base32Decoder.h"
+#include "Poco/Exception.h"
+#include
+
+
+using Poco::Base32Encoder;
+using Poco::Base32Decoder;
+using Poco::DataFormatException;
+
+
+Base32Test::Base32Test(const std::string& name): CppUnit::TestCase(name)
+{
+}
+
+
+Base32Test::~Base32Test()
+{
+}
+
+
+void Base32Test::testEncoder()
+{
+ {
+ std::ostringstream str;
+ Base32Encoder encoder(str);
+ encoder << std::string("\00\01\02\03\04\05", 6);
+ encoder.close();
+ assert (str.str() == "AAAQEAYEAU======");
+ }
+ {
+ std::ostringstream str;
+ Base32Encoder encoder(str);
+ encoder << std::string("\00\01\02\03", 4);
+ encoder.close();
+ assert (str.str() == "AAAQEAY=");
+ }
+ {
+ std::ostringstream str;
+ Base32Encoder encoder(str, false);
+ encoder << "ABCDEF";
+ encoder.close();
+ assert (str.str() == "IFBEGRCFIY");
+ }
+ {
+ std::ostringstream str;
+ Base32Encoder encoder(str);
+ encoder << "ABCDEF";
+ encoder.close();
+ assert (str.str() == "IFBEGRCFIY======");
+ }
+ {
+ std::ostringstream str;
+ Base32Encoder encoder(str);
+ encoder << "ABCDE";
+ encoder.close();
+ assert (str.str() == "IFBEGRCF");
+ }
+}
+
+
+void Base32Test::testDecoder()
+{
+ {
+ std::istringstream istr("AAAQEAYEAU======");
+ Base32Decoder decoder(istr);
+ assert (decoder.good() && decoder.get() == 0);
+ assert (decoder.good() && decoder.get() == 1);
+ assert (decoder.good() && decoder.get() == 2);
+ assert (decoder.good() && decoder.get() == 3);
+ assert (decoder.good() && decoder.get() == 4);
+ assert (decoder.good() && decoder.get() == 5);
+ assert (decoder.good() && decoder.get() == -1);
+ }
+ {
+ std::istringstream istr("AAAQEAYE");
+ Base32Decoder decoder(istr);
+ assert (decoder.good() && decoder.get() == 0);
+ assert (decoder.good() && decoder.get() == 1);
+ assert (decoder.good() && decoder.get() == 2);
+ assert (decoder.good() && decoder.get() == 3);
+ assert (decoder.good() && decoder.get() == 4);
+ assert (decoder.good() && decoder.get() == -1);
+ }
+ {
+ std::istringstream istr("AAAQEAY=");
+ Base32Decoder decoder(istr);
+ assert (decoder.good() && decoder.get() == 0);
+ assert (decoder.good() && decoder.get() == 1);
+ assert (decoder.good() && decoder.get() == 2);
+ assert (decoder.good() && decoder.get() == 3);
+ assert (decoder.good() && decoder.get() == -1);
+ }
+ {
+ std::istringstream istr("IFBEGRCFIY======");
+ Base32Decoder decoder(istr);
+ std::string s;
+ decoder >> s;
+ assert (s == "ABCDEF");
+ assert (decoder.eof());
+ assert (!decoder.fail());
+ }
+ {
+ std::istringstream istr("QUJD#REVG");
+ Base32Decoder decoder(istr);
+ std::string s;
+ try
+ {
+ decoder >> s;
+ assert (decoder.bad());
+ }
+ catch (DataFormatException&)
+ {
+ }
+ assert (!decoder.eof());
+ }
+}
+
+
+void Base32Test::testEncodeDecode()
+{
+ {
+ std::stringstream str;
+ Base32Encoder encoder(str);
+ encoder << "The quick brown fox ";
+ encoder << "jumped over the lazy dog.";
+ encoder.close();
+ Base32Decoder decoder(str);
+ std::string s;
+ int c = decoder.get();
+ while (c != -1) { s += char(c); c = decoder.get(); }
+ assert (s == "The quick brown fox jumped over the lazy dog.");
+ }
+ {
+ std::string src;
+ for (int i = 0; i < 255; ++i) src += char(i);
+ std::stringstream str;
+ Base32Encoder encoder(str);
+ encoder.write(src.data(), (std::streamsize) src.size());
+ encoder.close();
+ Base32Decoder decoder(str);
+ std::string s;
+ int c = decoder.get();
+ while (c != -1) { s += char(c); c = decoder.get(); }
+ assert (s == src);
+ }
+}
+
+
+void Base32Test::setUp()
+{
+}
+
+
+void Base32Test::tearDown()
+{
+}
+
+
+CppUnit::Test* Base32Test::suite()
+{
+ CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("Base32Test");
+
+ CppUnit_addTest(pSuite, Base32Test, testEncoder);
+ CppUnit_addTest(pSuite, Base32Test, testDecoder);
+ CppUnit_addTest(pSuite, Base32Test, testEncodeDecode);
+
+ return pSuite;
+}
diff --git a/pool/shard010/C++/0111171_output_accel_angle.cpp b/pool/shard010/C++/0111171_output_accel_angle.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e43a8bc4f2b773e339de7dc4fbc3d36e14153c06
--- /dev/null
+++ b/pool/shard010/C++/0111171_output_accel_angle.cpp
@@ -0,0 +1,20 @@
+/*******output 3axis_acceleration[G]*******/
+#include "ros/ros.h"
+#include "accel_angle.h"
+#include
+
+void chatterCallback(const openreroc_posturesensor::accel_angle msg_a_ang)
+{
+ printf("accel_x:%f\n ", msg_a_ang.ac_x_ang);
+ printf("accel_y:%f\n", msg_a_ang.ac_y_ang);
+ printf("accel_z:%f\n", msg_a_ang.ac_z_ang);
+}
+
+int main(int argc, char **argv)
+{
+ ros::init(argc, argv, "output_accel_angle");
+ ros::NodeHandle n;
+ ros::Subscriber sub = n.subscribe("accel_angle_value", 1000, chatterCallback);
+ ros::spin();
+ return 0;
+}
diff --git a/pool/shard010/C++/0111173_webfilesystem_impl.cc b/pool/shard010/C++/0111173_webfilesystem_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e05ded3733d9d8f42be30235e8a2f349f5cc4495
--- /dev/null
+++ b/pool/shard010/C++/0111173_webfilesystem_impl.cc
@@ -0,0 +1,144 @@
+// Copyright 2013 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 "content/child/fileapi/webfilesystem_impl.h"
+
+#include "base/bind.h"
+#include "content/child/child_thread.h"
+#include "content/child/fileapi/file_system_dispatcher.h"
+#include "content/child/fileapi/webfilesystem_callback_adapters.h"
+#include "content/child/fileapi/webfilewriter_impl.h"
+#include "third_party/WebKit/public/web/WebFileSystemCallbacks.h"
+#include "third_party/WebKit/public/platform/WebFileInfo.h"
+#include "third_party/WebKit/public/platform/WebString.h"
+#include "third_party/WebKit/public/platform/WebURL.h"
+#include "webkit/glue/webkit_glue.h"
+
+using WebKit::WebFileInfo;
+using WebKit::WebFileSystemCallbacks;
+using WebKit::WebFileSystemEntry;
+using WebKit::WebString;
+using WebKit::WebURL;
+using WebKit::WebVector;
+
+namespace content {
+
+WebFileSystemImpl::WebFileSystemImpl() {
+}
+
+void WebFileSystemImpl::move(const WebURL& src_path,
+ const WebURL& dest_path,
+ WebFileSystemCallbacks* callbacks) {
+ FileSystemDispatcher* dispatcher =
+ ChildThread::current()->file_system_dispatcher();
+ dispatcher->Move(GURL(src_path),
+ GURL(dest_path),
+ base::Bind(&FileStatusCallbackAdapter, callbacks));
+}
+
+void WebFileSystemImpl::copy(const WebURL& src_path,
+ const WebURL& dest_path,
+ WebFileSystemCallbacks* callbacks) {
+ FileSystemDispatcher* dispatcher =
+ ChildThread::current()->file_system_dispatcher();
+ dispatcher->Copy(GURL(src_path),
+ GURL(dest_path),
+ base::Bind(&FileStatusCallbackAdapter, callbacks));
+}
+
+void WebFileSystemImpl::remove(const WebURL& path,
+ WebFileSystemCallbacks* callbacks) {
+ FileSystemDispatcher* dispatcher =
+ ChildThread::current()->file_system_dispatcher();
+ dispatcher->Remove(
+ GURL(path),
+ false /* recursive */,
+ base::Bind(&FileStatusCallbackAdapter, callbacks));
+}
+
+void WebFileSystemImpl::removeRecursively(const WebURL& path,
+ WebFileSystemCallbacks* callbacks) {
+ FileSystemDispatcher* dispatcher =
+ ChildThread::current()->file_system_dispatcher();
+ dispatcher->Remove(
+ GURL(path),
+ true /* recursive */,
+ base::Bind(&FileStatusCallbackAdapter, callbacks));
+}
+
+void WebFileSystemImpl::readMetadata(const WebURL& path,
+ WebFileSystemCallbacks* callbacks) {
+ FileSystemDispatcher* dispatcher =
+ ChildThread::current()->file_system_dispatcher();
+ dispatcher->ReadMetadata(
+ GURL(path),
+ base::Bind(&ReadMetadataCallbackAdapter, callbacks),
+ base::Bind(&FileStatusCallbackAdapter, callbacks));
+}
+
+void WebFileSystemImpl::createFile(const WebURL& path,
+ bool exclusive,
+ WebFileSystemCallbacks* callbacks) {
+ FileSystemDispatcher* dispatcher =
+ ChildThread::current()->file_system_dispatcher();
+ dispatcher->Create(
+ GURL(path), exclusive, false /* directory */, false /* recursive */,
+ base::Bind(&FileStatusCallbackAdapter, callbacks));
+}
+
+void WebFileSystemImpl::createDirectory(const WebURL& path,
+ bool exclusive,
+ WebFileSystemCallbacks* callbacks) {
+ FileSystemDispatcher* dispatcher =
+ ChildThread::current()->file_system_dispatcher();
+ dispatcher->Create(
+ GURL(path), exclusive, true /* directory */, false /* recursive */,
+ base::Bind(&FileStatusCallbackAdapter, callbacks));
+}
+
+void WebFileSystemImpl::fileExists(const WebURL& path,
+ WebFileSystemCallbacks* callbacks) {
+ FileSystemDispatcher* dispatcher =
+ ChildThread::current()->file_system_dispatcher();
+ dispatcher->Exists(
+ GURL(path), false /* directory */,
+ base::Bind(&FileStatusCallbackAdapter, callbacks));
+}
+
+void WebFileSystemImpl::directoryExists(const WebURL& path,
+ WebFileSystemCallbacks* callbacks) {
+ FileSystemDispatcher* dispatcher =
+ ChildThread::current()->file_system_dispatcher();
+ dispatcher->Exists(
+ GURL(path), true /* directory */,
+ base::Bind(&FileStatusCallbackAdapter, callbacks));
+}
+
+void WebFileSystemImpl::readDirectory(const WebURL& path,
+ WebFileSystemCallbacks* callbacks) {
+ FileSystemDispatcher* dispatcher =
+ ChildThread::current()->file_system_dispatcher();
+ dispatcher->ReadDirectory(
+ GURL(path),
+ base::Bind(&ReadDirectoryCallbackAdapater, callbacks),
+ base::Bind(&FileStatusCallbackAdapter, callbacks));
+}
+
+WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter(
+ const WebURL& path, WebKit::WebFileWriterClient* client) {
+ return new WebFileWriterImpl(GURL(path), client);
+}
+
+void WebFileSystemImpl::createSnapshotFileAndReadMetadata(
+ const WebKit::WebURL& path,
+ WebKit::WebFileSystemCallbacks* callbacks) {
+ FileSystemDispatcher* dispatcher =
+ ChildThread::current()->file_system_dispatcher();
+ dispatcher->CreateSnapshotFile(
+ GURL(path),
+ base::Bind(&CreateSnapshotFileCallbackAdapter, callbacks),
+ base::Bind(&FileStatusCallbackAdapter, callbacks));
+}
+
+} // namespace content
diff --git a/pool/shard010/C++/0111175_WiggleRangeParser.cc b/pool/shard010/C++/0111175_WiggleRangeParser.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e3b1464629be5e87dd1251c3128332510473934e
--- /dev/null
+++ b/pool/shard010/C++/0111175_WiggleRangeParser.cc
@@ -0,0 +1,19 @@
+class WiggleRangeParser : public WiggleParser {
+public:
+ WiggleRangeParser() :
+ max_(-numeric_limits::max()),
+ min_(numeric_limits::max()) {
+ }
+
+ void addValue(int base, float value) {
+ max_ = max(value, max_);
+ min_ = min(value, min_);
+ }
+
+ float getMax() { return max_; }
+ float getMin() { return min_; }
+
+private:
+ float max_;
+ float min_;
+};
diff --git a/pool/shard010/C++/0111180_testopenstreetmap.cpp b/pool/shard010/C++/0111180_testopenstreetmap.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e49bfdbe4828f3d73c547c358b87a053b589495f
--- /dev/null
+++ b/pool/shard010/C++/0111180_testopenstreetmap.cpp
@@ -0,0 +1,193 @@
+/***************************************************************************
+ testopenstreetmap.cpp
+ --------------------------------------
+ Date : January 2013
+ Copyright : (C) 2013 by Martin Dobias
+ Email : wonder dot sk at gmail dot com
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include
+#include
+
+#include
+//#include
+
+#include "openstreetmap/qgsosmdatabase.h"
+#include "openstreetmap/qgsosmdownload.h"
+#include "openstreetmap/qgsosmimport.h"
+
+class TestOpenStreetMap : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void initTestCase();// will be called before the first testfunction is executed.
+ void cleanupTestCase();// will be called after the last testfunction was executed.
+ void init() ;// will be called before each testfunction is executed.
+ void cleanup() ;// will be called after every testfunction.
+ /** Our tests proper begin here */
+ void download();
+ void importAndQueries();
+ private:
+
+};
+
+void TestOpenStreetMap::initTestCase()
+{
+ //
+ // Runs once before any tests are run
+ //
+ // init QGIS's paths - true means that all path will be inited from prefix
+ QgsApplication::init();
+ //QgsApplication::initQgis();
+ //QgsApplication::showSettings();
+
+ //create some objects that will be used in all tests...
+ //create a map layer that will be used in all tests...
+ //QString myBaseFileName( TEST_DATA_DIR ); //defined in CmakeLists.txt
+}
+void TestOpenStreetMap::cleanupTestCase()
+{
+
+}
+void TestOpenStreetMap::init()
+{
+
+}
+void TestOpenStreetMap::cleanup()
+{
+}
+
+
+void TestOpenStreetMap::download()
+{
+ QgsRectangle rect( 7.148, 51.249, 7.152, 51.251 );
+
+ // start download
+ QgsOSMDownload download;
+ download.setQuery( QgsOSMDownload::queryFromRect( rect ) );
+ download.setOutputFileName( "/tmp/dl-test.osm" );
+ bool res = download.start();
+ QVERIFY( res );
+
+ // wait for finished() signal
+ int timeout = 15000; // in miliseconds - max waiting time
+ int waitTime = 500; // in miliseconds - unit waiting time
+ QSignalSpy spy( &download, SIGNAL( finished() ) );
+ while ( timeout > 0 && spy.count() == 0 )
+ {
+ QTest::qWait( waitTime );
+ timeout -= waitTime;
+ }
+
+ QVERIFY( spy.count() != 0 );
+
+ if ( download.hasError() )
+ qDebug( "ERROR: %s", download.errorString().toAscii().data() );
+}
+
+
+void TestOpenStreetMap::importAndQueries()
+{
+ QString dbFilename = "/tmp/testdata.db";
+ QString xmlFilename = TEST_DATA_DIR "/openstreetmap/testdata.xml";
+
+ QgsOSMXmlImport import( xmlFilename, dbFilename );
+ bool res = import.import();
+ if ( import.hasError() )
+ qDebug( "XML ERR: %s", import.errorString().toAscii().data() );
+ QCOMPARE( res, true );
+ QCOMPARE( import.hasError(), false );
+
+ qDebug( "import finished" );
+
+ QgsOSMDatabase db( dbFilename );
+ bool dbopenRes = db.open();
+ if ( !db.errorString().isEmpty() )
+ qDebug( "DB ERR: %s", db.errorString().toAscii().data() );
+ QCOMPARE( dbopenRes, true );
+
+ // query node
+
+ QgsOSMNode n = db.node( 11111 );
+ QCOMPARE( n.isValid(), true );
+ QCOMPARE( n.point().x(), 14.4277148 );
+ QCOMPARE( n.point().y(), 50.0651387 );
+
+ QgsOSMNode nNot = db.node( 22222 );
+ QCOMPARE( nNot.isValid(), false );
+
+ // query node tags
+
+ QgsOSMTags tags = db.tags( false, 11111 );
+ QCOMPARE( tags.count(), 7 );
+ QCOMPARE( tags.value( "addr:postcode" ), QString( "12800" ) );
+
+ QgsOSMTags tags2 = db.tags( false, 360769661 );
+ QCOMPARE( tags2.count(), 0 );
+ QCOMPARE( tags2.value( "addr:postcode" ), QString() );
+
+ QgsOSMTags tagsNot = db.tags( false, 22222 );
+ QCOMPARE( tagsNot.count(), 0 );
+
+ // list nodes
+
+ QgsOSMNodeIterator nodes = db.listNodes();
+ QCOMPARE( nodes.next().id(), ( qint64 )11111 );
+ QCOMPARE( nodes.next().id(), ( qint64 )360769661 );
+ nodes.close();
+
+ // query way
+
+ QgsOSMWay w = db.way( 32137532 );
+ QCOMPARE( w.isValid(), true );
+ QCOMPARE( w.nodes().count(), 5 );
+ QCOMPARE( w.nodes()[0], ( qint64 )360769661 );
+ QCOMPARE( w.nodes()[1], ( qint64 )360769664 );
+
+ QgsOSMWay wNot = db.way( 1234567 );
+ QCOMPARE( wNot.isValid(), false );
+
+ // query way tags
+
+ QgsOSMTags tagsW = db.tags( true, 32137532 );
+ QCOMPARE( tagsW.count(), 3 );
+ QCOMPARE( tagsW.value( "building" ), QString( "yes" ) );
+
+ QgsOSMTags tagsWNot = db.tags( true, 1234567 );
+ QCOMPARE( tagsWNot.count(), 0 );
+
+ // list ways
+
+ QgsOSMWayIterator ways = db.listWays();
+ QCOMPARE( ways.next().id(), ( qint64 )32137532 );
+ QCOMPARE( ways.next().isValid(), false );
+ ways.close();
+
+ bool exportRes1 = db.exportSpatiaLite( QgsOSMDatabase::Point, "sl_points", QStringList( "addr:postcode" ) );
+ //bool exportRes = db.exportSpatiaLite( QStringList("amenity") << "name" << "highway" );
+ if ( !db.errorString().isEmpty() )
+ qDebug( "EXPORT-1 ERR: %s", db.errorString().toAscii().data() );
+ QCOMPARE( exportRes1, true );
+
+
+ bool exportRes2 = db.exportSpatiaLite( QgsOSMDatabase::Polyline, "sl_lines", QStringList( "building" ) );
+ //bool exportRes2 = db.exportSpatiaLite( QStringList("amenity") << "name" << "highway" );
+ if ( !db.errorString().isEmpty() )
+ qDebug( "EXPORT-2 ERR: %s", db.errorString().toAscii().data() );
+ QCOMPARE( exportRes2, true );
+
+
+ // TODO: test exported data
+}
+
+
+QTEST_MAIN( TestOpenStreetMap )
+
+#include "testopenstreetmap.moc"
diff --git a/pool/shard010/C++/0111181_LengthNormWriter.cpp b/pool/shard010/C++/0111181_LengthNormWriter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..635983fca5cc4ef69e61e8bc358e51b86386fff7
--- /dev/null
+++ b/pool/shard010/C++/0111181_LengthNormWriter.cpp
@@ -0,0 +1,102 @@
+//
+// Copyright(C) 2005--2011 FirteX Development Team.
+// All rights reserved.
+// This file is part of FirteX (www.firtex.org)
+//
+// Use of the FirteX is subject to the terms of the software license set forth in
+// the LICENSE file included with this software, and also available at
+// http://www.firtex.org/license.html
+//
+// Author : Ruijie Guo
+// Email : ruijieguo@gmail.com
+// Created : 2006/1/4
+//
+
+#include "firtex/index/LengthNormWriter.h"
+#include "firtex/utility/NumberFormatter.h"
+#include "firtex/store/OutputStream.h"
+#include "firtex/index/LengthNormEncoder.h"
+
+FX_NS_USE(store);
+FX_NS_USE(utility);
+FX_NS_USE(document);
+
+using namespace std;
+
+FX_NS_DEF(index);
+
+SETUP_STREAM_LOGGER(index, LengthNormWriter);
+
+LengthNormWriter::LengthNormWriter(const FileSystemPtr& pFileSys)
+ : m_pFileSys(pFileSys)
+{
+}
+
+LengthNormWriter::~LengthNormWriter(void)
+{
+}
+
+void LengthNormWriter::init(const DocumentSchema* pDocSchema)
+{
+ DocumentSchema::Iterator iter = pDocSchema->iterator();
+ while (iter.hasNext())
+ {
+ const FieldSchema* pFieldSchema = iter.next();
+ fieldid_t fieldId = pFieldSchema->getId();
+ if (pFieldSchema->isIndexed() && pFieldSchema->hasLengthNorm())
+ {
+ if (fieldId >= (fieldid_t)m_lengthNorm.size())
+ {
+ m_lengthNorm.resize((size_t)fieldId + 1);
+ }
+ m_lengthNorm[fieldId].reset(new LengthNorm(FdIndexType::INT32));
+ m_lengthNorm[fieldId]->init(pFieldSchema);
+ }
+ }
+}
+
+void LengthNormWriter::addField(docid_t docId, const AnalyzedField* pField)
+{
+ fieldid_t fieldId = pField->getId();
+ FIRTEX_ASSERT2(m_lengthNorm[fieldId]);
+
+ const AnalyzedField::TokenView* pTokenView = pField->getTokenView();
+
+ int32_t length = (pTokenView == NULL) ? 1 :
+ (int32_t)pTokenView->getNumTokens();
+ int32_t norm = LengthNormEncoder::encode(length, pField->getBoost());
+
+ FIRTEX_ASSERT2(docId >= (docid_t)m_lengthNorm[fieldId]->size());
+ m_lengthNorm[fieldId]->setValue(docId, norm);
+}
+
+void LengthNormWriter::commitBarrel(const std::string& sSuffix)
+{
+ for (fieldid_t fieldId = 0; fieldId < (fieldid_t)m_lengthNorm.size();
+ fieldId++)
+ {
+ if (m_lengthNorm[fieldId])
+ {
+ m_lengthNorm[fieldId]->commit(m_pFileSys, NORM_FILEEXT, sSuffix);
+ }
+ }
+ m_lengthNorm.clear();
+}
+
+LengthNormIteratorPtr LengthNormWriter::iterator(fieldid_t fieldId) const
+{
+ if (fieldId > 0 && fieldId < (fieldid_t)m_lengthNorm.size())
+ {
+ ForwardIndexIteratorPtr pIt = m_lengthNorm[fieldId]->iterator();
+ LengthNormIteratorPtr pNormIt = std::dynamic_pointer_cast(pIt);
+ if (!pNormIt)
+ {
+ FIRTEX_THROW(CastException, "Invalid length norm iterator for field: [%d]",
+ fieldId);
+ }
+ }
+ return LengthNormIteratorPtr();
+}
+
+FX_NS_END
+
diff --git a/pool/shard010/C++/0111182_GSGrid_Residuals.cpp b/pool/shard010/C++/0111182_GSGrid_Residuals.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ab2ff5ef50c5f549cca40f5996258c6faf0f5fa6
--- /dev/null
+++ b/pool/shard010/C++/0111182_GSGrid_Residuals.cpp
@@ -0,0 +1,230 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Grid //
+// //
+//-------------------------------------------------------//
+// //
+// GSGrid_Residuals.cpp //
+// //
+// Copyright (C) 2003 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad@saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "GSGrid_Residuals.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGSGrid_Residuals::CGSGrid_Residuals(void)
+{
+ //-----------------------------------------------------
+ // 1. Info...
+
+ Set_Name (_TL("Residual Analysis (Grid)"));
+
+ Set_Author (SG_T("O.Conrad (c) 2003"));
+
+ Set_Description (_TW("Relations of each grid cell to its neighborhood. "
+ "Wilson & Gallant (2000) used this type of calculation in terrain analysis.\n"
+ "\n"
+ "Reference:\n"
+ "- Wilson, J.P., Gallant, J.C., [Eds.] (2000): "
+ "'Terrain analysis - principles and applications', "
+ "New York, John Wiley & Sons, Inc.\n"
+ ));
+
+
+ //-----------------------------------------------------
+ // 2. Parameters...
+
+ Parameters.Add_Grid( NULL, "GRID" , _TL("Grid") , _TL(""), PARAMETER_INPUT);
+
+ Parameters.Add_Grid( NULL, "MEAN" , _TL("Mean Value") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "DIFF" , _TL("Difference from Mean Value") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "STDDEV" , _TL("Standard Deviation") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "RANGE" , _TL("Value Range") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "MIN" , _TL("Minimum Value") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "MAX" , _TL("Maximum Value") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "DEVMEAN" , _TL("Deviation from Mean Value") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "PERCENT" , _TL("Percentile") , _TL(""), PARAMETER_OUTPUT);
+
+ Parameters.Add_Value( NULL, "RADIUS" , _TL("Radius (Cells)") , _TL(""), PARAMETER_TYPE_Int, 7, 1, true);
+
+ Parameters.Add_Parameters(
+ NULL, "WEIGHTING" , _TL("Weighting"),
+ _TL("")
+ )->asParameters()->Assign(m_Cells.Get_Weighting().Get_Parameters());
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGSGrid_Residuals::On_Execute(void)
+{
+ m_pGrid = Parameters("GRID") ->asGrid();
+
+ m_pMean = Parameters("MEAN") ->asGrid();
+ m_pDiff = Parameters("DIFF") ->asGrid();
+ m_pStdDev = Parameters("STDDEV") ->asGrid();
+ m_pRange = Parameters("RANGE") ->asGrid();
+ m_pMin = Parameters("MIN") ->asGrid();
+ m_pMax = Parameters("MAX") ->asGrid();
+ m_pDevMean = Parameters("DEVMEAN") ->asGrid();
+ m_pPercent = Parameters("PERCENT") ->asGrid();
+
+ DataObject_Set_Colors(m_pDiff , 100, SG_COLORS_RED_GREY_BLUE, true);
+ DataObject_Set_Colors(m_pStdDev , 100, SG_COLORS_RED_GREY_BLUE, true);
+ DataObject_Set_Colors(m_pRange , 100, SG_COLORS_RED_GREY_BLUE, true);
+ DataObject_Set_Colors(m_pMin , 100, SG_COLORS_RED_GREY_BLUE, true);
+ DataObject_Set_Colors(m_pMax , 100, SG_COLORS_RED_GREY_BLUE, true);
+ DataObject_Set_Colors(m_pDevMean, 100, SG_COLORS_RED_GREY_BLUE, true);
+ DataObject_Set_Colors(m_pPercent, 100, SG_COLORS_RED_GREY_BLUE, true);
+
+ //-----------------------------------------------------
+ m_Cells.Get_Weighting().Set_Parameters(Parameters("WEIGHTING")->asParameters());
+
+ if( !m_Cells.Set_Radius(Parameters("RADIUS")->asInt()) )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ for(int y=0; yis_InGrid(x, y) )
+ {
+ int i, ix, iy, nLower;
+ double z, iz, id, iw;
+
+ CSG_Simple_Statistics Statistics;
+
+ for(i=0, nLower=0, z=m_pGrid->asDouble(x, y); i 0.0 && m_pGrid->is_InGrid(ix, iy) )
+ {
+ Statistics.Add_Value(iz = m_pGrid->asDouble(ix, iy), iw);
+
+ if( z > iz )
+ {
+ nLower++;
+ }
+ }
+ }
+
+ //-------------------------------------------------
+ if( Statistics.Get_Weights() > 0.0 )
+ {
+ m_pMean ->Set_Value(x, y, Statistics.Get_Mean());
+ m_pDiff ->Set_Value(x, y, z - Statistics.Get_Mean());
+ m_pStdDev ->Set_Value(x, y, Statistics.Get_StdDev());
+ m_pRange ->Set_Value(x, y, Statistics.Get_Range());
+ m_pMin ->Set_Value(x, y, Statistics.Get_Minimum());
+ m_pMax ->Set_Value(x, y, Statistics.Get_Maximum());
+ m_pDevMean ->Set_Value(x, y, Statistics.Get_StdDev() > 0.0 ? ((z - Statistics.Get_Mean()) / Statistics.Get_StdDev()) : 0.0);
+ m_pPercent ->Set_Value(x, y, 100.0 * nLower / (double)Statistics.Get_Count());
+
+ return( true );
+ }
+ }
+
+ //-----------------------------------------------------
+ m_pMean ->Set_NoData(x, y);
+ m_pDiff ->Set_NoData(x, y);
+ m_pStdDev ->Set_NoData(x, y);
+ m_pRange ->Set_NoData(x, y);
+ m_pMin ->Set_NoData(x, y);
+ m_pMax ->Set_NoData(x, y);
+ m_pDevMean ->Set_NoData(x, y);
+ m_pPercent ->Set_NoData(x, y);
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/pool/shard010/C++/0111185_get_reference_vreg_jni.cc b/pool/shard010/C++/0111185_get_reference_vreg_jni.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8108c97f7712a0aa7ba47fa3ff7d146c3b0809b0
--- /dev/null
+++ b/pool/shard010/C++/0111185_get_reference_vreg_jni.cc
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * 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 "arch/context.h"
+#include "art_method-inl.h"
+#include "jni.h"
+#include "scoped_thread_state_change.h"
+#include "stack.h"
+#include "thread.h"
+
+namespace art {
+
+namespace {
+
+class TestVisitor : public StackVisitor {
+ public:
+ TestVisitor(Thread* thread, Context* context, mirror::Object* this_value)
+ SHARED_REQUIRES(Locks::mutator_lock_)
+ : StackVisitor(thread, context, StackVisitor::StackWalkKind::kIncludeInlinedFrames),
+ this_value_(this_value),
+ found_method_index_(0) {}
+
+ bool VisitFrame() SHARED_REQUIRES(Locks::mutator_lock_) {
+ ArtMethod* m = GetMethod();
+ std::string m_name(m->GetName());
+
+ if (m_name.compare("testThisWithInstanceCall") == 0) {
+ found_method_index_ = 1;
+ uint32_t value = 0;
+ CHECK(GetVReg(m, 1, kReferenceVReg, &value));
+ CHECK_EQ(reinterpret_cast(value), this_value_);
+ CHECK_EQ(GetThisObject(), this_value_);
+ } else if (m_name.compare("testThisWithStaticCall") == 0) {
+ found_method_index_ = 2;
+ uint32_t value = 0;
+ CHECK(GetVReg(m, 1, kReferenceVReg, &value));
+ } else if (m_name.compare("testParameter") == 0) {
+ found_method_index_ = 3;
+ uint32_t value = 0;
+ CHECK(GetVReg(m, 1, kReferenceVReg, &value));
+ } else if (m_name.compare("testObjectInScope") == 0) {
+ found_method_index_ = 4;
+ uint32_t value = 0;
+ CHECK(GetVReg(m, 0, kReferenceVReg, &value));
+ }
+
+ return true;
+ }
+
+ mirror::Object* this_value_;
+
+ // Value returned to Java to ensure the methods testSimpleVReg and testPairVReg
+ // have been found and tested.
+ jint found_method_index_;
+};
+
+extern "C" JNIEXPORT jint JNICALL Java_Main_doNativeCallRef(JNIEnv*, jobject value) {
+ ScopedObjectAccess soa(Thread::Current());
+ std::unique_ptr context(Context::Create());
+ TestVisitor visitor(soa.Self(), context.get(), soa.Decode(value));
+ visitor.WalkStack();
+ return visitor.found_method_index_;
+}
+
+extern "C" JNIEXPORT jint JNICALL Java_Main_doStaticNativeCallRef(JNIEnv*, jclass) {
+ ScopedObjectAccess soa(Thread::Current());
+ std::unique_ptr context(Context::Create());
+ TestVisitor visitor(soa.Self(), context.get(), nullptr);
+ visitor.WalkStack();
+ return visitor.found_method_index_;
+}
+
+} // namespace
+
+} // namespace art
diff --git a/pool/shard010/C++/0111194_editaddressdialog.cpp b/pool/shard010/C++/0111194_editaddressdialog.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b72339abebfc07b15da02320074b24c48eedc45c
--- /dev/null
+++ b/pool/shard010/C++/0111194_editaddressdialog.cpp
@@ -0,0 +1,137 @@
+#include "editaddressdialog.h"
+#include "ui_editaddressdialog.h"
+
+#include "addresstablemodel.h"
+#include "guiutil.h"
+
+#include
+#include
+
+EditAddressDialog::EditAddressDialog(Mode mode, QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::EditAddressDialog), mapper(0), mode(mode), model(0)
+{
+ ui->setupUi(this);
+
+ GUIUtil::setupAddressWidget(ui->addressEdit, this);
+
+ switch(mode)
+ {
+ case NewReceivingAddress:
+ setWindowTitle(tr("New receiving address"));
+ ui->addressEdit->setEnabled(false);
+ break;
+ case NewSendingAddress:
+ setWindowTitle(tr("New sending address"));
+ break;
+ case EditReceivingAddress:
+ setWindowTitle(tr("Edit receiving address"));
+ ui->addressEdit->setEnabled(false);
+ break;
+ case EditSendingAddress:
+ setWindowTitle(tr("Edit sending address"));
+ break;
+ }
+
+ mapper = new QDataWidgetMapper(this);
+ mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
+}
+
+EditAddressDialog::~EditAddressDialog()
+{
+ delete ui;
+}
+
+void EditAddressDialog::setModel(AddressTableModel *model)
+{
+ this->model = model;
+ if(!model)
+ return;
+
+ mapper->setModel(model);
+ mapper->addMapping(ui->labelEdit, AddressTableModel::Label);
+ mapper->addMapping(ui->addressEdit, AddressTableModel::Address);
+}
+
+void EditAddressDialog::loadRow(int row)
+{
+ mapper->setCurrentIndex(row);
+}
+
+bool EditAddressDialog::saveCurrentRow()
+{
+ if(!model)
+ return false;
+
+ switch(mode)
+ {
+ case NewReceivingAddress:
+ case NewSendingAddress:
+ address = model->addRow(
+ mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive,
+ ui->labelEdit->text(),
+ ui->addressEdit->text());
+ break;
+ case EditReceivingAddress:
+ case EditSendingAddress:
+ if(mapper->submit())
+ {
+ address = ui->addressEdit->text();
+ }
+ break;
+ }
+ return !address.isEmpty();
+}
+
+void EditAddressDialog::accept()
+{
+ if(!model)
+ return;
+
+ if(!saveCurrentRow())
+ {
+ switch(model->getEditStatus())
+ {
+ case AddressTableModel::OK:
+ // Failed with unknown reason. Just reject.
+ break;
+ case AddressTableModel::NO_CHANGES:
+ // No changes were made during edit operation. Just reject.
+ break;
+ case AddressTableModel::INVALID_ADDRESS:
+ QMessageBox::warning(this, windowTitle(),
+ tr("The entered address \"%1\" is not a valid Syscoin address.").arg(ui->addressEdit->text()),
+ QMessageBox::Ok, QMessageBox::Ok);
+ break;
+ case AddressTableModel::DUPLICATE_ADDRESS:
+ QMessageBox::warning(this, windowTitle(),
+ tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()),
+ QMessageBox::Ok, QMessageBox::Ok);
+ break;
+ case AddressTableModel::WALLET_UNLOCK_FAILURE:
+ QMessageBox::critical(this, windowTitle(),
+ tr("Could not unlock wallet."),
+ QMessageBox::Ok, QMessageBox::Ok);
+ break;
+ case AddressTableModel::KEY_GENERATION_FAILURE:
+ QMessageBox::critical(this, windowTitle(),
+ tr("New key generation failed."),
+ QMessageBox::Ok, QMessageBox::Ok);
+ break;
+
+ }
+ return;
+ }
+ QDialog::accept();
+}
+
+QString EditAddressDialog::getAddress() const
+{
+ return address;
+}
+
+void EditAddressDialog::setAddress(const QString &address)
+{
+ this->address = address;
+ ui->addressEdit->setText(address);
+}
diff --git a/pool/shard010/C++/0111200_HardwareTimer.cpp b/pool/shard010/C++/0111200_HardwareTimer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4f68ad7248072ddbedf1dfc911d232bb29eb6bcd
--- /dev/null
+++ b/pool/shard010/C++/0111200_HardwareTimer.cpp
@@ -0,0 +1,156 @@
+/******************************************************************************
+ * The MIT License
+ *
+ * Copyright (c) 2010 Bryan Newbold.
+ *
+ * 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
+
+#include
+#include // for noInterrupts(), interrupts()
+#include
+#include // for CYCLES_PER_MICROSECOND
+
+// TODO [0.1.0] Remove deprecated pieces
+
+/*
+ * Evil hack to infer this->dev from timerNum in the HardwareTimer
+ * constructor. See:
+ *
+ * http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.2
+ * http://yosefk.com/c++fqa/function.html#fqa-33.2
+ */
+
+extern "C" {
+ static timer_dev **this_devp;
+ static rcc_clk_id this_id;
+ static void set_this_dev(timer_dev *dev) {
+ if (dev->clk_id == this_id) {
+ *this_devp = dev;
+ }
+ }
+}
+
+/*
+ * HardwareTimer routines
+ */
+
+HardwareTimer::HardwareTimer(uint8 timerNum) {
+ rcc_clk_id timerID = (rcc_clk_id)(RCC_TIMER1 + (timerNum - 1));
+ this->dev = NULL;
+ noInterrupts(); // Hack to ensure we're the only ones using
+ // set_this_dev() and friends. TODO: use a lock.
+ this_id = timerID;
+ this_devp = &this->dev;
+ timer_foreach(set_this_dev);
+ interrupts();
+ ASSERT(this->dev != NULL);
+}
+
+void HardwareTimer::pause(void) {
+ timer_pause(this->dev);
+}
+
+void HardwareTimer::resume(void) {
+ timer_resume(this->dev);
+}
+
+uint32 HardwareTimer::getPrescaleFactor(void) {
+ return timer_get_prescaler(this->dev) + 1;
+}
+
+void HardwareTimer::setPrescaleFactor(uint32 factor) {
+ timer_set_prescaler(this->dev, (uint16)(factor - 1));
+}
+
+uint16 HardwareTimer::getOverflow() {
+ return timer_get_reload(this->dev);
+}
+
+void HardwareTimer::setOverflow(uint16 val) {
+ timer_set_reload(this->dev, val);
+}
+
+uint16 HardwareTimer::getCount(void) {
+ return timer_get_count(this->dev);
+}
+
+void HardwareTimer::setCount(uint16 val) {
+ uint16 ovf = this->getOverflow();
+ timer_set_count(this->dev, min(val, ovf));
+}
+
+#define MAX_RELOAD ((1 << 16) - 1)
+uint16 HardwareTimer::setPeriod(uint32 microseconds) {
+ // Not the best way to handle this edge case?
+ if (!microseconds) {
+ this->setPrescaleFactor(1);
+ this->setOverflow(1);
+ return this->getOverflow();
+ }
+
+ uint32 period_cyc = microseconds * CYCLES_PER_MICROSECOND;
+ uint16 prescaler = (uint16)(period_cyc / MAX_RELOAD + 1);
+ uint16 overflow = (uint16)((period_cyc + (prescaler / 2)) / prescaler);
+ this->setPrescaleFactor(prescaler);
+ this->setOverflow(overflow);
+ return overflow;
+}
+
+void HardwareTimer::setMode(int channel, timer_mode mode) {
+ timer_set_mode(this->dev, (uint8)channel, (timer_mode)mode);
+}
+
+uint16 HardwareTimer::getCompare(int channel) {
+ return timer_get_compare(this->dev, (uint8)channel);
+}
+
+void HardwareTimer::setCompare(int channel, uint16 val) {
+ uint16 ovf = this->getOverflow();
+ timer_set_compare(this->dev, (uint8)channel, min(val, ovf));
+}
+
+void HardwareTimer::attachInterrupt(int channel, voidFuncPtr handler) {
+ timer_attach_interrupt(this->dev, (uint8)channel, handler);
+}
+
+void HardwareTimer::detachInterrupt(int channel) {
+ timer_detach_interrupt(this->dev, (uint8)channel);
+}
+
+void HardwareTimer::refresh(void) {
+ timer_generate_update(this->dev);
+}
+
+/* -- Deprecated predefined instances -------------------------------------- */
+
+HardwareTimer Timer1(1);
+HardwareTimer Timer2(2);
+HardwareTimer Timer3(3);
+HardwareTimer Timer4(4);
+#ifdef STM32_HIGH_DENSITY
+HardwareTimer Timer5(5);
+HardwareTimer Timer6(6);
+HardwareTimer Timer7(7);
+HardwareTimer Timer8(8);
+#endif
diff --git a/pool/shard010/C++/0111202_LinkerObject.cpp b/pool/shard010/C++/0111202_LinkerObject.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8b7d9e06a1920f948b859c26aed35dbd9252b13a
--- /dev/null
+++ b/pool/shard010/C++/0111202_LinkerObject.cpp
@@ -0,0 +1,79 @@
+/*
+ This file is part of solidity.
+
+ solidity is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ solidity is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with solidity. If not, see .
+*/
+/** @file LinkerObject.cpp
+ * @author Christian R
+ * @date 2015
+ */
+
+#include
+#include
+
+using namespace dev;
+using namespace dev::eth;
+using namespace std;
+
+void LinkerObject::append(LinkerObject const& _other)
+{
+ for (auto const& ref: _other.linkReferences)
+ linkReferences[ref.first + bytecode.size()] = ref.second;
+ bytecode += _other.bytecode;
+}
+
+void LinkerObject::link(map const& _libraryAddresses)
+{
+ std::map remainingRefs;
+ for (auto const& linkRef: linkReferences)
+ if (h160 const* address = matchLibrary(linkRef.second, _libraryAddresses))
+ copy(address->data(), address->data() + 20, bytecode.begin() + linkRef.first);
+ else
+ remainingRefs.insert(linkRef);
+ linkReferences.swap(remainingRefs);
+}
+
+string LinkerObject::toHex() const
+{
+ string hex = dev::toHex(bytecode);
+ for (auto const& ref: linkReferences)
+ {
+ size_t pos = ref.first * 2;
+ string const& name = ref.second;
+ hex[pos] = hex[pos + 1] = hex[pos + 38] = hex[pos + 39] = '_';
+ for (size_t i = 0; i < 36; ++i)
+ hex[pos + 2 + i] = i < name.size() ? name[i] : '_';
+ }
+ return hex;
+}
+
+h160 const*
+LinkerObject::matchLibrary(
+ string const& _linkRefName,
+ map const& _libraryAddresses
+)
+{
+ auto it = _libraryAddresses.find(_linkRefName);
+ if (it != _libraryAddresses.end())
+ return &it->second;
+ // If the user did not supply a fully qualified library name,
+ // try to match only the simple libary name
+ size_t colon = _linkRefName.find(':');
+ if (colon == string::npos)
+ return nullptr;
+ it = _libraryAddresses.find(_linkRefName.substr(colon + 1));
+ if (it != _libraryAddresses.end())
+ return &it->second;
+ return nullptr;
+}
diff --git a/pool/shard010/C++/0111204_VRMarker.cpp b/pool/shard010/C++/0111204_VRMarker.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..41cb21ff7d7a603596cdab4f593124c0160e7663
--- /dev/null
+++ b/pool/shard010/C++/0111204_VRMarker.cpp
@@ -0,0 +1,55 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "modules/vr/VRMarker.h"
+
+namespace blink {
+
+VRMarker::VRMarker(): m_type(0), m_id(0)
+{
+ m_position = DOMFloat32Array::create(3);
+ m_orientation = DOMFloat32Array::create(4);
+}
+
+unsigned VRMarker::type() const
+{
+ return m_type;
+}
+
+unsigned VRMarker::id() const
+{
+ return m_id;
+}
+
+String VRMarker::content() const
+{
+ return m_content;
+}
+
+DOMFloat32Array* VRMarker::position() const
+{
+ return m_position;
+}
+
+DOMFloat32Array* VRMarker::orientation() const
+{
+ return m_orientation;
+}
+
+void VRMarker::setMarker(const device::mojom::blink::VRMarkerPtr& markerPtr)
+{
+ m_type = markerPtr->type;
+ m_id = markerPtr->id;
+ m_content = markerPtr->content;
+ memcpy(m_position->data(), &(markerPtr->position.front()), 3 * sizeof(float));
+ memcpy(m_orientation->data(), &(markerPtr->orientation.front()), 4 * sizeof(float));
+}
+
+DEFINE_TRACE(VRMarker)
+{
+ visitor->trace(m_position);
+ visitor->trace(m_orientation);
+}
+
+} // namespace blink
diff --git a/pool/shard010/C++/0111207_EnhancedPositionClient.cpp b/pool/shard010/C++/0111207_EnhancedPositionClient.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..df377649e235b9afdb713936876f5e057051cd05
--- /dev/null
+++ b/pool/shard010/C++/0111207_EnhancedPositionClient.cpp
@@ -0,0 +1,95 @@
+/* Copyright (C) 2014 Mentor Graphics
+ * Author: Marco Residori(marco_residori@mentor.com)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include
+#include
+#include "log.h"
+
+DLT_DECLARE_CONTEXT(gCtx);
+
+using namespace org::genivi::EnhancedPositionService;
+using namespace org::genivi::EnhancedPositionService::EnhancedPositionServiceTypes;
+
+void getPositionInfoAsyncCallback(const CommonAPI::CallStatus& callStatus, const EnhancedPositionServiceTypes::Timestamp& timestamp, const EnhancedPositionServiceTypes::PositionInfo& posInfo)
+{
+ if (callStatus != CommonAPI::CallStatus::SUCCESS) {
+ LOG_ERROR_MSG(gCtx,"Remote call failed!\n");
+ return;
+ }
+
+ for ( auto it = posInfo.begin(); it != posInfo.end(); ++it ) {
+ if (it->first == PositionInfoKey::LATITUDE)
+ {
+ LOG_INFO(gCtx,"LAT=%lf", it->second.get());
+ }
+ if (it->first == PositionInfoKey::LONGITUDE)
+ {
+ LOG_INFO(gCtx,"LON=%lf", it->second.get());
+ }
+ if (it->first == PositionInfoKey::ALTITUDE)
+ {
+ LOG_INFO(gCtx,"ALT=%lf", it->second.get());
+ }
+ if (it->first == PositionInfoKey::SPEED)
+ {
+ LOG_INFO(gCtx,"SPEED=%lf", it->second.get());
+ }
+ if (it->first == PositionInfoKey::CLIMB)
+ {
+ LOG_INFO(gCtx,"CLIMB=%lf", it->second.get());
+ }
+ if (it->first == PositionInfoKey::HEADING)
+ {
+ LOG_INFO(gCtx,"HEADING=%lf", it->second.get());
+ }
+ }
+}
+
+void positionUpdate(std::shared_ptr proxy, const EnhancedPositionServiceTypes::Bitmask& changedValues)
+{
+ LOG_INFO_MSG(gCtx,"Position Update");
+
+ if(proxy == NULL)
+ {
+ LOG_ERROR_MSG(gCtx,"Null pointer!");
+ return;
+ }
+
+ std::function fcb = getPositionInfoAsyncCallback;
+
+ proxy->GetPositionInfoAsync(changedValues,getPositionInfoAsyncCallback);
+
+}
+
+int main() {
+
+ DLT_REGISTER_APP("ENHC","ENHANCED-POSITION-CLIENT");
+ DLT_REGISTER_CONTEXT(gCtx,"ENHC","Global Context");
+
+ std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::load();
+ std::shared_ptr < CommonAPI::Factory > factory = runtime->createFactory();
+
+ const std::string& serviceAddress = "local:org.genivi.positioning.EnhancedPosition:org.genivi.positioning.EnhancedPosition";
+ std::shared_ptr myProxy = factory->buildProxy(serviceAddress);
+
+ LOG_INFO_MSG(gCtx,"EnhancedPositionClient");
+
+ while (!myProxy->isAvailable()) {
+ usleep(10);
+ }
+
+ myProxy->getPositionUpdateEvent().subscribe([&](const EnhancedPositionServiceTypes::Bitmask& changedValues) {
+ positionUpdate(myProxy, changedValues);
+ });
+
+ while (true) {
+ std::this_thread::sleep_for(std::chrono::seconds(5));
+ }
+
+ return 0;
+}
diff --git a/pool/shard010/C++/0111208_CWE23_Relative_Path_Traversal__wchar_t_listen_socket_fopen_45.cpp b/pool/shard010/C++/0111208_CWE23_Relative_Path_Traversal__wchar_t_listen_socket_fopen_45.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8da124f83238a8cc96740141c91be473ad313b54
--- /dev/null
+++ b/pool/shard010/C++/0111208_CWE23_Relative_Path_Traversal__wchar_t_listen_socket_fopen_45.cpp
@@ -0,0 +1,228 @@
+/* TEMPLATE GENERATED TESTCASE FILE
+Filename: CWE23_Relative_Path_Traversal__wchar_t_listen_socket_fopen_45.cpp
+Label Definition File: CWE23_Relative_Path_Traversal.label.xml
+Template File: sources-sink-45.tmpl.cpp
+*/
+/*
+ * @description
+ * CWE: 23 Relative Path Traversal
+ * BadSource: listen_socket Read data using a listen socket (server side)
+ * GoodSource: Use a fixed file name
+ * Sinks: fopen
+ * BadSink : Open the file named in data using fopen()
+ * Flow Variant: 45 Data flow: data passed as a static global variable from one function to another in the same source file
+ *
+ * */
+
+#include "std_testcase.h"
+
+#ifdef _WIN32
+#define BASEPATH L"c:\\temp\\"
+#else
+#include
+#define BASEPATH L"/tmp/"
+#endif
+
+#ifdef _WIN32
+#include
+#include
+#include
+#pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
+#define CLOSE_SOCKET closesocket
+#else
+#include
+#include
+#include
+#include
+#include
+#define INVALID_SOCKET -1
+#define SOCKET_ERROR -1
+#define CLOSE_SOCKET close
+#define SOCKET int
+#endif
+
+#define TCP_PORT 27015
+#define LISTEN_BACKLOG 5
+
+#ifdef _WIN32
+#define FOPEN _wfopen
+#else
+#define FOPEN fopen
+#endif
+
+namespace CWE23_Relative_Path_Traversal__wchar_t_listen_socket_fopen_45
+{
+
+static wchar_t * badData;
+static wchar_t * goodG2BData;
+
+#ifndef OMITBAD
+
+static void badSink()
+{
+ wchar_t * data = badData;
+ {
+ FILE *pFile = NULL;
+ /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
+ pFile = FOPEN(data, L"wb+");
+ if (pFile != NULL)
+ {
+ fclose(pFile);
+ }
+ }
+}
+
+void bad()
+{
+ wchar_t * data;
+ wchar_t dataBuffer[FILENAME_MAX] = BASEPATH;
+ data = dataBuffer;
+ {
+#ifdef _WIN32
+ WSADATA wsaData;
+ int wsaDataInit = 0;
+#endif
+ int recvResult;
+ struct sockaddr_in service;
+ wchar_t *replace;
+ SOCKET listenSocket = INVALID_SOCKET;
+ SOCKET acceptSocket = INVALID_SOCKET;
+ size_t dataLen = wcslen(data);
+ do
+ {
+#ifdef _WIN32
+ if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR)
+ {
+ break;
+ }
+ wsaDataInit = 1;
+#endif
+ /* POTENTIAL FLAW: Read data using a listen socket */
+ listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (listenSocket == INVALID_SOCKET)
+ {
+ break;
+ }
+ memset(&service, 0, sizeof(service));
+ service.sin_family = AF_INET;
+ service.sin_addr.s_addr = INADDR_ANY;
+ service.sin_port = htons(TCP_PORT);
+ if (bind(listenSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR)
+ {
+ break;
+ }
+ if (listen(listenSocket, LISTEN_BACKLOG) == SOCKET_ERROR)
+ {
+ break;
+ }
+ acceptSocket = accept(listenSocket, NULL, NULL);
+ if (acceptSocket == SOCKET_ERROR)
+ {
+ break;
+ }
+ /* Abort on error or the connection was closed */
+ recvResult = recv(acceptSocket, (char *)(data + dataLen), sizeof(wchar_t) * (FILENAME_MAX - dataLen - 1), 0);
+ if (recvResult == SOCKET_ERROR || recvResult == 0)
+ {
+ break;
+ }
+ /* Append null terminator */
+ data[dataLen + recvResult / sizeof(wchar_t)] = L'\0';
+ /* Eliminate CRLF */
+ replace = wcschr(data, L'\r');
+ if (replace)
+ {
+ *replace = L'\0';
+ }
+ replace = wcschr(data, L'\n');
+ if (replace)
+ {
+ *replace = L'\0';
+ }
+ }
+ while (0);
+ if (listenSocket != INVALID_SOCKET)
+ {
+ CLOSE_SOCKET(listenSocket);
+ }
+ if (acceptSocket != INVALID_SOCKET)
+ {
+ CLOSE_SOCKET(acceptSocket);
+ }
+#ifdef _WIN32
+ if (wsaDataInit)
+ {
+ WSACleanup();
+ }
+#endif
+ }
+ badData = data;
+ badSink();
+}
+
+#endif /* OMITBAD */
+
+#ifndef OMITGOOD
+
+/* goodG2B() uses the GoodSource with the BadSink */
+static void goodG2BSink()
+{
+ wchar_t * data = goodG2BData;
+ {
+ FILE *pFile = NULL;
+ /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
+ pFile = FOPEN(data, L"wb+");
+ if (pFile != NULL)
+ {
+ fclose(pFile);
+ }
+ }
+}
+
+static void goodG2B()
+{
+ wchar_t * data;
+ wchar_t dataBuffer[FILENAME_MAX] = BASEPATH;
+ data = dataBuffer;
+ /* FIX: Use a fixed file name */
+ wcscat(data, L"file.txt");
+ goodG2BData = data;
+ goodG2BSink();
+}
+
+void good()
+{
+ goodG2B();
+}
+
+#endif /* OMITGOOD */
+
+} /* close namespace */
+
+/* Below is the main(). It is only used when building this testcase on
+ its own for testing or for building a binary to use in testing binary
+ analysis tools. It is not used when compiling all the testcases as one
+ application, which is how source code analysis tools are tested. */
+
+#ifdef INCLUDEMAIN
+
+using namespace CWE23_Relative_Path_Traversal__wchar_t_listen_socket_fopen_45; /* so that we can use good and bad easily */
+
+int main(int argc, char * argv[])
+{
+ /* seed randomness */
+ srand( (unsigned)time(NULL) );
+#ifndef OMITGOOD
+ printLine("Calling good()...");
+ good();
+ printLine("Finished good()");
+#endif /* OMITGOOD */
+#ifndef OMITBAD
+ printLine("Calling bad()...");
+ bad();
+ printLine("Finished bad()");
+#endif /* OMITBAD */
+ return 0;
+}
+
+#endif
diff --git a/pool/shard010/C++/0111210_catalog_proxy.cpp b/pool/shard010/C++/0111210_catalog_proxy.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9cc03ddb325dd442e79885db5dd885233b1ad150
--- /dev/null
+++ b/pool/shard010/C++/0111210_catalog_proxy.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// Peloton
+//
+// catalog_proxy.cpp
+//
+// Identification: src/codegen/proxy/catalog_proxy.cpp
+//
+// Copyright (c) 2015-2017, Carnegie Mellon University Database Group
+//
+//===----------------------------------------------------------------------===//
+
+#include "codegen/proxy/catalog_proxy.h"
+
+#include "codegen/proxy/data_table_proxy.h"
+#include "storage/storage_manager.h"
+
+namespace peloton {
+namespace codegen {
+
+//===----------------------------------------------------------------------===//
+// Return the LLVM type that matches the memory layout of our Database class
+//===----------------------------------------------------------------------===//
+llvm::Type* CatalogProxy::GetType(CodeGen& codegen) {
+ static const std::string kCatalogTypeName =
+ "peloton::storage::StorageManager";
+ // Check if the type is already registered in the module, if so return it
+ auto* catalog_type = codegen.LookupTypeByName(kCatalogTypeName);
+ if (catalog_type != nullptr) {
+ return catalog_type;
+ }
+
+ // Right now we don't need to define each individual field of storage::Catalog
+ // since we only invoke functions on the class.
+ static constexpr uint64_t catalog_obj_size =
+ sizeof(storage::StorageManager);
+ /*
+ static constexpr uint64_t catalog_obj_size = sizeof(std::atomic) +
+ sizeof(lookup_dir) +
+ sizeof(std::mutex) +
+ sizeof(std::vector) +
+ sizeof(std::mutex);
+ static_assert(
+ catalog_obj_size == sizeof(catalog::Catalog),
+ "LLVM memory layout of catalog::Catalog doesn't match precompiled"
+ "version. Did you forget to update codegen/catalog_proxy.h?");
+ */
+ auto* byte_arr_type =
+ llvm::ArrayType::get(codegen.Int8Type(), catalog_obj_size);
+ catalog_type = llvm::StructType::create(codegen.GetContext(), {byte_arr_type},
+ kCatalogTypeName);
+ return catalog_type;
+}
+
+//===----------------------------------------------------------------------===//
+// Return the symbol of the Catalog::GetTableWithOid() function
+//===----------------------------------------------------------------------===//
+const std::string& CatalogProxy::_GetTableWithOid::GetFunctionName() {
+ static const std::string kGetTableByIdFnName =
+#ifdef __APPLE__
+ "_ZNK7peloton7storage14StorageManager15GetTableWithOidEjj";
+#else
+ "_ZNK7peloton7storage14StorageManager15GetTableWithOidEjj";
+#endif
+ return kGetTableByIdFnName;
+}
+
+//===----------------------------------------------------------------------===//
+// Return the LLVM function definition for Catalog::GetTableWithOid()
+//===----------------------------------------------------------------------===//
+llvm::Function* CatalogProxy::_GetTableWithOid::GetFunction(CodeGen& codegen) {
+ const std::string& fn_name = GetFunctionName();
+
+ // Has the function already been registered?
+ llvm::Function* llvm_fn = codegen.LookupFunction(fn_name);
+ if (llvm_fn != nullptr) {
+ return llvm_fn;
+ }
+
+ // The function hasn't been registered, let's do it now
+ llvm::Type* catalog_type = CatalogProxy::GetType(codegen);
+ llvm::Type* table_type = DataTableProxy::GetType(codegen);
+ std::vector fn_args{catalog_type->getPointerTo(),
+ codegen.Int32Type(), // database id
+ codegen.Int32Type()}; // table id
+ llvm::FunctionType* fn_type =
+ llvm::FunctionType::get(table_type->getPointerTo(), fn_args, false);
+ return codegen.RegisterFunction(fn_name, fn_type);
+}
+
+} // namespace codegen
+} // namespace peloton
diff --git a/pool/shard010/C++/0111212_helpers.cpp b/pool/shard010/C++/0111212_helpers.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7efe642eb629480616c80ebf8946e6c6e2c1eb05
--- /dev/null
+++ b/pool/shard010/C++/0111212_helpers.cpp
@@ -0,0 +1,59 @@
+#include "helpers.h"
+#include // trim()
+#include
+
+/***************************** LOCAL FUNCTIONS *******************************/
+
+/******************************************************************************
+ * http://stackoverflow.com/questions/236129/how-to-split-a-string-in-c
+ ******************************************************************************/
+std::vector& split(const std::string& s, char delim, std::vector& elems)
+{
+ std::stringstream ss(s);
+ std::string item;
+ while (std::getline(ss, item, delim))
+ if (!item.empty()) // don't add ""
+ elems.push_back(item);
+
+ return elems;
+}
+
+/*************************** HELPERS.H FUNCTIONS *****************************/
+
+// use boost for trimming...
+void trim(std::string& str)
+{
+ boost::trim(str);
+}
+
+/******************************************************************************
+ * split()
+ * http://stackoverflow.com/questions/236129/how-to-split-a-string-in-c
+ ******************************************************************************/
+std::vector split(const std::string& s, char delim)
+{
+ std::vector elems;
+ split(s, delim, elems);
+ return elems;
+}
+
+/******************************************************************************
+ * shortName()
+ * - returns the short version of the given filename
+ * - example: "./plugins/hello.so" => "hello"
+ ******************************************************************************/
+std::string shortName(const std::string& filename)
+{
+ std::string result = filename;
+ std::string::size_type pos = result.find_last_of("/") + 1; // strip leading dirs
+ result = result.substr(pos);
+ std::string extension = ".so"; // strip .so extension (if any)
+ pos = result.find(extension);
+ if (pos != std::string::npos)
+ result = result.substr(0, pos);
+ extension = ".dll"; // strip .dll extension (if any)
+ pos = result.find(extension);
+ if (pos != std::string::npos)
+ result = result.substr(0, pos);
+ return result;
+}
diff --git a/pool/shard010/C++/0111214_DWARFDebugArangeSet.cpp b/pool/shard010/C++/0111214_DWARFDebugArangeSet.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b1eb27299efb87ff89601574729059770a7aa801
--- /dev/null
+++ b/pool/shard010/C++/0111214_DWARFDebugArangeSet.cpp
@@ -0,0 +1,274 @@
+//===-- DWARFDebugArangeSet.cpp ---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "DWARFDebugArangeSet.h"
+
+#include
+#include "lldb/Core/Stream.h"
+#include "SymbolFileDWARF.h"
+
+using namespace lldb_private;
+
+DWARFDebugArangeSet::DWARFDebugArangeSet() :
+ m_offset(DW_INVALID_OFFSET),
+ m_header(),
+ m_arange_descriptors()
+{
+ m_header.length = 0;
+ m_header.version = 0;
+ m_header.cu_offset = 0;
+ m_header.addr_size = 0;
+ m_header.seg_size = 0;
+}
+
+void
+DWARFDebugArangeSet::Clear()
+{
+ m_offset = DW_INVALID_OFFSET;
+ m_header.length = 0;
+ m_header.version = 0;
+ m_header.cu_offset = 0;
+ m_header.addr_size = 0;
+ m_header.seg_size = 0;
+ m_arange_descriptors.clear();
+}
+
+void
+DWARFDebugArangeSet::SetHeader
+(
+ uint16_t version,
+ uint32_t cu_offset,
+ uint8_t addr_size,
+ uint8_t seg_size
+)
+{
+ m_header.version = version;
+ m_header.cu_offset = cu_offset;
+ m_header.addr_size = addr_size;
+ m_header.seg_size = seg_size;
+}
+
+void
+DWARFDebugArangeSet::Compact()
+{
+ if (m_arange_descriptors.empty())
+ return;
+
+ // Iterate through all arange descriptors and combine any ranges that
+ // overlap or have matching boundaries. The m_arange_descriptors are assumed
+ // to be in ascending order after being built by adding descriptors
+ // using the AddDescriptor method.
+ uint32_t i = 0;
+ while (i + 1 < m_arange_descriptors.size())
+ {
+ if (m_arange_descriptors[i].end_address() >= m_arange_descriptors[i+1].address)
+ {
+ // The current range ends at or exceeds the start of the next address range.
+ // Compute the max end address between the two and use that to make the new
+ // length.
+ const dw_addr_t max_end_addr = std::max(m_arange_descriptors[i].end_address(), m_arange_descriptors[i+1].end_address());
+ m_arange_descriptors[i].length = max_end_addr - m_arange_descriptors[i].address;
+ // Now remove the next entry as it was just combined with the previous one.
+ m_arange_descriptors.erase(m_arange_descriptors.begin()+i+1);
+ }
+ else
+ {
+ // Discontiguous address range, just proceed to the next one.
+ ++i;
+ }
+ }
+}
+//----------------------------------------------------------------------
+// Compare function DWARFDebugArangeSet::Descriptor structures
+//----------------------------------------------------------------------
+static bool DescriptorLessThan (const DWARFDebugArangeSet::Descriptor& range1, const DWARFDebugArangeSet::Descriptor& range2)
+{
+ return range1.address < range2.address;
+}
+
+//----------------------------------------------------------------------
+// Add a range descriptor and keep things sorted so we can easily
+// compact the ranges before being saved or used.
+//----------------------------------------------------------------------
+void
+DWARFDebugArangeSet::AddDescriptor(const DWARFDebugArangeSet::Descriptor& range)
+{
+ if (m_arange_descriptors.empty())
+ {
+ m_arange_descriptors.push_back(range);
+ return;
+ }
+
+ DescriptorIter end = m_arange_descriptors.end();
+ DescriptorIter pos = lower_bound(m_arange_descriptors.begin(), end, range, DescriptorLessThan);
+ const dw_addr_t range_end_addr = range.end_address();
+ if (pos != end)
+ {
+ const dw_addr_t found_end_addr = pos->end_address();
+ if (range.address < pos->address)
+ {
+ if (range_end_addr < pos->address)
+ {
+ // Non-contiguous entries, add this one before the found entry
+ m_arange_descriptors.insert(pos, range);
+ }
+ else if (range_end_addr == pos->address)
+ {
+ // The top end of 'range' is the lower end of the entry
+ // pointed to by 'pos'. We can combine range with the
+ // entry we found by setting the starting address and
+ // increasing the length since they don't overlap.
+ pos->address = range.address;
+ pos->length += range.length;
+ }
+ else
+ {
+ // We can combine these two and make sure the largest end
+ // address is used to make end address.
+ pos->address = range.address;
+ pos->length = std::max(found_end_addr, range_end_addr) - pos->address;
+ }
+ }
+ else if (range.address == pos->address)
+ {
+ pos->length = std::max(pos->length, range.length);
+ }
+ }
+ else
+ {
+ // NOTE: 'pos' points to entry past the end which is ok for insert,
+ // don't use otherwise!!!
+ const dw_addr_t max_addr = m_arange_descriptors.back().end_address();
+ if (max_addr < range.address)
+ {
+ // Non-contiguous entries, add this one before the found entry
+ m_arange_descriptors.insert(pos, range);
+ }
+ else if (max_addr == range.address)
+ {
+ m_arange_descriptors.back().length += range.length;
+ }
+ else
+ {
+ m_arange_descriptors.back().length = std::max(max_addr, range_end_addr) - m_arange_descriptors.back().address;
+ }
+ }
+}
+
+bool
+DWARFDebugArangeSet::Extract(const DataExtractor &data, lldb::offset_t *offset_ptr)
+{
+ if (data.ValidOffset(*offset_ptr))
+ {
+ m_arange_descriptors.clear();
+ m_offset = *offset_ptr;
+
+ // 7.20 Address Range Table
+ //
+ // Each set of entries in the table of address ranges contained in
+ // the .debug_aranges section begins with a header consisting of: a
+ // 4-byte length containing the length of the set of entries for this
+ // compilation unit, not including the length field itself; a 2-byte
+ // version identifier containing the value 2 for DWARF Version 2; a
+ // 4-byte offset into the.debug_infosection; a 1-byte unsigned integer
+ // containing the size in bytes of an address (or the offset portion of
+ // an address for segmented addressing) on the target system; and a
+ // 1-byte unsigned integer containing the size in bytes of a segment
+ // descriptor on the target system. This header is followed by a series
+ // of tuples. Each tuple consists of an address and a length, each in
+ // the size appropriate for an address on the target architecture.
+ m_header.length = data.GetU32(offset_ptr);
+ m_header.version = data.GetU16(offset_ptr);
+ m_header.cu_offset = data.GetU32(offset_ptr);
+ m_header.addr_size = data.GetU8(offset_ptr);
+ m_header.seg_size = data.GetU8(offset_ptr);
+
+
+ // The first tuple following the header in each set begins at an offset
+ // that is a multiple of the size of a single tuple (that is, twice the
+ // size of an address). The header is padded, if necessary, to the
+ // appropriate boundary.
+ const uint32_t header_size = *offset_ptr - m_offset;
+ const uint32_t tuple_size = m_header.addr_size << 1;
+ uint32_t first_tuple_offset = 0;
+ while (first_tuple_offset < header_size)
+ first_tuple_offset += tuple_size;
+
+ *offset_ptr = m_offset + first_tuple_offset;
+
+ Descriptor arangeDescriptor;
+
+ assert(sizeof(arangeDescriptor.address) == sizeof(arangeDescriptor.length));
+ assert(sizeof(arangeDescriptor.address) >= m_header.addr_size);
+
+ while (data.ValidOffset(*offset_ptr))
+ {
+ arangeDescriptor.address = data.GetMaxU64(offset_ptr, m_header.addr_size);
+ arangeDescriptor.length = data.GetMaxU64(offset_ptr, m_header.addr_size);
+
+ // Each set of tuples is terminated by a 0 for the address and 0
+ // for the length.
+ if (arangeDescriptor.address || arangeDescriptor.length)
+ m_arange_descriptors.push_back(arangeDescriptor);
+ else
+ break; // We are done if we get a zero address and length
+ }
+
+ return !m_arange_descriptors.empty();
+ }
+ return false;
+}
+
+
+dw_offset_t
+DWARFDebugArangeSet::GetOffsetOfNextEntry() const
+{
+ return m_offset + m_header.length + 4;
+}
+
+
+void
+DWARFDebugArangeSet::Dump(Stream *s) const
+{
+ s->Printf("Address Range Header: length = 0x%8.8x, version = 0x%4.4x, cu_offset = 0x%8.8x, addr_size = 0x%2.2x, seg_size = 0x%2.2x\n",
+ m_header.length ,m_header.version, m_header.cu_offset, m_header.addr_size, m_header.seg_size);
+
+ const uint32_t hex_width = m_header.addr_size * 2;
+ DescriptorConstIter pos;
+ DescriptorConstIter end = m_arange_descriptors.end();
+ for (pos = m_arange_descriptors.begin(); pos != end; ++pos)
+ s->Printf("[0x%*.*" PRIx64 " - 0x%*.*" PRIx64 ")\n",
+ hex_width, hex_width, pos->address,
+ hex_width, hex_width, pos->end_address());
+}
+
+
+class DescriptorContainsAddress
+{
+public:
+ DescriptorContainsAddress (dw_addr_t address) : m_address(address) {}
+ bool operator() (const DWARFDebugArangeSet::Descriptor& desc) const
+ {
+ return (m_address >= desc.address) && (m_address < (desc.address + desc.length));
+ }
+ private:
+ const dw_addr_t m_address;
+};
+
+dw_offset_t
+DWARFDebugArangeSet::FindAddress(dw_addr_t address) const
+{
+ DescriptorConstIter end = m_arange_descriptors.end();
+ DescriptorConstIter pos = std::find_if( m_arange_descriptors.begin(), end, // Range
+ DescriptorContainsAddress(address));// Predicate
+ if (pos != end)
+ return m_header.cu_offset;
+
+ return DW_INVALID_OFFSET;
+}
diff --git a/pool/shard010/C++/0111216_lru.cc b/pool/shard010/C++/0111216_lru.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a84e08bdd1d748537278ccb9e428bad0721c0f3c
--- /dev/null
+++ b/pool/shard010/C++/0111216_lru.cc
@@ -0,0 +1,62 @@
+/*
+ * \brief Least-recently-used cache replacement strategy
+ * \author Stefan Kalkowski
+ * \date 2013-12-05
+ */
+
+/*
+ * Copyright (C) 2013 Genode Labs GmbH
+ *
+ * This file is part of the Genode OS framework, which is distributed
+ * under the terms of the GNU General Public License version 2.
+ */
+#include
+#include "lru.h"
+#include "driver.h"
+
+typedef Driver::Chunk_level_4 Chunk;
+
+static const Lru_policy::Element *lru = 0;
+static Genode::List lru_list;
+
+
+static void lru_access(const Lru_policy::Element *e)
+{
+ if (e == lru) return;
+
+ if (e->next()) lru_list.remove(e);
+
+ lru_list.insert(e, lru);
+ lru = e;
+}
+
+
+void Lru_policy::read(const Lru_policy::Element *e) {
+ lru_access(e); }
+
+
+void Lru_policy::write(const Lru_policy::Element *e) {
+ lru_access(e); }
+
+
+void Lru_policy::flush(Cache::size_t size)
+{
+ Cache::size_t s = 0;
+ for (Lru_policy::Element *e = lru_list.first();
+ e && ((size == 0) || (s < size));
+ e = lru_list.first(), s += sizeof(Chunk)) {
+ Chunk *cb = static_cast(e);
+ e = e->next();
+ try {
+ cb->free(Driver::CACHE_BLK_SIZE,
+ cb->base_offset());
+ lru_list.remove(cb);
+ } catch(Chunk::Dirty_chunk &e) {
+ cb->sync(e.size, e.off);
+ }
+ }
+
+ if (!lru_list.first()) lru = 0;
+
+ if (s < size) throw Block::Driver::Request_congestion();
+}
diff --git a/pool/shard010/C++/0111221_mirror_layer_impl.cc b/pool/shard010/C++/0111221_mirror_layer_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..743a80b2f809e61e9babc15ef23bc6a912f1b4df
--- /dev/null
+++ b/pool/shard010/C++/0111221_mirror_layer_impl.cc
@@ -0,0 +1,91 @@
+// 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 "cc/layers/mirror_layer_impl.h"
+
+#include
+
+#include "cc/trees/effect_node.h"
+#include "cc/trees/layer_tree_impl.h"
+#include "cc/trees/occlusion.h"
+#include "components/viz/common/quads/compositor_render_pass_draw_quad.h"
+
+namespace cc {
+
+MirrorLayerImpl::MirrorLayerImpl(LayerTreeImpl* tree_impl, int id)
+ : LayerImpl(tree_impl, id) {}
+
+MirrorLayerImpl::~MirrorLayerImpl() = default;
+
+std::unique_ptr MirrorLayerImpl::CreateLayerImpl(
+ LayerTreeImpl* tree_impl) {
+ return MirrorLayerImpl::Create(tree_impl, id());
+}
+
+void MirrorLayerImpl::AppendQuads(viz::CompositorRenderPass* render_pass,
+ AppendQuadsData* append_quads_data) {
+ // TODO(mohsen): Currently, effects on the mirrored layer (e.g mask and
+ // opacity) are ignored. Consider applying them here.
+
+ auto* mirrored_layer = layer_tree_impl()->LayerById(mirrored_layer_id_);
+ auto* mirrored_render_surface =
+ GetEffectTree().GetRenderSurface(mirrored_layer->effect_tree_index());
+ gfx::Rect content_rect = mirrored_render_surface->content_rect();
+
+ gfx::Rect unoccluded_content_rect =
+ draw_properties().occlusion_in_content_space.GetUnoccludedContentRect(
+ content_rect);
+ if (unoccluded_content_rect.IsEmpty())
+ return;
+
+ const bool contents_opaque = false;
+ viz::SharedQuadState* shared_quad_state =
+ render_pass->CreateAndAppendSharedQuadState();
+ // TODO(crbug.com/1196414): Support 2D scales in mirror layers.
+ PopulateScaledSharedQuadStateWithContentRects(
+ shared_quad_state, mirrored_layer->GetIdealContentsScaleKey(),
+ content_rect, content_rect, contents_opaque);
+
+ AppendDebugBorderQuad(render_pass, content_rect, shared_quad_state,
+ append_quads_data);
+
+ viz::ResourceId mask_resource_id = viz::kInvalidResourceId;
+ gfx::RectF mask_uv_rect;
+ gfx::Size mask_texture_size;
+
+ auto* mirrored_effect_node = mirrored_render_surface->OwningEffectNode();
+ auto* quad =
+ render_pass->CreateAndAppendDrawQuad();
+ quad->SetNew(shared_quad_state, content_rect, unoccluded_content_rect,
+ mirrored_layer_render_pass_id(), mask_resource_id, mask_uv_rect,
+ mask_texture_size, mirrored_effect_node->surface_contents_scale,
+ gfx::PointF(), gfx::RectF(gfx::Rect(content_rect.size())),
+ !layer_tree_impl()->settings().enable_edge_anti_aliasing, 0.f);
+}
+
+void MirrorLayerImpl::PushPropertiesTo(LayerImpl* layer) {
+ LayerImpl::PushPropertiesTo(layer);
+
+ auto* mirror_layer = static_cast(layer);
+ mirror_layer->SetMirroredLayerId(mirrored_layer_id_);
+}
+
+gfx::Rect MirrorLayerImpl::GetDamageRect() const {
+ // TOOD(mohsen): Currently, the whole layer is marked as damaged. We should
+ // only consider the damage from the mirrored layer.
+ return gfx::Rect(bounds());
+}
+
+gfx::Rect MirrorLayerImpl::GetEnclosingVisibleRectInTargetSpace() const {
+ const LayerImpl* mirrored_layer =
+ layer_tree_impl()->LayerById(mirrored_layer_id_);
+ return GetScaledEnclosingVisibleRectInTargetSpace(
+ mirrored_layer->GetIdealContentsScaleKey());
+}
+
+const char* MirrorLayerImpl::LayerTypeAsString() const {
+ return "cc::MirrorLayerImpl";
+}
+
+} // namespace cc
diff --git a/pool/shard010/C++/0111222_switch.cc b/pool/shard010/C++/0111222_switch.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bb8c9856742963b73f2f03ed21e59624611b65d7
--- /dev/null
+++ b/pool/shard010/C++/0111222_switch.cc
@@ -0,0 +1,217 @@
+ /*// us file is part of NOX.
+ *
+ * NOX is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * NOX is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with NOX. If not, see .
+ */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "openflow-default.hh"
+#include "assert.hh"
+#include "component.hh"
+#include "flow.hh"
+#include "fnv_hash.hh"
+#include "hash_set.hh"
+#include "ofp-msg-event.hh"
+#include "vlog.hh"
+#include "flowmod.hh"
+#include "datapath-join.hh"
+#include
+
+#include
+#include "netinet++/ethernetaddr.hh"
+#include "netinet++/ethernet.hh"
+
+#include "../../../oflib/ofl-actions.h"
+#include "../../../oflib/ofl-messages.h"
+
+using namespace vigil;
+using namespace vigil::container;
+using namespace std;
+
+namespace {
+
+struct Mac_source
+{
+ /* Key. */
+ datapathid datapath_id; /* Switch. */
+ ethernetaddr mac; /* Source MAC. */
+
+ /* Value. */
+ mutable int port; /* Port where packets from 'mac' were seen. */
+
+ Mac_source() : port(-1) { }
+ Mac_source(datapathid datapath_id_, ethernetaddr mac_)
+ : datapath_id(datapath_id_), mac(mac_), port(-1)
+ { }
+};
+
+bool operator==(const Mac_source& a, const Mac_source& b)
+{
+ return a.datapath_id == b.datapath_id && a.mac == b.mac;
+}
+
+bool operator!=(const Mac_source& a, const Mac_source& b)
+{
+ return !(a == b);
+}
+
+struct Hash_mac_source
+{
+ std::size_t operator()(const Mac_source& val) const {
+ uint32_t x;
+ x = vigil::fnv_hash(&val.datapath_id, sizeof val.datapath_id);
+ x = vigil::fnv_hash(val.mac.octet, sizeof val.mac.octet, x);
+ return x;
+ }
+};
+
+Vlog_module log("switch");
+
+class Switch
+ : public Component
+{
+public:
+ Switch(const Context* c,
+ const json_object*)
+ : Component(c) { }
+
+ void configure(const Configuration*);
+
+ void install();
+
+ Disposition handle(const Event&);
+ //Disposition handle_dp_join(const Event& e);
+private:
+ typedef hash_set Source_table;
+ Source_table sources;
+
+ /* Set up a flow when we know the destination of a packet? This should
+ * ordinarily be true; it is only usefully false for debugging purposes. */
+ bool setup_flows;
+};
+
+void
+Switch::configure(const Configuration* conf) {
+ setup_flows = true; // default value
+ BOOST_FOREACH (const std::string& arg, conf->get_arguments()) {
+ if (arg == "noflow") {
+ setup_flows = false;
+ } else {
+ VLOG_WARN(log, "argument \"%s\" not supported", arg.c_str());
+ }
+ }
+
+ register_handler(Ofp_msg_event::get_name(OFPT_PACKET_IN), boost::bind(&Switch::handle, this, _1));
+
+}
+
+void
+Switch::install() {
+
+}
+
+Disposition
+Switch::handle(const Event& e)
+{
+ const Ofp_msg_event& pi = assert_cast(e);
+
+ struct ofl_msg_packet_in *in = (struct ofl_msg_packet_in *)**pi.msg;
+ Flow *flow = new Flow((struct ofl_match*) in->match);
+
+ /* drop all LLDP packets */
+ uint16_t dl_type;
+ flow->get_Field("eth_type",&dl_type);
+ if (dl_type == ethernet::LLDP){
+ return CONTINUE;
+ }
+
+ uint32_t in_port;
+ flow->get_Field("in_port", &in_port);
+
+
+ /* Learn the source. */
+ uint8_t eth_src[6];
+ flow->get_Field("eth_src", eth_src);
+ ethernetaddr dl_src(eth_src);
+ if (!dl_src.is_multicast()) {
+ Mac_source src(pi.dpid, dl_src);
+ Source_table::iterator i = sources.insert(src).first;
+
+ if (i->port != in_port) {
+ i->port = in_port;
+ VLOG_DBG(log, "learned that "EA_FMT" is on datapath %s port %d",
+ EA_ARGS(&dl_src), pi.dpid.string().c_str(),
+ (int) in_port);
+ }
+ } else {
+ VLOG_DBG(log, "multicast packet source "EA_FMT, EA_ARGS(&dl_src));
+ }
+
+ /* Figure out the destination. */
+ int out_port = -1; /* Flood by default. */
+ uint8_t eth_dst[6];
+ flow->get_Field("eth_dst", eth_dst);
+ ethernetaddr dl_dst(eth_dst);
+ if (!dl_dst.is_multicast()) {
+ Mac_source dst(pi.dpid, dl_dst);
+ Source_table::iterator i(sources.find(dst));
+ if (i != sources.end()) {
+ out_port = i->port;
+ }
+ }
+
+ /* Set up a flow if the output port is known. */
+ if (setup_flows && out_port != -1) {
+
+
+ Flow f;
+ f.Add_Field("in_port", in_port);
+ f.Add_Field("eth_src", eth_src);
+ f.Add_Field("eth_dst",eth_dst);
+ Actions *acts = new Actions();
+ acts->CreateOutput(out_port);
+ Instruction *inst = new Instruction();
+ inst->CreateApply(acts);
+ FlowMod *mod = new FlowMod(0x00ULL,0x00ULL, 0,OFPFC_ADD, 1, OFP_FLOW_PERMANENT, OFP_DEFAULT_PRIORITY,in->buffer_id,
+ OFPP_ANY, OFPG_ANY, ofd_flow_mod_flags());
+ mod->AddMatch(&f.match);
+ mod->AddInstructions(inst);
+ send_openflow_msg(pi.dpid, (struct ofl_msg_header *)&mod->fm_msg, 0/*xid*/, true/*block*/);
+ }
+ /* Send out packet if necessary. */
+ if (!setup_flows || out_port == -1 || in->buffer_id == UINT32_MAX) {
+ if (in->buffer_id == UINT32_MAX) {
+ if (in->total_len != in->data_length) {
+ /* Control path didn't buffer the packet and didn't send us
+ * the whole thing--what gives? */
+ VLOG_DBG(log, "total_len=%"PRIu16" data_len=%zu\n",
+ in->total_len, in->data_length);
+ return CONTINUE;
+ }
+ send_openflow_pkt(pi.dpid, Nonowning_buffer(in->data, in->data_length), in_port, out_port == -1 ? OFPP_FLOOD : out_port, true/*block*/);
+ } else {
+ send_openflow_pkt(pi.dpid, in->buffer_id, in_port, out_port == -1 ? OFPP_FLOOD : out_port, true/*block*/);
+ }
+ }
+ return CONTINUE;
+}
+
+REGISTER_COMPONENT(container::Simple_component_factory, Switch);
+
+} // unnamed namespacennamed namespace
diff --git a/pool/shard010/C++/0111225_bitcoind.cpp b/pool/shard010/C++/0111225_bitcoind.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..69479e14a7325ed2a9a2004254b2e967d14e2a95
--- /dev/null
+++ b/pool/shard010/C++/0111225_bitcoind.cpp
@@ -0,0 +1,141 @@
+// Copyright (c) 2009-2010 Satoshi Nakamoto
+// Copyright (c) 2009-2012 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 "init.h"
+#include "bitcoinrpc.h"
+#include
+
+void DetectShutdownThread(boost::thread_group* threadGroup)
+{
+ bool shutdown = ShutdownRequested();
+ // Tell the main threads to shutdown.
+ while (!shutdown)
+ {
+ MilliSleep(200);
+ shutdown = ShutdownRequested();
+ }
+ if (threadGroup)
+ threadGroup->interrupt_all();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Start
+//
+bool AppInit(int argc, char* argv[])
+{
+ boost::thread_group threadGroup;
+ boost::thread* detectShutdownThread = NULL;
+
+ bool fRet = false;
+ try
+ {
+ //
+ // Parameters
+ //
+ // If Qt is used, parameters/fireflycoin.conf are parsed in qt/bitcoin.cpp's main()
+ ParseParameters(argc, argv);
+ if (!boost::filesystem::is_directory(GetDataDir(false)))
+ {
+ fprintf(stderr, "Error: Specified directory does not exist\n");
+ Shutdown();
+ }
+ ReadConfigFile(mapArgs, mapMultiArgs);
+
+ if (mapArgs.count("-?") || mapArgs.count("--help"))
+ {
+ // First part of help message is specific to fireflycoind / RPC client
+ std::string strUsage = _("FireFlyCoin version") + " " + FormatFullVersion() + "\n\n" +
+ _("Usage:") + "\n" +
+ " fireflycoind [options] " + "\n" +
+ " fireflycoind [options] [params] " + _("Send command to -server or fireflycoind") + "\n" +
+ " fireflycoind [options] help " + _("List commands") + "\n" +
+ " fireflycoind [options] help " + _("Get help for a command") + "\n";
+
+ strUsage += "\n" + HelpMessage();
+
+ fprintf(stdout, "%s", strUsage.c_str());
+ return false;
+ }
+
+ // Command-line RPC
+ for (int i = 1; i < argc; i++)
+ if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "fireflycoin:"))
+ fCommandLine = true;
+
+ if (fCommandLine)
+ {
+ if (!SelectParamsFromCommandLine()) {
+ fprintf(stderr, "Error: invalid combination of -regtest and -testnet.\n");
+ return false;
+ }
+ int ret = CommandLineRPC(argc, argv);
+ exit(ret);
+ }
+#if !defined(WIN32)
+ fDaemon = GetBoolArg("-daemon", false);
+ if (fDaemon)
+ {
+ // Daemonize
+ pid_t pid = fork();
+ if (pid < 0)
+ {
+ fprintf(stderr, "Error: fork() returned %d errno %d\n", pid, errno);
+ return false;
+ }
+ if (pid > 0) // Parent process, pid is child process id
+ {
+ CreatePidFile(GetPidFile(), pid);
+ return true;
+ }
+ // Child process falls through to rest of initialization
+
+ pid_t sid = setsid();
+ if (sid < 0)
+ fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno);
+ }
+#endif
+
+ detectShutdownThread = new boost::thread(boost::bind(&DetectShutdownThread, &threadGroup));
+ fRet = AppInit2(threadGroup);
+ }
+ catch (std::exception& e) {
+ PrintExceptionContinue(&e, "AppInit()");
+ } catch (...) {
+ PrintExceptionContinue(NULL, "AppInit()");
+ }
+ if (!fRet) {
+ if (detectShutdownThread)
+ detectShutdownThread->interrupt();
+ threadGroup.interrupt_all();
+ }
+
+ if (detectShutdownThread)
+ {
+ detectShutdownThread->join();
+ delete detectShutdownThread;
+ detectShutdownThread = NULL;
+ }
+ Shutdown();
+
+ return fRet;
+}
+
+extern void noui_connect();
+int main(int argc, char* argv[])
+{
+ bool fRet = false;
+ fHaveGUI = false;
+
+ // Connect fireflycoind signal handlers
+ noui_connect();
+
+ fRet = AppInit(argc, argv);
+
+ if (fRet && fDaemon)
+ return 0;
+
+ return (fRet ? 0 : 1);
+}
diff --git a/pool/shard010/C++/0111231_chapter24_ex10.cpp b/pool/shard010/C++/0111231_chapter24_ex10.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d5e5dcb33c0f376304c8c5ae7f80155b39787af4
--- /dev/null
+++ b/pool/shard010/C++/0111231_chapter24_ex10.cpp
@@ -0,0 +1,48 @@
+// Chapter 24, exercise 10: test rand(); write a program that takes two integers
+// n and d and calls randint(n) d times; output the number of draws for each
+// [0:n) and see if there are any obvious biases
+
+#include
+#include
+#include
+#include
+#include
+ *
+ * Amazon EBS: Amazon EBS product page, Amazon EBS documentation
+ *
+ *
+ *
+ * Amazon VPC: Amazon VPC product page, Amazon VPC documentation
+ *
+ *
+ *
+ * AWS VPN: AWS VPN product page, AWS VPN documentation
+ *
+ * \sa Ec2Client::describeLocalGatewayRouteTables
+ */
+
+/*!
+ * Constructs a DescribeLocalGatewayRouteTablesResponse object for \a reply to \a request, with parent \a parent.
+ */
+DescribeLocalGatewayRouteTablesResponse::DescribeLocalGatewayRouteTablesResponse(
+ const DescribeLocalGatewayRouteTablesRequest &request,
+ QNetworkReply * const reply,
+ QObject * const parent)
+ : Ec2Response(new DescribeLocalGatewayRouteTablesResponsePrivate(this), parent)
+{
+ setRequest(new DescribeLocalGatewayRouteTablesRequest(request));
+ setReply(reply);
+}
+
+/*!
+ * \reimp
+ */
+const DescribeLocalGatewayRouteTablesRequest * DescribeLocalGatewayRouteTablesResponse::request() const
+{
+ Q_D(const DescribeLocalGatewayRouteTablesResponse);
+ return static_cast(d->request);
+}
+
+/*!
+ * \reimp
+ * Parses a successful EC2 DescribeLocalGatewayRouteTables \a response.
+ */
+void DescribeLocalGatewayRouteTablesResponse::parseSuccess(QIODevice &response)
+{
+ //Q_D(DescribeLocalGatewayRouteTablesResponse);
+ QXmlStreamReader xml(&response);
+ /// @todo
+}
+
+/*!
+ * \class QtAws::EC2::DescribeLocalGatewayRouteTablesResponsePrivate
+ * \brief The DescribeLocalGatewayRouteTablesResponsePrivate class provides private implementation for DescribeLocalGatewayRouteTablesResponse.
+ * \internal
+ *
+ * \inmodule QtAwsEC2
+ */
+
+/*!
+ * Constructs a DescribeLocalGatewayRouteTablesResponsePrivate object with public implementation \a q.
+ */
+DescribeLocalGatewayRouteTablesResponsePrivate::DescribeLocalGatewayRouteTablesResponsePrivate(
+ DescribeLocalGatewayRouteTablesResponse * const q) : Ec2ResponsePrivate(q)
+{
+
+}
+
+/*!
+ * Parses a EC2 DescribeLocalGatewayRouteTables response element from \a xml.
+ */
+void DescribeLocalGatewayRouteTablesResponsePrivate::parseDescribeLocalGatewayRouteTablesResponse(QXmlStreamReader &xml)
+{
+ Q_ASSERT(xml.name() == QLatin1String("DescribeLocalGatewayRouteTablesResponse"));
+ Q_UNUSED(xml) ///< @todo
+}
+
+} // namespace EC2
+} // namespace QtAws
diff --git a/pool/shard010/C++/0111259_decode_svc_test.cc b/pool/shard010/C++/0111259_decode_svc_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ec9935da795eadf8240bd97015124d8c8e5f9d08
--- /dev/null
+++ b/pool/shard010/C++/0111259_decode_svc_test.cc
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2016 The WebM project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include
+#include
+
+#include "test/codec_factory.h"
+#include "test/decode_test_driver.h"
+#include "test/ivf_video_source.h"
+#include "test/test_vectors.h"
+#include "test/util.h"
+
+namespace {
+
+const unsigned int kNumFrames = 19;
+
+class DecodeSvcTest : public ::libvpx_test::DecoderTest,
+ public ::libvpx_test::CodecTestWithParam {
+ protected:
+ DecodeSvcTest() : DecoderTest(GET_PARAM(::libvpx_test::kCodecFactoryParam)) {}
+ virtual ~DecodeSvcTest() {}
+
+ virtual void PreDecodeFrameHook(
+ const libvpx_test::CompressedVideoSource &video,
+ libvpx_test::Decoder *decoder) {
+ if (video.frame_number() == 0)
+ decoder->Control(VP9_DECODE_SVC_SPATIAL_LAYER, spatial_layer_);
+ }
+
+ virtual void DecompressedFrameHook(const vpx_image_t &img,
+ const unsigned int frame_number) {
+ ASSERT_EQ(img.d_w, width_);
+ ASSERT_EQ(img.d_h, height_);
+ total_frames_ = frame_number;
+ }
+
+ int spatial_layer_;
+ unsigned int width_;
+ unsigned int height_;
+ unsigned int total_frames_;
+};
+
+// SVC test vector is 1280x720, with 3 spatial layers, and 20 frames.
+
+// Decode the SVC test vector, which has 3 spatial layers, and decode up to
+// spatial layer 0. Verify the resolution of each decoded frame and the total
+// number of frames decoded. This results in 1/4x1/4 resolution (320x180).
+TEST_P(DecodeSvcTest, DecodeSvcTestUpToSpatialLayer0) {
+ const std::string filename = GET_PARAM(1);
+ std::unique_ptr video;
+ video.reset(new libvpx_test::IVFVideoSource(filename));
+ ASSERT_NE(video.get(), nullptr);
+ video->Init();
+ total_frames_ = 0;
+ spatial_layer_ = 0;
+ width_ = 320;
+ height_ = 180;
+ ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
+ ASSERT_EQ(total_frames_, kNumFrames);
+}
+
+// Decode the SVC test vector, which has 3 spatial layers, and decode up to
+// spatial layer 1. Verify the resolution of each decoded frame and the total
+// number of frames decoded. This results in 1/2x1/2 resolution (640x360).
+TEST_P(DecodeSvcTest, DecodeSvcTestUpToSpatialLayer1) {
+ const std::string filename = GET_PARAM(1);
+ std::unique_ptr video;
+ video.reset(new libvpx_test::IVFVideoSource(filename));
+ ASSERT_NE(video.get(), nullptr);
+ video->Init();
+ total_frames_ = 0;
+ spatial_layer_ = 1;
+ width_ = 640;
+ height_ = 360;
+ ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
+ ASSERT_EQ(total_frames_, kNumFrames);
+}
+
+// Decode the SVC test vector, which has 3 spatial layers, and decode up to
+// spatial layer 2. Verify the resolution of each decoded frame and the total
+// number of frames decoded. This results in the full resolution (1280x720).
+TEST_P(DecodeSvcTest, DecodeSvcTestUpToSpatialLayer2) {
+ const std::string filename = GET_PARAM(1);
+ std::unique_ptr video;
+ video.reset(new libvpx_test::IVFVideoSource(filename));
+ ASSERT_NE(video.get(), nullptr);
+ video->Init();
+ total_frames_ = 0;
+ spatial_layer_ = 2;
+ width_ = 1280;
+ height_ = 720;
+ ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
+ ASSERT_EQ(total_frames_, kNumFrames);
+}
+
+// Decode the SVC test vector, which has 3 spatial layers, and decode up to
+// spatial layer 10. Verify the resolution of each decoded frame and the total
+// number of frames decoded. This is beyond the number of spatial layers, so
+// the decoding should result in the full resolution (1280x720).
+TEST_P(DecodeSvcTest, DecodeSvcTestUpToSpatialLayer10) {
+ const std::string filename = GET_PARAM(1);
+ std::unique_ptr video;
+ video.reset(new libvpx_test::IVFVideoSource(filename));
+ ASSERT_NE(video.get(), nullptr);
+ video->Init();
+ total_frames_ = 0;
+ spatial_layer_ = 10;
+ width_ = 1280;
+ height_ = 720;
+ ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
+ ASSERT_EQ(total_frames_, kNumFrames);
+}
+
+VP9_INSTANTIATE_TEST_SUITE(
+ DecodeSvcTest, ::testing::ValuesIn(libvpx_test::kVP9TestVectorsSvc,
+ libvpx_test::kVP9TestVectorsSvc +
+ libvpx_test::kNumVP9TestVectorsSvc));
+} // namespace
diff --git a/pool/shard010/C++/0111260_bitcoin.cpp b/pool/shard010/C++/0111260_bitcoin.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1166f4037f8058d4ff639530dde30ddf54cacdee
--- /dev/null
+++ b/pool/shard010/C++/0111260_bitcoin.cpp
@@ -0,0 +1,297 @@
+/*
+ * W.J. van der Laan 2011-2012
+ */
+
+#include
+
+#include "bitcoingui.h"
+#include "clientmodel.h"
+#include "walletmodel.h"
+#include "optionsmodel.h"
+#include "guiutil.h"
+#include "guiconstants.h"
+#include "init.h"
+#include "util.h"
+#include "ui_interface.h"
+#include "paymentserver.h"
+#include "splashscreen.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifdef Q_OS_MAC
+#include "macdockiconhandler.h"
+#endif
+
+#if defined(BITCOIN_NEED_QT_PLUGINS) && !defined(_BITCOIN_QT_PLUGINS_INCLUDED)
+#define _BITCOIN_QT_PLUGINS_INCLUDED
+#define __INSURE__
+#include
+Q_IMPORT_PLUGIN(qcncodecs)
+Q_IMPORT_PLUGIN(qjpcodecs)
+Q_IMPORT_PLUGIN(qtwcodecs)
+Q_IMPORT_PLUGIN(qkrcodecs)
+Q_IMPORT_PLUGIN(qtaccessiblewidgets)
+#endif
+
+// Declare meta types used for QMetaObject::invokeMethod
+Q_DECLARE_METATYPE(bool*)
+
+// Need a global reference for the notifications to find the GUI
+static BitcoinGUI *guiref;
+static SplashScreen *splashref;
+
+static bool ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
+{
+ // Message from network thread
+ if(guiref)
+ {
+ bool modal = (style & CClientUIInterface::MODAL);
+ bool ret = false;
+ // In case of modal message, use blocking connection to wait for user to click a button
+ QMetaObject::invokeMethod(guiref, "message",
+ modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
+ Q_ARG(QString, QString::fromStdString(caption)),
+ Q_ARG(QString, QString::fromStdString(message)),
+ Q_ARG(unsigned int, style),
+ Q_ARG(bool*, &ret));
+ return ret;
+ }
+ else
+ {
+ printf("%s: %s\n", caption.c_str(), message.c_str());
+ fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
+ return false;
+ }
+}
+
+static bool ThreadSafeAskFee(const mpq& nFeeRequired)
+{
+ if(!guiref)
+ return false;
+ if(nFeeRequired < CTransaction::nMinTxFee || nFeeRequired <= nTransactionFee || fDaemon)
+ return true;
+
+ bool payFee = false;
+
+ QMetaObject::invokeMethod(guiref, "askFee", GUIUtil::blockingGUIThreadConnection(),
+ Q_ARG(mpq, nFeeRequired),
+ Q_ARG(bool*, &payFee));
+
+ return payFee;
+}
+
+static void InitMessage(const std::string &message)
+{
+ if(splashref)
+ {
+ splashref->showMessage(QString::fromStdString(message), Qt::AlignBottom|Qt::AlignHCenter, QColor(55,55,55));
+ qApp->processEvents();
+ }
+ printf("init message: %s\n", message.c_str());
+}
+
+/*
+ Translate string to current locale using Qt.
+ */
+static std::string Translate(const char* psz)
+{
+ return QCoreApplication::translate("bitcoin-core", psz).toStdString();
+}
+
+/* Handle runaway exceptions. Shows a message box with the problem and quits the program.
+ */
+static void handleRunawayException(std::exception *e)
+{
+ PrintExceptionContinue(e, "Runaway exception");
+ QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. Scicoin can no longer continue safely and will quit.") + QString("\n\n") + QString::fromStdString(strMiscWarning));
+ exit(1);
+}
+
+#ifndef BITCOIN_QT_TEST
+int main(int argc, char *argv[])
+{
+ // Command-line options take precedence:
+ ParseParameters(argc, argv);
+
+ // Internal string conversion is all UTF-8
+ QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
+ QTextCodec::setCodecForCStrings(QTextCodec::codecForTr());
+
+ Q_INIT_RESOURCE(bitcoin);
+ QApplication app(argc, argv);
+
+ // Register meta types used for QMetaObject::invokeMethod
+ qRegisterMetaType< bool* >();
+
+ // Do this early as we don't want to bother initializing if we are just calling IPC
+ // ... but do it after creating app, so QCoreApplication::arguments is initialized:
+ if (PaymentServer::ipcSendCommandLine())
+ exit(0);
+ PaymentServer* paymentServer = new PaymentServer(&app);
+
+ // Install global event filter that makes sure that long tooltips can be word-wrapped
+ app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
+
+ // ... then bitcoin.conf:
+ if (!boost::filesystem::is_directory(GetDataDir(false)))
+ {
+ // This message can not be translated, as translation is not initialized yet
+ // (which not yet possible because lang=XX can be overridden in bitcoin.conf in the data directory)
+ QMessageBox::critical(0, "Scicoin",
+ QString("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(mapArgs["-datadir"])));
+ return 1;
+ }
+ ReadConfigFile(mapArgs, mapMultiArgs);
+
+ // Application identification (must be set before OptionsModel is initialized,
+ // as it is used to locate QSettings)
+ QApplication::setOrganizationName("Scicoin");
+ QApplication::setOrganizationDomain("freico.in");
+ if(GetBoolArg("-testnet")) // Separate UI settings for testnet
+ QApplication::setApplicationName("Scicoin-Qt-testnet");
+ else
+ QApplication::setApplicationName("Scicoin-Qt");
+
+ // ... then GUI settings:
+ OptionsModel optionsModel;
+
+ // Get desired locale (e.g. "de_DE") from command line or use system locale
+ QString lang_territory = QString::fromStdString(GetArg("-lang", QLocale::system().name().toStdString()));
+ QString lang = lang_territory;
+ // Convert to "de" only by truncating "_DE"
+ lang.truncate(lang_territory.lastIndexOf('_'));
+
+ QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
+ // Load language files for configured locale:
+ // - First load the translator for the base language, without territory
+ // - Then load the more specific locale translator
+
+ // Load e.g. qt_de.qm
+ if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
+ app.installTranslator(&qtTranslatorBase);
+
+ // Load e.g. qt_de_DE.qm
+ if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
+ app.installTranslator(&qtTranslator);
+
+ // Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in bitcoin.qrc)
+ if (translatorBase.load(lang, ":/translations/"))
+ app.installTranslator(&translatorBase);
+
+ // Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in bitcoin.qrc)
+ if (translator.load(lang_territory, ":/translations/"))
+ app.installTranslator(&translator);
+
+ // Subscribe to global signals from core
+ uiInterface.ThreadSafeMessageBox.connect(ThreadSafeMessageBox);
+ uiInterface.ThreadSafeAskFee.connect(ThreadSafeAskFee);
+ uiInterface.InitMessage.connect(InitMessage);
+ uiInterface.Translate.connect(Translate);
+
+ // Show help message immediately after parsing command-line options (for "-lang") and setting locale,
+ // but before showing splash screen.
+ if (mapArgs.count("-?") || mapArgs.count("--help"))
+ {
+ GUIUtil::HelpMessageBox help;
+ help.showOrPrint();
+ return 1;
+ }
+
+#ifdef Q_OS_MAC
+ // on mac, also change the icon now because it would look strange to have a testnet splash (green) and a std app icon (orange)
+ if(GetBoolArg("-testnet")) {
+ MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet"));
+ }
+#endif
+
+ SplashScreen splash(QPixmap(), 0);
+ if (GetBoolArg("-splash", true) && !GetBoolArg("-min"))
+ {
+ splash.show();
+ splash.setAutoFillBackground(true);
+ splashref = &splash;
+ }
+
+ app.processEvents();
+ app.setQuitOnLastWindowClosed(false);
+
+ try
+ {
+ // Regenerate startup link, to fix links to old versions
+ if (GUIUtil::GetStartOnSystemStartup())
+ GUIUtil::SetStartOnSystemStartup(true);
+
+ boost::thread_group threadGroup;
+
+ BitcoinGUI window;
+ guiref = &window;
+
+ QTimer* pollShutdownTimer = new QTimer(guiref);
+ QObject::connect(pollShutdownTimer, SIGNAL(timeout()), guiref, SLOT(detectShutdown()));
+ pollShutdownTimer->start(200);
+
+ if(AppInit2(threadGroup))
+ {
+ {
+ // Put this in a block, so that the Model objects are cleaned up before
+ // calling Shutdown().
+
+ optionsModel.Upgrade(); // Must be done after AppInit2
+
+ if (splashref)
+ splash.finish(&window);
+
+ ClientModel clientModel(&optionsModel);
+ WalletModel walletModel(pwalletMain, &optionsModel);
+
+ window.setClientModel(&clientModel);
+ window.addWallet("~Default", &walletModel);
+ window.setCurrentWallet("~Default");
+
+ // If -min option passed, start window minimized.
+ if(GetBoolArg("-min"))
+ {
+ window.showMinimized();
+ }
+ else
+ {
+ window.show();
+ }
+
+ // Now that initialization/startup is done, process any command-line
+ // bitcoin: URIs
+ QObject::connect(paymentServer, SIGNAL(receivedURI(QString)), &window, SLOT(handleURI(QString)));
+ QTimer::singleShot(100, paymentServer, SLOT(uiReady()));
+
+ app.exec();
+
+ window.hide();
+ window.setClientModel(0);
+ window.removeAllWallets();
+ guiref = 0;
+ }
+ // Shutdown the core and its threads, but don't exit Bitcoin-Qt here
+ threadGroup.interrupt_all();
+ threadGroup.join_all();
+ Shutdown();
+ }
+ else
+ {
+ threadGroup.interrupt_all();
+ threadGroup.join_all();
+ Shutdown();
+ return 1;
+ }
+ } catch (std::exception& e) {
+ handleRunawayException(&e);
+ } catch (...) {
+ handleRunawayException(NULL);
+ }
+ return 0;
+}
+#endif // BITCOIN_QT_TEST
diff --git a/pool/shard010/C++/0111266_CryptoKeyReader.cc b/pool/shard010/C++/0111266_CryptoKeyReader.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1eb73e8fe9fe95ede43181a8072b66fae7569bb8
--- /dev/null
+++ b/pool/shard010/C++/0111266_CryptoKeyReader.cc
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include
+#include
+#include
+#include
+#include
+
+using namespace pulsar;
+
+CryptoKeyReader::CryptoKeyReader() {}
+CryptoKeyReader::~CryptoKeyReader() {}
+
+Result CryptoKeyReader::getPublicKey(const std::string& keyName, std::map& metadata,
+ EncryptionKeyInfo& encKeyInfo) const {
+ return ResultInvalidConfiguration;
+}
+
+Result CryptoKeyReader::getPrivateKey(const std::string& keyName,
+ std::map& metadata,
+ EncryptionKeyInfo& encKeyInfo) const {
+ return ResultInvalidConfiguration;
+}
+
+DefaultCryptoKeyReader::DefaultCryptoKeyReader(const std::string& publicKeyPath,
+ const std::string& privateKeyPath) {
+ publicKeyPath_ = publicKeyPath;
+ privateKeyPath_ = privateKeyPath;
+}
+
+DefaultCryptoKeyReader::~DefaultCryptoKeyReader() {}
+
+void DefaultCryptoKeyReader::readFile(std::string fileName, std::string& fileContents) const {
+ std::ifstream ifs(fileName);
+ std::stringstream fileStream;
+ fileStream << ifs.rdbuf();
+
+ fileContents = fileStream.str();
+}
+
+Result DefaultCryptoKeyReader::getPublicKey(const std::string& keyName,
+ std::map& metadata,
+ EncryptionKeyInfo& encKeyInfo) const {
+ std::string keyContents;
+ readFile(publicKeyPath_, keyContents);
+
+ encKeyInfo.setKey(keyContents);
+ return ResultOk;
+}
+
+Result DefaultCryptoKeyReader::getPrivateKey(const std::string& keyName,
+ std::map& metadata,
+ EncryptionKeyInfo& encKeyInfo) const {
+ std::string keyContents;
+ readFile(privateKeyPath_, keyContents);
+
+ encKeyInfo.setKey(keyContents);
+ return ResultOk;
+}
+
+CryptoKeyReaderPtr DefaultCryptoKeyReader::create(const std::string& publicKeyPath,
+ const std::string& privateKeyPath) {
+ return CryptoKeyReaderPtr(new DefaultCryptoKeyReader(publicKeyPath, privateKeyPath));
+}
\ No newline at end of file
diff --git a/pool/shard010/C++/0111268_Jit_Branch.cpp b/pool/shard010/C++/0111268_Jit_Branch.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2508fe1417f048f06c5b67cd87d888599a68888f
--- /dev/null
+++ b/pool/shard010/C++/0111268_Jit_Branch.cpp
@@ -0,0 +1,251 @@
+// Copyright 2013 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include "Common/CommonTypes.h"
+
+#include "Core/PowerPC/Jit64/Jit.h"
+#include "Core/PowerPC/Jit64/JitAsm.h"
+#include "Core/PowerPC/Jit64/JitRegCache.h"
+
+// The branches are known good, or at least reasonably good.
+// No need for a disable-mechanism.
+
+// If defined, clears CR0 at blr and bl-s. If the assumption that
+// flags never carry over between functions holds, then the task for
+// an optimizer becomes much easier.
+
+// #define ACID_TEST
+
+// Zelda and many more games seem to pass the Acid Test.
+
+using namespace Gen;
+
+void Jit64::sc(UGeckoInstruction inst)
+{
+ INSTRUCTION_START
+ JITDISABLE(bJITBranchOff);
+
+ gpr.Flush();
+ fpr.Flush();
+ MOV(32, PPCSTATE(pc), Imm32(js.compilerPC + 4));
+ LOCK();
+ OR(32, PPCSTATE(Exceptions), Imm32(EXCEPTION_SYSCALL));
+ WriteExceptionExit();
+}
+
+void Jit64::rfi(UGeckoInstruction inst)
+{
+ INSTRUCTION_START
+ JITDISABLE(bJITBranchOff);
+
+ gpr.Flush();
+ fpr.Flush();
+ // See Interpreter rfi for details
+ const u32 mask = 0x87C0FFFF;
+ const u32 clearMSR13 = 0xFFFBFFFF; // Mask used to clear the bit MSR[13]
+ // MSR = ((MSR & ~mask) | (SRR1 & mask)) & clearMSR13;
+ AND(32, PPCSTATE(msr), Imm32((~mask) & clearMSR13));
+ MOV(32, R(RSCRATCH), PPCSTATE_SRR1);
+ AND(32, R(RSCRATCH), Imm32(mask & clearMSR13));
+ OR(32, PPCSTATE(msr), R(RSCRATCH));
+ // NPC = SRR0;
+ MOV(32, R(RSCRATCH), PPCSTATE_SRR0);
+ WriteRfiExitDestInRSCRATCH();
+}
+
+void Jit64::bx(UGeckoInstruction inst)
+{
+ INSTRUCTION_START
+ JITDISABLE(bJITBranchOff);
+
+ // We must always process the following sentence
+ // even if the blocks are merged by PPCAnalyst::Flatten().
+ if (inst.LK)
+ MOV(32, PPCSTATE_LR, Imm32(js.compilerPC + 4));
+
+ // If this is not the last instruction of a block,
+ // we will skip the rest process.
+ // Because PPCAnalyst::Flatten() merged the blocks.
+ if (!js.isLastInstruction)
+ {
+ return;
+ }
+
+ gpr.Flush();
+ fpr.Flush();
+
+ u32 destination;
+ if (inst.AA)
+ destination = SignExt26(inst.LI << 2);
+ else
+ destination = js.compilerPC + SignExt26(inst.LI << 2);
+#ifdef ACID_TEST
+ if (inst.LK)
+ AND(32, PPCSTATE(cr), Imm32(~(0xFF000000)));
+#endif
+ if (destination == js.compilerPC)
+ {
+ //PanicAlert("Idle loop detected at %08x", destination);
+ // CALL(ProtectFunction(&CoreTiming::Idle, 0));
+ // JMP(Asm::testExceptions, true);
+ // make idle loops go faster
+ js.downcountAmount += 8;
+ }
+ WriteExit(destination, inst.LK, js.compilerPC + 4);
+}
+
+// TODO - optimize to hell and beyond
+// TODO - make nice easy to optimize special cases for the most common
+// variants of this instruction.
+void Jit64::bcx(UGeckoInstruction inst)
+{
+ INSTRUCTION_START
+ JITDISABLE(bJITBranchOff);
+
+ // USES_CR
+
+ FixupBranch pCTRDontBranch;
+ if ((inst.BO & BO_DONT_DECREMENT_FLAG) == 0) // Decrement and test CTR
+ {
+ SUB(32, PPCSTATE_CTR, Imm8(1));
+ if (inst.BO & BO_BRANCH_IF_CTR_0)
+ pCTRDontBranch = J_CC(CC_NZ, true);
+ else
+ pCTRDontBranch = J_CC(CC_Z, true);
+ }
+
+ FixupBranch pConditionDontBranch;
+ if ((inst.BO & BO_DONT_CHECK_CONDITION) == 0) // Test a CR bit
+ {
+ pConditionDontBranch = JumpIfCRFieldBit(inst.BI >> 2, 3 - (inst.BI & 3),
+ !(inst.BO_2 & BO_BRANCH_IF_TRUE));
+ }
+
+ if (inst.LK)
+ MOV(32, PPCSTATE_LR, Imm32(js.compilerPC + 4));
+
+ u32 destination;
+ if (inst.AA)
+ destination = SignExt16(inst.BD << 2);
+ else
+ destination = js.compilerPC + SignExt16(inst.BD << 2);
+
+ gpr.Flush(FLUSH_MAINTAIN_STATE);
+ fpr.Flush(FLUSH_MAINTAIN_STATE);
+ WriteExit(destination, inst.LK, js.compilerPC + 4);
+
+ if ((inst.BO & BO_DONT_CHECK_CONDITION) == 0)
+ SetJumpTarget( pConditionDontBranch );
+ if ((inst.BO & BO_DONT_DECREMENT_FLAG) == 0)
+ SetJumpTarget( pCTRDontBranch );
+
+ if (!analyzer.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE))
+ {
+ gpr.Flush();
+ fpr.Flush();
+ WriteExit(js.compilerPC + 4);
+ }
+}
+
+void Jit64::bcctrx(UGeckoInstruction inst)
+{
+ INSTRUCTION_START
+ JITDISABLE(bJITBranchOff);
+
+ // bcctrx doesn't decrement and/or test CTR
+ _dbg_assert_msg_(POWERPC, inst.BO_2 & BO_DONT_DECREMENT_FLAG, "bcctrx with decrement and test CTR option is invalid!");
+
+ if (inst.BO_2 & BO_DONT_CHECK_CONDITION)
+ {
+ // BO_2 == 1z1zz -> b always
+
+ //NPC = CTR & 0xfffffffc;
+ gpr.Flush();
+ fpr.Flush();
+
+ MOV(32, R(RSCRATCH), PPCSTATE_CTR);
+ if (inst.LK_3)
+ MOV(32, PPCSTATE_LR, Imm32(js.compilerPC + 4)); // LR = PC + 4;
+ AND(32, R(RSCRATCH), Imm32(0xFFFFFFFC));
+ WriteExitDestInRSCRATCH(inst.LK_3, js.compilerPC + 4);
+ }
+ else
+ {
+ // Rare condition seen in (just some versions of?) Nintendo's NES Emulator
+
+ // BO_2 == 001zy -> b if false
+ // BO_2 == 011zy -> b if true
+
+ FixupBranch b = JumpIfCRFieldBit(inst.BI >> 2, 3 - (inst.BI & 3),
+ !(inst.BO_2 & BO_BRANCH_IF_TRUE));
+ MOV(32, R(RSCRATCH), PPCSTATE_CTR);
+ AND(32, R(RSCRATCH), Imm32(0xFFFFFFFC));
+ //MOV(32, PPCSTATE(pc), R(RSCRATCH)); => Already done in WriteExitDestInRSCRATCH()
+ if (inst.LK_3)
+ MOV(32, PPCSTATE_LR, Imm32(js.compilerPC + 4)); // LR = PC + 4;
+
+ gpr.Flush(FLUSH_MAINTAIN_STATE);
+ fpr.Flush(FLUSH_MAINTAIN_STATE);
+ WriteExitDestInRSCRATCH(inst.LK_3, js.compilerPC + 4);
+ // Would really like to continue the block here, but it ends. TODO.
+ SetJumpTarget(b);
+
+ if (!analyzer.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE))
+ {
+ gpr.Flush();
+ fpr.Flush();
+ WriteExit(js.compilerPC + 4);
+ }
+ }
+}
+
+void Jit64::bclrx(UGeckoInstruction inst)
+{
+ INSTRUCTION_START
+ JITDISABLE(bJITBranchOff);
+
+ FixupBranch pCTRDontBranch;
+ if ((inst.BO & BO_DONT_DECREMENT_FLAG) == 0) // Decrement and test CTR
+ {
+ SUB(32, PPCSTATE_CTR, Imm8(1));
+ if (inst.BO & BO_BRANCH_IF_CTR_0)
+ pCTRDontBranch = J_CC(CC_NZ, true);
+ else
+ pCTRDontBranch = J_CC(CC_Z, true);
+ }
+
+ FixupBranch pConditionDontBranch;
+ if ((inst.BO & BO_DONT_CHECK_CONDITION) == 0) // Test a CR bit
+ {
+ pConditionDontBranch = JumpIfCRFieldBit(inst.BI >> 2, 3 - (inst.BI & 3),
+ !(inst.BO_2 & BO_BRANCH_IF_TRUE));
+ }
+
+ // This below line can be used to prove that blr "eats flags" in practice.
+ // This observation could let us do some useful optimizations.
+#ifdef ACID_TEST
+ AND(32, PPCSTATE(cr), Imm32(~(0xFF000000)));
+#endif
+
+ MOV(32, R(RSCRATCH), PPCSTATE_LR);
+ AND(32, R(RSCRATCH), Imm32(0xFFFFFFFC));
+ if (inst.LK)
+ MOV(32, PPCSTATE_LR, Imm32(js.compilerPC + 4));
+
+ gpr.Flush(FLUSH_MAINTAIN_STATE);
+ fpr.Flush(FLUSH_MAINTAIN_STATE);
+ WriteBLRExit();
+
+ if ((inst.BO & BO_DONT_CHECK_CONDITION) == 0)
+ SetJumpTarget( pConditionDontBranch );
+ if ((inst.BO & BO_DONT_DECREMENT_FLAG) == 0)
+ SetJumpTarget( pCTRDontBranch );
+
+ if (!analyzer.HasOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE))
+ {
+ gpr.Flush();
+ fpr.Flush();
+ WriteExit(js.compilerPC + 4);
+ }
+}
diff --git a/pool/shard010/C++/0111275_best_time_to_buy_and_sell_stock.cpp b/pool/shard010/C++/0111275_best_time_to_buy_and_sell_stock.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1a2bc7848ba95494ca063f725a71b07f367faf09
--- /dev/null
+++ b/pool/shard010/C++/0111275_best_time_to_buy_and_sell_stock.cpp
@@ -0,0 +1,31 @@
+#include
+#include
+
+using std::cout;
+using std::endl;
+using std::vector;
+
+class Solution {
+public:
+ typedef vector::size_type s_t;
+ int maxProfit(vector& prices) {
+ if (prices.size() < 2)
+ return 0;
+ vector dp(prices.size(), 0);
+ s_t min = 0;
+ for (s_t i = 1, iend = prices.size(); i < iend; ++i) {
+ int tmp = prices[i] - prices[min];
+ min = prices[min] < prices[i] ? min : i;
+ dp[i] = dp[i-1] < tmp ? tmp : dp[i-1];
+ }
+ return dp[prices.size()-1];
+ }
+};
+
+int main(void)
+{
+ int array[] = {1, 2, 3, 4};
+ vector vec(array, array+sizeof(array)/sizeof(array[0]));
+ cout << Solution().maxProfit(vec) << endl;
+
+}
diff --git a/pool/shard010/C++/0111278_SetSelectionCommand.cpp b/pool/shard010/C++/0111278_SetSelectionCommand.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..00a4d561d2be6db9825a415dcf346c3f863b28e9
--- /dev/null
+++ b/pool/shard010/C++/0111278_SetSelectionCommand.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SetSelectionCommand.h"
+
+#include "Document.h"
+#include "Frame.h"
+
+namespace WebCore {
+
+SetSelectionCommand::SetSelectionCommand(const VisibleSelection& selection, FrameSelection::SetSelectionOptions options)
+ : SimpleEditCommand(selection.base().anchorNode()->document())
+ , m_options(options)
+ , m_selectionToSet(selection)
+{
+}
+
+void SetSelectionCommand::doApply()
+{
+ FrameSelection& selection = frame().selection();
+
+ if (selection.shouldChangeSelection(m_selectionToSet) && !m_selectionToSet.isNoneOrOrphaned()) {
+ selection.setSelection(m_selectionToSet, m_options);
+ setEndingSelection(m_selectionToSet);
+ }
+}
+
+void SetSelectionCommand::doUnapply()
+{
+ FrameSelection& selection = frame().selection();
+
+ if (selection.shouldChangeSelection(startingSelection()) && !startingSelection().isNoneOrOrphaned())
+ selection.setSelection(startingSelection(), m_options);
+}
+
+} // namespace WebCore
diff --git a/pool/shard010/C++/0111279_unnamed_event.cc b/pool/shard010/C++/0111279_unnamed_event.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f52c79aac7c521ee03e523998f429d2e03385119
--- /dev/null
+++ b/pool/shard010/C++/0111279_unnamed_event.cc
@@ -0,0 +1,197 @@
+// Copyright 2010-2016, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "base/unnamed_event.h"
+
+#ifdef OS_WIN
+#include
+#else // OS_WIN
+#include
+#include
+#include
+#endif // OS_WIN
+
+#include "base/logging.h"
+#include "base/port.h"
+
+namespace gbase {
+
+#ifdef OS_WIN
+UnnamedEvent::UnnamedEvent()
+ : handle_(::CreateEvent(NULL, FALSE, FALSE, NULL)) {
+ // Use Auto reset mode of Win32 Event. (2nd arg of CreateEvent).
+ // pthread_cond_signal: auto reset mode.
+ // pthread_cond_broadcast: manual reset mode.
+ if (NULL == handle_.get()) {
+ LOG(ERROR) << "CreateEvent failed: " << ::GetLastError();
+ }
+}
+
+UnnamedEvent::~UnnamedEvent() {}
+
+bool UnnamedEvent::IsAvailable() const {
+ return (NULL != handle_.get());
+}
+
+bool UnnamedEvent::Notify() {
+ if (!IsAvailable()) {
+ LOG(WARNING) << "Event object is not available";
+ return false;
+ }
+
+ if (!::SetEvent(handle_.get())) {
+ LOG(ERROR) << "SetEvent failed: " << ::GetLastError();
+ return false;
+ }
+
+ return true;
+}
+
+bool UnnamedEvent::Wait(int msec) {
+ if (!IsAvailable()) {
+ return true; // assume that it is already raised
+ }
+
+ if (msec < 0) {
+ msec = INFINITE;
+ }
+
+ return WAIT_TIMEOUT !=
+ ::WaitForSingleObject(handle_.get(), msec);
+}
+
+#else // OS_WIN
+
+namespace {
+class ScopedPthreadMutexLock {
+ public:
+ explicit ScopedPthreadMutexLock(pthread_mutex_t *mutex) : mutex_(mutex) {
+ pthread_mutex_lock(mutex_);
+ }
+ ~ScopedPthreadMutexLock() {
+ pthread_mutex_unlock(mutex_);
+ }
+
+ private:
+ pthread_mutex_t *mutex_;
+ DISALLOW_COPY_AND_ASSIGN(ScopedPthreadMutexLock);
+};
+} // namespace
+
+UnnamedEvent::UnnamedEvent() : notified_(false) {
+ pthread_mutex_init(&mutex_, NULL);
+ pthread_cond_init(&cond_, NULL);
+}
+
+// It is necessary to ensure that no threads wait for this event before the
+// destruction.
+UnnamedEvent::~UnnamedEvent() {
+ pthread_mutex_destroy(&mutex_);
+ pthread_cond_destroy(&cond_);
+}
+
+bool UnnamedEvent::IsAvailable() const {
+ return true;
+}
+
+bool UnnamedEvent::Notify() {
+ {
+ ScopedPthreadMutexLock lock(&mutex_);
+ notified_ = true;
+ }
+
+ // Note: Need to awake all threads waiting for this event. Otherwise
+ // some thread would start to work incorrectly in some cases.
+ // An example error scenario is:
+ // - there are four threads, A, B, C and D.
+ // - A and B are producers. C and D are consumers.
+ // - C and D start to wait this event.
+ // - Then A notifies.
+ // - A takes the lock.
+ // - set notified_ true.
+ // - A releases the lock.
+ // - Then before A sends a signal to awake a thread (either C or D),
+ // B takes the lock.
+ // - A sends a signal, but both C and D are sleeping as the lock is
+ // still taken by B.
+ // - B releases the lock. So one of the thread (let's assume C for this
+ // example) starts to run, because it can take the lock.
+ // - B also sends a signal again.
+ // - C overrides notified_ to false, and releases the lock.
+ // - At last, D starts to run wrongly.
+ // The broadcast and while (in Wait) idiom is a popular way to fix such
+ // cases.
+ pthread_cond_broadcast(&cond_);
+ return true;
+}
+
+bool UnnamedEvent::Wait(int msec) {
+ ScopedPthreadMutexLock lock(&mutex_);
+ if (!notified_) {
+ // Need to wait actually.
+ if (msec < 0) {
+ // Wait forever.
+ while (!notified_) {
+ pthread_cond_wait(&cond_, &mutex_);
+ }
+ } else {
+ // Wait with time out.
+ struct timeval tv;
+ if (gettimeofday(&tv, NULL) != 0) {
+ LOG(ERROR) << "Failed to take the current time: " << errno;
+ return false;
+ }
+
+ struct timespec timeout;
+ timeout.tv_sec = tv.tv_sec + msec / 1000;
+ timeout.tv_nsec = 1000 * (tv.tv_usec + 1000 * (msec % 1000));
+
+ // if tv_nsec >= 10^9, pthread_cond_timedwait may return EINVAL
+ while (timeout.tv_nsec >= 1000000000) {
+ timeout.tv_sec++;
+ timeout.tv_nsec -= 1000000000;
+ }
+
+ int result = 0;
+ while (!notified_ && result == 0) {
+ result = pthread_cond_timedwait(&cond_, &mutex_, &timeout);
+ }
+
+ if (result != 0) {
+ // Time out.
+ return false;
+ }
+ }
+ }
+ DCHECK(notified_);
+ notified_ = false;
+ return true;
+}
+#endif // OS_WIN
+} // namespace gbase
diff --git a/pool/shard010/C++/0111283_connect_test.cpp b/pool/shard010/C++/0111283_connect_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2975a514d7c844f851dbd29a8dbb7af293b9d39a
--- /dev/null
+++ b/pool/shard010/C++/0111283_connect_test.cpp
@@ -0,0 +1,222 @@
+/*
+ Copyright (C) Kai Blin 2007
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+
+ A client/server connect test for dplay.
+*/
+#define INITGUID
+#define _WIN32_DCOM
+#include
+#include
+#include
+#include
+
+// {EF016237-BEEE-402a-A2D6-A2694C109574}
+DEFINE_GUID(CONNECT_TEST,
+0xef016237, 0xbeee, 0x402a, 0xa2, 0xd6, 0xa2, 0x69, 0x4c, 0x10, 0x95, 0x74);
+
+typedef struct _dp_player_list {
+ DPID dpid;
+ char name[15];
+ DWORD flags;
+ struct _dp_player_list *next;
+} dp_player_list;
+
+//------------------------ Globals ----------------------
+IDirectPlay8Peer *pDP = NULL;
+IDirectPlay8Address *pDP_addr = NULL;
+BOOL is_server = FALSE;
+
+//------------------ Function prototypes ----------------
+DWORD handleArgs(int argc, char **argv);
+HRESULT WINAPI dPlayMsgHandler(void * user_context, DWORD msg_id, void * msg_buff);
+HRESULT initDPlay();
+void cleanupDPlay();
+HRESULT enumDPlaySP();
+HRESULT getDPlayAddr();
+HRESULT hostGame();
+
+int main(int argc, char** argv)
+{
+ HRESULT hr;
+ DWORD dwresult;
+ MSG msg;
+ BOOL done = FALSE;
+ int i = 0;
+
+ if((dwresult = handleArgs(argc, argv)) == -1)
+ {
+ return dwresult;
+ }
+
+ if(FAILED(hr = CoInitialize(NULL)))
+ {
+ return -1;
+ }
+
+ if(FAILED(hr = initDPlay()))
+ {
+ fprintf(stderr, "Failed to init dplay: 0x%08x\n", hr);
+ goto cleanup;
+ }
+
+ if(FAILED(hr = enumDPlaySP()))
+ {
+ fprintf(stderr, "Failed enumerating service providers: 0x%08x\n", hr);
+ goto cleanup;
+ }
+
+ if(FAILED(hr = getDPlayAddr()))
+ {
+ fprintf(stderr, "Failed to get IDirectPlay8Address com object: 0x%08x\n", hr);
+ goto cleanup;
+ }
+
+ if(is_server)
+ {
+ printf("Selected server mode, hosting a game.\n");
+ if(FAILED(hr = hostGame()))
+ {
+ fprintf(stderr, "Failed to host game: 0x%08x\n", hr);
+ goto cleanup;
+ }
+ }
+ else
+ {
+ printf("Selected client mode, enumerating games.\n");
+ }
+
+#if 0
+ while(!done)
+ {
+ if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ else
+ {
+ // fake game loop
+ ++i;
+ if(is_server)
+ printf("S");
+ else
+ printf("c");
+ if(i > 25)
+ break;
+ }
+ }
+#endif
+ puts("Press any key to exit.");
+ getchar();
+
+cleanup:
+ cleanupDPlay();
+ CoUninitialize();
+}
+
+DWORD handleArgs(int argc, char **argv)
+{
+ if(argc < 2)
+ {
+ is_server = FALSE;
+ return 0;
+ }
+ if(strcmp(argv[1], "server") == 0)
+ is_server = TRUE;
+
+ return 0;
+}
+
+HRESULT WINAPI dPlayMsgHandler(void * user_context, DWORD msg_id, void * msg_buff)
+{
+ return S_OK;
+}
+
+HRESULT enumDPlaySP()
+{
+ HRESULT hr;
+ DWORD items = 0, size = 0, i;
+ DPN_SERVICE_PROVIDER_INFO *dp_sp_info, *dp_sp_item;
+
+ hr = pDP->EnumServiceProviders(NULL, NULL, NULL, &size, &items, 0);
+
+ if(hr != DPNERR_BUFFERTOOSMALL)
+ {
+ fprintf(stderr, "Failed to get the service provider array size: 0x%08x\n", hr);
+ return hr;
+ }
+
+ dp_sp_info = static_cast(CoTaskMemAlloc(size));
+
+ if(FAILED(hr = pDP->EnumServiceProviders(NULL, NULL, dp_sp_info, &size, &items, 0)))
+ {
+ fprintf(stderr, "Failed to enumerate service providers: 0x%08x\n", hr);
+ return hr;
+ }
+
+ dp_sp_item = dp_sp_info;
+ printf("Found %d providers:\n", items);
+ for(i = 0; i < items; ++i)
+ {
+ printf("Provider: %S\n", dp_sp_item->pwszName);
+ ++dp_sp_item;
+ }
+
+ CoTaskMemFree(dp_sp_info);
+ return hr;
+}
+
+HRESULT getDPlayAddr()
+{
+ HRESULT hr;
+
+ if(FAILED(hr = CoCreateInstance(CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address,
+ (LPVOID *)&pDP_addr)))
+ {
+ fprintf(stderr, "Failed to create IDirectPlay8Address instance: 0x%08x\n", hr);
+ return hr;
+ }
+
+ if(FAILED(pDP_addr->SetSP(&CLSID_DP8SP_TCPIP)))
+ {
+ fprintf(stderr, "Failed to set TCP/IP service provider: 0x%08x\n", hr);
+ return hr;
+ }
+
+ printf("Loaded the TCP/IP service provider.\n");
+ return hr;
+}
+
+HRESULT hostGame()
+{
+ HRESULT hr;
+ DPN_APPLICATION_DESC app_desc;
+
+ ZeroMemory(&app_desc, sizeof(DPN_APPLICATION_DESC));
+ app_desc.dwSize = sizeof(DPN_APPLICATION_DESC);
+ app_desc.guidApplication = CONNECT_TEST;
+
+ if(FAILED(hr = pDP->Host(&app_desc, &pDP_addr, 1, NULL, NULL, NULL, DPNHOST_OKTOQUERYFORADDRESSING)))
+ {
+ fprintf(stderr, "Failed to host a game: 0x%08x\n", hr);
+ return hr;
+ }
+
+ printf("Hosted game.\n");
+
+ return hr;
+}
+
diff --git a/pool/shard010/C++/0111284_main.cpp b/pool/shard010/C++/0111284_main.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..011ffdfd50111b145f2bb89ef7447d4be8b36c81
--- /dev/null
+++ b/pool/shard010/C++/0111284_main.cpp
@@ -0,0 +1,48 @@
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+using namespace std;
+
+
+int main(int argc, char **argv) {
+ if (argc < 2) {
+ cerr << "Usage: " << argv[0] << " [--wast]" << endl;
+ return 1;
+ }
+
+ bool wast = false;
+ if (argc == 3) {
+ wast = (string(argv[2]) == "--wast");
+ if (!wast) {
+ cerr << "Usage: " << argv[0] << " [--wast]" << endl;
+ return 1;
+ }
+ }
+
+ ifstream input(argv[1]);
+ if (!input.is_open()) {
+ cerr << "File not found: " << argv[1] << endl;
+ return 1;
+ }
+
+ string str(
+ (std::istreambuf_iterator(input)),
+ std::istreambuf_iterator()
+ );
+
+ // clean input of any whitespace (including space and new lines)
+ str.erase(remove_if(str.begin(), str.end(), [](unsigned char x){return std::isspace(x);}), str.end());
+
+ if (wast) {
+ cout << evm2wasm::evmhex2wast(str);
+ } else {
+ cout << evm2wasm::evmhex2wasm(str);
+ }
+
+ return 0;
+}
diff --git a/pool/shard010/C++/0111285_speedwidget.cpp b/pool/shard010/C++/0111285_speedwidget.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6a321c2f865c15d2592dc49aa71f3fdf27cb5801
--- /dev/null
+++ b/pool/shard010/C++/0111285_speedwidget.cpp
@@ -0,0 +1,205 @@
+/*
+ * Bittorrent Client using Qt and libtorrent.
+ * Copyright (C) 2015 Anton Lashkov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * In addition, as a special exception, the copyright holders give permission to
+ * link this program with the OpenSSL project's "OpenSSL" library (or with
+ * modified versions of it that use the same license as the "OpenSSL" library),
+ * and distribute the linked executables. You must obey the GNU General Public
+ * License in all respects for all of the code used other than "OpenSSL". If you
+ * modify file(s), 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.
+ */
+
+#include "speedwidget.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include "propertieswidget.h"
+#include "base/bittorrent/session.h"
+#include "base/bittorrent/sessionstatus.h"
+#include "base/preferences.h"
+#include "base/utils/misc.h"
+
+ComboBoxMenuButton::ComboBoxMenuButton(QWidget *parent, QMenu *menu)
+ : QComboBox(parent)
+ , m_menu(menu)
+{
+}
+
+void ComboBoxMenuButton::showPopup()
+{
+ QPoint p = mapToGlobal(QPoint(0, height()));
+ m_menu->exec(p);
+ QComboBox::hidePopup();
+}
+
+
+SpeedWidget::SpeedWidget(PropertiesWidget *parent)
+ : QWidget(parent)
+{
+ m_layout = new QVBoxLayout(this);
+ m_layout->setContentsMargins(0, 0, 0, 0);
+
+ m_hlayout = new QHBoxLayout();
+ m_hlayout->setContentsMargins(0, 0, 0, 0);
+
+ m_periodLabel = new QLabel("" + tr("Period:") + "");
+
+ m_periodCombobox = new QComboBox();
+ m_periodCombobox->addItem(tr("1 Minute"));
+ m_periodCombobox->addItem(tr("5 Minutes"));
+ m_periodCombobox->addItem(tr("30 Minutes"));
+ m_periodCombobox->addItem(tr("6 Hours"));
+
+ connect(m_periodCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(onPeriodChange(int)));
+
+ m_graphsMenu = new QMenu();
+ m_graphsMenu->addAction(tr("Total Upload"));
+ m_graphsMenu->addAction(tr("Total Download"));
+ m_graphsMenu->addAction(tr("Payload Upload"));
+ m_graphsMenu->addAction(tr("Payload Download"));
+ m_graphsMenu->addAction(tr("Overhead Upload"));
+ m_graphsMenu->addAction(tr("Overhead Download"));
+ m_graphsMenu->addAction(tr("DHT Upload"));
+ m_graphsMenu->addAction(tr("DHT Download"));
+ m_graphsMenu->addAction(tr("Tracker Upload"));
+ m_graphsMenu->addAction(tr("Tracker Download"));
+
+ m_graphsMenuActions = m_graphsMenu->actions();
+ m_graphsSignalMapper = new QSignalMapper();
+
+ for (int id = SpeedPlotView::UP; id < SpeedPlotView::NB_GRAPHS; ++id) {
+ QAction *action = m_graphsMenuActions.at(id);
+ action->setCheckable(true);
+ action->setChecked(true);
+ connect(action, SIGNAL(changed()), m_graphsSignalMapper, SLOT(map()));
+ m_graphsSignalMapper->setMapping(action, id);
+ }
+ connect(m_graphsSignalMapper, SIGNAL(mapped(int)), this, SLOT(onGraphChange(int)));
+
+ m_graphsButton = new ComboBoxMenuButton(this, m_graphsMenu);
+ m_graphsButton->addItem(tr("Select Graphs"));
+
+ m_hlayout->addWidget(m_periodLabel);
+ m_hlayout->addWidget(m_periodCombobox);
+ m_hlayout->addStretch();
+ m_hlayout->addWidget(m_graphsButton);
+
+ m_plot = new SpeedPlotView(this);
+
+ m_layout->addLayout(m_hlayout);
+ m_layout->addWidget(m_plot);
+
+ loadSettings();
+
+ m_isUpdating = true;
+ m_updateFuture = QtConcurrent::run(this, &SpeedWidget::update);
+
+ m_plot->show();
+}
+
+SpeedWidget::~SpeedWidget()
+{
+ qDebug("SpeedWidget::~SpeedWidget() ENTER");
+
+ m_isUpdating = false;
+ m_updateFuture.waitForFinished();
+
+ saveSettings();
+
+ qDebug("SpeedWidget::~SpeedWidget() EXIT");
+}
+
+void SpeedWidget::update()
+{
+ while (m_isUpdating) {
+
+ BitTorrent::SessionStatus btStatus = BitTorrent::Session::instance()->status();
+
+ m_plot->pushXPoint(QDateTime::currentDateTime().toTime_t());
+ m_plot->pushYPoint(SpeedPlotView::UP, btStatus.uploadRate());
+ m_plot->pushYPoint(SpeedPlotView::DOWN, btStatus.downloadRate());
+ m_plot->pushYPoint(SpeedPlotView::PAYLOAD_UP, btStatus.payloadUploadRate());
+ m_plot->pushYPoint(SpeedPlotView::PAYLOAD_DOWN, btStatus.payloadDownloadRate());
+ m_plot->pushYPoint(SpeedPlotView::OVERHEAD_UP, btStatus.ipOverheadUploadRate());
+ m_plot->pushYPoint(SpeedPlotView::OVERHEAD_DOWN, btStatus.ipOverheadDownloadRate());
+ m_plot->pushYPoint(SpeedPlotView::DHT_UP, btStatus.dhtUploadRate());
+ m_plot->pushYPoint(SpeedPlotView::DHT_DOWN, btStatus.dhtDownloadRate());
+ m_plot->pushYPoint(SpeedPlotView::TRACKER_UP, btStatus.trackerUploadRate());
+ m_plot->pushYPoint(SpeedPlotView::TRACKER_DOWN, btStatus.trackerDownloadRate());
+
+ QMetaObject::invokeMethod(this, "graphUpdate", Qt::QueuedConnection);
+ Utils::Misc::msleep(1000);
+ }
+}
+
+void SpeedWidget::graphUpdate()
+{
+ m_plot->replot();
+}
+
+void SpeedWidget::onPeriodChange(int period)
+{
+ m_plot->setViewableLastPoints(static_cast(period));
+ graphUpdate();
+}
+
+void SpeedWidget::onGraphChange(int id)
+{
+ QAction *action = m_graphsMenuActions.at(id);
+ m_plot->setGraphEnable(static_cast(id), action->isChecked());
+
+ graphUpdate();
+}
+
+void SpeedWidget::loadSettings()
+{
+ Preferences *preferences = Preferences::instance();
+
+ int periodIndex = preferences->getSpeedWidgetPeriod();
+ m_periodCombobox->setCurrentIndex(periodIndex);
+ onPeriodChange(static_cast(periodIndex));
+
+ for (int id = SpeedPlotView::UP; id < SpeedPlotView::NB_GRAPHS; ++id) {
+ QAction *action = m_graphsMenuActions.at(id);
+ bool enable = preferences->getSpeedWidgetGraphEnable(id);
+
+ action->setChecked(enable);
+ m_plot->setGraphEnable(static_cast(id), enable);
+ }
+}
+
+void SpeedWidget::saveSettings() const
+{
+ Preferences *preferences = Preferences::instance();
+
+ preferences->setSpeedWidgetPeriod(m_periodCombobox->currentIndex());
+
+ for (int id = SpeedPlotView::UP; id < SpeedPlotView::NB_GRAPHS; ++id) {
+ QAction *action = m_graphsMenuActions.at(id);
+ preferences->setSpeedWidgetGraphEnable(id, action->isChecked());
+ }
+}
+
diff --git a/pool/shard010/C++/0111286_camera_self_filter_server.cpp b/pool/shard010/C++/0111286_camera_self_filter_server.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e24edfbc353fc45e33bf3baee879801ed45bd4b4
--- /dev/null
+++ b/pool/shard010/C++/0111286_camera_self_filter_server.cpp
@@ -0,0 +1,186 @@
+/*********************************************************************
+ *
+ * Software License Agreement (BSD License)
+ *
+ * Copyright (c) 2008, Robert Bosch LLC.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of the Robert Bosch nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *********************************************************************/
+
+/*
+ * camera_self_filter.cpp
+ *
+ * Created on: Oct 6, 2010
+ * Author: christian
+ */
+
+#include
+
+#include
+#include
+#include
+#include "cv_bridge/CvBridge.h"
+#include "sensor_msgs/Image.h"
+#include "sensor_msgs/CameraInfo.h"
+#include "image_transport/image_transport.h"
+#include
+
+#define GL_GLEXT_PROTOTYPES
+#include
+#include
+#include
+
+#include "camera_self_filter/robotMeshModel.h"
+#include "camera_self_filter/mask.h"
+
+
+RobotMeshModel* robmod=NULL;
+IplImage* ipl_maskBGRA = NULL;
+IplImage* ipl_maskBW = NULL;
+
+bool inverted;
+sensor_msgs::CvBridge bridge;
+
+
+void initializeGL ()
+{
+ glClearColor(0, 0, 0, 0);
+// glEnable(GL_LIGHTING);
+// glEnable(GL_LIGHT0);
+ glEnable(GL_NORMALIZE);
+ glEnable(GL_COLOR_MATERIAL);
+ glEnable(GL_CULL_FACE);
+ glEnable(GL_DEPTH_TEST);
+ glShadeModel(GL_SMOOTH);
+ glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR_MIPMAP_LINEAR);
+}
+
+
+
+//function that draws the robot at current state
+void display() {
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ robmod->setCamera();
+ robmod->setCameraPose();
+ robmod->paintRobot();
+ glReadPixels(0, 0, robmod->cam_info_->width, robmod->cam_info_->height , GL_BGRA, GL_UNSIGNED_BYTE, ipl_maskBGRA->imageData);
+
+ glutSwapBuffers();
+}
+
+
+
+sensor_msgs::ImagePtr calc_and_publish_BWMask(const ros::Time time_stamp, const std::string frame_id ){
+ robmod->updateRobotLinks(time_stamp);
+ glutPostRedisplay();
+ glutMainLoopEvent();
+ cvCvtColor(ipl_maskBGRA, ipl_maskBW, CV_BGRA2GRAY);
+ cvFlip(ipl_maskBW);
+ if (inverted)
+ cvNot(ipl_maskBW,ipl_maskBW);
+
+ sensor_msgs::ImagePtr img_msg = sensor_msgs::CvBridge::cvToImgMsg(ipl_maskBW);
+ img_msg->header.frame_id = frame_id;
+ img_msg->header.stamp = time_stamp;
+ return img_msg;
+
+
+
+}
+
+bool calcMaskCB(camera_self_filter::maskRequest& req, camera_self_filter::maskResponse& res){
+ sensor_msgs::ImagePtr img = calc_and_publish_BWMask(req.header.stamp, req.header.frame_id);
+ res.mask_image = *img;
+ return true;
+
+}
+
+
+int main(int argc, char **argv) {
+ glutInit(&argc, argv);
+ ros::init(argc, argv, "robot_self_filter");
+
+
+ //create selfilter service
+ ros::NodeHandle nh;
+ ros::NodeHandle nh_priv("~");
+
+ //set parameters
+
+
+ std::string camera_topic;
+ std::string camera_info_topic;
+
+ nh_priv.param("inverted",inverted, false);
+ nh_priv.param("camera_topic", camera_topic, "/wide_stereo/right/image_rect_color" );
+ nh_priv.param("camera_info_topic", camera_info_topic, "/wide_stereo/right/camera_info" );
+
+ ROS_INFO("camera topic %s", camera_topic.c_str());
+ ROS_INFO("camera info %s", camera_info_topic.c_str());
+
+ //create robot model
+ robmod = new RobotMeshModel;
+
+ //initialize glut
+ glutInitWindowSize (robmod->cam_info_->width, robmod->cam_info_->height);
+ glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+
+
+ glutCreateWindow ("dummy");
+ glutHideWindow();
+
+ initializeGL();
+ // Register glut callbacks:
+ glutDisplayFunc (display);
+
+ ipl_maskBGRA = cvCreateImage(cvSize( robmod->cam_info_->width, robmod->cam_info_->height), IPL_DEPTH_8U, 4);
+ ipl_maskBW = cvCreateImage(cvSize( robmod->cam_info_->width, robmod->cam_info_->height), IPL_DEPTH_8U, 1);
+
+
+
+
+
+ ros::ServiceServer mask_service = nh.advertiseService("self_mask", calcMaskCB );
+
+
+ ros::spin();
+
+
+ //clean up
+ cvReleaseImage(&ipl_maskBGRA);
+ cvReleaseImage(&ipl_maskBW);
+ delete robmod;
+ return 0;
+}
+
diff --git a/pool/shard010/C++/0111288_CAirbusStaticPort.cpp b/pool/shard010/C++/0111288_CAirbusStaticPort.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b7261ea2169a807b0e7e71b98c94ea6acf1927e9
--- /dev/null
+++ b/pool/shard010/C++/0111288_CAirbusStaticPort.cpp
@@ -0,0 +1,53 @@
+
+// qt-plus
+#include "CLogger.h"
+
+// Quick3D
+#include "CConsoleBoard.h"
+#include "C3DScene.h"
+#include "CAtmosphere.h"
+#include "CAircraft.h"
+
+// Application
+#include "CAirbusStaticPort.h"
+
+using namespace Math;
+
+//-------------------------------------------------------------------------------------------------
+
+CComponent* CAirbusStaticPort::instantiator(C3DScene* pScene)
+{
+ return new CAirbusStaticPort(pScene);
+}
+
+//-------------------------------------------------------------------------------------------------
+
+CAirbusStaticPort::CAirbusStaticPort(C3DScene* pScene)
+ : CComponent(pScene)
+{
+}
+
+//-------------------------------------------------------------------------------------------------
+
+CAirbusStaticPort::~CAirbusStaticPort()
+{
+}
+
+//-------------------------------------------------------------------------------------------------
+
+void CAirbusStaticPort::update(double dDeltaTime)
+{
+ QSP pAircraft = QSP_CAST(CAircraft, root());
+
+ if (pAircraft)
+ {
+ double dPressure = CAtmosphere::getInstance()->pressure_Nm2(pAircraft->geoloc().Altitude) * N_TO_KG;
+
+ pushData(CAirbusData(m_sName, adStatic_Pressure_kgm2, dPressure));
+
+ LOG_VALUE(QString("%1 (PRS KGM2)").arg(m_sName),
+ QString("%1")
+ .arg(QString::number(dPressure, 'f', 4))
+ );
+ }
+}
diff --git a/pool/shard010/C++/0111293_MSOfficeTextStripper.cpp b/pool/shard010/C++/0111293_MSOfficeTextStripper.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..841251312ff273aa2d897d7f4cde5801d31fa990
--- /dev/null
+++ b/pool/shard010/C++/0111293_MSOfficeTextStripper.cpp
@@ -0,0 +1,98 @@
+#include
+#include
+#include "MSOfficeTextStripper.h"
+
+#ifdef WIN32
+#include
+#endif
+
+using namespace std;
+FX_NS_DEF(plugin);
+
+
+MSOfficeTextStripper::MSOfficeTextStripper(void)
+ : m_pTextBuffer(NULL)
+ , m_nTextPos(0)
+ , m_nTextSize(0)
+{
+ m_pAnalyze = new Analyze(this);
+}
+
+MSOfficeTextStripper::~MSOfficeTextStripper(void)
+{
+ if (m_pTextBuffer)
+ {
+ delete m_pTextBuffer;
+ m_pTextBuffer = NULL;
+ }
+ m_nTextSize = 0;
+ m_nTextPos = 0;
+ delete m_pAnalyze;
+}
+
+char* MSOfficeTextStripper::strip(const char* szFileName)
+{
+ m_nTextPos = 0;
+
+ FILE* hFile = fopen(szFileName, "rb");
+ if (!hFile)
+ return NULL;
+
+ const char* p = szFileName;
+ while(*p)
+ p++;
+ p--;
+ if (*p == L't')
+ m_pAnalyze->parsePPT(hFile);
+ else if (*p == L's')
+ m_pAnalyze->parseXLS(hFile);
+ else
+ m_pAnalyze->parseDOC(hFile);
+
+ fclose(hFile);
+
+ if (m_nTextPos > 0 )
+ return m_pTextBuffer;
+ return NULL;
+}
+
+void MSOfficeTextStripper::output_paragraph(unsigned short int *buffer)
+{
+ size_t len = wcslen((const wchar_t*)buffer);
+ if (!m_pTextBuffer || (m_nTextSize - m_nTextPos < len) )
+ growBuffer(0);
+#ifdef WIN32
+ int nRet = WideCharToMultiByte(CP_ACP, 0, (const wchar_t*)buffer, (int)len,
+ m_pTextBuffer + m_nTextPos, (int)m_nTextSize - m_nTextPos, NULL, NULL);
+ if (nRet > 0)
+ {
+ m_nTextPos += nRet;
+ }
+#else
+ mbstate_t state;
+ memset( &state, 0, sizeof(state) );
+ wchar_t const* tmp = (wchar_t const*)buffer;
+ size_t nRet = wcsrtombs(m_pTextBuffer + m_nTextPos,&tmp,m_nTextSize - m_nTextPos,&state);
+ if (nRet != (size_t)-1)
+ m_nTextPos += nRet;
+#endif
+ if (m_nTextSize - m_nTextPos > 0)
+ m_pTextBuffer[m_nTextPos++] = ' ';
+}
+
+void MSOfficeTextStripper::growBuffer(size_t nGrowLen)
+{
+ size_t nNewLen = m_nTextSize + nGrowLen;
+ if (nNewLen < (m_nTextSize << 1) )
+ nNewLen = (m_nTextSize << 1);
+ if (nNewLen < (size_t)DEFAULT_TEXTBUF_SIZE)
+ nNewLen = DEFAULT_TEXTBUF_SIZE;
+ char* pBuf = new char[nNewLen];
+ if (m_nTextPos > 0)
+ memcpy(pBuf,m_pTextBuffer,m_nTextPos);
+ delete[] m_pTextBuffer;
+ m_pTextBuffer = pBuf;
+ m_nTextSize = nNewLen;
+}
+
+FX_NS_END
diff --git a/pool/shard010/C++/0111295_dfsalgo.cpp b/pool/shard010/C++/0111295_dfsalgo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..44ee30e8d3e20a190c372414a53fb8f386594a5e
--- /dev/null
+++ b/pool/shard010/C++/0111295_dfsalgo.cpp
@@ -0,0 +1,107 @@
+/*****************************************************************************
+ * Copyright © 2016 Oakware - All Rights Reserved
+ *
+ * Github :
+ * Authors: Ivan Kondratuk
+ *
+ * This file is part of Graph Builder.
+ *
+ * Graph Builder is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Graph Builder is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Graph Builder. If not, see .
+ *****************************************************************************/
+
+#include "dfsalgo.h"
+#include "AlgoPlugins/graphreset.h"
+
+#define asleep() if(!sl->sleep(params.sleepTime)) return false;
+
+DfsAlgo::DfsAlgo(QObject *par):
+ QObject(par)
+{
+ sl = new Sleeper(this);
+}
+
+bool DfsAlgo::run(AbstractGraph *gr, int sver){
+ VectorListGS sgr = gr->getGraphModel().toVectorList(); // Return if
+ if(sgr.count() <= 1) return false; // no vertexes
+
+ QBitArray vis(sgr.count()); // Variables
+ QStack st;
+ int conComp = 1;
+
+ st << sver; vis[sver] = true;
+ resetGraph(gr, "#03A9F4", params.ri.color);
+ AG_CHANGE_VER_PARAM((*gr), sver, color, "#7E57C2")
+
+ while(!st.empty()){
+ asleep();
+
+ int i, v = st.top();
+ for(i=0; iisOriented()){
+ result += '\n';
+ result += tr("Connected components count: ")
+ + QString::number(conComp);
+ }
+ return true;
+}
+
+void DfsAlgo::stop(){
+ sl->stop();
+}
+
+QString DfsAlgo::name(){
+ return tr("DFS");
+}
+
+QString DfsAlgo::qmlDialog(){
+ return "qrc:/DFS/ResDialog.qml";
+}
+
+QString DfsAlgo::getResult(){
+ return result;
+}
+
+void DfsAlgo::setParams(const plugParams &pp){
+ params = pp;
+}
diff --git a/pool/shard010/C++/0111298_DeferredRenderPipeline.cpp b/pool/shard010/C++/0111298_DeferredRenderPipeline.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2590b5b99a43402401565cd4cc98ff2b1570dafd
--- /dev/null
+++ b/pool/shard010/C++/0111298_DeferredRenderPipeline.cpp
@@ -0,0 +1,74 @@
+#include "DeferredRenderPipeline.h"
+#include "SceneManager.h"
+#include "MeshRendererComponent.h"
+#include "Lighting.h"
+
+using namespace std;
+using namespace AnEngine::Game;
+using namespace AnEngine::RenderCore;
+
+namespace AnEngine::RenderCore
+{
+ void DeferredRenderPipeline::OnRender(std::mutex& sceneResMutex)
+ {
+ FenceContext::Instance()->WaitAllFence();
+
+ /* GBuffer阶段,渲染所有摄像机的 GBuffer、Depth、Normal */
+ //lock_guard lock(sceneResMutex);
+ GBuffer();
+
+ /* 对于场景中的每一个光源,绘制其深度图,以生成阴影。 */
+ //lock_guard lock(sceneResMutex);
+ DepthPreLight();
+
+ /* 阴影 */
+ FenceContext::Instance()->WaitAllFence();
+ Shadow();
+
+ /* 反射 */
+
+ /* 使用前向渲染处理半透明物体 */
+
+ /* 天空盒 */
+
+ /* 全屏后处理 */
+ FenceContext::Instance()->WaitAllFence();
+ PostProcess();
+
+ /* 绘制UI组件 */
+ UI();
+ }
+
+ void DeferredRenderPipeline::GBuffer()
+ {
+ var scene = Game::SceneManager::ActiveScene();
+ // 网格渲染器是 ECS 组织的
+ var objs = scene->GetGroupOfType(); // 从场景中获取所有的 Mesh Renderer 组件进行渲染
+ const auto& mrs = *objs;
+ var[list, allocator] = GraphicsContext::GetOne();
+ var ilist = list->GetCommandList();
+ var iallocator = allocator->GetAllocator();
+ ThrowIfFailed(iallocator->Reset());
+
+ ThrowIfFailed(ilist->Close());
+ GraphicsContext::Push(list, allocator);
+ }
+
+ void DeferredRenderPipeline::DepthPreLight()
+ {
+ var scene = Game::SceneManager::ActiveScene();
+ // 灯光是 Behaviour 组织的
+
+ }
+
+ void DeferredRenderPipeline::Shadow()
+ {
+ }
+
+ void DeferredRenderPipeline::UI()
+ {
+ }
+ void DeferredRenderPipeline::PostProcess()
+ {
+ }
+}
\ No newline at end of file
diff --git a/pool/shard010/C++/0111302_QGis.cpp b/pool/shard010/C++/0111302_QGis.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2d0c126ec5caf824bc8d7210183a600287605daa
--- /dev/null
+++ b/pool/shard010/C++/0111302_QGis.cpp
@@ -0,0 +1,78 @@
+/************************************************************************************
+TerraME - a software platform for multiple scale spatially-explicit dynamic modeling.
+Copyright (C) 2001-2017 INPE and TerraLAB/UFOP -- www.terrame.org
+
+This code is part of the TerraME framework.
+This framework is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The framework provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and TerraLAB / UFOP be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this software and its documentation.
+*************************************************************************************/
+
+#include "QGis.h"
+
+#include
+
+#include "QgsReader.h"
+#include "QgsWriter.h"
+#include "Utils.h"
+
+terrame::qgis::QGis& terrame::qgis::QGis::getInstance()
+{
+ static terrame::qgis::QGis instance;
+ return instance;
+}
+
+terrame::qgis::QGisProject terrame::qgis::QGis::read(const std::string& qgsfile)
+{
+ QgsReader reader;
+ reader.setPostgisRole(user, password);
+ return reader.read(qgsfile);
+}
+
+void terrame::qgis::QGis::write(const QGisProject& qgp)
+{
+ QgsWriter writer;
+
+ if (boost::filesystem::exists(qgp.getFile()))
+ {
+ QGisProject fileQgp = getInstance().read(qgp.getFile());
+ std::vector layersInFile = fileQgp.getLayers();
+ std::vector layersParam = qgp.getLayers();
+ std::vector layersToAdd = fileQgp.getLayersDiff(qgp);
+ std::vector layersToRemove = qgp.getLayersDiff(fileQgp);
+
+ if(layersToAdd.size() > 0)
+ {
+ writer.addLayers(qgp, layersToAdd);
+ }
+
+ if(layersToRemove.size() > 0)
+ {
+ writer.removeLayers(qgp, layersToRemove);
+ }
+ }
+ else
+ {
+ writer.create(qgp);
+ }
+}
+
+void terrame::qgis::QGis::setPostgisRole(const std::string& user,
+ const std::string& password)
+{
+ this->user = user;
+ this->password = password;
+}
diff --git a/pool/shard010/C++/0111303_enumliterals.cpp b/pool/shard010/C++/0111303_enumliterals.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c17cb885b1e837cdcccbcc16e2d9196eba6bd25e
--- /dev/null
+++ b/pool/shard010/C++/0111303_enumliterals.cpp
@@ -0,0 +1,26 @@
+#include "enumliterals.h"
+
+#include "dock/pages/model/enumliteralsmodel.h"
+
+EnumLiterals::EnumLiterals(QWidget* parent) : PageBase(parent),ui(new Ui_GenericTable()),m_pModel(0)
+{
+ ui->setupUi(this);
+}
+
+EnumLiterals::~EnumLiterals()
+{
+ delete ui;
+}
+
+void EnumLiterals::setCurrentObject(UMLObject* o)
+{
+ if (!m_pModel) {
+ m_pModel = new EnumLiteralsModel(this);
+ ui->m_pTable->setModel(m_pModel);
+ ui->m_pTable->horizontalHeader()->setResizeMode(0,QHeaderView::Stretch);
+ for (int i=1;icolumnCount();i++) {
+ ui->m_pTable->horizontalHeader()->setResizeMode(i,QHeaderView::ResizeToContents);
+ }
+ }
+ m_pModel->setCurrentObject(o);
+}
\ No newline at end of file
diff --git a/pool/shard010/C++/0111308_playerwatcher.cpp b/pool/shard010/C++/0111308_playerwatcher.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a621b72a011001dde6374d7251c827553fe72c7e
--- /dev/null
+++ b/pool/shard010/C++/0111308_playerwatcher.cpp
@@ -0,0 +1,153 @@
+#include "playerwatcher.h"
+
+#include "playerinterface.h"
+#include "propertiesinterface.h"
+
+#include
+#include
+
+#include
+
+using namespace std;
+using namespace CppUtilities;
+
+namespace DBusSoundRecorder {
+
+inline ostream &operator<<(ostream &stream, const QString &str)
+{
+ return stream << str.toLocal8Bit().data();
+}
+
+PlayerWatcher::PlayerWatcher(const QString &appName, bool ignorePlaybackStatus, QObject *parent)
+ : QObject(parent)
+ , m_mediaPlayerInterfaceName(QStringLiteral("org.mpris.MediaPlayer2.%1").arg(appName))
+ , m_mediaPlayerServiceWatcher(
+ new QDBusServiceWatcher(m_mediaPlayerInterfaceName, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this))
+ , m_propertiesInterface(new OrgFreedesktopDBusPropertiesInterface(
+ m_mediaPlayerInterfaceName, QStringLiteral("/org/mpris/MediaPlayer2"), QDBusConnection::sessionBus(), this))
+ , m_playerInterface(new OrgMprisMediaPlayer2PlayerInterface(
+ m_mediaPlayerInterfaceName, QStringLiteral("/org/mpris/MediaPlayer2"), QDBusConnection::sessionBus(), this))
+ , m_isPlaying(false)
+ , m_isAd(false)
+ , m_trackNumber(0)
+ , m_diskNumber(0)
+ , m_silent(false)
+ , m_ignorePlaybackStatus(ignorePlaybackStatus)
+{
+ if (!connect(m_mediaPlayerServiceWatcher, &QDBusServiceWatcher::serviceOwnerChanged, this, &PlayerWatcher::serviceOwnerChanged)) {
+ cout << "Warning: Unable to connect \"serviceOwnerChanged\" signal of service watcher." << endl;
+ }
+ // The code below might not work with some players:
+ //if(!connect(m_propertiesInterface, &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged, this, &PlayerWatcher::propertiesChanged)) {
+ // cout << "Warning: Unable to connect \"PropertiesChanged\" signal of properties interface." << endl;
+ //}
+ // However, the following seems to work always:
+ if (!QDBusConnection::sessionBus().connect(m_mediaPlayerInterfaceName, QStringLiteral("/org/mpris/MediaPlayer2"),
+ QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"), this, SLOT(propertiesChanged()))) {
+ cout << "Warning: Unable to connect \"PropertiesChanged\" signal of properties interface." << endl;
+ }
+ propertiesChanged();
+}
+
+void PlayerWatcher::play()
+{
+ m_playerInterface->Play();
+}
+
+void PlayerWatcher::stop()
+{
+ m_playerInterface->Stop();
+}
+
+void PlayerWatcher::pause()
+{
+ m_playerInterface->Pause();
+}
+
+void PlayerWatcher::playPause()
+{
+ m_playerInterface->PlayPause();
+}
+
+void PlayerWatcher::serviceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner)
+{
+ if (oldOwner.isEmpty()) {
+ cerr << "MPRIS service \"" << service << "\" is now online" << endl;
+ }
+ if (newOwner.isEmpty()) {
+ cerr << "MPRIS service \"" << service << "\" went offline" << endl;
+ }
+}
+
+void PlayerWatcher::propertiesChanged()
+{
+ // get meta data
+ QVariantMap metadata = m_playerInterface->metadata();
+ m_isAd = metadata.value(QStringLiteral("mpris:trackid")).toString().startsWith(QLatin1String("spotify:ad"));
+ QString title = metadata.value(QStringLiteral("xesam:title")).toString();
+ QString album = metadata.value(QStringLiteral("xesam:album")).toString();
+ QString artist = metadata.value(QStringLiteral("xesam:artist")).toString();
+ bool isPlaying;
+ if (m_ignorePlaybackStatus) {
+ // determine playback status by checking whether there is a song title
+ isPlaying = !title.isEmpty();
+ } else {
+ isPlaying = !m_playerInterface->playbackStatus().compare(QLatin1String("playing"), Qt::CaseInsensitive);
+ }
+ if (isPlaying) {
+ if (!m_isPlaying) {
+ cerr << "Playback started" << endl;
+ }
+ // use title, album and artist to identify song
+ if (m_title != title || m_album != album || m_artist != artist) {
+ // next song playing
+ m_title = title;
+ m_album = album;
+ m_artist = artist;
+ // read additional meta data
+ m_year = metadata.value(QStringLiteral("xesam:contentCreated")).toString();
+ m_genre = metadata.value(QStringLiteral("xesam:genre")).toString();
+ m_trackNumber = metadata.value(QStringLiteral("xesam:tracknumber")).toUInt();
+ if (!m_trackNumber) {
+ m_trackNumber = metadata.value(QStringLiteral("xesam:trackNumber")).toUInt();
+ }
+ m_diskNumber = metadata.value(QStringLiteral("xesam:discnumber")).toUInt();
+ if (!m_diskNumber) {
+ m_diskNumber = metadata.value(QStringLiteral("xesam:discNumber")).toUInt();
+ }
+ m_length = TimeSpan(metadata.value(QStringLiteral("mpris:length")).toULongLong() * 10);
+ // notify
+ cerr << "Next song: " << m_title << endl;
+ if (!m_isPlaying && !m_silent) {
+ m_isPlaying = true;
+ emit playbackStarted();
+ }
+ if (!m_silent) {
+ m_isPlaying = true;
+ emit nextSong();
+ }
+ } else if (!m_isPlaying) {
+ if (!m_silent) {
+ m_isPlaying = true;
+ emit playbackStarted();
+ }
+ }
+ } else if (m_isPlaying) {
+ m_isPlaying = false;
+ cerr << "Playback stopped" << endl;
+ if (!m_silent) {
+ emit playbackStopped();
+ }
+ }
+}
+
+void PlayerWatcher::notificationReceived()
+{
+ cout << "It works!" << endl;
+}
+
+void PlayerWatcher::seeked(qlonglong pos)
+{
+ cerr << "Seeked: " << pos << endl;
+}
+} // namespace DBusSoundRecorder
diff --git a/pool/shard010/C++/0111312_MCASBench.cpp b/pool/shard010/C++/0111312_MCASBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..136c7070f70827a3c5fa764938ec81e45190e7f7
--- /dev/null
+++ b/pool/shard010/C++/0111312_MCASBench.cpp
@@ -0,0 +1,88 @@
+/**
+ * Copyright (C) 2011
+ * University of Rochester Department of Computer Science
+ * and
+ * Lehigh University Department of Computer Science and Engineering
+ *
+ * License: Modified BSD
+ * Please see the file LICENSE.RSTM for licensing information
+ */
+
+#if defined(STM_CPU_SPARC)
+#include
+#endif
+
+/**
+ * Step 1:
+ * Include the configuration code for the harness, and the API code.
+ */
+#include
+#include
+#include
+#include "bmconfig.hpp"
+
+/**
+ * We provide the option to build the entire benchmark in a single
+ * source. The bmconfig.hpp include defines all of the important functions
+ * that are implemented in this file, and bmharness.cpp defines the
+ * execution infrastructure.
+ */
+#ifdef SINGLE_SOURCE_BUILD
+#include "bmharness.cpp"
+#endif
+
+/**
+ * Step 2:
+ * Declare the data type that will be stress tested via this benchmark.
+ * Also provide any functions that will be needed to manipulate the data
+ * type. Take care to avoid unnecessary indirection.
+ */
+
+int* matrix;
+
+/**
+ * Step 3:
+ * Declare an instance of the data type, and provide init, test, and verify
+ * functions
+ */
+
+/*** Initialize an array that we can use for our MCAS test */
+void bench_init()
+{
+ matrix = (int*)malloc(CFG.elements * sizeof(int));
+}
+
+/*** Run a bunch of random transactions */
+void bench_test(uintptr_t, uint32_t* seed)
+{
+ // cache the seed locally so we can restore it on abort
+ //
+ // NB: volatile needed because using a non-volatile local in conjunction
+ // with a setjmp-longjmp control transfer is undefined, and gcc won't
+ // allow it with -Wall -Werror.
+ volatile uint32_t local_seed = *seed;
+
+ TM_BEGIN(atomic) {
+ for (uint32_t i = 0; i < CFG.ops; ++i) {
+ uint32_t loc = rand_r_32(&local_seed) % CFG.elements;
+ TM_WRITE(matrix[loc], 1 + TM_READ(matrix[loc]));
+ }
+ } TM_END;
+ *seed = local_seed;
+}
+
+/*** Ensure the final state of the benchmark satisfies all invariants */
+bool bench_verify() { return true; }
+
+/**
+ * Step 4:
+ * Include the code that has the main() function, and the code for creating
+ * threads and calling the three above-named functions. Don't forget to
+ * provide an arg reparser.
+ */
+
+/*** Deal with special names that map to different M values */
+void bench_reparse()
+{
+ if (CFG.bmname == "") CFG.bmname = "MCAS";
+}
diff --git a/pool/shard010/C++/0111313_File.cpp b/pool/shard010/C++/0111313_File.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ea694e97b4e37b0741a16b29970fbd3ce7fcf787
--- /dev/null
+++ b/pool/shard010/C++/0111313_File.cpp
@@ -0,0 +1,92 @@
+#include "File.h"
+
+#include
+#include
+
+#include
+
+
+/**
+ * @class File
+ * A file can be filled by a downloader or read by an uploader.
+ * It has a fixed size.
+ * 'read' and 'write' are thread safe and a 'QReadWriteLock'.
+ */
+
+/**
+ * Create a new empty file or open an existing one.
+ * If the file already exists the given size must match.
+ */
+File::File(const QString& name, quint64 size) throw(FileSizeDoesntMatchException)
+ : size(size)
+{
+ this->fileInWriteMode = new QFile(name);
+ if (this->fileInWriteMode->exists())
+ {
+ if ((quint64)this->fileInWriteMode->size() != this->size)
+ throw FileSizeDoesntMatchException();
+ }
+ this->fileInWriteMode->open(QIODevice::WriteOnly);
+ this->fileInWriteMode->resize(this->size); // Warning : can fail
+
+ this->fileInReadMode = new QFile(name);
+ this->fileInReadMode->open(QIODevice::ReadOnly);
+
+ quint64 offset = 0;
+ for (int chunkNum = 0; offset < size; offset += File::chunkSize, chunkNum++)
+ this->chunks.append(new Chunk(*this, chunkNum));
+}
+
+File::~File()
+{
+ this->fileInWriteMode->flush();
+
+ delete this->fileInWriteMode;
+ delete this->fileInReadMode;
+ foreach (Chunk* chunk, this->chunks)
+ delete chunk;
+}
+
+/**
+ * Write some bytes to the file at the given offset.
+ * If the buffer exceed the file size then only the beginning of the buffer is
+ * used, the file is not resizing.
+ */
+bool File::write(const QByteArray& buffer, qint64 offset)
+{
+ if ((quint64)offset >= this->size)
+ return true;
+
+ QMutexLocker locker(&this->writeLock);
+
+ this->fileInWriteMode->seek(offset);
+ int maxSize = (this->size - offset);
+ qint64 n = this->fileInWriteMode->write(buffer.data(), buffer.size() > maxSize ? maxSize : buffer.size());
+
+ return offset + n >= (qint64)this->size || n == -1;
+}
+
+/**
+ * Fill the buffer with the read bytes from the given offset.
+ * If the end of file is reached the buffer will be partialy filled.
+ */
+qint64 File::read(QByteArray& buffer, qint64 offset)
+{
+ if ((quint64)offset >= this->size)
+ return 0;
+
+ QMutexLocker locker(&this->readLock);
+
+ this->fileInReadMode->seek(offset);
+ qint64 bytesRead = this->fileInReadMode->read(buffer.data(), buffer.size());
+
+ return bytesRead;
+}
+
+/**
+ * Return a collection of the file's chunks.
+ */
+const QList& File::getChunks()
+{
+ return this->chunks;
+}
diff --git a/pool/shard010/C++/0111318_PersonalizeErrors.cpp b/pool/shard010/C++/0111318_PersonalizeErrors.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eeedf6c514c95aab847fd47c809856a0cc5b3dd9
--- /dev/null
+++ b/pool/shard010/C++/0111318_PersonalizeErrors.cpp
@@ -0,0 +1,57 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+#include
+
+using namespace Aws::Client;
+using namespace Aws::Utils;
+using namespace Aws::Personalize;
+
+namespace Aws
+{
+namespace Personalize
+{
+namespace PersonalizeErrorMapper
+{
+
+static const int RESOURCE_ALREADY_EXISTS_HASH = HashingUtils::HashString("ResourceAlreadyExistsException");
+static const int LIMIT_EXCEEDED_HASH = HashingUtils::HashString("LimitExceededException");
+static const int INVALID_INPUT_HASH = HashingUtils::HashString("InvalidInputException");
+static const int RESOURCE_IN_USE_HASH = HashingUtils::HashString("ResourceInUseException");
+static const int INVALID_NEXT_TOKEN_HASH = HashingUtils::HashString("InvalidNextTokenException");
+
+
+AWSError GetErrorForName(const char* errorName)
+{
+ int hashCode = HashingUtils::HashString(errorName);
+
+ if (hashCode == RESOURCE_ALREADY_EXISTS_HASH)
+ {
+ return AWSError(static_cast(PersonalizeErrors::RESOURCE_ALREADY_EXISTS), false);
+ }
+ else if (hashCode == LIMIT_EXCEEDED_HASH)
+ {
+ return AWSError(static_cast(PersonalizeErrors::LIMIT_EXCEEDED), true);
+ }
+ else if (hashCode == INVALID_INPUT_HASH)
+ {
+ return AWSError(static_cast(PersonalizeErrors::INVALID_INPUT), false);
+ }
+ else if (hashCode == RESOURCE_IN_USE_HASH)
+ {
+ return AWSError(static_cast(PersonalizeErrors::RESOURCE_IN_USE), false);
+ }
+ else if (hashCode == INVALID_NEXT_TOKEN_HASH)
+ {
+ return AWSError(static_cast(PersonalizeErrors::INVALID_NEXT_TOKEN), false);
+ }
+ return AWSError(CoreErrors::UNKNOWN, false);
+}
+
+} // namespace PersonalizeErrorMapper
+} // namespace Personalize
+} // namespace Aws
diff --git a/pool/shard010/C++/0111319_git.cpp b/pool/shard010/C++/0111319_git.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..03dc639d1944468ae6519a6a3ab52a99d9f30aac
--- /dev/null
+++ b/pool/shard010/C++/0111319_git.cpp
@@ -0,0 +1,169 @@
+// Copyright 2015 Stefano Pogliani
+#include
+
+#include "repositories/git/git.hpp"
+#include "repositories/git/internal/error.hpp"
+#include "repositories/git/internal/istream.hpp"
+
+using sf::exception::GitException;
+using sf::exception::GitInvalidVersion;
+using sf::exception::GitTypeError;
+
+using sf::repository::GitRepo;
+using sf::repository::GitRepoVersion;
+using sf::repository::RepositoryVersionRef;
+
+using sf::repository::internal::GitBlobStream;
+using sf::repository::internal::GitBlobStreamBuf;
+using sf::repository::internal::checkGitError;
+
+
+void GitRepo::ensure_repo_is_open() {
+ // Return if repository is open valid.
+ if (this->repo) {
+ return;
+ }
+
+ int error = git_repository_open(&this->repo, this->path.c_str());
+ checkGitError(error);
+}
+
+git_commit* GitRepo::resolveCommit(std::string revision) {
+ this->ensure_repo_is_open();
+
+ // Get object named by revision.
+ git_object* object = nullptr;
+ int error = git_revparse_single(&object, this->repo, revision.c_str());
+ checkGitError(error);
+
+ // Check type is commit.
+ if (git_object_type(object) != GIT_OBJ_COMMIT) {
+ git_object_free(object);
+ throw GitTypeError(GIT_OBJ_COMMIT, git_object_type(object));
+ }
+
+ return (git_commit*)object;
+}
+
+
+GitRepo::GitRepo(std::string path, std::string latest) {
+ this->latest_alias = latest;
+ this->path = path;
+ this->repo = nullptr;
+}
+
+GitRepo::~GitRepo() {
+ if (this->repo) {
+ git_repository_free(this->repo);
+ }
+}
+
+RepositoryVersionRef GitRepo::latest() {
+ return this->version(this->latest_alias);
+}
+
+RepositoryVersionRef GitRepo::version(std::string revision) {
+ git_commit* commit = this->resolveCommit(revision);
+ git_tree* tree = nullptr;
+
+ int error = git_commit_tree(&tree, commit);
+ git_commit_free(commit);
+
+ checkGitError(error);
+ return RepositoryVersionRef(new GitRepoVersion(this, tree));
+}
+
+std::string GitRepo::resolveVersion(
+ sf::state::Context context, const std::string version
+) {
+ this->verifyVersion(context, version);
+ git_commit* commit = nullptr;
+
+ // Resolve special version.
+ if (version == "") {
+ commit = this->resolveCommit(this->latest_alias);
+ } else {
+ commit = this->resolveCommit(version);
+ }
+
+ // Get commit ID.
+ char oidstr[GIT_OID_HEXSZ + 1];
+ git_oid_tostr(oidstr, sizeof(oidstr), git_commit_id(commit));
+
+ git_commit_free(commit);
+ return std::string(oidstr);
+}
+
+void GitRepo::verifyVersion(
+ sf::state::Context, const std::string version
+) {
+ // Try to resolve the commit.
+ try {
+ // Resolve special version.
+ if (version == "") {
+ this->resolveCommit(this->latest_alias);
+ } else {
+ this->resolveCommit(version);
+ }
+
+ } catch (GitTypeError&) {
+ throw GitInvalidVersion(version);
+
+ } catch (GitException& exc) {
+ // If the version cannot be parsed or the commit
+ // cannot be found throw an exception.
+ int code = exc.gitCode();
+ if (code == GIT_ENOTFOUND || code == GIT_EAMBIGUOUS) {
+ throw GitInvalidVersion(version);
+ }
+
+ // Otherwise propagate the original exception.
+ throw;
+ }
+}
+
+
+GitRepoVersion::GitRepoVersion(GitRepo* repo, git_tree* tree) {
+ this->repo = repo;
+ this->tree = tree;
+}
+
+GitRepoVersion::~GitRepoVersion() {
+ git_tree_free(this->tree);
+}
+
+bool GitRepoVersion::exists(const std::string path) {
+ git_tree_entry* entry = nullptr;
+ int error = git_tree_entry_bypath(&entry, this->tree, path.c_str());
+ if (error == GIT_ENOTFOUND) {
+ return false;
+ }
+
+ checkGitError(error);
+ git_tree_entry_free(entry);
+ return true;
+}
+
+std::istream* GitRepoVersion::streamFileRaw(const std::string path) {
+ // Get tree entry from path.
+ git_tree_entry* entry = nullptr;
+ int error = git_tree_entry_bypath(&entry, this->tree, path.c_str());
+ checkGitError(error);
+
+ // Check type is blob.
+ if (git_tree_entry_type(entry) != GIT_OBJ_BLOB) {
+ git_tree_entry_free(entry);
+ throw GitTypeError(GIT_OBJ_BLOB, git_tree_entry_type(entry));
+ }
+
+ // Convert to blob.
+ git_blob* blob = nullptr;
+ error = git_blob_lookup(&blob, this->repo->repo, git_tree_entry_id(entry));
+ git_tree_entry_free(entry);
+ checkGitError(error);
+
+ // Build stream and return.
+ GitBlobStreamBuf* buffer = new GitBlobStreamBuf(blob);
+ git_blob_free(blob);
+ return new GitBlobStream(buffer);
+}
diff --git a/pool/shard010/C++/0111322_net_converter.cc b/pool/shard010/C++/0111322_net_converter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5223709ae585f128ab9933e1d2c80c7b5aaa3eb5
--- /dev/null
+++ b/pool/shard010/C++/0111322_net_converter.cc
@@ -0,0 +1,99 @@
+// Copyright (c) 2015 GitHub, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#include "atom/common/native_mate_converters/net_converter.h"
+
+#include
+#include
+
+#include "atom/common/node_includes.h"
+#include "atom/common/native_mate_converters/gurl_converter.h"
+#include "atom/common/native_mate_converters/value_converter.h"
+#include "base/values.h"
+#include "native_mate/dictionary.h"
+#include "net/base/upload_bytes_element_reader.h"
+#include "net/base/upload_data_stream.h"
+#include "net/base/upload_element_reader.h"
+#include "net/base/upload_file_element_reader.h"
+#include "net/cert/x509_certificate.h"
+#include "net/http/http_response_headers.h"
+#include "net/url_request/url_request.h"
+
+namespace mate {
+
+// static
+v8::Local Converter::ToV8(
+ v8::Isolate* isolate, const net::URLRequest* val) {
+ scoped_ptr dict(new base::DictionaryValue);
+ dict->SetString("method", val->method());
+ std::string url;
+ if (!val->url_chain().empty()) url = val->url().spec();
+ dict->SetStringWithoutPathExpansion("url", url);
+ dict->SetString("referrer", val->referrer());
+ scoped_ptr list(new base::ListValue);
+ atom::GetUploadData(list.get(), val);
+ if (!list->empty())
+ dict->Set("uploadData", std::move(list));
+ return mate::ConvertToV8(isolate, *(dict.get()));
+}
+
+// static
+v8::Local Converter::ToV8(
+ v8::Isolate* isolate, const net::AuthChallengeInfo* val) {
+ mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
+ dict.Set("isProxy", val->is_proxy);
+ dict.Set("scheme", val->scheme);
+ dict.Set("host", val->challenger.host());
+ dict.Set("port", static_cast(val->challenger.port()));
+ dict.Set("realm", val->realm);
+ return mate::ConvertToV8(isolate, dict);
+}
+
+// static
+v8::Local Converter>::ToV8(
+ v8::Isolate* isolate, const scoped_refptr& val) {
+ mate::Dictionary dict(isolate, v8::Object::New(isolate));
+ std::string encoded_data;
+ net::X509Certificate::GetPEMEncoded(
+ val->os_cert_handle(), &encoded_data);
+ auto buffer = node::Buffer::Copy(isolate,
+ encoded_data.data(),
+ encoded_data.size()).ToLocalChecked();
+ dict.Set("data", buffer);
+ dict.Set("issuerName", val->issuer().GetDisplayName());
+ return dict.GetHandle();
+}
+
+} // namespace mate
+
+namespace atom {
+
+void GetUploadData(base::ListValue* upload_data_list,
+ const net::URLRequest* request) {
+ const net::UploadDataStream* upload_data = request->get_upload();
+ if (!upload_data)
+ return;
+ const std::vector>* readers =
+ upload_data->GetElementReaders();
+ for (const auto& reader : *readers) {
+ scoped_ptr upload_data_dict(
+ new base::DictionaryValue);
+ if (reader->AsBytesReader()) {
+ const net::UploadBytesElementReader* bytes_reader =
+ reader->AsBytesReader();
+ scoped_ptr bytes(
+ base::BinaryValue::CreateWithCopiedBuffer(bytes_reader->bytes(),
+ bytes_reader->length()));
+ upload_data_dict->Set("bytes", std::move(bytes));
+ } else if (reader->AsFileReader()) {
+ const net::UploadFileElementReader* file_reader =
+ reader->AsFileReader();
+ auto file_path = file_reader->path().AsUTF8Unsafe();
+ upload_data_dict->SetStringWithoutPathExpansion("file", file_path);
+ }
+ upload_data_list->Append(std::move(upload_data_dict));
+ }
+}
+
+} // namespace atom
diff --git a/pool/shard010/C++/0111323_ecma-lcache.cpp b/pool/shard010/C++/0111323_ecma-lcache.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5ce4aca499507ce934f20e85f9ca7054c692a8b5
--- /dev/null
+++ b/pool/shard010/C++/0111323_ecma-lcache.cpp
@@ -0,0 +1,348 @@
+/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
+ *
+ * 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 "ecma-gc.h"
+#include "ecma-globals.h"
+#include "ecma-helpers.h"
+#include "ecma-lcache.h"
+#include "jrt-libc-includes.h"
+
+/** \addtogroup ecma ECMA
+ * @{
+ *
+ * \addtogroup ecmalcache Property lookup cache
+ * @{
+ */
+
+#ifndef CONFIG_ECMA_LCACHE_DISABLE
+/**
+ * Entry of LCache hash table
+ */
+typedef struct
+{
+ /** Compressed pointer to object (ECMA_NULL_POINTER marks record empty) */
+ mem_cpointer_t object_cp;
+
+ /** Compressed pointer to property's name */
+ mem_cpointer_t prop_name_cp;
+
+ /** Compressed pointer to a property of the object */
+ mem_cpointer_t prop_cp;
+
+ /** Padding structure to 8 bytes size */
+ uint16_t padding;
+} ecma_lcache_hash_entry_t;
+
+JERRY_STATIC_ASSERT (sizeof (ecma_lcache_hash_entry_t) == sizeof (uint64_t));
+
+/**
+ * LCache hash value length, in bits
+ */
+#define ECMA_LCACHE_HASH_BITS (sizeof (lit_string_hash_t) * JERRY_BITSINBYTE)
+
+/**
+ * Number of rows in LCache's hash table
+ */
+#define ECMA_LCACHE_HASH_ROWS_COUNT (1ull << ECMA_LCACHE_HASH_BITS)
+
+/**
+ * Number of entries in a row of LCache's hash table
+ */
+#define ECMA_LCACHE_HASH_ROW_LENGTH (2)
+
+/**
+ * LCache's hash table
+ */
+static ecma_lcache_hash_entry_t ecma_lcache_hash_table[ ECMA_LCACHE_HASH_ROWS_COUNT ][ ECMA_LCACHE_HASH_ROW_LENGTH ];
+#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
+
+/**
+ * Initialize LCache
+ */
+void
+ecma_lcache_init (void)
+{
+#ifndef CONFIG_ECMA_LCACHE_DISABLE
+ memset (ecma_lcache_hash_table, 0, sizeof (ecma_lcache_hash_table));
+#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
+} /* ecma_lcache_init */
+
+#ifndef CONFIG_ECMA_LCACHE_DISABLE
+/**
+ * Invalidate specified LCache entry
+ */
+static void
+ecma_lcache_invalidate_entry (ecma_lcache_hash_entry_t *entry_p) /**< entry to invalidate */
+{
+ JERRY_ASSERT (entry_p != NULL);
+ JERRY_ASSERT (entry_p->object_cp != ECMA_NULL_POINTER);
+
+ ecma_deref_object (ECMA_GET_NON_NULL_POINTER (ecma_object_t,
+ entry_p->object_cp));
+
+ entry_p->object_cp = ECMA_NULL_POINTER;
+ ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t,
+ entry_p->prop_name_cp));
+
+ if (entry_p->prop_cp != ECMA_NULL_POINTER)
+ {
+ ecma_set_property_lcached (ECMA_GET_NON_NULL_POINTER (ecma_property_t,
+ entry_p->prop_cp),
+ false);
+ }
+} /* ecma_lcache_invalidate_entry */
+#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
+
+/**
+ * Invalidate all entries in LCache
+ */
+void
+ecma_lcache_invalidate_all (void)
+{
+#ifndef CONFIG_ECMA_LCACHE_DISABLE
+ for (uint32_t row_index = 0; row_index < ECMA_LCACHE_HASH_ROWS_COUNT; row_index++)
+ {
+ for (uint32_t entry_index = 0; entry_index < ECMA_LCACHE_HASH_ROW_LENGTH; entry_index++)
+ {
+ if (ecma_lcache_hash_table[ row_index ][ entry_index ].object_cp != ECMA_NULL_POINTER)
+ {
+ ecma_lcache_invalidate_entry (&ecma_lcache_hash_table[ row_index ][ entry_index ]);
+ }
+ }
+ }
+#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
+} /* ecma_lcache_invalidate_all */
+
+#ifndef CONFIG_ECMA_LCACHE_DISABLE
+/**
+ * Invalidate entries of LCache's row that correspond to given (object, property) pair
+ */
+static void
+ecma_lcache_invalidate_row_for_object_property_pair (uint32_t row_index, /**< index of the row */
+ unsigned int object_cp, /**< compressed pointer
+ * to an object */
+ unsigned property_cp) /**< compressed pointer
+ * to the object's
+ * property */
+{
+ for (uint32_t entry_index = 0; entry_index < ECMA_LCACHE_HASH_ROW_LENGTH; entry_index++)
+ {
+ if (ecma_lcache_hash_table[ row_index ][ entry_index ].object_cp == object_cp
+ && ecma_lcache_hash_table[ row_index ][ entry_index ].prop_cp == property_cp)
+ {
+ ecma_lcache_invalidate_entry (&ecma_lcache_hash_table[ row_index ][ entry_index ]);
+ }
+ }
+} /* ecma_lcache_invalidate_row_for_object_property_pair */
+#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
+
+/**
+ * Insert an entry into LCache
+ */
+void
+ecma_lcache_insert (ecma_object_t *object_p, /**< object */
+ ecma_string_t *prop_name_p, /**< property's name */
+ ecma_property_t *prop_p) /**< pointer to associated property or NULL
+ * (NULL indicates that the object doesn't have property
+ * with the name specified) */
+{
+ JERRY_ASSERT (object_p != NULL);
+ JERRY_ASSERT (prop_name_p != NULL);
+
+#ifndef CONFIG_ECMA_LCACHE_DISABLE
+ prop_name_p = ecma_copy_or_ref_ecma_string (prop_name_p);
+
+ lit_string_hash_t hash_key = ecma_string_hash (prop_name_p);
+
+ if (prop_p != NULL)
+ {
+ if (unlikely (ecma_is_property_lcached (prop_p)))
+ {
+ mem_cpointer_t prop_cp;
+ ECMA_SET_NON_NULL_POINTER (prop_cp, prop_p);
+
+ int32_t entry_index;
+ for (entry_index = 0; entry_index < ECMA_LCACHE_HASH_ROW_LENGTH; entry_index++)
+ {
+ if (ecma_lcache_hash_table[hash_key][entry_index].object_cp != ECMA_NULL_POINTER
+ && ecma_lcache_hash_table[hash_key][entry_index].prop_cp == prop_cp)
+ {
+#ifndef JERRY_NDEBUG
+ ecma_object_t* obj_in_entry_p;
+ obj_in_entry_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t,
+ ecma_lcache_hash_table[hash_key][entry_index].object_cp);
+ JERRY_ASSERT (obj_in_entry_p == object_p);
+#endif /* !JERRY_NDEBUG */
+ break;
+ }
+ }
+
+ JERRY_ASSERT (entry_index != ECMA_LCACHE_HASH_ROW_LENGTH);
+ ecma_lcache_invalidate_entry (&ecma_lcache_hash_table[hash_key][entry_index]);
+ }
+
+ JERRY_ASSERT (!ecma_is_property_lcached (prop_p));
+ ecma_set_property_lcached (prop_p, true);
+ }
+
+ int32_t entry_index;
+ for (entry_index = 0; entry_index < ECMA_LCACHE_HASH_ROW_LENGTH; entry_index++)
+ {
+ if (ecma_lcache_hash_table[hash_key][entry_index].object_cp == ECMA_NULL_POINTER)
+ {
+ break;
+ }
+ }
+
+ if (entry_index == ECMA_LCACHE_HASH_ROW_LENGTH)
+ {
+ /* No empty entry was found, invalidating the whole row */
+ for (uint32_t i = 0; i < ECMA_LCACHE_HASH_ROW_LENGTH; i++)
+ {
+ ecma_lcache_invalidate_entry (&ecma_lcache_hash_table[hash_key][i]);
+ }
+
+ entry_index = 0;
+ }
+
+ ecma_ref_object (object_p);
+ ECMA_SET_NON_NULL_POINTER (ecma_lcache_hash_table[ hash_key ][ entry_index ].object_cp, object_p);
+ ECMA_SET_NON_NULL_POINTER (ecma_lcache_hash_table[ hash_key ][ entry_index ].prop_name_cp, prop_name_p);
+ ECMA_SET_POINTER (ecma_lcache_hash_table[ hash_key ][ entry_index ].prop_cp, prop_p);
+#else /* CONFIG_ECMA_LCACHE_DISABLE */
+ (void) prop_p;
+#endif /* CONFIG_ECMA_LCACHE_DISABLE */
+} /* ecma_lcache_insert */
+
+/**
+ * Lookup property in the LCache
+ *
+ * @return true - if (object, property name) pair is registered in LCache,
+ * false - probably, not registered.
+ */
+bool __attr_always_inline___
+ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
+ const ecma_string_t *prop_name_p, /**< property's name */
+ ecma_property_t **prop_p_p) /**< out: if return value is true,
+ * then here will be pointer to property,
+ * if the object contains property with specified name,
+ * or, otherwise - NULL;
+ * if return value is false,
+ * then the output parameter is not set */
+{
+#ifndef CONFIG_ECMA_LCACHE_DISABLE
+ lit_string_hash_t hash_key = ecma_string_hash (prop_name_p);
+
+ unsigned int object_cp;
+ ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
+
+ for (uint32_t i = 0; i < ECMA_LCACHE_HASH_ROW_LENGTH; i++)
+ {
+ if (ecma_lcache_hash_table[hash_key][i].object_cp == object_cp)
+ {
+ ecma_string_t *entry_prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
+ ecma_lcache_hash_table[hash_key][i].prop_name_cp);
+
+ if (ecma_compare_ecma_strings_equal_hashes (prop_name_p, entry_prop_name_p))
+ {
+ ecma_property_t *prop_p = ECMA_GET_POINTER (ecma_property_t, ecma_lcache_hash_table[hash_key][i].prop_cp);
+ JERRY_ASSERT (prop_p == NULL || ecma_is_property_lcached (prop_p));
+
+ *prop_p_p = prop_p;
+
+ return true;
+ }
+ else
+ {
+ /* may be equal but it is long to compare it here */
+ }
+ }
+ }
+#else /* CONFIG_ECMA_LCACHE_DISABLE */
+ (void) object_p;
+ (void) prop_name_p;
+ (void) prop_p_p;
+#endif /* CONFIG_ECMA_LCACHE_DISABLE */
+
+ return false;
+} /* ecma_lcache_lookup */
+
+/**
+ * Invalidate LCache entries associated with given object and property name / property
+ *
+ * Note:
+ * Either property name argument or property argument should be NULL,
+ * and another should be non-NULL.
+ * In case property name argument is NULL, property's name is taken
+ * from property's description.
+ */
+void
+ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
+ ecma_string_t *prop_name_arg_p, /**< property's name (See also: Note) */
+ ecma_property_t *prop_p) /**< property (See also: Note) */
+{
+ JERRY_ASSERT (object_p != NULL);
+ JERRY_ASSERT (prop_p != NULL || prop_name_arg_p != NULL);
+
+#ifndef CONFIG_ECMA_LCACHE_DISABLE
+ ecma_string_t *prop_name_p = NULL;
+
+ if (prop_p != NULL)
+ {
+ JERRY_ASSERT (prop_p->type == ECMA_PROPERTY_NAMEDDATA
+ || prop_p->type == ECMA_PROPERTY_NAMEDACCESSOR);
+
+ bool is_cached = ecma_is_property_lcached (prop_p);
+
+ if (!is_cached)
+ {
+ return;
+ }
+
+ ecma_set_property_lcached (prop_p, false);
+
+ if (prop_p->type == ECMA_PROPERTY_NAMEDDATA)
+ {
+ prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
+ prop_p->u.named_data_property.name_p);
+ }
+ else
+ {
+ prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
+ prop_p->u.named_accessor_property.name_p);
+ }
+ }
+ else
+ {
+ prop_name_p = prop_name_arg_p;
+ }
+
+ unsigned int object_cp, prop_cp;
+ ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
+ ECMA_SET_POINTER (prop_cp, prop_p);
+
+ lit_string_hash_t hash_key = ecma_string_hash (prop_name_p);
+
+ /* Property's name has was computed.
+ * Given (object, property name) pair should be in the row corresponding to computed hash.
+ */
+ ecma_lcache_invalidate_row_for_object_property_pair (hash_key, object_cp, prop_cp);
+#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
+} /* ecma_lcache_invalidate */
+
+/**
+ * @}
+ * @}
+ */
diff --git a/pool/shard010/C++/0111328_vectorv.cc b/pool/shard010/C++/0111328_vectorv.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0efff4172e3e650604eb8f5d4aef78ff10f685f3
--- /dev/null
+++ b/pool/shard010/C++/0111328_vectorv.cc
@@ -0,0 +1,154 @@
+/*
+ * vectorv.cc -- template specialization for Vector
+ * Eddie Kohler
+ *
+ * Copyright (c) 1999-2000 Massachusetts Institute of Technology
+ *
+ * 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, subject to the conditions
+ * listed in the Click LICENSE file. These conditions include: you must
+ * preserve this copyright notice, and you cannot mention the copyright
+ * holders in advertising related to the Software without their permission.
+ * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
+ * notice is a summary of the Click LICENSE file; the license in that file is
+ * legally binding.
+ */
+
+#include
+#include
+#include
+CLICK_DECLS
+
+Vector::Vector(const Vector &x)
+ : _l(0), _n(0), _capacity(0)
+{
+ *this = x;
+}
+
+Vector::~Vector()
+{
+ CLICK_LFREE(_l, sizeof(void *) * _capacity);
+}
+
+Vector &
+Vector::operator=(const Vector &o)
+{
+ if (&o != this) {
+#ifdef VALGRIND_MAKE_MEM_NOACCESS
+ if (_l && _n)
+ VALGRIND_MAKE_MEM_NOACCESS(_l, _n * sizeof(void *));
+#endif
+ _n = 0;
+ if (reserve(o._n)) {
+ _n = o._n;
+#ifdef VALGRIND_MAKE_MEM_UNDEFINED
+ if (_l && _n)
+ VALGRIND_MAKE_MEM_UNDEFINED(_l, _n * sizeof(void *));
+#endif
+ memcpy(_l, o._l, sizeof(void *) * _n);
+ }
+ }
+ return *this;
+}
+
+Vector &
+Vector::assign(size_type n, void* e)
+{
+#ifdef VALGRIND_MAKE_MEM_NOACCESS
+ if (_l && _n)
+ VALGRIND_MAKE_MEM_NOACCESS(_l, _n * sizeof(void *));
+#endif
+ _n = 0;
+ resize(n, e);
+ return *this;
+}
+
+Vector::iterator
+Vector::insert(iterator i, void* e)
+{
+ assert(i >= begin() && i <= end());
+ size_type pos = i - begin();
+ if (_n < _capacity || reserve(RESERVE_GROW)) {
+#ifdef VALGRIND_MAKE_MEM_UNDEFINED
+ VALGRIND_MAKE_MEM_UNDEFINED(_l + _n, sizeof(void*));
+#endif
+ i = begin() + pos;
+ memmove(i + 1, i, (end() - i) * sizeof(void*));
+ *i = e;
+ _n++;
+ }
+ return i;
+}
+
+Vector::iterator
+Vector::erase(iterator a, iterator b)
+{
+ if (b > a) {
+ assert(a >= begin() && b <= end());
+ memmove(a, b, (end() - b) * sizeof(void*));
+ _n -= b - a;
+#ifdef VALGRIND_MAKE_MEM_NOACCESS
+ VALGRIND_MAKE_MEM_NOACCESS(_l + _n, (b - a) * sizeof(void *));
+#endif
+ return a;
+ } else
+ return b;
+}
+
+bool
+Vector::reserve(size_type want)
+{
+ if (want < 0)
+ want = (_capacity > 0 ? _capacity * 2 : 4);
+ if (want <= _capacity)
+ return true;
+
+ void** new_l = (void **) CLICK_LALLOC(sizeof(void *) * want);
+ if (!new_l)
+ return false;
+#ifdef VALGRIND_MAKE_MEM_NOACCESS
+ VALGRIND_MAKE_MEM_NOACCESS(new_l + _n, (want - _n) * sizeof(void *));
+#endif
+
+ memcpy(new_l, _l, sizeof(void*) * _n);
+ CLICK_LFREE(_l, sizeof(void *) * _capacity);
+
+ _l = new_l;
+ _capacity = want;
+ return true;
+}
+
+void
+Vector::resize(size_type nn, void* e)
+{
+ if (nn <= _capacity || reserve(nn)) {
+#ifdef VALGRIND_MAKE_MEM_NOACCESS
+ if (nn < _n)
+ VALGRIND_MAKE_MEM_NOACCESS(_l + nn, (_n - nn) * sizeof(void *));
+ if (_n < nn)
+ VALGRIND_MAKE_MEM_UNDEFINED(_l + _n, (nn - _n) * sizeof(void *));
+#endif
+ for (size_type i = _n; i < nn; i++)
+ _l[i] = e;
+ _n = nn;
+ }
+}
+
+void
+Vector::swap(Vector &x)
+{
+ void **l = _l;
+ _l = x._l;
+ x._l = l;
+
+ size_type n = _n;
+ _n = x._n;
+ x._n = n;
+
+ size_type cap = _capacity;
+ _capacity = x._capacity;
+ x._capacity = cap;
+}
+
+CLICK_ENDDECLS
diff --git a/pool/shard010/C++/0111333_RotateTransformOperation.cpp b/pool/shard010/C++/0111333_RotateTransformOperation.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e64cd7d1e0846a0244d9453d5837ae585b115951
--- /dev/null
+++ b/pool/shard010/C++/0111333_RotateTransformOperation.cpp
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "platform/transforms/RotateTransformOperation.h"
+
+#include "platform/animation/AnimationUtilities.h"
+#include "platform/geometry/FloatPoint3D.h"
+#include "wtf/MathExtras.h"
+#include
+
+using namespace std;
+
+namespace blink {
+
+static const double angleEpsilon = 1e-4;
+
+FloatPoint3D RotateTransformOperation::axis() const
+{
+ return FloatPoint3D(x(), y(), z());
+}
+
+bool RotateTransformOperation::shareSameAxis(const RotateTransformOperation* from, const RotateTransformOperation* to, FloatPoint3D* axis, double* fromAngle, double* toAngle)
+{
+ *axis = FloatPoint3D(0, 0, 1);
+ *fromAngle = 0;
+ *toAngle = 0;
+
+ if (!from && !to)
+ return true;
+
+ bool fromZero = !from || from->axis().isZero();
+ bool toZero = !to || to->axis().isZero();
+
+ if (fromZero && toZero)
+ return true;
+
+ if (fromZero) {
+ *axis = to->axis();
+ *toAngle = to->angle();
+ return true;
+ }
+
+ if (toZero) {
+ *axis = from->axis();
+ *fromAngle = from->angle();
+ return true;
+ }
+
+ FloatPoint3D fromAxis = from->axis();
+ FloatPoint3D toAxis = to->axis();
+
+ double fromSquared = fromAxis.lengthSquared();
+ double toSquared = toAxis.lengthSquared();
+
+ double dot = fromAxis.dot(toAxis);
+ double error = std::abs(1 - (dot * dot) / (fromSquared * toSquared));
+
+ if (error > angleEpsilon)
+ return false;
+ *axis = from->axis();
+ *fromAngle = from->angle();
+ *toAngle = to->angle();
+ return true;
+}
+
+PassRefPtr RotateTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)
+{
+ if (from && !from->isSameType(*this))
+ return this;
+
+ if (blendToIdentity)
+ return RotateTransformOperation::create(m_x, m_y, m_z, m_angle - m_angle * progress, m_type);
+
+ const RotateTransformOperation* fromOp = static_cast(from);
+
+ // Optimize for single axis rotation
+ if (!fromOp || (fromOp->m_x == 0 && fromOp->m_y == 0 && fromOp->m_z == 1) ||
+ (fromOp->m_x == 0 && fromOp->m_y == 1 && fromOp->m_z == 0) ||
+ (fromOp->m_x == 1 && fromOp->m_y == 0 && fromOp->m_z == 0)) {
+ double fromAngle = fromOp ? fromOp->m_angle : 0;
+ return RotateTransformOperation::create(fromOp ? fromOp->m_x : m_x,
+ fromOp ? fromOp->m_y : m_y,
+ fromOp ? fromOp->m_z : m_z,
+ blink::blend(fromAngle, m_angle, progress), m_type);
+ }
+ double fromAngle;
+ double toAngle;
+ FloatPoint3D axis;
+
+ if (shareSameAxis(fromOp, this, &axis, &fromAngle, &toAngle))
+ return RotateTransformOperation::create(axis.x(), axis.y(), axis.z(), blink::blend(fromAngle, toAngle, progress), m_type);
+
+ const RotateTransformOperation* toOp = this;
+
+ // Create the 2 rotation matrices
+ TransformationMatrix fromT;
+ TransformationMatrix toT;
+ fromT.rotate3d((fromOp ? fromOp->m_x : 0),
+ (fromOp ? fromOp->m_y : 0),
+ (fromOp ? fromOp->m_z : 1),
+ (fromOp ? fromOp->m_angle : 0));
+
+ toT.rotate3d((toOp ? toOp->m_x : 0),
+ (toOp ? toOp->m_y : 0),
+ (toOp ? toOp->m_z : 1),
+ (toOp ? toOp->m_angle : 0));
+
+ // Blend them
+ toT.blend(fromT, progress);
+
+ // Extract the result as a quaternion
+ TransformationMatrix::DecomposedType decomp;
+ toT.decompose(decomp);
+
+ // Convert that to Axis/Angle form
+ double x = -decomp.quaternionX;
+ double y = -decomp.quaternionY;
+ double z = -decomp.quaternionZ;
+ double length = sqrt(x * x + y * y + z * z);
+ double angle = 0;
+
+ if (length > 0.00001) {
+ x /= length;
+ y /= length;
+ z /= length;
+ angle = rad2deg(acos(decomp.quaternionW) * 2);
+ } else {
+ x = 0;
+ y = 0;
+ z = 1;
+ }
+ return RotateTransformOperation::create(x, y, z, angle, Rotate3D);
+}
+
+bool RotateTransformOperation::canBlendWith(const TransformOperation& other) const
+{
+ return other.isSameType(*this);
+}
+
+} // namespace blink
diff --git a/pool/shard010/C++/0111335_RetainedDOMInfo.cpp b/pool/shard010/C++/0111335_RetainedDOMInfo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b12969fc73df789424b5bb2e3a81147f89ec3fd6
--- /dev/null
+++ b/pool/shard010/C++/0111335_RetainedDOMInfo.cpp
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RetainedDOMInfo.h"
+
+#include "ContainerNode.h"
+
+namespace WebCore {
+
+RetainedDOMInfo::RetainedDOMInfo(Node* root)
+ : m_root(root)
+{
+ ASSERT(m_root);
+}
+
+RetainedDOMInfo::~RetainedDOMInfo()
+{
+}
+
+void RetainedDOMInfo::Dispose()
+{
+ delete this;
+}
+
+bool RetainedDOMInfo::IsEquivalent(v8::RetainedObjectInfo* other)
+{
+ ASSERT(other);
+ return other == this || static_cast(other)->GetEquivalenceClass() == this->GetEquivalenceClass();
+}
+
+intptr_t RetainedDOMInfo::GetHash()
+{
+ return PtrHash::hash(m_root);
+}
+
+const char* RetainedDOMInfo::GetGroupLabel()
+{
+ return m_root->inDocument() ? "(Document DOM trees)" : "(Detached DOM trees)";
+}
+
+const char* RetainedDOMInfo::GetLabel()
+{
+ return m_root->inDocument() ? "Document DOM tree" : "Detached DOM tree";
+}
+
+intptr_t RetainedDOMInfo::GetElementCount()
+{
+ intptr_t count = 1;
+ Node* current = m_root;
+ while (current) {
+ current = current->traverseNextNode(m_root);
+ ++count;
+ }
+ return count;
+}
+
+intptr_t RetainedDOMInfo::GetEquivalenceClass()
+{
+ return reinterpret_cast(m_root);
+}
+
+} // namespace WebCore
diff --git a/pool/shard010/C++/0111336_matrix_exponential_op.cc b/pool/shard010/C++/0111336_matrix_exponential_op.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4cc3f32f7e4a727fa2d9ec3c21a3750111f46392
--- /dev/null
+++ b/pool/shard010/C++/0111336_matrix_exponential_op.cc
@@ -0,0 +1,59 @@
+/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==============================================================================*/
+
+// See docs in ../ops/linalg_ops.cc.
+
+#include "third_party/eigen3/Eigen/Core"
+#include "third_party/eigen3/unsupported/Eigen/MatrixFunctions"
+#include "tensorflow/core/framework/kernel_def_builder.h"
+#include "tensorflow/core/framework/op_kernel.h"
+#include "tensorflow/core/framework/tensor_shape.h"
+#include "tensorflow/core/kernels/linalg_ops_common.h"
+#include "tensorflow/core/lib/core/errors.h"
+#include "tensorflow/core/platform/logging.h"
+#include "tensorflow/core/platform/macros.h"
+#include "tensorflow/core/platform/types.h"
+
+
+namespace tensorflow {
+
+template
+class MatrixExponentialOp : public LinearAlgebraOp {
+ public:
+ INHERIT_LINALG_TYPEDEFS(Scalar);
+
+ explicit MatrixExponentialOp(OpKernelConstruction* context) : Base(context) {}
+
+ void ComputeMatrix(OpKernelContext* context, const ConstMatrixMaps& inputs,
+ MatrixMaps* outputs) final {
+ const ConstMatrixMap& input = inputs[0];
+ if (input.rows() == 0) return;
+ using Matrix = Eigen::Matrix;
+ Matrix tmp = input;
+ outputs->at(0) = tmp.exp();
+ }
+
+ private:
+ TF_DISALLOW_COPY_AND_ASSIGN(MatrixExponentialOp);
+};
+
+REGISTER_LINALG_OP("MatrixExponential", (MatrixExponentialOp), float);
+REGISTER_LINALG_OP("MatrixExponential", (MatrixExponentialOp), double);
+REGISTER_LINALG_OP("MatrixExponential",
+ (MatrixExponentialOp), complex64);
+REGISTER_LINALG_OP("MatrixExponential",
+ (MatrixExponentialOp), complex128);
+
+} // namespace tensorflow
diff --git a/pool/shard010/C++/0111338_inireader.cpp b/pool/shard010/C++/0111338_inireader.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d9041fdf1f7f7ec810e4a289b92392331a70e38f
--- /dev/null
+++ b/pool/shard010/C++/0111338_inireader.cpp
@@ -0,0 +1,47 @@
+#include "stdafx.h"
+#include
+
+char Path[MAX_PATH];
+char iniFile[MAX_PATH];
+char Read[500];
+DWORD destsize = 500;
+//"E:\\VehicleData.ini"
+char* readIniString(char* Section, char* Key) {
+ GetPrivateProfileString(Section, Key, "NULL", Read, destsize, iniFile);
+ return Read;
+}
+DWORD readIniDWORD(char*Section, char* Key) {
+ DWORD ini = GetPrivateProfileInt(Section, Key, -1337, iniFile);
+ return ini;
+}
+void Init(HMODULE hModule) {
+ memset(Path, 0, sizeof(Path));
+
+ if (GetModuleFileNameA(hModule, Path, MAX_PATH) != 0) {
+ size_t slash = -1;
+
+ for (size_t i = 0; i < strlen(Path); i++) {
+ if (Path[i] == '/' || Path[i] == '\\') {
+ slash = i;
+ }
+ }
+
+ if (slash != -1) {
+ Path[slash + 1] = '\0';
+ strcpy_s(iniFile, Path);
+ strcat_s(iniFile, "VehicleData.ini");
+
+ }
+ else {
+ // Shitty manual mapper detected.
+ MessageBoxA(NULL, "Unable to parse target module path", "ERROR", MB_OK);
+ ExitProcess(0);
+ }
+ }
+ else {
+ // Shitty manual mapper detected.
+ MessageBoxA(NULL, "GetModuleFileNameA failed", "ERROR", MB_OK);
+ ExitProcess(0);
+ }
+}
+
diff --git a/pool/shard010/C++/0111339_BinaryNumber.cpp b/pool/shard010/C++/0111339_BinaryNumber.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6b5e8834830419f51746871767f2c5ef926c5c9d
--- /dev/null
+++ b/pool/shard010/C++/0111339_BinaryNumber.cpp
@@ -0,0 +1,86 @@
+/*--------------------------------------------------------------------------*
+
+ BinaryNumber.cpp
+
+ See BinaryNumber.h for notes on this class.
+
+ *--------------------------------------------------------------------------*/
+#include "BinaryNumber.h"
+
+#include // strlen
+#include // ARRAYSIZE
+
+namespace ExampleLib
+{
+ BinaryNumber::BinaryNumber(const char* stringValue)
+ :
+ _numericValue(0)
+ {
+ size_t stringLength = strlen(stringValue);
+ if (stringLength > MaxStringValueLength)
+ {
+ throw BinaryNumber::InvalidInputException();
+ }
+
+ const char* cursor = stringValue + stringLength - 1;
+ unsigned int placeValue = 1;
+ while(cursor >= stringValue)
+ {
+ switch(*cursor)
+ {
+ case '1':
+ _numericValue += ( unsigned short ) placeValue;
+ break;
+ case '0':
+ break;
+ default:
+ throw BinaryNumber::InvalidInputException();
+ }
+ placeValue *= 2;
+ cursor--;
+ }
+
+ PopulateStringValue(_numericValue);
+ }
+
+ BinaryNumber::BinaryNumber(unsigned short numericValue)
+ :
+ _numericValue(numericValue)
+ {
+ PopulateStringValue(numericValue);
+ }
+
+ void BinaryNumber::PopulateStringValue(unsigned short numericValue)
+ {
+ unsigned short value = numericValue;
+ char* cursor = _stringValue + MaxStringValueLength;
+ *cursor-- = '\0';
+
+ while(value > 0 && cursor >= _stringValue)
+ {
+ *cursor-- = (value & 1) ? '1' : '0';
+ value = value >> 1;
+ }
+ while(cursor >= _stringValue)
+ {
+ *cursor-- = '0';
+ }
+ }
+
+ BinaryNumber BinaryNumber::operator+(const BinaryNumber& rhs)
+ {
+ unsigned short sum = this->_numericValue + rhs._numericValue;
+ if (sum < this->_numericValue)
+ {
+ throw BinaryNumber::IntegerOverflowException();
+ }
+
+ return BinaryNumber(sum);
+ }
+
+ bool BinaryNumber::operator==(const BinaryNumber& rhs) const
+ {
+ return ((this->_numericValue == rhs._numericValue) &&
+ (strcmp(this->_stringValue, rhs._stringValue) == 0));
+ }
+}
\ No newline at end of file
diff --git a/pool/shard010/C++/0111341_qmllistselectionmodel.cpp b/pool/shard010/C++/0111341_qmllistselectionmodel.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b1a5588ab4f233482b61c149790bd70efd32c51f
--- /dev/null
+++ b/pool/shard010/C++/0111341_qmllistselectionmodel.cpp
@@ -0,0 +1,142 @@
+/*
+ Copyright (C) 2010 Klarälvdalens Datakonsult AB,
+ a KDAB Group company, info@kdab.net,
+ author Stephen Kelly
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
+ License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+*/
+
+#include "qmllistselectionmodel.h"
+
+#include
+#include
+
+QMLListSelectionModel::QMLListSelectionModel(QItemSelectionModel *selectionModel, QObject* parent)
+ : QObject(parent), m_selectionModel(selectionModel)
+{
+ connect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(selectionChanged()));
+}
+
+QMLListSelectionModel::QMLListSelectionModel(QAbstractItemModel* model, QObject* parent)
+ : QObject(parent), m_selectionModel(new QItemSelectionModel(model, this))
+{
+ connect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(selectionChanged()));
+}
+
+QItemSelectionModel* QMLListSelectionModel::selectionModel() const
+{
+ return m_selectionModel;
+}
+
+QList< int > QMLListSelectionModel::selection() const
+{
+ QList< int > list;
+ const QModelIndexList indexes = m_selectionModel->selectedRows();
+ foreach (const QModelIndex &index, indexes)
+ list << index.row();
+ return list;
+}
+
+bool QMLListSelectionModel::hasSelection() const
+{
+ return m_selectionModel->hasSelection();
+}
+
+int QMLListSelectionModel::currentRow() const
+{
+ const QModelIndexList indexes = m_selectionModel->selectedRows();
+ if (indexes.size() != 1)
+ return -1;
+ Q_ASSERT(indexes.first().isValid());
+ return indexes.first().row();
+}
+
+void QMLListSelectionModel::setCurrentRow(int row)
+{
+ select(row, QItemSelectionModel::ClearAndSelect);
+}
+
+qint64 QMLListSelectionModel::currentItemId() const
+{
+ const QModelIndexList indexes = m_selectionModel->selectedRows();
+ if (indexes.size() != 1)
+ return -1;
+ Q_ASSERT(indexes.first().isValid());
+ return indexes.first().data(Akonadi::EntityTreeModel::ItemIdRole).toLongLong();
+}
+
+void QMLListSelectionModel::setCurrentItemId(qint64 itemId)
+{
+ const QModelIndexList list = Akonadi::EntityTreeModel::modelIndexesForItem(m_selectionModel->model(), Akonadi::Item(itemId));
+ if (list.size() == 1) {
+ const QModelIndex idx = list.first();
+ m_selectionModel->select(QItemSelection(idx, idx), QItemSelectionModel::ClearAndSelect);
+ }
+}
+
+void QMLListSelectionModel::select(int row, int command)
+{
+ if (row < 0) {
+ clearSelection();
+ return;
+ }
+ static const int column = 0;
+ const QModelIndex idx = m_selectionModel->model()->index(row, column);
+ Q_ASSERT(idx.isValid());
+ QItemSelection sel(idx, idx);
+ QItemSelectionModel::SelectionFlags flags = static_cast(command);
+ m_selectionModel->select(sel, flags);
+}
+
+bool QMLListSelectionModel::requestNext()
+{
+ const QModelIndexList list = m_selectionModel->selectedRows();
+ if (list.isEmpty() || list.size() != 1)
+ return false;
+
+ const QModelIndex idx = list.first();
+ Q_ASSERT(idx.isValid());
+ const QModelIndex next = idx.sibling(idx.row() + 1, idx.column());
+ if (!next.isValid())
+ return false;
+
+ m_selectionModel->select(QItemSelection(next, next), QItemSelectionModel::ClearAndSelect);
+ return true;
+}
+
+bool QMLListSelectionModel::requestPrevious()
+{
+ const QModelIndexList list = m_selectionModel->selectedRows();
+ if (list.isEmpty() || list.size() != 1)
+ return false;
+
+ const QModelIndex idx = list.first();
+ Q_ASSERT(idx.isValid());
+ if (idx.row() == 0)
+ return false;
+
+ const QModelIndex previous = idx.sibling(idx.row() - 1, idx.column());
+ m_selectionModel->select(QItemSelection(previous, previous), QItemSelectionModel::ClearAndSelect);
+ return true;
+}
+
+void QMLListSelectionModel::clearSelection()
+{
+ // Don't call QItemSelectionModel::clearSelection. It is non-virtual so
+ // item selection models in chains can't react to it properly.
+ m_selectionModel->select(QItemSelection(), QItemSelectionModel::Clear);
+}
+
diff --git a/pool/shard010/C/0139063_fix-apple-kb.c b/pool/shard010/C/0139063_fix-apple-kb.c
new file mode 100644
index 0000000000000000000000000000000000000000..f98f29bcb808b5fe80a3a0f9956f467f456a5371
--- /dev/null
+++ b/pool/shard010/C/0139063_fix-apple-kb.c
@@ -0,0 +1,85 @@
+// http://apple.stackexchange.com/a/199958
+#include
+#include
+#include
+#include
+#include
+
+
+int main(int argc, char **argv) {
+ if (argc != 2 || strcmp(argv[1], "-h") == 0) {
+ printf("Pass a hidraw device as the first and only parameter!\n");
+ printf("You may find the right device with:\n");
+ printf(" dmesg | grep Apple | grep Keyboard | grep input0 | tail -1 | "
+ "sed -e 's/.hidraw\([[:digit:]]\+\)./\/dev\/hidraw\1/'\n");
+ return 1;
+ }
+ int fd, i, res, desc_size = 0;
+ char buf[256];
+ struct hidraw_devinfo info;
+ char *device = argv[1];
+ fd = open(device, O_RDWR | O_NONBLOCK);
+ if (fd < 0) {
+ perror("Unable to open device");
+ return 1;
+ }
+ memset(&info, 0, sizeof(info));
+ memset(buf, 0, sizeof(buf));
+ // Get Report Descriptor Size
+ res = ioctl(fd, HIDIOCGRDESCSIZE, &desc_size);
+ if (res < 0) {
+ perror("HIDIOCGRDESCSIZE");
+ }
+// if (desc_size != 75) {
+// printf("Error: unexpected descriptor size %d; you've probably got "
+// "the wrong hidraw device!\n", desc_size);
+// return 1;
+// }
+ // Get Raw Info
+ res = ioctl(fd, HIDIOCGRAWINFO, &info);
+ if (res < 0) {
+ perror("HIDIOCGRAWINFO");
+ } else {
+ if (info.vendor != 0x05ac) {
+ printf("Error: Wrong vendor ID, make sure you got the right "
+ "hidraw device!\n");
+ return 1;
+ }
+ if (info.product != 0x0250) {
+ printf("Warning: Unknown product ID 0x%x!\n", info.product);
+ }
+ }
+ // Get Feature
+ buf[0] = 0x09; // Report Number
+ res = ioctl(fd, HIDIOCGFEATURE(256), buf);
+ if (res < 0) {
+ perror("HIDIOCGFEATURE");
+ } else {
+ printf("HID Feature Report (before change):\n\t");
+ for (i = 0; i < res; i++) printf("%hhx ", buf[i]);
+ puts("\n");
+ }
+ // Set Feature
+ buf[0] = 0x09; // Report Number
+ buf[1] = 0x00; // Report data
+ buf[2] = 0x00; // padding
+ buf[3] = 0x00; // padding
+ res = ioctl(fd, HIDIOCSFEATURE(4), buf);
+ if (res < 0) {
+ perror("HIDIOCSFEATURE");
+ } else {
+ printf("Caps lock delay disabled.\n");
+ }
+ // Get Feature
+ buf[0] = 0x09; // Report Number
+ res = ioctl(fd, HIDIOCGFEATURE(256), buf);
+ if (res < 0) {
+ perror("HIDIOCGFEATURE");
+ } else {
+ printf("HID Feature Report (after change):\n\t");
+ for (i = 0; i < res; i++) printf("%hhx ", buf[i]);
+ puts("\n");
+ }
+ close(fd);
+ return 0;
+}
diff --git a/pool/shard010/C/0139064_btm_main.c b/pool/shard010/C/0139064_btm_main.c
new file mode 100644
index 0000000000000000000000000000000000000000..043e7fd01d97deb5887068c4bde2b9d4e37d9765
--- /dev/null
+++ b/pool/shard010/C/0139064_btm_main.c
@@ -0,0 +1,97 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2002-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the definition of the btm control block when
+ * BTM_DYNAMIC_MEMORY is used.
+ *
+ ******************************************************************************/
+
+#include "bt_types.h"
+#include "bt_target.h"
+#include
+#include "btm_int.h"
+#include "allocator.h"
+
+/* Global BTM control block structure
+*/
+#if BTM_DYNAMIC_MEMORY == FALSE
+tBTM_CB btm_cb;
+#else
+tBTM_CB *btm_cb_ptr;
+#endif
+
+/*******************************************************************************
+**
+** Function btm_init
+**
+** Description This function is called at BTM startup to allocate the
+** control block (if using dynamic memory), and initializes the
+** tracing level. It then initializes the various components of
+** btm.
+**
+** Returns void
+**
+*******************************************************************************/
+void btm_init (void)
+{
+#if BTM_DYNAMIC_MEMORY
+ btm_cb_ptr = (tBTM_CB *)osi_malloc(sizeof(tBTM_CB));
+#endif /* #if BTM_DYNAMIC_MEMORY */
+ /* All fields are cleared; nonzero fields are reinitialized in appropriate function */
+ memset(&btm_cb, 0, sizeof(tBTM_CB));
+ btm_cb.page_queue = fixed_queue_new(SIZE_MAX);
+ btm_cb.sec_pending_q = fixed_queue_new(SIZE_MAX);
+
+#if defined(BTM_INITIAL_TRACE_LEVEL)
+ btm_cb.trace_level = BTM_INITIAL_TRACE_LEVEL;
+#else
+ btm_cb.trace_level = BT_TRACE_LEVEL_NONE;
+#endif
+ /* Initialize BTM component structures */
+ btm_inq_db_init(); /* Inquiry Database and Structures */
+ btm_acl_init(); /* ACL Database and Structures */
+#if (SMP_INCLUDED == TRUE)
+ btm_sec_init(BTM_SEC_MODE_SP); /* Security Manager Database and Structures */
+#endif ///SMP_INCLUDED == TRUE
+#if BTM_SCO_INCLUDED == TRUE
+ btm_sco_init(); /* SCO Database and Structures (If included) */
+#endif
+
+ btm_dev_init(); /* Device Manager Structures & HCI_Reset */
+}
+
+
+/*******************************************************************************
+**
+** Function btm_free
+**
+** Description This function is called at btu core free the fixed queue
+**
+** Returns void
+**
+*******************************************************************************/
+void btm_free(void)
+{
+ fixed_queue_free(btm_cb.page_queue, osi_free_func);
+ fixed_queue_free(btm_cb.sec_pending_q, osi_free_func);
+#if BTM_DYNAMIC_MEMORY
+ FREE_AND_RESET(btm_cb_ptr);
+#endif
+}
diff --git a/pool/shard010/C/0139065_omap4460plus_hwmon_temp_sensor.c b/pool/shard010/C/0139065_omap4460plus_hwmon_temp_sensor.c
new file mode 100644
index 0000000000000000000000000000000000000000..aed431ecb4ac45540a92b24c37d6223b3822752d
--- /dev/null
+++ b/pool/shard010/C/0139065_omap4460plus_hwmon_temp_sensor.c
@@ -0,0 +1,244 @@
+/*
+ *
+ * OMAP4460 Plus bandgap on die sensor hwmon driver.
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ * J Keerthy
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+static const char *names[3] = { "mpu", "gpu", "core"};
+
+static ssize_t show_name(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct platform_device *pdev = container_of(dev,
+ struct platform_device, dev);
+ int id = pdev->id;
+
+ return sprintf(buf, names[id]);
+}
+
+static ssize_t show_temp_max(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ struct temp_sensor_hwmon *tsh = dev_get_drvdata(dev);
+ struct platform_device *pdev = container_of(dev,
+ struct platform_device, dev);
+ int id = pdev->id;
+ int temp;
+
+ temp = omap4460plus_scm_show_temp_max(tsh->scm_ptr, id);
+
+ return sprintf(buf, "%d\n", temp);
+}
+
+static ssize_t set_temp_max(struct device *dev,
+ struct device_attribute *devattr,
+ const char *buf, size_t count)
+{
+ struct temp_sensor_hwmon *tsh = dev_get_drvdata(dev);
+ struct platform_device *pdev = container_of(dev,
+ struct platform_device, dev);
+ int id = pdev->id, ret;
+ long val;
+
+ if (strict_strtol(buf, 10, &val))
+ return -EINVAL;
+ ret = omap4460plus_scm_set_temp_max(tsh->scm_ptr, id, val);
+ if (ret < 0)
+ return ret;
+
+ return count;
+}
+
+static ssize_t show_temp_max_hyst(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ struct temp_sensor_hwmon *tsh = dev_get_drvdata(dev);
+ struct platform_device *pdev = container_of(dev,
+ struct platform_device, dev);
+ int id = pdev->id;
+ int temp;
+
+ temp = omap4460plus_scm_show_temp_max_hyst(tsh->scm_ptr, id);
+
+ return sprintf(buf, "%d\n", temp);
+}
+
+static ssize_t set_temp_max_hyst(struct device *dev,
+ struct device_attribute *devattr,
+ const char *buf, size_t count)
+{
+ struct temp_sensor_hwmon *tsh = dev_get_drvdata(dev);
+ struct platform_device *pdev = container_of(dev,
+ struct platform_device, dev);
+ int id = pdev->id, ret;
+ long val;
+
+ if (strict_strtol(buf, 10, &val))
+ return -EINVAL;
+ ret = omap4460plus_scm_set_temp_max_hyst(tsh->scm_ptr, id, val);
+ if (ret < 0)
+ return ret;
+
+ return count;
+}
+
+static ssize_t show_update_interval(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ int time = 0;
+ struct temp_sensor_hwmon *tsh = dev_get_drvdata(dev);
+ struct platform_device *pdev = container_of(dev,
+ struct platform_device, dev);
+ int id = pdev->id;
+
+ time = omap4460plus_scm_show_update_interval(tsh->scm_ptr, id);
+
+ return sprintf(buf, "%d\n", time);
+}
+
+static ssize_t set_update_interval(struct device *dev,
+ struct device_attribute *devattr,
+ const char *buf, size_t count)
+{
+ struct temp_sensor_hwmon *tsh = dev_get_drvdata(dev);
+ struct platform_device *pdev = container_of(dev,
+ struct platform_device, dev);
+ int id = pdev->id;
+ unsigned long val;
+
+ if (strict_strtoul(buf, 10, &val))
+ return -EINVAL;
+
+ omap4460plus_scm_set_update_interval(tsh->scm_ptr, val, id);
+ return count;
+}
+
+static int read_temp(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ struct temp_sensor_hwmon *tsh = dev_get_drvdata(dev);
+ struct platform_device *pdev = container_of(dev,
+ struct platform_device, dev);
+ int id = pdev->id;
+ int temp;
+
+ temp = omap4460plus_scm_read_temp(tsh->scm_ptr, id);
+
+ return sprintf(buf, "%d\n", temp);
+}
+
+static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
+static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, read_temp, NULL, 0);
+static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max,
+ set_temp_max, 0);
+static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, show_temp_max_hyst,
+ set_temp_max_hyst, 0);
+static SENSOR_DEVICE_ATTR(update_interval, S_IWUSR | S_IRUGO,
+ show_update_interval, set_update_interval, 0);
+
+static struct attribute *temp_sensor_attributes[] = {
+ &dev_attr_name.attr,
+
+ &sensor_dev_attr_temp1_input.dev_attr.attr,
+ &sensor_dev_attr_temp1_max.dev_attr.attr,
+ &sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
+ &sensor_dev_attr_update_interval.dev_attr.attr,
+ NULL
+};
+
+static const struct attribute_group temp_sensor_group = {
+ .attrs = temp_sensor_attributes,
+};
+
+static int __devinit omap4460plus_temp_sensor_probe(struct platform_device
+ *pdev)
+{
+ int ret;
+ struct device *hwmon;
+
+ ret = sysfs_create_group(&pdev->dev.kobj, &temp_sensor_group);
+ if (ret)
+ goto err_sysfs;
+ hwmon = hwmon_device_register(&pdev->dev);
+ if (IS_ERR(hwmon)) {
+ dev_err(&pdev->dev, "hwmon_device_register failed.\n");
+ ret = PTR_ERR(hwmon);
+ goto err_reg;
+ }
+
+ return 0;
+
+err_reg:
+ sysfs_remove_group(&pdev->dev.kobj, &temp_sensor_group);
+err_sysfs:
+
+ return ret;
+}
+
+static int __devexit omap4460plus_temp_sensor_remove(struct platform_device
+ *pdev)
+{
+ hwmon_device_unregister(&pdev->dev);
+ sysfs_remove_group(&pdev->dev.kobj, &temp_sensor_group);
+
+ return 0;
+}
+
+static struct platform_driver omap4460plus_temp_sensor_driver = {
+ .probe = omap4460plus_temp_sensor_probe,
+ .remove = omap4460plus_temp_sensor_remove,
+ .driver = {
+ .name = "temp_sensor_hwmon",
+ },
+};
+
+static int __init omap4460plus_hwmon_temp_sensor_init(void)
+{
+ return platform_driver_register(&omap4460plus_temp_sensor_driver);
+}
+
+module_init(omap4460plus_hwmon_temp_sensor_init);
+
+static void __exit omap4460plus_hwmon_temp_sensor_exit(void)
+{
+ platform_driver_unregister(&omap4460plus_temp_sensor_driver);
+}
+
+module_exit(omap4460plus_hwmon_temp_sensor_exit);
+
+MODULE_DESCRIPTION("OMAP446X temperature sensor Hwmon Driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:" DRIVER_NAME);
+MODULE_AUTHOR("J Keerthy ");
diff --git a/pool/shard010/C/0139066_gsfcid.c b/pool/shard010/C/0139066_gsfcid.c
new file mode 100644
index 0000000000000000000000000000000000000000..fa5f12c458ce8e4de7b23890655d9ae445fab299
--- /dev/null
+++ b/pool/shard010/C/0139066_gsfcid.c
@@ -0,0 +1,209 @@
+/* Copyright (C) 2000 Aladdin Enterprises. All rights reserved.
+
+ This software is provided AS-IS with no warranty, either express or
+ implied.
+
+ This software is distributed under license and may not be copied,
+ modified or distributed except as expressly authorized under the terms
+ of the license contained in the file LICENSE in this distribution.
+
+ For more information about licensing, please refer to
+ http://www.ghostscript.com/licensing/. For information on
+ commercial licensing, go to http://www.artifex.com/licensing/ or
+ contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+ San Rafael, CA 94903, U.S.A., +1(415)492-9861.
+*/
+
+/* $Id: gsfcid.c,v 1.14 2005/01/13 16:58:07 igor Exp $ */
+/* Support for CID-keyed fonts */
+#include "memory_.h"
+#include "gx.h"
+#include "gsmatrix.h" /* for gsfont.h */
+#include "gsstruct.h"
+#include "gxfcid.h"
+#include "gserrors.h"
+
+/* CIDSystemInfo structure descriptors */
+public_st_cid_system_info();
+public_st_cid_system_info_element();
+
+/* CID-keyed font structure descriptors */
+public_st_gs_font_cid_data();
+public_st_gs_font_cid0();
+private
+ENUM_PTRS_WITH(font_cid0_enum_ptrs, gs_font_cid0 *pfcid0)
+{
+ index -= 2;
+ if (index < st_gs_font_cid_data_num_ptrs)
+ return ENUM_USING(st_gs_font_cid_data, &pfcid0->cidata.common,
+ sizeof(gs_font_cid_data), index);
+ ENUM_PREFIX(st_gs_font_base, st_gs_font_cid_data_num_ptrs);
+}
+ENUM_PTR(0, gs_font_cid0, cidata.FDArray);
+ENUM_PTR(1, gs_font_cid0, cidata.proc_data);
+ENUM_PTRS_END
+private
+RELOC_PTRS_WITH(font_cid0_reloc_ptrs, gs_font_cid0 *pfcid0);
+ RELOC_PREFIX(st_gs_font_base);
+ RELOC_USING(st_gs_font_cid_data, &pfcid0->cidata.common,
+ sizeof(st_gs_font_cid_data));
+ RELOC_VAR(pfcid0->cidata.FDArray);
+ RELOC_VAR(pfcid0->cidata.proc_data);
+RELOC_PTRS_END
+public_st_gs_font_cid1();
+private
+ENUM_PTRS_WITH(font_cid1_enum_ptrs, gs_font_cid1 *pfcid1)
+{
+ if (index < st_cid_system_info_num_ptrs)
+ return ENUM_USING(st_cid_system_info, &pfcid1->cidata.CIDSystemInfo,
+ sizeof(st_cid_system_info), index);
+ ENUM_PREFIX(st_gs_font_base, st_cid_system_info_num_ptrs);
+}
+ENUM_PTRS_END
+private
+RELOC_PTRS_WITH(font_cid1_reloc_ptrs, gs_font_cid1 *pfcid1);
+ RELOC_PREFIX(st_gs_font_base);
+ RELOC_USING(st_cid_system_info, &pfcid1->cidata.CIDSystemInfo,
+ sizeof(st_cid_system_info));
+RELOC_PTRS_END
+public_st_gs_font_cid2();
+private
+ENUM_PTRS_WITH(font_cid2_enum_ptrs, gs_font_cid2 *pfcid2)
+{
+ if (index < st_gs_font_cid_data_num_ptrs)
+ return ENUM_USING(st_gs_font_cid_data, &pfcid2->cidata.common,
+ sizeof(gs_font_cid_data), index);
+ ENUM_PREFIX(st_gs_font_type42, st_gs_font_cid_data_num_ptrs);
+}
+ENUM_PTRS_END
+private
+RELOC_PTRS_WITH(font_cid2_reloc_ptrs, gs_font_cid2 *pfcid2);
+ RELOC_PREFIX(st_gs_font_type42);
+ RELOC_USING(st_gs_font_cid_data, &pfcid2->cidata.common,
+ sizeof(st_gs_font_cid_data));
+RELOC_PTRS_END
+
+/* GC descriptor for allocating FDArray for CIDFontType 0 fonts. */
+gs_private_st_ptr(st_gs_font_type1_ptr, gs_font_type1 *, "gs_font_type1 *",
+ font1_ptr_enum_ptrs, font1_ptr_reloc_ptrs);
+gs_public_st_element(st_gs_font_type1_ptr_element, gs_font_type1 *,
+ "gs_font_type1 *[]", font1_ptr_element_enum_ptrs,
+ font1_ptr_element_reloc_ptrs, st_gs_font_type1_ptr);
+
+/*
+ * The CIDSystemInfo of a CMap may be null. We represent this by setting
+ * Registry and Ordering to empty strings, and Supplement to 0.
+ */
+void
+cid_system_info_set_null(gs_cid_system_info_t *pcidsi)
+{
+ memset(pcidsi, 0, sizeof(*pcidsi));
+}
+bool
+cid_system_info_is_null(const gs_cid_system_info_t *pcidsi)
+{
+ return (pcidsi->Registry.size == 0 && pcidsi->Ordering.size == 0 &&
+ pcidsi->Supplement == 0);
+}
+
+/*
+ * Get the CIDSystemInfo of a font. If the font is not a CIDFont,
+ * return NULL.
+ */
+const gs_cid_system_info_t *
+gs_font_cid_system_info(const gs_font *pfont)
+{
+ switch (pfont->FontType) {
+ case ft_CID_encrypted:
+ return &((const gs_font_cid0 *)pfont)->cidata.common.CIDSystemInfo;
+ case ft_CID_user_defined:
+ return &((const gs_font_cid1 *)pfont)->cidata.CIDSystemInfo;
+ case ft_CID_TrueType:
+ return &((const gs_font_cid2 *)pfont)->cidata.common.CIDSystemInfo;
+ default:
+ return 0;
+ }
+}
+
+/*
+ * Check CIDSystemInfo compatibility.
+ */
+bool
+gs_is_CIDSystemInfo_compatible(const gs_cid_system_info_t *info0,
+ const gs_cid_system_info_t *info1)
+{
+ if (info0 == NULL || info1 == NULL)
+ return false;
+ if (info0->Registry.size != info1->Registry.size)
+ return false;
+ if (info0->Ordering.size != info1->Ordering.size)
+ return false;
+ if (memcmp(info0->Registry.data, info1->Registry.data,
+ info0->Registry.size))
+ return false;
+ if (memcmp(info0->Ordering.data, info1->Ordering.data,
+ info0->Ordering.size))
+ return false;
+ return true;
+}
+
+/*
+ * Provide a default enumerate_glyph procedure for CIDFontType 0 fonts.
+ * Built for simplicity, not for speed.
+ */
+font_proc_enumerate_glyph(gs_font_cid0_enumerate_glyph); /* check prototype */
+int
+gs_font_cid0_enumerate_glyph(gs_font *font, int *pindex,
+ gs_glyph_space_t ignore_glyph_space,
+ gs_glyph *pglyph)
+{
+ gs_font_cid0 *const pfont = (gs_font_cid0 *)font;
+
+ while (*pindex < pfont->cidata.common.CIDCount) {
+ gs_glyph_data_t gdata;
+ int fidx;
+ gs_glyph glyph = (gs_glyph)(gs_min_cid_glyph + (*pindex)++);
+ int code;
+
+ gdata.memory = pfont->memory;
+ code = pfont->cidata.glyph_data((gs_font_base *)pfont, glyph,
+ &gdata, &fidx);
+ if (code < 0 || gdata.bits.size == 0)
+ continue;
+ *pglyph = glyph;
+ gs_glyph_data_free(&gdata, "gs_font_cid0_enumerate_glyphs");
+ return 0;
+ }
+ *pindex = 0;
+ return 0;
+}
+
+/* Return the font from the FDArray at the given index */
+const gs_font *
+gs_cid0_indexed_font(const gs_font *font, int fidx)
+{
+ gs_font_cid0 *const pfont = (gs_font_cid0 *)font;
+
+ if (font->FontType != ft_CID_encrypted) {
+ eprintf1("Unexpected font type: %d\n", font->FontType);
+ return 0;
+ }
+ return (const gs_font*) (pfont->cidata.FDArray[fidx]);
+}
+
+/* Check whether a CID font has a Type 2 subfont. */
+bool
+gs_cid0_has_type2(const gs_font *font)
+{
+ gs_font_cid0 *const pfont = (gs_font_cid0 *)font;
+ int i;
+
+ if (font->FontType != ft_CID_encrypted) {
+ eprintf1("Unexpected font type: %d\n", font->FontType);
+ return false;
+ }
+ for (i = 0; i < pfont->cidata.FDArray_size; i++)
+ if (((const gs_font *)pfont->cidata.FDArray[i])->FontType == ft_encrypted2)
+ return true;
+ return false;
+}
diff --git a/pool/shard010/C/0139067_main.c b/pool/shard010/C/0139067_main.c
new file mode 100644
index 0000000000000000000000000000000000000000..8285d2082eebe8013bc871053296e1f240888d98
--- /dev/null
+++ b/pool/shard010/C/0139067_main.c
@@ -0,0 +1,81 @@
+/*
+ * main.c - main body of program
+ *
+ * (C) 2005 Attila Grosz ( gyros @ freemail . hu )
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ *
+ */
+#include
+#include
+#include "block.h"
+
+static void copyright()
+{
+ printf( "CMD2CAS 1.0 (C) 2005 by Attila Grosz\n");
+}
+
+static void usage()
+{
+ copyright();
+ printf( "This program converts standard TRS-80/System-80 disk\n");
+ printf( "(CMD) files to tape (CAS) images.\n");
+ printf( "Syntax: cmd2cas