text
stringlengths
8
99.9k
meta
dict
/// /// Copyright (c) 2016 Dropbox, Inc. All rights reserved. /// /// Auto-generated by Stone, do not modify. /// #import <Foundation/Foundation.h> #import "DBSerializableProtocol.h" @class DBTEAMPOLICIESSharedFolderJoinPolicy; NS_ASSUME_NONNULL_BEGIN #pragma mark - API Object /// /// The `SharedFolderJoinPolicy` union. /// /// Policy governing which shared folders a team member can join. /// /// This class implements the `DBSerializable` protocol (serialize and /// deserialize instance methods), which is required for all Obj-C SDK API route /// objects. /// @interface DBTEAMPOLICIESSharedFolderJoinPolicy : NSObject <DBSerializable, NSCopying> #pragma mark - Instance fields /// The `DBTEAMPOLICIESSharedFolderJoinPolicyTag` enum type represents the /// possible tag states with which the `DBTEAMPOLICIESSharedFolderJoinPolicy` /// union can exist. typedef NS_CLOSED_ENUM(NSInteger, DBTEAMPOLICIESSharedFolderJoinPolicyTag){ /// Team members can only join folders shared by teammates. DBTEAMPOLICIESSharedFolderJoinPolicyFromTeamOnly, /// Team members can join any shared folder, including those shared by users /// outside the team. DBTEAMPOLICIESSharedFolderJoinPolicyFromAnyone, /// (no description). DBTEAMPOLICIESSharedFolderJoinPolicyOther, }; /// Represents the union's current tag state. @property (nonatomic, readonly) DBTEAMPOLICIESSharedFolderJoinPolicyTag tag; #pragma mark - Constructors /// /// Initializes union class with tag state of "from_team_only". /// /// Description of the "from_team_only" tag state: Team members can only join /// folders shared by teammates. /// /// @return An initialized instance. /// - (instancetype)initWithFromTeamOnly; /// /// Initializes union class with tag state of "from_anyone". /// /// Description of the "from_anyone" tag state: Team members can join any shared /// folder, including those shared by users outside the team. /// /// @return An initialized instance. /// - (instancetype)initWithFromAnyone; /// /// Initializes union class with tag state of "other". /// /// @return An initialized instance. /// - (instancetype)initWithOther; - (instancetype)init NS_UNAVAILABLE; #pragma mark - Tag state methods /// /// Retrieves whether the union's current tag state has value "from_team_only". /// /// @return Whether the union's current tag state has value "from_team_only". /// - (BOOL)isFromTeamOnly; /// /// Retrieves whether the union's current tag state has value "from_anyone". /// /// @return Whether the union's current tag state has value "from_anyone". /// - (BOOL)isFromAnyone; /// /// Retrieves whether the union's current tag state has value "other". /// /// @return Whether the union's current tag state has value "other". /// - (BOOL)isOther; /// /// Retrieves string value of union's current tag state. /// /// @return A human-readable string representing the union's current tag state. /// - (NSString *)tagName; @end #pragma mark - Serializer Object /// /// The serialization class for the `DBTEAMPOLICIESSharedFolderJoinPolicy` /// union. /// @interface DBTEAMPOLICIESSharedFolderJoinPolicySerializer : NSObject /// /// Serializes `DBTEAMPOLICIESSharedFolderJoinPolicy` instances. /// /// @param instance An instance of the `DBTEAMPOLICIESSharedFolderJoinPolicy` /// API object. /// /// @return A json-compatible dictionary representation of the /// `DBTEAMPOLICIESSharedFolderJoinPolicy` API object. /// + (nullable NSDictionary<NSString *, id> *)serialize:(DBTEAMPOLICIESSharedFolderJoinPolicy *)instance; /// /// Deserializes `DBTEAMPOLICIESSharedFolderJoinPolicy` instances. /// /// @param dict A json-compatible dictionary representation of the /// `DBTEAMPOLICIESSharedFolderJoinPolicy` API object. /// /// @return An instantiation of the `DBTEAMPOLICIESSharedFolderJoinPolicy` /// object. /// + (DBTEAMPOLICIESSharedFolderJoinPolicy *)deserialize:(NSDictionary<NSString *, id> *)dict; @end NS_ASSUME_NONNULL_END
{ "pile_set_name": "Github" }
/*********************************************************************** !!!!!! DO NOT MODIFY !!!!!! GacGen.exe Resource.xml This file is generated by Workflow compiler https://github.com/vczh-libraries ***********************************************************************/ #ifndef VCZH_WORKFLOW_COMPILER_GENERATED_DEMOREFLECTION #define VCZH_WORKFLOW_COMPILER_GENERATED_DEMOREFLECTION #include "Demo.h" #ifndef VCZH_DEBUG_NO_REFLECTION #include "GacUIReflection.h" #endif #if defined( _MSC_VER) #pragma warning(push) #pragma warning(disable:4250) #elif defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wparentheses-equality" #elif defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wparentheses-equality" #endif /*********************************************************************** Reflection ***********************************************************************/ namespace vl { namespace reflection { namespace description { #ifndef VCZH_DEBUG_NO_REFLECTION DECL_TYPE_INFO(::demo::MainWindow) DECL_TYPE_INFO(::demo::MainWindowConstructor) #endif extern bool LoadDemoTypes(); } } } #if defined( _MSC_VER) #pragma warning(pop) #elif defined(__GNUC__) #pragma GCC diagnostic pop #elif defined(__clang__) #pragma clang diagnostic pop #endif #endif
{ "pile_set_name": "Github" }
--- sandbox/linux/BUILD.gn.orig 2019-04-08 08:18:26 UTC +++ sandbox/linux/BUILD.gn @@ -12,12 +12,12 @@ if (is_android) { } declare_args() { - compile_suid_client = is_linux + compile_suid_client = is_linux && !is_bsd - compile_credentials = is_linux + compile_credentials = is_linux && !is_bsd # On Android, use plain GTest. - use_base_test_suite = is_linux + use_base_test_suite = is_linux && !is_bsd } if (is_nacl_nonsfi) { @@ -379,7 +379,7 @@ component("sandbox_services") { public_deps += [ ":sandbox_services_headers" ] } - if (is_nacl_nonsfi) { + if (is_nacl_nonsfi || is_bsd) { cflags = [ "-fgnu-inline-asm" ] sources -= [ @@ -387,6 +387,8 @@ component("sandbox_services") { "services/init_process_reaper.h", "services/scoped_process.cc", "services/scoped_process.h", + "services/syscall_wrappers.cc", + "services/syscall_wrappers.h", "services/yama.cc", "services/yama.h", "syscall_broker/broker_channel.cc", @@ -405,6 +407,10 @@ component("sandbox_services") { "syscall_broker/broker_process.h", "syscall_broker/broker_simple_message.cc", "syscall_broker/broker_simple_message.h", + ] + sources += [ + "services/libc_interceptor.cc", + "services/libc_interceptor.h", ] } else if (!is_android) { sources += [
{ "pile_set_name": "Github" }
#ifndef CREATE_EMPTY_DIRECTED_GRAPH_WITH_GRAPH_NAME_H #define CREATE_EMPTY_DIRECTED_GRAPH_WITH_GRAPH_NAME_H #include <boost/graph/adjacency_list.hpp> boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, boost::no_property, boost::no_property, boost::property<boost::graph_name_t, std::string>> create_empty_directed_graph_with_graph_name() noexcept; #endif // CREATE_EMPTY_DIRECTED_GRAPH_WITH_GRAPH_NAME_H
{ "pile_set_name": "Github" }
#if !defined(BOOST_PP_IS_ITERATING) ///// header body #ifndef BOOST_MPL_AUX778076_ADVANCE_BACKWARD_HPP_INCLUDED #define BOOST_MPL_AUX778076_ADVANCE_BACKWARD_HPP_INCLUDED // Copyright Aleksey Gurtovoy 2000-2004 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/mpl for documentation. // $Id$ // $Date$ // $Revision$ #if !defined(BOOST_MPL_PREPROCESSING_MODE) # include <boost/mpl/prior.hpp> # include <boost/mpl/apply_wrap.hpp> #endif #include <boost/mpl/aux_/config/use_preprocessed.hpp> #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \ && !defined(BOOST_MPL_PREPROCESSING_MODE) # define BOOST_MPL_PREPROCESSED_HEADER advance_backward.hpp # include <boost/mpl/aux_/include_preprocessed.hpp> #else # include <boost/mpl/limits/unrolling.hpp> # include <boost/mpl/aux_/nttp_decl.hpp> # include <boost/mpl/aux_/config/eti.hpp> # include <boost/preprocessor/iterate.hpp> # include <boost/preprocessor/cat.hpp> # include <boost/preprocessor/inc.hpp> namespace boost { namespace mpl { namespace aux { // forward declaration template< BOOST_MPL_AUX_NTTP_DECL(long, N) > struct advance_backward; # define BOOST_PP_ITERATION_PARAMS_1 \ (3,(0, BOOST_MPL_LIMIT_UNROLLING, <boost/mpl/aux_/advance_backward.hpp>)) # include BOOST_PP_ITERATE() // implementation for N that exceeds BOOST_MPL_LIMIT_UNROLLING template< BOOST_MPL_AUX_NTTP_DECL(long, N) > struct advance_backward { template< typename Iterator > struct apply { typedef typename apply_wrap1< advance_backward<BOOST_MPL_LIMIT_UNROLLING> , Iterator >::type chunk_result_; typedef typename apply_wrap1< advance_backward<( (N - BOOST_MPL_LIMIT_UNROLLING) < 0 ? 0 : N - BOOST_MPL_LIMIT_UNROLLING )> , chunk_result_ >::type type; }; }; }}} #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS #endif // BOOST_MPL_AUX778076_ADVANCE_BACKWARD_HPP_INCLUDED ///// iteration, depth == 1 // For gcc 4.4 compatability, we must include the // BOOST_PP_ITERATION_DEPTH test inside an #else clause. #else // BOOST_PP_IS_ITERATING #if BOOST_PP_ITERATION_DEPTH() == 1 #define i_ BOOST_PP_FRAME_ITERATION(1) template<> struct advance_backward< BOOST_PP_FRAME_ITERATION(1) > { template< typename Iterator > struct apply { typedef Iterator iter0; #if i_ > 0 # define BOOST_PP_ITERATION_PARAMS_2 \ (3,(1, BOOST_PP_FRAME_ITERATION(1), <boost/mpl/aux_/advance_backward.hpp>)) # include BOOST_PP_ITERATE() #endif typedef BOOST_PP_CAT(iter,BOOST_PP_FRAME_ITERATION(1)) type; }; #if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG) /// ETI workaround template<> struct apply<int> { typedef int type; }; #endif }; #undef i_ ///// iteration, depth == 2 #elif BOOST_PP_ITERATION_DEPTH() == 2 # define AUX778076_ITER_0 BOOST_PP_CAT(iter,BOOST_PP_DEC(BOOST_PP_FRAME_ITERATION(2))) # define AUX778076_ITER_1 BOOST_PP_CAT(iter,BOOST_PP_FRAME_ITERATION(2)) typedef typename prior<AUX778076_ITER_0>::type AUX778076_ITER_1; # undef AUX778076_ITER_1 # undef AUX778076_ITER_0 #endif // BOOST_PP_ITERATION_DEPTH() #endif // BOOST_PP_IS_ITERATING
{ "pile_set_name": "Github" }
/* * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. 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. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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. */ #import "SimpleDBMissingParameterException.h" @implementation SimpleDBMissingParameterException @synthesize boxUsage; -(id)initWithMessage:(NSString *)theMessage { if (self = [super initWithMessage:theMessage]) { } return self; } -(void)setPropertiesWithException:(AmazonServiceException *)theException { [super setPropertiesWithException:theException]; if ([theException.additionalFields valueForKey:@"BoxUsage"] != nil) { self.boxUsage = [AmazonSDKUtil convertStringToNumber:[theException.additionalFields valueForKey:@"BoxUsage"]]; } } -(NSString *)description { NSMutableString *buffer = [[NSMutableString alloc] initWithCapacity:256]; [buffer appendString:@"{"]; [buffer appendString:[[[NSString alloc] initWithFormat:@"BoxUsage: %@,", boxUsage] autorelease]]; [buffer appendString:[super description]]; [buffer appendString:@"}"]; return [buffer autorelease]; } -(void)dealloc { [boxUsage release]; [super dealloc]; } @end
{ "pile_set_name": "Github" }
// Copyright 2004-present Facebook. All Rights Reserved. #include "SamplingProfilerJniMethod.h" #include <JavaScriptCore/JSProfilerPrivate.h> #include <jschelpers/JSCHelpers.h> #include <jni.h> #include <string> using namespace facebook::jni; namespace facebook { namespace react { /* static */ jni::local_ref<SamplingProfilerJniMethod::jhybriddata> SamplingProfilerJniMethod::initHybrid(jni::alias_ref<jclass>, jlong javaScriptContext) { return makeCxxInstance(javaScriptContext); } /* static */ void SamplingProfilerJniMethod::registerNatives() { registerHybrid( {makeNativeMethod("initHybrid", SamplingProfilerJniMethod::initHybrid), makeNativeMethod("poke", SamplingProfilerJniMethod::poke)}); } SamplingProfilerJniMethod::SamplingProfilerJniMethod(jlong javaScriptContext) { context_ = reinterpret_cast<JSGlobalContextRef>(javaScriptContext); } void SamplingProfilerJniMethod::poke( jni::alias_ref<JSPackagerClientResponder::javaobject> responder) { if (!JSC_JSSamplingProfilerEnabled(context_)) { responder->error("The JSSamplingProfiler is disabled. See this " "https://fburl.com/u4lw7xeq for some help"); return; } JSValueRef jsResult = JSC_JSPokeSamplingProfiler(context_); if (JSC_JSValueGetType(context_, jsResult) == kJSTypeNull) { responder->respond("started"); } else { JSStringRef resultStrRef = JSValueToStringCopy(context_, jsResult, nullptr); size_t length = JSStringGetLength(resultStrRef); char buffer[length + 1]; JSStringGetUTF8CString(resultStrRef, buffer, length + 1); JSStringRelease(resultStrRef); responder->respond(buffer); } } } }
{ "pile_set_name": "Github" }
#include <bits/stdc++.h> #define sd(x) scanf("%d",&x) #define sd2(x,y) scanf("%d%d",&x,&y) #define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z) #define fi first #define se second #define pb(x) push_back(x) #define mp(x,y) make_pair(x,y) #define LET(x, a) __typeof(a) x(a) #define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++) #define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout); #define func __FUNCTION__ #define line __LINE__ using namespace std; template<typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p){out<<'('<<p.fi<<", "<<p.se<<')'; return out;} template<typename T> ostream& operator<<(ostream& out, vector<T> const & v){ int l = v.size(); for(int i = 0; i < l-1; i++) out<<v[i]<<' '; if(l>0) out<<v[l-1]; return out;} void tr(){cout << endl;} template<typename S, typename ... Strings> void tr(S x, const Strings&... rest){cout<<x<<' ';tr(rest...);} const int N = 100100; int n, p; int l[N], r[N]; int main(){ sd2(n,p); for(int i = 0; i < n; i++){ sd2(l[i], r[i]); } l[n] = l[0]; r[n] = r[0]; long double res = 0; for(int i = 1; i <= n; i++){ long long v1 = (r[i]/p) - ((l[i]-1)/p); long long v2 = (r[i-1]/p) - ((l[i-1]-1)/p); long long l1 = r[i]-l[i]+1; long long l2 = r[i-1]-l[i-1]+1; long long t = (l1-v1)*(l2-v2); long double p = (long double) t / (long double) (l1*l2); p = 1.0f-p; res += p*2000; } printf("%.9lf\n", (double)res); return 0; }
{ "pile_set_name": "Github" }
// RUN: %clang_cc1 -emit-llvm -triple i386-apple-macosx10.7.2 < %s | FileCheck %s // The preferred alignment for a long long on x86-32 is 8; make sure the // alloca for x uses that alignment. int test (long long x) { return (int)x; } // CHECK-LABEL: define i32 @test // CHECK: alloca i64, align 8 // Make sure we honor the aligned attribute. struct X { int x,y,z,a; }; int test2(struct X x __attribute((aligned(16)))) { return x.z; } // CHECK-LABEL: define i32 @test2 // CHECK: alloca %struct._Z1X, align 16
{ "pile_set_name": "Github" }
// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2012 Gael Guennebaud <gael.guennebaud@inria.fr> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef EIGEN_REF_H #define EIGEN_REF_H namespace Eigen { template<typename Derived> class RefBase; template<typename PlainObjectType, int Options = 0, typename StrideType = typename internal::conditional<PlainObjectType::IsVectorAtCompileTime,InnerStride<1>,OuterStride<> >::type > class Ref; /** \class Ref * \ingroup Core_Module * * \brief A matrix or vector expression mapping an existing expressions * * \tparam PlainObjectType the equivalent matrix type of the mapped data * \tparam Options specifies whether the pointer is \c #Aligned, or \c #Unaligned. * The default is \c #Unaligned. * \tparam StrideType optionally specifies strides. By default, Ref implies a contiguous storage along the inner dimension (inner stride==1), * but accept a variable outer stride (leading dimension). * This can be overridden by specifying strides. * The type passed here must be a specialization of the Stride template, see examples below. * * This class permits to write non template functions taking Eigen's object as parameters while limiting the number of copies. * A Ref<> object can represent either a const expression or a l-value: * \code * // in-out argument: * void foo1(Ref<VectorXf> x); * * // read-only const argument: * void foo2(const Ref<const VectorXf>& x); * \endcode * * In the in-out case, the input argument must satisfies the constraints of the actual Ref<> type, otherwise a compilation issue will be triggered. * By default, a Ref<VectorXf> can reference any dense vector expression of float having a contiguous memory layout. * Likewise, a Ref<MatrixXf> can reference any column major dense matrix expression of float whose column's elements are contiguously stored with * the possibility to have a constant space inbetween each column, i.e.: the inner stride mmust be equal to 1, but the outer-stride (or leading dimension), * can be greater than the number of rows. * * In the const case, if the input expression does not match the above requirement, then it is evaluated into a temporary before being passed to the function. * Here are some examples: * \code * MatrixXf A; * VectorXf a; * foo1(a.head()); // OK * foo1(A.col()); // OK * foo1(A.row()); // compilation error because here innerstride!=1 * foo2(A.row()); // The row is copied into a contiguous temporary * foo2(2*a); // The expression is evaluated into a temporary * foo2(A.col().segment(2,4)); // No temporary * \endcode * * The range of inputs that can be referenced without temporary can be enlarged using the last two template parameter. * Here is an example accepting an innerstride!=1: * \code * // in-out argument: * void foo3(Ref<VectorXf,0,InnerStride<> > x); * foo3(A.row()); // OK * \endcode * The downside here is that the function foo3 might be significantly slower than foo1 because it won't be able to exploit vectorization, and will involved more * expensive address computations even if the input is contiguously stored in memory. To overcome this issue, one might propose to overloads internally calling a * template function, e.g.: * \code * // in the .h: * void foo(const Ref<MatrixXf>& A); * void foo(const Ref<MatrixXf,0,Stride<> >& A); * * // in the .cpp: * template<typename TypeOfA> void foo_impl(const TypeOfA& A) { * ... // crazy code goes here * } * void foo(const Ref<MatrixXf>& A) { foo_impl(A); } * void foo(const Ref<MatrixXf,0,Stride<> >& A) { foo_impl(A); } * \endcode * * * \sa PlainObjectBase::Map(), \ref TopicStorageOrders */ namespace internal { template<typename _PlainObjectType, int _Options, typename _StrideType> struct traits<Ref<_PlainObjectType, _Options, _StrideType> > : public traits<Map<_PlainObjectType, _Options, _StrideType> > { typedef _PlainObjectType PlainObjectType; typedef _StrideType StrideType; enum { Options = _Options, Flags = traits<Map<_PlainObjectType, _Options, _StrideType> >::Flags | NestByRefBit }; template<typename Derived> struct match { enum { HasDirectAccess = internal::has_direct_access<Derived>::ret, StorageOrderMatch = PlainObjectType::IsVectorAtCompileTime || ((PlainObjectType::Flags&RowMajorBit)==(Derived::Flags&RowMajorBit)), InnerStrideMatch = int(StrideType::InnerStrideAtCompileTime)==int(Dynamic) || int(StrideType::InnerStrideAtCompileTime)==int(Derived::InnerStrideAtCompileTime) || (int(StrideType::InnerStrideAtCompileTime)==0 && int(Derived::InnerStrideAtCompileTime)==1), OuterStrideMatch = Derived::IsVectorAtCompileTime || int(StrideType::OuterStrideAtCompileTime)==int(Dynamic) || int(StrideType::OuterStrideAtCompileTime)==int(Derived::OuterStrideAtCompileTime), AlignmentMatch = (_Options!=Aligned) || ((PlainObjectType::Flags&AlignedBit)==0) || ((traits<Derived>::Flags&AlignedBit)==AlignedBit), MatchAtCompileTime = HasDirectAccess && StorageOrderMatch && InnerStrideMatch && OuterStrideMatch && AlignmentMatch }; typedef typename internal::conditional<MatchAtCompileTime,internal::true_type,internal::false_type>::type type; }; }; template<typename Derived> struct traits<RefBase<Derived> > : public traits<Derived> {}; } template<typename Derived> class RefBase : public MapBase<Derived> { typedef typename internal::traits<Derived>::PlainObjectType PlainObjectType; typedef typename internal::traits<Derived>::StrideType StrideType; public: typedef MapBase<Derived> Base; EIGEN_DENSE_PUBLIC_INTERFACE(RefBase) inline Index innerStride() const { return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1; } inline Index outerStride() const { return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer() : IsVectorAtCompileTime ? this->size() : int(Flags)&RowMajorBit ? this->cols() : this->rows(); } RefBase() : Base(0,RowsAtCompileTime==Dynamic?0:RowsAtCompileTime,ColsAtCompileTime==Dynamic?0:ColsAtCompileTime), // Stride<> does not allow default ctor for Dynamic strides, so let' initialize it with dummy values: m_stride(StrideType::OuterStrideAtCompileTime==Dynamic?0:StrideType::OuterStrideAtCompileTime, StrideType::InnerStrideAtCompileTime==Dynamic?0:StrideType::InnerStrideAtCompileTime) {} EIGEN_INHERIT_ASSIGNMENT_OPERATORS(RefBase) protected: typedef Stride<StrideType::OuterStrideAtCompileTime,StrideType::InnerStrideAtCompileTime> StrideBase; template<typename Expression> void construct(Expression& expr) { if(PlainObjectType::RowsAtCompileTime==1) { eigen_assert(expr.rows()==1 || expr.cols()==1); ::new (static_cast<Base*>(this)) Base(expr.data(), 1, expr.size()); } else if(PlainObjectType::ColsAtCompileTime==1) { eigen_assert(expr.rows()==1 || expr.cols()==1); ::new (static_cast<Base*>(this)) Base(expr.data(), expr.size(), 1); } else ::new (static_cast<Base*>(this)) Base(expr.data(), expr.rows(), expr.cols()); ::new (&m_stride) StrideBase(StrideType::OuterStrideAtCompileTime==0?0:expr.outerStride(), StrideType::InnerStrideAtCompileTime==0?0:expr.innerStride()); } StrideBase m_stride; }; template<typename PlainObjectType, int Options, typename StrideType> class Ref : public RefBase<Ref<PlainObjectType, Options, StrideType> > { typedef internal::traits<Ref> Traits; public: typedef RefBase<Ref> Base; EIGEN_DENSE_PUBLIC_INTERFACE(Ref) #ifndef EIGEN_PARSED_BY_DOXYGEN template<typename Derived> inline Ref(PlainObjectBase<Derived>& expr, typename internal::enable_if<bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0) { Base::construct(expr); } template<typename Derived> inline Ref(const DenseBase<Derived>& expr, typename internal::enable_if<bool(internal::is_lvalue<Derived>::value&&bool(Traits::template match<Derived>::MatchAtCompileTime)),Derived>::type* = 0, int = Derived::ThisConstantIsPrivateInPlainObjectBase) #else template<typename Derived> inline Ref(DenseBase<Derived>& expr) #endif { Base::construct(expr.const_cast_derived()); } EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Ref) }; // this is the const ref version template<typename TPlainObjectType, int Options, typename StrideType> class Ref<const TPlainObjectType, Options, StrideType> : public RefBase<Ref<const TPlainObjectType, Options, StrideType> > { typedef internal::traits<Ref> Traits; public: typedef RefBase<Ref> Base; EIGEN_DENSE_PUBLIC_INTERFACE(Ref) template<typename Derived> inline Ref(const DenseBase<Derived>& expr) { // std::cout << match_helper<Derived>::HasDirectAccess << "," << match_helper<Derived>::OuterStrideMatch << "," << match_helper<Derived>::InnerStrideMatch << "\n"; // std::cout << int(StrideType::OuterStrideAtCompileTime) << " - " << int(Derived::OuterStrideAtCompileTime) << "\n"; // std::cout << int(StrideType::InnerStrideAtCompileTime) << " - " << int(Derived::InnerStrideAtCompileTime) << "\n"; construct(expr.derived(), typename Traits::template match<Derived>::type()); } protected: template<typename Expression> void construct(const Expression& expr,internal::true_type) { Base::construct(expr); } template<typename Expression> void construct(const Expression& expr, internal::false_type) { m_object.lazyAssign(expr); Base::construct(m_object); } protected: TPlainObjectType m_object; }; } // end namespace Eigen #endif // EIGEN_REF_H
{ "pile_set_name": "Github" }
// Copyright (C) 2005-2006 The Trustees of Indiana University. // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // Authors: Douglas Gregor // Andrew Lumsdaine #ifndef BOOST_GRAPH_DETAIL_REMOTE_UPDATE_SET_HPP #define BOOST_GRAPH_DETAIL_REMOTE_UPDATE_SET_HPP #ifndef BOOST_GRAPH_USE_MPI #error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included" #endif #include <boost/graph/parallel/process_group.hpp> #include <boost/type_traits/is_convertible.hpp> #include <vector> #include <boost/assert.hpp> #include <boost/optional.hpp> #include <queue> namespace boost { namespace graph { namespace detail { template<typename ProcessGroup> void do_synchronize(ProcessGroup& pg) { using boost::parallel::synchronize; synchronize(pg); } struct remote_set_queued {}; struct remote_set_immediate {}; template<typename ProcessGroup> class remote_set_semantics { BOOST_STATIC_CONSTANT (bool, queued = (is_convertible< typename ProcessGroup::communication_category, boost::parallel::bsp_process_group_tag>::value)); public: typedef typename mpl::if_c<queued, remote_set_queued, remote_set_immediate>::type type; }; template<typename Derived, typename ProcessGroup, typename Value, typename OwnerMap, typename Semantics = typename remote_set_semantics<ProcessGroup>::type> class remote_update_set; /********************************************************************** * Remote updating set that queues messages until synchronization * **********************************************************************/ template<typename Derived, typename ProcessGroup, typename Value, typename OwnerMap> class remote_update_set<Derived, ProcessGroup, Value, OwnerMap, remote_set_queued> { typedef typename property_traits<OwnerMap>::key_type Key; typedef std::vector<std::pair<Key, Value> > Updates; typedef typename Updates::size_type updates_size_type; typedef typename Updates::value_type updates_pair_type; public: private: typedef typename ProcessGroup::process_id_type process_id_type; enum message_kind { /** Message containing the number of updates that will be sent in * a msg_updates message that will immediately follow. This * message will contain a single value of type * updates_size_type. */ msg_num_updates, /** Contains (key, value) pairs with all of the updates from a * particular source. The number of updates is variable, but will * be provided in a msg_num_updates message that immediately * preceeds this message. * */ msg_updates }; struct handle_messages { explicit handle_messages(remote_update_set* self, const ProcessGroup& pg) : self(self), update_sizes(num_processes(pg), 0) { } void operator()(process_id_type source, int tag) { switch(tag) { case msg_num_updates: { // Receive the # of updates updates_size_type num_updates; receive(self->process_group, source, tag, num_updates); update_sizes[source] = num_updates; } break; case msg_updates: { updates_size_type num_updates = update_sizes[source]; BOOST_ASSERT(num_updates); // Receive the actual updates std::vector<updates_pair_type> updates(num_updates); receive(self->process_group, source, msg_updates, &updates[0], num_updates); // Send updates to derived "receive_update" member Derived* derived = static_cast<Derived*>(self); for (updates_size_type u = 0; u < num_updates; ++u) derived->receive_update(source, updates[u].first, updates[u].second); update_sizes[source] = 0; } break; }; } private: remote_update_set* self; std::vector<updates_size_type> update_sizes; }; friend struct handle_messages; protected: remote_update_set(const ProcessGroup& pg, const OwnerMap& owner) : process_group(pg, handle_messages(this, pg)), updates(num_processes(pg)), owner(owner) { } void update(const Key& key, const Value& value) { if (get(owner, key) == process_id(process_group)) { Derived* derived = static_cast<Derived*>(this); derived->receive_update(get(owner, key), key, value); } else { updates[get(owner, key)].push_back(std::make_pair(key, value)); } } void collect() { } void synchronize() { // Emit all updates and then remove them process_id_type num_processes = updates.size(); for (process_id_type p = 0; p < num_processes; ++p) { if (!updates[p].empty()) { send(process_group, p, msg_num_updates, updates[p].size()); send(process_group, p, msg_updates, &updates[p].front(), updates[p].size()); updates[p].clear(); } } do_synchronize(process_group); } ProcessGroup process_group; private: std::vector<Updates> updates; OwnerMap owner; }; /********************************************************************** * Remote updating set that sends messages immediately * **********************************************************************/ template<typename Derived, typename ProcessGroup, typename Value, typename OwnerMap> class remote_update_set<Derived, ProcessGroup, Value, OwnerMap, remote_set_immediate> { typedef typename property_traits<OwnerMap>::key_type Key; typedef std::pair<Key, Value> update_pair_type; typedef typename std::vector<update_pair_type>::size_type updates_size_type; public: typedef typename ProcessGroup::process_id_type process_id_type; private: enum message_kind { /** Contains a (key, value) pair that will be updated. */ msg_update }; struct handle_messages { explicit handle_messages(remote_update_set* self, const ProcessGroup& pg) : self(self) { update_sizes.resize(num_processes(pg), 0); } void operator()(process_id_type source, int tag) { // Receive the # of updates BOOST_ASSERT(tag == msg_update); update_pair_type update; receive(self->process_group, source, tag, update); // Send update to derived "receive_update" member Derived* derived = static_cast<Derived*>(self); derived->receive_update(source, update.first, update.second); } private: std::vector<updates_size_type> update_sizes; remote_update_set* self; }; friend struct handle_messages; protected: remote_update_set(const ProcessGroup& pg, const OwnerMap& owner) : process_group(pg, handle_messages(this, pg)), owner(owner) { } void update(const Key& key, const Value& value) { if (get(owner, key) == process_id(process_group)) { Derived* derived = static_cast<Derived*>(this); derived->receive_update(get(owner, key), key, value); } else send(process_group, get(owner, key), msg_update, update_pair_type(key, value)); } void collect() { typedef std::pair<process_id_type, int> probe_type; handle_messages handler(this, process_group); while (optional<probe_type> stp = probe(process_group)) if (stp->second == msg_update) handler(stp->first, stp->second); } void synchronize() { do_synchronize(process_group); } ProcessGroup process_group; OwnerMap owner; }; } } } // end namespace boost::graph::detail #endif // BOOST_GRAPH_DETAIL_REMOTE_UPDATE_SET_HPP
{ "pile_set_name": "Github" }
/** @file Intel Processor Power Management ACPI Code. Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include "CpuPowerMgmt.h" DefinitionBlock ( "CPU0PSD.aml", "SSDT", 0x02, "PmRef", "Cpu0Psd", 0x3000 ) { External(\PC00, IntObj) External(\TCNT, FieldUnitObj) External(\_SB.CFGD, FieldUnitObj) External(\_SB.PR00, DeviceObj) Scope(\_SB.PR00) { Name(HPSD,Package() // HW_ALL { Package() {5, // NumEntries. Current Value is 5. 0, // Revision. Current Value is 0. 0, // Domain. 0xFE, // Coordination type 0xFE = HW_ALL 0x80 // Number of processors. } }) Name(SPSD,Package() // SW_ALL { Package() {5, // NumEntries. Current Value is 5. 0, // Revision. Current Value is 0. 0, // Domain. 0xFC, // Coordination type 0xFC = SW_ALL 0x80 // Number of processors. } }) // // The _PSD object provides information to the OSPM related // to P-State coordination between processors in a multi-processor // configurations. // Method(_PSD,0) { If (And(\_SB.CFGD, PPM_TURBO_BOOST_MAX)) // Intel Turbo Boost Max 3.0 { Store (0, Index(DerefOf(Index(HPSD, 0)),2)) // Domain Store (1, Index(DerefOf(Index(HPSD, 0)),4)) // Number of processors belonging to the domain. } Else { Store (TCNT, Index(DerefOf(Index(HPSD, 0)),4)) Store (TCNT, Index(DerefOf(Index(SPSD, 0)),4)) } If(And(PC00,0x0800)) // If Hardware co-ordination of P states { Return(HPSD) } Return(SPSD) } } // End of Scope(\_SB.PR00) } // End of Definition Block
{ "pile_set_name": "Github" }
--- contrib/virt.te 2012-11-25 21:35:09.181247450 +0100 +++ contrib/virt.te 2012-11-25 21:34:09.223216815 +0100 @@ -281,7 +281,11 @@ userdom_search_user_home_dirs(virt_domain) userdom_read_all_users_state(virt_domain) -qemu_exec(virt_domain) +ifdef(`distro_gentoo',` + optional_policy(` + qemu_exec(virt_domain) + ') +') tunable_policy(`virt_use_execmem',` allow virt_domain self:process { execmem execstack };
{ "pile_set_name": "Github" }
/*============================================================================= Copyright (c) 2018 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #ifndef BOOST_FUSION_IS_NATIVE_FUSION_SEQUENCE #define BOOST_FUSION_IS_NATIVE_FUSION_SEQUENCE #include <boost/fusion/support/config.hpp> #include <boost/fusion/support/sequence_base.hpp> #include <boost/mpl/and.hpp> #include <boost/type_traits/is_complete.hpp> #include <boost/type_traits/is_convertible.hpp> namespace boost { namespace fusion { namespace detail { template <typename Sequence> struct is_native_fusion_sequence : mpl::and_< is_complete<Sequence> , is_convertible<Sequence, detail::from_sequence_convertible_type> > {}; }}} #endif
{ "pile_set_name": "Github" }
/* * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include <stdio.h> #include <errno.h> #include "bio_lcl.h" #include "internal/cryptlib.h" /* * BIO_put and BIO_get both add to the digest, BIO_gets returns the digest */ static int nullf_write(BIO *h, const char *buf, int num); static int nullf_read(BIO *h, char *buf, int size); static int nullf_puts(BIO *h, const char *str); static int nullf_gets(BIO *h, char *str, int size); static long nullf_ctrl(BIO *h, int cmd, long arg1, void *arg2); static long nullf_callback_ctrl(BIO *h, int cmd, BIO_info_cb *fp); static const BIO_METHOD methods_nullf = { BIO_TYPE_NULL_FILTER, "NULL filter", /* TODO: Convert to new style write function */ bwrite_conv, nullf_write, /* TODO: Convert to new style read function */ bread_conv, nullf_read, nullf_puts, nullf_gets, nullf_ctrl, NULL, NULL, nullf_callback_ctrl, }; const BIO_METHOD *BIO_f_null(void) { return &methods_nullf; } static int nullf_read(BIO *b, char *out, int outl) { int ret = 0; if (out == NULL) return 0; if (b->next_bio == NULL) return 0; ret = BIO_read(b->next_bio, out, outl); BIO_clear_retry_flags(b); BIO_copy_next_retry(b); return ret; } static int nullf_write(BIO *b, const char *in, int inl) { int ret = 0; if ((in == NULL) || (inl <= 0)) return 0; if (b->next_bio == NULL) return 0; ret = BIO_write(b->next_bio, in, inl); BIO_clear_retry_flags(b); BIO_copy_next_retry(b); return ret; } static long nullf_ctrl(BIO *b, int cmd, long num, void *ptr) { long ret; if (b->next_bio == NULL) return 0; switch (cmd) { case BIO_C_DO_STATE_MACHINE: BIO_clear_retry_flags(b); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); BIO_copy_next_retry(b); break; case BIO_CTRL_DUP: ret = 0L; break; default: ret = BIO_ctrl(b->next_bio, cmd, num, ptr); } return ret; } static long nullf_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp) { long ret = 1; if (b->next_bio == NULL) return 0; switch (cmd) { default: ret = BIO_callback_ctrl(b->next_bio, cmd, fp); break; } return ret; } static int nullf_gets(BIO *bp, char *buf, int size) { if (bp->next_bio == NULL) return 0; return BIO_gets(bp->next_bio, buf, size); } static int nullf_puts(BIO *bp, const char *str) { if (bp->next_bio == NULL) return 0; return BIO_puts(bp->next_bio, str); }
{ "pile_set_name": "Github" }
#include "api_config.h" #include "common.h" #include <iostream> #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/ini_parser.hpp> #include <boost/algorithm/string.hpp> // === implementation of the api_config class === using namespace lsl; using namespace lslboost::algorithm; /// Helper function: Substitute the "~" character by the full home directory (according to environment variables). std::string expand_tilde(const std::string &filename) { if (!filename.empty() && filename[0] == '~') { std::string homedir; if (getenv("HOME")) homedir = getenv("HOME"); else if (getenv("USERPROFILE")) homedir = getenv("USERPROFILE"); else if (getenv("HOMEDRIVE") && getenv("HOMEPATH")) homedir = std::string(getenv("HOMEDRIVE")) + getenv("HOMEPATH"); else { std::cerr << "Cannot determine the user's home directory; config files in the home directory will not be discovered." << std::endl; return filename; } return homedir + filename.substr(1); } return filename; } /// Helper function: Parse a set specifier (a string of the form {a, b, c, ...}) into a vector of strings. static std::vector<std::string> parse_set(const std::string &setstr) { std::vector<std::string> result; if ((setstr.size() > 2) && setstr[0] == '{' && setstr[setstr.size()-1] == '}') { // non-empty set: split by "," std::string sub = setstr.substr(1,setstr.size()-2); lslboost::algorithm::split(result,sub,lslboost::algorithm::is_any_of(",")); // remove leading and trailing whitespace from each element for (std::vector<std::string>::iterator i=result.begin(); i!=result.end(); i++) trim(*i); } return result; } // Returns true if the file exists and is openable for reading bool file_is_readable(const std::string& filename) { std::ifstream f(filename.c_str()); return f.good(); } /** * Constructor. * Applies default settings and overrides them based on a config file (if present). */ api_config::api_config() { // for each config file location under consideration... std::string filenames[] = {"lsl_api.cfg", expand_tilde("~/lsl_api/lsl_api.cfg"), "/etc/lsl_api/lsl_api.cfg"}; for (std::size_t k=0; k < sizeof(filenames)/sizeof(filenames[0]); k++) { try { if (file_is_readable(filenames[k])) { // try to load it if the file exists load_from_file(filenames[k]); // successful: finished return; } } catch(std::exception &e) { std::cerr << "Error trying to load config file " << filenames[k] << ": " << e.what() << std::endl; } } // unsuccessful: load default settings load_from_file(); } /** * Load a configuration file (or use defaults if a filename is empty). * Expects a proper platform-native file name. Throws if there's an error. */ void api_config::load_from_file(const std::string &filename) { try { lslboost::property_tree::ptree pt; if (!filename.empty()) read_ini(filename, pt); // read out the [ports] parameters multicast_port_ = pt.get("ports.MulticastPort",16571); base_port_ = pt.get("ports.BasePort",16572); port_range_ = pt.get("ports.PortRange",32); allow_random_ports_ = pt.get("ports.AllowRandomPorts",true); #ifdef __APPLE__ ipv6_ = pt.get("ports.IPv6","disable"); // on Mac OS (10.7) there's a bug in the IPv6 implementation that breaks LSL when it tries to use both v4 and v6 #else ipv6_ = pt.get("ports.IPv6","allow"); #endif // fix some common mis-spellings if (ipv6_ == "disabled") ipv6_ = "disable"; if (ipv6_ == "allowed") ipv6_ = "allow"; if (ipv6_ == "forced") ipv6_ = "force"; if (ipv6_ != "disable" && ipv6_ != "allow" && ipv6_ != "force") throw std::runtime_error("Unsupported setting for the IPv6 parameter."); // read the [multicast] parameters resolve_scope_ = pt.get("multicast.ResolveScope","site"); listen_address_ = pt.get("multicast.ListenAddress",""); std::vector<std::string> machine_group = parse_set(pt.get("multicast.MachineAddresses","{127.0.0.1, FF31:113D:6FDD:2C17:A643:FFE2:1BD1:3CD2}")); std::vector<std::string> link_group = parse_set(pt.get("multicast.LinkAddresses","{255.255.255.255, 224.0.0.183, FF02:113D:6FDD:2C17:A643:FFE2:1BD1:3CD2}")); std::vector<std::string> site_group = parse_set(pt.get("multicast.SiteAddresses","{239.255.172.215, FF05:113D:6FDD:2C17:A643:FFE2:1BD1:3CD2}")); std::vector<std::string> organization_group = parse_set(pt.get("multicast.OrganizationAddresses","{239.192.172.215, FF08:113D:6FDD:2C17:A643:FFE2:1BD1:3CD2}")); std::vector<std::string> global_group = parse_set(pt.get("multicast.GlobalAddresses","{}")); multicast_ttl_ = -1; // construct list of addresses & TTL according to the ResolveScope. if (resolve_scope_ == "machine") { multicast_addresses_ = machine_group; multicast_ttl_ = 0; } if (resolve_scope_ == "link") { multicast_addresses_ = machine_group; multicast_addresses_.insert(multicast_addresses_.end(),link_group.begin(),link_group.end()); multicast_ttl_ = 1; } if (resolve_scope_ == "site") { multicast_addresses_ = machine_group; multicast_addresses_.insert(multicast_addresses_.end(),link_group.begin(),link_group.end()); multicast_addresses_.insert(multicast_addresses_.end(),site_group.begin(),site_group.end()); multicast_ttl_ = 24; } if (resolve_scope_ == "organization") { multicast_addresses_ = machine_group; multicast_addresses_.insert(multicast_addresses_.end(),link_group.begin(),link_group.end()); multicast_addresses_.insert(multicast_addresses_.end(),site_group.begin(),site_group.end()); multicast_addresses_.insert(multicast_addresses_.end(),organization_group.begin(),organization_group.end()); multicast_ttl_ = 32; } if (resolve_scope_ == "global") { multicast_addresses_ = machine_group; multicast_addresses_.insert(multicast_addresses_.end(),link_group.begin(),link_group.end()); multicast_addresses_.insert(multicast_addresses_.end(),site_group.begin(),site_group.end()); multicast_addresses_.insert(multicast_addresses_.end(),organization_group.begin(),organization_group.end()); multicast_addresses_.insert(multicast_addresses_.end(),global_group.begin(),global_group.end()); multicast_ttl_ = 255; } if (multicast_ttl_ == -1) throw std::runtime_error("This ResolveScope setting is unsupported."); // apply overrides, if any int ttl_override = pt.get("multicast.TTLOverride",-1); std::vector<std::string> address_override = parse_set(pt.get("multicast.AddressesOverride","{}")); if (ttl_override >= 0) multicast_ttl_ = ttl_override; if (!address_override.empty()) multicast_addresses_ = address_override; // read the [lab] settings known_peers_ = parse_set(pt.get("lab.KnownPeers","{}")); session_id_ = pt.get("lab.SessionID","default"); // read the [tuning] settings use_protocol_version_ = std::min(LSL_PROTOCOL_VERSION,pt.get("tuning.UseProtocolVersion",LSL_PROTOCOL_VERSION)); watchdog_check_interval_ = pt.get("tuning.WatchdogCheckInterval",15.0); watchdog_time_threshold_ = pt.get("tuning.WatchdogTimeThreshold",15.0); multicast_min_rtt_ = pt.get("tuning.MulticastMinRTT",0.5); multicast_max_rtt_ = pt.get("tuning.MulticastMaxRTT",3.0); unicast_min_rtt_ = pt.get("tuning.UnicastMinRTT",0.75); unicast_max_rtt_ = pt.get("tuning.UnicastMaxRTT",5.0); continuous_resolve_interval_ = pt.get("tuning.ContinuousResolveInterval",0.5); timer_resolution_ = pt.get("tuning.TimerResolution",1); max_cached_queries_ = pt.get("tuning.MaxCachedQueries",100); time_update_interval_ = pt.get("tuning.TimeUpdateInterval",2.0); time_update_minprobes_ = pt.get("tuning.TimeUpdateMinProbes",6); time_probe_count_ = pt.get("tuning.TimeProbeCount",8); time_probe_interval_ = pt.get("tuning.TimeProbeInterval",0.064); time_probe_max_rtt_ = pt.get("tuning.TimeProbeMaxRTT",0.128); outlet_buffer_reserve_ms_ = pt.get("tuning.OutletBufferReserveMs",5000); outlet_buffer_reserve_samples_ = pt.get("tuning.OutletBufferReserveSamples",128); inlet_buffer_reserve_ms_ = pt.get("tuning.InletBufferReserveMs",5000); inlet_buffer_reserve_samples_ = pt.get("tuning.InletBufferReserveSamples",128); smoothing_halftime_ = pt.get("tuning.SmoothingHalftime",90.0f); force_default_timestamps_ = pt.get("tuning.ForceDefaultTimestamps", false); } catch(std::exception &e) { std::cerr << "Error parsing config file " << filename << " (" << e.what() << "). Rolling back to defaults." << std::endl; // any error: assign defaults load_from_file(); // and rethrow throw e; } } /** * Instantiate / retrieve singleton. */ const api_config *api_config::get_instance() { lslboost::call_once(&called_once,once_flag); return get_instance_internal(); } api_config *api_config::get_instance_internal() { static api_config cfg; return &cfg; } void api_config::called_once() { get_instance_internal(); } lslboost::once_flag api_config::once_flag = BOOST_ONCE_INIT;
{ "pile_set_name": "Github" }
// Copyright Aleksey Gurtovoy 2000-2004 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Preprocessed version of "boost/mpl/apply_wrap.hpp" header // -- DO NOT modify by hand! namespace boost { namespace mpl { template< typename F , typename has_apply_ = typename aux::has_apply<F>::type > struct apply_wrap0 : F::template apply< > { }; template< typename F, typename T1 > struct apply_wrap1 : F::template apply<T1> { }; template< typename F, typename T1, typename T2 > struct apply_wrap2 : F::template apply< T1,T2 > { }; template< typename F, typename T1, typename T2, typename T3 > struct apply_wrap3 : F::template apply< T1,T2,T3 > { }; template< typename F, typename T1, typename T2, typename T3, typename T4 > struct apply_wrap4 : F::template apply< T1,T2,T3,T4 > { }; template< typename F, typename T1, typename T2, typename T3, typename T4 , typename T5 > struct apply_wrap5 : F::template apply< T1,T2,T3,T4,T5 > { }; }}
{ "pile_set_name": "Github" }
--- a/pppd/sha1.c +++ b/pppd/sha1.c @@ -18,7 +18,7 @@ #include <string.h> #include <netinet/in.h> /* htonl() */ -#include <net/ppp_defs.h> +#include "pppd.h" #include "sha1.h" static void
{ "pile_set_name": "Github" }
// SPDX-License-Identifier: GPL-2.0 #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include <memory.h> #include <malloc.h> #include <time.h> #include <ctype.h> #include <sys/types.h> #include <sys/wait.h> #include <signal.h> #include <errno.h> #include <sys/time.h> #include <linux/hpet.h> extern void hpet_open_close(int, const char **); extern void hpet_info(int, const char **); extern void hpet_poll(int, const char **); extern void hpet_fasync(int, const char **); extern void hpet_read(int, const char **); #include <sys/poll.h> #include <sys/ioctl.h> struct hpet_command { char *command; void (*func)(int argc, const char ** argv); } hpet_command[] = { { "open-close", hpet_open_close }, { "info", hpet_info }, { "poll", hpet_poll }, { "fasync", hpet_fasync }, }; int main(int argc, const char ** argv) { unsigned int i; argc--; argv++; if (!argc) { fprintf(stderr, "-hpet: requires command\n"); return -1; } for (i = 0; i < (sizeof (hpet_command) / sizeof (hpet_command[0])); i++) if (!strcmp(argv[0], hpet_command[i].command)) { argc--; argv++; fprintf(stderr, "-hpet: executing %s\n", hpet_command[i].command); hpet_command[i].func(argc, argv); return 0; } fprintf(stderr, "do_hpet: command %s not implemented\n", argv[0]); return -1; } void hpet_open_close(int argc, const char **argv) { int fd; if (argc != 1) { fprintf(stderr, "hpet_open_close: device-name\n"); return; } fd = open(argv[0], O_RDONLY); if (fd < 0) fprintf(stderr, "hpet_open_close: open failed\n"); else close(fd); return; } void hpet_info(int argc, const char **argv) { struct hpet_info info; int fd; if (argc != 1) { fprintf(stderr, "hpet_info: device-name\n"); return; } fd = open(argv[0], O_RDONLY); if (fd < 0) { fprintf(stderr, "hpet_info: open of %s failed\n", argv[0]); return; } if (ioctl(fd, HPET_INFO, &info) < 0) { fprintf(stderr, "hpet_info: failed to get info\n"); goto out; } fprintf(stderr, "hpet_info: hi_irqfreq 0x%lx hi_flags 0x%lx ", info.hi_ireqfreq, info.hi_flags); fprintf(stderr, "hi_hpet %d hi_timer %d\n", info.hi_hpet, info.hi_timer); out: close(fd); return; } void hpet_poll(int argc, const char **argv) { unsigned long freq; int iterations, i, fd; struct pollfd pfd; struct hpet_info info; struct timeval stv, etv; struct timezone tz; long usec; if (argc != 3) { fprintf(stderr, "hpet_poll: device-name freq iterations\n"); return; } freq = atoi(argv[1]); iterations = atoi(argv[2]); fd = open(argv[0], O_RDONLY); if (fd < 0) { fprintf(stderr, "hpet_poll: open of %s failed\n", argv[0]); return; } if (ioctl(fd, HPET_IRQFREQ, freq) < 0) { fprintf(stderr, "hpet_poll: HPET_IRQFREQ failed\n"); goto out; } if (ioctl(fd, HPET_INFO, &info) < 0) { fprintf(stderr, "hpet_poll: failed to get info\n"); goto out; } fprintf(stderr, "hpet_poll: info.hi_flags 0x%lx\n", info.hi_flags); if (info.hi_flags && (ioctl(fd, HPET_EPI, 0) < 0)) { fprintf(stderr, "hpet_poll: HPET_EPI failed\n"); goto out; } if (ioctl(fd, HPET_IE_ON, 0) < 0) { fprintf(stderr, "hpet_poll, HPET_IE_ON failed\n"); goto out; } pfd.fd = fd; pfd.events = POLLIN; for (i = 0; i < iterations; i++) { pfd.revents = 0; gettimeofday(&stv, &tz); if (poll(&pfd, 1, -1) < 0) fprintf(stderr, "hpet_poll: poll failed\n"); else { long data; gettimeofday(&etv, &tz); usec = stv.tv_sec * 1000000 + stv.tv_usec; usec = (etv.tv_sec * 1000000 + etv.tv_usec) - usec; fprintf(stderr, "hpet_poll: expired time = 0x%lx\n", usec); fprintf(stderr, "hpet_poll: revents = 0x%x\n", pfd.revents); if (read(fd, &data, sizeof(data)) != sizeof(data)) { fprintf(stderr, "hpet_poll: read failed\n"); } else fprintf(stderr, "hpet_poll: data 0x%lx\n", data); } } out: close(fd); return; } static int hpet_sigio_count; static void hpet_sigio(int val) { fprintf(stderr, "hpet_sigio: called\n"); hpet_sigio_count++; } void hpet_fasync(int argc, const char **argv) { unsigned long freq; int iterations, i, fd, value; sig_t oldsig; struct hpet_info info; hpet_sigio_count = 0; fd = -1; if ((oldsig = signal(SIGIO, hpet_sigio)) == SIG_ERR) { fprintf(stderr, "hpet_fasync: failed to set signal handler\n"); return; } if (argc != 3) { fprintf(stderr, "hpet_fasync: device-name freq iterations\n"); goto out; } fd = open(argv[0], O_RDONLY); if (fd < 0) { fprintf(stderr, "hpet_fasync: failed to open %s\n", argv[0]); return; } if ((fcntl(fd, F_SETOWN, getpid()) == 1) || ((value = fcntl(fd, F_GETFL)) == 1) || (fcntl(fd, F_SETFL, value | O_ASYNC) == 1)) { fprintf(stderr, "hpet_fasync: fcntl failed\n"); goto out; } freq = atoi(argv[1]); iterations = atoi(argv[2]); if (ioctl(fd, HPET_IRQFREQ, freq) < 0) { fprintf(stderr, "hpet_fasync: HPET_IRQFREQ failed\n"); goto out; } if (ioctl(fd, HPET_INFO, &info) < 0) { fprintf(stderr, "hpet_fasync: failed to get info\n"); goto out; } fprintf(stderr, "hpet_fasync: info.hi_flags 0x%lx\n", info.hi_flags); if (info.hi_flags && (ioctl(fd, HPET_EPI, 0) < 0)) { fprintf(stderr, "hpet_fasync: HPET_EPI failed\n"); goto out; } if (ioctl(fd, HPET_IE_ON, 0) < 0) { fprintf(stderr, "hpet_fasync, HPET_IE_ON failed\n"); goto out; } for (i = 0; i < iterations; i++) { (void) pause(); fprintf(stderr, "hpet_fasync: count = %d\n", hpet_sigio_count); } out: signal(SIGIO, oldsig); if (fd >= 0) close(fd); return; }
{ "pile_set_name": "Github" }
// // Created by Fabrice Aneche on 06/01/14. // Copyright (c) 2014 Dailymotion. All rights reserved. // #import <Foundation/Foundation.h> @interface NSData (ImageContentType) /** * Compute the content type for an image data * * @param data the input data * * @return the content type as string (i.e. image/jpeg, image/gif) */ + (NSString *)sd_contentTypeForImageData:(NSData *)data; @end @interface NSData (ImageContentTypeDeprecated) + (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`"); @end
{ "pile_set_name": "Github" }
#include "ExtractionOptionsJsonObject.h" #include <regex> namespace polycube { namespace service { namespace model { ExtractionOptionsJsonObject::ExtractionOptionsJsonObject() { m_swapOnRead = false; m_swapOnReadIsSet = true; m_emptyOnRead = false; m_emptyOnReadIsSet = true; } ExtractionOptionsJsonObject::ExtractionOptionsJsonObject(const nlohmann::json &val) : JsonObjectBase(val) { m_swapOnReadIsSet = false; m_emptyOnReadIsSet = false; if (val.count("swap-on-read")) setSwapOnRead(val.at("swap-on-read").get<bool>()); if (val.count("empty-on-read")) setEmptyOnRead(val.at("empty-on-read").get<bool>()); } nlohmann::json ExtractionOptionsJsonObject::toJson() const { nlohmann::json val = nlohmann::json::object(); if (!getBase().is_null()) val.update(getBase()); if (m_swapOnReadIsSet) val["swap-on-read"] = m_swapOnRead; if (m_emptyOnReadIsSet) val["empty-on-read"] = m_emptyOnRead; return val; } bool ExtractionOptionsJsonObject::getSwapOnRead() const { return m_swapOnRead; } void ExtractionOptionsJsonObject::setSwapOnRead(bool value) { m_swapOnRead = value; m_swapOnReadIsSet = true; } bool ExtractionOptionsJsonObject::swapOnReadIsSet() const { return m_swapOnReadIsSet; } void ExtractionOptionsJsonObject::unsetSwapOnRead() { m_swapOnReadIsSet = false; } bool ExtractionOptionsJsonObject::getEmptyOnRead() const { return m_emptyOnRead; } void ExtractionOptionsJsonObject::setEmptyOnRead(bool value) { m_emptyOnRead = value; m_emptyOnReadIsSet = true; } bool ExtractionOptionsJsonObject::emptyOnReadIsSet() const { return m_emptyOnReadIsSet; } void ExtractionOptionsJsonObject::unsetEmptyOnRead() { m_emptyOnReadIsSet = false; } }// namespace model }// namespace service }// namespace polycube
{ "pile_set_name": "Github" }
/* Mantis PCI bridge driver Copyright (C) Manu Abraham (abraham.manu@gmail.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <asm/io.h> #include <linux/ioport.h> #include <linux/pci.h> #include <linux/i2c.h> #include "dmxdev.h" #include "dvbdev.h" #include "dvb_demux.h" #include "dvb_frontend.h" #include "dvb_net.h" #include "mantis_common.h" #include "mantis_reg.h" #include "mantis_i2c.h" #define TRIALS 10000 static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg) { u32 rxd, i, stat, trials; dprintk(MANTIS_INFO, 0, " %s: Address=[0x%02x] <R>[ ", __func__, msg->addr); for (i = 0; i < msg->len; i++) { rxd = (msg->addr << 25) | (1 << 24) | MANTIS_I2C_RATE_3 | MANTIS_I2C_STOP | MANTIS_I2C_PGMODE; if (i == (msg->len - 1)) rxd &= ~MANTIS_I2C_STOP; mmwrite(MANTIS_INT_I2CDONE, MANTIS_INT_STAT); mmwrite(rxd, MANTIS_I2CDATA_CTL); /* wait for xfer completion */ for (trials = 0; trials < TRIALS; trials++) { stat = mmread(MANTIS_INT_STAT); if (stat & MANTIS_INT_I2CDONE) break; } dprintk(MANTIS_TMG, 0, "I2CDONE: trials=%d\n", trials); /* wait for xfer completion */ for (trials = 0; trials < TRIALS; trials++) { stat = mmread(MANTIS_INT_STAT); if (stat & MANTIS_INT_I2CRACK) break; } dprintk(MANTIS_TMG, 0, "I2CRACK: trials=%d\n", trials); rxd = mmread(MANTIS_I2CDATA_CTL); msg->buf[i] = (u8)((rxd >> 8) & 0xFF); dprintk(MANTIS_INFO, 0, "%02x ", msg->buf[i]); } dprintk(MANTIS_INFO, 0, "]\n"); return 0; } static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msg) { int i; u32 txd = 0, stat, trials; dprintk(MANTIS_INFO, 0, " %s: Address=[0x%02x] <W>[ ", __func__, msg->addr); for (i = 0; i < msg->len; i++) { dprintk(MANTIS_INFO, 0, "%02x ", msg->buf[i]); txd = (msg->addr << 25) | (msg->buf[i] << 8) | MANTIS_I2C_RATE_3 | MANTIS_I2C_STOP | MANTIS_I2C_PGMODE; if (i == (msg->len - 1)) txd &= ~MANTIS_I2C_STOP; mmwrite(MANTIS_INT_I2CDONE, MANTIS_INT_STAT); mmwrite(txd, MANTIS_I2CDATA_CTL); /* wait for xfer completion */ for (trials = 0; trials < TRIALS; trials++) { stat = mmread(MANTIS_INT_STAT); if (stat & MANTIS_INT_I2CDONE) break; } dprintk(MANTIS_TMG, 0, "I2CDONE: trials=%d\n", trials); /* wait for xfer completion */ for (trials = 0; trials < TRIALS; trials++) { stat = mmread(MANTIS_INT_STAT); if (stat & MANTIS_INT_I2CRACK) break; } dprintk(MANTIS_TMG, 0, "I2CRACK: trials=%d\n", trials); } dprintk(MANTIS_INFO, 0, "]\n"); return 0; } static int mantis_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) { int ret = 0, i = 0, trials; u32 stat, data, txd; struct mantis_pci *mantis; struct mantis_hwconfig *config; mantis = i2c_get_adapdata(adapter); BUG_ON(!mantis); config = mantis->hwconfig; BUG_ON(!config); dprintk(MANTIS_DEBUG, 1, "Messages:%d", num); mutex_lock(&mantis->i2c_lock); while (i < num) { /* Byte MODE */ if ((config->i2c_mode & MANTIS_BYTE_MODE) && ((i + 1) < num) && (msgs[i].len < 2) && (msgs[i + 1].len < 2) && (msgs[i + 1].flags & I2C_M_RD)) { dprintk(MANTIS_DEBUG, 0, " Byte MODE:\n"); /* Read operation */ txd = msgs[i].addr << 25 | (0x1 << 24) | (msgs[i].buf[0] << 16) | MANTIS_I2C_RATE_3; mmwrite(txd, MANTIS_I2CDATA_CTL); /* wait for xfer completion */ for (trials = 0; trials < TRIALS; trials++) { stat = mmread(MANTIS_INT_STAT); if (stat & MANTIS_INT_I2CDONE) break; } /* check for xfer completion */ if (stat & MANTIS_INT_I2CDONE) { /* check xfer was acknowledged */ if (stat & MANTIS_INT_I2CRACK) { data = mmread(MANTIS_I2CDATA_CTL); msgs[i + 1].buf[0] = (data >> 8) & 0xff; dprintk(MANTIS_DEBUG, 0, " Byte <%d> RXD=0x%02x [%02x]\n", 0x0, data, msgs[i + 1].buf[0]); } else { /* I/O error */ dprintk(MANTIS_ERROR, 1, " I/O error, LINE:%d", __LINE__); ret = -EIO; break; } } else { /* I/O error */ dprintk(MANTIS_ERROR, 1, " I/O error, LINE:%d", __LINE__); ret = -EIO; break; } i += 2; /* Write/Read operation in one go */ } if (i < num) { if (msgs[i].flags & I2C_M_RD) ret = mantis_i2c_read(mantis, &msgs[i]); else ret = mantis_i2c_write(mantis, &msgs[i]); i++; if (ret < 0) goto bail_out; } } mutex_unlock(&mantis->i2c_lock); return num; bail_out: mutex_unlock(&mantis->i2c_lock); return ret; } static u32 mantis_i2c_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_EMUL; } static struct i2c_algorithm mantis_algo = { .master_xfer = mantis_i2c_xfer, .functionality = mantis_i2c_func, }; int __devinit mantis_i2c_init(struct mantis_pci *mantis) { u32 intstat, intmask; struct i2c_adapter *i2c_adapter = &mantis->adapter; struct pci_dev *pdev = mantis->pdev; init_waitqueue_head(&mantis->i2c_wq); mutex_init(&mantis->i2c_lock); strncpy(i2c_adapter->name, "Mantis I2C", sizeof(i2c_adapter->name)); i2c_set_adapdata(i2c_adapter, mantis); i2c_adapter->owner = THIS_MODULE; i2c_adapter->algo = &mantis_algo; i2c_adapter->algo_data = NULL; i2c_adapter->timeout = 500; i2c_adapter->retries = 3; i2c_adapter->dev.parent = &pdev->dev; mantis->i2c_rc = i2c_add_adapter(i2c_adapter); if (mantis->i2c_rc < 0) return mantis->i2c_rc; dprintk(MANTIS_DEBUG, 1, "Initializing I2C .."); intstat = mmread(MANTIS_INT_STAT); intmask = mmread(MANTIS_INT_MASK); mmwrite(intstat, MANTIS_INT_STAT); dprintk(MANTIS_DEBUG, 1, "Disabling I2C interrupt"); intmask = mmread(MANTIS_INT_MASK); mmwrite((intmask & ~MANTIS_INT_I2CDONE), MANTIS_INT_MASK); return 0; } EXPORT_SYMBOL_GPL(mantis_i2c_init); int mantis_i2c_exit(struct mantis_pci *mantis) { u32 intmask; dprintk(MANTIS_DEBUG, 1, "Disabling I2C interrupt"); intmask = mmread(MANTIS_INT_MASK); mmwrite((intmask & ~MANTIS_INT_I2CDONE), MANTIS_INT_MASK); dprintk(MANTIS_DEBUG, 1, "Removing I2C adapter"); return i2c_del_adapter(&mantis->adapter); } EXPORT_SYMBOL_GPL(mantis_i2c_exit);
{ "pile_set_name": "Github" }
#include <elle/das/tuple.hh> #include <elle/test.hh> #include <elle/serialization/json.hh> #include <elle/das/Symbol.hh> #include <elle/das/serializer.hh> ELLE_DAS_SYMBOL(foo); ELLE_DAS_SYMBOL(bar); static void basics() { auto t = elle::das::make_tuple(foo = 3, bar = "lol"); BOOST_CHECK_EQUAL(t.foo, 3); BOOST_CHECK_EQUAL(t.bar, "lol"); } static void move() { elle::das::make_tuple(foo = elle::make_unique<int>(42), bar = std::vector<int>()); auto f = elle::make_unique<int>(42); auto b = std::vector<int>(); elle::das::make_tuple(foo = std::move(f), bar = b); } static void print() { auto t = elle::das::make_tuple(foo = 3, bar = "lol"); BOOST_CHECK_EQUAL(elle::sprintf("%s", t), "(foo = 3, bar = lol)"); } static void serialize() { auto t = elle::das::make_tuple(foo = 3, bar = std::string("lol")); auto s = elle::serialization::json::serialize(t); auto j = elle::json::read(s.string()); BOOST_CHECK(j["foo"] == 3); BOOST_CHECK(j["bar"] == "lol"); auto d = elle::serialization::json::deserialize<decltype(t)>(s); BOOST_CHECK(d.foo == t.foo); BOOST_CHECK(d.bar == t.bar); } static void hash() { using elle::das::make_tuple; BOOST_TEST( hash_value(elle::das::make_tuple()) == hash_value(elle::das::make_tuple())); BOOST_TEST( hash_value(elle::das::make_tuple(foo = 3, bar = std::string("lol"))) == hash_value(elle::das::make_tuple(foo = 3, bar = std::string("lol")))); BOOST_TEST( hash_value(elle::das::make_tuple(foo = 3, bar = std::string("lol"))) != hash_value(elle::das::make_tuple(foo = 4, bar = std::string("lol")))); BOOST_TEST( hash_value(elle::das::make_tuple(foo = 3, bar = std::string("lol"))) != hash_value(elle::das::make_tuple(foo = 3, bar = std::string("bar")))); BOOST_TEST( hash_value(elle::das::make_tuple(foo = 3, bar = std::string("lol"))) != hash_value(elle::das::make_tuple(bar = std::string("lol"), foo = 3))); } static void compare() { BOOST_TEST( elle::das::make_tuple() == elle::das::make_tuple()); BOOST_TEST( elle::das::make_tuple(foo = 3, bar = std::string("lol")) == elle::das::make_tuple(foo = 3, bar = std::string("lol"))); BOOST_TEST( elle::das::make_tuple(foo = 3, bar = std::string("lol")) != elle::das::make_tuple(foo = 4, bar = std::string("lol"))); BOOST_TEST( elle::das::make_tuple(foo = 3, bar = std::string("lol")) != elle::das::make_tuple(foo = 3, bar = std::string("bar"))); } /*-------. | Driver | `-------*/ ELLE_TEST_SUITE() { auto& master = boost::unit_test::framework::master_test_suite(); master.add(BOOST_TEST_CASE(basics)); master.add(BOOST_TEST_CASE(move)); master.add(BOOST_TEST_CASE(print)); master.add(BOOST_TEST_CASE(serialize)); master.add(BOOST_TEST_CASE(hash)); master.add(BOOST_TEST_CASE(compare)); }
{ "pile_set_name": "Github" }
// Copyright 2001-2019 Crytek GmbH / Crytek Group. All rights reserved. #pragma once namespace Designer { class Model; enum ECompilerFlag { eCompiler_CastShadow = BIT(1), eCompiler_Physicalize = BIT(2), eCompiler_General = eCompiler_CastShadow | eCompiler_Physicalize }; //! This class plays a role of creating engine resources used for rendering and physicalizing out of the Designer::Model instance. class ModelCompiler : public _i_reference_target_t { public: ModelCompiler(int nCompilerFlag); ModelCompiler(const ModelCompiler& compiler); virtual ~ModelCompiler(); bool IsValid() const; void Compile(CBaseObject* pBaseObject, Model* pModel, ShelfID shelfID = eShelf_Any, bool bUpdateOnlyRenderNode = false); void DeleteAllRenderNodes(); void DeleteRenderNode(ShelfID shelfID); IRenderNode* GetRenderNode() { return m_pRenderNode[0]; } void UpdateHighlightPassState(bool bSelected, bool bHighlighted); bool GetIStatObj(_smart_ptr<IStatObj>* pStatObj); bool CreateIndexdMesh(Model* pModel, IIndexedMesh* pMesh, bool bCreateBackFaces); void SaveToCgf(const char* filename); void SetViewDistRatio(int nViewDistRatio) { m_viewDistRatio = nViewDistRatio; } int GetViewDistRatio() const { return m_viewDistRatio; } void SetRenderFlags(uint64 nRenderFlag) { m_RenderFlags = nRenderFlag; } uint64 GetRenderFlags() const { return m_RenderFlags; } void SetStaticObjFlags(int nStaticObjFlag); int GetStaticObjFlags(); void SetSelected(bool bSelect); void AddFlags(int nFlags) { m_nCompilerFlag |= nFlags; } void RemoveFlags(int nFlags) { m_nCompilerFlag &= (~nFlags); } bool CheckFlags(int nFlags) const { return (m_nCompilerFlag & nFlags) ? true : false; } void SaveMesh(CArchive& ar, CBaseObject* pObj, Model* pModel); bool LoadMesh(CArchive& ar, CBaseObject* pObj, Model* pModel); bool SaveMesh(int nVersion, std::vector<char>& buffer, CBaseObject* pObj, Model* pModel); bool LoadMesh(int nVersion, std::vector<char>& buffer, CBaseObject* pObj, Model* pModel); private: bool UpdateMesh(CBaseObject* pBaseObject, Model* pModel, ShelfID nShelf); void UpdateRenderNode(CBaseObject* pBaseObject, ShelfID nShelf); void RemoveStatObj(ShelfID nShelf); void CreateStatObj(ShelfID nShelf); IMaterial* GetMaterialFromBaseObj(CBaseObject* pObj) const; void InvalidateStatObj(IStatObj* pStatObj, bool bPhysics); private: mutable IStatObj* m_pStatObj[cShelfMax]; mutable IRenderNode* m_pRenderNode[cShelfMax]; uint64 m_RenderFlags; int m_viewDistRatio; int m_nCompilerFlag; }; }
{ "pile_set_name": "Github" }
// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2012 Giacomo Po <gpo@ucla.edu> // Copyright (C) 2011 Gael Guennebaud <g.gael@free.fr> // // 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 <cmath> #include "../../test/sparse_solver.h" #include <Eigen/IterativeSolvers> template<typename T> void test_minres_T() { // Identity preconditioner MINRES<SparseMatrix<T>, Lower, IdentityPreconditioner > minres_colmajor_lower_I; MINRES<SparseMatrix<T>, Upper, IdentityPreconditioner > minres_colmajor_upper_I; // Diagonal preconditioner MINRES<SparseMatrix<T>, Lower, DiagonalPreconditioner<T> > minres_colmajor_lower_diag; MINRES<SparseMatrix<T>, Upper, DiagonalPreconditioner<T> > minres_colmajor_upper_diag; MINRES<SparseMatrix<T>, Lower|Upper, DiagonalPreconditioner<T> > minres_colmajor_uplo_diag; // call tests for SPD matrix CALL_SUBTEST( check_sparse_spd_solving(minres_colmajor_lower_I) ); CALL_SUBTEST( check_sparse_spd_solving(minres_colmajor_upper_I) ); CALL_SUBTEST( check_sparse_spd_solving(minres_colmajor_lower_diag) ); CALL_SUBTEST( check_sparse_spd_solving(minres_colmajor_upper_diag) ); CALL_SUBTEST( check_sparse_spd_solving(minres_colmajor_uplo_diag) ); // TO DO: symmetric semi-definite matrix // TO DO: symmetric indefinite matrix } void test_minres() { CALL_SUBTEST_1(test_minres_T<double>()); // CALL_SUBTEST_2(test_minres_T<std::compex<double> >()); }
{ "pile_set_name": "Github" }
#define YEAR 2013 #define STATUS "release" #ifndef ROOT_DIR #define ROOT_DIR ".." #endif #define BUILD_DIR ROOT_DIR + "/build/NetBox/ #ifndef SOURCE_DIR #define SOURCE_DIR ROOT_DIR + "/src/NetBox" #endif #ifndef OUTPUT_DIR #define OUTPUT_DIR ROOT_DIR + "/build" #endif #ifndef BINARIES_DIR_FAR2 #define BINARIES_DIR_FAR2 BUILD_DIR + "/Far2" #endif #ifndef BINARIES_DIR_FAR3 #define BINARIES_DIR_FAR3 BUILD_DIR + "/Far3" #endif #ifndef PUTTY_SOURCE_DIR #define PUTTY_SOURCE_DIR "C:/Program Files/Putty" #endif #define FileSourceMain_Far2x86 BINARIES_DIR_FAR2 + "/x86/NetBox.dll" #define FileSourceMain_Far2x64 BINARIES_DIR_FAR2 + "/x64/NetBox.dll" #define FileSourceMain_Far3x86 BINARIES_DIR_FAR3 + "/x86/NetBox.dll" #define FileSourceMain_Far3x64 BINARIES_DIR_FAR3 + "/x64/NetBox.dll" #define FileSourceEng SOURCE_DIR + "/NetBoxEng.lng" #define FileSourceRus SOURCE_DIR + "/NetBoxRus.lng" #define FileSourceChangeLog ROOT_DIR + "/ChangeLog" #define FileSourceReadmeEng ROOT_DIR + "/README.md" #define FileSourceReadmeRu ROOT_DIR + "/README.RU.md" #define FileSourceLicense ROOT_DIR + "/LICENSE.txt" #define PluginSubDirName "NetBox" #define Major #define Minor #define Rev #define Build #expr ParseVersion(FileSourceMain_Far2x86, Major, Minor, Rev, Build) #define Version Str(Major) + "." + Str(Minor) + (Rev > 0 ? "." + Str(Rev) : "") + \ (STATUS != "" ? " " + STATUS : "") [Setup] AppId=netbox AppMutex=NetBox AppName=NetBox plugin for Far2/Far3 AppPublisher=Michael Lukashov AppPublisherURL=https://github.com/michaellukashov/Far-NetBox AppSupportURL=http://forum.farmanager.com/viewtopic.php?f=39&t=6638 AppUpdatesURL=http://plugring.farmanager.com/plugin.php?pid=859&l=en VersionInfoCompany=Michael Lukashov VersionInfoDescription=Setup for NetBox plugin for Far2/Far3 {#Version} VersionInfoVersion={#Major}.{#Minor}.{#Rev}.{#Build} VersionInfoTextVersion={#Version} VersionInfoCopyright=(c) 2011-{#YEAR} Michael Lukashov DefaultDirName={pf}\Far Manager\Plugins\{#PluginSubDirName} UsePreviousAppDir=false DisableProgramGroupPage=true LicenseFile=licence.setup ; UninstallDisplayIcon={app}\winscp.ico OutputDir={#OUTPUT_DIR} DisableStartupPrompt=yes AppVersion={#Version} AppVerName=NetBox plugin for Far2/Far3 {#Version} OutputBaseFilename=FarNetBox-{#Major}.{#Minor}.{#Rev}_Far2_Far3_x86_x64 Compression=lzma2/ultra SolidCompression=yes PrivilegesRequired=none Uninstallable=no MinVersion=5.1 DisableDirPage=yes ; AlwaysShowDirOnReadyPage=yes ArchitecturesInstallIn64BitMode=x64 [Types] Name: full; Description: "Full installation" ; Name: compact; Description: "Compact installation" Name: custom; Description: "Custom installation"; Flags: iscustom ; Languages: en ru [Components] Name: main_far2_x86; Description: "NetBox for Far2/x86"; Types: full custom; check: IsFar2X86Installed Name: main_far2_x64; Description: "NetBox for Far2/x64"; Types: full custom; check: IsWin64 and IsFar3X64Installed Name: main_far3_x86; Description: "NetBox for Far3/x86"; Types: full custom; check: IsFar3X86Installed Name: main_far3_x64; Description: "NetBox for Far3/x64"; Types: full custom; check: IsWin64 and IsFar3X64Installed ; Name: pageant; Description: "Pageant (SSH authentication agent)"; Types: full ; Name: puttygen; Description: "PuTTYgen (key generator)"; Types: full [Files] Source: "{#FileSourceMain_Far2x86}"; DestName: "NetBox.dll"; DestDir: "{code:GetPlugin2X86Dir}"; Components: main_far2_x86; Flags: ignoreversion Source: "{#FileSourceMain_Far2x64}"; DestName: "NetBox.dll"; DestDir: "{code:GetPlugin2X64Dir}"; Components: main_far2_x64; Flags: ignoreversion Source: "{#FileSourceMain_Far3x86}"; DestName: "NetBox.dll"; DestDir: "{code:GetPlugin3X86Dir}"; Components: main_far3_x86; Flags: ignoreversion Source: "{#FileSourceMain_Far3x64}"; DestName: "NetBox.dll"; DestDir: "{code:GetPlugin3X64Dir}"; Components: main_far3_x64; Flags: ignoreversion Source: "{#FileSourceEng}"; DestName: "NetBoxEng.lng"; DestDir: "{code:GetPlugin2X86Dir}"; Components: main_far2_x86; Flags: ignoreversion Source: "{#FileSourceEng}"; DestName: "NetBoxEng.lng"; DestDir: "{code:GetPlugin2X64Dir}"; Components: main_far2_x64; Flags: ignoreversion Source: "{#FileSourceEng}"; DestName: "NetBoxEng.lng"; DestDir: "{code:GetPlugin3X86Dir}"; Components: main_far3_x86; Flags: ignoreversion Source: "{#FileSourceEng}"; DestName: "NetBoxEng.lng"; DestDir: "{code:GetPlugin3X64Dir}"; Components: main_far3_x64; Flags: ignoreversion Source: "{#FileSourceRus}"; DestName: "NetBoxRus.lng"; DestDir: "{code:GetPlugin2X86Dir}"; Components: main_far2_x86; Flags: ignoreversion Source: "{#FileSourceRus}"; DestName: "NetBoxRus.lng"; DestDir: "{code:GetPlugin2X64Dir}"; Components: main_far2_x64; Flags: ignoreversion Source: "{#FileSourceRus}"; DestName: "NetBoxRus.lng"; DestDir: "{code:GetPlugin3X86Dir}"; Components: main_far3_x86; Flags: ignoreversion Source: "{#FileSourceRus}"; DestName: "NetBoxRus.lng"; DestDir: "{code:GetPlugin3X64Dir}"; Components: main_far3_x64; Flags: ignoreversion Source: "{#FileSourceChangeLog}"; DestName: "ChangeLog"; DestDir: "{code:GetPlugin2X86Dir}"; Components: main_far2_x86; Flags: ignoreversion Source: "{#FileSourceChangeLog}"; DestName: "ChangeLog"; DestDir: "{code:GetPlugin2X64Dir}"; Components: main_far2_x64; Flags: ignoreversion Source: "{#FileSourceChangeLog}"; DestName: "ChangeLog"; DestDir: "{code:GetPlugin3X86Dir}"; Components: main_far3_x86; Flags: ignoreversion Source: "{#FileSourceChangeLog}"; DestName: "ChangeLog"; DestDir: "{code:GetPlugin3X64Dir}"; Components: main_far3_x64; Flags: ignoreversion Source: "{#FileSourceReadmeEng}"; DestName: "README.md"; DestDir: "{code:GetPlugin2X86Dir}"; Components: main_far2_x86; Flags: ignoreversion Source: "{#FileSourceReadmeEng}"; DestName: "README.md"; DestDir: "{code:GetPlugin2X64Dir}"; Components: main_far2_x64; Flags: ignoreversion Source: "{#FileSourceReadmeEng}"; DestName: "README.md"; DestDir: "{code:GetPlugin3X86Dir}"; Components: main_far3_x86; Flags: ignoreversion Source: "{#FileSourceReadmeEng}"; DestName: "README.md"; DestDir: "{code:GetPlugin3X64Dir}"; Components: main_far3_x64; Flags: ignoreversion Source: "{#FileSourceReadmeRu}"; DestName: "README.RU.md"; DestDir: "{code:GetPlugin2X86Dir}"; Components: main_far2_x86; Flags: ignoreversion Source: "{#FileSourceReadmeRu}"; DestName: "README.RU.md"; DestDir: "{code:GetPlugin2X64Dir}"; Components: main_far2_x64; Flags: ignoreversion Source: "{#FileSourceReadmeRu}"; DestName: "README.RU.md"; DestDir: "{code:GetPlugin3X86Dir}"; Components: main_far3_x86; Flags: ignoreversion Source: "{#FileSourceReadmeRu}"; DestName: "README.RU.md"; DestDir: "{code:GetPlugin3X64Dir}"; Components: main_far3_x64; Flags: ignoreversion Source: "{#FileSourceLicense}"; DestName: "LICENSE.txt"; DestDir: "{code:GetPlugin2X86Dir}"; Components: main_far2_x86; Flags: ignoreversion Source: "{#FileSourceLicense}"; DestName: "LICENSE.txt"; DestDir: "{code:GetPlugin2X64Dir}"; Components: main_far2_x64; Flags: ignoreversion Source: "{#FileSourceLicense}"; DestName: "LICENSE.txt"; DestDir: "{code:GetPlugin3X86Dir}"; Components: main_far3_x86; Flags: ignoreversion Source: "{#FileSourceLicense}"; DestName: "LICENSE.txt"; DestDir: "{code:GetPlugin3X64Dir}"; Components: main_far3_x64; Flags: ignoreversion ; Source: "{#PUTTY_SOURCE_DIR}\LICENCE"; DestDir: "{code:GetPluginX86Dir}\PuTTY"; Components: main_x86 pageant puttygen; Flags: ignoreversion ; Source: "{#PUTTY_SOURCE_DIR}\LICENCE"; DestDir: "{code:GetPluginX64Dir}\PuTTY"; Components: main_x64 pageant puttygen; Flags: ignoreversion ; Source: "{#PUTTY_SOURCE_DIR}\putty.hlp"; DestDir: "{code:GetPluginX86Dir}\PuTTY"; Components: main_x86 pageant puttygen; Flags: ignoreversion ; Source: "{#PUTTY_SOURCE_DIR}\putty.hlp"; DestDir: "{code:GetPluginX64Dir}\PuTTY"; Components: main_x64 pageant puttygen; Flags: ignoreversion ; Source: "{#PUTTY_SOURCE_DIR}\pageant.exe"; DestDir: "{code:GetPluginX86Dir}\PuTTY"; Components: main_x86 pageant; Flags: ignoreversion ; Source: "{#PUTTY_SOURCE_DIR}\pageant.exe"; DestDir: "{code:GetPluginX64Dir}\PuTTY"; Components: main_x64 pageant; Flags: ignoreversion ; Source: "{#PUTTY_SOURCE_DIR}\puttygen.exe"; DestDir: "{code:GetPluginX86Dir}\PuTTY"; Components: main_x86 puttygen; Flags: ignoreversion ; Source: "{#PUTTY_SOURCE_DIR}\puttygen.exe"; DestDir: "{code:GetPluginX64Dir}\PuTTY"; Components: main_x64 puttygen; Flags: ignoreversion [InstallDelete] [Code] var InputDirsPage: TInputDirWizardPage; function GetFar2X86InstallDir(): String; var InstallDir: String; begin if RegQueryStringValue(HKLM, 'Software\Far2', 'InstallDir', InstallDir) or RegQueryStringValue(HKCU, 'Software\Far2', 'InstallDir', InstallDir) then begin Result := InstallDir; end; end; function GetFar2X64InstallDir(): String; var InstallDir: String; begin if RegQueryStringValue(HKCU, 'Software\Far2', 'InstallDir_x64', InstallDir) or RegQueryStringValue(HKLM, 'Software\Far2', 'InstallDir_x64', InstallDir) then begin Result := InstallDir; end; end; function IsFar2X86Installed(): Boolean; begin Result := GetFar2X86InstallDir() <> ''; end; function IsFar2X64Installed(): Boolean; begin Result := GetFar2X64InstallDir() <> ''; end; function GetDefaultFar2X86Dir(): String; var InstallDir: String; begin InstallDir := GetFar2X86InstallDir(); if InstallDir <> '' then begin Result := AddBackslash(InstallDir) + 'Plugins\{#PluginSubDirName}'; end else begin Result := ExpandConstant('{pf}\Far2\Plugins\{#PluginSubDirName}'); end; end; function GetDefaultFar2X64Dir(): String; var InstallDir: String; begin InstallDir := GetFar2X64InstallDir(); if InstallDir <> '' then begin Result := AddBackslash(InstallDir) + 'Plugins\{#PluginSubDirName}'; end else begin Result := ExpandConstant('{pf}\Far2\Plugins\{#PluginSubDirName}'); end; end; function GetPlugin2X86Dir(Param: String): String; begin Result := InputDirsPage.Values[0]; end; function GetPlugin2X64Dir(Param: String): String; begin Result := InputDirsPage.Values[1]; end; function GetFar3X86InstallDir(): String; var InstallDir: String; begin if RegQueryStringValue(HKLM, 'Software\Far Manager', 'InstallDir', InstallDir) or RegQueryStringValue(HKCU, 'Software\Far Manager', 'InstallDir', InstallDir) then begin Result := InstallDir; end; end; function GetFar3X64InstallDir(): String; var InstallDir: String; begin if RegQueryStringValue(HKLM, 'Software\Far Manager', 'InstallDir_x64', InstallDir) or RegQueryStringValue(HKCU, 'Software\Far Manager', 'InstallDir_x64', InstallDir) then begin Result := InstallDir; end; end; function IsFar3X86Installed(): Boolean; begin Result := GetFar3X86InstallDir() <> ''; end; function IsFar3X64Installed(): Boolean; begin Result := GetFar3X64InstallDir() <> ''; end; function GetDefaultFar3X86Dir(): String; var InstallDir: String; begin InstallDir := GetFar3X86InstallDir(); if InstallDir <> '' then begin Result := AddBackslash(InstallDir) + 'Plugins\{#PluginSubDirName}'; end else begin Result := ExpandConstant('{pf}\Far Manager\Plugins\{#PluginSubDirName}'); end; end; function GetDefaultFar3X64Dir(): String; var InstallDir: String; begin InstallDir := GetFar3X64InstallDir(); if InstallDir <> '' then begin Result := AddBackslash(InstallDir) + 'Plugins\{#PluginSubDirName}'; end else begin Result := ExpandConstant('{pf}\Far Manager\Plugins\{#PluginSubDirName}'); end; end; function GetPlugin3X86Dir(Param: String): String; begin Result := InputDirsPage.Values[2]; end; function GetPlugin3X64Dir(Param: String): String; begin Result := InputDirsPage.Values[3]; end; procedure CreateTheWizardPage; begin // Input dirs InputDirsPage := CreateInputDirPage(wpSelectComponents, 'Select plugin location', 'Where plugin should be installed?', 'Plugin will be installed in the following folder(s).'#13#10#13#10 + 'To continue, click Next. If you would like to select a different folder, click Browse.', False, 'Plugin folder'); InputDirsPage.Add('Far2/x86 plugin location:'); InputDirsPage.Values[0] := GetDefaultFar2X86Dir(); InputDirsPage.Add('Far2/x64 plugin location:'); InputDirsPage.Values[1] := GetDefaultFar2X64Dir(); InputDirsPage.Add('Far3/x86 plugin location:'); InputDirsPage.Values[2] := GetDefaultFar3X86Dir(); InputDirsPage.Add('Far3/x64 plugin location:'); InputDirsPage.Values[3] := GetDefaultFar3X64Dir(); end; procedure SetupInputDirs(); begin InputDirsPage.Edits[0].Enabled := IsComponentSelected('main_far2_x86'); InputDirsPage.Buttons[0].Enabled := IsComponentSelected('main_far2_x86'); InputDirsPage.PromptLabels[0].Enabled := IsComponentSelected('main_far2_x86'); // InputDirsPage.Edits[1].Visible := IsWin64(); // InputDirsPage.Buttons[1].Visible := IsWin64(); // InputDirsPage.PromptLabels[1].Visible := IsWin64(); InputDirsPage.Edits[1].Enabled := IsComponentSelected('main_far2_x64'); InputDirsPage.Buttons[1].Enabled := IsComponentSelected('main_far2_x64'); InputDirsPage.PromptLabels[1].Enabled := IsComponentSelected('main_far2_x64'); InputDirsPage.Edits[2].Enabled := IsComponentSelected('main_far3_x86'); InputDirsPage.Buttons[2].Enabled := IsComponentSelected('main_far3_x86'); InputDirsPage.PromptLabels[2].Enabled := IsComponentSelected('main_far3_x86'); // InputDirsPage.Edits[3].Visible := IsWin64(); // InputDirsPage.Buttons[3].Visible := IsWin64(); // InputDirsPage.PromptLabels[3].Visible := IsWin64(); InputDirsPage.Edits[3].Enabled := IsComponentSelected('main_far3_x64'); InputDirsPage.Buttons[3].Enabled := IsComponentSelected('main_far3_x64'); InputDirsPage.PromptLabels[3].Enabled := IsComponentSelected('main_far3_x64'); end; function NextButtonClick(CurPageID: Integer): Boolean; begin if CurPageID = wpWelcome then begin // SetupComponents(); end else if CurPageID = wpSelectComponents then begin SetupInputDirs(); end else if CurPageID = InputDirsPage.ID then begin WizardForm.DirEdit.Text := InputDirsPage.Values[0]; end; Result := True; end; function BackButtonClick(CurPageID: Integer): Boolean; begin // MsgBox('CurPageID: ' + IntToStr(CurPageID), mbInformation, mb_Ok); if CurPageID = InputDirsPage.ID then begin // SetupComponents(); end; if CurPageID = wpReady then begin SetupInputDirs(); end; Result := True; end; procedure InitializeWizard(); begin // Custom wizard page CreateTheWizardPage; WizardForm.LicenseAcceptedRadio.Checked := True; end;
{ "pile_set_name": "Github" }
/* fre:ac - free audio converter * Copyright (C) 2001-2020 Robert Kausch <robert.kausch@freac.org> * * 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 PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include <dialogs/config/configcomponent.h> #include <config.h> #include <resources.h> #ifdef __WIN32__ # include <smooth/init.win32.h> #endif using namespace BoCA; using namespace BoCA::AS; freac::ConfigComponentDialog::ConfigComponentDialog(Component *component) { BoCA::Config *config = BoCA::Config::Get(); BoCA::I18n *i18n = BoCA::I18n::Get(); i18n->SetContext("Configuration"); layer = component->GetConfigurationLayer(); if (layer != NIL) { mainWnd = new Window(component->GetName(), Point(config->GetIntValue(Config::CategorySettingsID, Config::SettingsWindowPosXID, Config::SettingsWindowPosXDefault), config->GetIntValue(Config::CategorySettingsID, Config::SettingsWindowPosYID, Config::SettingsWindowPosYDefault)) + Point(60, 60), layer->GetSize() + Size(8, 73)); mainWnd->SetRightToLeft(i18n->IsActiveLanguageRightToLeft()); mainWnd_titlebar = new Titlebar(TB_CLOSEBUTTON); divbar = new Divider(39, OR_HORZ | OR_BOTTOM); btn_cancel = new Button(i18n->TranslateString("Cancel"), Point(175, 29), Size()); btn_cancel->onAction.Connect(&ConfigComponentDialog::Cancel, this); btn_cancel->SetOrientation(OR_LOWERRIGHT); btn_ok = new Button(i18n->TranslateString("OK"), btn_cancel->GetPosition() - Point(88, 0), Size()); btn_ok->onAction.Connect(&ConfigComponentDialog::OK, this); btn_ok->SetOrientation(OR_LOWERRIGHT); Add(mainWnd); mainWnd->Add(mainWnd_titlebar); mainWnd->Add(divbar); mainWnd->Add(btn_ok); mainWnd->Add(btn_cancel); mainWnd->GetMainLayer()->Add(layer); mainWnd->SetFlags(mainWnd->GetFlags() | WF_NOTASKBUTTON | WF_MODAL); mainWnd->SetIcon(ImageLoader::Load(String(Config::Get()->resourcesPath).Append("icons/freac.png"))); #ifdef __WIN32__ mainWnd->SetIconDirect(LoadImageA(hInstance, MAKEINTRESOURCEA(IDI_ICON), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED)); #endif } else { mainWnd = NIL; mainWnd_titlebar = NIL; btn_cancel = NIL; btn_ok = NIL; divbar = NIL; } } freac::ConfigComponentDialog::~ConfigComponentDialog() { if (layer == NIL) return; DeleteObject(mainWnd_titlebar); DeleteObject(mainWnd); DeleteObject(btn_ok); DeleteObject(btn_cancel); DeleteObject(divbar); } const Error &freac::ConfigComponentDialog::ShowDialog() { if (layer != NIL) mainWnd->WaitUntilClosed(); else error = Error(); return error; } Void freac::ConfigComponentDialog::OK() { if (layer->SaveSettings() == Error()) return; mainWnd->Close(); } Void freac::ConfigComponentDialog::Cancel() { mainWnd->Close(); }
{ "pile_set_name": "Github" }
--- record.c.orig 2001-08-14 20:10:46.000000000 +0800 +++ record.c 2011-09-05 15:09:11.000000000 +0800 @@ -31,14 +31,18 @@ ** May 25, 2000 Ver 1.0 */ -#include<stdio.h> -#include<fcntl.h> -#include<sys/types.h> -#include<pwd.h> -#include<ctype.h> -#include<errno.h> +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <pwd.h> +#include <ctype.h> +#include <errno.h> -#include"record.h" +#include "record.h" +#include "xjump.h" #define FS '\t' /* field separator */
{ "pile_set_name": "Github" }
/* * linux/fs/super.c * * (C) 1991 Linus Torvalds */ /* * super.c contains code to handle the super-block tables. */ #include <linux/config.h> #include <linux/sched.h> #include <linux/kernel.h> #include <asm/system.h> #include <errno.h> #include <sys/stat.h> int sync_dev(int dev); void wait_for_keypress(void); /* set_bit uses setb, as gas doesn't recognize setc */ #define set_bit(bitnr,addr) ({ \ register int __res __asm__("ax"); \ __asm__("bt %2,%3;setb %%al":"=a" (__res):"a" (0),"r" (bitnr),"m" (*(addr))); \ __res; }) struct super_block super_block[NR_SUPER]; /* this is initialized in init/main.c */ int ROOT_DEV = 0; static void lock_super(struct super_block * sb) { cli(); while (sb->s_lock) sleep_on(&(sb->s_wait)); sb->s_lock = 1; sti(); } static void free_super(struct super_block * sb) { cli(); sb->s_lock = 0; wake_up(&(sb->s_wait)); sti(); } static void wait_on_super(struct super_block * sb) { cli(); while (sb->s_lock) sleep_on(&(sb->s_wait)); sti(); } struct super_block * get_super(int dev) { struct super_block * s; if (!dev) return NULL; s = 0+super_block; while (s < NR_SUPER+super_block) if (s->s_dev == dev) { wait_on_super(s); if (s->s_dev == dev) return s; s = 0+super_block; } else s++; return NULL; } void put_super(int dev) { struct super_block * sb; struct m_inode * inode; int i; if (dev == ROOT_DEV) { printk("root diskette changed: prepare for armageddon\n\r"); return; } if (!(sb = get_super(dev))) return; if (sb->s_imount) { printk("Mounted disk changed - tssk, tssk\n\r"); return; } lock_super(sb); sb->s_dev = 0; for(i=0;i<I_MAP_SLOTS;i++) brelse(sb->s_imap[i]); for(i=0;i<Z_MAP_SLOTS;i++) brelse(sb->s_zmap[i]); free_super(sb); return; } static struct super_block * read_super(int dev) { struct super_block * s; struct buffer_head * bh; int i,block; if (!dev) return NULL; check_disk_change(dev); if (s = get_super(dev)) return s; for (s = 0+super_block ;; s++) { if (s >= NR_SUPER+super_block) return NULL; if (!s->s_dev) break; } s->s_dev = dev; s->s_isup = NULL; s->s_imount = NULL; s->s_time = 0; s->s_rd_only = 0; s->s_dirt = 0; lock_super(s); if (!(bh = bread(dev,1))) { s->s_dev=0; free_super(s); return NULL; } *((struct d_super_block *) s) = *((struct d_super_block *) bh->b_data); brelse(bh); if (s->s_magic != SUPER_MAGIC) { s->s_dev = 0; free_super(s); return NULL; } for (i=0;i<I_MAP_SLOTS;i++) s->s_imap[i] = NULL; for (i=0;i<Z_MAP_SLOTS;i++) s->s_zmap[i] = NULL; block=2; for (i=0 ; i < s->s_imap_blocks ; i++) if (s->s_imap[i]=bread(dev,block)) block++; else break; for (i=0 ; i < s->s_zmap_blocks ; i++) if (s->s_zmap[i]=bread(dev,block)) block++; else break; if (block != 2+s->s_imap_blocks+s->s_zmap_blocks) { for(i=0;i<I_MAP_SLOTS;i++) brelse(s->s_imap[i]); for(i=0;i<Z_MAP_SLOTS;i++) brelse(s->s_zmap[i]); s->s_dev=0; free_super(s); return NULL; } s->s_imap[0]->b_data[0] |= 1; s->s_zmap[0]->b_data[0] |= 1; free_super(s); return s; } int sys_umount(char * dev_name) { struct m_inode * inode; struct super_block * sb; int dev; if (!(inode=namei(dev_name))) return -ENOENT; dev = inode->i_zone[0]; if (!S_ISBLK(inode->i_mode)) { iput(inode); return -ENOTBLK; } iput(inode); if (dev==ROOT_DEV) return -EBUSY; if (!(sb=get_super(dev)) || !(sb->s_imount)) return -ENOENT; if (!sb->s_imount->i_mount) printk("Mounted inode has i_mount=0\n"); for (inode=inode_table+0 ; inode<inode_table+NR_INODE ; inode++) if (inode->i_dev==dev && inode->i_count) return -EBUSY; sb->s_imount->i_mount=0; iput(sb->s_imount); sb->s_imount = NULL; iput(sb->s_isup); sb->s_isup = NULL; put_super(dev); sync_dev(dev); return 0; } int sys_mount(char * dev_name, char * dir_name, int rw_flag) { struct m_inode * dev_i, * dir_i; struct super_block * sb; int dev; if (!(dev_i=namei(dev_name))) return -ENOENT; dev = dev_i->i_zone[0]; if (!S_ISBLK(dev_i->i_mode)) { iput(dev_i); return -EPERM; } iput(dev_i); if (!(dir_i=namei(dir_name))) return -ENOENT; if (dir_i->i_count != 1 || dir_i->i_num == ROOT_INO) { iput(dir_i); return -EBUSY; } if (!S_ISDIR(dir_i->i_mode)) { iput(dir_i); return -EPERM; } if (!(sb=read_super(dev))) { iput(dir_i); return -EBUSY; } if (sb->s_imount) { iput(dir_i); return -EBUSY; } if (dir_i->i_mount) { iput(dir_i); return -EPERM; } sb->s_imount=dir_i; dir_i->i_mount=1; dir_i->i_dirt=1; /* NOTE! we don't iput(dir_i) */ return 0; /* we do that in umount */ } void mount_root(void) { int i,free; struct super_block * p; struct m_inode * mi; if (32 != sizeof (struct d_inode)) panic("bad i-node size"); for(i=0;i<NR_FILE;i++) file_table[i].f_count=0; if (MAJOR(ROOT_DEV) == 2) { printk("Insert root floppy and press ENTER"); wait_for_keypress(); } for(p = &super_block[0] ; p < &super_block[NR_SUPER] ; p++) { p->s_dev = 0; p->s_lock = 0; p->s_wait = NULL; } if (!(p=read_super(ROOT_DEV))) panic("Unable to mount root"); if (!(mi=iget(ROOT_DEV,ROOT_INO))) panic("Unable to read root i-node"); mi->i_count += 3 ; /* NOTE! it is logically used 4 times, not 1 */ p->s_isup = p->s_imount = mi; current->pwd = mi; current->root = mi; free=0; i=p->s_nzones; while (-- i >= 0) if (!set_bit(i&8191,p->s_zmap[i>>13]->b_data)) free++; printk("%d/%d free blocks\n\r",free,p->s_nzones); free=0; i=p->s_ninodes+1; while (-- i >= 0) if (!set_bit(i&8191,p->s_imap[i>>13]->b_data)) free++; printk("%d/%d free inodes\n\r",free,p->s_ninodes); }
{ "pile_set_name": "Github" }
// // GDDropboxUploadStateWrapper.m // GDFileManagerExample // // Created by Graham Dennis on 11/08/13. // Copyright (c) 2013 Graham Dennis. All rights reserved. // #import "GDFileManagerUploadState.h" @implementation GDFileManagerUploadState @synthesize parentVersionID = _parentVersionID; - (instancetype)initWithUploadState:(id<NSCoding>)uploadState mimeType:(NSString *)mimeType uploadURL:(NSURL *)uploadURL parentVersionID:(NSString *)parentVersionID { return [self initWithUploadState:uploadState mimeType:mimeType uploadURL:uploadURL parentVersionID:parentVersionID extraState:nil]; } - (instancetype)initWithUploadState:(id <NSCoding>)uploadState mimeType:(NSString *)mimeType uploadURL:(NSURL *)uploadURL parentVersionID:(NSString *)parentVersionID extraState:(NSDictionary *)extraState { if ((self = [super init])) { _uploadState = uploadState; _uploadURL = uploadURL; _parentVersionID = parentVersionID; _mimeType = mimeType; _extraState = extraState; } return self; } - (NSURL *)fileServiceSessionURL { return self.uploadURL; } #pragma mark - NSCoding static NSString *const kUploadState = @"UploadState"; static NSString *const kUploadURL = @"UploadURL"; static NSString *const kParentVersionID = @"ParentVersionID"; static NSString *const kMIMEType = @"MIMEType"; static NSString *const kExtraState = @"ExtraState"; - (id)initWithCoder:(NSCoder *)aDecoder { id <NSCoding> uploadState = [aDecoder decodeObjectForKey:kUploadState]; NSURL *uploadURL = [aDecoder decodeObjectForKey:kUploadURL]; NSString *parentVersionID = [aDecoder decodeObjectForKey:kParentVersionID]; NSString *mimeType = [aDecoder decodeObjectForKey:kMIMEType]; NSDictionary *extraState = [aDecoder decodeObjectForKey:kExtraState]; return [self initWithUploadState:uploadState mimeType:mimeType uploadURL:uploadURL parentVersionID:parentVersionID extraState:extraState]; } - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:self.uploadState forKey:kUploadState]; [aCoder encodeObject:self.uploadURL forKey:kUploadURL]; [aCoder encodeObject:self.parentVersionID forKey:kParentVersionID]; [aCoder encodeObject:self.mimeType forKey:kMIMEType]; [aCoder encodeObject:self.extraState forKey:kExtraState]; } @end
{ "pile_set_name": "Github" }
/dts-v1/; #include "bcm6348.dtsi" #include <dt-bindings/input/input.h> / { model = "Sagem F@st 2404"; compatible = "sagem,fast-2404", "brcm,bcm6348"; chosen { bootargs = "rootfstype=squashfs,jffs2 noinitrd console=ttyS0,115200"; stdout-path = "serial0:115200n8"; }; }; &pflash { status = "okay"; partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; cfe@0 { label = "CFE"; reg = <0x000000 0x010000>; read-only; }; linux@10000 { label = "linux"; reg = <0x010000 0x3e0000>; compatible = "brcm,bcm963xx-imagetag"; }; nvram@3f0000 { label = "nvram"; reg = <0x3f0000 0x010000>; }; }; }; &pinctrl { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_pci &pinctrl_ext_mii &pinctrl_mii_pccard>; }; &uart0 { status = "okay"; };
{ "pile_set_name": "Github" }
// // TAPIResponse.m // TwitterNetworkLayer // // Created on 10/17/14. // Copyright © 2020 Twitter. All rights reserved. // #import "TAPIError.h" #import "TAPIResponse.h" #import "TNL_Project.h" NS_INLINE BOOL _DataBeginsWithHTMLDocType(NSData *data) { static const char sDocType[] = "<!DOCTYPE html"; static const size_t sDocTypeLength = (sizeof(sDocType) / sizeof(sDocType[0])) - 1; // minus 1 to ignore the NULL terminator return data.length >= sDocTypeLength && 0 == strncmp(data.bytes, sDocType, sDocTypeLength); } static id _ParseAPIResponse(TNLResponseInfo *info, NSError ** parseErrorOut, NSError ** apiErrorOut); static NSArray *_ExtractAPIErrors(id parsedObject); @implementation TAPIResponse @synthesize apiError = _apiError; @synthesize parseError = _parseError; @synthesize parsedObject = _parsedObject; - (void)prepare { [super prepare]; if (!_operationError) { NSError *apiError; NSError *parseError; _parsedObject = _ParseAPIResponse(_info, &parseError, &apiError); _parseError = parseError; _apiError = apiError; TNLAttemptMetrics *metrics = _metrics.attemptMetrics.lastObject; metrics.responseBodyParseError = parseError; if (apiError) { metrics.APIErrors = @[apiError]; } } } - (instancetype)initWithCoder:(NSCoder *)coder { self = [super initWithCoder:coder]; if (self) { _parsedObject = [coder decodeObjectOfClasses:[NSSet setWithObjects:[NSString class], [NSNumber class], [NSArray class], [NSDictionary class], nil] forKey:@"parsedObject"]; _parseError = [coder decodeObjectOfClass:[NSError class] forKey:@"parseError"]; _apiError = [coder decodeObjectOfClass:[NSError class] forKey:@"apiError"]; } return self; } - (void)encodeWithCoder:(NSCoder *)aCoder { [super encodeWithCoder:aCoder]; [aCoder encodeObject:TNLErrorToSecureCodingError(_parsedObject) forKey:@"parsedObject"]; [aCoder encodeObject:TNLErrorToSecureCodingError(_apiError) forKey:@"apiError"]; [aCoder encodeObject:TNLErrorToSecureCodingError(_parseError) forKey:@"parseError"]; } - (NSError *)anyError { return self.operationError ?: self.parseError ?: self.apiError; } @end static id _ParseAPIResponse(TNLResponseInfo *info, NSError ** errorOut, NSError ** apiErrorOut) { id json = nil; NSError *parseError = nil; __block NSError *apiError = TNLHTTPStatusCodeIsSuccess(info.statusCode) ? nil : [NSError errorWithDomain:TAPIErrorDomain code:0 userInfo:nil]; NSInteger statusCode = info.statusCode; NSData *data = info.data; TNLAssert(statusCode > 0); BOOL hasDocTypePrefix = _DataBeginsWithHTMLDocType(data); if (hasDocTypePrefix) { parseError = [NSError errorWithDomain:TAPIOperationErrorDomain code:TAPIOperationErrorCodeServiceEncounteredTechnicalError userInfo:nil]; } else { json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError]; if (json) { NSArray *apiErrors = _ExtractAPIErrors(json); // Underlying behavior in some 4XX errors if (TNLHTTPStatusCodeIsClientError(statusCode)) { [apiErrors enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { NSError *currentError = obj; if ([currentError.domain isEqualToString:TAPIErrorDomain]) { apiError = currentError; *stop = YES; } }]; } } else { parseError = [NSError errorWithDomain:TAPIParseErrorDomain code:TAPIParseErrorCodeCannotParseResponse userInfo:(parseError) ? @{ NSUnderlyingErrorKey : parseError } : nil]; } } if (errorOut) { *errorOut = parseError; } if (apiErrorOut) { *apiErrorOut = apiError; } return json; } static NSArray *_ExtractAPIErrors(id parsedObject) { TNLAssert(parsedObject != nil); NSMutableArray *errorItems = [[NSMutableArray alloc] init]; if ([parsedObject isKindOfClass:[NSDictionary class]]) { id errors = [parsedObject objectForKey:@"errors"]; if ([errors isKindOfClass:[NSArray class]]) { [errors enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { BOOL successfullyParsedError = NO; if ([obj isKindOfClass:[NSDictionary class]]) { id codeObject = [obj objectForKey:@"code"]; id messageObject = [obj objectForKey:@"message"]; if (codeObject && messageObject) { NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; if (messageObject) { userInfo[NSLocalizedDescriptionKey] = messageObject; } NSInteger code = [codeObject integerValue]; id timestamp = [obj objectForKey:@"timestamp"]; if (timestamp) { userInfo[@"timestamp"] = timestamp; } [errorItems addObject:[NSError errorWithDomain:TAPIErrorDomain code:code userInfo:userInfo]]; successfullyParsedError = YES; } } if (!successfullyParsedError) { NSLog(@"Failed to parse server error:[%@]", obj); } }]; } } return errorItems; }
{ "pile_set_name": "Github" }
// Copyright (c) 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. // // This implements a Clang tool to convert all instances of std::string("") to // std::string(). The latter is more efficient (as std::string doesn't have to // take a copy of an empty string) and generates fewer instructions as well. It // should be run using the tools/clang/scripts/run_tool.py helper. #include <memory> #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Basic/SourceManager.h" #include "clang/Frontend/FrontendActions.h" #include "clang/Tooling/CommonOptionsParser.h" #include "clang/Tooling/Refactoring.h" #include "clang/Tooling/Tooling.h" #include "llvm/Support/CommandLine.h" using namespace clang::ast_matchers; using clang::tooling::CommonOptionsParser; using clang::tooling::Replacement; using clang::tooling::Replacements; namespace { // Handles replacements for stack and heap-allocated instances, e.g.: // std::string a(""); // std::string* b = new std::string(""); class ConstructorCallback : public MatchFinder::MatchCallback { public: ConstructorCallback(Replacements* replacements) : replacements_(replacements) {} virtual void run(const MatchFinder::MatchResult& result) override; private: Replacements* const replacements_; }; // Handles replacements for invocations of std::string("") in an initializer // list. class InitializerCallback : public MatchFinder::MatchCallback { public: InitializerCallback(Replacements* replacements) : replacements_(replacements) {} virtual void run(const MatchFinder::MatchResult& result) override; private: Replacements* const replacements_; }; // Handles replacements for invocations of std::string("") in a temporary // context, e.g. FunctionThatTakesString(std::string("")). Note that this // handles implicits construction of std::string as well. class TemporaryCallback : public MatchFinder::MatchCallback { public: TemporaryCallback(Replacements* replacements) : replacements_(replacements) {} virtual void run(const MatchFinder::MatchResult& result) override; private: Replacements* const replacements_; }; class EmptyStringConverter { public: explicit EmptyStringConverter(Replacements* replacements) : constructor_callback_(replacements), initializer_callback_(replacements), temporary_callback_(replacements) {} void SetupMatchers(MatchFinder* match_finder); private: ConstructorCallback constructor_callback_; InitializerCallback initializer_callback_; TemporaryCallback temporary_callback_; }; void EmptyStringConverter::SetupMatchers(MatchFinder* match_finder) { const clang::ast_matchers::StatementMatcher& constructor_call = id( "call", cxxConstructExpr( hasDeclaration(cxxMethodDecl(ofClass(hasName("std::basic_string")))), argumentCountIs(2), hasArgument(0, id("literal", stringLiteral())), hasArgument(1, cxxDefaultArgExpr()))); // Note that expr(has()) in the matcher is significant; the Clang AST wraps // calls to the std::string constructor with exprWithCleanups nodes. Without // the expr(has()) matcher, the first and last rules would not match anything! match_finder->addMatcher(varDecl(forEach(expr(has(constructor_call)))), &constructor_callback_); match_finder->addMatcher(cxxNewExpr(has(constructor_call)), &constructor_callback_); // The implicitly generated constructor for temporary could be wrapped by // implicitCastExpr, so ignoringParenImpCasts is needed. match_finder->addMatcher( cxxBindTemporaryExpr(ignoringParenImpCasts(forEach(constructor_call))), &temporary_callback_); // Note that forEachConstructorInitializer is needed. The std::string // constructor is wrapped by exprWithCleanups and cxxCtorInitializer. // forEach() would not work. match_finder->addMatcher(cxxConstructorDecl(forEachConstructorInitializer( withInitializer(expr(has(constructor_call))))), &initializer_callback_); } void ConstructorCallback::run(const MatchFinder::MatchResult& result) { const clang::StringLiteral* literal = result.Nodes.getNodeAs<clang::StringLiteral>("literal"); if (literal->getLength() > 0) return; const clang::CXXConstructExpr* call = result.Nodes.getNodeAs<clang::CXXConstructExpr>("call"); clang::CharSourceRange range = clang::CharSourceRange::getTokenRange(call->getParenOrBraceRange()); auto err = replacements_->add(Replacement(*result.SourceManager, range, "")); assert(!err); } void InitializerCallback::run(const MatchFinder::MatchResult& result) { const clang::StringLiteral* literal = result.Nodes.getNodeAs<clang::StringLiteral>("literal"); if (literal->getLength() > 0) return; const clang::CXXConstructExpr* call = result.Nodes.getNodeAs<clang::CXXConstructExpr>("call"); auto err = replacements_->add(Replacement(*result.SourceManager, call, "")); assert(!err); } void TemporaryCallback::run(const MatchFinder::MatchResult& result) { const clang::StringLiteral* literal = result.Nodes.getNodeAs<clang::StringLiteral>("literal"); if (literal->getLength() > 0) return; const clang::CXXConstructExpr* call = result.Nodes.getNodeAs<clang::CXXConstructExpr>("call"); // Differentiate between explicit and implicit calls to std::string's // constructor. An implicitly generated constructor won't have a valid // source range for the parenthesis. We do this because the matched expression // for |call| in the explicit case doesn't include the closing parenthesis. clang::SourceRange range = call->getParenOrBraceRange(); if (range.isValid()) { auto err = replacements_->add(Replacement(*result.SourceManager, literal, "")); assert(!err); } else { auto err = replacements_->add( Replacement(*result.SourceManager, call, literal->isWide() ? "std::wstring()" : "std::string()")); assert(!err); } } } // namespace static llvm::cl::extrahelp common_help(CommonOptionsParser::HelpMessage); int main(int argc, const char* argv[]) { llvm::cl::OptionCategory category("EmptyString Tool"); CommonOptionsParser options(argc, argv, category); clang::tooling::ClangTool tool(options.getCompilations(), options.getSourcePathList()); Replacements replacements; EmptyStringConverter converter(&replacements); MatchFinder match_finder; converter.SetupMatchers(&match_finder); std::unique_ptr<clang::tooling::FrontendActionFactory> frontend_factory = clang::tooling::newFrontendActionFactory(&match_finder); int result = tool.run(frontend_factory.get()); if (result != 0) return result; if (replacements.empty()) return 0; // Each replacement line should have the following format: // r:<file path>:<offset>:<length>:<replacement text> // Only the <replacement text> field can contain embedded ":" characters. // TODO(dcheng): Use a more clever serialization. Ideally we'd use the YAML // serialization and then use clang-apply-replacements, but that would require // copying and pasting a larger amount of boilerplate for all Chrome clang // tools. llvm::outs() << "==== BEGIN EDITS ====\n"; for (const auto& r : replacements) { llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() << ":::" << r.getLength() << ":::" << r.getReplacementText() << "\n"; } llvm::outs() << "==== END EDITS ====\n"; return 0; }
{ "pile_set_name": "Github" }
/** * Copyright (c) 2016-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ #import <XCTest/XCTest.h> #import <IGListKit/IGListKit.h> #import "IGListDebugger.h" #import "IGListAdapterUpdaterInternal.h" #import "IGListTestAdapterDataSource.h" #import "IGListMoveIndexInternal.h" #import "IGListMoveIndexPathInternal.h" @interface IGListDebuggerTests : XCTestCase @end @implementation IGListDebuggerTests - (void)test_whenSearchingAdapterInstances_thatCorrectCountReturned { UIViewController *controller = [UIViewController new]; UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:[UICollectionViewFlowLayout new]]; IGListAdapterUpdater *updater = [IGListAdapterUpdater new]; NSIndexPath *path = [NSIndexPath indexPathForItem:0 inSection:0]; updater.applyingUpdateData = [[IGListBatchUpdateData alloc] initWithInsertSections:[NSIndexSet indexSetWithIndex:1] deleteSections:[NSIndexSet indexSetWithIndex:2] moveSections:[NSSet setWithObject:[[IGListMoveIndex alloc] initWithFrom:3 to:4]] insertIndexPaths:@[path] deleteIndexPaths:@[path] moveIndexPaths:@[[[IGListMoveIndexPath alloc] initWithFrom:path to:path]]]; IGListTestAdapterDataSource *dataSource = [IGListTestAdapterDataSource new]; dataSource.objects = @[@1, @2, @3]; IGListAdapter *adapter1 = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] viewController:nil workingRangeSize:0]; adapter1.collectionView = collectionView; adapter1.dataSource = dataSource; IGListAdapter *adapter2 = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] viewController:controller workingRangeSize:2]; adapter2.collectionView = collectionView; IGListAdapter *adapter3 = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] viewController:controller workingRangeSize:2]; adapter3.collectionView = collectionView; NSArray *descriptions = [IGListDebugger adapterDescriptions]; XCTAssertEqual(descriptions.count, 4); } @end
{ "pile_set_name": "Github" }
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_TEST_UTILS_H_ #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_TEST_UTILS_H_ #include <map> #include <memory> #include <string> #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h" #include "components/prefs/testing_pref_service.h" #include "net/log/test_net_log.h" #include "net/url_request/test_url_fetcher_factory.h" #include "net/url_request/url_request_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" class PrefService; class TestingPrefServiceSimple; namespace data_reduction_proxy { class DataReductionProxyTestContext; class MockDataReductionProxyConfig; template <class C> class MockDataReductionProxySettings : public C { public: MockDataReductionProxySettings<C>() : C() { } MOCK_METHOD0(GetOriginalProfilePrefs, PrefService*()); MOCK_METHOD0(GetLocalStatePrefs, PrefService*()); MOCK_METHOD1(RecordStartupState, void(ProxyStartupState state)); }; class DataReductionProxySettingsTestBase : public testing::Test { public: static void AddTestProxyToCommandLine(); DataReductionProxySettingsTestBase(); DataReductionProxySettingsTestBase(bool allowed, bool fallback_allowed, bool promo_allowed); ~DataReductionProxySettingsTestBase() override; void AddProxyToCommandLine(); void SetUp() override; template <class C> void ResetSettings(bool allowed, bool fallback_allowed, bool promo_allowed, bool holdback); virtual void ResetSettings(bool allowed, bool fallback_allowed, bool promo_allowed, bool holdback) = 0; void ExpectSetProxyPrefs(bool expected_enabled, bool expected_at_startup); void CheckMaybeActivateDataReductionProxy(bool initially_enabled, bool request_succeeded, bool expected_enabled, bool expected_restricted, bool expected_fallback_restricted); void CheckOnPrefChange(bool enabled, bool expected_enabled, bool managed); void InitWithStatisticsPrefs(); void InitDataReductionProxy(bool enabled_at_startup); void CheckDataReductionProxySyntheticTrial(bool enabled); bool SyntheticFieldTrialRegistrationCallback(const std::string& trial_name, const std::string& group_name) { synthetic_field_trials_[trial_name] = group_name; return true; } base::MessageLoopForIO message_loop_; std::unique_ptr<DataReductionProxyTestContext> test_context_; std::unique_ptr<DataReductionProxySettings> settings_; base::Time last_update_time_; std::map<std::string, std::string> synthetic_field_trials_; }; // Test implementations should be subclasses of an instantiation of this // class parameterized for whatever DataReductionProxySettings class // is being tested. template <class C> class ConcreteDataReductionProxySettingsTest : public DataReductionProxySettingsTestBase { public: typedef MockDataReductionProxySettings<C> MockSettings; void ResetSettings(bool allowed, bool fallback_allowed, bool promo_allowed, bool holdback) override { return DataReductionProxySettingsTestBase::ResetSettings<C>( allowed, fallback_allowed, promo_allowed, holdback); } }; } // namespace data_reduction_proxy #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_TEST_UTILS_H_
{ "pile_set_name": "Github" }
// // CSSlider.m // AppSlate // // Created by Taehan Kim on 12. 01. 26.. // Copyright (c) 2012년 ChocolateSoft. All rights reserved. // #import "CSSlider.h" @implementation CSSlider -(id) object { return ((UISlider*)csView); } //=========================================================================== #pragma mark - -(void) setMinimumBarColor:(UIColor*)color { if( [color isKindOfClass:[UIColor class]] ) [((UISlider*)csView) setMinimumTrackTintColor:color]; } -(UIColor*) getMinimumBarColor { return ((UISlider*)csView).minimumTrackTintColor; } -(void) setMaximumBarColor:(UIColor*)color { if( [color isKindOfClass:[UIColor class]] ) [((UISlider*)csView) setMaximumTrackTintColor:color]; } -(UIColor*) getMaximumBarColor { return ((UISlider*)csView).maximumTrackTintColor; } -(void) setThumbColor:(UIColor*)color { if( [color isKindOfClass:[UIColor class]] ) [((UISlider*)csView) setThumbTintColor:color]; } -(UIColor*) getThumbColor { return ((UISlider*)csView).thumbTintColor; } -(void) setMinimumValue:(NSNumber*)number { if( [number isKindOfClass:[NSNumber class]] ) [((UISlider*)csView) setMinimumValue:[number floatValue]]; else if( [number isKindOfClass:[NSString class]] ) [((UISlider*)csView) setMinimumValue:[(NSString*)number length]]; } -(NSNumber*) getMinimumValue { return @( ((UISlider*)csView).minimumValue ); } -(void) setMaximumValue:(NSNumber*)number { if( [number isKindOfClass:[NSNumber class]] ) [((UISlider*)csView) setMaximumValue:[number floatValue]]; else if( [number isKindOfClass:[NSString class]] ) [((UISlider*)csView) setMaximumValue:[(NSString*)number length]]; } -(NSNumber*) getMaximumValue { return @( ((UISlider*)csView).maximumValue ); } -(void) setThumbValue:(NSNumber*)number { CGFloat toValue; if( [number isKindOfClass:[NSNumber class]] ) toValue = [number floatValue]; else if( [number isKindOfClass:[NSString class]] ) toValue = [(NSString*)number length]; else{ EXCLAMATION; return; } if( toValue > ((UISlider*)csView).maximumValue ) toValue = ((UISlider*)csView).maximumValue; if( toValue < ((UISlider*)csView).minimumValue ) toValue = ((UISlider*)csView).minimumValue; [((UISlider*)csView) setValue:toValue animated:YES]; } -(NSNumber*) getThumbValue { return @( ((UISlider*)csView).value ); } -(void) setContinuosChange:(NSNumber*)boolVal { if( [boolVal isKindOfClass:[NSNumber class]] ) [((UISlider*)csView) setContinuous:[boolVal boolValue]]; } -(NSNumber*) getContinuosChange { return@( ((UISlider*)csView).continuous ); } #pragma mark - -(id) initGear { if( !(self = [super init]) ) return nil; csView = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, 400, MINSIZE)]; [csView setBackgroundColor:[UIColor clearColor]]; [csView setUserInteractionEnabled:YES]; csCode = CS_SLIDER; isUIObj = YES; [((UISlider*)csView) setMinimumValue:0]; [((UISlider*)csView) setMaximumValue:10]; [((UISlider*)csView) setValue:5]; [((UISlider*)csView) setContinuous:NO]; [((UISlider*)csView) setMinimumTrackTintColor:[UIColor darkGrayColor]]; [((UISlider*)csView) setMaximumTrackTintColor:[UIColor whiteColor]]; [((UISlider*)csView) setThumbTintColor:[UIColor whiteColor]]; [((UISlider*)csView) addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged]; DEFAULT_CENTER_D; NSDictionary *d0 = ALPHA_D; NSDictionary *d1 = MAKE_PROPERTY_D(@"Value", P_NUM, @selector(setThumbValue:),@selector(getThumbValue)); NSDictionary *d2 = MAKE_PROPERTY_D(@"Minimum Value", P_NUM, @selector(setMinimumValue:),@selector(getMinimumValue)); NSDictionary *d3 = MAKE_PROPERTY_D(@"Maximum Value", P_NUM, @selector(setMaximumValue:),@selector(getMaximumValue)); NSDictionary *d4 = MAKE_PROPERTY_D(@"Minimum Bar Color", P_COLOR, @selector(setMinimumBarColor:),@selector(getMinimumBarColor)); NSDictionary *d5 = MAKE_PROPERTY_D(@"Maximum Bar Color", P_COLOR, @selector(setMaximumBarColor:),@selector(getMaximumBarColor)); // NSDictionary *d6 = MAKE_PROPERTY_D(@"Thumb Color", P_COLOR, @selector(setThumbColor:),@selector(getThumbColor)); NSDictionary *d7 = MAKE_PROPERTY_D(@"Continuos Change", P_BOOL, @selector(setContinuosChange:),@selector(getContinuosChange)); pListArray = @[xc,yc,d0,d1,d2,d3,d4,d5,d7]; NSMutableDictionary MAKE_ACTION_D(@"Changed Value", A_NUM, a1); NSMutableDictionary MAKE_ACTION_D(@"Minimum Value", A_NUM, a2); NSMutableDictionary MAKE_ACTION_D(@"Maximum Value", A_NUM, a3); actionArray = @[a1, a2, a3]; return self; } -(id)initWithCoder:(NSCoder *)decoder { if( (self=[super initWithCoder:decoder]) ) { [((UISlider*)csView) addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged]; } return self; } #pragma mark - Gear's Unique Actions -(void) valueChanged:(id) sender { SEL act; NSNumber *nsMagicNum; CGFloat myValue = ((UISlider*)sender).value; // 1. value changed act = ((NSValue*)((NSDictionary*)actionArray[0])[@"selector"]).pointerValue; if( nil != act ){ nsMagicNum = ((NSDictionary*)actionArray[0])[@"mNum"]; CSGearObject *gObj = [USERCONTEXT getGearWithMagicNum:nsMagicNum.integerValue]; if( nil != gObj ){ if( [gObj respondsToSelector:act] ) [gObj performSelector:act withObject:@(myValue)]; else EXCLAMATION; } } // 2. did min value act = ((NSValue*)((NSDictionary*)actionArray[1])[@"selector"]).pointerValue; if( nil != act && myValue == ((UISlider*)sender).minimumValue ) { nsMagicNum = ((NSDictionary*)actionArray[1])[@"mNum"]; CSGearObject *gObj = [USERCONTEXT getGearWithMagicNum:nsMagicNum.integerValue]; if( nil != gObj ){ if( [gObj respondsToSelector:act] ) [gObj performSelector:act withObject:@(myValue)]; else EXCLAMATION; } } // 3. did max value act = ((NSValue*)((NSDictionary*)actionArray[2])[@"selector"]).pointerValue; if( nil != act && myValue == (NSUInteger)((UISlider*)sender).maximumValue ) { nsMagicNum = ((NSDictionary*)actionArray[2])[@"mNum"]; CSGearObject *gObj = [USERCONTEXT getGearWithMagicNum:nsMagicNum.integerValue]; if( nil != gObj ){ if( [gObj respondsToSelector:act] ) [gObj performSelector:act withObject:@(myValue)]; else EXCLAMATION; } } } #pragma mark - Code Generatorz // If not supported gear, return NO. -(BOOL) setDefaultVarName:(NSString *) _name { return [super setDefaultVarName:NSStringFromClass([self class])]; } -(NSString*) sdkClassName { return @"UISlider"; } -(NSString*) addTargetCode { return [NSString stringWithFormat:@" [%@ addTarget:self action:@selector(%@ValueChanged) forControlEvents:UIControlEventValueChanged];\n",varName,varName]; } -(NSString*) actionCode { NSMutableString *code = [[NSMutableString alloc] initWithFormat:@"-(void)%@ValueChanged\n{\n",varName]; SEL act; NSNumber *nsMagicNum; act = ((NSValue*)((NSDictionary*)actionArray[0])[@"selector"]).pointerValue; if( act ) { nsMagicNum = ((NSDictionary*)actionArray[0])[@"mNum"]; CSGearObject *gObj = [USERCONTEXT getGearWithMagicNum:nsMagicNum.integerValue]; const char *sel_name_c = sel_getName(act); NSString *selNameStr = [NSString stringWithCString:sel_name_c encoding:NSUTF8StringEncoding]; if( [selNameStr hasSuffix:@"Action:"] ) { [code appendFormat:@" %@\n",[gObj actionPropertyCode:selNameStr valStr:[NSString stringWithFormat:@"%@.value",varName]]]; } else [code appendFormat:@" [%@ %@@(%@.value)];\n",[gObj getVarName],@(sel_name_c),self.getVarName]; } act = ((NSValue*)((NSDictionary*)actionArray[1])[@"selector"]).pointerValue; if( act ) { nsMagicNum = ((NSDictionary*)actionArray[1])[@"mNum"]; CSGearObject *gObj = [USERCONTEXT getGearWithMagicNum:nsMagicNum.integerValue]; const char *sel_name_c = sel_getName(act); NSString *selNameStr = [NSString stringWithCString:sel_name_c encoding:NSUTF8StringEncoding]; if( [selNameStr hasSuffix:@"Action:"] ) { [code appendFormat:@" %@\n",[gObj actionPropertyCode:selNameStr valStr:[NSString stringWithFormat:@"%@.value",varName]]]; } else [code appendFormat:@" if( %@.minimumValue == %@.value )[%@ %@@(%@.value)];\n",self.getVarName,self.getVarName,[gObj getVarName],@(sel_name_c),self.getVarName]; } act = ((NSValue*)((NSDictionary*)actionArray[2])[@"selector"]).pointerValue; if( act ) { nsMagicNum = ((NSDictionary*)actionArray[2])[@"mNum"]; CSGearObject *gObj = [USERCONTEXT getGearWithMagicNum:nsMagicNum.integerValue]; const char *sel_name_c = sel_getName(act); NSString *selNameStr = [NSString stringWithCString:sel_name_c encoding:NSUTF8StringEncoding]; if( [selNameStr hasSuffix:@"Action:"] ) { [code appendFormat:@" %@\n",[gObj actionPropertyCode:selNameStr valStr:[NSString stringWithFormat:@"%@.value",varName]]]; } else [code appendFormat:@" if( %@.maximumValue == %@.value )[%@ %@@(%@.value)];\n",self.getVarName,self.getVarName,[gObj getVarName],@(sel_name_c),self.getVarName]; } [code appendString:@"}\n"]; return code; } @end
{ "pile_set_name": "Github" }
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build !gccgo #include "textflag.h" // // System call support for AMD64, OpenBSD // // Just jump to package syscall's implementation for all these functions. // The runtime may know about them. TEXT ·Syscall(SB),NOSPLIT,$0-56 JMP syscall·Syscall(SB) TEXT ·Syscall6(SB),NOSPLIT,$0-80 JMP syscall·Syscall6(SB) TEXT ·Syscall9(SB),NOSPLIT,$0-104 JMP syscall·Syscall9(SB) TEXT ·RawSyscall(SB),NOSPLIT,$0-56 JMP syscall·RawSyscall(SB) TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 JMP syscall·RawSyscall6(SB)
{ "pile_set_name": "Github" }
SubDir HAIKU_TOP src tests system network posixnet ; UsePrivateHeaders private shared ; UnitTestLib posixnettest.so : PosixNetTestAddon.cpp GetAddrInfo.cpp SocketTests.cpp : be $(TARGET_NETWORK_LIBS) [ TargetLibstdc++ ] ;
{ "pile_set_name": "Github" }
/* * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef _LIBROOT_MEMORY_PRIVATE_H #define _LIBROOT_MEMORY_PRIVATE_H #include <OS.h> #include <sys/cdefs.h> __BEGIN_DECLS status_t get_memory_properties(team_id teamID, const void* address, uint32* _protected, uint32* _lock); __END_DECLS #endif // _LIBROOT_MEMORY_PRIVATE_H
{ "pile_set_name": "Github" }
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_snprintf_53a.c Label Definition File: CWE122_Heap_Based_Buffer_Overflow__c_CWE805.string.label.xml Template File: sources-sink-53a.tmpl.c */ /* * @description * CWE: 122 Heap Based Buffer Overflow * BadSource: Allocate using malloc() and set data pointer to a small buffer * GoodSource: Allocate using malloc() and set data pointer to a large buffer * Sink: snprintf * BadSink : Copy string to data using snprintf * Flow Variant: 53 Data flow: data passed as an argument from one function through two others to a fourth; all four functions are in different source files * * */ #include "std_testcase.h" #include <wchar.h> #ifdef _WIN32 #define SNPRINTF _snwprintf #else #define SNPRINTF snprintf #endif #ifndef OMITBAD /* bad function declaration */ void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_snprintf_53b_badSink(wchar_t * data); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_snprintf_53_bad() { wchar_t * data; data = NULL; /* FLAW: Allocate and point data to a small buffer that is smaller than the large buffer used in the sinks */ data = (wchar_t *)malloc(50*sizeof(wchar_t)); data[0] = L'\0'; /* null terminate */ CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_snprintf_53b_badSink(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* good function declaration */ void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_snprintf_53b_goodG2BSink(wchar_t * data); /* goodG2B uses the GoodSource with the BadSink */ static void goodG2B() { wchar_t * data; data = NULL; /* FIX: Allocate and point data to a large buffer that is at least as large as the large buffer used in the sink */ data = (wchar_t *)malloc(100*sizeof(wchar_t)); data[0] = L'\0'; /* null terminate */ CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_snprintf_53b_goodG2BSink(data); } void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_snprintf_53_good() { goodG2B(); } #endif /* OMITGOOD */ /* 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 int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_snprintf_53_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_snprintf_53_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
{ "pile_set_name": "Github" }
/*============================================================================= Copyright (c) 2011 Eric Niebler Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #if !defined(BOOST_FUSION_ACCUMULATE_FWD_HPP_INCLUDED) #define BOOST_FUSION_ACCUMULATE_FWD_HPP_INCLUDED #include <boost/fusion/support/config.hpp> #include <boost/fusion/support/is_sequence.hpp> #include <boost/utility/enable_if.hpp> namespace boost { namespace fusion { namespace result_of { template <typename Sequence, typename State, typename F> struct accumulate; } template <typename Sequence, typename State, typename F> BOOST_FUSION_GPU_ENABLED typename lazy_enable_if< traits::is_sequence<Sequence> , result_of::accumulate<Sequence, State const, F> >::type accumulate(Sequence& seq, State const& state, F f); template <typename Sequence, typename State, typename F> BOOST_FUSION_GPU_ENABLED typename lazy_enable_if< traits::is_sequence<Sequence> , result_of::accumulate<Sequence const, State const, F> >::type accumulate(Sequence const& seq, State const& state, F f); }} #endif
{ "pile_set_name": "Github" }
// SPDX-License-Identifier: GPL-2.0 #include <sys/types.h> #include <errno.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <regex.h> #include "../../../util/debug.h" #include "../../../util/header.h" static inline void cpuid(unsigned int op, unsigned int *a, unsigned int *b, unsigned int *c, unsigned int *d) { __asm__ __volatile__ (".byte 0x53\n\tcpuid\n\t" "movl %%ebx, %%esi\n\t.byte 0x5b" : "=a" (*a), "=S" (*b), "=c" (*c), "=d" (*d) : "a" (op)); } static int __get_cpuid(char *buffer, size_t sz, const char *fmt) { unsigned int a, b, c, d, lvl; int family = -1, model = -1, step = -1; int nb; char vendor[16]; cpuid(0, &lvl, &b, &c, &d); strncpy(&vendor[0], (char *)(&b), 4); strncpy(&vendor[4], (char *)(&d), 4); strncpy(&vendor[8], (char *)(&c), 4); vendor[12] = '\0'; if (lvl >= 1) { cpuid(1, &a, &b, &c, &d); family = (a >> 8) & 0xf; /* bits 11 - 8 */ model = (a >> 4) & 0xf; /* Bits 7 - 4 */ step = a & 0xf; /* extended family */ if (family == 0xf) family += (a >> 20) & 0xff; /* extended model */ if (family >= 0x6) model += ((a >> 16) & 0xf) << 4; } nb = scnprintf(buffer, sz, fmt, vendor, family, model, step); /* look for end marker to ensure the entire data fit */ if (strchr(buffer, '$')) { buffer[nb-1] = '\0'; return 0; } return ENOBUFS; } int get_cpuid(char *buffer, size_t sz) { return __get_cpuid(buffer, sz, "%s,%u,%u,%u$"); } char * get_cpuid_str(struct perf_pmu *pmu __maybe_unused) { char *buf = malloc(128); if (buf && __get_cpuid(buf, 128, "%s-%u-%X-%X$") < 0) { free(buf); return NULL; } return buf; } /* Full CPUID format for x86 is vendor-family-model-stepping */ static bool is_full_cpuid(const char *id) { const char *tmp = id; int count = 0; while ((tmp = strchr(tmp, '-')) != NULL) { count++; tmp++; } if (count == 3) return true; return false; } int strcmp_cpuid_str(const char *mapcpuid, const char *id) { regex_t re; regmatch_t pmatch[1]; int match; bool full_mapcpuid = is_full_cpuid(mapcpuid); bool full_cpuid = is_full_cpuid(id); /* * Full CPUID format is required to identify a platform. * Error out if the cpuid string is incomplete. */ if (full_mapcpuid && !full_cpuid) { pr_info("Invalid CPUID %s. Full CPUID is required, " "vendor-family-model-stepping\n", id); return 1; } if (regcomp(&re, mapcpuid, REG_EXTENDED) != 0) { /* Warn unable to generate match particular string. */ pr_info("Invalid regular expression %s\n", mapcpuid); return 1; } match = !regexec(&re, id, 1, pmatch, 0); regfree(&re); if (match) { size_t match_len = (pmatch[0].rm_eo - pmatch[0].rm_so); size_t cpuid_len; /* If the full CPUID format isn't required, * ignoring the stepping. */ if (!full_mapcpuid && full_cpuid) cpuid_len = strrchr(id, '-') - id; else cpuid_len = strlen(id); /* Verify the entire string matched. */ if (match_len == cpuid_len) return 0; } return 1; }
{ "pile_set_name": "Github" }
#ifdef __OBJC__ #import <UIKit/UIKit.h> #else #ifndef FOUNDATION_EXPORT #if defined(__cplusplus) #define FOUNDATION_EXPORT extern "C" #else #define FOUNDATION_EXPORT extern #endif #endif #endif FOUNDATION_EXPORT double QuickLayoutVersionNumber; FOUNDATION_EXPORT const unsigned char QuickLayoutVersionString[];
{ "pile_set_name": "Github" }
/***************************************************************************/ /* */ /* ftlcdfil.h */ /* */ /* FreeType API for color filtering of subpixel bitmap glyphs */ /* (specification). */ /* */ /* Copyright 2006-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef FTLCDFIL_H_ #define FTLCDFIL_H_ #include <ft2build.h> #include FT_FREETYPE_H #include FT_PARAMETER_TAGS_H #ifdef FREETYPE_H #error "freetype.h of FreeType 1 has been loaded!" #error "Please fix the directory search order for header files" #error "so that freetype.h of FreeType 2 is found first." #endif FT_BEGIN_HEADER /*************************************************************************** * * @section: * lcd_filtering * * @title: * LCD Filtering * * @abstract: * Reduce color fringes of subpixel-rendered bitmaps. * * @description: * Should you #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your * `ftoption.h', which enables patented ClearType-style rendering, * the LCD-optimized glyph bitmaps should be filtered to reduce color * fringes inherent to this technology. The default FreeType LCD * rendering uses different technology, and API described below, * although available, does nothing. * * ClearType-style LCD rendering exploits the color-striped structure of * LCD pixels, increasing the available resolution in the direction of * the stripe (usually horizontal RGB) by a factor of~3. Since these * subpixels are color pixels, using them unfiltered creates severe * color fringes. Use the @FT_Library_SetLcdFilter API to specify a * low-pass filter, which is then applied to subpixel-rendered bitmaps * generated through @FT_Render_Glyph. The filter sacrifices some of * the higher resolution to reduce color fringes, making the glyph image * slightly blurrier. Positional improvements will remain. * * A filter should have two properties: * * 1) It should be normalized, meaning the sum of the 5~components * should be 256 (0x100). It is possible to go above or under this * target sum, however: going under means tossing out contrast, going * over means invoking clamping and thereby non-linearities that * increase contrast somewhat at the expense of greater distortion * and color-fringing. Contrast is better enhanced through stem * darkening. * * 2) It should be color-balanced, meaning a filter `{~a, b, c, b, a~}' * where a~+ b~=~c. It distributes the computed coverage for one * subpixel to all subpixels equally, sacrificing some won resolution * but drastically reducing color-fringing. Positioning improvements * remain! Note that color-fringing can only really be minimized * when using a color-balanced filter and alpha-blending the glyph * onto a surface in linear space; see @FT_Render_Glyph. * * Regarding the form, a filter can be a `boxy' filter or a `beveled' * filter. Boxy filters are sharper but are less forgiving of non-ideal * gamma curves of a screen (viewing angles!), beveled filters are * fuzzier but more tolerant. * * Examples: * * - [0x10 0x40 0x70 0x40 0x10] is beveled and neither balanced nor * normalized. * * - [0x1A 0x33 0x4D 0x33 0x1A] is beveled and balanced but not * normalized. * * - [0x19 0x33 0x66 0x4c 0x19] is beveled and normalized but not * balanced. * * - [0x00 0x4c 0x66 0x4c 0x00] is boxily beveled and normalized but not * balanced. * * - [0x00 0x55 0x56 0x55 0x00] is boxy, normalized, and almost * balanced. * * - [0x08 0x4D 0x56 0x4D 0x08] is beveled, normalized and, almost * balanced. * * The filter affects glyph bitmaps rendered through @FT_Render_Glyph, * @FT_Load_Glyph, and @FT_Load_Char. It does _not_ affect the output * of @FT_Outline_Render and @FT_Outline_Get_Bitmap. * * If this feature is activated, the dimensions of LCD glyph bitmaps are * either wider or taller than the dimensions of the corresponding * outline with regard to the pixel grid. For example, for * @FT_RENDER_MODE_LCD, the filter adds 3~subpixels to the left, and * 3~subpixels to the right. The bitmap offset values are adjusted * accordingly, so clients shouldn't need to modify their layout and * glyph positioning code when enabling the filter. * * It is important to understand that linear alpha blending and gamma * correction is critical for correctly rendering glyphs onto surfaces * without artifacts and even more critical when subpixel rendering is * involved. * * Each of the 3~alpha values (subpixels) is independently used to blend * one color channel. That is, red alpha blends the red channel of the * text color with the red channel of the background pixel. The * distribution of density values by the color-balanced filter assumes * alpha blending is done in linear space; only then color artifacts * cancel out. */ /**************************************************************************** * * @enum: * FT_LcdFilter * * @description: * A list of values to identify various types of LCD filters. * * @values: * FT_LCD_FILTER_NONE :: * Do not perform filtering. When used with subpixel rendering, this * results in sometimes severe color fringes. * * FT_LCD_FILTER_DEFAULT :: * The default filter reduces color fringes considerably, at the cost * of a slight blurriness in the output. * * It is a beveled, normalized, and color-balanced five-tap filter * that is more forgiving to screens with non-ideal gamma curves and * viewing angles. Note that while color-fringing is reduced, it can * only be minimized by using linear alpha blending and gamma * correction to render glyphs onto surfaces. The default filter * weights are [0x08 0x4D 0x56 0x4D 0x08]. * * FT_LCD_FILTER_LIGHT :: * The light filter is a variant that is sharper at the cost of * slightly more color fringes than the default one. * * It is a boxy, normalized, and color-balanced three-tap filter that * is less forgiving to screens with non-ideal gamma curves and * viewing angles. This filter works best when the rendering system * uses linear alpha blending and gamma correction to render glyphs * onto surfaces. The light filter weights are * [0x00 0x55 0x56 0x55 0x00]. * * FT_LCD_FILTER_LEGACY :: * This filter corresponds to the original libXft color filter. It * provides high contrast output but can exhibit really bad color * fringes if glyphs are not extremely well hinted to the pixel grid. * In other words, it only works well if the TrueType bytecode * interpreter is enabled *and* high-quality hinted fonts are used. * * This filter is only provided for comparison purposes, and might be * disabled or stay unsupported in the future. * * FT_LCD_FILTER_LEGACY1 :: * For historical reasons, the FontConfig library returns a different * enumeration value for legacy LCD filtering. To make code work that * (incorrectly) forwards FontConfig's enumeration value to * @FT_Library_SetLcdFilter without proper mapping, it is thus easiest * to have another enumeration value, which is completely equal to * `FT_LCD_FILTER_LEGACY'. * * @since: * 2.3.0 (`FT_LCD_FILTER_LEGACY1' since 2.6.2) */ typedef enum FT_LcdFilter_ { FT_LCD_FILTER_NONE = 0, FT_LCD_FILTER_DEFAULT = 1, FT_LCD_FILTER_LIGHT = 2, FT_LCD_FILTER_LEGACY1 = 3, FT_LCD_FILTER_LEGACY = 16, FT_LCD_FILTER_MAX /* do not remove */ } FT_LcdFilter; /************************************************************************** * * @func: * FT_Library_SetLcdFilter * * @description: * This function is used to apply color filtering to LCD decimated * bitmaps, like the ones used when calling @FT_Render_Glyph with * @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V. * * @input: * library :: * A handle to the target library instance. * * filter :: * The filter type. * * You can use @FT_LCD_FILTER_NONE here to disable this feature, or * @FT_LCD_FILTER_DEFAULT to use a default filter that should work * well on most LCD screens. * * @return: * FreeType error code. 0~means success. * * @note: * This feature is always disabled by default. Clients must make an * explicit call to this function with a `filter' value other than * @FT_LCD_FILTER_NONE in order to enable it. * * Due to *PATENTS* covering subpixel rendering, this function doesn't * do anything except returning `FT_Err_Unimplemented_Feature' if the * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not * defined in your build of the library, which should correspond to all * default builds of FreeType. * * @since: * 2.3.0 */ FT_EXPORT( FT_Error ) FT_Library_SetLcdFilter( FT_Library library, FT_LcdFilter filter ); /************************************************************************** * * @func: * FT_Library_SetLcdFilterWeights * * @description: * This function can be used to enable LCD filter with custom weights, * instead of using presets in @FT_Library_SetLcdFilter. * * @input: * library :: * A handle to the target library instance. * * weights :: * A pointer to an array; the function copies the first five bytes and * uses them to specify the filter weights. * * @return: * FreeType error code. 0~means success. * * @note: * Due to *PATENTS* covering subpixel rendering, this function doesn't * do anything except returning `FT_Err_Unimplemented_Feature' if the * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not * defined in your build of the library, which should correspond to all * default builds of FreeType. * * LCD filter weights can also be set per face using @FT_Face_Properties * with @FT_PARAM_TAG_LCD_FILTER_WEIGHTS. * * @since: * 2.4.0 */ FT_EXPORT( FT_Error ) FT_Library_SetLcdFilterWeights( FT_Library library, unsigned char *weights ); /* * @type: * FT_LcdFiveTapFilter * * @description: * A typedef for passing the five LCD filter weights to * @FT_Face_Properties within an @FT_Parameter structure. * * @since: * 2.8 * */ #define FT_LCD_FILTER_FIVE_TAPS 5 typedef FT_Byte FT_LcdFiveTapFilter[FT_LCD_FILTER_FIVE_TAPS]; /* */ FT_END_HEADER #endif /* FTLCDFIL_H_ */ /* END */
{ "pile_set_name": "Github" }
/* (No Commment) */ "CFBundleName" = "餐厅";
{ "pile_set_name": "Github" }
// // LMJCalendarViewController.m // PLMMPRJK // // Created by HuXuPeng on 2017/5/7. // Copyright © 2017年 GoMePrjk. All rights reserved. // #import "LMJCalendarViewController.h" #import "LMJEventTool.h" @interface LMJCalendarViewController () @end @implementation LMJCalendarViewController - (void)viewDidLoad { [super viewDidLoad]; LMJWeak(self); LMJEventModel *eventModel = [[LMJEventModel alloc] init]; // @property (nonatomic, strong) NSString *title; //标题 // @property (nonatomic, strong) NSString *location; //地点 //@"yyyy-MM-dd HH:mm" // @property (nonatomic, strong) NSString *startDateStr; //开始时间 // @property (nonatomic, strong) NSString *endDateStr; //结束时间 // @property (nonatomic, assign) BOOL allDay; //是否全天 // @property (nonatomic, strong) NSString *notes; //备注 // if (alarmStr.length == 0) { // alarmTime = 0; // } else if ([alarmStr isEqualToString:@"不提醒"]) { // alarmTime = 0; // } else if ([alarmStr isEqualToString:@"1分钟前"]) { // alarmTime = 60.0 * -1.0f; // } else if ([alarmStr isEqualToString:@"10分钟前"]) { // alarmTime = 60.0 * -10.f; // } else if ([alarmStr isEqualToString:@"30分钟前"]) { // alarmTime = 60.0 * -30.f; // } else if ([alarmStr isEqualToString:@"1小时前"]) { // alarmTime = 60.0 * -60.f; // } else if ([alarmStr isEqualToString:@"1天前"]) { // alarmTime = 60.0 * - 60.f * 24; // @property (nonatomic, strong) NSString *alarmStr; //提醒 eventModel.title = @"eventModel标题"; eventModel.location = @"BeiJing"; eventModel.startDateStr = @"2018-04-05 19:10"; eventModel.endDateStr = @"2018-04-05 20:10"; eventModel.allDay = YES; eventModel.notes = @"eventModel备注"; eventModel.alarmStr = @"1小时前"; self.addItem([LMJWordItem itemWithTitle:@"事件标题: " subTitle:@"" itemOperation:nil]) .addItem([LMJWordItem itemWithTitle:@"增加日历事件" subTitle: nil itemOperation:^(NSIndexPath *indexPath) { [[LMJEventTool sharedEventTool] createEventWithEventModel:eventModel]; [weakself.view makeToast:@"增加了"]; }]) .addItem([LMJWordItem itemWithTitle:@"查找" subTitle: nil itemOperation:^(NSIndexPath *indexPath) { EKEvent *event = [[LMJEventTool sharedEventTool] getEventWithEKEventModel:eventModel]; weakself.sections.firstObject.items.firstObject.subTitle = event.title; [weakself.tableView reloadRow:0 inSection:0 withRowAnimation:0]; }]) .addItem([LMJWordItem itemWithTitle:@"删除" subTitle:nil itemOperation:^(NSIndexPath *indexPath) { BOOL isDeleted = [[LMJEventTool sharedEventTool] deleteEvent:eventModel]; if (isDeleted) { [weakself.view makeToast:@"删除成功"]; weakself.sections.firstObject.items.firstObject.subTitle = nil; [weakself.tableView reloadRow:0 inSection:0 withRowAnimation:0]; }else { [weakself.view makeToast:@"删除失败"]; } }]); } #pragma mark - LMJNavUIBaseViewControllerDataSource /** 导航条左边的按钮 */ - (UIImage *)lmjNavigationBarLeftButtonImage:(UIButton *)leftButton navigationBar:(LMJNavigationBar *)navigationBar { [leftButton setImage:[UIImage imageNamed:@"NavgationBar_white_back"] forState:UIControlStateHighlighted]; return [UIImage imageNamed:@"NavgationBar_blue_back"]; } #pragma mark - LMJNavUIBaseViewControllerDelegate /** 左边的按钮的点击 */ -(void)leftButtonEvent:(UIButton *)sender navigationBar:(LMJNavigationBar *)navigationBar { [self.navigationController popViewControllerAnimated:YES]; } @end
{ "pile_set_name": "Github" }
// // detail/winrt_ssocket_service.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef ASIO_DETAIL_WINRT_SSOCKET_SERVICE_HPP #define ASIO_DETAIL_WINRT_SSOCKET_SERVICE_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" #if defined(ASIO_WINDOWS_RUNTIME) #include "asio/error.hpp" #include "asio/io_service.hpp" #include "asio/detail/addressof.hpp" #include "asio/detail/winrt_socket_connect_op.hpp" #include "asio/detail/winrt_ssocket_service_base.hpp" #include "asio/detail/winrt_utils.hpp" #include "asio/detail/push_options.hpp" namespace clmdep_asio { namespace detail { template <typename Protocol> class winrt_ssocket_service : public winrt_ssocket_service_base { public: // The protocol type. typedef Protocol protocol_type; // The endpoint type. typedef typename Protocol::endpoint endpoint_type; // The native type of a socket. typedef Windows::Networking::Sockets::StreamSocket^ native_handle_type; // The implementation type of the socket. struct implementation_type : base_implementation_type { // Default constructor. implementation_type() : base_implementation_type(), protocol_(endpoint_type().protocol()) { } // The protocol associated with the socket. protocol_type protocol_; }; // Constructor. winrt_ssocket_service(clmdep_asio::io_service& io_service) : winrt_ssocket_service_base(io_service) { } // Move-construct a new socket implementation. void move_construct(implementation_type& impl, implementation_type& other_impl) { this->base_move_construct(impl, other_impl); impl.protocol_ = other_impl.protocol_; other_impl.protocol_ = endpoint_type().protocol(); } // Move-assign from another socket implementation. void move_assign(implementation_type& impl, winrt_ssocket_service& other_service, implementation_type& other_impl) { this->base_move_assign(impl, other_service, other_impl); impl.protocol_ = other_impl.protocol_; other_impl.protocol_ = endpoint_type().protocol(); } // Move-construct a new socket implementation from another protocol type. template <typename Protocol1> void converting_move_construct(implementation_type& impl, typename winrt_ssocket_service< Protocol1>::implementation_type& other_impl) { this->base_move_construct(impl, other_impl); impl.protocol_ = protocol_type(other_impl.protocol_); other_impl.protocol_ = typename Protocol1::endpoint().protocol(); } // Open a new socket implementation. clmdep_asio::error_code open(implementation_type& impl, const protocol_type& protocol, clmdep_asio::error_code& ec) { if (is_open(impl)) { ec = clmdep_asio::error::already_open; return ec; } try { impl.socket_ = ref new Windows::Networking::Sockets::StreamSocket; impl.protocol_ = protocol; ec = clmdep_asio::error_code(); } catch (Platform::Exception^ e) { ec = clmdep_asio::error_code(e->HResult, clmdep_asio::system_category()); } return ec; } // Assign a native socket to a socket implementation. clmdep_asio::error_code assign(implementation_type& impl, const protocol_type& protocol, const native_handle_type& native_socket, clmdep_asio::error_code& ec) { if (is_open(impl)) { ec = clmdep_asio::error::already_open; return ec; } impl.socket_ = native_socket; impl.protocol_ = protocol; ec = clmdep_asio::error_code(); return ec; } // Bind the socket to the specified local endpoint. clmdep_asio::error_code bind(implementation_type&, const endpoint_type&, clmdep_asio::error_code& ec) { ec = clmdep_asio::error::operation_not_supported; return ec; } // Get the local endpoint. endpoint_type local_endpoint(const implementation_type& impl, clmdep_asio::error_code& ec) const { endpoint_type endpoint; endpoint.resize(do_get_endpoint(impl, true, endpoint.data(), endpoint.size(), ec)); return endpoint; } // Get the remote endpoint. endpoint_type remote_endpoint(const implementation_type& impl, clmdep_asio::error_code& ec) const { endpoint_type endpoint; endpoint.resize(do_get_endpoint(impl, false, endpoint.data(), endpoint.size(), ec)); return endpoint; } // Set a socket option. template <typename Option> clmdep_asio::error_code set_option(implementation_type& impl, const Option& option, clmdep_asio::error_code& ec) { return do_set_option(impl, option.level(impl.protocol_), option.name(impl.protocol_), option.data(impl.protocol_), option.size(impl.protocol_), ec); } // Get a socket option. template <typename Option> clmdep_asio::error_code get_option(const implementation_type& impl, Option& option, clmdep_asio::error_code& ec) const { std::size_t size = option.size(impl.protocol_); do_get_option(impl, option.level(impl.protocol_), option.name(impl.protocol_), option.data(impl.protocol_), &size, ec); if (!ec) option.resize(impl.protocol_, size); return ec; } // Connect the socket to the specified endpoint. clmdep_asio::error_code connect(implementation_type& impl, const endpoint_type& peer_endpoint, clmdep_asio::error_code& ec) { return do_connect(impl, peer_endpoint.data(), ec); } // Start an asynchronous connect. template <typename Handler> void async_connect(implementation_type& impl, const endpoint_type& peer_endpoint, Handler& handler) { bool is_continuation = clmdep_asio_handler_cont_helpers::is_continuation(handler); // Allocate and construct an operation to wrap the handler. typedef winrt_socket_connect_op<Handler> op; typename op::ptr p = { clmdep_asio::detail::addressof(handler), clmdep_asio_handler_alloc_helpers::allocate( sizeof(op), handler), 0 }; p.p = new (p.v) op(handler); ASIO_HANDLER_CREATION((p.p, "socket", &impl, "async_connect")); start_connect_op(impl, peer_endpoint.data(), p.p, is_continuation); p.v = p.p = 0; } }; } // namespace detail } // namespace clmdep_asio #include "asio/detail/pop_options.hpp" #endif // defined(ASIO_WINDOWS_RUNTIME) #endif // ASIO_DETAIL_WINRT_SSOCKET_SERVICE_HPP
{ "pile_set_name": "Github" }
%verify "executed" %include "arm-vfp/funop.S" {"instr":"ftosizs s1, s0"}
{ "pile_set_name": "Github" }
// Copyright 2015 Dolphin Emulator Project // Licensed under GPLv2+ // Refer to the license.txt file included. #pragma once #include <memory> #include <optional> #include <vector> #include "Common/CommonTypes.h" class PointerWrap; namespace DiscIO { struct Partition; } namespace DVDInterface { enum class ReplyType : u32; } namespace DiscIO { enum class Platform; class Volume; } // namespace DiscIO namespace IOS::ES { class TMDReader; class TicketReader; } // namespace IOS::ES namespace DVDThread { void Start(); void Stop(); void DoState(PointerWrap& p); void SetDisc(std::unique_ptr<DiscIO::Volume> disc); bool HasDisc(); bool IsEncryptedAndHashed(); DiscIO::Platform GetDiscType(); u64 PartitionOffsetToRawOffset(u64 offset, const DiscIO::Partition& partition); IOS::ES::TMDReader GetTMD(const DiscIO::Partition& partition); IOS::ES::TicketReader GetTicket(const DiscIO::Partition& partition); bool IsInsertedDiscRunning(); // This function returns true and calls SConfig::SetRunningGameMetadata(Volume&, Partition&) // if both of the following conditions are true: // - A disc is inserted // - The title_id argument doesn't contain a value, or its value matches the disc's title ID bool UpdateRunningGameMetadata(const DiscIO::Partition& partition, std::optional<u64> title_id = {}); void StartRead(u64 dvd_offset, u32 length, const DiscIO::Partition& partition, DVDInterface::ReplyType reply_type, s64 ticks_until_completion); void StartReadToEmulatedRAM(u32 output_address, u64 dvd_offset, u32 length, const DiscIO::Partition& partition, DVDInterface::ReplyType reply_type, s64 ticks_until_completion); } // namespace DVDThread
{ "pile_set_name": "Github" }
/* * Copyright (C) 2014 Freescale Semiconductor * * SPDX-License-Identifier: GPL-2.0+ */ #ifndef __FSL_DPAA_FD_H #define __FSL_DPAA_FD_H /* Place-holder for FDs, we represent it via the simplest form that we need for * now. Different overlays may be needed to support different options, etc. (It * is impractical to define One True Struct, because the resulting encoding * routines (lots of read-modify-writes) would be worst-case performance whether * or not circumstances required them.) */ struct dpaa_fd { union { u32 words[8]; struct dpaa_fd_simple { u32 addr_lo; u32 addr_hi; u32 len; /* offset in the MS 16 bits, BPID in the LS 16 bits */ u32 bpid_offset; u32 frc; /* frame context */ /* "err", "va", "cbmt", "asal", [...] */ u32 ctrl; /* flow context */ u32 flc_lo; u32 flc_hi; } simple; }; }; enum dpaa_fd_format { dpaa_fd_single = 0, dpaa_fd_list, dpaa_fd_sg }; static inline u64 ldpaa_fd_get_addr(const struct dpaa_fd *fd) { return (u64)((((uint64_t)fd->simple.addr_hi) << 32) + fd->simple.addr_lo); } static inline void ldpaa_fd_set_addr(struct dpaa_fd *fd, u64 addr) { fd->simple.addr_hi = upper_32_bits(addr); fd->simple.addr_lo = lower_32_bits(addr); } static inline u32 ldpaa_fd_get_len(const struct dpaa_fd *fd) { return fd->simple.len; } static inline void ldpaa_fd_set_len(struct dpaa_fd *fd, u32 len) { fd->simple.len = len; } static inline uint16_t ldpaa_fd_get_offset(const struct dpaa_fd *fd) { return (uint16_t)(fd->simple.bpid_offset >> 16) & 0x0FFF; } static inline void ldpaa_fd_set_offset(struct dpaa_fd *fd, uint16_t offset) { fd->simple.bpid_offset &= 0xF000FFFF; fd->simple.bpid_offset |= (u32)offset << 16; } static inline uint16_t ldpaa_fd_get_bpid(const struct dpaa_fd *fd) { return (uint16_t)(fd->simple.bpid_offset & 0xFFFF); } static inline void ldpaa_fd_set_bpid(struct dpaa_fd *fd, uint16_t bpid) { fd->simple.bpid_offset &= 0xFFFF0000; fd->simple.bpid_offset |= (u32)bpid; } /* When frames are dequeued, the FDs show up inside "dequeue" result structures * (if at all, not all dequeue results contain valid FDs). This structure type * is intentionally defined without internal detail, and the only reason it * isn't declared opaquely (without size) is to allow the user to provide * suitably-sized (and aligned) memory for these entries. */ struct ldpaa_dq { uint32_t dont_manipulate_directly[16]; }; /* Parsing frame dequeue results */ #define LDPAA_DQ_STAT_FQEMPTY 0x80 #define LDPAA_DQ_STAT_HELDACTIVE 0x40 #define LDPAA_DQ_STAT_FORCEELIGIBLE 0x20 #define LDPAA_DQ_STAT_VALIDFRAME 0x10 #define LDPAA_DQ_STAT_ODPVALID 0x04 #define LDPAA_DQ_STAT_VOLATILE 0x02 #define LDPAA_DQ_STAT_EXPIRED 0x01 uint32_t ldpaa_dq_flags(const struct ldpaa_dq *); static inline int ldpaa_dq_is_pull(const struct ldpaa_dq *dq) { return (int)(ldpaa_dq_flags(dq) & LDPAA_DQ_STAT_VOLATILE); } static inline int ldpaa_dq_is_pull_complete( const struct ldpaa_dq *dq) { return (int)(ldpaa_dq_flags(dq) & LDPAA_DQ_STAT_EXPIRED); } /* seqnum/odpid are valid only if VALIDFRAME and ODPVALID flags are TRUE */ uint16_t ldpaa_dq_seqnum(const struct ldpaa_dq *); uint16_t ldpaa_dq_odpid(const struct ldpaa_dq *); uint32_t ldpaa_dq_fqid(const struct ldpaa_dq *); uint32_t ldpaa_dq_byte_count(const struct ldpaa_dq *); uint32_t ldpaa_dq_frame_count(const struct ldpaa_dq *); uint32_t ldpaa_dq_fqd_ctx_hi(const struct ldpaa_dq *); uint32_t ldpaa_dq_fqd_ctx_lo(const struct ldpaa_dq *); /* get the Frame Descriptor */ const struct dpaa_fd *ldpaa_dq_fd(const struct ldpaa_dq *); #endif /* __FSL_DPAA_FD_H */
{ "pile_set_name": "Github" }
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build aix // +build ppc package unix //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64 //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64 //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64 //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) func setTimespec(sec, nsec int64) Timespec { return Timespec{Sec: int32(sec), Nsec: int32(nsec)} } func setTimeval(sec, usec int64) Timeval { return Timeval{Sec: int32(sec), Usec: int32(usec)} } func (iov *Iovec) SetLen(length int) { iov.Len = uint32(length) } func (msghdr *Msghdr) SetControllen(length int) { msghdr.Controllen = uint32(length) } func (msghdr *Msghdr) SetIovlen(length int) { msghdr.Iovlen = int32(length) } func (cmsg *Cmsghdr) SetLen(length int) { cmsg.Len = uint32(length) } func Fstat(fd int, stat *Stat_t) error { return fstat(fd, stat) } func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error { return fstatat(dirfd, path, stat, flags) } func Lstat(path string, stat *Stat_t) error { return lstat(path, stat) } func Stat(path string, statptr *Stat_t) error { return stat(path, statptr) }
{ "pile_set_name": "Github" }
# /* ************************************************************************** # * * # * (C) Copyright Edward Diener 2014. * # * Distributed under the Boost Software License, Version 1.0. (See * # * accompanying file LICENSE_1_0.txt or copy at * # * http://www.boost.org/LICENSE_1_0.txt) * # * * # ************************************************************************** */ # # /* See http://www.boost.org for most recent version. */ # # ifndef BOOST_PREPROCESSOR_ARRAY_DETAIL_GET_DATA_HPP # define BOOST_PREPROCESSOR_ARRAY_DETAIL_GET_DATA_HPP # # include <boost/preprocessor/config/config.hpp> # include <boost/preprocessor/tuple/rem.hpp> # include <boost/preprocessor/control/if.hpp> # include <boost/preprocessor/control/iif.hpp> # include <boost/preprocessor/facilities/is_1.hpp> # # /* BOOST_PP_ARRAY_DETAIL_GET_DATA */ # # define BOOST_PP_ARRAY_DETAIL_GET_DATA_NONE(size, data) # if BOOST_PP_VARIADICS && !(BOOST_PP_VARIADICS_MSVC && _MSC_VER <= 1400) # if BOOST_PP_VARIADICS_MSVC # define BOOST_PP_ARRAY_DETAIL_GET_DATA_ANY_VC_DEFAULT(size, data) BOOST_PP_TUPLE_REM(size) data # define BOOST_PP_ARRAY_DETAIL_GET_DATA_ANY_VC_CAT(size, data) BOOST_PP_TUPLE_REM_CAT(size) data # define BOOST_PP_ARRAY_DETAIL_GET_DATA_ANY(size, data) \ BOOST_PP_IIF \ ( \ BOOST_PP_IS_1(size), \ BOOST_PP_ARRAY_DETAIL_GET_DATA_ANY_VC_CAT, \ BOOST_PP_ARRAY_DETAIL_GET_DATA_ANY_VC_DEFAULT \ ) \ (size,data) \ /**/ # else # define BOOST_PP_ARRAY_DETAIL_GET_DATA_ANY(size, data) BOOST_PP_TUPLE_REM(size) data # endif # else # define BOOST_PP_ARRAY_DETAIL_GET_DATA_ANY(size, data) BOOST_PP_TUPLE_REM(size) data # endif # define BOOST_PP_ARRAY_DETAIL_GET_DATA(size, data) \ BOOST_PP_IF \ ( \ size, \ BOOST_PP_ARRAY_DETAIL_GET_DATA_ANY, \ BOOST_PP_ARRAY_DETAIL_GET_DATA_NONE \ ) \ (size,data) \ /**/ # # endif /* BOOST_PREPROCESSOR_ARRAY_DETAIL_GET_DATA_HPP */
{ "pile_set_name": "Github" }
//////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2007-2016 Hartmut Kaiser // Copyright (c) 2008-2009 Chirag Dekate, Anshul Tandon // Copyright (c) 2012-2013 Thomas Heller // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //////////////////////////////////////////////////////////////////////////////// #pragma once #include <hpx/config.hpp> #include <hpx/assert.hpp> #include <hpx/modules/errors.hpp> #include <hpx/topology/cpu_mask.hpp> #include <boost/variant.hpp> #include <cstddef> #include <cstdint> #include <limits> #include <string> #include <utility> #include <vector> namespace hpx { namespace threads { namespace detail { typedef std::vector<std::int64_t> bounds_type; enum distribution_type { compact = 0x01, scatter = 0x02, balanced = 0x04, numa_balanced = 0x08 }; struct spec_type { enum type { unknown, thread, socket, numanode, core, pu }; HPX_CORE_EXPORT static char const* type_name(type t); static std::int64_t all_entities() { return (std::numeric_limits<std::int64_t>::min)(); } spec_type(type t = unknown, std::int64_t min = all_entities(), std::int64_t max = all_entities()) : type_(t) , index_bounds_() { if (t != unknown) { if (max == 0 || max == all_entities()) { // one or all entities index_bounds_.push_back(min); } else if (min != all_entities()) { // all entities between min and -max, or just min,max HPX_ASSERT(min >= 0); index_bounds_.push_back(min); index_bounds_.push_back(max); } } } bool operator==(spec_type const& rhs) const { if (type_ != rhs.type_ || index_bounds_.size() != rhs.index_bounds_.size()) return false; for (std::size_t i = 0; i < index_bounds_.size(); ++i) { if (index_bounds_[i] != rhs.index_bounds_[i]) return false; } return true; } type type_; bounds_type index_bounds_; }; typedef std::vector<spec_type> mapping_type; typedef std::pair<spec_type, mapping_type> full_mapping_type; typedef std::vector<full_mapping_type> mappings_spec_type; typedef boost::variant<distribution_type, mappings_spec_type> mappings_type; HPX_CORE_EXPORT bounds_type extract_bounds( spec_type const& m, std::size_t default_last, error_code& ec); HPX_CORE_EXPORT void parse_mappings(std::string const& spec, mappings_type& mappings, error_code& ec = throws); } // namespace detail HPX_CORE_EXPORT void parse_affinity_options(std::string const& spec, std::vector<mask_type>& affinities, std::size_t used_cores, std::size_t max_cores, std::size_t num_threads, std::vector<std::size_t>& num_pus, bool use_process_mask, error_code& ec = throws); // backwards compatibility helper inline void parse_affinity_options(std::string const& spec, std::vector<mask_type>& affinities, error_code& ec = throws) { std::vector<std::size_t> num_pus; parse_affinity_options( spec, affinities, 1, 1, affinities.size(), num_pus, false, ec); } }} // namespace hpx::threads
{ "pile_set_name": "Github" }
// Boost.Units - A C++ library for zero-overhead dimensional analysis and // unit/quantity manipulation and conversion // // Copyright (C) 2003-2008 Matthias Christian Schabel // Copyright (C) 2008 Steven Watanabe // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_UNITS_ACCELERATION_DERIVED_DIMENSION_HPP #define BOOST_UNITS_ACCELERATION_DERIVED_DIMENSION_HPP #include <boost/units/derived_dimension.hpp> #include <boost/units/physical_dimensions/length.hpp> #include <boost/units/physical_dimensions/time.hpp> namespace boost { namespace units { /// derived dimension for acceleration : L T^-2 typedef derived_dimension<length_base_dimension,1, time_base_dimension,-2>::type acceleration_dimension; } // namespace units } // namespace boost #endif // BOOST_UNITS_ACCELERATION_DERIVED_DIMENSION_HPP
{ "pile_set_name": "Github" }
// Boost.Units - A C++ library for zero-overhead dimensional analysis and // unit/quantity manipulation and conversion // // Copyright (C) 2003-2008 Matthias Christian Schabel // Copyright (C) 2008 Steven Watanabe // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_UNITS_PRESSURE_DERIVED_DIMENSION_HPP #define BOOST_UNITS_PRESSURE_DERIVED_DIMENSION_HPP #include <boost/units/derived_dimension.hpp> #include <boost/units/physical_dimensions/length.hpp> #include <boost/units/physical_dimensions/mass.hpp> #include <boost/units/physical_dimensions/time.hpp> namespace boost { namespace units { /// derived dimension for pressure : L^-1 M T^-2 typedef derived_dimension<length_base_dimension,-1, mass_base_dimension,1, time_base_dimension,-2>::type pressure_dimension; } // namespace units } // namespace boost #endif // BOOST_UNITS_PRESSURE_DERIVED_DIMENSION_HPP
{ "pile_set_name": "Github" }
{ config, pkgs, lib, ... }: with lib; let cfg = config.services.jackett; in { options = { services.jackett = { enable = mkEnableOption "Jackett"; dataDir = mkOption { type = types.str; default = "/var/lib/jackett/.config/Jackett"; description = "The directory where Jackett stores its data files."; }; openFirewall = mkOption { type = types.bool; default = false; description = "Open ports in the firewall for the Jackett web interface."; }; user = mkOption { type = types.str; default = "jackett"; description = "User account under which Jackett runs."; }; group = mkOption { type = types.str; default = "jackett"; description = "Group under which Jackett runs."; }; package = mkOption { type = types.package; default = pkgs.jackett; defaultText = "pkgs.jackett"; description = "Jackett package to use."; }; }; }; config = mkIf cfg.enable { systemd.tmpfiles.rules = [ "d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -" ]; systemd.services.jackett = { description = "Jackett"; after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { Type = "simple"; User = cfg.user; Group = cfg.group; ExecStart = "${cfg.package}/bin/Jackett --NoUpdates --DataFolder '${cfg.dataDir}'"; Restart = "on-failure"; }; }; networking.firewall = mkIf cfg.openFirewall { allowedTCPPorts = [ 9117 ]; }; users.users = mkIf (cfg.user == "jackett") { jackett = { group = cfg.group; home = cfg.dataDir; uid = config.ids.uids.jackett; }; }; users.groups = mkIf (cfg.group == "jackett") { jackett.gid = config.ids.gids.jackett; }; }; }
{ "pile_set_name": "Github" }
; RUN: opt < %s -instcombine -S | FileCheck %s ; <rdar://problem/10803154> ; There should be no transformation. ; CHECK: %a = trunc i32 %x to i8 ; CHECK: %b = icmp ne i8 %a, 0 ; CHECK: %c = and i32 %x, 16711680 ; CHECK: %d = icmp ne i32 %c, 0 ; CHECK: %e = and i1 %b, %d ; CHECK: ret i1 %e define i1 @f1(i32 %x) { %a = trunc i32 %x to i8 %b = icmp ne i8 %a, 0 %c = and i32 %x, 16711680 %d = icmp ne i32 %c, 0 %e = and i1 %b, %d ret i1 %e }
{ "pile_set_name": "Github" }
//===- llvm/Assembly/PrintModulePass.h - Printing Pass ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file defines two passes to print out a module. The PrintModulePass pass // simply prints out the entire module when it is executed. The // PrintFunctionPass class is designed to be pipelined with other // FunctionPass's, and prints out the functions of the module as they are // processed. // //===----------------------------------------------------------------------===// #ifndef LLVM_ASSEMBLY_PRINTMODULEPASS_H #define LLVM_ASSEMBLY_PRINTMODULEPASS_H #include <string> namespace llvm { class FunctionPass; class ModulePass; class raw_ostream; /// createPrintModulePass - Create and return a pass that writes the /// module to the specified raw_ostream. ModulePass *createPrintModulePass(raw_ostream *OS, bool DeleteStream=false, const std::string &Banner = ""); /// createPrintFunctionPass - Create and return a pass that prints /// functions to the specified raw_ostream as they are processed. FunctionPass *createPrintFunctionPass(const std::string &Banner, raw_ostream *OS, bool DeleteStream=false); } // End llvm namespace #endif
{ "pile_set_name": "Github" }
% Generated by roxygen2: do not edit by hand % Please edit documentation in R/ncdc_datasets.r \name{ncdc_datasets} \alias{ncdc_datasets} \title{Search NOAA datasets} \usage{ ncdc_datasets( datasetid = NULL, datatypeid = NULL, stationid = NULL, locationid = NULL, startdate = NULL, enddate = NULL, sortfield = NULL, sortorder = NULL, limit = 25, offset = NULL, token = NULL, ... ) } \arguments{ \item{datasetid}{(optional) Accepts a single valid dataset id. Data returned will be from the dataset specified.} \item{datatypeid}{Accepts a valid data type id or a vector or list of data type ids. (optional)} \item{stationid}{Accepts a valid station id or a vector or list of station ids} \item{locationid}{Accepts a valid location id or a vector or list of location ids (optional)} \item{startdate}{(optional) Accepts valid ISO formated date (yyyy-mm-dd) or date time (YYYY-MM-DDThh:mm:ss). Data returned will have data after the specified date. The date range must be less than 1 year.} \item{enddate}{(optional) Accepts valid ISO formated date (yyyy-mm-dd) or date time (YYYY-MM-DDThh:mm:ss). Data returned will have data before the specified date. The date range must be less than 1 year.} \item{sortfield}{The field to sort results by. Supports id, name, mindate, maxdate, and datacoverage fields (optional)} \item{sortorder}{Which order to sort by, asc or desc. Defaults to asc (optional)} \item{limit}{Defaults to 25, limits the number of results in the response. Maximum is 1000 (optional)} \item{offset}{Defaults to 0, used to offset the resultlist (optional)} \item{token}{This must be a valid token token supplied to you by NCDC's Climate Data Online access token generator. (required) See \strong{Authentication} section below for more details.} \item{...}{Curl options passed on to \code{\link[crul]{HttpClient}} (optional)} } \value{ A data.frame for all datasets, or a list of length two, each with a data.frame. } \description{ From the NOAA API docs: All of our data are in datasets. To retrieve any data from us, you must know what dataset it is in. } \section{Authentication}{ Get an API key (aka, token) at \url{https://www.ncdc.noaa.gov/cdo-web/token}. You can pass your token in as an argument or store it one of two places: \itemize{ \item your .Rprofile file with the entry \code{options(noaakey = "your-noaa-token")} \item your .Renviron file with the entry \code{NOAA_KEY=your-noaa-token} } See \code{\link{Startup}} for information on how to create/find your .Rrofile and .Renviron files } \examples{ \dontrun{ # Get a table of all datasets ncdc_datasets() # Get details from a particular dataset ncdc_datasets(datasetid='ANNUAL') # Get datasets with Temperature at the time of observation (TOBS) data type ncdc_datasets(datatypeid='TOBS') ## two datatypeid's ncdc_datasets(datatypeid=c('TOBS', "ACMH")) # Get datasets with data for a series of the same parameter arg, in this case # stationid's ncdc_datasets(stationid='COOP:310090') ncdc_datasets(stationid=c('COOP:310090','COOP:310184','COOP:310212')) # Multiple datatypeid's ncdc_datasets(datatypeid=c('ACMC','ACMH','ACSC')) ncdc_datasets(datasetid='ANNUAL', datatypeid=c('ACMC','ACMH','ACSC')) ncdc_datasets(datasetid='GSOY', datatypeid=c('ACMC','ACMH','ACSC')) # Multiple locationid's ncdc_datasets(locationid="FIPS:30091") ncdc_datasets(locationid=c("FIPS:30103", "FIPS:30091")) } } \references{ \url{https://www.ncdc.noaa.gov/cdo-web/webservices/v2} } \seealso{ Other ncdc: \code{\link{ncdc_combine}()}, \code{\link{ncdc_datacats}()}, \code{\link{ncdc_datatypes}()}, \code{\link{ncdc_locs_cats}()}, \code{\link{ncdc_locs}()}, \code{\link{ncdc_plot}()}, \code{\link{ncdc_stations}()}, \code{\link{ncdc}()} } \concept{ncdc}
{ "pile_set_name": "Github" }
#ifndef GRAPHICS_API_GLES3 #define NO_NATIVE_SHADOWMAP #endif #ifdef NO_NATIVE_SHADOWMAP #define TEXTURE2D_SHADOW(textureName) uniform mediump sampler2D textureName #define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName,coord3.xy).r<coord3.z?0.0:1.0) #define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap #else #define TEXTURE2D_SHADOW(textureName) uniform mediump sampler2DShadow textureName #define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName,coord3,0.0) #define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap #endif #if defined(RECEIVESHADOW)&&defined(SHADOW) #define CALCULATE_SHADOWS #endif #if defined(RECEIVESHADOW)&&defined(SHADOW_SPOT) #define CALCULATE_SPOTSHADOWS #endif uniform vec4 u_ShadowBias; // x: depth bias, y: normal bias #if defined(CALCULATE_SHADOWS)||defined(CALCULATE_SPOTSHADOWS) #include "ShadowSampleTent.glsl" uniform vec4 u_ShadowMapSize; uniform vec4 u_ShadowParams; // x: shadowStrength y: ShadowSpotLightStrength float sampleShdowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize) { float attenuation; vec4 attenuation4; vec2 offset=shadowMapSize.xy/2.0; vec3 shadowCoord0=shadowCoord + vec3(-offset,0.0); vec3 shadowCoord1=shadowCoord + vec3(offset.x,-offset.y,0.0); vec3 shadowCoord2=shadowCoord + vec3(-offset.x,offset.y,0.0); vec3 shadowCoord3=shadowCoord + vec3(offset,0.0); attenuation4.x = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord0); attenuation4.y = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord1); attenuation4.z = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord2); attenuation4.w = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord3); attenuation = dot(attenuation4, vec4(0.25)); return attenuation; } float sampleShdowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize) { float attenuation; float fetchesWeights[9]; vec2 fetchesUV[9]; sampleShadowComputeSamplesTent5x5(shadowmapSize, shadowCoord.xy, fetchesWeights, fetchesUV); attenuation = fetchesWeights[0] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[0].xy, shadowCoord.z)); attenuation += fetchesWeights[1] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[1].xy, shadowCoord.z)); attenuation += fetchesWeights[2] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[2].xy, shadowCoord.z)); attenuation += fetchesWeights[3] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[3].xy, shadowCoord.z)); attenuation += fetchesWeights[4] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[4].xy, shadowCoord.z)); attenuation += fetchesWeights[5] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[5].xy, shadowCoord.z)); attenuation += fetchesWeights[6] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[6].xy, shadowCoord.z)); attenuation += fetchesWeights[7] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[7].xy, shadowCoord.z)); attenuation += fetchesWeights[8] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[8].xy, shadowCoord.z)); return attenuation; } #endif #if defined(CALCULATE_SHADOWS)//shader中自定义的宏不可用ifdef 必须改成if defined TEXTURE2D_SHADOW(u_ShadowMap); uniform mat4 u_ShadowMatrices[4]; uniform vec4 u_ShadowSplitSpheres[4];// max cascade is 4 mediump int computeCascadeIndex(vec3 positionWS) { vec3 fromCenter0 = positionWS - u_ShadowSplitSpheres[0].xyz; vec3 fromCenter1 = positionWS - u_ShadowSplitSpheres[1].xyz; vec3 fromCenter2 = positionWS - u_ShadowSplitSpheres[2].xyz; vec3 fromCenter3 = positionWS - u_ShadowSplitSpheres[3].xyz; mediump vec4 comparison = vec4( dot(fromCenter0, fromCenter0)<u_ShadowSplitSpheres[0].w, dot(fromCenter1, fromCenter1)<u_ShadowSplitSpheres[1].w, dot(fromCenter2, fromCenter2)<u_ShadowSplitSpheres[2].w, dot(fromCenter3, fromCenter3)<u_ShadowSplitSpheres[3].w); comparison.yzw = clamp(comparison.yzw - comparison.xyz,0.0,1.0);//keep the nearest mediump vec4 indexCoefficient = vec4(4.0,3.0,2.0,1.0); mediump int index = 4 - int(dot(comparison, indexCoefficient)); return index; } vec4 getShadowCoord(vec4 positionWS) { #ifdef SHADOW_CASCADE mediump int cascadeIndex = computeCascadeIndex(positionWS.xyz); if(cascadeIndex > 3)// out of shadow range cascadeIndex is 4. return vec4(0.0); #ifdef GRAPHICS_API_GLES3 return u_ShadowMatrices[cascadeIndex] * positionWS; #else mat4 shadowMat; if(cascadeIndex == 0) shadowMat = u_ShadowMatrices[0]; else if(cascadeIndex == 1) shadowMat = u_ShadowMatrices[1]; else if(cascadeIndex == 2) shadowMat = u_ShadowMatrices[2]; else shadowMat = u_ShadowMatrices[3]; return shadowMat * positionWS; #endif #else return u_ShadowMatrices[0] * positionWS; #endif } float sampleShadowmap(vec4 shadowCoord) { shadowCoord.xyz /= shadowCoord.w; float attenuation = 1.0; if(shadowCoord.z > 0.0 && shadowCoord.z < 1.0) { #if defined(SHADOW_SOFT_SHADOW_HIGH) attenuation = sampleShdowMapFiltered9(u_ShadowMap,shadowCoord.xyz,u_ShadowMapSize); #elif defined(SHADOW_SOFT_SHADOW_LOW) attenuation = sampleShdowMapFiltered4(u_ShadowMap,shadowCoord.xyz,u_ShadowMapSize); #else attenuation = SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,shadowCoord.xyz); #endif attenuation = mix(1.0,attenuation,u_ShadowParams.x);//shadowParams.x:shadow strength } return attenuation; } #endif #if defined(CALCULATE_SPOTSHADOWS)//shader中自定义的宏不可用ifdef 必须改成if defined TEXTURE2D_SHADOW(u_SpotShadowMap); uniform mat4 u_SpotViewProjectMatrix; float sampleSpotShadowmap(vec4 shadowCoord) { shadowCoord.xyz /= shadowCoord.w; float attenuation = 1.0; shadowCoord.xy +=1.0; shadowCoord.xy/=2.0; if(shadowCoord.z > 0.0 && shadowCoord.z < 1.0) { #if defined(SHADOW_SPOT_SOFT_SHADOW_HIGH) attenuation = sampleShdowMapFiltered9(u_SpotShadowMap,shadowCoord.xyz,u_ShadowMapSize); #elif defined(SHADOW_SPOT_SOFT_SHADOW_LOW) attenuation = sampleShdowMapFiltered4(u_SpotShadowMap,shadowCoord.xyz,u_ShadowMapSize); #else attenuation = SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,shadowCoord.xyz); #endif attenuation = mix(1.0,attenuation,u_ShadowParams.y);//shadowParams.y:shadow strength } return attenuation; } #endif vec3 applyShadowBias(vec3 positionWS, vec3 normalWS, vec3 lightDirection) { float invNdotL = 1.0 - clamp(dot(-lightDirection, normalWS),0.0,1.0); float scale = invNdotL * u_ShadowBias.y; // normal bias is negative since we want to apply an inset normal offset positionWS += -lightDirection * u_ShadowBias.xxx; positionWS += normalWS * vec3(scale); return positionWS; }
{ "pile_set_name": "Github" }
/* * Callbacks prototypes for FSM * * Copyright (C) 1996 Universidade de Lisboa * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ #ifndef CALLBACKS_H #define CALLBACKS_H extern void cb_out_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); extern void cb_out_2(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); extern void cb_in_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); extern void cb_in_2(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); extern void cb_in_3(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); extern void cb_disc_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); extern void cb_disc_2(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); extern void cb_disc_3(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); extern void cb_notdone(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); extern void cb_selp_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); extern void cb_open(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); #endif
{ "pile_set_name": "Github" }
/* * GDevelop Core * Copyright 2008-present Florian Rival (Florian.Rival@gmail.com). All rights * reserved. This project is released under the MIT License. */ #ifndef GDCORE_PROPERTYDESCRIPTOR #define GDCORE_PROPERTYDESCRIPTOR #include <vector> #include "GDCore/String.h" namespace gd { class SerializerElement; } namespace gd { /** * \brief Used to describe a property shown in a property grid. * \see gd::Object * \see gd::EffectMetadata */ class GD_CORE_API PropertyDescriptor { public: /** * \brief Create a property being a simple gd::String with the specified * value. * * \param propertyValue The value of the property. */ PropertyDescriptor(gd::String propertyValue) : currentValue(propertyValue), type("string"), label(""), hidden(false) {} /** * \brief Empty constructor creating an empty property to be displayed. */ PropertyDescriptor() : hidden(false){}; /** * \brief Destructor */ virtual ~PropertyDescriptor(); /** * \brief Change the value displayed in the property grid */ PropertyDescriptor& SetValue(gd::String value) { currentValue = value; return *this; } /** * \brief Change the type of the value displayed in the property grid. * \note The type is arbitrary and is interpreted by the class updating the * property grid: Refer to it or to the documentation of the class which is * returning the PropertyDescriptor to learn more about valid values for the * type. */ PropertyDescriptor& SetType(gd::String type_) { type = type_; return *this; } /** * \brief Change the label displayed in the property grid. */ PropertyDescriptor& SetLabel(gd::String label_) { label = label_; return *this; } /** * \brief Change the description displayed to the user, if any. */ PropertyDescriptor& SetDescription(gd::String description_) { description = description_; return *this; } /** * \brief Add an information about the property. * \note The information are arbitrary and are interpreted by the class * updating the property grid: Refer to it or to the documentation of the * class which is returning the PropertyDescriptor to learn more about valid * values for the extra information. */ PropertyDescriptor& AddExtraInfo(const gd::String& info) { extraInformation.push_back(info); return *this; } const gd::String& GetValue() const { return currentValue; } const gd::String& GetType() const { return type; } const gd::String& GetLabel() const { return label; } const gd::String& GetDescription() const { return description; } const std::vector<gd::String>& GetExtraInfo() const { return extraInformation; } /** * \brief Set if the property should be shown or hidden in the editor. */ PropertyDescriptor& SetHidden(bool enable = true) { hidden = enable; return *this; } /** * \brief Check if the property should be shown or hidden in the editor. */ bool IsHidden() const { return hidden; } /** \name Serialization */ ///@{ /** * \brief Serialize the PropertyDescriptor. */ virtual void SerializeTo(SerializerElement& element) const; /** * \brief Unserialize the PropertyDescriptor. */ virtual void UnserializeFrom(const SerializerElement& element); /** * \brief Serialize only the value and extra informations. */ virtual void SerializeValuesTo(SerializerElement& element) const; /** * \brief Unserialize only the value and extra informations. */ virtual void UnserializeValuesFrom(const SerializerElement& element); ///@} private: gd::String currentValue; ///< The current value to be shown. gd::String type; ///< The type of the property. This is arbitrary and interpreted by ///< the class responsible for updating the property grid. gd::String label; //< The user-friendly property name gd::String description; //< The user-friendly property description std::vector<gd::String> extraInformation; ///< Can be used to store for example the available ///< choices, if a property is a displayed as a combo ///< box. bool hidden; }; } // namespace gd #endif
{ "pile_set_name": "Github" }
--- gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc.orig 2019-04-08 08:32:57 UTC +++ gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc @@ -562,7 +562,7 @@ class GLCopyTextureCHROMIUMES3Test : public GLCopyText bool ShouldSkipNorm16() const { DCHECK(!ShouldSkipTest()); -#if (defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX)) && \ +#if (defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) || defined(OS_BSD)) && \ (defined(ARCH_CPU_X86) || defined(ARCH_CPU_X86_64)) // Make sure it's tested; it is safe to assume that the flag is always true // on desktop.
{ "pile_set_name": "Github" }
#ifndef ABSTRACT_H #define ABSTRACT_H #ifdef PROFILE #define printf(a, b) Serial.println(b) #endif #if defined ARDUINO_SAM_DUE || defined ADAFRUIT_GRAND_CENTRAL_M4 #define HostOS 0x01 #endif #ifdef CORE_TEENSY #define HostOS 0x04 #endif #ifdef ESP32 #define HostOS 0x05 #endif #ifdef _STM32_DEF_ #define HostOS 0x06 #endif /* Memory abstraction functions */ /*===============================================================================*/ bool _RamLoad(char* filename, uint16 address) { File f; bool result = false; if (f = SD.open(filename, FILE_READ)) { while (f.available()) _RamWrite(address++, f.read()); f.close(); result = true; } return(result); } /* Filesystem (disk) abstraction fuctions */ /*===============================================================================*/ File rootdir, userdir; #define FOLDERCHAR '/' typedef struct { uint8 dr; uint8 fn[8]; uint8 tp[3]; uint8 ex, s1, s2, rc; uint8 al[16]; uint8 cr, r0, r1, r2; } CPM_FCB; typedef struct { uint8 dr; uint8 fn[8]; uint8 tp[3]; uint8 ex, s1, s2, rc; uint8 al[16]; } CPM_DIRENTRY; #if defined board_teensy41 static DirFat_t fileDirEntry; #else static dir_t fileDirEntry; #endif File _sys_fopen_w(uint8* filename) { return(SD.open((char*)filename, O_CREAT | O_WRITE)); } int _sys_fputc(uint8 ch, File& f) { return(f.write(ch)); } void _sys_fflush(File& f) { f.flush(); } void _sys_fclose(File& f) { f.close(); } int _sys_select(uint8* disk) { uint8 result = FALSE; File f; digitalWrite(LED, HIGH ^ LEDinv); if (f = SD.open((char*)disk, O_READ)) { if (f.isDirectory()) result = TRUE; f.close(); } digitalWrite(LED, LOW ^ LEDinv); return(result); } long _sys_filesize(uint8* filename) { long l = -1; File f; digitalWrite(LED, HIGH ^ LEDinv); if (f = SD.open((char*)filename, O_RDONLY)) { l = f.size(); f.close(); } digitalWrite(LED, LOW ^ LEDinv); return(l); } int _sys_openfile(uint8* filename) { File f; int result = 0; digitalWrite(LED, HIGH ^ LEDinv); f = SD.open((char*)filename, O_READ); if (f) { f.dirEntry(&fileDirEntry); f.close(); result = 1; } digitalWrite(LED, LOW ^ LEDinv); return(result); } int _sys_makefile(uint8* filename) { File f; int result = 0; digitalWrite(LED, HIGH ^ LEDinv); f = SD.open((char*)filename, O_CREAT | O_WRITE); if (f) { f.close(); result = 1; } digitalWrite(LED, LOW ^ LEDinv); return(result); } int _sys_deletefile(uint8* filename) { digitalWrite(LED, HIGH ^ LEDinv); return(SD.remove((char*)filename)); digitalWrite(LED, LOW ^ LEDinv); } int _sys_renamefile(uint8* filename, uint8* newname) { File f; int result = 0; digitalWrite(LED, HIGH ^ LEDinv); f = SD.open((char*)filename, O_WRITE | O_APPEND); if (f) { if (f.rename((char*)newname)) { f.close(); result = 1; } } digitalWrite(LED, LOW ^ LEDinv); return(result); } #ifdef DEBUGLOG void _sys_logbuffer(uint8* buffer) { #ifdef CONSOLELOG puts((char*)buffer); #else File f; uint8 s = 0; while (*(buffer + s)) // Computes buffer size ++s; if (f = SD.open(LogName, O_CREAT | O_APPEND | O_WRITE)) { f.write(buffer, s); f.flush(); f.close(); } #endif } #endif bool _sys_extendfile(char* fn, unsigned long fpos) { uint8 result = true; File f; unsigned long i; digitalWrite(LED, HIGH ^ LEDinv); if (f = SD.open(fn, O_WRITE | O_APPEND)) { if (fpos > f.size()) { for (i = 0; i < f.size() - fpos; ++i) { if (f.write((uint8)0) != 1) { result = false; break; } } } f.close(); } else { result = false; } digitalWrite(LED, LOW ^ LEDinv); return(result); } uint8 _sys_readseq(uint8* filename, long fpos) { uint8 result = 0xff; File f; uint8 bytesread; uint8 dmabuf[BlkSZ]; uint8 i; digitalWrite(LED, HIGH ^ LEDinv); f = SD.open((char*)filename, O_READ); if (f) { if (f.seek(fpos)) { for (i = 0; i < BlkSZ; ++i) dmabuf[i] = 0x1a; bytesread = f.read(&dmabuf[0], BlkSZ); if (bytesread) { for (i = 0; i < BlkSZ; ++i) _RamWrite(dmaAddr + i, dmabuf[i]); } result = bytesread ? 0x00 : 0x01; } else { result = 0x01; } f.close(); } else { result = 0x10; } digitalWrite(LED, LOW ^ LEDinv); return(result); } uint8 _sys_writeseq(uint8* filename, long fpos) { uint8 result = 0xff; File f; digitalWrite(LED, HIGH ^ LEDinv); if (_sys_extendfile((char*)filename, fpos)) f = SD.open((char*)filename, O_RDWR); if (f) { if (f.seek(fpos)) { if (f.write(_RamSysAddr(dmaAddr), BlkSZ)) result = 0x00; } else { result = 0x01; } f.close(); } else { result = 0x10; } digitalWrite(LED, LOW ^ LEDinv); return(result); } uint8 _sys_readrand(uint8* filename, long fpos) { uint8 result = 0xff; File f; uint8 bytesread; uint8 dmabuf[BlkSZ]; uint8 i; long extSize; digitalWrite(LED, HIGH ^ LEDinv); f = SD.open((char*)filename, O_READ); if (f) { if (f.seek(fpos)) { for (i = 0; i < BlkSZ; ++i) dmabuf[i] = 0x1a; bytesread = f.read(&dmabuf[0], BlkSZ); if (bytesread) { for (i = 0; i < BlkSZ; ++i) _RamWrite(dmaAddr + i, dmabuf[i]); } result = bytesread ? 0x00 : 0x01; } else { if (fpos >= 65536L * BlkSZ) { result = 0x06; // seek past 8MB (largest file size in CP/M) } else { extSize = f.size(); // round file size up to next full logical extent extSize = ExtSZ * ((extSize / ExtSZ) + ((extSize % ExtSZ) ? 1 : 0)); if (fpos < extSize) result = 0x01; // reading unwritten data else result = 0x04; // seek to unwritten extent } } f.close(); } else { result = 0x10; } digitalWrite(LED, LOW ^ LEDinv); return(result); } uint8 _sys_writerand(uint8* filename, long fpos) { uint8 result = 0xff; File f; digitalWrite(LED, HIGH ^ LEDinv); if (_sys_extendfile((char*)filename, fpos)) { f = SD.open((char*)filename, O_RDWR); } if (f) { if (f.seek(fpos)) { if (f.write(_RamSysAddr(dmaAddr), BlkSZ)) result = 0x00; } else { result = 0x06; } f.close(); } else { result = 0x10; } digitalWrite(LED, LOW ^ LEDinv); return(result); } static uint8 findNextDirName[13]; static uint16 fileRecords = 0; static uint16 fileExtents = 0; static uint16 fileExtentsUsed = 0; static uint16 firstFreeAllocBlock; uint8 _findnext(uint8 isdir) { File f; uint8 result = 0xff; bool isfile; uint32 bytes; digitalWrite(LED, HIGH ^ LEDinv); if (allExtents && fileRecords) { _mockupDirEntry(); result = 0; } else { while (f = userdir.openNextFile()) { f.getName((char*)&findNextDirName[0], 13); isfile = !f.isDirectory(); bytes = f.size(); f.dirEntry(&fileDirEntry); f.close(); if (!isfile) continue; _HostnameToFCBname(findNextDirName, fcbname); if (match(fcbname, pattern)) { if (isdir) { // account for host files that aren't multiples of the block size // by rounding their bytes up to the next multiple of blocks if (bytes & (BlkSZ - 1)) { bytes = (bytes & ~(BlkSZ - 1)) + BlkSZ; } fileRecords = bytes / BlkSZ; fileExtents = fileRecords / BlkEX + ((fileRecords & (BlkEX - 1)) ? 1 : 0); fileExtentsUsed = 0; firstFreeAllocBlock = firstBlockAfterDir; _mockupDirEntry(); } else { fileRecords = 0; fileExtents = 0; fileExtentsUsed = 0; firstFreeAllocBlock = firstBlockAfterDir; } _RamWrite(tmpFCB, filename[0] - '@'); _HostnameToFCB(tmpFCB, findNextDirName); result = 0x00; break; } } } digitalWrite(LED, LOW ^ LEDinv); return(result); } uint8 _findfirst(uint8 isdir) { uint8 path[4] = { '?', FOLDERCHAR, '?', 0 }; path[0] = filename[0]; path[2] = filename[2]; if (userdir) userdir.close(); userdir = SD.open((char*)path); // Set directory search to start from the first position _HostnameToFCBname(filename, pattern); fileRecords = 0; fileExtents = 0; fileExtentsUsed = 0; return(_findnext(isdir)); } uint8 _findnextallusers(uint8 isdir) { uint8 result = 0xFF; char dirname[13]; bool done = false; while (!done) { while (!userdir) { userdir = rootdir.openNextFile(); if (!userdir) { done = true; break; } userdir.getName(dirname, sizeof dirname); if (userdir.isDirectory() && strlen(dirname) == 1 && isxdigit(dirname[0])) { currFindUser = dirname[0] <= '9' ? dirname[0] - '0' : toupper(dirname[0]) - 'A' + 10; break; } userdir.close(); } if (userdir) { result = _findnext(isdir); if (result) { userdir.close(); } else { done = true; } } else { result = 0xFF; done = true; } } return result; } uint8 _findfirstallusers(uint8 isdir) { uint8 path[2] = { '?', 0 }; path[0] = filename[0]; if (rootdir) rootdir.close(); if (userdir) userdir.close(); rootdir = SD.open((char*)path); // Set directory search to start from the first position strcpy((char*)pattern, "???????????"); if (!rootdir) return 0xFF; fileRecords = 0; fileExtents = 0; fileExtentsUsed = 0; return(_findnextallusers(isdir)); } uint8 _Truncate(char* filename, uint8 rc) { File f; int result = 0; digitalWrite(LED, HIGH ^ LEDinv); f = SD.open((char*)filename, O_WRITE | O_APPEND); if (f) { if (f.truncate(rc * BlkSZ)) { f.close(); result = 1; } } digitalWrite(LED, LOW ^ LEDinv); return(result); } void _MakeUserDir() { uint8 dFolder = cDrive + 'A'; uint8 uFolder = toupper(tohex(userCode)); uint8 path[4] = { dFolder, FOLDERCHAR, uFolder, 0 }; digitalWrite(LED, HIGH ^ LEDinv); SD.mkdir((char*)path); digitalWrite(LED, LOW ^ LEDinv); } uint8 _sys_makedisk(uint8 drive) { uint8 result = 0; if (drive < 1 || drive>16) { result = 0xff; } else { uint8 dFolder = drive + '@'; uint8 disk[2] = { dFolder, 0 }; digitalWrite(LED, HIGH ^ LEDinv); if (!SD.mkdir((char*)disk)) { result = 0xfe; } else { uint8 path[4] = { dFolder, FOLDERCHAR, '0', 0 }; SD.mkdir((char*)path); } digitalWrite(LED, LOW ^ LEDinv); } return(result); } /* Console abstraction functions */ /*===============================================================================*/ int _kbhit(void) { return(Serial.available()); } uint8 _getch(void) { while (!Serial.available()); return(Serial.read()); } uint8 _getche(void) { uint8 ch = _getch(); Serial.write(ch); return(ch); } void _putch(uint8 ch) { Serial.write(ch); } void _clrscr(void) { Serial.println("\e[H\e[J"); } #endif
{ "pile_set_name": "Github" }
/** * Copyright 1993-2013 NVIDIA Corporation. All rights reserved. * * Please refer to the NVIDIA end user license agreement (EULA) associated * with this source code for terms and conditions that govern your use of * this software. Any use, reproduction, disclosure, or distribution of * this software and related documentation outside the terms of the EULA * is strictly prohibited. * */ // Helper functions for CUDA Driver API error handling (make sure that CUDA_H is included in your projects) #ifndef HELPER_CUDA_DRVAPI_H #define HELPER_CUDA_DRVAPI_H #include <stdlib.h> #include <stdio.h> #include <string.h> #include <helper_string.h> #include <drvapi_error_string.h> #ifndef MAX #define MAX(a,b) (a > b ? a : b) #endif #ifndef EXIT_WAIVED #define EXIT_WAIVED 2 #endif //////////////////////////////////////////////////////////////////////////////// // These are CUDA Helper functions // add a level of protection to the CUDA SDK samples, let's force samples to explicitly include CUDA.H #ifdef __cuda_cuda_h__ // This will output the proper CUDA error strings in the event that a CUDA host call returns an error #ifndef checkCudaErrors #define checkCudaErrors(err) __checkCudaErrors (err, __FILE__, __LINE__) // These are the inline versions for all of the SDK helper functions inline void __checkCudaErrors(CUresult err, const char *file, const int line) { if (CUDA_SUCCESS != err) { fprintf(stderr, "checkCudaErrors() Driver API error = %04d \"%s\" from file <%s>, line %i.\n", err, getCudaDrvErrorString(err), file, line); exit(EXIT_FAILURE); } } #endif #ifdef getLastCudaDrvErrorMsg #undef getLastCudaDrvErrorMsg #endif #define getLastCudaDrvErrorMsg(msg) __getLastCudaDrvErrorMsg (msg, __FILE__, __LINE__) inline void __getLastCudaDrvErrorMsg(const char *msg, const char *file, const int line) { CUresult err = cuCtxSynchronize(); if (CUDA_SUCCESS != err) { fprintf(stderr, "getLastCudaDrvErrorMsg -> %s", msg); fprintf(stderr, "getLastCudaDrvErrorMsg -> cuCtxSynchronize API error = %04d \"%s\" in file <%s>, line %i.\n", err, getCudaDrvErrorString(err), file, line); exit(EXIT_FAILURE); } } // This function wraps the CUDA Driver API into a template function template <class T> inline void getCudaAttribute(T *attribute, CUdevice_attribute device_attribute, int device) { CUresult error_result = cuDeviceGetAttribute(attribute, device_attribute, device); if (error_result != CUDA_SUCCESS) { printf("cuDeviceGetAttribute returned %d\n-> %s\n", (int)error_result, getCudaDrvErrorString(error_result)); exit(EXIT_SUCCESS); } } #endif // Beginning of GPU Architecture definitions inline int _ConvertSMVer2CoresDRV(int major, int minor) { // Defines for GPU Architecture types (using the SM version to determine the # of cores per SM typedef struct { int SM; // 0xMm (hexidecimal notation), M = SM Major version, and m = SM minor version int Cores; } sSMtoCores; sSMtoCores nGpuArchCoresPerSM[] = { { 0x10, 8 }, // Tesla Generation (SM 1.0) G80 class { 0x11, 8 }, // Tesla Generation (SM 1.1) G8x class { 0x12, 8 }, // Tesla Generation (SM 1.2) G9x class { 0x13, 8 }, // Tesla Generation (SM 1.3) GT200 class { 0x20, 32 }, // Fermi Generation (SM 2.0) GF100 class { 0x21, 48 }, // Fermi Generation (SM 2.1) GF10x class { 0x30, 192}, // Kepler Generation (SM 3.0) GK10x class { 0x35, 192}, // Kepler Generation (SM 3.5) GK11x class { -1, -1 } }; int index = 0; while (nGpuArchCoresPerSM[index].SM != -1) { if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor)) { return nGpuArchCoresPerSM[index].Cores; } index++; } // If we don't find the values, we default use the previous one to run properly printf("MapSMtoCores for SM %d.%d is undefined. Default to use %d Cores/SM\n", major, minor, nGpuArchCoresPerSM[7].Cores); return nGpuArchCoresPerSM[7].Cores; } // end of GPU Architecture definitions #ifdef __cuda_cuda_h__ // General GPU Device CUDA Initialization inline int gpuDeviceInitDRV(int ARGC, const char **ARGV) { int cuDevice = 0; int deviceCount = 0; CUresult err = cuInit(0); if (CUDA_SUCCESS == err) { checkCudaErrors(cuDeviceGetCount(&deviceCount)); } if (deviceCount == 0) { fprintf(stderr, "cudaDeviceInit error: no devices supporting CUDA\n"); exit(EXIT_FAILURE); } int dev = 0; dev = getCmdLineArgumentInt(ARGC, (const char **) ARGV, "device="); if (dev < 0) { dev = 0; } if (dev > deviceCount-1) { fprintf(stderr, "\n"); fprintf(stderr, ">> %d CUDA capable GPU device(s) detected. <<\n", deviceCount); fprintf(stderr, ">> cudaDeviceInit (-device=%d) is not a valid GPU device. <<\n", dev); fprintf(stderr, "\n"); return -dev; } checkCudaErrors(cuDeviceGet(&cuDevice, dev)); char name[100]; cuDeviceGetName(name, 100, cuDevice); int computeMode; getCudaAttribute<int>(&computeMode, CU_DEVICE_ATTRIBUTE_COMPUTE_MODE, dev); if (computeMode == CU_COMPUTEMODE_PROHIBITED) { fprintf(stderr, "Error: device is running in <CU_COMPUTEMODE_PROHIBITED>, no threads can use this CUDA Device.\n"); return -1; } if (checkCmdLineFlag(ARGC, (const char **) ARGV, "quiet") == false) { printf("gpuDeviceInitDRV() Using CUDA Device [%d]: %s\n", dev, name); } return dev; } // This function returns the best GPU based on performance inline int gpuGetMaxGflopsDeviceIdDRV() { CUdevice current_device = 0, max_perf_device = 0; int device_count = 0, sm_per_multiproc = 0; int max_compute_perf = 0, best_SM_arch = 0; int major = 0, minor = 0 , multiProcessorCount, clockRate; cuInit(0); checkCudaErrors(cuDeviceGetCount(&device_count)); if (device_count == 0) { fprintf(stderr, "gpuGetMaxGflopsDeviceIdDRV error: no devices supporting CUDA\n"); exit(EXIT_FAILURE); } // Find the best major SM Architecture GPU device while (current_device < device_count) { checkCudaErrors(cuDeviceComputeCapability(&major, &minor, current_device)); if (major > 0 && major < 9999) { best_SM_arch = MAX(best_SM_arch, major); } current_device++; } // Find the best CUDA capable GPU device current_device = 0; while (current_device < device_count) { checkCudaErrors(cuDeviceGetAttribute(&multiProcessorCount, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, current_device)); checkCudaErrors(cuDeviceGetAttribute(&clockRate, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, current_device)); checkCudaErrors(cuDeviceComputeCapability(&major, &minor, current_device)); int computeMode; getCudaAttribute<int>(&computeMode, CU_DEVICE_ATTRIBUTE_COMPUTE_MODE, current_device); if (computeMode != CU_COMPUTEMODE_PROHIBITED) { if (major == 9999 && minor == 9999) { sm_per_multiproc = 1; } else { sm_per_multiproc = _ConvertSMVer2CoresDRV(major, minor); } int compute_perf = multiProcessorCount * sm_per_multiproc * clockRate; if (compute_perf > max_compute_perf) { // If we find GPU with SM major > 2, search only these if (best_SM_arch > 2) { // If our device==dest_SM_arch, choose this, or else pass if (major == best_SM_arch) { max_compute_perf = compute_perf; max_perf_device = current_device; } } else { max_compute_perf = compute_perf; max_perf_device = current_device; } } } ++current_device; } return max_perf_device; } // This function returns the best Graphics GPU based on performance inline int gpuGetMaxGflopsGLDeviceIdDRV() { CUdevice current_device = 0, max_perf_device = 0; int device_count = 0, sm_per_multiproc = 0; int max_compute_perf = 0, best_SM_arch = 0; int major = 0, minor = 0, multiProcessorCount, clockRate; int bTCC = 0; char deviceName[256]; cuInit(0); checkCudaErrors(cuDeviceGetCount(&device_count)); if (device_count == 0) { fprintf(stderr, "gpuGetMaxGflopsGLDeviceIdDRV error: no devices supporting CUDA\n"); exit(EXIT_FAILURE); } // Find the best major SM Architecture GPU device that are graphics devices while (current_device < device_count) { checkCudaErrors(cuDeviceGetName(deviceName, 256, current_device)); checkCudaErrors(cuDeviceComputeCapability(&major, &minor, current_device)); #if CUDA_VERSION >= 3020 checkCudaErrors(cuDeviceGetAttribute(&bTCC, CU_DEVICE_ATTRIBUTE_TCC_DRIVER, current_device)); #else // Assume a Tesla GPU is running in TCC if we are running CUDA 3.1 if (deviceName[0] == 'T') { bTCC = 1; } #endif int computeMode; getCudaAttribute<int>(&computeMode, CU_DEVICE_ATTRIBUTE_COMPUTE_MODE, current_device); if (computeMode != CU_COMPUTEMODE_PROHIBITED) { if (!bTCC) { if (major > 0 && major < 9999) { best_SM_arch = MAX(best_SM_arch, major); } } } current_device++; } // Find the best CUDA capable GPU device current_device = 0; while (current_device < device_count) { checkCudaErrors(cuDeviceGetAttribute(&multiProcessorCount, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, current_device)); checkCudaErrors(cuDeviceGetAttribute(&clockRate, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, current_device)); checkCudaErrors(cuDeviceComputeCapability(&major, &minor, current_device)); #if CUDA_VERSION >= 3020 checkCudaErrors(cuDeviceGetAttribute(&bTCC, CU_DEVICE_ATTRIBUTE_TCC_DRIVER, current_device)); #else // Assume a Tesla GPU is running in TCC if we are running CUDA 3.1 if (deviceName[0] == 'T') { bTCC = 1; } #endif int computeMode; getCudaAttribute<int>(&computeMode, CU_DEVICE_ATTRIBUTE_COMPUTE_MODE, current_device); if (computeMode != CU_COMPUTEMODE_PROHIBITED) { if (major == 9999 && minor == 9999) { sm_per_multiproc = 1; } else { sm_per_multiproc = _ConvertSMVer2CoresDRV(major, minor); } // If this is a Tesla based GPU and SM 2.0, and TCC is disabled, this is a contendor if (!bTCC) // Is this GPU running the TCC driver? If so we pass on this { int compute_perf = multiProcessorCount * sm_per_multiproc * clockRate; if (compute_perf > max_compute_perf) { // If we find GPU with SM major > 2, search only these if (best_SM_arch > 2) { // If our device = dest_SM_arch, then we pick this one if (major == best_SM_arch) { max_compute_perf = compute_perf; max_perf_device = current_device; } } else { max_compute_perf = compute_perf; max_perf_device = current_device; } } } } ++current_device; } return max_perf_device; } // General initialization call to pick the best CUDA Device inline CUdevice findCudaDeviceDRV(int argc, const char **argv) { CUdevice cuDevice; int devID = 0; // If the command-line has a device number specified, use it if (checkCmdLineFlag(argc, (const char **)argv, "device")) { devID = gpuDeviceInitDRV(argc, argv); if (devID < 0) { printf("exiting...\n"); exit(EXIT_SUCCESS); } } else { // Otherwise pick the device with highest Gflops/s char name[100]; devID = gpuGetMaxGflopsDeviceIdDRV(); checkCudaErrors(cuDeviceGet(&cuDevice, devID)); cuDeviceGetName(name, 100, cuDevice); printf("> Using CUDA Device [%d]: %s\n", devID, name); } cuDeviceGet(&cuDevice, devID); return cuDevice; } // This function will pick the best CUDA device available with OpenGL interop inline CUdevice findCudaGLDeviceDRV(int argc, const char **argv) { CUdevice cuDevice; int devID = 0; // If the command-line has a device number specified, use it if (checkCmdLineFlag(argc, (const char **)argv, "device")) { devID = gpuDeviceInitDRV(argc, (const char **)argv); if (devID < 0) { printf("no CUDA capable devices found, exiting...\n"); exit(EXIT_SUCCESS); } } else { char name[100]; // Otherwise pick the device with highest Gflops/s devID = gpuGetMaxGflopsGLDeviceIdDRV(); checkCudaErrors(cuDeviceGet(&cuDevice, devID)); cuDeviceGetName(name, 100, cuDevice); printf("> Using CUDA/GL Device [%d]: %s\n", devID, name); } return devID; } // General check for CUDA GPU SM Capabilities inline bool checkCudaCapabilitiesDRV(int major_version, int minor_version, int devID) { CUdevice cuDevice; char name[256]; int major = 0, minor = 0; checkCudaErrors(cuDeviceGet(&cuDevice, devID)); checkCudaErrors(cuDeviceGetName(name, 100, cuDevice)); checkCudaErrors(cuDeviceComputeCapability(&major, &minor, devID)); if ((major > major_version) || (major == major_version && minor >= minor_version)) { printf("> Device %d: <%16s >, Compute SM %d.%d detected\n", devID, name, major, minor); return true; } else { printf("No GPU device was found that can support CUDA compute capability %d.%d.\n", major_version, minor_version); return false; } } #endif // end of CUDA Helper Functions #endif
{ "pile_set_name": "Github" }
--- src/client.c.org Tue Nov 30 13:49:23 2004 +++ src/client.c Wed Dec 1 12:42:01 2004 @@ -144,6 +144,7 @@ static size_t try_read_from_server PROTO ((char *, size_t)); +static void proxy_connect PROTO ((cvsroot_t *, int)); static void auth_server PROTO ((cvsroot_t *, struct buffer *, struct buffer *, int, int, struct hostent *)); @@ -3762,7 +3763,7 @@ int port_number; struct sockaddr_in client_sai; struct hostent *hostinfo; - struct buffer *to_server, *from_server; + struct buffer *local_to_server, *local_from_server; sock = socket (AF_INET, SOCK_STREAM, 0); if (sock == -1) @@ -3770,7 +3771,17 @@ error (1, 0, "cannot create socket: %s", SOCK_STRERROR (SOCK_ERRNO)); } port_number = get_cvs_port_number (root); + + /* if we have a proxy connect to that instead */ + if(root->proxy) + { + hostinfo = init_sockaddr (&client_sai, root->proxy, root->proxy_port); + } + else + { hostinfo = init_sockaddr (&client_sai, root->hostname, port_number); + } + if (trace) { fprintf (stderr, " -> Connecting to %s(%s):%d\n", @@ -3780,29 +3791,41 @@ if (connect (sock, (struct sockaddr *) &client_sai, sizeof (client_sai)) < 0) error (1, 0, "connect to %s(%s):%d failed: %s", - root->hostname, + root->proxy ? root->proxy : root->hostname, inet_ntoa (client_sai.sin_addr), - port_number, SOCK_STRERROR (SOCK_ERRNO)); + root->proxy ? root->proxy_port : port_number, + SOCK_STRERROR (SOCK_ERRNO)); - make_bufs_from_fds (sock, sock, 0, &to_server, &from_server, 1); + make_bufs_from_fds (sock, sock, 0, &local_to_server, &local_from_server, 1); - auth_server (root, to_server, from_server, verify_only, do_gssapi, hostinfo); + if(root->proxy) + { + // REALLY ugly hack to allow proxy_connect() to use send_to_server(). + // The proper fix would be to remove the global to_server & from_server + // variables, and instead let send_to_server() etc. take the target + // server struct as a paramter. + to_server = local_to_server; + from_server = local_from_server; + proxy_connect (root, port_number); + } + + auth_server (root, local_to_server, local_from_server, verify_only, do_gssapi, hostinfo); if (verify_only) { int status; - status = buf_shutdown (to_server); + status = buf_shutdown (local_to_server); if (status != 0) error (0, status, "shutting down buffer to server"); - buf_free (to_server); - to_server = NULL; + buf_free (local_to_server); + local_to_server = NULL; - status = buf_shutdown (from_server); + status = buf_shutdown (local_from_server); if (status != 0) error (0, status, "shutting down buffer from server"); - buf_free (from_server); - from_server = NULL; + buf_free (local_from_server); + local_from_server = NULL; /* Don't need to set server_started = 0 since we don't set it to 1 * until returning from this call. @@ -3810,11 +3833,53 @@ } else { - *to_server_p = to_server; - *from_server_p = from_server; + *to_server_p = local_to_server; + *from_server_p = local_from_server; } return; +} + + + +static void +proxy_connect (root, port_number) + cvsroot_t *root; + int port_number; +{ +#define CONNECT_STRING "CONNECT %s:%d HTTP/1.0\r\n\r\n" + /* Send a "CONNECT" command to proxy: */ + char* read_buf; + int codenum, count; + + /* 4 characters for port covered by the length of %s & %d */ + char* write_buf = xmalloc (strlen (CONNECT_STRING) + strlen (root->hostname +) + 20 + 1); + int len = sprintf (write_buf, CONNECT_STRING, root->hostname, port_number); + + send_to_server (write_buf, len); + + /* Wait for HTTP status code, bail out if you don't get back a 2xx code.*/ + count = read_line (&read_buf); + sscanf (read_buf, "%s %d", write_buf, &codenum); + + if ((codenum / 100) != 2) + error (1, 0, "proxy server %s:%d does not support http tunnelling", + root->proxy, root->proxy_port); + free (read_buf); + free (write_buf); + + /* Skip through remaining part of MIME header, recv_line + consumes the trailing \n */ + while(read_line (&read_buf) > 0) + { + if (read_buf[0] == '\r' || read_buf[0] == 0) + { + free (read_buf); + break; + } + free (read_buf); + } } --- src/client.h.org Wed Dec 1 07:36:43 2004 +++ src/client.h Wed Dec 1 07:38:06 2004 @@ -69,6 +69,9 @@ # ifndef CVS_AUTH_PORT # define CVS_AUTH_PORT 2401 # endif /* CVS_AUTH_PORT */ +# ifndef CVS_PROXY_PORT +# define CVS_PROXY_PORT 80 +# endif /* CVS_PROXY_PORT */ # endif /* (AUTH_CLIENT_SUPPORT) || defined (HAVE_GSSAPI) */ # if HAVE_KERBEROS --- src/root.c.org Wed Dec 1 07:38:19 2004 +++ src/root.c Wed Dec 1 07:48:43 2004 @@ -303,6 +303,8 @@ newroot->proxy_port = 0; newroot->isremote = 0; #endif /* CLIENT_SUPPORT */ + newroot->proxy = NULL; + newroot->proxy_port = CVS_PROXY_PORT; return newroot; } @@ -332,6 +334,8 @@ if (root->proxy_hostname != NULL) free (root->proxy_hostname); #endif /* CLIENT_SUPPORT */ + if (root->proxy != NULL) + free (root->proxy); free (root); } @@ -375,6 +379,7 @@ #ifdef CLIENT_SUPPORT int check_hostname, no_port, no_password; #endif /* CLIENT_SUPPORT */ + const char *env_var; /* allocate some space */ newroot = new_cvsroot_t(); @@ -555,6 +560,29 @@ /* restore the '/' */ cvsroot_copy = firstslash; *cvsroot_copy = '/'; + + + /* Determine proxy */ + env_var = getenv("CVS_PROXY"); + if (!env_var) + env_var = getenv("HTTP_PROXY"); + /* Check if a proxy was specified, and if it is a HTTP proxy */ + if (env_var && !memcmp(env_var, "http://", 7)) + { + char *port_str; + + /* Try to parse the proxy data */ + env_var += 7; + /* TODO - parse username/password data, too */ + port_str = strchr(env_var, ':'); + if (port_str) + { + *port_str++ = 0; + newroot->proxy_port = atoi(port_str); + } + newroot->proxy = xstrdup(env_var); + } + #endif /* CLIENT_SUPPORT */ } --- src/root.h.org Wed Dec 1 07:48:49 2004 +++ src/root.h Wed Dec 1 12:26:12 2004 @@ -39,4 +39,5 @@ int proxy_port; /* The port of the proxy or zero, as above. */ unsigned char isremote; /* Nonzero if we are doing remote access. */ #endif /* CLIENT_SUPPORT */ + char *proxy; } cvsroot_t;
{ "pile_set_name": "Github" }
/* * Broadcom UniMAC MDIO bus controller driver * * Copyright (C) 2014-2017 Broadcom * * 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 <linux/kernel.h> #include <linux/phy.h> #include <linux/platform_device.h> #include <linux/sched.h> #include <linux/module.h> #include <linux/io.h> #include <linux/delay.h> #include <linux/of.h> #include <linux/of_platform.h> #include <linux/of_mdio.h> #include <linux/platform_data/mdio-bcm-unimac.h> #define MDIO_CMD 0x00 #define MDIO_START_BUSY (1 << 29) #define MDIO_READ_FAIL (1 << 28) #define MDIO_RD (2 << 26) #define MDIO_WR (1 << 26) #define MDIO_PMD_SHIFT 21 #define MDIO_PMD_MASK 0x1F #define MDIO_REG_SHIFT 16 #define MDIO_REG_MASK 0x1F #define MDIO_CFG 0x04 #define MDIO_C22 (1 << 0) #define MDIO_C45 0 #define MDIO_CLK_DIV_SHIFT 4 #define MDIO_CLK_DIV_MASK 0x3F #define MDIO_SUPP_PREAMBLE (1 << 12) struct unimac_mdio_priv { struct mii_bus *mii_bus; void __iomem *base; int (*wait_func) (void *wait_func_data); void *wait_func_data; }; static inline u32 unimac_mdio_readl(struct unimac_mdio_priv *priv, u32 offset) { /* MIPS chips strapped for BE will automagically configure the * peripheral registers for CPU-native byte order. */ if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) return __raw_readl(priv->base + offset); else return readl_relaxed(priv->base + offset); } static inline void unimac_mdio_writel(struct unimac_mdio_priv *priv, u32 val, u32 offset) { if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) __raw_writel(val, priv->base + offset); else writel_relaxed(val, priv->base + offset); } static inline void unimac_mdio_start(struct unimac_mdio_priv *priv) { u32 reg; reg = unimac_mdio_readl(priv, MDIO_CMD); reg |= MDIO_START_BUSY; unimac_mdio_writel(priv, reg, MDIO_CMD); } static inline unsigned int unimac_mdio_busy(struct unimac_mdio_priv *priv) { return unimac_mdio_readl(priv, MDIO_CMD) & MDIO_START_BUSY; } static int unimac_mdio_poll(void *wait_func_data) { struct unimac_mdio_priv *priv = wait_func_data; unsigned int timeout = 1000; do { if (!unimac_mdio_busy(priv)) return 0; usleep_range(1000, 2000); } while (--timeout); if (!timeout) return -ETIMEDOUT; return 0; } static int unimac_mdio_read(struct mii_bus *bus, int phy_id, int reg) { struct unimac_mdio_priv *priv = bus->priv; int ret; u32 cmd; /* Prepare the read operation */ cmd = MDIO_RD | (phy_id << MDIO_PMD_SHIFT) | (reg << MDIO_REG_SHIFT); unimac_mdio_writel(priv, cmd, MDIO_CMD); /* Start MDIO transaction */ unimac_mdio_start(priv); ret = priv->wait_func(priv->wait_func_data); if (ret) return ret; cmd = unimac_mdio_readl(priv, MDIO_CMD); /* Some broken devices are known not to release the line during * turn-around, e.g: Broadcom BCM53125 external switches, so check for * that condition here and ignore the MDIO controller read failure * indication. */ if (!(bus->phy_ignore_ta_mask & 1 << phy_id) && (cmd & MDIO_READ_FAIL)) return -EIO; return cmd & 0xffff; } static int unimac_mdio_write(struct mii_bus *bus, int phy_id, int reg, u16 val) { struct unimac_mdio_priv *priv = bus->priv; u32 cmd; /* Prepare the write operation */ cmd = MDIO_WR | (phy_id << MDIO_PMD_SHIFT) | (reg << MDIO_REG_SHIFT) | (0xffff & val); unimac_mdio_writel(priv, cmd, MDIO_CMD); unimac_mdio_start(priv); return priv->wait_func(priv->wait_func_data); } /* Workaround for integrated BCM7xxx Gigabit PHYs which have a problem with * their internal MDIO management controller making them fail to successfully * be read from or written to for the first transaction. We insert a dummy * BMSR read here to make sure that phy_get_device() and get_phy_id() can * correctly read the PHY MII_PHYSID1/2 registers and successfully register a * PHY device for this peripheral. * * Once the PHY driver is registered, we can workaround subsequent reads from * there (e.g: during system-wide power management). * * bus->reset is invoked before mdiobus_scan during mdiobus_register and is * therefore the right location to stick that workaround. Since we do not want * to read from non-existing PHYs, we either use bus->phy_mask or do a manual * Device Tree scan to limit the search area. */ static int unimac_mdio_reset(struct mii_bus *bus) { struct device_node *np = bus->dev.of_node; struct device_node *child; u32 read_mask = 0; int addr; if (!np) { read_mask = ~bus->phy_mask; } else { for_each_available_child_of_node(np, child) { addr = of_mdio_parse_addr(&bus->dev, child); if (addr < 0) continue; read_mask |= 1 << addr; } } for (addr = 0; addr < PHY_MAX_ADDR; addr++) { if (read_mask & 1 << addr) { dev_dbg(&bus->dev, "Workaround for PHY @ %d\n", addr); mdiobus_read(bus, addr, MII_BMSR); } } return 0; } static int unimac_mdio_probe(struct platform_device *pdev) { struct unimac_mdio_pdata *pdata = pdev->dev.platform_data; struct unimac_mdio_priv *priv; struct device_node *np; struct mii_bus *bus; struct resource *r; int ret; np = pdev->dev.of_node; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; r = platform_get_resource(pdev, IORESOURCE_MEM, 0); /* Just ioremap, as this MDIO block is usually integrated into an * Ethernet MAC controller register range */ priv->base = devm_ioremap(&pdev->dev, r->start, resource_size(r)); if (!priv->base) { dev_err(&pdev->dev, "failed to remap register\n"); return -ENOMEM; } priv->mii_bus = mdiobus_alloc(); if (!priv->mii_bus) return -ENOMEM; bus = priv->mii_bus; bus->priv = priv; if (pdata) { bus->name = pdata->bus_name; priv->wait_func = pdata->wait_func; priv->wait_func_data = pdata->wait_func_data; bus->phy_mask = ~pdata->phy_mask; } else { bus->name = "unimac MII bus"; priv->wait_func_data = priv; priv->wait_func = unimac_mdio_poll; } bus->parent = &pdev->dev; bus->read = unimac_mdio_read; bus->write = unimac_mdio_write; bus->reset = unimac_mdio_reset; snprintf(bus->id, MII_BUS_ID_SIZE, "%s-%d", pdev->name, pdev->id); ret = of_mdiobus_register(bus, np); if (ret) { dev_err(&pdev->dev, "MDIO bus registration failed\n"); goto out_mdio_free; } platform_set_drvdata(pdev, priv); dev_info(&pdev->dev, "Broadcom UniMAC MDIO bus at 0x%p\n", priv->base); return 0; out_mdio_free: mdiobus_free(bus); return ret; } static int unimac_mdio_remove(struct platform_device *pdev) { struct unimac_mdio_priv *priv = platform_get_drvdata(pdev); mdiobus_unregister(priv->mii_bus); mdiobus_free(priv->mii_bus); return 0; } static const struct of_device_id unimac_mdio_ids[] = { { .compatible = "brcm,genet-mdio-v5", }, { .compatible = "brcm,genet-mdio-v4", }, { .compatible = "brcm,genet-mdio-v3", }, { .compatible = "brcm,genet-mdio-v2", }, { .compatible = "brcm,genet-mdio-v1", }, { .compatible = "brcm,unimac-mdio", }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, unimac_mdio_ids); static struct platform_driver unimac_mdio_driver = { .driver = { .name = UNIMAC_MDIO_DRV_NAME, .of_match_table = unimac_mdio_ids, }, .probe = unimac_mdio_probe, .remove = unimac_mdio_remove, }; module_platform_driver(unimac_mdio_driver); MODULE_AUTHOR("Broadcom Corporation"); MODULE_DESCRIPTION("Broadcom UniMAC MDIO bus controller"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:" UNIMAC_MDIO_DRV_NAME);
{ "pile_set_name": "Github" }
/* * This program 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. * * 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 Lesser General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) */ #include "evolution-config.h" #include "e-composer-spell-header.h" G_DEFINE_TYPE ( EComposerSpellHeader, e_composer_spell_header, E_TYPE_COMPOSER_TEXT_HEADER) static void e_composer_spell_header_class_init (EComposerSpellHeaderClass *class) { EComposerTextHeaderClass *composer_text_header_class; composer_text_header_class = E_COMPOSER_TEXT_HEADER_CLASS (class); composer_text_header_class->entry_type = E_TYPE_SPELL_ENTRY; } static void e_composer_spell_header_init (EComposerSpellHeader *header) { } EComposerHeader * e_composer_spell_header_new_label (ESourceRegistry *registry, const gchar *label) { g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL); return g_object_new ( E_TYPE_COMPOSER_SPELL_HEADER, "label", label, "button", FALSE, "registry", registry, NULL); } EComposerHeader * e_composer_spell_header_new_button (ESourceRegistry *registry, const gchar *label) { g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL); return g_object_new ( E_TYPE_COMPOSER_SPELL_HEADER, "label", label, "button", TRUE, "registry", registry, NULL); }
{ "pile_set_name": "Github" }
--- a/sockd/sockd_io.c.old 2017-05-10 19:57:20.672000000 +0000 +++ b/sockd/sockd_io.c 2017-05-10 20:00:34.548000000 +0000 @@ -2912,7 +2912,7 @@ siginfo(sig, si, sc) int src_so_rcvbuf, dst_so_rcvbuf; #endif /* HAVE_RECVBUF_IOCTL */ -#if HAVE_SENDBUF_IOCTL +#ifdef HAVE_SENDBUF_IOCTL int src_so_sndbuf, dst_so_sndbuf; #endif /* HAVE_SENDBUF_IOCTL */ @@ -2960,7 +2960,7 @@ siginfo(sig, si, sc) *src_bufferinfo = NUL; *dst_bufferinfo = NUL; -#if HAVE_RECVBUF_IOCTL || HAVE_SENDBUF_IOCTL +#if defined(HAVE_RECVBUF_IOCTL) || defined(HAVE_SENDBUF_IOCTL) havesocketinfo = 1; @@ -2987,7 +2987,7 @@ siginfo(sig, si, sc) } #endif /* HAVE_RECVBUF_IOCTL */ -#if HAVE_SENDBUF_IOCTL +#ifdef HAVE_SENDBUF_IOCTL if (havesocketinfo) { if (ioctl(src->s, SENDBUF_IOCTLVAL, &src_so_sndbuf) != 0) { swarn("%s: sendbuf size ioctl() on src-fd %d failed", @@ -3005,7 +3005,7 @@ siginfo(sig, si, sc) } #endif /* HAVE_SENDBUF_IOCTL */ -#if HAVE_SENDBUF_IOCTL && HAVE_RECVBUF_IOCTL +#ifdef HAVE_SENDBUF_IOCTL && HAVE_RECVBUF_IOCTL if (havesocketinfo) { snprintf(src_bufferinfo, sizeof(src_bufferinfo), "%lu buffered (%lu + %lu + %lu)",
{ "pile_set_name": "Github" }
/* Copyright 2006-2015 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * See http://www.boost.org/libs/flyweight for library home page. */ #ifndef BOOST_FLYWEIGHT_SERIALIZE_HPP #define BOOST_FLYWEIGHT_SERIALIZE_HPP #if defined(_MSC_VER)&&(_MSC_VER>=1200) #pragma once #endif #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ #include <boost/flyweight/flyweight_fwd.hpp> #include <boost/flyweight/detail/archive_constructed.hpp> #include <boost/flyweight/detail/serialization_helper.hpp> #include <boost/serialization/nvp.hpp> #include <boost/serialization/split_free.hpp> #include <boost/throw_exception.hpp> #include <memory> /* Serialization routines for flyweight<T>. */ namespace boost{ namespace serialization{ template< class Archive, typename T,typename Arg1,typename Arg2,typename Arg3 > inline void serialize( Archive& ar,::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3>& f, const unsigned int version) { split_free(ar,f,version); } template< class Archive, typename T,typename Arg1,typename Arg2,typename Arg3 > void save( Archive& ar,const ::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3>& f, const unsigned int /*version*/) { typedef ::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3> flyweight; typedef ::boost::flyweights::detail::save_helper<flyweight> helper; typedef typename helper::size_type size_type; helper& hlp=ar.template get_helper<helper>(); size_type n=hlp.find(f); ar<<make_nvp("item",n); if(n==hlp.size()){ ar<<make_nvp("key",f.get_key()); hlp.push_back(f); } } template< class Archive, typename T,typename Arg1,typename Arg2,typename Arg3 > void load( Archive& ar,::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3>& f, const unsigned int version) { typedef ::boost::flyweights::flyweight<T,Arg1,Arg2,Arg3> flyweight; typedef typename flyweight::key_type key_type; typedef ::boost::flyweights::detail::load_helper<flyweight> helper; typedef typename helper::size_type size_type; helper& hlp=ar.template get_helper<helper>(); size_type n=0; ar>>make_nvp("item",n); if(n>hlp.size()){ throw_exception( archive::archive_exception(archive::archive_exception::other_exception)); } else if(n==hlp.size()){ ::boost::flyweights::detail::archive_constructed<key_type> k( "key",ar,version); hlp.push_back(flyweight(k.get())); } f=hlp[n]; } } /* namespace serialization */ } /* namespace boost */ #endif
{ "pile_set_name": "Github" }
/***** * Tencent is pleased to support the open source community by making QMUI_iOS available. * Copyright (C) 2016-2019 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at * http://opensource.org/licenses/MIT * 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. *****/ // // QMUITableView.m // qmui // // Created by QMUI Team on 14-7-2. // #import "QMUITableView.h" #import "UITableView+QMUI.h" #import "UIView+QMUI.h" @implementation QMUITableView @dynamic delegate; @dynamic dataSource; - (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style { if (self = [super initWithFrame:frame style:style]) { [self didInitialize]; } return self; } - (instancetype)initWithCoder:(NSCoder *)aDecoder { if (self = [super initWithCoder:aDecoder]) { [self didInitialize]; } return self; } - (void)didInitialize { [self qmui_styledAsQMUITableView]; } - (void)dealloc { self.delegate = nil; self.dataSource = nil; } // 保证一直存在tableFooterView,以去掉列表内容不满一屏时尾部的空白分割线 - (void)setTableFooterView:(UIView *)tableFooterView { if (!tableFooterView) { tableFooterView = [[UIView alloc] init]; } [super setTableFooterView:tableFooterView]; } - (BOOL)touchesShouldCancelInContentView:(UIView *)view { if ([self.delegate respondsToSelector:@selector(tableView:touchesShouldCancelInContentView:)]) { return [self.delegate tableView:self touchesShouldCancelInContentView:view]; } // 默认情况下只有当view是非UIControl的时候才会返回yes,这里统一对UIButton也返回yes // 原因是UITableView上面把事件延迟去掉了,但是这样如果拖动的时候手指是在UIControl上面的话,就拖动不了了 if ([view isKindOfClass:[UIControl class]]) { if ([view isKindOfClass:[UIButton class]]) { return YES; } else { return NO; } } return YES; } @end
{ "pile_set_name": "Github" }
/* ___DISCLAIMER___ */ /* clock.c: PLL, CCLK, PCLK controls */ #include <arm/NXP/LPC17xx/LPC17xx.h> #include "config.h" #include "clock.h" #include "bits.h" #include "uart.h" void clock_disconnect() { disconnectPLL0(); disablePLL0(); } void clock_init() { /* set flash access time to 5 clks (80<f<=100MHz) */ setFlashAccessTime(5); /* setup PLL0 for 96MHz First, disable and disconnect PLL0. */ clock_disconnect(); /* PLL is disabled and disconnected. setup PCLK NOW as it cannot be changed reliably with PLL0 connected. see: http://ics.nxp.com/support/documents/microcontrollers/pdf/errata.lpc1754.pdf */ /* continue with PLL0 setup: enable the xtal oscillator and wait for it to become stable set the oscillator as clk source for PLL0 set PLL0 multiplier+predivider enable PLL0 set CCLK divider wait for PLL0 to lock connect PLL0 done */ enableMainOsc(); setClkSrc(CLKSRC_MAINOSC); setPLL0MultPrediv(CONFIG_CLK_MULT, CONFIG_CLK_PREDIV); enablePLL0(); setCCLKDiv(CONFIG_CLK_CCLKDIV); connectPLL0(); /* configure PLL1 for USB operation */ disconnectPLL1(); disablePLL1(); LPC_SC->PLL1CFG = 0x23; enablePLL1(); connectPLL1(); } void setFlashAccessTime(uint8_t clocks) { LPC_SC->FLASHCFG=FLASHTIM(clocks); } void setPLL0MultPrediv(uint16_t mult, uint8_t prediv) { LPC_SC->PLL0CFG=PLL_MULT(mult) | PLL_PREDIV(prediv); PLL0feed(); } void enablePLL0() { LPC_SC->PLL0CON |= PLLE0; PLL0feed(); } void disablePLL0() { LPC_SC->PLL0CON &= ~PLLE0; PLL0feed(); } void connectPLL0() { while(!(LPC_SC->PLL0STAT & PLOCK0)); LPC_SC->PLL0CON |= PLLC0; PLL0feed(); } void disconnectPLL0() { LPC_SC->PLL0CON &= ~PLLC0; PLL0feed(); } void setPLL1MultPrediv(uint16_t mult, uint8_t prediv) { LPC_SC->PLL1CFG=PLL_MULT(mult) | PLL_PREDIV(prediv); PLL1feed(); } void enablePLL1() { LPC_SC->PLL1CON |= PLLE1; PLL1feed(); } void disablePLL1() { LPC_SC->PLL1CON &= ~PLLE1; PLL1feed(); } void connectPLL1() { while(!(LPC_SC->PLL1STAT & PLOCK1)); LPC_SC->PLL1CON |= PLLC1; PLL1feed(); } void disconnectPLL1() { LPC_SC->PLL1CON &= ~PLLC1; PLL1feed(); } void setCCLKDiv(uint8_t div) { LPC_SC->CCLKCFG=CCLK_DIV(div); } void enableMainOsc() { LPC_SC->SCS=OSCEN; while(!(LPC_SC->SCS&OSCSTAT)); } void disableMainOsc() { LPC_SC->SCS=0; } void PLL0feed() { LPC_SC->PLL0FEED=0xaa; LPC_SC->PLL0FEED=0x55; } void PLL1feed() { LPC_SC->PLL1FEED=0xaa; LPC_SC->PLL1FEED=0x55; } void setClkSrc(uint8_t src) { LPC_SC->CLKSRCSEL=src; }
{ "pile_set_name": "Github" }
#ifndef _NRF_DELAY_H #define _NRF_DELAY_H // #include "nrf.h" /*lint --e{438, 522} "Variable not used" "Function lacks side-effects" */ #if defined ( __CC_ARM ) static __ASM void __INLINE nrf_delay_us(uint32_t volatile number_of_us) { loop SUBS R0, R0, #1 NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP BNE loop BX LR } #elif defined ( __ICCARM__ ) static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) { __ASM ( "loop:\n\t" " SUBS R0, R0, #1\n\t" " NOP\n\t" " NOP\n\t" " NOP\n\t" " NOP\n\t" " NOP\n\t" " NOP\n\t" " NOP\n\t" " NOP\n\t" " NOP\n\t" " NOP\n\t" " NOP\n\t" " NOP\n\t" " BNE loop\n\t"); } #elif defined ( __GNUC__ ) __INLINE static void nrf_delay_us(uint32_t volatile number_of_us) { do { __ASM volatile ( "NOP\n\t" "NOP\n\t" "NOP\n\t" "NOP\n\t" "NOP\n\t" "NOP\n\t" "NOP\n\t" "NOP\n\t" "NOP\n\t" "NOP\n\t" "NOP\n\t" "NOP\n\t" "NOP\n\t" "NOP\n\t" ); } while (--number_of_us); } #endif void nrf_delay_ms(uint32_t volatile number_of_ms); #endif
{ "pile_set_name": "Github" }
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com> // This file is subject to the license terms in the LICENSE file // found in the top-level directory of this distribution. #include <cppast/cpp_template_parameter.hpp> #include <cppast/cpp_entity_kind.hpp> using namespace cppast; const char* cppast::to_string(cpp_template_keyword kw) noexcept { switch (kw) { case cpp_template_keyword::keyword_class: return "class"; case cpp_template_keyword::keyword_typename: return "typename"; } return "should not get here"; } std::unique_ptr<cpp_template_type_parameter> cpp_template_type_parameter::build( const cpp_entity_index& idx, cpp_entity_id id, std::string name, cpp_template_keyword kw, bool variadic, std::unique_ptr<cpp_type> default_type) { std::unique_ptr<cpp_template_type_parameter> result( new cpp_template_type_parameter(std::move(name), kw, variadic, std::move(default_type))); idx.register_definition(std::move(id), type_safe::cref(*result)); return result; } cpp_entity_kind cpp_template_type_parameter::kind() noexcept { return cpp_entity_kind::template_type_parameter_t; } cpp_entity_kind cpp_template_type_parameter::do_get_entity_kind() const noexcept { return kind(); } bool detail::cpp_template_parameter_ref_predicate::operator()(const cpp_entity& e) { return e.kind() == cpp_entity_kind::template_type_parameter_t; } std::unique_ptr<cpp_non_type_template_parameter> cpp_non_type_template_parameter::build( const cpp_entity_index& idx, cpp_entity_id id, std::string name, std::unique_ptr<cpp_type> type, bool is_variadic, std::unique_ptr<cpp_expression> default_value) { std::unique_ptr<cpp_non_type_template_parameter> result( new cpp_non_type_template_parameter(std::move(name), std::move(type), is_variadic, std::move(default_value))); idx.register_definition(std::move(id), type_safe::cref(*result)); return result; } cpp_entity_kind cpp_non_type_template_parameter::kind() noexcept { return cpp_entity_kind::non_type_template_parameter_t; } cpp_entity_kind cpp_non_type_template_parameter::do_get_entity_kind() const noexcept { return kind(); } bool detail::cpp_template_ref_predicate::operator()(const cpp_entity& e) { return is_template(e.kind()) || e.kind() == cpp_entity_kind::template_template_parameter_t; } cpp_entity_kind cpp_template_template_parameter::kind() noexcept { return cpp_entity_kind::template_template_parameter_t; } cpp_entity_kind cpp_template_template_parameter::do_get_entity_kind() const noexcept { return kind(); }
{ "pile_set_name": "Github" }
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Oct 15 2018 10:31:50). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import <AddressBookCore/ABCNPropertyDescription.h> #import <AddressBookCore/ABCNAbstractPropertyDescription-Protocol.h> @class NSString; @interface ABCNIdentifierDescription : ABCNPropertyDescription <ABCNAbstractPropertyDescription> { } - (void)decodeUsingCoder:(id)arg1 contact:(id)arg2; - (void)encodeUsingCoder:(id)arg1 contact:(id)arg2; - (void)copyFromContact:(id)arg1 to:(id)arg2; - (BOOL)isEqualForContact:(id)arg1 other:(id)arg2; - (id)init; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end
{ "pile_set_name": "Github" }
#include <rose.h> class SgVarSubstCopy : public SgCopyHelp { SgVariableSymbol *sourceSymbol; SgExpression *replacementExpression; public: SgVarSubstCopy(SgVariableSymbol *sourceSymbol, SgExpression *replacementExpression) : sourceSymbol(sourceSymbol), replacementExpression(replacementExpression) {} SgNode *copyAst(const SgNode *n) { if (const SgVarRefExp *vr = isSgVarRefExp(const_cast<SgNode *>(n))) { if (vr->get_symbol() == sourceSymbol) { return replacementExpression->copy(*this); } } return n->copy(*this); } }; #define SgNULL_FILE Sg_File_Info::generateDefaultFileInfoForTransformationNode() int main(int argc, char **argv) { // Initialize and check compatibility. See Rose::initialize ROSE_INITIALIZE; // Build the AST used by ROSE SgProject *project = frontend(argc, argv); // Find the exampleFunction function SgGlobal *global = project->get_file(0).get_globalScope(); SgFunctionSymbol *exampleFunctionSym = global->lookup_function_symbol("exampleFunction"); ROSE_ASSERT(exampleFunctionSym != NULL); SgFunctionDeclaration *exampleFunctionDecl = exampleFunctionSym->get_declaration(); ROSE_ASSERT(exampleFunctionDecl != NULL); SgFunctionDefinition *exampleFunctionDef = exampleFunctionDecl->get_definition(); ROSE_ASSERT(exampleFunctionDef != NULL); // Find its first parameter SgInitializedName *firstParamName = exampleFunctionDecl->get_args().front(); ROSE_ASSERT(firstParamName != NULL); SgVariableSymbol *firstParamSym = exampleFunctionDef->lookup_var_symbol(firstParamName->get_name()); ROSE_ASSERT(firstParamSym != NULL); // Construct the expression to substitute for SgIntVal *twenty = new SgIntVal(SgNULL_FILE, 20); // Create our copy help mechanism with the required parameters SgVarSubstCopy ourCopyHelp(firstParamSym, twenty); // Do the copy SgNode *exampleFunctionDeclCopyNode = exampleFunctionDecl->copy(ourCopyHelp); ROSE_ASSERT(exampleFunctionDeclCopyNode != NULL); SgFunctionDeclaration *exampleFunctionDeclCopy = isSgFunctionDeclaration(exampleFunctionDeclCopyNode); ROSE_ASSERT(exampleFunctionDeclCopy != NULL); // Change the name of the new function exampleFunctionDeclCopy->set_name("exampleFunction20"); global->get_symbol_table()->insert(exampleFunctionDeclCopy->get_name(), new SgFunctionSymbol(exampleFunctionDeclCopy)); // Add function to global scope global->append_declaration(exampleFunctionDeclCopy); // Generate source code from AST and call the vendor's compiler return backend(project); }
{ "pile_set_name": "Github" }
Description: Compute MD4 checksum. Files: lib/md4.h lib/md4.c m4/md4.m4 Depends-on: byteswap stdalign stdint configure.ac: AC_REQUIRE([AC_C_RESTRICT]) gl_MD4 Makefile.am: lib_SOURCES += md4.c Include: "md4.h" License: LGPLv2+ Maintainer: Simon Josefsson
{ "pile_set_name": "Github" }
# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_enclave_library(oehostfs STATIC hostfs.c) maybe_build_using_clangw(oehostfs) enclave_include_directories(oehostfs PRIVATE ${CMAKE_BINARY_DIR}/syscall ${PROJECT_SOURCE_DIR}/include/openenclave/corelibc) enclave_enable_code_coverage(oehostfs) enclave_link_libraries(oehostfs PRIVATE oesyscall) install_enclaves( TARGETS oehostfs EXPORT openenclave-targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/openenclave/enclave)
{ "pile_set_name": "Github" }
// // KCSIBeaconTests.m // KCSIBeaconTests // // Copyright 2015 Kinvey, Inc // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #import <XCTest/XCTest.h> #import "KCSBeaconManager.h" @interface KCSIBeaconTests : XCTestCase <KCSBeaconManagerDelegate> @property (nonatomic, strong) NSError* rangingError; @end @implementation KCSIBeaconTests - (void)setUp { [super setUp]; // Put setup code here. This method is called before the invocation of each test method in the class. } - (void)tearDown { // Put teardown code here. This method is called after the invocation of each test method in the class. [super tearDown]; } - (void)testExample { KCSBeaconManager* manager = [[KCSBeaconManager alloc] init]; manager.delegate = self; [manager startMonitoringForRegion:[[NSUUID UUID] UUIDString] identifier:@"com.kinvey.foo"]; while (1) { [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]]; } } - (void) rangingFailedForRegion:(CLBeaconRegion *)region withError:(NSError *)error { self.rangingError = error; } @end
{ "pile_set_name": "Github" }
/* Author: aeroson Description: Sets the text on the dialog Parameters: None Returns: Nothing */ #define AGM_CrewInfo_TextIDC 11123 private["_text", "_ctrl"]; disableSerialization; _text = _this select 0; _ctrl = (uiNamespace getVariable "AGM_CrewInfo_dialog") displayCtrl AGM_CrewInfo_TextIDC; _ctrl ctrlSetStructuredText parseText _text; _ctrl ctrlCommit 0;
{ "pile_set_name": "Github" }
OPTION DOTNAME .text$ SEGMENT ALIGN(256) 'CODE' EXTERN OPENSSL_ia32cap_P:NEAR PUBLIC aesni_multi_cbc_encrypt ALIGN 32 aesni_multi_cbc_encrypt PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_aesni_multi_cbc_encrypt:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rax,rsp push rbx push rbp push r12 push r13 push r14 push r15 lea rsp,QWORD PTR[((-168))+rsp] movaps XMMWORD PTR[rsp],xmm6 movaps XMMWORD PTR[16+rsp],xmm7 movaps XMMWORD PTR[32+rsp],xmm8 movaps XMMWORD PTR[48+rsp],xmm9 movaps XMMWORD PTR[64+rsp],xmm10 movaps XMMWORD PTR[80+rsp],xmm11 movaps XMMWORD PTR[96+rsp],xmm12 movaps XMMWORD PTR[(-104)+rax],xmm13 movaps XMMWORD PTR[(-88)+rax],xmm14 movaps XMMWORD PTR[(-72)+rax],xmm15 sub rsp,48 and rsp,-64 mov QWORD PTR[16+rsp],rax $L$enc4x_body:: movdqu xmm12,XMMWORD PTR[rsi] lea rsi,QWORD PTR[120+rsi] lea rdi,QWORD PTR[80+rdi] $L$enc4x_loop_grande:: mov DWORD PTR[24+rsp],edx xor edx,edx mov ecx,DWORD PTR[((-64))+rdi] mov r8,QWORD PTR[((-80))+rdi] cmp ecx,edx mov r12,QWORD PTR[((-72))+rdi] cmovg edx,ecx test ecx,ecx movdqu xmm2,XMMWORD PTR[((-56))+rdi] mov DWORD PTR[32+rsp],ecx cmovle r8,rsp mov ecx,DWORD PTR[((-24))+rdi] mov r9,QWORD PTR[((-40))+rdi] cmp ecx,edx mov r13,QWORD PTR[((-32))+rdi] cmovg edx,ecx test ecx,ecx movdqu xmm3,XMMWORD PTR[((-16))+rdi] mov DWORD PTR[36+rsp],ecx cmovle r9,rsp mov ecx,DWORD PTR[16+rdi] mov r10,QWORD PTR[rdi] cmp ecx,edx mov r14,QWORD PTR[8+rdi] cmovg edx,ecx test ecx,ecx movdqu xmm4,XMMWORD PTR[24+rdi] mov DWORD PTR[40+rsp],ecx cmovle r10,rsp mov ecx,DWORD PTR[56+rdi] mov r11,QWORD PTR[40+rdi] cmp ecx,edx mov r15,QWORD PTR[48+rdi] cmovg edx,ecx test ecx,ecx movdqu xmm5,XMMWORD PTR[64+rdi] mov DWORD PTR[44+rsp],ecx cmovle r11,rsp test edx,edx jz $L$enc4x_done movups xmm1,XMMWORD PTR[((16-120))+rsi] pxor xmm2,xmm12 movups xmm0,XMMWORD PTR[((32-120))+rsi] pxor xmm3,xmm12 mov eax,DWORD PTR[((240-120))+rsi] pxor xmm4,xmm12 movdqu xmm6,XMMWORD PTR[r8] pxor xmm5,xmm12 movdqu xmm7,XMMWORD PTR[r9] pxor xmm2,xmm6 movdqu xmm8,XMMWORD PTR[r10] pxor xmm3,xmm7 movdqu xmm9,XMMWORD PTR[r11] pxor xmm4,xmm8 pxor xmm5,xmm9 movdqa xmm10,XMMWORD PTR[32+rsp] xor rbx,rbx jmp $L$oop_enc4x ALIGN 32 $L$oop_enc4x:: add rbx,16 lea rbp,QWORD PTR[16+rsp] mov ecx,1 sub rbp,rbx DB 102,15,56,220,209 prefetcht0 [31+rbx*1+r8] prefetcht0 [31+rbx*1+r9] DB 102,15,56,220,217 prefetcht0 [31+rbx*1+r10] prefetcht0 [31+rbx*1+r10] DB 102,15,56,220,225 DB 102,15,56,220,233 movups xmm1,XMMWORD PTR[((48-120))+rsi] cmp ecx,DWORD PTR[32+rsp] DB 102,15,56,220,208 DB 102,15,56,220,216 DB 102,15,56,220,224 cmovge r8,rbp cmovg r12,rbp DB 102,15,56,220,232 movups xmm0,XMMWORD PTR[((-56))+rsi] cmp ecx,DWORD PTR[36+rsp] DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 cmovge r9,rbp cmovg r13,rbp DB 102,15,56,220,233 movups xmm1,XMMWORD PTR[((-40))+rsi] cmp ecx,DWORD PTR[40+rsp] DB 102,15,56,220,208 DB 102,15,56,220,216 DB 102,15,56,220,224 cmovge r10,rbp cmovg r14,rbp DB 102,15,56,220,232 movups xmm0,XMMWORD PTR[((-24))+rsi] cmp ecx,DWORD PTR[44+rsp] DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 cmovge r11,rbp cmovg r15,rbp DB 102,15,56,220,233 movups xmm1,XMMWORD PTR[((-8))+rsi] movdqa xmm11,xmm10 DB 102,15,56,220,208 prefetcht0 [15+rbx*1+r12] prefetcht0 [15+rbx*1+r13] DB 102,15,56,220,216 prefetcht0 [15+rbx*1+r14] prefetcht0 [15+rbx*1+r15] DB 102,15,56,220,224 DB 102,15,56,220,232 movups xmm0,XMMWORD PTR[((128-120))+rsi] pxor xmm12,xmm12 DB 102,15,56,220,209 pcmpgtd xmm11,xmm12 movdqu xmm12,XMMWORD PTR[((-120))+rsi] DB 102,15,56,220,217 paddd xmm10,xmm11 movdqa XMMWORD PTR[32+rsp],xmm10 DB 102,15,56,220,225 DB 102,15,56,220,233 movups xmm1,XMMWORD PTR[((144-120))+rsi] cmp eax,11 DB 102,15,56,220,208 DB 102,15,56,220,216 DB 102,15,56,220,224 DB 102,15,56,220,232 movups xmm0,XMMWORD PTR[((160-120))+rsi] jb $L$enc4x_tail DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 movups xmm1,XMMWORD PTR[((176-120))+rsi] DB 102,15,56,220,208 DB 102,15,56,220,216 DB 102,15,56,220,224 DB 102,15,56,220,232 movups xmm0,XMMWORD PTR[((192-120))+rsi] je $L$enc4x_tail DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 movups xmm1,XMMWORD PTR[((208-120))+rsi] DB 102,15,56,220,208 DB 102,15,56,220,216 DB 102,15,56,220,224 DB 102,15,56,220,232 movups xmm0,XMMWORD PTR[((224-120))+rsi] jmp $L$enc4x_tail ALIGN 32 $L$enc4x_tail:: DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 movdqu xmm6,XMMWORD PTR[rbx*1+r8] movdqu xmm1,XMMWORD PTR[((16-120))+rsi] DB 102,15,56,221,208 movdqu xmm7,XMMWORD PTR[rbx*1+r9] pxor xmm6,xmm12 DB 102,15,56,221,216 movdqu xmm8,XMMWORD PTR[rbx*1+r10] pxor xmm7,xmm12 DB 102,15,56,221,224 movdqu xmm9,XMMWORD PTR[rbx*1+r11] pxor xmm8,xmm12 DB 102,15,56,221,232 movdqu xmm0,XMMWORD PTR[((32-120))+rsi] pxor xmm9,xmm12 movups XMMWORD PTR[(-16)+rbx*1+r12],xmm2 pxor xmm2,xmm6 movups XMMWORD PTR[(-16)+rbx*1+r13],xmm3 pxor xmm3,xmm7 movups XMMWORD PTR[(-16)+rbx*1+r14],xmm4 pxor xmm4,xmm8 movups XMMWORD PTR[(-16)+rbx*1+r15],xmm5 pxor xmm5,xmm9 dec edx jnz $L$oop_enc4x mov rax,QWORD PTR[16+rsp] mov edx,DWORD PTR[24+rsp] lea rdi,QWORD PTR[160+rdi] dec edx jnz $L$enc4x_loop_grande $L$enc4x_done:: movaps xmm6,XMMWORD PTR[((-216))+rax] movaps xmm7,XMMWORD PTR[((-200))+rax] movaps xmm8,XMMWORD PTR[((-184))+rax] movaps xmm9,XMMWORD PTR[((-168))+rax] movaps xmm10,XMMWORD PTR[((-152))+rax] movaps xmm11,XMMWORD PTR[((-136))+rax] movaps xmm12,XMMWORD PTR[((-120))+rax] mov r15,QWORD PTR[((-48))+rax] mov r14,QWORD PTR[((-40))+rax] mov r13,QWORD PTR[((-32))+rax] mov r12,QWORD PTR[((-24))+rax] mov rbp,QWORD PTR[((-16))+rax] mov rbx,QWORD PTR[((-8))+rax] lea rsp,QWORD PTR[rax] $L$enc4x_epilogue:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_aesni_multi_cbc_encrypt:: aesni_multi_cbc_encrypt ENDP PUBLIC aesni_multi_cbc_decrypt ALIGN 32 aesni_multi_cbc_decrypt PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_aesni_multi_cbc_decrypt:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rax,rsp push rbx push rbp push r12 push r13 push r14 push r15 lea rsp,QWORD PTR[((-168))+rsp] movaps XMMWORD PTR[rsp],xmm6 movaps XMMWORD PTR[16+rsp],xmm7 movaps XMMWORD PTR[32+rsp],xmm8 movaps XMMWORD PTR[48+rsp],xmm9 movaps XMMWORD PTR[64+rsp],xmm10 movaps XMMWORD PTR[80+rsp],xmm11 movaps XMMWORD PTR[96+rsp],xmm12 movaps XMMWORD PTR[(-104)+rax],xmm13 movaps XMMWORD PTR[(-88)+rax],xmm14 movaps XMMWORD PTR[(-72)+rax],xmm15 sub rsp,48 and rsp,-64 mov QWORD PTR[16+rsp],rax $L$dec4x_body:: movdqu xmm12,XMMWORD PTR[rsi] lea rsi,QWORD PTR[120+rsi] lea rdi,QWORD PTR[80+rdi] $L$dec4x_loop_grande:: mov DWORD PTR[24+rsp],edx xor edx,edx mov ecx,DWORD PTR[((-64))+rdi] mov r8,QWORD PTR[((-80))+rdi] cmp ecx,edx mov r12,QWORD PTR[((-72))+rdi] cmovg edx,ecx test ecx,ecx movdqu xmm6,XMMWORD PTR[((-56))+rdi] mov DWORD PTR[32+rsp],ecx cmovle r8,rsp mov ecx,DWORD PTR[((-24))+rdi] mov r9,QWORD PTR[((-40))+rdi] cmp ecx,edx mov r13,QWORD PTR[((-32))+rdi] cmovg edx,ecx test ecx,ecx movdqu xmm7,XMMWORD PTR[((-16))+rdi] mov DWORD PTR[36+rsp],ecx cmovle r9,rsp mov ecx,DWORD PTR[16+rdi] mov r10,QWORD PTR[rdi] cmp ecx,edx mov r14,QWORD PTR[8+rdi] cmovg edx,ecx test ecx,ecx movdqu xmm8,XMMWORD PTR[24+rdi] mov DWORD PTR[40+rsp],ecx cmovle r10,rsp mov ecx,DWORD PTR[56+rdi] mov r11,QWORD PTR[40+rdi] cmp ecx,edx mov r15,QWORD PTR[48+rdi] cmovg edx,ecx test ecx,ecx movdqu xmm9,XMMWORD PTR[64+rdi] mov DWORD PTR[44+rsp],ecx cmovle r11,rsp test edx,edx jz $L$dec4x_done movups xmm1,XMMWORD PTR[((16-120))+rsi] movups xmm0,XMMWORD PTR[((32-120))+rsi] mov eax,DWORD PTR[((240-120))+rsi] movdqu xmm2,XMMWORD PTR[r8] movdqu xmm3,XMMWORD PTR[r9] pxor xmm2,xmm12 movdqu xmm4,XMMWORD PTR[r10] pxor xmm3,xmm12 movdqu xmm5,XMMWORD PTR[r11] pxor xmm4,xmm12 pxor xmm5,xmm12 movdqa xmm10,XMMWORD PTR[32+rsp] xor rbx,rbx jmp $L$oop_dec4x ALIGN 32 $L$oop_dec4x:: add rbx,16 lea rbp,QWORD PTR[16+rsp] mov ecx,1 sub rbp,rbx DB 102,15,56,222,209 prefetcht0 [31+rbx*1+r8] prefetcht0 [31+rbx*1+r9] DB 102,15,56,222,217 prefetcht0 [31+rbx*1+r10] prefetcht0 [31+rbx*1+r11] DB 102,15,56,222,225 DB 102,15,56,222,233 movups xmm1,XMMWORD PTR[((48-120))+rsi] cmp ecx,DWORD PTR[32+rsp] DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 cmovge r8,rbp cmovg r12,rbp DB 102,15,56,222,232 movups xmm0,XMMWORD PTR[((-56))+rsi] cmp ecx,DWORD PTR[36+rsp] DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 cmovge r9,rbp cmovg r13,rbp DB 102,15,56,222,233 movups xmm1,XMMWORD PTR[((-40))+rsi] cmp ecx,DWORD PTR[40+rsp] DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 cmovge r10,rbp cmovg r14,rbp DB 102,15,56,222,232 movups xmm0,XMMWORD PTR[((-24))+rsi] cmp ecx,DWORD PTR[44+rsp] DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 cmovge r11,rbp cmovg r15,rbp DB 102,15,56,222,233 movups xmm1,XMMWORD PTR[((-8))+rsi] movdqa xmm11,xmm10 DB 102,15,56,222,208 prefetcht0 [15+rbx*1+r12] prefetcht0 [15+rbx*1+r13] DB 102,15,56,222,216 prefetcht0 [15+rbx*1+r14] prefetcht0 [15+rbx*1+r15] DB 102,15,56,222,224 DB 102,15,56,222,232 movups xmm0,XMMWORD PTR[((128-120))+rsi] pxor xmm12,xmm12 DB 102,15,56,222,209 pcmpgtd xmm11,xmm12 movdqu xmm12,XMMWORD PTR[((-120))+rsi] DB 102,15,56,222,217 paddd xmm10,xmm11 movdqa XMMWORD PTR[32+rsp],xmm10 DB 102,15,56,222,225 DB 102,15,56,222,233 movups xmm1,XMMWORD PTR[((144-120))+rsi] cmp eax,11 DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 DB 102,15,56,222,232 movups xmm0,XMMWORD PTR[((160-120))+rsi] jb $L$dec4x_tail DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 movups xmm1,XMMWORD PTR[((176-120))+rsi] DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 DB 102,15,56,222,232 movups xmm0,XMMWORD PTR[((192-120))+rsi] je $L$dec4x_tail DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 movups xmm1,XMMWORD PTR[((208-120))+rsi] DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 DB 102,15,56,222,232 movups xmm0,XMMWORD PTR[((224-120))+rsi] jmp $L$dec4x_tail ALIGN 32 $L$dec4x_tail:: DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 pxor xmm6,xmm0 pxor xmm7,xmm0 DB 102,15,56,222,233 movdqu xmm1,XMMWORD PTR[((16-120))+rsi] pxor xmm8,xmm0 pxor xmm9,xmm0 movdqu xmm0,XMMWORD PTR[((32-120))+rsi] DB 102,15,56,223,214 DB 102,15,56,223,223 movdqu xmm6,XMMWORD PTR[((-16))+rbx*1+r8] movdqu xmm7,XMMWORD PTR[((-16))+rbx*1+r9] DB 102,65,15,56,223,224 DB 102,65,15,56,223,233 movdqu xmm8,XMMWORD PTR[((-16))+rbx*1+r10] movdqu xmm9,XMMWORD PTR[((-16))+rbx*1+r11] movups XMMWORD PTR[(-16)+rbx*1+r12],xmm2 movdqu xmm2,XMMWORD PTR[rbx*1+r8] movups XMMWORD PTR[(-16)+rbx*1+r13],xmm3 movdqu xmm3,XMMWORD PTR[rbx*1+r9] pxor xmm2,xmm12 movups XMMWORD PTR[(-16)+rbx*1+r14],xmm4 movdqu xmm4,XMMWORD PTR[rbx*1+r10] pxor xmm3,xmm12 movups XMMWORD PTR[(-16)+rbx*1+r15],xmm5 movdqu xmm5,XMMWORD PTR[rbx*1+r11] pxor xmm4,xmm12 pxor xmm5,xmm12 dec edx jnz $L$oop_dec4x mov rax,QWORD PTR[16+rsp] mov edx,DWORD PTR[24+rsp] lea rdi,QWORD PTR[160+rdi] dec edx jnz $L$dec4x_loop_grande $L$dec4x_done:: movaps xmm6,XMMWORD PTR[((-216))+rax] movaps xmm7,XMMWORD PTR[((-200))+rax] movaps xmm8,XMMWORD PTR[((-184))+rax] movaps xmm9,XMMWORD PTR[((-168))+rax] movaps xmm10,XMMWORD PTR[((-152))+rax] movaps xmm11,XMMWORD PTR[((-136))+rax] movaps xmm12,XMMWORD PTR[((-120))+rax] mov r15,QWORD PTR[((-48))+rax] mov r14,QWORD PTR[((-40))+rax] mov r13,QWORD PTR[((-32))+rax] mov r12,QWORD PTR[((-24))+rax] mov rbp,QWORD PTR[((-16))+rax] mov rbx,QWORD PTR[((-8))+rax] lea rsp,QWORD PTR[rax] $L$dec4x_epilogue:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_aesni_multi_cbc_decrypt:: aesni_multi_cbc_decrypt ENDP EXTERN __imp_RtlVirtualUnwind:NEAR ALIGN 16 se_handler PROC PRIVATE push rsi push rdi push rbx push rbp push r12 push r13 push r14 push r15 pushfq sub rsp,64 mov rax,QWORD PTR[120+r8] mov rbx,QWORD PTR[248+r8] mov rsi,QWORD PTR[8+r9] mov r11,QWORD PTR[56+r9] mov r10d,DWORD PTR[r11] lea r10,QWORD PTR[r10*1+rsi] cmp rbx,r10 jb $L$in_prologue mov rax,QWORD PTR[152+r8] mov r10d,DWORD PTR[4+r11] lea r10,QWORD PTR[r10*1+rsi] cmp rbx,r10 jae $L$in_prologue mov rax,QWORD PTR[16+rax] mov rbx,QWORD PTR[((-8))+rax] mov rbp,QWORD PTR[((-16))+rax] mov r12,QWORD PTR[((-24))+rax] mov r13,QWORD PTR[((-32))+rax] mov r14,QWORD PTR[((-40))+rax] mov r15,QWORD PTR[((-48))+rax] mov QWORD PTR[144+r8],rbx mov QWORD PTR[160+r8],rbp mov QWORD PTR[216+r8],r12 mov QWORD PTR[224+r8],r13 mov QWORD PTR[232+r8],r14 mov QWORD PTR[240+r8],r15 lea rsi,QWORD PTR[((-56-160))+rax] lea rdi,QWORD PTR[512+r8] mov ecx,20 DD 0a548f3fch $L$in_prologue:: mov rdi,QWORD PTR[8+rax] mov rsi,QWORD PTR[16+rax] mov QWORD PTR[152+r8],rax mov QWORD PTR[168+r8],rsi mov QWORD PTR[176+r8],rdi mov rdi,QWORD PTR[40+r9] mov rsi,r8 mov ecx,154 DD 0a548f3fch mov rsi,r9 xor rcx,rcx mov rdx,QWORD PTR[8+rsi] mov r8,QWORD PTR[rsi] mov r9,QWORD PTR[16+rsi] mov r10,QWORD PTR[40+rsi] lea r11,QWORD PTR[56+rsi] lea r12,QWORD PTR[24+rsi] mov QWORD PTR[32+rsp],r10 mov QWORD PTR[40+rsp],r11 mov QWORD PTR[48+rsp],r12 mov QWORD PTR[56+rsp],rcx call QWORD PTR[__imp_RtlVirtualUnwind] mov eax,1 add rsp,64 popfq pop r15 pop r14 pop r13 pop r12 pop rbp pop rbx pop rdi pop rsi DB 0F3h,0C3h ;repret se_handler ENDP .text$ ENDS .pdata SEGMENT READONLY ALIGN(4) ALIGN 4 DD imagerel $L$SEH_begin_aesni_multi_cbc_encrypt DD imagerel $L$SEH_end_aesni_multi_cbc_encrypt DD imagerel $L$SEH_info_aesni_multi_cbc_encrypt DD imagerel $L$SEH_begin_aesni_multi_cbc_decrypt DD imagerel $L$SEH_end_aesni_multi_cbc_decrypt DD imagerel $L$SEH_info_aesni_multi_cbc_decrypt .pdata ENDS .xdata SEGMENT READONLY ALIGN(8) ALIGN 8 $L$SEH_info_aesni_multi_cbc_encrypt:: DB 9,0,0,0 DD imagerel se_handler DD imagerel $L$enc4x_body,imagerel $L$enc4x_epilogue $L$SEH_info_aesni_multi_cbc_decrypt:: DB 9,0,0,0 DD imagerel se_handler DD imagerel $L$dec4x_body,imagerel $L$dec4x_epilogue .xdata ENDS END
{ "pile_set_name": "Github" }
/****************************************************************************** * most_balanced_minimum_cuts.h * * * Source of KaHIP -- Karlsruhe High Quality Partitioning. * Christian Schulz <christian.schulz.phone@gmail.com> *****************************************************************************/ #ifndef MOST_BALANCED_MINIMUM_CUTS_SBD5CS #define MOST_BALANCED_MINIMUM_CUTS_SBD5CS #include "data_structure/graph_access.h" #include "partition_config.h" class most_balanced_minimum_cuts { public: most_balanced_minimum_cuts(); virtual ~most_balanced_minimum_cuts(); void compute_good_balanced_min_cut( graph_access & residualGraph, const PartitionConfig & config, NodeWeight & perfect_rhs_weight, std::vector< NodeID > & new_rhs_node ); private: void build_internal_scc_graph( graph_access & residualGraph, std::vector<int> & components, int comp_count, graph_access & scc_graph); void compute_new_rhs( graph_access & scc_graph, const PartitionConfig & config, std::vector< NodeWeight > & comp_weights, int comp_of_s, int comp_of_t, NodeWeight optimal_rhs_weight, std::vector<int> & comp_for_rhs); }; #endif /* end of include guard: MOST_BALANCED_MINIMUM_CUTS_SBD5CS */
{ "pile_set_name": "Github" }
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Crashlytics FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Crashlytics/iOS" "${PODS_ROOT}/Fabric/iOS" GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 OTHER_LDFLAGS = $(inherited) -l"c++" -l"z" -framework "Security" -framework "SystemConfiguration" -framework "UIKit" PODS_BUILD_DIR = ${BUILD_DIR} PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) PODS_ROOT = ${SRCROOT} PODS_TARGET_SRCROOT = ${PODS_ROOT}/Crashlytics PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} SKIP_INSTALL = YES USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
{ "pile_set_name": "Github" }
#ifndef BOOST_BIND_STORAGE_HPP_INCLUDED #define BOOST_BIND_STORAGE_HPP_INCLUDED // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif // // bind/storage.hpp // // boost/bind.hpp support header, optimized storage // // Copyright (c) 2006 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // // See http://www.boost.org/libs/bind/bind.html for documentation. // #include <boost/config.hpp> #include <boost/bind/arg.hpp> #ifdef BOOST_MSVC # pragma warning(push) # pragma warning(disable: 4512) // assignment operator could not be generated #endif namespace boost { namespace _bi { // 1 template<class A1> struct storage1 { explicit storage1( A1 a1 ): a1_( a1 ) {} template<class V> void accept(V & v) const { BOOST_BIND_VISIT_EACH(v, a1_, 0); } A1 a1_; }; #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( __BORLANDC__ ) template<int I> struct storage1< boost::arg<I> > { explicit storage1( boost::arg<I> ) {} template<class V> void accept(V &) const { } static boost::arg<I> a1_() { return boost::arg<I>(); } }; template<int I> struct storage1< boost::arg<I> (*) () > { explicit storage1( boost::arg<I> (*) () ) {} template<class V> void accept(V &) const { } static boost::arg<I> a1_() { return boost::arg<I>(); } }; #endif // 2 template<class A1, class A2> struct storage2: public storage1<A1> { typedef storage1<A1> inherited; storage2( A1 a1, A2 a2 ): storage1<A1>( a1 ), a2_( a2 ) {} template<class V> void accept(V & v) const { inherited::accept(v); BOOST_BIND_VISIT_EACH(v, a2_, 0); } A2 a2_; }; #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template<class A1, int I> struct storage2< A1, boost::arg<I> >: public storage1<A1> { typedef storage1<A1> inherited; storage2( A1 a1, boost::arg<I> ): storage1<A1>( a1 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a2_() { return boost::arg<I>(); } }; template<class A1, int I> struct storage2< A1, boost::arg<I> (*) () >: public storage1<A1> { typedef storage1<A1> inherited; storage2( A1 a1, boost::arg<I> (*) () ): storage1<A1>( a1 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a2_() { return boost::arg<I>(); } }; #endif // 3 template<class A1, class A2, class A3> struct storage3: public storage2< A1, A2 > { typedef storage2<A1, A2> inherited; storage3( A1 a1, A2 a2, A3 a3 ): storage2<A1, A2>( a1, a2 ), a3_( a3 ) {} template<class V> void accept(V & v) const { inherited::accept(v); BOOST_BIND_VISIT_EACH(v, a3_, 0); } A3 a3_; }; #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template<class A1, class A2, int I> struct storage3< A1, A2, boost::arg<I> >: public storage2< A1, A2 > { typedef storage2<A1, A2> inherited; storage3( A1 a1, A2 a2, boost::arg<I> ): storage2<A1, A2>( a1, a2 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a3_() { return boost::arg<I>(); } }; template<class A1, class A2, int I> struct storage3< A1, A2, boost::arg<I> (*) () >: public storage2< A1, A2 > { typedef storage2<A1, A2> inherited; storage3( A1 a1, A2 a2, boost::arg<I> (*) () ): storage2<A1, A2>( a1, a2 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a3_() { return boost::arg<I>(); } }; #endif // 4 template<class A1, class A2, class A3, class A4> struct storage4: public storage3< A1, A2, A3 > { typedef storage3<A1, A2, A3> inherited; storage4( A1 a1, A2 a2, A3 a3, A4 a4 ): storage3<A1, A2, A3>( a1, a2, a3 ), a4_( a4 ) {} template<class V> void accept(V & v) const { inherited::accept(v); BOOST_BIND_VISIT_EACH(v, a4_, 0); } A4 a4_; }; #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template<class A1, class A2, class A3, int I> struct storage4< A1, A2, A3, boost::arg<I> >: public storage3< A1, A2, A3 > { typedef storage3<A1, A2, A3> inherited; storage4( A1 a1, A2 a2, A3 a3, boost::arg<I> ): storage3<A1, A2, A3>( a1, a2, a3 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a4_() { return boost::arg<I>(); } }; template<class A1, class A2, class A3, int I> struct storage4< A1, A2, A3, boost::arg<I> (*) () >: public storage3< A1, A2, A3 > { typedef storage3<A1, A2, A3> inherited; storage4( A1 a1, A2 a2, A3 a3, boost::arg<I> (*) () ): storage3<A1, A2, A3>( a1, a2, a3 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a4_() { return boost::arg<I>(); } }; #endif // 5 template<class A1, class A2, class A3, class A4, class A5> struct storage5: public storage4< A1, A2, A3, A4 > { typedef storage4<A1, A2, A3, A4> inherited; storage5( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5 ): storage4<A1, A2, A3, A4>( a1, a2, a3, a4 ), a5_( a5 ) {} template<class V> void accept(V & v) const { inherited::accept(v); BOOST_BIND_VISIT_EACH(v, a5_, 0); } A5 a5_; }; #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template<class A1, class A2, class A3, class A4, int I> struct storage5< A1, A2, A3, A4, boost::arg<I> >: public storage4< A1, A2, A3, A4 > { typedef storage4<A1, A2, A3, A4> inherited; storage5( A1 a1, A2 a2, A3 a3, A4 a4, boost::arg<I> ): storage4<A1, A2, A3, A4>( a1, a2, a3, a4 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a5_() { return boost::arg<I>(); } }; template<class A1, class A2, class A3, class A4, int I> struct storage5< A1, A2, A3, A4, boost::arg<I> (*) () >: public storage4< A1, A2, A3, A4 > { typedef storage4<A1, A2, A3, A4> inherited; storage5( A1 a1, A2 a2, A3 a3, A4 a4, boost::arg<I> (*) () ): storage4<A1, A2, A3, A4>( a1, a2, a3, a4 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a5_() { return boost::arg<I>(); } }; #endif // 6 template<class A1, class A2, class A3, class A4, class A5, class A6> struct storage6: public storage5< A1, A2, A3, A4, A5 > { typedef storage5<A1, A2, A3, A4, A5> inherited; storage6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6 ): storage5<A1, A2, A3, A4, A5>( a1, a2, a3, a4, a5 ), a6_( a6 ) {} template<class V> void accept(V & v) const { inherited::accept(v); BOOST_BIND_VISIT_EACH(v, a6_, 0); } A6 a6_; }; #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template<class A1, class A2, class A3, class A4, class A5, int I> struct storage6< A1, A2, A3, A4, A5, boost::arg<I> >: public storage5< A1, A2, A3, A4, A5 > { typedef storage5<A1, A2, A3, A4, A5> inherited; storage6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, boost::arg<I> ): storage5<A1, A2, A3, A4, A5>( a1, a2, a3, a4, a5 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a6_() { return boost::arg<I>(); } }; template<class A1, class A2, class A3, class A4, class A5, int I> struct storage6< A1, A2, A3, A4, A5, boost::arg<I> (*) () >: public storage5< A1, A2, A3, A4, A5 > { typedef storage5<A1, A2, A3, A4, A5> inherited; storage6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, boost::arg<I> (*) () ): storage5<A1, A2, A3, A4, A5>( a1, a2, a3, a4, a5 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a6_() { return boost::arg<I>(); } }; #endif // 7 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct storage7: public storage6< A1, A2, A3, A4, A5, A6 > { typedef storage6<A1, A2, A3, A4, A5, A6> inherited; storage7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7 ): storage6<A1, A2, A3, A4, A5, A6>( a1, a2, a3, a4, a5, a6 ), a7_( a7 ) {} template<class V> void accept(V & v) const { inherited::accept(v); BOOST_BIND_VISIT_EACH(v, a7_, 0); } A7 a7_; }; #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template<class A1, class A2, class A3, class A4, class A5, class A6, int I> struct storage7< A1, A2, A3, A4, A5, A6, boost::arg<I> >: public storage6< A1, A2, A3, A4, A5, A6 > { typedef storage6<A1, A2, A3, A4, A5, A6> inherited; storage7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, boost::arg<I> ): storage6<A1, A2, A3, A4, A5, A6>( a1, a2, a3, a4, a5, a6 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a7_() { return boost::arg<I>(); } }; template<class A1, class A2, class A3, class A4, class A5, class A6, int I> struct storage7< A1, A2, A3, A4, A5, A6, boost::arg<I> (*) () >: public storage6< A1, A2, A3, A4, A5, A6 > { typedef storage6<A1, A2, A3, A4, A5, A6> inherited; storage7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, boost::arg<I> (*) () ): storage6<A1, A2, A3, A4, A5, A6>( a1, a2, a3, a4, a5, a6 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a7_() { return boost::arg<I>(); } }; #endif // 8 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct storage8: public storage7< A1, A2, A3, A4, A5, A6, A7 > { typedef storage7<A1, A2, A3, A4, A5, A6, A7> inherited; storage8( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8 ): storage7<A1, A2, A3, A4, A5, A6, A7>( a1, a2, a3, a4, a5, a6, a7 ), a8_( a8 ) {} template<class V> void accept(V & v) const { inherited::accept(v); BOOST_BIND_VISIT_EACH(v, a8_, 0); } A8 a8_; }; #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, int I> struct storage8< A1, A2, A3, A4, A5, A6, A7, boost::arg<I> >: public storage7< A1, A2, A3, A4, A5, A6, A7 > { typedef storage7<A1, A2, A3, A4, A5, A6, A7> inherited; storage8( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, boost::arg<I> ): storage7<A1, A2, A3, A4, A5, A6, A7>( a1, a2, a3, a4, a5, a6, a7 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a8_() { return boost::arg<I>(); } }; template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, int I> struct storage8< A1, A2, A3, A4, A5, A6, A7, boost::arg<I> (*) () >: public storage7< A1, A2, A3, A4, A5, A6, A7 > { typedef storage7<A1, A2, A3, A4, A5, A6, A7> inherited; storage8( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, boost::arg<I> (*) () ): storage7<A1, A2, A3, A4, A5, A6, A7>( a1, a2, a3, a4, a5, a6, a7 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a8_() { return boost::arg<I>(); } }; #endif // 9 template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> struct storage9: public storage8< A1, A2, A3, A4, A5, A6, A7, A8 > { typedef storage8<A1, A2, A3, A4, A5, A6, A7, A8> inherited; storage9( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9 ): storage8<A1, A2, A3, A4, A5, A6, A7, A8>( a1, a2, a3, a4, a5, a6, a7, a8 ), a9_( a9 ) {} template<class V> void accept(V & v) const { inherited::accept(v); BOOST_BIND_VISIT_EACH(v, a9_, 0); } A9 a9_; }; #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, int I> struct storage9< A1, A2, A3, A4, A5, A6, A7, A8, boost::arg<I> >: public storage8< A1, A2, A3, A4, A5, A6, A7, A8 > { typedef storage8<A1, A2, A3, A4, A5, A6, A7, A8> inherited; storage9( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, boost::arg<I> ): storage8<A1, A2, A3, A4, A5, A6, A7, A8>( a1, a2, a3, a4, a5, a6, a7, a8 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a9_() { return boost::arg<I>(); } }; template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, int I> struct storage9< A1, A2, A3, A4, A5, A6, A7, A8, boost::arg<I> (*) () >: public storage8< A1, A2, A3, A4, A5, A6, A7, A8 > { typedef storage8<A1, A2, A3, A4, A5, A6, A7, A8> inherited; storage9( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, boost::arg<I> (*) () ): storage8<A1, A2, A3, A4, A5, A6, A7, A8>( a1, a2, a3, a4, a5, a6, a7, a8 ) {} template<class V> void accept(V & v) const { inherited::accept(v); } static boost::arg<I> a9_() { return boost::arg<I>(); } }; #endif } // namespace _bi } // namespace boost #ifdef BOOST_MSVC # pragma warning(default: 4512) // assignment operator could not be generated # pragma warning(pop) #endif #endif // #ifndef BOOST_BIND_STORAGE_HPP_INCLUDED
{ "pile_set_name": "Github" }
// StringUtils.cpp #include "StdAfx.h" #include "StringUtils.h" void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2) { dest1.Empty(); dest2.Empty(); bool quoteMode = false; int i; for (i = 0; i < src.Length(); i++) { wchar_t c = src[i]; if (c == L'\"') quoteMode = !quoteMode; else if (c == L' ' && !quoteMode) { if (!quoteMode) { i++; break; } } else dest1 += c; } dest2 = src.Mid(i); } void SplitString(const UString &srcString, UStringVector &destStrings) { destStrings.Clear(); UString string; int len = srcString.Length(); if (len == 0) return; for (int i = 0; i < len; i++) { wchar_t c = srcString[i]; if (c == L' ') { if (!string.IsEmpty()) { destStrings.Add(string); string.Empty(); } } else string += c; } if (!string.IsEmpty()) destStrings.Add(string); } UString JoinStrings(const UStringVector &srcStrings) { UString destString; for (int i = 0; i < srcStrings.Size(); i++) { if (i != 0) destString += L' '; destString += srcStrings[i]; } return destString; }
{ "pile_set_name": "Github" }
$NetBSD: patch-ac,v 1.2 2006/08/02 19:24:55 kristerw Exp $ --- xroads.c.orig 1999-06-30 20:25:02.000000000 +0200 +++ xroads.c 2006-08-02 21:14:27.000000000 +0200 @@ -282,13 +282,13 @@ } /*************************************************************************************************/ -int trunc( float num ) { /* Truncate a float to an int */ +int mytrunc( float num ) { /* Truncate a float to an int */ if (num>0) return (int)num; else return (int)(num-0.5); } /*************************************************************************************************/ -int round( float num ) { /* Round a float to an int */ +int roundup( float num ) { /* Round a float to an int */ return (int)(num+0.5); } @@ -394,11 +394,11 @@ /* VacAttack */ /* if(data[amonst->type].attack1==VACCUUM && (amonst->x==monst[targ].x - || amonst->y==monst[targ].y) && (round(amonst->x) == - trunc(amonst->x) && round(amonst->y) == trunc(amonst->y))) { + || amonst->y==monst[targ].y) && (roundup(amonst->x) == + mytrunc(amonst->x) && roundup(amonst->y) == mytrunc(amonst->y))) { */ - if(data[amonst->type].attack1==VACCUUM && (round(amonst->x) == - trunc(amonst->x) && round(amonst->y) == trunc(amonst->y)) && + if(data[amonst->type].attack1==VACCUUM && (roundup(amonst->x) == + mytrunc(amonst->x) && roundup(amonst->y) == mytrunc(amonst->y)) && clearshot(amonst, &monst[targ])) { watchentity(amonst, &monst[targ]); vacattack(amonst, &monst[targ]); @@ -423,19 +423,19 @@ else amonst->frame++; if(data[amonst->type].etype!=EFFECT) { - maze[round(oldy)][round(oldx)]=-2; /* Blank out old space */ - maze[trunc(oldy)][trunc(oldx)]=-2; - maze[round(amonst->y)][round(amonst->x)]=number; - maze[trunc(amonst->y)][trunc(amonst->x)]=number; + maze[roundup(oldy)][roundup(oldx)]=-2; /* Blank out old space */ + maze[mytrunc(oldy)][mytrunc(oldx)]=-2; + maze[roundup(amonst->y)][roundup(amonst->x)]=number; + maze[mytrunc(amonst->y)][mytrunc(amonst->x)]=number; } /* If there was something underneath the effect, redraw it */ - if(maze[trunc(amonst->y)][trunc(amonst->x)]!=-2) { - bmonst=&monst[maze[trunc(amonst->y)][trunc(amonst->x)]]; + if(maze[mytrunc(amonst->y)][mytrunc(amonst->x)]!=-2) { + bmonst=&monst[maze[mytrunc(amonst->y)][mytrunc(amonst->x)]]; draw_tilex2(mainwindow, data[bmonst->type].tile[bmonst->frame], (bmonst->x)*GRIDSIZE, (bmonst->y)*GRIDSIZE, bmonst->color, bmonst->dir); } - if(maze[round(amonst->y)][round(amonst->x)]!=-2) { - bmonst=&monst[maze[round(amonst->y)][round(amonst->x)]]; + if(maze[roundup(amonst->y)][roundup(amonst->x)]!=-2) { + bmonst=&monst[maze[roundup(amonst->y)][roundup(amonst->x)]]; draw_tilex2(mainwindow, data[bmonst->type].tile[bmonst->frame], (bmonst->x)*GRIDSIZE, (bmonst->y)*GRIDSIZE, bmonst->color, bmonst->dir); } @@ -558,7 +558,7 @@ else if(player->attr & PULL_R) { newx+=1; player->attr &= ~PULL_R; } /* Only one half-step at a time */ - if(round(newx)!=trunc(newx) && round(newy)!=trunc(newy)) { + if(roundup(newx)!=mytrunc(newx) && roundup(newy)!=mytrunc(newy)) { #ifdef DEBUG printf("Damn, in two half-steps at a time...\n"); #endif @@ -574,30 +574,30 @@ /* If we're in a half-step, eqx and eqy are the space we're moving into */ - if(round(newx)!=trunc(newx)) { - eqy = trunc(newy); + if(roundup(newx)!=mytrunc(newx)) { + eqy = mytrunc(newy); if(newx > player->x) - eqx = round(newx); + eqx = roundup(newx); else if(newx < player->x) - eqx = trunc(newx); + eqx = mytrunc(newx); } - else if(round(newy)!=trunc(newy)) { - eqx = trunc(newx); + else if(roundup(newy)!=mytrunc(newy)) { + eqx = mytrunc(newx); if(newy > player->y) - eqy = round(newy); + eqy = roundup(newy); else if(newy < player->y) - eqy = trunc(newy); + eqy = mytrunc(newy); } else { - eqx = trunc(newx); - eqy = trunc(newy); + eqx = mytrunc(newx); + eqy = mytrunc(newy); } /* switch(player->dir) { - case LEFT: eqx = trunc(newx); break; - case RIGHT: eqx = round(newx); break; - case UP: eqy = trunc(newy); break; - case DOWN: eqy = round(newy); break; + case LEFT: eqx = mytrunc(newx); break; + case RIGHT: eqx = roundup(newx); break; + case UP: eqy = mytrunc(newy); break; + case DOWN: eqy = roundup(newy); break; default: } */ @@ -610,8 +610,8 @@ printf("Destination (%0.2f, %0.2f)...\n", newx, newy); printf("Equiv (%d, %d)\n", eqx, eqy); printf("@ %d, %d : %d\n", eqx, eqy, maze[eqy][eqx]); - printf("newx: %0.2f: round %d, trunc %d\n", newx, round(newx), trunc(newx)); - printf("newy: %0.2f: round %d, trunc %d\n", newy, round(newy), trunc(newy)); + printf("newx: %0.2f: round %d, trunc %d\n", newx, roundup(newx), mytrunc(newx)); + printf("newy: %0.2f: round %d, trunc %d\n", newy, roundup(newy), mytrunc(newy)); printf("Checkdest: %d\n", checkdest(eqx, eqy)); printf("-----\n"); } @@ -646,8 +646,8 @@ else if(!okay) { #ifdef DEBUG printf("something in the way. (%d or %d)\n", - maze[trunc(newy)][trunc(newx)], - maze[round(newy)][round(newy)]); + maze[mytrunc(newy)][mytrunc(newx)], + maze[roundup(newy)][roundup(newy)]); #endif newx=player->x; newy=player->y; @@ -658,15 +658,15 @@ #endif /* Destination has been set, now all we have to do is move there */ - maze[round(player->y)][round(player->x)]=-2; - maze[trunc(player->y)][trunc(player->x)]=-2; + maze[roundup(player->y)][roundup(player->x)]=-2; + maze[mytrunc(player->y)][mytrunc(player->x)]=-2; draw_tilex2(mainwindow, blank, player->x*GRIDSIZE, player->y*GRIDSIZE, BLACK, RIGHT); /* Draw player */ player->x=newx; player->y=newy; - maze[round(player->y)][round(player->x)]=player->ind; - maze[trunc(player->y)][trunc(player->x)]=player->ind; + maze[roundup(player->y)][roundup(player->x)]=player->ind; + maze[mytrunc(player->y)][mytrunc(player->x)]=player->ind; draw_tilex2(mainwindow, data[datapos].tile[player->frame], player->x*GRIDSIZE, player->y*GRIDSIZE, player->color, player->dir); @@ -1279,8 +1279,8 @@ player[i]->health = 0; if(player[i]->attr & ACTIVE) { player[i]->attr ^= ACTIVE; - maze[round(player[i]->y)][round(player[i]->x)] = -2; - maze[trunc(player[i]->y)][trunc(player[i]->x)] = -2; + maze[roundup(player[i]->y)][roundup(player[i]->x)] = -2; + maze[mytrunc(player[i]->y)][mytrunc(player[i]->x)] = -2; draw_tilex2(mainwindow, blank, player[i]->x*GRIDSIZE, player[i]->y*GRIDSIZE, BLACK, RIGHT); #ifdef XPLOSIONS
{ "pile_set_name": "Github" }
/* * linux/sound/soc/ep93xx-i2s.c * EP93xx I2S driver * * Copyright (C) 2010 Ryan Mallon <ryan@bluewatersys.com> * * Based on the original driver by: * Copyright (C) 2007 Chase Douglas <chasedouglas@gmail> * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org> * * 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. * */ #include <linux/module.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/clk.h> #include <linux/io.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/initval.h> #include <sound/soc.h> #include <mach/hardware.h> #include <mach/ep93xx-regs.h> #include <mach/dma.h> #include "ep93xx-pcm.h" #define EP93XX_I2S_TXCLKCFG 0x00 #define EP93XX_I2S_RXCLKCFG 0x04 #define EP93XX_I2S_GLCTRL 0x0C #define EP93XX_I2S_TXLINCTRLDATA 0x28 #define EP93XX_I2S_TXCTRL 0x2C #define EP93XX_I2S_TXWRDLEN 0x30 #define EP93XX_I2S_TX0EN 0x34 #define EP93XX_I2S_RXLINCTRLDATA 0x58 #define EP93XX_I2S_RXCTRL 0x5C #define EP93XX_I2S_RXWRDLEN 0x60 #define EP93XX_I2S_RX0EN 0x64 #define EP93XX_I2S_WRDLEN_16 (0 << 0) #define EP93XX_I2S_WRDLEN_24 (1 << 0) #define EP93XX_I2S_WRDLEN_32 (2 << 0) #define EP93XX_I2S_LINCTRLDATA_R_JUST (1 << 2) /* Right justify */ #define EP93XX_I2S_CLKCFG_LRS (1 << 0) /* lrclk polarity */ #define EP93XX_I2S_CLKCFG_CKP (1 << 1) /* Bit clock polarity */ #define EP93XX_I2S_CLKCFG_REL (1 << 2) /* First bit transition */ #define EP93XX_I2S_CLKCFG_MASTER (1 << 3) /* Master mode */ #define EP93XX_I2S_CLKCFG_NBCG (1 << 4) /* Not bit clock gating */ struct ep93xx_i2s_info { struct clk *mclk; struct clk *sclk; struct clk *lrclk; struct ep93xx_pcm_dma_params *dma_params; struct resource *mem; void __iomem *regs; }; struct ep93xx_pcm_dma_params ep93xx_i2s_dma_params[] = { [SNDRV_PCM_STREAM_PLAYBACK] = { .name = "i2s-pcm-out", .dma_port = EP93XX_DMA_M2P_PORT_I2S1, }, [SNDRV_PCM_STREAM_CAPTURE] = { .name = "i2s-pcm-in", .dma_port = EP93XX_DMA_M2P_PORT_I2S1, }, }; static inline void ep93xx_i2s_write_reg(struct ep93xx_i2s_info *info, unsigned reg, unsigned val) { __raw_writel(val, info->regs + reg); } static inline unsigned ep93xx_i2s_read_reg(struct ep93xx_i2s_info *info, unsigned reg) { return __raw_readl(info->regs + reg); } static void ep93xx_i2s_enable(struct ep93xx_i2s_info *info, int stream) { unsigned base_reg; int i; if ((ep93xx_i2s_read_reg(info, EP93XX_I2S_TX0EN) & 0x1) == 0 && (ep93xx_i2s_read_reg(info, EP93XX_I2S_RX0EN) & 0x1) == 0) { /* Enable clocks */ clk_enable(info->mclk); clk_enable(info->sclk); clk_enable(info->lrclk); /* Enable i2s */ ep93xx_i2s_write_reg(info, EP93XX_I2S_GLCTRL, 1); } /* Enable fifos */ if (stream == SNDRV_PCM_STREAM_PLAYBACK) base_reg = EP93XX_I2S_TX0EN; else base_reg = EP93XX_I2S_RX0EN; for (i = 0; i < 3; i++) ep93xx_i2s_write_reg(info, base_reg + (i * 4), 1); } static void ep93xx_i2s_disable(struct ep93xx_i2s_info *info, int stream) { unsigned base_reg; int i; /* Disable fifos */ if (stream == SNDRV_PCM_STREAM_PLAYBACK) base_reg = EP93XX_I2S_TX0EN; else base_reg = EP93XX_I2S_RX0EN; for (i = 0; i < 3; i++) ep93xx_i2s_write_reg(info, base_reg + (i * 4), 0); if ((ep93xx_i2s_read_reg(info, EP93XX_I2S_TX0EN) & 0x1) == 0 && (ep93xx_i2s_read_reg(info, EP93XX_I2S_RX0EN) & 0x1) == 0) { /* Disable i2s */ ep93xx_i2s_write_reg(info, EP93XX_I2S_GLCTRL, 0); /* Disable clocks */ clk_disable(info->lrclk); clk_disable(info->sclk); clk_disable(info->mclk); } } static int ep93xx_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); struct snd_soc_dai *cpu_dai = rtd->cpu_dai; snd_soc_dai_set_dma_data(cpu_dai, substream, &info->dma_params[substream->stream]); return 0; } static void ep93xx_i2s_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); ep93xx_i2s_disable(info, substream->stream); } static int ep93xx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) { struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(cpu_dai); unsigned int clk_cfg, lin_ctrl; clk_cfg = ep93xx_i2s_read_reg(info, EP93XX_I2S_RXCLKCFG); lin_ctrl = ep93xx_i2s_read_reg(info, EP93XX_I2S_RXLINCTRLDATA); switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: clk_cfg |= EP93XX_I2S_CLKCFG_REL; lin_ctrl &= ~EP93XX_I2S_LINCTRLDATA_R_JUST; break; case SND_SOC_DAIFMT_LEFT_J: clk_cfg &= ~EP93XX_I2S_CLKCFG_REL; lin_ctrl &= ~EP93XX_I2S_LINCTRLDATA_R_JUST; break; case SND_SOC_DAIFMT_RIGHT_J: clk_cfg &= ~EP93XX_I2S_CLKCFG_REL; lin_ctrl |= EP93XX_I2S_LINCTRLDATA_R_JUST; break; default: return -EINVAL; } switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* CPU is master */ clk_cfg |= EP93XX_I2S_CLKCFG_MASTER; break; case SND_SOC_DAIFMT_CBM_CFM: /* Codec is master */ clk_cfg &= ~EP93XX_I2S_CLKCFG_MASTER; break; default: return -EINVAL; } switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_NB_NF: /* Negative bit clock, lrclk low on left word */ clk_cfg &= ~(EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_REL); break; case SND_SOC_DAIFMT_NB_IF: /* Negative bit clock, lrclk low on right word */ clk_cfg &= ~EP93XX_I2S_CLKCFG_CKP; clk_cfg |= EP93XX_I2S_CLKCFG_REL; break; case SND_SOC_DAIFMT_IB_NF: /* Positive bit clock, lrclk low on left word */ clk_cfg |= EP93XX_I2S_CLKCFG_CKP; clk_cfg &= ~EP93XX_I2S_CLKCFG_REL; break; case SND_SOC_DAIFMT_IB_IF: /* Positive bit clock, lrclk low on right word */ clk_cfg |= EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_REL; break; } /* Write new register values */ ep93xx_i2s_write_reg(info, EP93XX_I2S_RXCLKCFG, clk_cfg); ep93xx_i2s_write_reg(info, EP93XX_I2S_TXCLKCFG, clk_cfg); ep93xx_i2s_write_reg(info, EP93XX_I2S_RXLINCTRLDATA, lin_ctrl); ep93xx_i2s_write_reg(info, EP93XX_I2S_TXLINCTRLDATA, lin_ctrl); return 0; } static int ep93xx_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); unsigned word_len, div, sdiv, lrdiv; int err; switch (params_format(params)) { case SNDRV_PCM_FORMAT_S16_LE: word_len = EP93XX_I2S_WRDLEN_16; break; case SNDRV_PCM_FORMAT_S24_LE: word_len = EP93XX_I2S_WRDLEN_24; break; case SNDRV_PCM_FORMAT_S32_LE: word_len = EP93XX_I2S_WRDLEN_32; break; default: return -EINVAL; } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ep93xx_i2s_write_reg(info, EP93XX_I2S_TXWRDLEN, word_len); else ep93xx_i2s_write_reg(info, EP93XX_I2S_RXWRDLEN, word_len); /* * EP93xx I2S module can be setup so SCLK / LRCLK value can be * 32, 64, 128. MCLK / SCLK value can be 2 and 4. * We set LRCLK equal to `rate' and minimum SCLK / LRCLK * value is 64, because our sample size is 32 bit * 2 channels. * I2S standard permits us to transmit more bits than * the codec uses. */ div = clk_get_rate(info->mclk) / params_rate(params); sdiv = 4; if (div > (256 + 512) / 2) { lrdiv = 128; } else { lrdiv = 64; if (div < (128 + 256) / 2) sdiv = 2; } err = clk_set_rate(info->sclk, clk_get_rate(info->mclk) / sdiv); if (err) return err; err = clk_set_rate(info->lrclk, clk_get_rate(info->sclk) / lrdiv); if (err) return err; ep93xx_i2s_enable(info, substream->stream); return 0; } static int ep93xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, unsigned int freq, int dir) { struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(cpu_dai); if (dir == SND_SOC_CLOCK_IN || clk_id != 0) return -EINVAL; return clk_set_rate(info->mclk, freq); } #ifdef CONFIG_PM static int ep93xx_i2s_suspend(struct snd_soc_dai *dai) { struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); if (!dai->active) return 0; ep93xx_i2s_disable(info, SNDRV_PCM_STREAM_PLAYBACK); ep93xx_i2s_disable(info, SNDRV_PCM_STREAM_CAPTURE); return 0; } static int ep93xx_i2s_resume(struct snd_soc_dai *dai) { struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); if (!dai->active) return 0; ep93xx_i2s_enable(info, SNDRV_PCM_STREAM_PLAYBACK); ep93xx_i2s_enable(info, SNDRV_PCM_STREAM_CAPTURE); return 0; } #else #define ep93xx_i2s_suspend NULL #define ep93xx_i2s_resume NULL #endif static struct snd_soc_dai_ops ep93xx_i2s_dai_ops = { .startup = ep93xx_i2s_startup, .shutdown = ep93xx_i2s_shutdown, .hw_params = ep93xx_i2s_hw_params, .set_sysclk = ep93xx_i2s_set_sysclk, .set_fmt = ep93xx_i2s_set_dai_fmt, }; #define EP93XX_I2S_FORMATS (SNDRV_PCM_FMTBIT_S32_LE) static struct snd_soc_dai_driver ep93xx_i2s_dai = { .symmetric_rates= 1, .suspend = ep93xx_i2s_suspend, .resume = ep93xx_i2s_resume, .playback = { .channels_min = 2, .channels_max = 2, .rates = SNDRV_PCM_RATE_8000_192000, .formats = EP93XX_I2S_FORMATS, }, .capture = { .channels_min = 2, .channels_max = 2, .rates = SNDRV_PCM_RATE_8000_192000, .formats = EP93XX_I2S_FORMATS, }, .ops = &ep93xx_i2s_dai_ops, }; static int ep93xx_i2s_probe(struct platform_device *pdev) { struct ep93xx_i2s_info *info; struct resource *res; int err; info = kzalloc(sizeof(struct ep93xx_i2s_info), GFP_KERNEL); if (!info) { err = -ENOMEM; goto fail; } dev_set_drvdata(&pdev->dev, info); info->dma_params = ep93xx_i2s_dma_params; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { err = -ENODEV; goto fail; } info->mem = request_mem_region(res->start, resource_size(res), pdev->name); if (!info->mem) { err = -EBUSY; goto fail; } info->regs = ioremap(info->mem->start, resource_size(info->mem)); if (!info->regs) { err = -ENXIO; goto fail_release_mem; } info->mclk = clk_get(&pdev->dev, "mclk"); if (IS_ERR(info->mclk)) { err = PTR_ERR(info->mclk); goto fail_unmap_mem; } info->sclk = clk_get(&pdev->dev, "sclk"); if (IS_ERR(info->sclk)) { err = PTR_ERR(info->sclk); goto fail_put_mclk; } info->lrclk = clk_get(&pdev->dev, "lrclk"); if (IS_ERR(info->lrclk)) { err = PTR_ERR(info->lrclk); goto fail_put_sclk; } err = snd_soc_register_dai(&pdev->dev, &ep93xx_i2s_dai); if (err) goto fail_put_lrclk; return 0; fail_put_lrclk: clk_put(info->lrclk); fail_put_sclk: clk_put(info->sclk); fail_put_mclk: clk_put(info->mclk); fail_unmap_mem: iounmap(info->regs); fail_release_mem: release_mem_region(info->mem->start, resource_size(info->mem)); kfree(info); fail: return err; } static int __devexit ep93xx_i2s_remove(struct platform_device *pdev) { struct ep93xx_i2s_info *info = dev_get_drvdata(&pdev->dev); snd_soc_unregister_dai(&pdev->dev); clk_put(info->lrclk); clk_put(info->sclk); clk_put(info->mclk); iounmap(info->regs); release_mem_region(info->mem->start, resource_size(info->mem)); kfree(info); return 0; } static struct platform_driver ep93xx_i2s_driver = { .probe = ep93xx_i2s_probe, .remove = __devexit_p(ep93xx_i2s_remove), .driver = { .name = "ep93xx-i2s", .owner = THIS_MODULE, }, }; static int __init ep93xx_i2s_init(void) { return platform_driver_register(&ep93xx_i2s_driver); } static void __exit ep93xx_i2s_exit(void) { platform_driver_unregister(&ep93xx_i2s_driver); } module_init(ep93xx_i2s_init); module_exit(ep93xx_i2s_exit); MODULE_ALIAS("platform:ep93xx-i2s"); MODULE_AUTHOR("Ryan Mallon <ryan@bluewatersys.com>"); MODULE_DESCRIPTION("EP93XX I2S driver"); MODULE_LICENSE("GPL");
{ "pile_set_name": "Github" }
/* * Copyright 2019-2020 Hans-Kristian Arntzen * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SPIRV_CROSS_C_API_H #define SPIRV_CROSS_C_API_H #include <stddef.h> #include "spirv.h" /* * C89-compatible wrapper for SPIRV-Cross' API. * Documentation here is sparse unless the behavior does not map 1:1 with C++ API. * It is recommended to look at the canonical C++ API for more detailed information. */ #ifdef __cplusplus extern "C" { #endif /* Bumped if ABI or API breaks backwards compatibility. */ #define SPVC_C_API_VERSION_MAJOR 0 /* Bumped if APIs or enumerations are added in a backwards compatible way. */ #define SPVC_C_API_VERSION_MINOR 30 /* Bumped if internal implementation details change. */ #define SPVC_C_API_VERSION_PATCH 0 #if !defined(SPVC_PUBLIC_API) #if defined(SPVC_EXPORT_SYMBOLS) /* Exports symbols. Standard C calling convention is used. */ #if defined(__GNUC__) #define SPVC_PUBLIC_API __attribute__((visibility("default"))) #elif defined(_MSC_VER) #define SPVC_PUBLIC_API __declspec(dllexport) #else #define SPVC_PUBLIC_API #endif #else #define SPVC_PUBLIC_API #endif #endif /* * Gets the SPVC_C_API_VERSION_* used to build this library. * Can be used to check for ABI mismatch if so-versioning did not catch it. */ SPVC_PUBLIC_API void spvc_get_version(unsigned *major, unsigned *minor, unsigned *patch); /* Gets a human readable version string to identify which commit a particular binary was created from. */ SPVC_PUBLIC_API const char *spvc_get_commit_revision_and_timestamp(void); /* These types are opaque to the user. */ typedef struct spvc_context_s *spvc_context; typedef struct spvc_parsed_ir_s *spvc_parsed_ir; typedef struct spvc_compiler_s *spvc_compiler; typedef struct spvc_compiler_options_s *spvc_compiler_options; typedef struct spvc_resources_s *spvc_resources; struct spvc_type_s; typedef const struct spvc_type_s *spvc_type; typedef struct spvc_constant_s *spvc_constant; struct spvc_set_s; typedef const struct spvc_set_s *spvc_set; /* * Shallow typedefs. All SPIR-V IDs are plain 32-bit numbers, but this helps communicate which data is used. * Maps to a SPIRType. */ typedef SpvId spvc_type_id; /* Maps to a SPIRVariable. */ typedef SpvId spvc_variable_id; /* Maps to a SPIRConstant. */ typedef SpvId spvc_constant_id; /* See C++ API. */ typedef struct spvc_reflected_resource { spvc_variable_id id; spvc_type_id base_type_id; spvc_type_id type_id; const char *name; } spvc_reflected_resource; /* See C++ API. */ typedef struct spvc_entry_point { SpvExecutionModel execution_model; const char *name; } spvc_entry_point; /* See C++ API. */ typedef struct spvc_combined_image_sampler { spvc_variable_id combined_id; spvc_variable_id image_id; spvc_variable_id sampler_id; } spvc_combined_image_sampler; /* See C++ API. */ typedef struct spvc_specialization_constant { spvc_constant_id id; unsigned constant_id; } spvc_specialization_constant; /* See C++ API. */ typedef struct spvc_buffer_range { unsigned index; size_t offset; size_t range; } spvc_buffer_range; /* See C++ API. */ typedef struct spvc_hlsl_root_constants { unsigned start; unsigned end; unsigned binding; unsigned space; } spvc_hlsl_root_constants; /* See C++ API. */ typedef struct spvc_hlsl_vertex_attribute_remap { unsigned location; const char *semantic; } spvc_hlsl_vertex_attribute_remap; /* * Be compatible with non-C99 compilers, which do not have stdbool. * Only recent MSVC compilers supports this for example, and ideally SPIRV-Cross should be linkable * from a wide range of compilers in its C wrapper. */ typedef unsigned char spvc_bool; #define SPVC_TRUE ((spvc_bool)1) #define SPVC_FALSE ((spvc_bool)0) typedef enum spvc_result { /* Success. */ SPVC_SUCCESS = 0, /* The SPIR-V is invalid. Should have been caught by validation ideally. */ SPVC_ERROR_INVALID_SPIRV = -1, /* The SPIR-V might be valid or invalid, but SPIRV-Cross currently cannot correctly translate this to your target language. */ SPVC_ERROR_UNSUPPORTED_SPIRV = -2, /* If for some reason we hit this, new or malloc failed. */ SPVC_ERROR_OUT_OF_MEMORY = -3, /* Invalid API argument. */ SPVC_ERROR_INVALID_ARGUMENT = -4, SPVC_ERROR_INT_MAX = 0x7fffffff } spvc_result; typedef enum spvc_capture_mode { /* The Parsed IR payload will be copied, and the handle can be reused to create other compiler instances. */ SPVC_CAPTURE_MODE_COPY = 0, /* * The payload will now be owned by the compiler. * parsed_ir should now be considered a dead blob and must not be used further. * This is optimal for performance and should be the go-to option. */ SPVC_CAPTURE_MODE_TAKE_OWNERSHIP = 1, SPVC_CAPTURE_MODE_INT_MAX = 0x7fffffff } spvc_capture_mode; typedef enum spvc_backend { /* This backend can only perform reflection, no compiler options are supported. Maps to spirv_cross::Compiler. */ SPVC_BACKEND_NONE = 0, SPVC_BACKEND_GLSL = 1, /* spirv_cross::CompilerGLSL */ SPVC_BACKEND_HLSL = 2, /* CompilerHLSL */ SPVC_BACKEND_MSL = 3, /* CompilerMSL */ SPVC_BACKEND_CPP = 4, /* CompilerCPP */ SPVC_BACKEND_JSON = 5, /* CompilerReflection w/ JSON backend */ SPVC_BACKEND_INT_MAX = 0x7fffffff } spvc_backend; /* Maps to C++ API. */ typedef enum spvc_resource_type { SPVC_RESOURCE_TYPE_UNKNOWN = 0, SPVC_RESOURCE_TYPE_UNIFORM_BUFFER = 1, SPVC_RESOURCE_TYPE_STORAGE_BUFFER = 2, SPVC_RESOURCE_TYPE_STAGE_INPUT = 3, SPVC_RESOURCE_TYPE_STAGE_OUTPUT = 4, SPVC_RESOURCE_TYPE_SUBPASS_INPUT = 5, SPVC_RESOURCE_TYPE_STORAGE_IMAGE = 6, SPVC_RESOURCE_TYPE_SAMPLED_IMAGE = 7, SPVC_RESOURCE_TYPE_ATOMIC_COUNTER = 8, SPVC_RESOURCE_TYPE_PUSH_CONSTANT = 9, SPVC_RESOURCE_TYPE_SEPARATE_IMAGE = 10, SPVC_RESOURCE_TYPE_SEPARATE_SAMPLERS = 11, SPVC_RESOURCE_TYPE_ACCELERATION_STRUCTURE = 12, SPVC_RESOURCE_TYPE_INT_MAX = 0x7fffffff } spvc_resource_type; /* Maps to spirv_cross::SPIRType::BaseType. */ typedef enum spvc_basetype { SPVC_BASETYPE_UNKNOWN = 0, SPVC_BASETYPE_VOID = 1, SPVC_BASETYPE_BOOLEAN = 2, SPVC_BASETYPE_INT8 = 3, SPVC_BASETYPE_UINT8 = 4, SPVC_BASETYPE_INT16 = 5, SPVC_BASETYPE_UINT16 = 6, SPVC_BASETYPE_INT32 = 7, SPVC_BASETYPE_UINT32 = 8, SPVC_BASETYPE_INT64 = 9, SPVC_BASETYPE_UINT64 = 10, SPVC_BASETYPE_ATOMIC_COUNTER = 11, SPVC_BASETYPE_FP16 = 12, SPVC_BASETYPE_FP32 = 13, SPVC_BASETYPE_FP64 = 14, SPVC_BASETYPE_STRUCT = 15, SPVC_BASETYPE_IMAGE = 16, SPVC_BASETYPE_SAMPLED_IMAGE = 17, SPVC_BASETYPE_SAMPLER = 18, SPVC_BASETYPE_ACCELERATION_STRUCTURE = 19, SPVC_BASETYPE_INT_MAX = 0x7fffffff } spvc_basetype; #define SPVC_COMPILER_OPTION_COMMON_BIT 0x1000000 #define SPVC_COMPILER_OPTION_GLSL_BIT 0x2000000 #define SPVC_COMPILER_OPTION_HLSL_BIT 0x4000000 #define SPVC_COMPILER_OPTION_MSL_BIT 0x8000000 #define SPVC_COMPILER_OPTION_LANG_BITS 0x0f000000 #define SPVC_COMPILER_OPTION_ENUM_BITS 0xffffff #define SPVC_MAKE_MSL_VERSION(major, minor, patch) ((major) * 10000 + (minor) * 100 + (patch)) /* Maps to C++ API. */ typedef enum spvc_msl_platform { SPVC_MSL_PLATFORM_IOS = 0, SPVC_MSL_PLATFORM_MACOS = 1, SPVC_MSL_PLATFORM_MAX_INT = 0x7fffffff } spvc_msl_platform; /* Maps to C++ API. */ typedef enum spvc_msl_vertex_format { SPVC_MSL_VERTEX_FORMAT_OTHER = 0, SPVC_MSL_VERTEX_FORMAT_UINT8 = 1, SPVC_MSL_VERTEX_FORMAT_UINT16 = 2 } spvc_msl_vertex_format; /* Maps to C++ API. */ typedef struct spvc_msl_vertex_attribute { unsigned location; unsigned msl_buffer; unsigned msl_offset; unsigned msl_stride; spvc_bool per_instance; spvc_msl_vertex_format format; SpvBuiltIn builtin; } spvc_msl_vertex_attribute; /* * Initializes the vertex attribute struct. */ SPVC_PUBLIC_API void spvc_msl_vertex_attribute_init(spvc_msl_vertex_attribute *attr); /* Maps to C++ API. */ typedef struct spvc_msl_resource_binding { SpvExecutionModel stage; unsigned desc_set; unsigned binding; unsigned msl_buffer; unsigned msl_texture; unsigned msl_sampler; } spvc_msl_resource_binding; /* * Initializes the resource binding struct. * The defaults are non-zero. */ SPVC_PUBLIC_API void spvc_msl_resource_binding_init(spvc_msl_resource_binding *binding); #define SPVC_MSL_PUSH_CONSTANT_DESC_SET (~(0u)) #define SPVC_MSL_PUSH_CONSTANT_BINDING (0) #define SPVC_MSL_SWIZZLE_BUFFER_BINDING (~(1u)) #define SPVC_MSL_BUFFER_SIZE_BUFFER_BINDING (~(2u)) #define SPVC_MSL_ARGUMENT_BUFFER_BINDING (~(3u)) /* Obsolete. Sticks around for backwards compatibility. */ #define SPVC_MSL_AUX_BUFFER_STRUCT_VERSION 1 /* Runtime check for incompatibility. Obsolete. */ SPVC_PUBLIC_API unsigned spvc_msl_get_aux_buffer_struct_version(void); /* Maps to C++ API. */ typedef enum spvc_msl_sampler_coord { SPVC_MSL_SAMPLER_COORD_NORMALIZED = 0, SPVC_MSL_SAMPLER_COORD_PIXEL = 1, SPVC_MSL_SAMPLER_INT_MAX = 0x7fffffff } spvc_msl_sampler_coord; /* Maps to C++ API. */ typedef enum spvc_msl_sampler_filter { SPVC_MSL_SAMPLER_FILTER_NEAREST = 0, SPVC_MSL_SAMPLER_FILTER_LINEAR = 1, SPVC_MSL_SAMPLER_FILTER_INT_MAX = 0x7fffffff } spvc_msl_sampler_filter; /* Maps to C++ API. */ typedef enum spvc_msl_sampler_mip_filter { SPVC_MSL_SAMPLER_MIP_FILTER_NONE = 0, SPVC_MSL_SAMPLER_MIP_FILTER_NEAREST = 1, SPVC_MSL_SAMPLER_MIP_FILTER_LINEAR = 2, SPVC_MSL_SAMPLER_MIP_FILTER_INT_MAX = 0x7fffffff } spvc_msl_sampler_mip_filter; /* Maps to C++ API. */ typedef enum spvc_msl_sampler_address { SPVC_MSL_SAMPLER_ADDRESS_CLAMP_TO_ZERO = 0, SPVC_MSL_SAMPLER_ADDRESS_CLAMP_TO_EDGE = 1, SPVC_MSL_SAMPLER_ADDRESS_CLAMP_TO_BORDER = 2, SPVC_MSL_SAMPLER_ADDRESS_REPEAT = 3, SPVC_MSL_SAMPLER_ADDRESS_MIRRORED_REPEAT = 4, SPVC_MSL_SAMPLER_ADDRESS_INT_MAX = 0x7fffffff } spvc_msl_sampler_address; /* Maps to C++ API. */ typedef enum spvc_msl_sampler_compare_func { SPVC_MSL_SAMPLER_COMPARE_FUNC_NEVER = 0, SPVC_MSL_SAMPLER_COMPARE_FUNC_LESS = 1, SPVC_MSL_SAMPLER_COMPARE_FUNC_LESS_EQUAL = 2, SPVC_MSL_SAMPLER_COMPARE_FUNC_GREATER = 3, SPVC_MSL_SAMPLER_COMPARE_FUNC_GREATER_EQUAL = 4, SPVC_MSL_SAMPLER_COMPARE_FUNC_EQUAL = 5, SPVC_MSL_SAMPLER_COMPARE_FUNC_NOT_EQUAL = 6, SPVC_MSL_SAMPLER_COMPARE_FUNC_ALWAYS = 7, SPVC_MSL_SAMPLER_COMPARE_FUNC_INT_MAX = 0x7fffffff } spvc_msl_sampler_compare_func; /* Maps to C++ API. */ typedef enum spvc_msl_sampler_border_color { SPVC_MSL_SAMPLER_BORDER_COLOR_TRANSPARENT_BLACK = 0, SPVC_MSL_SAMPLER_BORDER_COLOR_OPAQUE_BLACK = 1, SPVC_MSL_SAMPLER_BORDER_COLOR_OPAQUE_WHITE = 2, SPVC_MSL_SAMPLER_BORDER_COLOR_INT_MAX = 0x7fffffff } spvc_msl_sampler_border_color; /* Maps to C++ API. */ typedef enum spvc_msl_format_resolution { SPVC_MSL_FORMAT_RESOLUTION_444 = 0, SPVC_MSL_FORMAT_RESOLUTION_422, SPVC_MSL_FORMAT_RESOLUTION_420, SPVC_MSL_FORMAT_RESOLUTION_INT_MAX = 0x7fffffff } spvc_msl_format_resolution; /* Maps to C++ API. */ typedef enum spvc_msl_chroma_location { SPVC_MSL_CHROMA_LOCATION_COSITED_EVEN = 0, SPVC_MSL_CHROMA_LOCATION_MIDPOINT, SPVC_MSL_CHROMA_LOCATION_INT_MAX = 0x7fffffff } spvc_msl_chroma_location; /* Maps to C++ API. */ typedef enum spvc_msl_component_swizzle { SPVC_MSL_COMPONENT_SWIZZLE_IDENTITY = 0, SPVC_MSL_COMPONENT_SWIZZLE_ZERO, SPVC_MSL_COMPONENT_SWIZZLE_ONE, SPVC_MSL_COMPONENT_SWIZZLE_R, SPVC_MSL_COMPONENT_SWIZZLE_G, SPVC_MSL_COMPONENT_SWIZZLE_B, SPVC_MSL_COMPONENT_SWIZZLE_A, SPVC_MSL_COMPONENT_SWIZZLE_INT_MAX = 0x7fffffff } spvc_msl_component_swizzle; /* Maps to C++ API. */ typedef enum spvc_msl_sampler_ycbcr_model_conversion { SPVC_MSL_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY = 0, SPVC_MSL_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY, SPVC_MSL_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_BT_709, SPVC_MSL_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_BT_601, SPVC_MSL_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_BT_2020, SPVC_MSL_SAMPLER_YCBCR_MODEL_CONVERSION_INT_MAX = 0x7fffffff } spvc_msl_sampler_ycbcr_model_conversion; /* Maps to C+ API. */ typedef enum spvc_msl_sampler_ycbcr_range { SPVC_MSL_SAMPLER_YCBCR_RANGE_ITU_FULL = 0, SPVC_MSL_SAMPLER_YCBCR_RANGE_ITU_NARROW, SPVC_MSL_SAMPLER_YCBCR_RANGE_INT_MAX = 0x7fffffff } spvc_msl_sampler_ycbcr_range; /* Maps to C++ API. */ typedef struct spvc_msl_constexpr_sampler { spvc_msl_sampler_coord coord; spvc_msl_sampler_filter min_filter; spvc_msl_sampler_filter mag_filter; spvc_msl_sampler_mip_filter mip_filter; spvc_msl_sampler_address s_address; spvc_msl_sampler_address t_address; spvc_msl_sampler_address r_address; spvc_msl_sampler_compare_func compare_func; spvc_msl_sampler_border_color border_color; float lod_clamp_min; float lod_clamp_max; int max_anisotropy; spvc_bool compare_enable; spvc_bool lod_clamp_enable; spvc_bool anisotropy_enable; } spvc_msl_constexpr_sampler; /* * Initializes the constexpr sampler struct. * The defaults are non-zero. */ SPVC_PUBLIC_API void spvc_msl_constexpr_sampler_init(spvc_msl_constexpr_sampler *sampler); /* Maps to the sampler Y'CbCr conversion-related portions of MSLConstexprSampler. See C++ API for defaults and details. */ typedef struct spvc_msl_sampler_ycbcr_conversion { unsigned planes; spvc_msl_format_resolution resolution; spvc_msl_sampler_filter chroma_filter; spvc_msl_chroma_location x_chroma_offset; spvc_msl_chroma_location y_chroma_offset; spvc_msl_component_swizzle swizzle[4]; spvc_msl_sampler_ycbcr_model_conversion ycbcr_model; spvc_msl_sampler_ycbcr_range ycbcr_range; unsigned bpc; } spvc_msl_sampler_ycbcr_conversion; /* * Initializes the constexpr sampler struct. * The defaults are non-zero. */ SPVC_PUBLIC_API void spvc_msl_sampler_ycbcr_conversion_init(spvc_msl_sampler_ycbcr_conversion *conv); /* Maps to C++ API. */ typedef enum spvc_hlsl_binding_flag_bits { SPVC_HLSL_BINDING_AUTO_NONE_BIT = 0, SPVC_HLSL_BINDING_AUTO_PUSH_CONSTANT_BIT = 1 << 0, SPVC_HLSL_BINDING_AUTO_CBV_BIT = 1 << 1, SPVC_HLSL_BINDING_AUTO_SRV_BIT = 1 << 2, SPVC_HLSL_BINDING_AUTO_UAV_BIT = 1 << 3, SPVC_HLSL_BINDING_AUTO_SAMPLER_BIT = 1 << 4, SPVC_HLSL_BINDING_AUTO_ALL = 0x7fffffff } spvc_hlsl_binding_flag_bits; typedef unsigned spvc_hlsl_binding_flags; #define SPVC_HLSL_PUSH_CONSTANT_DESC_SET (~(0u)) #define SPVC_HLSL_PUSH_CONSTANT_BINDING (0) /* Maps to C++ API. */ typedef struct spvc_hlsl_resource_binding_mapping { unsigned register_space; unsigned register_binding; } spvc_hlsl_resource_binding_mapping; typedef struct spvc_hlsl_resource_binding { SpvExecutionModel stage; unsigned desc_set; unsigned binding; spvc_hlsl_resource_binding_mapping cbv, uav, srv, sampler; } spvc_hlsl_resource_binding; /* * Initializes the resource binding struct. * The defaults are non-zero. */ SPVC_PUBLIC_API void spvc_hlsl_resource_binding_init(spvc_hlsl_resource_binding *binding); /* Maps to the various spirv_cross::Compiler*::Option structures. See C++ API for defaults and details. */ typedef enum spvc_compiler_option { SPVC_COMPILER_OPTION_UNKNOWN = 0, SPVC_COMPILER_OPTION_FORCE_TEMPORARY = 1 | SPVC_COMPILER_OPTION_COMMON_BIT, SPVC_COMPILER_OPTION_FLATTEN_MULTIDIMENSIONAL_ARRAYS = 2 | SPVC_COMPILER_OPTION_COMMON_BIT, SPVC_COMPILER_OPTION_FIXUP_DEPTH_CONVENTION = 3 | SPVC_COMPILER_OPTION_COMMON_BIT, SPVC_COMPILER_OPTION_FLIP_VERTEX_Y = 4 | SPVC_COMPILER_OPTION_COMMON_BIT, SPVC_COMPILER_OPTION_GLSL_SUPPORT_NONZERO_BASE_INSTANCE = 5 | SPVC_COMPILER_OPTION_GLSL_BIT, SPVC_COMPILER_OPTION_GLSL_SEPARATE_SHADER_OBJECTS = 6 | SPVC_COMPILER_OPTION_GLSL_BIT, SPVC_COMPILER_OPTION_GLSL_ENABLE_420PACK_EXTENSION = 7 | SPVC_COMPILER_OPTION_GLSL_BIT, SPVC_COMPILER_OPTION_GLSL_VERSION = 8 | SPVC_COMPILER_OPTION_GLSL_BIT, SPVC_COMPILER_OPTION_GLSL_ES = 9 | SPVC_COMPILER_OPTION_GLSL_BIT, SPVC_COMPILER_OPTION_GLSL_VULKAN_SEMANTICS = 10 | SPVC_COMPILER_OPTION_GLSL_BIT, SPVC_COMPILER_OPTION_GLSL_ES_DEFAULT_FLOAT_PRECISION_HIGHP = 11 | SPVC_COMPILER_OPTION_GLSL_BIT, SPVC_COMPILER_OPTION_GLSL_ES_DEFAULT_INT_PRECISION_HIGHP = 12 | SPVC_COMPILER_OPTION_GLSL_BIT, SPVC_COMPILER_OPTION_HLSL_SHADER_MODEL = 13 | SPVC_COMPILER_OPTION_HLSL_BIT, SPVC_COMPILER_OPTION_HLSL_POINT_SIZE_COMPAT = 14 | SPVC_COMPILER_OPTION_HLSL_BIT, SPVC_COMPILER_OPTION_HLSL_POINT_COORD_COMPAT = 15 | SPVC_COMPILER_OPTION_HLSL_BIT, SPVC_COMPILER_OPTION_HLSL_SUPPORT_NONZERO_BASE_VERTEX_BASE_INSTANCE = 16 | SPVC_COMPILER_OPTION_HLSL_BIT, SPVC_COMPILER_OPTION_MSL_VERSION = 17 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_TEXEL_BUFFER_TEXTURE_WIDTH = 18 | SPVC_COMPILER_OPTION_MSL_BIT, /* Obsolete, use SWIZZLE_BUFFER_INDEX instead. */ SPVC_COMPILER_OPTION_MSL_AUX_BUFFER_INDEX = 19 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_SWIZZLE_BUFFER_INDEX = 19 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_INDIRECT_PARAMS_BUFFER_INDEX = 20 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_SHADER_OUTPUT_BUFFER_INDEX = 21 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_SHADER_PATCH_OUTPUT_BUFFER_INDEX = 22 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_SHADER_TESS_FACTOR_OUTPUT_BUFFER_INDEX = 23 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_SHADER_INPUT_WORKGROUP_INDEX = 24 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_ENABLE_POINT_SIZE_BUILTIN = 25 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_DISABLE_RASTERIZATION = 26 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_CAPTURE_OUTPUT_TO_BUFFER = 27 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_SWIZZLE_TEXTURE_SAMPLES = 28 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_PAD_FRAGMENT_OUTPUT_COMPONENTS = 29 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_TESS_DOMAIN_ORIGIN_LOWER_LEFT = 30 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_PLATFORM = 31 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_ARGUMENT_BUFFERS = 32 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_GLSL_EMIT_PUSH_CONSTANT_AS_UNIFORM_BUFFER = 33 | SPVC_COMPILER_OPTION_GLSL_BIT, SPVC_COMPILER_OPTION_MSL_TEXTURE_BUFFER_NATIVE = 34 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_GLSL_EMIT_UNIFORM_BUFFER_AS_PLAIN_UNIFORMS = 35 | SPVC_COMPILER_OPTION_GLSL_BIT, SPVC_COMPILER_OPTION_MSL_BUFFER_SIZE_BUFFER_INDEX = 36 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_EMIT_LINE_DIRECTIVES = 37 | SPVC_COMPILER_OPTION_COMMON_BIT, SPVC_COMPILER_OPTION_MSL_MULTIVIEW = 38 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_VIEW_MASK_BUFFER_INDEX = 39 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_DEVICE_INDEX = 40 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_VIEW_INDEX_FROM_DEVICE_INDEX = 41 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_DISPATCH_BASE = 42 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_DYNAMIC_OFFSETS_BUFFER_INDEX = 43 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_TEXTURE_1D_AS_2D = 44 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_ENABLE_BASE_INDEX_ZERO = 45 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_IOS_FRAMEBUFFER_FETCH_SUBPASS = 46 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_INVARIANT_FP_MATH = 47 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_EMULATE_CUBEMAP_ARRAY = 48 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_ENABLE_DECORATION_BINDING = 49 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_FORCE_ACTIVE_ARGUMENT_BUFFER_RESOURCES = 50 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_FORCE_NATIVE_ARRAYS = 51 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_ENABLE_STORAGE_IMAGE_QUALIFIER_DEDUCTION = 52 | SPVC_COMPILER_OPTION_COMMON_BIT, SPVC_COMPILER_OPTION_HLSL_FORCE_STORAGE_BUFFER_AS_UAV = 53 | SPVC_COMPILER_OPTION_HLSL_BIT, SPVC_COMPILER_OPTION_FORCE_ZERO_INITIALIZED_VARIABLES = 54 | SPVC_COMPILER_OPTION_COMMON_BIT, SPVC_COMPILER_OPTION_HLSL_NONWRITABLE_UAV_TEXTURE_AS_SRV = 55 | SPVC_COMPILER_OPTION_HLSL_BIT, SPVC_COMPILER_OPTION_INT_MAX = 0x7fffffff } spvc_compiler_option; /* * Context is the highest-level API construct. * The context owns all memory allocations made by its child object hierarchy, including various non-opaque structs and strings. * This means that the API user only has to care about one "destroy" call ever when using the C API. * All pointers handed out by the APIs are only valid as long as the context * is alive and spvc_context_release_allocations has not been called. */ SPVC_PUBLIC_API spvc_result spvc_context_create(spvc_context *context); /* Frees all memory allocations and objects associated with the context and its child objects. */ SPVC_PUBLIC_API void spvc_context_destroy(spvc_context context); /* Frees all memory allocations and objects associated with the context and its child objects, but keeps the context alive. */ SPVC_PUBLIC_API void spvc_context_release_allocations(spvc_context context); /* Get the string for the last error which was logged. */ SPVC_PUBLIC_API const char *spvc_context_get_last_error_string(spvc_context context); /* Get notified in a callback when an error triggers. Useful for debugging. */ typedef void (*spvc_error_callback)(void *userdata, const char *error); SPVC_PUBLIC_API void spvc_context_set_error_callback(spvc_context context, spvc_error_callback cb, void *userdata); /* SPIR-V parsing interface. Maps to Parser which then creates a ParsedIR, and that IR is extracted into the handle. */ SPVC_PUBLIC_API spvc_result spvc_context_parse_spirv(spvc_context context, const SpvId *spirv, size_t word_count, spvc_parsed_ir *parsed_ir); /* * Create a compiler backend. Capture mode controls if we construct by copy or move semantics. * It is always recommended to use SPVC_CAPTURE_MODE_TAKE_OWNERSHIP if you only intend to cross-compile the IR once. */ SPVC_PUBLIC_API spvc_result spvc_context_create_compiler(spvc_context context, spvc_backend backend, spvc_parsed_ir parsed_ir, spvc_capture_mode mode, spvc_compiler *compiler); /* Maps directly to C++ API. */ SPVC_PUBLIC_API unsigned spvc_compiler_get_current_id_bound(spvc_compiler compiler); /* Create compiler options, which will initialize defaults. */ SPVC_PUBLIC_API spvc_result spvc_compiler_create_compiler_options(spvc_compiler compiler, spvc_compiler_options *options); /* Override options. Will return error if e.g. MSL options are used for the HLSL backend, etc. */ SPVC_PUBLIC_API spvc_result spvc_compiler_options_set_bool(spvc_compiler_options options, spvc_compiler_option option, spvc_bool value); SPVC_PUBLIC_API spvc_result spvc_compiler_options_set_uint(spvc_compiler_options options, spvc_compiler_option option, unsigned value); /* Set compiler options. */ SPVC_PUBLIC_API spvc_result spvc_compiler_install_compiler_options(spvc_compiler compiler, spvc_compiler_options options); /* Compile IR into a string. *source is owned by the context, and caller must not free it themselves. */ SPVC_PUBLIC_API spvc_result spvc_compiler_compile(spvc_compiler compiler, const char **source); /* Maps to C++ API. */ SPVC_PUBLIC_API spvc_result spvc_compiler_add_header_line(spvc_compiler compiler, const char *line); SPVC_PUBLIC_API spvc_result spvc_compiler_require_extension(spvc_compiler compiler, const char *ext); SPVC_PUBLIC_API spvc_result spvc_compiler_flatten_buffer_block(spvc_compiler compiler, spvc_variable_id id); SPVC_PUBLIC_API spvc_bool spvc_compiler_variable_is_depth_or_compare(spvc_compiler compiler, spvc_variable_id id); /* * HLSL specifics. * Maps to C++ API. */ SPVC_PUBLIC_API spvc_result spvc_compiler_hlsl_set_root_constants_layout(spvc_compiler compiler, const spvc_hlsl_root_constants *constant_info, size_t count); SPVC_PUBLIC_API spvc_result spvc_compiler_hlsl_add_vertex_attribute_remap(spvc_compiler compiler, const spvc_hlsl_vertex_attribute_remap *remap, size_t remaps); SPVC_PUBLIC_API spvc_variable_id spvc_compiler_hlsl_remap_num_workgroups_builtin(spvc_compiler compiler); SPVC_PUBLIC_API spvc_result spvc_compiler_hlsl_set_resource_binding_flags(spvc_compiler compiler, spvc_hlsl_binding_flags flags); SPVC_PUBLIC_API spvc_result spvc_compiler_hlsl_add_resource_binding(spvc_compiler compiler, const spvc_hlsl_resource_binding *binding); SPVC_PUBLIC_API spvc_bool spvc_compiler_hlsl_is_resource_used(spvc_compiler compiler, SpvExecutionModel model, unsigned set, unsigned binding); /* * MSL specifics. * Maps to C++ API. */ SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_rasterization_disabled(spvc_compiler compiler); /* Obsolete. Renamed to needs_swizzle_buffer. */ SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_aux_buffer(spvc_compiler compiler); SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_swizzle_buffer(spvc_compiler compiler); SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_buffer_size_buffer(spvc_compiler compiler); SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_output_buffer(spvc_compiler compiler); SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_patch_output_buffer(spvc_compiler compiler); SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_input_threadgroup_mem(spvc_compiler compiler); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_vertex_attribute(spvc_compiler compiler, const spvc_msl_vertex_attribute *attrs); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_resource_binding(spvc_compiler compiler, const spvc_msl_resource_binding *binding); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_discrete_descriptor_set(spvc_compiler compiler, unsigned desc_set); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_set_argument_buffer_device_address_space(spvc_compiler compiler, unsigned desc_set, spvc_bool device_address); SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_vertex_attribute_used(spvc_compiler compiler, unsigned location); SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_resource_used(spvc_compiler compiler, SpvExecutionModel model, unsigned set, unsigned binding); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_remap_constexpr_sampler(spvc_compiler compiler, spvc_variable_id id, const spvc_msl_constexpr_sampler *sampler); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_remap_constexpr_sampler_by_binding(spvc_compiler compiler, unsigned desc_set, unsigned binding, const spvc_msl_constexpr_sampler *sampler); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_remap_constexpr_sampler_ycbcr(spvc_compiler compiler, spvc_variable_id id, const spvc_msl_constexpr_sampler *sampler, const spvc_msl_sampler_ycbcr_conversion *conv); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_remap_constexpr_sampler_by_binding_ycbcr(spvc_compiler compiler, unsigned desc_set, unsigned binding, const spvc_msl_constexpr_sampler *sampler, const spvc_msl_sampler_ycbcr_conversion *conv); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_set_fragment_output_components(spvc_compiler compiler, unsigned location, unsigned components); SPVC_PUBLIC_API unsigned spvc_compiler_msl_get_automatic_resource_binding(spvc_compiler compiler, spvc_variable_id id); SPVC_PUBLIC_API unsigned spvc_compiler_msl_get_automatic_resource_binding_secondary(spvc_compiler compiler, spvc_variable_id id); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_dynamic_buffer(spvc_compiler compiler, unsigned desc_set, unsigned binding, unsigned index); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_inline_uniform_block(spvc_compiler compiler, unsigned desc_set, unsigned binding); /* * Reflect resources. * Maps almost 1:1 to C++ API. */ SPVC_PUBLIC_API spvc_result spvc_compiler_get_active_interface_variables(spvc_compiler compiler, spvc_set *set); SPVC_PUBLIC_API spvc_result spvc_compiler_set_enabled_interface_variables(spvc_compiler compiler, spvc_set set); SPVC_PUBLIC_API spvc_result spvc_compiler_create_shader_resources(spvc_compiler compiler, spvc_resources *resources); SPVC_PUBLIC_API spvc_result spvc_compiler_create_shader_resources_for_active_variables(spvc_compiler compiler, spvc_resources *resources, spvc_set active); SPVC_PUBLIC_API spvc_result spvc_resources_get_resource_list_for_type(spvc_resources resources, spvc_resource_type type, const spvc_reflected_resource **resource_list, size_t *resource_size); /* * Decorations. * Maps to C++ API. */ SPVC_PUBLIC_API void spvc_compiler_set_decoration(spvc_compiler compiler, SpvId id, SpvDecoration decoration, unsigned argument); SPVC_PUBLIC_API void spvc_compiler_set_decoration_string(spvc_compiler compiler, SpvId id, SpvDecoration decoration, const char *argument); SPVC_PUBLIC_API void spvc_compiler_set_name(spvc_compiler compiler, SpvId id, const char *argument); SPVC_PUBLIC_API void spvc_compiler_set_member_decoration(spvc_compiler compiler, spvc_type_id id, unsigned member_index, SpvDecoration decoration, unsigned argument); SPVC_PUBLIC_API void spvc_compiler_set_member_decoration_string(spvc_compiler compiler, spvc_type_id id, unsigned member_index, SpvDecoration decoration, const char *argument); SPVC_PUBLIC_API void spvc_compiler_set_member_name(spvc_compiler compiler, spvc_type_id id, unsigned member_index, const char *argument); SPVC_PUBLIC_API void spvc_compiler_unset_decoration(spvc_compiler compiler, SpvId id, SpvDecoration decoration); SPVC_PUBLIC_API void spvc_compiler_unset_member_decoration(spvc_compiler compiler, spvc_type_id id, unsigned member_index, SpvDecoration decoration); SPVC_PUBLIC_API spvc_bool spvc_compiler_has_decoration(spvc_compiler compiler, SpvId id, SpvDecoration decoration); SPVC_PUBLIC_API spvc_bool spvc_compiler_has_member_decoration(spvc_compiler compiler, spvc_type_id id, unsigned member_index, SpvDecoration decoration); SPVC_PUBLIC_API const char *spvc_compiler_get_name(spvc_compiler compiler, SpvId id); SPVC_PUBLIC_API unsigned spvc_compiler_get_decoration(spvc_compiler compiler, SpvId id, SpvDecoration decoration); SPVC_PUBLIC_API const char *spvc_compiler_get_decoration_string(spvc_compiler compiler, SpvId id, SpvDecoration decoration); SPVC_PUBLIC_API unsigned spvc_compiler_get_member_decoration(spvc_compiler compiler, spvc_type_id id, unsigned member_index, SpvDecoration decoration); SPVC_PUBLIC_API const char *spvc_compiler_get_member_decoration_string(spvc_compiler compiler, spvc_type_id id, unsigned member_index, SpvDecoration decoration); SPVC_PUBLIC_API const char *spvc_compiler_get_member_name(spvc_compiler compiler, spvc_type_id id, unsigned member_index); /* * Entry points. * Maps to C++ API. */ SPVC_PUBLIC_API spvc_result spvc_compiler_get_entry_points(spvc_compiler compiler, const spvc_entry_point **entry_points, size_t *num_entry_points); SPVC_PUBLIC_API spvc_result spvc_compiler_set_entry_point(spvc_compiler compiler, const char *name, SpvExecutionModel model); SPVC_PUBLIC_API spvc_result spvc_compiler_rename_entry_point(spvc_compiler compiler, const char *old_name, const char *new_name, SpvExecutionModel model); SPVC_PUBLIC_API const char *spvc_compiler_get_cleansed_entry_point_name(spvc_compiler compiler, const char *name, SpvExecutionModel model); SPVC_PUBLIC_API void spvc_compiler_set_execution_mode(spvc_compiler compiler, SpvExecutionMode mode); SPVC_PUBLIC_API void spvc_compiler_unset_execution_mode(spvc_compiler compiler, SpvExecutionMode mode); SPVC_PUBLIC_API void spvc_compiler_set_execution_mode_with_arguments(spvc_compiler compiler, SpvExecutionMode mode, unsigned arg0, unsigned arg1, unsigned arg2); SPVC_PUBLIC_API spvc_result spvc_compiler_get_execution_modes(spvc_compiler compiler, const SpvExecutionMode **modes, size_t *num_modes); SPVC_PUBLIC_API unsigned spvc_compiler_get_execution_mode_argument(spvc_compiler compiler, SpvExecutionMode mode); SPVC_PUBLIC_API unsigned spvc_compiler_get_execution_mode_argument_by_index(spvc_compiler compiler, SpvExecutionMode mode, unsigned index); SPVC_PUBLIC_API SpvExecutionModel spvc_compiler_get_execution_model(spvc_compiler compiler); /* * Type query interface. * Maps to C++ API, except it's read-only. */ SPVC_PUBLIC_API spvc_type spvc_compiler_get_type_handle(spvc_compiler compiler, spvc_type_id id); /* Pulls out SPIRType::self. This effectively gives the type ID without array or pointer qualifiers. * This is necessary when reflecting decoration/name information on members of a struct, * which are placed in the base type, not the qualified type. * This is similar to spvc_reflected_resource::base_type_id. */ SPVC_PUBLIC_API spvc_type_id spvc_type_get_base_type_id(spvc_type type); SPVC_PUBLIC_API spvc_basetype spvc_type_get_basetype(spvc_type type); SPVC_PUBLIC_API unsigned spvc_type_get_bit_width(spvc_type type); SPVC_PUBLIC_API unsigned spvc_type_get_vector_size(spvc_type type); SPVC_PUBLIC_API unsigned spvc_type_get_columns(spvc_type type); SPVC_PUBLIC_API unsigned spvc_type_get_num_array_dimensions(spvc_type type); SPVC_PUBLIC_API spvc_bool spvc_type_array_dimension_is_literal(spvc_type type, unsigned dimension); SPVC_PUBLIC_API SpvId spvc_type_get_array_dimension(spvc_type type, unsigned dimension); SPVC_PUBLIC_API unsigned spvc_type_get_num_member_types(spvc_type type); SPVC_PUBLIC_API spvc_type_id spvc_type_get_member_type(spvc_type type, unsigned index); SPVC_PUBLIC_API SpvStorageClass spvc_type_get_storage_class(spvc_type type); /* Image type query. */ SPVC_PUBLIC_API spvc_type_id spvc_type_get_image_sampled_type(spvc_type type); SPVC_PUBLIC_API SpvDim spvc_type_get_image_dimension(spvc_type type); SPVC_PUBLIC_API spvc_bool spvc_type_get_image_is_depth(spvc_type type); SPVC_PUBLIC_API spvc_bool spvc_type_get_image_arrayed(spvc_type type); SPVC_PUBLIC_API spvc_bool spvc_type_get_image_multisampled(spvc_type type); SPVC_PUBLIC_API spvc_bool spvc_type_get_image_is_storage(spvc_type type); SPVC_PUBLIC_API SpvImageFormat spvc_type_get_image_storage_format(spvc_type type); SPVC_PUBLIC_API SpvAccessQualifier spvc_type_get_image_access_qualifier(spvc_type type); /* * Buffer layout query. * Maps to C++ API. */ SPVC_PUBLIC_API spvc_result spvc_compiler_get_declared_struct_size(spvc_compiler compiler, spvc_type struct_type, size_t *size); SPVC_PUBLIC_API spvc_result spvc_compiler_get_declared_struct_size_runtime_array(spvc_compiler compiler, spvc_type struct_type, size_t array_size, size_t *size); SPVC_PUBLIC_API spvc_result spvc_compiler_get_declared_struct_member_size(spvc_compiler compiler, spvc_type type, unsigned index, size_t *size); SPVC_PUBLIC_API spvc_result spvc_compiler_type_struct_member_offset(spvc_compiler compiler, spvc_type type, unsigned index, unsigned *offset); SPVC_PUBLIC_API spvc_result spvc_compiler_type_struct_member_array_stride(spvc_compiler compiler, spvc_type type, unsigned index, unsigned *stride); SPVC_PUBLIC_API spvc_result spvc_compiler_type_struct_member_matrix_stride(spvc_compiler compiler, spvc_type type, unsigned index, unsigned *stride); /* * Workaround helper functions. * Maps to C++ API. */ SPVC_PUBLIC_API spvc_result spvc_compiler_build_dummy_sampler_for_combined_images(spvc_compiler compiler, spvc_variable_id *id); SPVC_PUBLIC_API spvc_result spvc_compiler_build_combined_image_samplers(spvc_compiler compiler); SPVC_PUBLIC_API spvc_result spvc_compiler_get_combined_image_samplers(spvc_compiler compiler, const spvc_combined_image_sampler **samplers, size_t *num_samplers); /* * Constants * Maps to C++ API. */ SPVC_PUBLIC_API spvc_result spvc_compiler_get_specialization_constants(spvc_compiler compiler, const spvc_specialization_constant **constants, size_t *num_constants); SPVC_PUBLIC_API spvc_constant spvc_compiler_get_constant_handle(spvc_compiler compiler, spvc_constant_id id); SPVC_PUBLIC_API spvc_constant_id spvc_compiler_get_work_group_size_specialization_constants(spvc_compiler compiler, spvc_specialization_constant *x, spvc_specialization_constant *y, spvc_specialization_constant *z); /* * Buffer ranges * Maps to C++ API. */ SPVC_PUBLIC_API spvc_result spvc_compiler_get_active_buffer_ranges(spvc_compiler compiler, spvc_variable_id id, const spvc_buffer_range **ranges, size_t *num_ranges); /* * No stdint.h until C99, sigh :( * For smaller types, the result is sign or zero-extended as appropriate. * Maps to C++ API. * TODO: The SPIRConstant query interface and modification interface is not quite complete. */ SPVC_PUBLIC_API float spvc_constant_get_scalar_fp16(spvc_constant constant, unsigned column, unsigned row); SPVC_PUBLIC_API float spvc_constant_get_scalar_fp32(spvc_constant constant, unsigned column, unsigned row); SPVC_PUBLIC_API double spvc_constant_get_scalar_fp64(spvc_constant constant, unsigned column, unsigned row); SPVC_PUBLIC_API unsigned spvc_constant_get_scalar_u32(spvc_constant constant, unsigned column, unsigned row); SPVC_PUBLIC_API int spvc_constant_get_scalar_i32(spvc_constant constant, unsigned column, unsigned row); SPVC_PUBLIC_API unsigned spvc_constant_get_scalar_u16(spvc_constant constant, unsigned column, unsigned row); SPVC_PUBLIC_API int spvc_constant_get_scalar_i16(spvc_constant constant, unsigned column, unsigned row); SPVC_PUBLIC_API unsigned spvc_constant_get_scalar_u8(spvc_constant constant, unsigned column, unsigned row); SPVC_PUBLIC_API int spvc_constant_get_scalar_i8(spvc_constant constant, unsigned column, unsigned row); SPVC_PUBLIC_API void spvc_constant_get_subconstants(spvc_constant constant, const spvc_constant_id **constituents, size_t *count); SPVC_PUBLIC_API spvc_type_id spvc_constant_get_type(spvc_constant constant); /* * Misc reflection * Maps to C++ API. */ SPVC_PUBLIC_API spvc_bool spvc_compiler_get_binary_offset_for_decoration(spvc_compiler compiler, spvc_variable_id id, SpvDecoration decoration, unsigned *word_offset); SPVC_PUBLIC_API spvc_bool spvc_compiler_buffer_is_hlsl_counter_buffer(spvc_compiler compiler, spvc_variable_id id); SPVC_PUBLIC_API spvc_bool spvc_compiler_buffer_get_hlsl_counter_buffer(spvc_compiler compiler, spvc_variable_id id, spvc_variable_id *counter_id); SPVC_PUBLIC_API spvc_result spvc_compiler_get_declared_capabilities(spvc_compiler compiler, const SpvCapability **capabilities, size_t *num_capabilities); SPVC_PUBLIC_API spvc_result spvc_compiler_get_declared_extensions(spvc_compiler compiler, const char ***extensions, size_t *num_extensions); SPVC_PUBLIC_API const char *spvc_compiler_get_remapped_declared_block_name(spvc_compiler compiler, spvc_variable_id id); SPVC_PUBLIC_API spvc_result spvc_compiler_get_buffer_block_decorations(spvc_compiler compiler, spvc_variable_id id, const SpvDecoration **decorations, size_t *num_decorations); #ifdef __cplusplus } #endif #endif
{ "pile_set_name": "Github" }
/* * Matrix test. */ #include "io/streams/cout.hh" #include "lang/array.hh" #include "math/matrices/matrix.hh" #include "lang/exceptions/ex_index_out_of_bounds.hh" using io::streams::cout; using lang::array; using math::matrices::matrix; int main() { try { matrix<> m(3,2); m(0,0) = 0.1; m(0,1) = 0.02; m(1,0) = 1.0; m(1,1) = 2.0; m(2,0) = 10; m(2,1) = 30; matrix<> m_ramp = matrix<>::ramp(-0.5, 0.25, 0.5); array<unsigned long> dims1(1); dims1[0] = m_ramp.size(); matrix<> m_ramp1 = reshape(m_ramp,dims1); cout << m << "\n"; cout << m_ramp << "\n"; cout << m_ramp1 << "\n"; cout << "--- convolution 1D (full) ---\n"; cout << conv(m_ramp1,m_ramp1) << "\n"; cout << "--- convolution 1D (cropped) ---\n"; cout << conv_crop(m_ramp1,m_ramp1) << "\n"; cout << "--- convolution 1D (cropped strict) ---\n"; cout << conv_crop_strict(m_ramp1,m_ramp1) << "\n"; cout << "--- convolution 2D (full) ---\n"; cout << conv(m,m) << "\n"; cout << conv(m,transpose(m)) << "\n"; cout << conv(m,m_ramp) << "\n"; cout << conv(m_ramp,m) << "\n"; cout << conv(m_ramp,transpose(m_ramp)) << "\n"; cout << "--- convolution 2D (cropped) ---\n"; cout << conv_crop(m,m) << "\n"; cout << conv_crop(m,transpose(m)) << "\n"; cout << conv_crop(m,m_ramp) << "\n"; cout << conv_crop(m_ramp,m) << "\n"; cout << conv_crop(m_ramp,transpose(m_ramp)) << "\n"; cout << "--- convolution 2D (cropped strict) ---\n"; cout << conv_crop_strict(m,m) << "\n"; cout << conv_crop_strict(m,transpose(m)) << "\n"; cout << conv_crop_strict(m,m_ramp) << "\n"; cout << conv_crop_strict(m_ramp,m) << "\n"; cout << conv_crop_strict(m_ramp,transpose(m_ramp)) << "\n"; cout << "--- min, max, sum, prod ---\n"; cout << min(m,0) << "\n"; cout << min(m,1) << "\n"; cout << max(m,0) << "\n"; cout << max(m,1) << "\n"; cout << sum(m,0) << "\n"; cout << sum(m,1) << "\n"; cout << prod(m,0) << "\n"; cout << prod(m,1) << "\n"; cout << "--- cumsum, cumprod ---\n"; cout << cumsum(m,0) << "\n"; cout << cumsum(m,1) << "\n"; cout << cumprod(m,0) << "\n"; cout << cumprod(m,1) << "\n"; cout << "--- mean, var ---\n"; cout << mean(m) << "\n"; cout << var(m) << "\n"; cout << mean(m,0) << "\n"; cout << mean(m,1) << "\n"; cout << var(m,0) << "\n"; cout << var(m,1) << "\n"; cout << "--- gradient ---\n"; cout << gradient(m,0) << "\n"; cout << gradient(m,1) << "\n"; cout << "--- reverse ---\n"; cout << m.reverse(0) << "\n"; cout << m.reverse(1) << "\n"; cout << "--- vertcat, horzcat, concat ---\n"; cout << vertcat(m,m) << "\n"; cout << horzcat(m,m) << "\n"; cout << concat(m,m,4) << "\n"; cout << "--- resize, transpose ---\n"; cout << resize(m,2,2) << "\n"; cout << resize(m,4,4) << "\n"; cout << transpose(resize(m,4,4)) << "\n"; array<unsigned long> order(3); order[0] = 2; order[1] = 1; order[2] = 0; cout << permute_dimensions(resize(m,4,4),order) << "\n"; order[1] = 3; order.resize(2); cout << "--- repmat ---\n"; cout << repmat(m,order) << "\n"; cout << "--- sort ---\n"; cout << m << "\n"; cout << m.sort_idx(0) << "\n"; cout << m << "\n"; cout << m.sort_idx(1) << "\n"; cout << m << "\n"; } catch (lang::exceptions::ex_index_out_of_bounds& e) { cout << e << "\n"; cout << e.index() << "\n"; } return 0; }
{ "pile_set_name": "Github" }
// RUN: %compile-run-and-check #include <omp.h> #include <stdio.h> int main() { int res = 0; #pragma omp parallel num_threads(2) reduction(+:res) { int tid = omp_get_thread_num(); #pragma omp target teams distribute reduction(+:res) for (int i = tid; i < 2; i++) ++res; } // The first thread makes 2 iterations, the second - 1. Expected result of the // reduction res is 3. // CHECK: res = 3. printf("res = %d.\n", res); return 0; }
{ "pile_set_name": "Github" }
/* Copyright (C) 2015 Apple Inc. All Rights Reserved. See LICENSE.txt for this sample’s licensing information Abstract: The EAGLView class is a UIView subclass that renders OpenGL scene. */ #import "EAGLView.h" #import "ES2Renderer.h" @interface EAGLView () { ES2Renderer* _renderer; EAGLContext* _context; NSInteger _animationFrameInterval; CADisplayLink* _displayLink; } @end @implementation EAGLView // Must return the CAEAGLLayer class so that CA allocates an EAGLLayer backing for this view + (Class) layerClass { return [CAEAGLLayer class]; } // The GL view is stored in the storyboard file. When it's unarchived it's sent -initWithCoder: - (instancetype) initWithCoder:(NSCoder*)coder { if ((self = [super initWithCoder:coder])) { // Get the layer CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; eaglLayer.opaque = TRUE; eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; if (!_context || ![EAGLContext setCurrentContext:_context]) { return nil; } _renderer = [[ES2Renderer alloc] initWithContext:_context AndDrawable:(id<EAGLDrawable>)self.layer]; if (!_renderer) { return nil; } _animating = FALSE; _animationFrameInterval = 1; _displayLink = nil; } return self; } - (void) drawView:(id)sender { [EAGLContext setCurrentContext:_context]; [_renderer render]; } - (void) layoutSubviews { [_renderer resizeFromLayer:(CAEAGLLayer*)self.layer]; [self drawView:nil]; } - (NSInteger) animationFrameInterval { return _animationFrameInterval; } - (void) setAnimationFrameInterval:(NSInteger)frameInterval { // Frame interval defines how many display frames must pass between each time the // display link fires. The display link will only fire 30 times a second when the // frame internal is two on a display that refreshes 60 times a second. The default // frame interval setting of one will fire 60 times a second when the display refreshes // at 60 times a second. A frame interval setting of less than one results in undefined // behavior. if (frameInterval >= 1) { _animationFrameInterval = frameInterval; if (_animating) { [self stopAnimation]; [self startAnimation]; } } } - (void) startAnimation { if (!_animating) { // Create the display link and set the callback to our drawView method _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView:)]; // Set it to our _animationFrameInterval [_displayLink setFrameInterval:_animationFrameInterval]; // Have the display link run on the default runn loop (and the main thread) [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; _animating = TRUE; } } - (void)stopAnimation { if (_animating) { [_displayLink invalidate]; _displayLink = nil; _animating = FALSE; } } - (void) dealloc { // tear down context if ([EAGLContext currentContext] == _context) [EAGLContext setCurrentContext:nil]; } @end
{ "pile_set_name": "Github" }
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Oct 15 2018 10:31:50). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import <UIFoundation/NSCollectionViewLayout.h> @interface NSCollectionViewLayout (NSPrivateItemSequence) + (BOOL)itemLayoutIsSequential; @end
{ "pile_set_name": "Github" }
name: rdev_get_ringparam ID: 721 format: field:unsigned short common_type; offset:0; size:2; signed:0; field:unsigned char common_flags; offset:2; size:1; signed:0; field:unsigned char common_preempt_count; offset:3; size:1; signed:0; field:int common_pid; offset:4; size:4; signed:1; field:char wiphy_name[32]; offset:8; size:32; signed:0; print fmt: "%s", REC->wiphy_name
{ "pile_set_name": "Github" }
/* * jccoefct.c * * Copyright (C) 1994-1997, Thomas G. Lane. * This file is part of the Independent JPEG Group's software. * For conditions of distribution and use, see the accompanying README file. * * This file contains the coefficient buffer controller for compression. * This controller is the top level of the JPEG compressor proper. * The coefficient buffer lies between forward-DCT and entropy encoding steps. */ #define JPEG_INTERNALS #include "jinclude.h" #include "jpeglib.h" /* We use a full-image coefficient buffer when doing Huffman optimization, * and also for writing multiple-scan JPEG files. In all cases, the DCT * step is run during the first pass, and subsequent passes need only read * the buffered coefficients. */ #ifdef ENTROPY_OPT_SUPPORTED #define FULL_COEF_BUFFER_SUPPORTED #else #ifdef C_MULTISCAN_FILES_SUPPORTED #define FULL_COEF_BUFFER_SUPPORTED #endif #endif /* Private buffer controller object */ typedef struct { struct jpeg_c_coef_controller pub; /* public fields */ JDIMENSION iMCU_row_num; /* iMCU row # within image */ JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ int MCU_vert_offset; /* counts MCU rows within iMCU row */ int MCU_rows_per_iMCU_row; /* number of such rows needed */ /* For single-pass compression, it's sufficient to buffer just one MCU * (although this may prove a bit slow in practice). We allocate a * workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each * MCU constructed and sent. (On 80x86, the workspace is FAR even though * it's not really very big; this is to keep the module interfaces unchanged * when a large coefficient buffer is necessary.) * In multi-pass modes, this array points to the current MCU's blocks * within the virtual arrays. */ JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; /* In multi-pass modes, we need a virtual block array for each component. */ jvirt_barray_ptr whole_image[MAX_COMPONENTS]; } my_coef_controller; typedef my_coef_controller * my_coef_ptr; /* Forward declarations */ METHODDEF(boolean) compress_data JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); #ifdef FULL_COEF_BUFFER_SUPPORTED METHODDEF(boolean) compress_first_pass JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); METHODDEF(boolean) compress_output JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); #endif LOCAL(void) start_iMCU_row (j_compress_ptr cinfo) /* Reset within-iMCU-row counters for a new row */ { my_coef_ptr coef = (my_coef_ptr) cinfo->coef; /* In an interleaved scan, an MCU row is the same as an iMCU row. * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. * But at the bottom of the image, process only what's left. */ if (cinfo->comps_in_scan > 1) { coef->MCU_rows_per_iMCU_row = 1; } else { if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; else coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; } coef->mcu_ctr = 0; coef->MCU_vert_offset = 0; } /* * Initialize for a processing pass. */ METHODDEF(void) start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) { my_coef_ptr coef = (my_coef_ptr) cinfo->coef; coef->iMCU_row_num = 0; start_iMCU_row(cinfo); switch (pass_mode) { case JBUF_PASS_THRU: if (coef->whole_image[0] != NULL) ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); coef->pub.compress_data = compress_data; break; #ifdef FULL_COEF_BUFFER_SUPPORTED case JBUF_SAVE_AND_PASS: if (coef->whole_image[0] == NULL) ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); coef->pub.compress_data = compress_first_pass; break; case JBUF_CRANK_DEST: if (coef->whole_image[0] == NULL) ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); coef->pub.compress_data = compress_output; break; #endif default: ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); break; } } /* * Process some data in the single-pass case. * We process the equivalent of one fully interleaved MCU row ("iMCU" row) * per call, ie, v_samp_factor block rows for each component in the image. * Returns TRUE if the iMCU row is completed, FALSE if suspended. * * NB: input_buf contains a plane for each component in image, * which we index according to the component's SOF position. */ METHODDEF(boolean) compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf) { my_coef_ptr coef = (my_coef_ptr) cinfo->coef; JDIMENSION MCU_col_num; /* index of current MCU within row */ JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; int blkn, bi, ci, yindex, yoffset, blockcnt; JDIMENSION ypos, xpos; jpeg_component_info *compptr; /* Loop to write as much as one whole iMCU row */ for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; yoffset++) { for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col; MCU_col_num++) { /* Determine where data comes from in input_buf and do the DCT thing. * Each call on forward_DCT processes a horizontal row of DCT blocks * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks * sequentially. Dummy blocks at the right or bottom edge are filled in * specially. The data in them does not matter for image reconstruction, * so we fill them with values that will encode to the smallest amount of * data, viz: all zeroes in the AC entries, DC entries equal to previous * block's DC value. (Thanks to Thomas Kinsman for this idea.) */ blkn = 0; for (ci = 0; ci < cinfo->comps_in_scan; ci++) { compptr = cinfo->cur_comp_info[ci]; blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width : compptr->last_col_width; xpos = MCU_col_num * compptr->MCU_sample_width; ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */ for (yindex = 0; yindex < compptr->MCU_height; yindex++) { if (coef->iMCU_row_num < last_iMCU_row || yoffset+yindex < compptr->last_row_height) { (*cinfo->fdct->forward_DCT) (cinfo, compptr, input_buf[compptr->component_index], coef->MCU_buffer[blkn], ypos, xpos, (JDIMENSION) blockcnt); if (blockcnt < compptr->MCU_width) { /* Create some dummy blocks at the right edge of the image. */ jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt], (compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK)); for (bi = blockcnt; bi < compptr->MCU_width; bi++) { coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0]; } } } else { /* Create a row of dummy blocks at the bottom of the image. */ jzero_far((void FAR *) coef->MCU_buffer[blkn], compptr->MCU_width * SIZEOF(JBLOCK)); for (bi = 0; bi < compptr->MCU_width; bi++) { coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0]; } } blkn += compptr->MCU_width; ypos += DCTSIZE; } } /* Try to write the MCU. In event of a suspension failure, we will * re-DCT the MCU on restart (a bit inefficient, could be fixed...) */ if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { /* Suspension forced; update state counters and exit */ coef->MCU_vert_offset = yoffset; coef->mcu_ctr = MCU_col_num; return FALSE; } } /* Completed an MCU row, but perhaps not an iMCU row */ coef->mcu_ctr = 0; } /* Completed the iMCU row, advance counters for next one */ coef->iMCU_row_num++; start_iMCU_row(cinfo); return TRUE; } #ifdef FULL_COEF_BUFFER_SUPPORTED /* * Process some data in the first pass of a multi-pass case. * We process the equivalent of one fully interleaved MCU row ("iMCU" row) * per call, ie, v_samp_factor block rows for each component in the image. * This amount of data is read from the source buffer, DCT'd and quantized, * and saved into the virtual arrays. We also generate suitable dummy blocks * as needed at the right and lower edges. (The dummy blocks are constructed * in the virtual arrays, which have been padded appropriately.) This makes * it possible for subsequent passes not to worry about real vs. dummy blocks. * * We must also emit the data to the entropy encoder. This is conveniently * done by calling compress_output() after we've loaded the current strip * of the virtual arrays. * * NB: input_buf contains a plane for each component in image. All * components are DCT'd and loaded into the virtual arrays in this pass. * However, it may be that only a subset of the components are emitted to * the entropy encoder during this first pass; be careful about looking * at the scan-dependent variables (MCU dimensions, etc). */ METHODDEF(boolean) compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) { my_coef_ptr coef = (my_coef_ptr) cinfo->coef; JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; JDIMENSION blocks_across, MCUs_across, MCUindex; int bi, ci, h_samp_factor, block_row, block_rows, ndummy; JCOEF lastDC; jpeg_component_info *compptr; JBLOCKARRAY buffer; JBLOCKROW thisblockrow, lastblockrow; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { /* Align the virtual buffer for this component. */ buffer = (*cinfo->mem->access_virt_barray) ((j_common_ptr) cinfo, coef->whole_image[ci], coef->iMCU_row_num * compptr->v_samp_factor, (JDIMENSION) compptr->v_samp_factor, TRUE); /* Count non-dummy DCT block rows in this iMCU row. */ if (coef->iMCU_row_num < last_iMCU_row) block_rows = compptr->v_samp_factor; else { /* NB: can't use last_row_height here, since may not be set! */ block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); if (block_rows == 0) block_rows = compptr->v_samp_factor; } blocks_across = compptr->width_in_blocks; h_samp_factor = compptr->h_samp_factor; /* Count number of dummy blocks to be added at the right margin. */ ndummy = (int) (blocks_across % h_samp_factor); if (ndummy > 0) ndummy = h_samp_factor - ndummy; /* Perform DCT for all non-dummy blocks in this iMCU row. Each call * on forward_DCT processes a complete horizontal row of DCT blocks. */ for (block_row = 0; block_row < block_rows; block_row++) { thisblockrow = buffer[block_row]; (*cinfo->fdct->forward_DCT) (cinfo, compptr, input_buf[ci], thisblockrow, (JDIMENSION) (block_row * DCTSIZE), (JDIMENSION) 0, blocks_across); if (ndummy > 0) { /* Create dummy blocks at the right edge of the image. */ thisblockrow += blocks_across; /* => first dummy block */ jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK)); lastDC = thisblockrow[-1][0]; for (bi = 0; bi < ndummy; bi++) { thisblockrow[bi][0] = lastDC; } } } /* If at end of image, create dummy block rows as needed. * The tricky part here is that within each MCU, we want the DC values * of the dummy blocks to match the last real block's DC value. * This squeezes a few more bytes out of the resulting file... */ if (coef->iMCU_row_num == last_iMCU_row) { blocks_across += ndummy; /* include lower right corner */ MCUs_across = blocks_across / h_samp_factor; for (block_row = block_rows; block_row < compptr->v_samp_factor; block_row++) { thisblockrow = buffer[block_row]; lastblockrow = buffer[block_row-1]; jzero_far((void FAR *) thisblockrow, (size_t) (blocks_across * SIZEOF(JBLOCK))); for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) { lastDC = lastblockrow[h_samp_factor-1][0]; for (bi = 0; bi < h_samp_factor; bi++) { thisblockrow[bi][0] = lastDC; } thisblockrow += h_samp_factor; /* advance to next MCU in row */ lastblockrow += h_samp_factor; } } } } /* NB: compress_output will increment iMCU_row_num if successful. * A suspension return will result in redoing all the work above next time. */ /* Emit data to the entropy encoder, sharing code with subsequent passes */ return compress_output(cinfo, input_buf); } /* * Process some data in subsequent passes of a multi-pass case. * We process the equivalent of one fully interleaved MCU row ("iMCU" row) * per call, ie, v_samp_factor block rows for each component in the scan. * The data is obtained from the virtual arrays and fed to the entropy coder. * Returns TRUE if the iMCU row is completed, FALSE if suspended. * * NB: input_buf is ignored; it is likely to be a NULL pointer. */ METHODDEF(boolean) compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) { my_coef_ptr coef = (my_coef_ptr) cinfo->coef; JDIMENSION MCU_col_num; /* index of current MCU within row */ int blkn, ci, xindex, yindex, yoffset; JDIMENSION start_col; JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; JBLOCKROW buffer_ptr; jpeg_component_info *compptr; /* Align the virtual buffers for the components used in this scan. * NB: during first pass, this is safe only because the buffers will * already be aligned properly, so jmemmgr.c won't need to do any I/O. */ for (ci = 0; ci < cinfo->comps_in_scan; ci++) { compptr = cinfo->cur_comp_info[ci]; buffer[ci] = (*cinfo->mem->access_virt_barray) ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], coef->iMCU_row_num * compptr->v_samp_factor, (JDIMENSION) compptr->v_samp_factor, FALSE); } /* Loop to process one whole iMCU row */ for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; yoffset++) { for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; MCU_col_num++) { /* Construct list of pointers to DCT blocks belonging to this MCU */ blkn = 0; /* index of current DCT block within MCU */ for (ci = 0; ci < cinfo->comps_in_scan; ci++) { compptr = cinfo->cur_comp_info[ci]; start_col = MCU_col_num * compptr->MCU_width; for (yindex = 0; yindex < compptr->MCU_height; yindex++) { buffer_ptr = buffer[ci][yindex+yoffset] + start_col; for (xindex = 0; xindex < compptr->MCU_width; xindex++) { coef->MCU_buffer[blkn++] = buffer_ptr++; } } } /* Try to write the MCU. */ if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { /* Suspension forced; update state counters and exit */ coef->MCU_vert_offset = yoffset; coef->mcu_ctr = MCU_col_num; return FALSE; } } /* Completed an MCU row, but perhaps not an iMCU row */ coef->mcu_ctr = 0; } /* Completed the iMCU row, advance counters for next one */ coef->iMCU_row_num++; start_iMCU_row(cinfo); return TRUE; } #endif /* FULL_COEF_BUFFER_SUPPORTED */ /* * Initialize coefficient buffer controller. */ GLOBAL(void) jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer) { my_coef_ptr coef; coef = (my_coef_ptr) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_coef_controller)); cinfo->coef = (struct jpeg_c_coef_controller *) coef; coef->pub.start_pass = start_pass_coef; /* Create the coefficient buffer. */ if (need_full_buffer) { #ifdef FULL_COEF_BUFFER_SUPPORTED /* Allocate a full-image virtual array for each component, */ /* padded to a multiple of samp_factor DCT blocks in each direction. */ int ci; jpeg_component_info *compptr; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, (JDIMENSION) jround_up((long) compptr->width_in_blocks, (long) compptr->h_samp_factor), (JDIMENSION) jround_up((long) compptr->height_in_blocks, (long) compptr->v_samp_factor), (JDIMENSION) compptr->v_samp_factor); } #else ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); #endif } else { /* We only need a single-MCU buffer. */ JBLOCKROW buffer; int i; buffer = (JBLOCKROW) (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { coef->MCU_buffer[i] = buffer + i; } coef->whole_image[0] = NULL; /* flag for no virtual arrays */ } }
{ "pile_set_name": "Github" }
/* Copyright 2015 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. ==============================================================================*/ #define EIGEN_USE_THREADS #include "tensorflow/core/kernels/concat_lib_cpu.h" #include <vector> #include "tensorflow/core/framework/register_types.h" #include "tensorflow/core/kernels/concat_lib.h" namespace tensorflow { namespace { template <typename T> struct MemCpyCopier { inline void Copy(T* dst, const T* src, int input_index, size_t n) { if (DataTypeCanUseMemcpy(DataTypeToEnum<T>::v())) { memcpy(dst, src, n * sizeof(T)); } else { for (size_t k = 0; k < n; ++k) { *dst++ = *src++; } } } }; template <> struct MemCpyCopier<ResourceHandle> { inline void Copy(ResourceHandle* dst, const ResourceHandle* src, int input_index, size_t n) { for (size_t k = 0; k < n; ++k) { *dst++ = *src++; } } }; } // namespace template <typename T> void ConcatCPU(DeviceBase* d, const std::vector< std::unique_ptr<typename TTypes<T, 2>::ConstMatrix>>& inputs, typename TTypes<T, 2>::Matrix* output) { if (std::is_same<T, string>::value) { // use a large cost here to force strings to be handled by separate threads ConcatCPUImpl<T>(d, inputs, 100000, MemCpyCopier<T>(), output); } else { ConcatCPUImpl<T>(d, inputs, sizeof(T) /* cost_per_unit */, MemCpyCopier<T>(), output); } } #define REGISTER(T) \ template void ConcatCPU<T>( \ DeviceBase*, \ const std::vector<std::unique_ptr<typename TTypes<T, 2>::ConstMatrix>>&, \ typename TTypes<T, 2>::Matrix* output); TF_CALL_ALL_TYPES(REGISTER) REGISTER(quint8) REGISTER(qint8) REGISTER(quint16) REGISTER(qint16) REGISTER(qint32) REGISTER(bfloat16) TF_CALL_variant(REGISTER) #if defined(IS_MOBILE_PLATFORM) && !defined(SUPPORT_SELECTIVE_REGISTRATION) && \ !defined(__ANDROID_TYPES_FULL__) // Primarily used for SavedModel support on mobile. Registering it here only // if __ANDROID_TYPES_FULL__ is not defined (which already registers string) // to avoid duplicate registration. REGISTER(string); #endif // defined(IS_MOBILE_PLATFORM) && // !defined(SUPPORT_SELECTIVE_REGISTRATION) && // !defined(__ANDROID_TYPES_FULL__) #ifdef TENSORFLOW_USE_SYCL template <typename T> void ConcatSYCL(const Eigen::SyclDevice& d, const std::vector< std::unique_ptr<typename TTypes<T, 2>::ConstMatrix>>& inputs, typename TTypes<T, 2>::Matrix* output) { ConcatSYCLImpl<T>(d, inputs, sizeof(T) /* cost_per_unit */, MemCpyCopier<T>(), output); } #define REGISTER_SYCL(T) \ template void ConcatSYCL<T>( \ const Eigen::SyclDevice&, \ const std::vector<std::unique_ptr<typename TTypes<T, 2>::ConstMatrix>>&, \ typename TTypes<T, 2>::Matrix* output); TF_CALL_GPU_NUMBER_TYPES_NO_HALF(REGISTER_SYCL) #undef REGISTER_SYCL #endif // TENSORFLOW_USE_SYCL } // namespace tensorflow
{ "pile_set_name": "Github" }
#pragma once #include <iterator> // random_access_iterator_tag #include <nlohmann/detail/meta/void_t.hpp> #include <nlohmann/detail/meta/cpp_future.hpp> namespace nlohmann { namespace detail { template<typename It, typename = void> struct iterator_types {}; template<typename It> struct iterator_types < It, void_t<typename It::difference_type, typename It::value_type, typename It::pointer, typename It::reference, typename It::iterator_category >> { using difference_type = typename It::difference_type; using value_type = typename It::value_type; using pointer = typename It::pointer; using reference = typename It::reference; using iterator_category = typename It::iterator_category; }; // This is required as some compilers implement std::iterator_traits in a way that // doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. template<typename T, typename = void> struct iterator_traits { }; template<typename T> struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >> : iterator_types<T> { }; template<typename T> struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>> { using iterator_category = std::random_access_iterator_tag; using value_type = T; using difference_type = ptrdiff_t; using pointer = T*; using reference = T&; }; } // namespace detail } // namespace nlohmann
{ "pile_set_name": "Github" }
/*============================================================================= Copyright (c) 2001-2011 Hartmut Kaiser Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #if !defined(BOOST_SPIRIT_STREAM_MAY_05_2007_1228PM) #define BOOST_SPIRIT_STREAM_MAY_05_2007_1228PM #if defined(_MSC_VER) #pragma once #endif #include <boost/spirit/home/qi/detail/string_parse.hpp> #include <boost/spirit/home/qi/stream/detail/match_manip.hpp> #include <boost/spirit/home/qi/stream/detail/iterator_source.hpp> #include <boost/spirit/home/support/detail/hold_any.hpp> #include <iosfwd> #include <sstream> /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { /////////////////////////////////////////////////////////////////////////// // Enablers /////////////////////////////////////////////////////////////////////////// template <> struct use_terminal<qi::domain, tag::stream> // enables stream : mpl::true_ {}; template <> struct use_terminal<qi::domain, tag::wstream> // enables wstream : mpl::true_ {}; }} /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace qi { #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS using spirit::stream; using spirit::wstream; #endif using spirit::stream_type; using spirit::wstream_type; template <typename Char = char, typename T = spirit::basic_hold_any<char> > struct stream_parser : primitive_parser<stream_parser<Char, T> > { template <typename Context, typename Iterator> struct attribute { typedef T type; }; template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper , Attribute& attr_) const { typedef qi::detail::iterator_source<Iterator> source_device; typedef boost::iostreams::stream<source_device> instream; qi::skip_over(first, last, skipper); instream in(first, last); // copies 'first' in >> attr_; // use existing operator>>() // advance the iterator if everything is ok if (in) { if (!in.eof()) { std::streamsize pos = in.tellg(); std::advance(first, pos); } else { first = last; } return true; } return false; } template <typename Context> info what(Context& /*context*/) const { return info("stream"); } }; template <typename T, typename Char = char> struct typed_stream : proto::terminal<stream_parser<Char, T> >::type { }; /////////////////////////////////////////////////////////////////////////// // Parser generators: make_xxx function (objects) /////////////////////////////////////////////////////////////////////////// template <typename Char> struct make_stream { typedef stream_parser<Char> result_type; result_type operator()(unused_type, unused_type) const { return result_type(); } }; template <typename Modifiers> struct make_primitive<tag::stream, Modifiers> : make_stream<char> {}; template <typename Modifiers> struct make_primitive<tag::wstream, Modifiers> : make_stream<wchar_t> {}; }}} #endif
{ "pile_set_name": "Github" }
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Oct 15 2018 10:31:50). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import <NewsUI2/_TtC7NewsUI217NoopAudioAssembly.h> @interface _TtC7NewsUI217NoopAudioAssembly (NewsUI2) - (void)loadInRegistry:(id)arg1; @end
{ "pile_set_name": "Github" }
#include <stdio.h> #include <string.h> int romanToInt(char *s) { int len = strlen(s); int ans = 0; int i = 0; while (i < len) { switch (s[i]) { case 'M': ans += 1000; break; case 'D': ans += 500; break; case 'C': if (s[i + 1] == 'D' || s[i + 1] == 'M'){ ans -= 100; } else { ans += 100; } break; case 'L': ans += 50; break; case 'X': if (s[i + 1] == 'L' || s[i + 1] == 'C'){ ans -= 10; } else { ans += 10; } break; case 'V': ans += 5; break; case 'I': if (s[i + 1] == 'V' || s[i + 1] == 'X'){ ans -= 1; } else { ans += 1; } break; default: break; } i++; } return ans; } int main() { char s1[] = "MMXIV"; char s2[] = "MMXV"; /* should be 2014 */ printf("%d\n", romanToInt(s1)); /* should be 2015 */ printf("%d\n", romanToInt(s2)); return 0; }
{ "pile_set_name": "Github" }
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Oct 15 2018 10:31:50). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import <SAObjects/AceObject.h> #import <SAObjects/SAAceSerializable-Protocol.h> @class NSString; @interface SAUITemplateEdgeInsets : AceObject <SAAceSerializable> { } + (id)edgeInsetsWithDictionary:(id)arg1 context:(id)arg2; + (id)edgeInsets; @property(nonatomic) float top; @property(nonatomic) float right; @property(nonatomic) float left; @property(nonatomic) float bottom; - (id)encodedClassName; - (id)groupIdentifier; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end
{ "pile_set_name": "Github" }