text
stringlengths
2
99.9k
meta
dict
// Boost string_algo library finder.hpp header file ---------------------------// // Copyright Pavol Droba 2002-2006. // // 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 updates, documentation, and revision history. #ifndef BOOST_STRING_FINDER_DETAIL_HPP #define BOOST_STRING_FINDER_DETAIL_HPP #include <boost/algorithm/string/config.hpp> #include <boost/algorithm/string/constants.hpp> #include <boost/detail/iterator.hpp> #include <boost/range/iterator_range.hpp> #include <boost/range/begin.hpp> #include <boost/range/end.hpp> #include <boost/range/empty.hpp> #include <boost/range/as_literal.hpp> namespace boost { namespace algorithm { namespace detail { // find first functor -----------------------------------------------// // find a subsequence in the sequence ( functor ) /* Returns a pair <begin,end> marking the subsequence in the sequence. If the find fails, functor returns <End,End> */ template<typename SearchIteratorT,typename PredicateT> struct first_finderF { typedef SearchIteratorT search_iterator_type; // Construction template< typename SearchT > first_finderF( const SearchT& Search, PredicateT Comp ) : m_Search(::boost::begin(Search), ::boost::end(Search)), m_Comp(Comp) {} first_finderF( search_iterator_type SearchBegin, search_iterator_type SearchEnd, PredicateT Comp ) : m_Search(SearchBegin, SearchEnd), m_Comp(Comp) {} // Operation template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> operator()( ForwardIteratorT Begin, ForwardIteratorT End ) const { typedef iterator_range<ForwardIteratorT> result_type; typedef ForwardIteratorT input_iterator_type; // Outer loop for(input_iterator_type OuterIt=Begin; OuterIt!=End; ++OuterIt) { // Sanity check if( boost::empty(m_Search) ) return result_type( End, End ); input_iterator_type InnerIt=OuterIt; search_iterator_type SubstrIt=m_Search.begin(); for(; InnerIt!=End && SubstrIt!=m_Search.end(); ++InnerIt,++SubstrIt) { if( !( m_Comp(*InnerIt,*SubstrIt) ) ) break; } // Substring matching succeeded if ( SubstrIt==m_Search.end() ) return result_type( OuterIt, InnerIt ); } return result_type( End, End ); } private: iterator_range<search_iterator_type> m_Search; PredicateT m_Comp; }; // find last functor -----------------------------------------------// // find the last match a subseqeunce in the sequence ( functor ) /* Returns a pair <begin,end> marking the subsequence in the sequence. If the find fails, returns <End,End> */ template<typename SearchIteratorT, typename PredicateT> struct last_finderF { typedef SearchIteratorT search_iterator_type; typedef first_finderF< search_iterator_type, PredicateT> first_finder_type; // Construction template< typename SearchT > last_finderF( const SearchT& Search, PredicateT Comp ) : m_Search(::boost::begin(Search), ::boost::end(Search)), m_Comp(Comp) {} last_finderF( search_iterator_type SearchBegin, search_iterator_type SearchEnd, PredicateT Comp ) : m_Search(SearchBegin, SearchEnd), m_Comp(Comp) {} // Operation template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> operator()( ForwardIteratorT Begin, ForwardIteratorT End ) const { typedef iterator_range<ForwardIteratorT> result_type; if( boost::empty(m_Search) ) return result_type( End, End ); typedef BOOST_STRING_TYPENAME boost::detail:: iterator_traits<ForwardIteratorT>::iterator_category category; return findit( Begin, End, category() ); } private: // forward iterator template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> findit( ForwardIteratorT Begin, ForwardIteratorT End, std::forward_iterator_tag ) const { typedef ForwardIteratorT input_iterator_type; typedef iterator_range<ForwardIteratorT> result_type; first_finder_type first_finder( m_Search.begin(), m_Search.end(), m_Comp ); result_type M=first_finder( Begin, End ); result_type Last=M; while( M ) { Last=M; M=first_finder( ::boost::end(M), End ); } return Last; } // bidirectional iterator template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> findit( ForwardIteratorT Begin, ForwardIteratorT End, std::bidirectional_iterator_tag ) const { typedef iterator_range<ForwardIteratorT> result_type; typedef ForwardIteratorT input_iterator_type; // Outer loop for(input_iterator_type OuterIt=End; OuterIt!=Begin; ) { input_iterator_type OuterIt2=--OuterIt; input_iterator_type InnerIt=OuterIt2; search_iterator_type SubstrIt=m_Search.begin(); for(; InnerIt!=End && SubstrIt!=m_Search.end(); ++InnerIt,++SubstrIt) { if( !( m_Comp(*InnerIt,*SubstrIt) ) ) break; } // Substring matching succeeded if( SubstrIt==m_Search.end() ) return result_type( OuterIt2, InnerIt ); } return result_type( End, End ); } private: iterator_range<search_iterator_type> m_Search; PredicateT m_Comp; }; // find n-th functor -----------------------------------------------// // find the n-th match of a subsequence in the sequence ( functor ) /* Returns a pair <begin,end> marking the subsequence in the sequence. If the find fails, returns <End,End> */ template<typename SearchIteratorT, typename PredicateT> struct nth_finderF { typedef SearchIteratorT search_iterator_type; typedef first_finderF< search_iterator_type, PredicateT> first_finder_type; typedef last_finderF< search_iterator_type, PredicateT> last_finder_type; // Construction template< typename SearchT > nth_finderF( const SearchT& Search, int Nth, PredicateT Comp) : m_Search(::boost::begin(Search), ::boost::end(Search)), m_Nth(Nth), m_Comp(Comp) {} nth_finderF( search_iterator_type SearchBegin, search_iterator_type SearchEnd, int Nth, PredicateT Comp) : m_Search(SearchBegin, SearchEnd), m_Nth(Nth), m_Comp(Comp) {} // Operation template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> operator()( ForwardIteratorT Begin, ForwardIteratorT End ) const { if(m_Nth>=0) { return find_forward(Begin, End, m_Nth); } else { return find_backward(Begin, End, -m_Nth); } } private: // Implementation helpers template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> find_forward( ForwardIteratorT Begin, ForwardIteratorT End, unsigned int N) const { typedef ForwardIteratorT input_iterator_type; typedef iterator_range<ForwardIteratorT> result_type; // Sanity check if( boost::empty(m_Search) ) return result_type( End, End ); // Instantiate find functor first_finder_type first_finder( m_Search.begin(), m_Search.end(), m_Comp ); result_type M( Begin, Begin ); for( unsigned int n=0; n<=N; ++n ) { // find next match M=first_finder( ::boost::end(M), End ); if ( !M ) { // Subsequence not found, return return M; } } return M; } template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> find_backward( ForwardIteratorT Begin, ForwardIteratorT End, unsigned int N) const { typedef ForwardIteratorT input_iterator_type; typedef iterator_range<ForwardIteratorT> result_type; // Sanity check if( boost::empty(m_Search) ) return result_type( End, End ); // Instantiate find functor last_finder_type last_finder( m_Search.begin(), m_Search.end(), m_Comp ); result_type M( End, End ); for( unsigned int n=1; n<=N; ++n ) { // find next match M=last_finder( Begin, ::boost::begin(M) ); if ( !M ) { // Subsequence not found, return return M; } } return M; } private: iterator_range<search_iterator_type> m_Search; int m_Nth; PredicateT m_Comp; }; // find head/tail implementation helpers ---------------------------// template<typename ForwardIteratorT> iterator_range<ForwardIteratorT> find_head_impl( ForwardIteratorT Begin, ForwardIteratorT End, unsigned int N, std::forward_iterator_tag ) { typedef ForwardIteratorT input_iterator_type; typedef iterator_range<ForwardIteratorT> result_type; input_iterator_type It=Begin; for( unsigned int Index=0; Index<N && It!=End; ++Index,++It ) {}; return result_type( Begin, It ); } template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> find_head_impl( ForwardIteratorT Begin, ForwardIteratorT End, unsigned int N, std::random_access_iterator_tag ) { typedef ForwardIteratorT input_iterator_type; typedef iterator_range<ForwardIteratorT> result_type; if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) ) return result_type( Begin, End ); return result_type(Begin,Begin+N); } // Find head implementation template<typename ForwardIteratorT> iterator_range<ForwardIteratorT> find_head_impl( ForwardIteratorT Begin, ForwardIteratorT End, unsigned int N ) { typedef BOOST_STRING_TYPENAME boost::detail:: iterator_traits<ForwardIteratorT>::iterator_category category; return ::boost::algorithm::detail::find_head_impl( Begin, End, N, category() ); } template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> find_tail_impl( ForwardIteratorT Begin, ForwardIteratorT End, unsigned int N, std::forward_iterator_tag ) { typedef ForwardIteratorT input_iterator_type; typedef iterator_range<ForwardIteratorT> result_type; unsigned int Index=0; input_iterator_type It=Begin; input_iterator_type It2=Begin; // Advance It2 by N increments for( Index=0; Index<N && It2!=End; ++Index,++It2 ) {}; // Advance It, It2 to the end for(; It2!=End; ++It,++It2 ) {}; return result_type( It, It2 ); } template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> find_tail_impl( ForwardIteratorT Begin, ForwardIteratorT End, unsigned int N, std::bidirectional_iterator_tag ) { typedef ForwardIteratorT input_iterator_type; typedef iterator_range<ForwardIteratorT> result_type; input_iterator_type It=End; for( unsigned int Index=0; Index<N && It!=Begin; ++Index,--It ) {}; return result_type( It, End ); } template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> find_tail_impl( ForwardIteratorT Begin, ForwardIteratorT End, unsigned int N, std::random_access_iterator_tag ) { typedef ForwardIteratorT input_iterator_type; typedef iterator_range<ForwardIteratorT> result_type; if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) ) return result_type( Begin, End ); return result_type( End-N, End ); } // Operation template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> find_tail_impl( ForwardIteratorT Begin, ForwardIteratorT End, unsigned int N ) { typedef BOOST_STRING_TYPENAME boost::detail:: iterator_traits<ForwardIteratorT>::iterator_category category; return ::boost::algorithm::detail::find_tail_impl( Begin, End, N, category() ); } // find head functor -----------------------------------------------// // find a head in the sequence ( functor ) /* This functor find a head of the specified range. For a specified N, the head is a subsequence of N starting elements of the range. */ struct head_finderF { // Construction head_finderF( int N ) : m_N(N) {} // Operation template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> operator()( ForwardIteratorT Begin, ForwardIteratorT End ) const { if(m_N>=0) { return ::boost::algorithm::detail::find_head_impl( Begin, End, m_N ); } else { iterator_range<ForwardIteratorT> Res= ::boost::algorithm::detail::find_tail_impl( Begin, End, -m_N ); return ::boost::make_iterator_range(Begin, Res.begin()); } } private: int m_N; }; // find tail functor -----------------------------------------------// // find a tail in the sequence ( functor ) /* This functor find a tail of the specified range. For a specified N, the head is a subsequence of N starting elements of the range. */ struct tail_finderF { // Construction tail_finderF( int N ) : m_N(N) {} // Operation template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> operator()( ForwardIteratorT Begin, ForwardIteratorT End ) const { if(m_N>=0) { return ::boost::algorithm::detail::find_tail_impl( Begin, End, m_N ); } else { iterator_range<ForwardIteratorT> Res= ::boost::algorithm::detail::find_head_impl( Begin, End, -m_N ); return ::boost::make_iterator_range(Res.end(), End); } } private: int m_N; }; // find token functor -----------------------------------------------// // find a token in a sequence ( functor ) /* This find functor finds a token specified be a predicate in a sequence. It is equivalent of std::find algorithm, with an exception that it return range instead of a single iterator. If bCompress is set to true, adjacent matching tokens are concatenated into one match. */ template< typename PredicateT > struct token_finderF { // Construction token_finderF( PredicateT Pred, token_compress_mode_type eCompress=token_compress_off ) : m_Pred(Pred), m_eCompress(eCompress) {} // Operation template< typename ForwardIteratorT > iterator_range<ForwardIteratorT> operator()( ForwardIteratorT Begin, ForwardIteratorT End ) const { typedef iterator_range<ForwardIteratorT> result_type; ForwardIteratorT It=std::find_if( Begin, End, m_Pred ); if( It==End ) { return result_type( End, End ); } else { ForwardIteratorT It2=It; if( m_eCompress==token_compress_on ) { // Find first non-matching character while( It2!=End && m_Pred(*It2) ) ++It2; } else { // Advance by one position ++It2; } return result_type( It, It2 ); } } private: PredicateT m_Pred; token_compress_mode_type m_eCompress; }; // find range functor -----------------------------------------------// // find a range in the sequence ( functor ) /* This functor actually does not perform any find operation. It always returns given iterator range as a result. */ template<typename ForwardIterator1T> struct range_finderF { typedef ForwardIterator1T input_iterator_type; typedef iterator_range<input_iterator_type> result_type; // Construction range_finderF( input_iterator_type Begin, input_iterator_type End ) : m_Range(Begin, End) {} range_finderF(const iterator_range<input_iterator_type>& Range) : m_Range(Range) {} // Operation template< typename ForwardIterator2T > iterator_range<ForwardIterator2T> operator()( ForwardIterator2T, ForwardIterator2T ) const { #if BOOST_WORKAROUND( __MWERKS__, <= 0x3003 ) return iterator_range<const ForwardIterator2T>(this->m_Range); #elif BOOST_WORKAROUND(BOOST_MSVC, <= 1300) return iterator_range<ForwardIterator2T>(m_Range.begin(), m_Range.end()); #else return m_Range; #endif } private: iterator_range<input_iterator_type> m_Range; }; } // namespace detail } // namespace algorithm } // namespace boost #endif // BOOST_STRING_FINDER_DETAIL_HPP
{ "pile_set_name": "Github" }
/* * Copyright (C) 2016 Red Hat, 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. */ package io.syndesis.test.integration.customizer; import java.util.Arrays; import java.util.UUID; import io.syndesis.common.model.action.ConnectorAction; import io.syndesis.common.model.action.ConnectorDescriptor; import io.syndesis.common.model.connection.ConfigurationProperty; import io.syndesis.common.model.connection.Connection; import io.syndesis.common.model.connection.Connector; import io.syndesis.common.model.integration.Flow; import io.syndesis.common.model.integration.Integration; import io.syndesis.common.model.integration.Step; import io.syndesis.common.model.integration.StepKind; import org.junit.Assert; import org.junit.Test; /** * @author Christoph Deppisch */ public class JsonPathIntegrationCustomizerTest { @Test public void shouldCustomizeProperties() { Integration toCustomize = new Integration.Builder() .name("test") .addConnection(new Connection.Builder() .id(UUID.randomUUID().toString()) .name("test-connection") .putConfiguredProperty("connection-property", "initial") .build()) .addFlow(new Flow.Builder() .steps(Arrays.asList(new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id("timer-connection") .connector(new Connector.Builder() .id("timer") .putProperty("period", new ConfigurationProperty.Builder() .kind("property") .secret(false) .componentProperty(false) .build()) .build()) .build()) .putConfiguredProperty("period", "1000") .action(new ConnectorAction.Builder() .id("periodic-timer-action") .descriptor(new ConnectorDescriptor.Builder() .connectorId("timer") .componentScheme("timer") .putConfiguredProperty("timer-name", "syndesis-timer") .build()) .build()) .build(), new Step.Builder() .stepKind(StepKind.log) .putConfiguredProperty("bodyLoggingEnabled", "false") .putConfiguredProperty("contextLoggingEnabled", "false") .putConfiguredProperty("customText", "Hello Syndesis!") .build())) .build()) .build(); Assert.assertEquals(toCustomize, new JsonPathIntegrationCustomizer(null, null, null).apply(toCustomize)); Assert.assertEquals("customized", new JsonPathIntegrationCustomizer("$..connection-property", "customized").apply(toCustomize).getConnections().get(0).getConfiguredProperties().get("connection-property")); Assert.assertEquals("customized", new JsonPathIntegrationCustomizer("$..customText", "customized").apply(toCustomize).getFlows().get(0).getSteps().get(1).getConfiguredProperties().get("customText")); Assert.assertEquals("foo", new JsonPathIntegrationCustomizer("$..configuredProperties", "new_key", "foo").apply(toCustomize).getFlows().get(0).getSteps().get(1).getConfiguredProperties().get("new_key")); } }
{ "pile_set_name": "Github" }
# Copyright 2016 Telefonica Investigacion y Desarrollo, S.A.U # # This file is part of Orion Context Broker. # # Orion Context Broker is free software: you can redistribute it and/or # modify it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # Orion Context Broker is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero # General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. # # For those usages not covered by this license please contact with # iot_support at tid dot es # VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh --NAME-- POST Subscriptions V2 q expression without cache --SHELL-INIT-- dbInit CB brokerStart CB 0 IPv4 -noCache accumulatorStart --pretty-print --SHELL-- # # 01. Create subscription with q: temperature==20..40 # 02. Create entity with t=10 (not notif) # 03. Update entity to t=15 (not notif) # 04. Update entity to t=25 (notif) # 05. Update entity to t=35 (notif) # 06. Update entity to t=45 (not notif) # 07. Dump accumulator (2 notifications) # echo "01. Create subscription with q: temperature==20..40" echo "===================================================" payload=' { "subject": { "entities": [ { "id": "E1", "type": "T" } ], "condition": { "attrs": [ "temperature" ], "expression": { "q": "temperature==20..40" } } }, "notification": { "http": {"url": "http://localhost:'$LISTENER_PORT'/notify"}, "attrs": ["temperature" ] }, "expires": "2050-04-05T14:00:00.00Z" } ' orionCurl --url /v2/subscriptions --payload "$payload" echo echo echo "02. Create entity with t=10 (not notif)" echo "======================================" payload='{ "id": "E1", "type": "T", "temperature": 10 }' orionCurl --url '/v2/entities?options=keyValues' --payload "$payload" echo echo echo "03. Update entity to t=15 (not notif)" echo "====================================" payload='{ "temperature": 15 }' orionCurl --url '/v2/entities/E1/attrs?options=keyValues' --payload "$payload" -X PATCH echo echo echo "04. Update entity to t=25 (notif)" echo "=================================" payload='{ "temperature": 25 }' orionCurl --url '/v2/entities/E1/attrs?options=keyValues' --payload "$payload" -X PATCH echo echo echo "05. Update entity to t=35 (notif)" echo "=================================" payload='{ "temperature": 35 }' orionCurl --url '/v2/entities/E1/attrs?options=keyValues' --payload "$payload" -X PATCH echo echo echo "06. Update entity to t=45 (not notif)" echo "====================================" payload='{ "temperature": 45 }' orionCurl --url '/v2/entities/E1/attrs?options=keyValues' --payload "$payload" -X PATCH echo echo echo "07. Get accumulator dump (2 notifications)" echo "==========================================" accumulatorDump echo echo --REGEXPECT-- 01. Create subscription with q: temperature==20..40 =================================================== HTTP/1.1 201 Created Content-Length: 0 Location: /v2/subscriptions/REGEX([0-9a-f]{24}) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Date: REGEX(.*) 02. Create entity with t=10 (not notif) ====================================== HTTP/1.1 201 Created Content-Length: 0 Location: /v2/entities/E1?type=T Fiware-Correlator: REGEX([0-9a-f\-]{36}) Date: REGEX(.*) 03. Update entity to t=15 (not notif) ==================================== HTTP/1.1 204 No Content Fiware-Correlator: REGEX([0-9a-f\-]{36}) Date: REGEX(.*) 04. Update entity to t=25 (notif) ================================= HTTP/1.1 204 No Content Fiware-Correlator: REGEX([0-9a-f\-]{36}) Date: REGEX(.*) 05. Update entity to t=35 (notif) ================================= HTTP/1.1 204 No Content Fiware-Correlator: REGEX([0-9a-f\-]{36}) Date: REGEX(.*) 06. Update entity to t=45 (not notif) ==================================== HTTP/1.1 204 No Content Fiware-Correlator: REGEX([0-9a-f\-]{36}) Date: REGEX(.*) 07. Get accumulator dump (2 notifications) ========================================== POST http://localhost:REGEX(\d+)/notify Fiware-Servicepath: / Content-Length: 134 User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) Ngsiv2-Attrsformat: normalized Host: localhost:REGEX(\d+) Accept: application/json Content-Type: application/json; charset=utf-8 Fiware-Correlator: REGEX([0-9a-f\-]{36}) { "data": [ { "id": "E1", "temperature": { "metadata": {}, "type": "Number", "value": 25 }, "type": "T" } ], "subscriptionId": "REGEX([0-9a-f]{24})" } ======================================= POST http://localhost:REGEX(\d+)/notify Fiware-Servicepath: / Content-Length: 134 User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) Ngsiv2-Attrsformat: normalized Host: localhost:REGEX(\d+) Accept: application/json Content-Type: application/json; charset=utf-8 Fiware-Correlator: REGEX([0-9a-f\-]{36}) { "data": [ { "id": "E1", "temperature": { "metadata": {}, "type": "Number", "value": 35 }, "type": "T" } ], "subscriptionId": "REGEX([0-9a-f]{24})" } ======================================= --TEARDOWN-- brokerStop CB accumulatorStop $LISTENER_PORT dbDrop CB
{ "pile_set_name": "Github" }
#ifndef MATCHTYPE_H #define MATCHTYPE_H #include <platform.h> #include "../ast/ast.h" #include "../pass/pass.h" PONY_EXTERN_C_BEGIN /// See comment for is_matchtype() for a description of these values typedef enum { MATCHTYPE_ACCEPT, MATCHTYPE_REJECT, MATCHTYPE_DENY } matchtype_t; /** * Determine if we can match on operand_type and extract a pattern_type. * * Return ACCEPT if there exists a type which is all of: * 1. A subtype of operand_type. * 2. A type that an object of type operand_type can be safely used as. This is * an important restriction to maintain capability safety. If operand_type * is "Foo box" then "Foo ref" is a subtype of that, but not one that we can * safely use. * This complication exists because capabilities cannot be recovered at * runtime and must be handled entirely at compile time. * 3. A subtype of pattern_type. * * Return DENY if no such type can exist, but one could if capabilities were * ignored. For example an operand_type of "Foo box" and a pattern_type of * "Foo ref". This is to prevent a match that could be detected with runtime * information but would actually violate the capability guarantees. * When DENY is returned, no matching is allowed, even if some other * is_matchtype() relationship exists. * * Return REJECT if no such type can exist. */ matchtype_t is_matchtype(ast_t* operand, ast_t* pattern, errorframe_t* errorf, pass_opt_t* opt); PONY_EXTERN_C_END #endif
{ "pile_set_name": "Github" }
/* * Copyright (c) 2012 Analog Devices, Inc. * Author: Lars-Peter Clausen <[email protected]> * * 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/kernel.h> #include <linux/export.h> #include <linux/module.h> #include <linux/iio/iio.h> #include <linux/iio/buffer.h> #include <linux/iio/kfifo_buf.h> #include <linux/iio/triggered_buffer.h> #include <linux/iio/trigger_consumer.h> static const struct iio_buffer_setup_ops iio_triggered_buffer_setup_ops = { .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, }; /** * iio_triggered_buffer_setup() - Setup triggered buffer and pollfunc * @indio_dev: IIO device structure * @pollfunc_bh: Function which will be used as pollfunc bottom half * @pollfunc_th: Function which will be used as pollfunc top half * @setup_ops: Buffer setup functions to use for this device. * If NULL the default setup functions for triggered * buffers will be used. * * This function combines some common tasks which will normally be performed * when setting up a triggered buffer. It will allocate the buffer and the * pollfunc, as well as register the buffer with the IIO core. * * Before calling this function the indio_dev structure should already be * completely initialized, but not yet registered. In practice this means that * this function should be called right before iio_device_register(). * * To free the resources allocated by this function call * iio_triggered_buffer_cleanup(). */ int iio_triggered_buffer_setup(struct iio_dev *indio_dev, irqreturn_t (*pollfunc_bh)(int irq, void *p), irqreturn_t (*pollfunc_th)(int irq, void *p), const struct iio_buffer_setup_ops *setup_ops) { struct iio_buffer *buffer; int ret; buffer = iio_kfifo_allocate(indio_dev); if (!buffer) { ret = -ENOMEM; goto error_ret; } iio_device_attach_buffer(indio_dev, buffer); indio_dev->pollfunc = iio_alloc_pollfunc(pollfunc_bh, pollfunc_th, IRQF_ONESHOT, indio_dev, "%s_consumer%d", indio_dev->name, indio_dev->id); if (indio_dev->pollfunc == NULL) { ret = -ENOMEM; goto error_kfifo_free; } /* Ring buffer functions - here trigger setup related */ if (setup_ops) indio_dev->setup_ops = setup_ops; else indio_dev->setup_ops = &iio_triggered_buffer_setup_ops; /* Flag that polled ring buffering is possible */ indio_dev->modes |= INDIO_BUFFER_TRIGGERED; ret = iio_buffer_register(indio_dev, indio_dev->channels, indio_dev->num_channels); if (ret) goto error_dealloc_pollfunc; return 0; error_dealloc_pollfunc: iio_dealloc_pollfunc(indio_dev->pollfunc); error_kfifo_free: iio_kfifo_free(indio_dev->buffer); error_ret: return ret; } EXPORT_SYMBOL(iio_triggered_buffer_setup); /** * iio_triggered_buffer_cleanup() - Free resources allocated by iio_triggered_buffer_setup() * @indio_dev: IIO device structure */ void iio_triggered_buffer_cleanup(struct iio_dev *indio_dev) { iio_buffer_unregister(indio_dev); iio_dealloc_pollfunc(indio_dev->pollfunc); iio_kfifo_free(indio_dev->buffer); } EXPORT_SYMBOL(iio_triggered_buffer_cleanup); MODULE_AUTHOR("Lars-Peter Clausen <[email protected]>"); MODULE_DESCRIPTION("IIO helper functions for setting up triggered buffers"); MODULE_LICENSE("GPL");
{ "pile_set_name": "Github" }
/* * QEMU Executable loader * * Copyright (c) 2006 Fabrice Bellard * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * Gunzip functionality in this file is derived from u-boot: * * (C) Copyright 2008 Semihalf * * (C) Copyright 2000-2005 * Wolfgang Denk, DENX Software Engineering, [email protected]. * * 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, see <http://www.gnu.org/licenses/>. */ #include "hw/hw.h" #include "disas/disas.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h" #include "uboot_image.h" #include "hw/loader.h" #include "hw/nvram/fw_cfg.h" #include "exec/memory.h" #include "exec/address-spaces.h" #include <zlib.h> bool option_rom_has_mr = false; bool rom_file_has_mr = true; static int roms_loaded; /* return the size or -1 if error */ int get_image_size(const char *filename) { int fd, size; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) return -1; size = lseek(fd, 0, SEEK_END); close(fd); return size; } /* return the size or -1 if error */ /* deprecated, because caller does not specify buffer size! */ int load_image(const char *filename, uint8_t *addr) { int fd, size; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) return -1; size = lseek(fd, 0, SEEK_END); if (size == -1) { fprintf(stderr, "file %-20s: get size error: %s\n", filename, strerror(errno)); close(fd); return -1; } lseek(fd, 0, SEEK_SET); if (read(fd, addr, size) != size) { close(fd); return -1; } close(fd); return size; } /* return the size or -1 if error */ ssize_t load_image_size(const char *filename, void *addr, size_t size) { int fd; ssize_t actsize; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) { return -1; } actsize = read(fd, addr, size); if (actsize < 0) { close(fd); return -1; } close(fd); return actsize; } /* read()-like version */ ssize_t read_targphys(const char *name, int fd, hwaddr dst_addr, size_t nbytes) { uint8_t *buf; ssize_t did; buf = g_malloc(nbytes); did = read(fd, buf, nbytes); if (did > 0) rom_add_blob_fixed("read", buf, did, dst_addr); g_free(buf); return did; } /* return the size or -1 if error */ int load_image_targphys(const char *filename, hwaddr addr, uint64_t max_sz) { int size; size = get_image_size(filename); if (size > max_sz) { return -1; } if (size > 0) { rom_add_file_fixed(filename, addr, -1); } return size; } void pstrcpy_targphys(const char *name, hwaddr dest, int buf_size, const char *source) { const char *nulp; char *ptr; if (buf_size <= 0) return; nulp = memchr(source, 0, buf_size); if (nulp) { rom_add_blob_fixed(name, source, (nulp - source) + 1, dest); } else { rom_add_blob_fixed(name, source, buf_size, dest); ptr = rom_ptr(dest + buf_size - 1); *ptr = 0; } } /* A.OUT loader */ struct exec { uint32_t a_info; /* Use macros N_MAGIC, etc for access */ uint32_t a_text; /* length of text, in bytes */ uint32_t a_data; /* length of data, in bytes */ uint32_t a_bss; /* length of uninitialized data area, in bytes */ uint32_t a_syms; /* length of symbol table data in file, in bytes */ uint32_t a_entry; /* start address */ uint32_t a_trsize; /* length of relocation info for text, in bytes */ uint32_t a_drsize; /* length of relocation info for data, in bytes */ }; static void bswap_ahdr(struct exec *e) { bswap32s(&e->a_info); bswap32s(&e->a_text); bswap32s(&e->a_data); bswap32s(&e->a_bss); bswap32s(&e->a_syms); bswap32s(&e->a_entry); bswap32s(&e->a_trsize); bswap32s(&e->a_drsize); } #define N_MAGIC(exec) ((exec).a_info & 0xffff) #define OMAGIC 0407 #define NMAGIC 0410 #define ZMAGIC 0413 #define QMAGIC 0314 #define _N_HDROFF(x) (1024 - sizeof (struct exec)) #define N_TXTOFF(x) \ (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \ (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec))) #define N_TXTADDR(x, target_page_size) (N_MAGIC(x) == QMAGIC ? target_page_size : 0) #define _N_SEGMENT_ROUND(x, target_page_size) (((x) + target_page_size - 1) & ~(target_page_size - 1)) #define _N_TXTENDADDR(x, target_page_size) (N_TXTADDR(x, target_page_size)+(x).a_text) #define N_DATADDR(x, target_page_size) \ (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x, target_page_size)) \ : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x, target_page_size), target_page_size))) int load_aout(const char *filename, hwaddr addr, int max_sz, int bswap_needed, hwaddr target_page_size) { int fd; ssize_t size, ret; struct exec e; uint32_t magic; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) return -1; size = read(fd, &e, sizeof(e)); if (size < 0) goto fail; if (bswap_needed) { bswap_ahdr(&e); } magic = N_MAGIC(e); switch (magic) { case ZMAGIC: case QMAGIC: case OMAGIC: if (e.a_text + e.a_data > max_sz) goto fail; lseek(fd, N_TXTOFF(e), SEEK_SET); size = read_targphys(filename, fd, addr, e.a_text + e.a_data); if (size < 0) goto fail; break; case NMAGIC: if (N_DATADDR(e, target_page_size) + e.a_data > max_sz) goto fail; lseek(fd, N_TXTOFF(e), SEEK_SET); size = read_targphys(filename, fd, addr, e.a_text); if (size < 0) goto fail; ret = read_targphys(filename, fd, addr + N_DATADDR(e, target_page_size), e.a_data); if (ret < 0) goto fail; size += ret; break; default: goto fail; } close(fd); return size; fail: close(fd); return -1; } /* ELF loader */ static void *load_at(int fd, off_t offset, size_t size) { void *ptr; if (lseek(fd, offset, SEEK_SET) < 0) return NULL; ptr = g_malloc(size); if (read(fd, ptr, size) != size) { g_free(ptr); return NULL; } return ptr; } #ifdef ELF_CLASS #undef ELF_CLASS #endif #define ELF_CLASS ELFCLASS32 #include "elf.h" #define SZ 32 #define elf_word uint32_t #define elf_sword int32_t #define bswapSZs bswap32s #include "hw/elf_ops.h" #undef elfhdr #undef elf_phdr #undef elf_shdr #undef elf_sym #undef elf_rela #undef elf_note #undef elf_word #undef elf_sword #undef bswapSZs #undef SZ #define elfhdr elf64_hdr #define elf_phdr elf64_phdr #define elf_note elf64_note #define elf_shdr elf64_shdr #define elf_sym elf64_sym #define elf_rela elf64_rela #define elf_word uint64_t #define elf_sword int64_t #define bswapSZs bswap64s #define SZ 64 #include "hw/elf_ops.h" const char *load_elf_strerror(int error) { switch (error) { case 0: return "No error"; case ELF_LOAD_FAILED: return "Failed to load ELF"; case ELF_LOAD_NOT_ELF: return "The image is not ELF"; case ELF_LOAD_WRONG_ARCH: return "The image is from incompatible architecture"; case ELF_LOAD_WRONG_ENDIAN: return "The image has incorrect endianness"; default: return "Unknown error"; } } /* return < 0 if error, otherwise the number of bytes loaded in memory */ int load_elf(const char *filename, uint64_t (*translate_fn)(void *, uint64_t), void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr, int big_endian, int elf_machine, int clear_lsb) { int fd, data_order, target_data_order, must_swab, ret = ELF_LOAD_FAILED; uint8_t e_ident[EI_NIDENT]; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) { perror(filename); return -1; } if (read(fd, e_ident, sizeof(e_ident)) != sizeof(e_ident)) goto fail; if (e_ident[0] != ELFMAG0 || e_ident[1] != ELFMAG1 || e_ident[2] != ELFMAG2 || e_ident[3] != ELFMAG3) { ret = ELF_LOAD_NOT_ELF; goto fail; } #ifdef HOST_WORDS_BIGENDIAN data_order = ELFDATA2MSB; #else data_order = ELFDATA2LSB; #endif must_swab = data_order != e_ident[EI_DATA]; if (big_endian) { target_data_order = ELFDATA2MSB; } else { target_data_order = ELFDATA2LSB; } if (target_data_order != e_ident[EI_DATA]) { ret = ELF_LOAD_WRONG_ENDIAN; goto fail; } lseek(fd, 0, SEEK_SET); if (e_ident[EI_CLASS] == ELFCLASS64) { ret = load_elf64(filename, fd, translate_fn, translate_opaque, must_swab, pentry, lowaddr, highaddr, elf_machine, clear_lsb); } else { ret = load_elf32(filename, fd, translate_fn, translate_opaque, must_swab, pentry, lowaddr, highaddr, elf_machine, clear_lsb); } fail: close(fd); return ret; } static void bswap_uboot_header(uboot_image_header_t *hdr) { #ifndef HOST_WORDS_BIGENDIAN bswap32s(&hdr->ih_magic); bswap32s(&hdr->ih_hcrc); bswap32s(&hdr->ih_time); bswap32s(&hdr->ih_size); bswap32s(&hdr->ih_load); bswap32s(&hdr->ih_ep); bswap32s(&hdr->ih_dcrc); #endif } #define ZALLOC_ALIGNMENT 16 static void *zalloc(void *x, unsigned items, unsigned size) { void *p; size *= items; size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1); p = g_malloc(size); return (p); } static void zfree(void *x, void *addr) { g_free(addr); } #define HEAD_CRC 2 #define EXTRA_FIELD 4 #define ORIG_NAME 8 #define COMMENT 0x10 #define RESERVED 0xe0 #define DEFLATED 8 /* This is the usual maximum in uboot, so if a uImage overflows this, it would * overflow on real hardware too. */ #define UBOOT_MAX_GUNZIP_BYTES (64 << 20) static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src, size_t srclen) { z_stream s; ssize_t dstbytes; int r, i, flags; /* skip header */ i = 10; flags = src[3]; if (src[2] != DEFLATED || (flags & RESERVED) != 0) { puts ("Error: Bad gzipped data\n"); return -1; } if ((flags & EXTRA_FIELD) != 0) i = 12 + src[10] + (src[11] << 8); if ((flags & ORIG_NAME) != 0) while (src[i++] != 0) ; if ((flags & COMMENT) != 0) while (src[i++] != 0) ; if ((flags & HEAD_CRC) != 0) i += 2; if (i >= srclen) { puts ("Error: gunzip out of data in header\n"); return -1; } s.zalloc = zalloc; s.zfree = zfree; r = inflateInit2(&s, -MAX_WBITS); if (r != Z_OK) { printf ("Error: inflateInit2() returned %d\n", r); return (-1); } s.next_in = src + i; s.avail_in = srclen - i; s.next_out = dst; s.avail_out = dstlen; r = inflate(&s, Z_FINISH); if (r != Z_OK && r != Z_STREAM_END) { printf ("Error: inflate() returned %d\n", r); return -1; } dstbytes = s.next_out - (unsigned char *) dst; inflateEnd(&s); return dstbytes; } /* Load a U-Boot image. */ static int load_uboot_image(const char *filename, hwaddr *ep, hwaddr *loadaddr, int *is_linux, uint8_t image_type, uint64_t (*translate_fn)(void *, uint64_t), void *translate_opaque) { int fd; int size; hwaddr address; uboot_image_header_t h; uboot_image_header_t *hdr = &h; uint8_t *data = NULL; int ret = -1; int do_uncompress = 0; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) return -1; size = read(fd, hdr, sizeof(uboot_image_header_t)); if (size < 0) goto out; bswap_uboot_header(hdr); if (hdr->ih_magic != IH_MAGIC) goto out; if (hdr->ih_type != image_type) { fprintf(stderr, "Wrong image type %d, expected %d\n", hdr->ih_type, image_type); goto out; } /* TODO: Implement other image types. */ switch (hdr->ih_type) { case IH_TYPE_KERNEL: address = hdr->ih_load; if (translate_fn) { address = translate_fn(translate_opaque, address); } if (loadaddr) { *loadaddr = hdr->ih_load; } switch (hdr->ih_comp) { case IH_COMP_NONE: break; case IH_COMP_GZIP: do_uncompress = 1; break; default: fprintf(stderr, "Unable to load u-boot images with compression type %d\n", hdr->ih_comp); goto out; } if (ep) { *ep = hdr->ih_ep; } /* TODO: Check CPU type. */ if (is_linux) { if (hdr->ih_os == IH_OS_LINUX) { *is_linux = 1; } else { *is_linux = 0; } } break; case IH_TYPE_RAMDISK: address = *loadaddr; break; default: fprintf(stderr, "Unsupported u-boot image type %d\n", hdr->ih_type); goto out; } data = g_malloc(hdr->ih_size); if (read(fd, data, hdr->ih_size) != hdr->ih_size) { fprintf(stderr, "Error reading file\n"); goto out; } if (do_uncompress) { uint8_t *compressed_data; size_t max_bytes; ssize_t bytes; compressed_data = data; max_bytes = UBOOT_MAX_GUNZIP_BYTES; data = g_malloc(max_bytes); bytes = gunzip(data, max_bytes, compressed_data, hdr->ih_size); g_free(compressed_data); if (bytes < 0) { fprintf(stderr, "Unable to decompress gzipped image!\n"); goto out; } hdr->ih_size = bytes; } rom_add_blob_fixed(filename, data, hdr->ih_size, address); ret = hdr->ih_size; out: g_free(data); close(fd); return ret; } int load_uimage(const char *filename, hwaddr *ep, hwaddr *loadaddr, int *is_linux, uint64_t (*translate_fn)(void *, uint64_t), void *translate_opaque) { return load_uboot_image(filename, ep, loadaddr, is_linux, IH_TYPE_KERNEL, translate_fn, translate_opaque); } /* Load a ramdisk. */ int load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz) { return load_uboot_image(filename, NULL, &addr, NULL, IH_TYPE_RAMDISK, NULL, NULL); } /* Load a gzip-compressed kernel to a dynamically allocated buffer. */ int load_image_gzipped_buffer(const char *filename, uint64_t max_sz, uint8_t **buffer) { uint8_t *compressed_data = NULL; uint8_t *data = NULL; gsize len; ssize_t bytes; int ret = -1; if (!g_file_get_contents(filename, (char **) &compressed_data, &len, NULL)) { goto out; } /* Is it a gzip-compressed file? */ if (len < 2 || compressed_data[0] != 0x1f || compressed_data[1] != 0x8b) { goto out; } if (max_sz > LOAD_IMAGE_MAX_GUNZIP_BYTES) { max_sz = LOAD_IMAGE_MAX_GUNZIP_BYTES; } data = g_malloc(max_sz); bytes = gunzip(data, max_sz, compressed_data, len); if (bytes < 0) { fprintf(stderr, "%s: unable to decompress gzipped kernel file\n", filename); goto out; } /* trim to actual size and return to caller */ *buffer = g_realloc(data, bytes); ret = bytes; /* ownership has been transferred to caller */ data = NULL; out: g_free(compressed_data); g_free(data); return ret; } /* Load a gzip-compressed kernel. */ int load_image_gzipped(const char *filename, hwaddr addr, uint64_t max_sz) { int bytes; uint8_t *data; bytes = load_image_gzipped_buffer(filename, max_sz, &data); if (bytes != -1) { rom_add_blob_fixed(filename, data, bytes, addr); g_free(data); } return bytes; } /* * Functions for reboot-persistent memory regions. * - used for vga bios and option roms. * - also linux kernel (-kernel / -initrd). */ typedef struct Rom Rom; struct Rom { char *name; char *path; /* datasize is the amount of memory allocated in "data". If datasize is less * than romsize, it means that the area from datasize to romsize is filled * with zeros. */ size_t romsize; size_t datasize; uint8_t *data; MemoryRegion *mr; int isrom; char *fw_dir; char *fw_file; hwaddr addr; QTAILQ_ENTRY(Rom) next; }; static FWCfgState *fw_cfg; static QTAILQ_HEAD(, Rom) roms = QTAILQ_HEAD_INITIALIZER(roms); static void rom_insert(Rom *rom) { Rom *item; if (roms_loaded) { hw_error ("ROM images must be loaded at startup\n"); } /* list is ordered by load address */ QTAILQ_FOREACH(item, &roms, next) { if (rom->addr >= item->addr) continue; QTAILQ_INSERT_BEFORE(item, rom, next); return; } QTAILQ_INSERT_TAIL(&roms, rom, next); } static void fw_cfg_resized(const char *id, uint64_t length, void *host) { if (fw_cfg) { fw_cfg_modify_file(fw_cfg, id + strlen("/rom@"), host, length); } } static void *rom_set_mr(Rom *rom, Object *owner, const char *name) { void *data; rom->mr = g_malloc(sizeof(*rom->mr)); memory_region_init_resizeable_ram(rom->mr, owner, name, rom->datasize, rom->romsize, fw_cfg_resized, &error_fatal); memory_region_set_readonly(rom->mr, true); vmstate_register_ram_global(rom->mr); data = memory_region_get_ram_ptr(rom->mr); memcpy(data, rom->data, rom->datasize); return data; } int rom_add_file(const char *file, const char *fw_dir, hwaddr addr, int32_t bootindex, bool option_rom) { Rom *rom; int rc, fd = -1; char devpath[100]; rom = g_malloc0(sizeof(*rom)); rom->name = g_strdup(file); rom->path = qemu_find_file(QEMU_FILE_TYPE_BIOS, rom->name); if (rom->path == NULL) { rom->path = g_strdup(file); } fd = open(rom->path, O_RDONLY | O_BINARY); if (fd == -1) { fprintf(stderr, "Could not open option rom '%s': %s\n", rom->path, strerror(errno)); goto err; } if (fw_dir) { rom->fw_dir = g_strdup(fw_dir); rom->fw_file = g_strdup(file); } rom->addr = addr; rom->romsize = lseek(fd, 0, SEEK_END); if (rom->romsize == -1) { fprintf(stderr, "rom: file %-20s: get size error: %s\n", rom->name, strerror(errno)); goto err; } rom->datasize = rom->romsize; rom->data = g_malloc0(rom->datasize); lseek(fd, 0, SEEK_SET); rc = read(fd, rom->data, rom->datasize); if (rc != rom->datasize) { fprintf(stderr, "rom: file %-20s: read error: rc=%d (expected %zd)\n", rom->name, rc, rom->datasize); goto err; } close(fd); rom_insert(rom); if (rom->fw_file && fw_cfg) { const char *basename; char fw_file_name[FW_CFG_MAX_FILE_PATH]; void *data; basename = strrchr(rom->fw_file, '/'); if (basename) { basename++; } else { basename = rom->fw_file; } snprintf(fw_file_name, sizeof(fw_file_name), "%s/%s", rom->fw_dir, basename); snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name); if ((!option_rom || option_rom_has_mr) && rom_file_has_mr) { data = rom_set_mr(rom, OBJECT(fw_cfg), devpath); } else { data = rom->data; } fw_cfg_add_file(fw_cfg, fw_file_name, data, rom->romsize); } else { snprintf(devpath, sizeof(devpath), "/rom@" TARGET_FMT_plx, addr); } add_boot_device_path(bootindex, NULL, devpath); return 0; err: if (fd != -1) close(fd); g_free(rom->data); g_free(rom->path); g_free(rom->name); g_free(rom); return -1; } MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len, size_t max_len, hwaddr addr, const char *fw_file_name, FWCfgReadCallback fw_callback, void *callback_opaque) { Rom *rom; MemoryRegion *mr = NULL; rom = g_malloc0(sizeof(*rom)); rom->name = g_strdup(name); rom->addr = addr; rom->romsize = max_len ? max_len : len; rom->datasize = len; rom->data = g_malloc0(rom->datasize); memcpy(rom->data, blob, len); rom_insert(rom); if (fw_file_name && fw_cfg) { char devpath[100]; void *data; snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name); if (rom_file_has_mr) { data = rom_set_mr(rom, OBJECT(fw_cfg), devpath); mr = rom->mr; } else { data = rom->data; } fw_cfg_add_file_callback(fw_cfg, fw_file_name, fw_callback, callback_opaque, data, rom->datasize); } return mr; } /* This function is specific for elf program because we don't need to allocate * all the rom. We just allocate the first part and the rest is just zeros. This * is why romsize and datasize are different. Also, this function seize the * memory ownership of "data", so we don't have to allocate and copy the buffer. */ int rom_add_elf_program(const char *name, void *data, size_t datasize, size_t romsize, hwaddr addr) { Rom *rom; rom = g_malloc0(sizeof(*rom)); rom->name = g_strdup(name); rom->addr = addr; rom->datasize = datasize; rom->romsize = romsize; rom->data = data; rom_insert(rom); return 0; } int rom_add_vga(const char *file) { return rom_add_file(file, "vgaroms", 0, -1, true); } int rom_add_option(const char *file, int32_t bootindex) { return rom_add_file(file, "genroms", 0, bootindex, true); } static void rom_reset(void *unused) { Rom *rom; QTAILQ_FOREACH(rom, &roms, next) { if (rom->fw_file) { continue; } if (rom->data == NULL) { continue; } if (rom->mr) { void *host = memory_region_get_ram_ptr(rom->mr); memcpy(host, rom->data, rom->datasize); } else { cpu_physical_memory_write_rom(&address_space_memory, rom->addr, rom->data, rom->datasize); } if (rom->isrom) { /* rom needs to be written only once */ g_free(rom->data); rom->data = NULL; } /* * The rom loader is really on the same level as firmware in the guest * shadowing a ROM into RAM. Such a shadowing mechanism needs to ensure * that the instruction cache for that new region is clear, so that the * CPU definitely fetches its instructions from the just written data. */ cpu_flush_icache_range(rom->addr, rom->datasize); } } int rom_check_and_register_reset(void) { hwaddr addr = 0; MemoryRegionSection section; Rom *rom; QTAILQ_FOREACH(rom, &roms, next) { if (rom->fw_file) { continue; } if (addr > rom->addr) { fprintf(stderr, "rom: requested regions overlap " "(rom %s. free=0x" TARGET_FMT_plx ", addr=0x" TARGET_FMT_plx ")\n", rom->name, addr, rom->addr); return -1; } addr = rom->addr; addr += rom->romsize; section = memory_region_find(get_system_memory(), rom->addr, 1); rom->isrom = int128_nz(section.size) && memory_region_is_rom(section.mr); memory_region_unref(section.mr); } qemu_register_reset(rom_reset, NULL); roms_loaded = 1; return 0; } void rom_set_fw(FWCfgState *f) { fw_cfg = f; } static Rom *find_rom(hwaddr addr) { Rom *rom; QTAILQ_FOREACH(rom, &roms, next) { if (rom->fw_file) { continue; } if (rom->mr) { continue; } if (rom->addr > addr) { continue; } if (rom->addr + rom->romsize < addr) { continue; } return rom; } return NULL; } /* * Copies memory from registered ROMs to dest. Any memory that is contained in * a ROM between addr and addr + size is copied. Note that this can involve * multiple ROMs, which need not start at addr and need not end at addr + size. */ int rom_copy(uint8_t *dest, hwaddr addr, size_t size) { hwaddr end = addr + size; uint8_t *s, *d = dest; size_t l = 0; Rom *rom; QTAILQ_FOREACH(rom, &roms, next) { if (rom->fw_file) { continue; } if (rom->mr) { continue; } if (rom->addr + rom->romsize < addr) { continue; } if (rom->addr > end) { break; } d = dest + (rom->addr - addr); s = rom->data; l = rom->datasize; if ((d + l) > (dest + size)) { l = dest - d; } if (l > 0) { memcpy(d, s, l); } if (rom->romsize > rom->datasize) { /* If datasize is less than romsize, it means that we didn't * allocate all the ROM because the trailing data are only zeros. */ d += l; l = rom->romsize - rom->datasize; if ((d + l) > (dest + size)) { /* Rom size doesn't fit in the destination area. Adjust to avoid * overflow. */ l = dest - d; } if (l > 0) { memset(d, 0x0, l); } } } return (d + l) - dest; } void *rom_ptr(hwaddr addr) { Rom *rom; rom = find_rom(addr); if (!rom || !rom->data) return NULL; return rom->data + (addr - rom->addr); } void hmp_info_roms(Monitor *mon, const QDict *qdict) { Rom *rom; QTAILQ_FOREACH(rom, &roms, next) { if (rom->mr) { monitor_printf(mon, "%s" " size=0x%06zx name=\"%s\"\n", memory_region_name(rom->mr), rom->romsize, rom->name); } else if (!rom->fw_file) { monitor_printf(mon, "addr=" TARGET_FMT_plx " size=0x%06zx mem=%s name=\"%s\"\n", rom->addr, rom->romsize, rom->isrom ? "rom" : "ram", rom->name); } else { monitor_printf(mon, "fw=%s/%s" " size=0x%06zx name=\"%s\"\n", rom->fw_dir, rom->fw_file, rom->romsize, rom->name); } } }
{ "pile_set_name": "Github" }
'use strict'; const { app, assert } = require('egg-mock/bootstrap'); describe('test/app/controller/home.test.js', () => { it('should assert', function* () { const pkg = require('../../../package.json'); assert(app.config.keys.startsWith(pkg.name)); // const ctx = app.mockContext({}); // yield ctx.service.xx(); }); it('should GET /', () => { return app.httpRequest() .get('/') .expect('hi, egg') .expect(200); }); });
{ "pile_set_name": "Github" }
/* * linux/drivers/mfd/mcp-core.c * * Copyright (C) 2001 Russell King * * 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. * * Generic MCP (Multimedia Communications Port) layer. All MCP locking * is solely held within this file. */ #include <linux/module.h> #include <linux/init.h> #include <linux/errno.h> #include <linux/smp.h> #include <linux/device.h> #include <linux/slab.h> #include <linux/string.h> #include <linux/mfd/mcp.h> #define to_mcp(d) container_of(d, struct mcp, attached_device) #define to_mcp_driver(d) container_of(d, struct mcp_driver, drv) static int mcp_bus_match(struct device *dev, struct device_driver *drv) { return 1; } static int mcp_bus_probe(struct device *dev) { struct mcp *mcp = to_mcp(dev); struct mcp_driver *drv = to_mcp_driver(dev->driver); return drv->probe(mcp); } static int mcp_bus_remove(struct device *dev) { struct mcp *mcp = to_mcp(dev); struct mcp_driver *drv = to_mcp_driver(dev->driver); drv->remove(mcp); return 0; } static struct bus_type mcp_bus_type = { .name = "mcp", .match = mcp_bus_match, .probe = mcp_bus_probe, .remove = mcp_bus_remove, }; /** * mcp_set_telecom_divisor - set the telecom divisor * @mcp: MCP interface structure * @div: SIB clock divisor * * Set the telecom divisor on the MCP interface. The resulting * sample rate is SIBCLOCK/div. */ void mcp_set_telecom_divisor(struct mcp *mcp, unsigned int div) { unsigned long flags; spin_lock_irqsave(&mcp->lock, flags); mcp->ops->set_telecom_divisor(mcp, div); spin_unlock_irqrestore(&mcp->lock, flags); } EXPORT_SYMBOL(mcp_set_telecom_divisor); /** * mcp_set_audio_divisor - set the audio divisor * @mcp: MCP interface structure * @div: SIB clock divisor * * Set the audio divisor on the MCP interface. */ void mcp_set_audio_divisor(struct mcp *mcp, unsigned int div) { unsigned long flags; spin_lock_irqsave(&mcp->lock, flags); mcp->ops->set_audio_divisor(mcp, div); spin_unlock_irqrestore(&mcp->lock, flags); } EXPORT_SYMBOL(mcp_set_audio_divisor); /** * mcp_reg_write - write a device register * @mcp: MCP interface structure * @reg: 4-bit register index * @val: 16-bit data value * * Write a device register. The MCP interface must be enabled * to prevent this function hanging. */ void mcp_reg_write(struct mcp *mcp, unsigned int reg, unsigned int val) { unsigned long flags; spin_lock_irqsave(&mcp->lock, flags); mcp->ops->reg_write(mcp, reg, val); spin_unlock_irqrestore(&mcp->lock, flags); } EXPORT_SYMBOL(mcp_reg_write); /** * mcp_reg_read - read a device register * @mcp: MCP interface structure * @reg: 4-bit register index * * Read a device register and return its value. The MCP interface * must be enabled to prevent this function hanging. */ unsigned int mcp_reg_read(struct mcp *mcp, unsigned int reg) { unsigned long flags; unsigned int val; spin_lock_irqsave(&mcp->lock, flags); val = mcp->ops->reg_read(mcp, reg); spin_unlock_irqrestore(&mcp->lock, flags); return val; } EXPORT_SYMBOL(mcp_reg_read); /** * mcp_enable - enable the MCP interface * @mcp: MCP interface to enable * * Enable the MCP interface. Each call to mcp_enable will need * a corresponding call to mcp_disable to disable the interface. */ void mcp_enable(struct mcp *mcp) { unsigned long flags; spin_lock_irqsave(&mcp->lock, flags); if (mcp->use_count++ == 0) mcp->ops->enable(mcp); spin_unlock_irqrestore(&mcp->lock, flags); } EXPORT_SYMBOL(mcp_enable); /** * mcp_disable - disable the MCP interface * @mcp: MCP interface to disable * * Disable the MCP interface. The MCP interface will only be * disabled once the number of calls to mcp_enable matches the * number of calls to mcp_disable. */ void mcp_disable(struct mcp *mcp) { unsigned long flags; spin_lock_irqsave(&mcp->lock, flags); if (--mcp->use_count == 0) mcp->ops->disable(mcp); spin_unlock_irqrestore(&mcp->lock, flags); } EXPORT_SYMBOL(mcp_disable); static void mcp_release(struct device *dev) { struct mcp *mcp = container_of(dev, struct mcp, attached_device); kfree(mcp); } struct mcp *mcp_host_alloc(struct device *parent, size_t size) { struct mcp *mcp; mcp = kzalloc(sizeof(struct mcp) + size, GFP_KERNEL); if (mcp) { spin_lock_init(&mcp->lock); device_initialize(&mcp->attached_device); mcp->attached_device.parent = parent; mcp->attached_device.bus = &mcp_bus_type; mcp->attached_device.dma_mask = parent->dma_mask; mcp->attached_device.release = mcp_release; } return mcp; } EXPORT_SYMBOL(mcp_host_alloc); int mcp_host_add(struct mcp *mcp, void *pdata) { mcp->attached_device.platform_data = pdata; dev_set_name(&mcp->attached_device, "mcp0"); return device_add(&mcp->attached_device); } EXPORT_SYMBOL(mcp_host_add); void mcp_host_del(struct mcp *mcp) { device_del(&mcp->attached_device); } EXPORT_SYMBOL(mcp_host_del); void mcp_host_free(struct mcp *mcp) { put_device(&mcp->attached_device); } EXPORT_SYMBOL(mcp_host_free); int mcp_driver_register(struct mcp_driver *mcpdrv) { mcpdrv->drv.bus = &mcp_bus_type; return driver_register(&mcpdrv->drv); } EXPORT_SYMBOL(mcp_driver_register); void mcp_driver_unregister(struct mcp_driver *mcpdrv) { driver_unregister(&mcpdrv->drv); } EXPORT_SYMBOL(mcp_driver_unregister); static int __init mcp_init(void) { return bus_register(&mcp_bus_type); } static void __exit mcp_exit(void) { bus_unregister(&mcp_bus_type); } module_init(mcp_init); module_exit(mcp_exit); MODULE_AUTHOR("Russell King <[email protected]>"); MODULE_DESCRIPTION("Core multimedia communications port driver"); MODULE_LICENSE("GPL");
{ "pile_set_name": "Github" }
/*=====================================================================* * Copyright (C) 2012 Paul Mineiro * * All rights reserved. * * * * Redistribution and use in source and binary forms, with * * or without modification, are permitted provided that the * * following conditions are met: * * * * * Redistributions of source code must retain the * * above copyright notice, this list of conditions and * * the following disclaimer. * * * * * Redistributions in binary form must reproduce the * * above copyright notice, this list of conditions and * * the following disclaimer in the documentation and/or * * other materials provided with the distribution. * * * * * Neither the name of Paul Mineiro nor the names * * of other contributors may be used to endorse or promote * * products derived from this software without specific * * prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * * * * Contact: Paul Mineiro <[email protected]> * *=====================================================================*/ #ifndef __CAST_H_ #ifdef __cplusplus #define cast_uint32_t static_cast<uint32_t> #else #define cast_uint32_t (uint32_t) #endif #endif // __CAST_H_ /*=====================================================================* * Copyright (C) 2011 Paul Mineiro * * All rights reserved. * * * * Redistribution and use in source and binary forms, with * * or without modification, are permitted provided that the * * following conditions are met: * * * * * Redistributions of source code must retain the * * above copyright notice, this list of conditions and * * the following disclaimer. * * * * * Redistributions in binary form must reproduce the * * above copyright notice, this list of conditions and * * the following disclaimer in the documentation and/or * * other materials provided with the distribution. * * * * * Neither the name of Paul Mineiro nor the names * * of other contributors may be used to endorse or promote * * products derived from this software without specific * * prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * * * * Contact: Paul Mineiro <[email protected]> * *=====================================================================*/ #ifndef __SSE_H_ #define __SSE_H_ #ifdef __SSE2__ #include <emmintrin.h> #ifdef __cplusplus namespace { #endif // __cplusplus typedef __m128 v4sf; typedef __m128i v4si; #define v4si_to_v4sf _mm_cvtepi32_ps #define v4sf_to_v4si _mm_cvttps_epi32 #define v4sfl(x) ((const v4sf) { (x), (x), (x), (x) }) #define v2dil(x) ((const v4si) { (x), (x) }) #define v4sil(x) v2dil((((unsigned long long) (x)) << 32) | (x)) typedef union { v4sf f; float array[4]; } v4sfindexer; #define v4sf_index(_findx, _findi) \ ({ \ v4sfindexer _findvx = { _findx } ; \ _findvx.array[_findi]; \ }) typedef union { v4si i; int array[4]; } v4siindexer; #define v4si_index(_iindx, _iindi) \ ({ \ v4siindexer _iindvx = { _iindx } ; \ _iindvx.array[_iindi]; \ }) typedef union { v4sf f; v4si i; } v4sfv4sipun; #define v4sf_fabs(x) \ ({ \ v4sfv4sipun vx; \ vx.f = x; \ vx.i &= v4sil (0x7FFFFFFF); \ vx.f; \ }) #ifdef __cplusplus } // end namespace #endif // __cplusplus #endif // __SSE2__ #endif // __SSE_H_ /*=====================================================================* * Copyright (C) 2011 Paul Mineiro * * All rights reserved. * * * * Redistribution and use in source and binary forms, with * * or without modification, are permitted provided that the * * following conditions are met: * * * * * Redistributions of source code must retain the * * above copyright notice, this list of conditions and * * the following disclaimer. * * * * * Redistributions in binary form must reproduce the * * above copyright notice, this list of conditions and * * the following disclaimer in the documentation and/or * * other materials provided with the distribution. * * * * * Neither the name of Paul Mineiro nor the names * * of other contributors may be used to endorse or promote * * products derived from this software without specific * * prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * * * * Contact: Paul Mineiro <[email protected]> * *=====================================================================*/ #ifndef __FAST_EXP_H_ #define __FAST_EXP_H_ #include <stdint.h> // Underflow of exponential is common practice in numerical routines, // so handle it here. static inline float fastpow2 (float p) { float offset = (p < 0) ? 1.0f : 0.0f; float clipp = (p < -126) ? -126.0f : p; int w = clipp; float z = clipp - w + offset; union { uint32_t i; float f; } v = { cast_uint32_t ( (1 << 23) * (clipp + 121.2740575f + 27.7280233f / (4.84252568f - z) - 1.49012907f * z) ) }; return v.f; } static inline float fastexp (float p) { return fastpow2 (1.442695040f * p); } static inline float fasterpow2 (float p) { float clipp = (p < -126) ? -126.0f : p; union { uint32_t i; float f; } v = { cast_uint32_t ( (1 << 23) * (clipp + 126.94269504f) ) }; return v.f; } static inline float fasterexp (float p) { return fasterpow2 (1.442695040f * p); } #ifdef __SSE2__ static inline v4sf vfastpow2 (const v4sf p) { v4sf ltzero = _mm_cmplt_ps (p, v4sfl (0.0f)); v4sf offset = _mm_and_ps (ltzero, v4sfl (1.0f)); v4sf lt126 = _mm_cmplt_ps (p, v4sfl (-126.0f)); v4sf clipp = _mm_or_ps (_mm_andnot_ps (lt126, p), _mm_and_ps (lt126, v4sfl (-126.0f))); v4si w = v4sf_to_v4si (clipp); v4sf z = clipp - v4si_to_v4sf (w) + offset; const v4sf c_121_2740838 = v4sfl (121.2740575f); const v4sf c_27_7280233 = v4sfl (27.7280233f); const v4sf c_4_84252568 = v4sfl (4.84252568f); const v4sf c_1_49012907 = v4sfl (1.49012907f); union { v4si i; v4sf f; } v = { v4sf_to_v4si ( v4sfl (1 << 23) * (clipp + c_121_2740838 + c_27_7280233 / (c_4_84252568 - z) - c_1_49012907 * z) ) }; return v.f; } static inline v4sf vfastexp (const v4sf p) { const v4sf c_invlog_2 = v4sfl (1.442695040f); return vfastpow2 (c_invlog_2 * p); } static inline v4sf vfasterpow2 (const v4sf p) { const v4sf c_126_94269504 = v4sfl (126.94269504f); v4sf lt126 = _mm_cmplt_ps (p, v4sfl (-126.0f)); v4sf clipp = _mm_or_ps (_mm_andnot_ps (lt126, p), _mm_and_ps (lt126, v4sfl (-126.0f))); union { v4si i; v4sf f; } v = { v4sf_to_v4si (v4sfl (1 << 23) * (clipp + c_126_94269504)) }; return v.f; } static inline v4sf vfasterexp (const v4sf p) { const v4sf c_invlog_2 = v4sfl (1.442695040f); return vfasterpow2 (c_invlog_2 * p); } #endif //__SSE2__ #endif // __FAST_EXP_H_ /*=====================================================================* * Copyright (C) 2011 Paul Mineiro * * All rights reserved. * * * * Redistribution and use in source and binary forms, with * * or without modification, are permitted provided that the * * following conditions are met: * * * * * Redistributions of source code must retain the * * above copyright notice, this list of conditions and * * the following disclaimer. * * * * * Redistributions in binary form must reproduce the * * above copyright notice, this list of conditions and * * the following disclaimer in the documentation and/or * * other materials provided with the distribution. * * * * * Neither the name of Paul Mineiro nor the names * * of other contributors may be used to endorse or promote * * products derived from this software without specific * * prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * * * * Contact: Paul Mineiro <[email protected]> * *=====================================================================*/ #ifndef __FAST_LOG_H_ #define __FAST_LOG_H_ #include <stdint.h> static inline float fastlog2 (float x) { union { float f; uint32_t i; } vx = { x }; union { uint32_t i; float f; } mx = { (vx.i & 0x007FFFFF) | 0x3f000000 }; float y = vx.i; y *= 1.1920928955078125e-7f; return y - 124.22551499f - 1.498030302f * mx.f - 1.72587999f / (0.3520887068f + mx.f); } static inline float fastlog (float x) { return 0.69314718f * fastlog2 (x); } static inline float fasterlog2 (float x) { union { float f; uint32_t i; } vx = { x }; float y = vx.i; y *= 1.1920928955078125e-7f; return y - 126.94269504f; } static inline float fasterlog (float x) { // return 0.69314718f * fasterlog2 (x); union { float f; uint32_t i; } vx = { x }; float y = vx.i; y *= 8.2629582881927490e-8f; return y - 87.989971088f; } #ifdef __SSE2__ static inline v4sf vfastlog2 (v4sf x) { union { v4sf f; v4si i; } vx = { x }; union { v4si i; v4sf f; } mx; mx.i = (vx.i & v4sil (0x007FFFFF)) | v4sil (0x3f000000); v4sf y = v4si_to_v4sf (vx.i); y *= v4sfl (1.1920928955078125e-7f); const v4sf c_124_22551499 = v4sfl (124.22551499f); const v4sf c_1_498030302 = v4sfl (1.498030302f); const v4sf c_1_725877999 = v4sfl (1.72587999f); const v4sf c_0_3520087068 = v4sfl (0.3520887068f); return y - c_124_22551499 - c_1_498030302 * mx.f - c_1_725877999 / (c_0_3520087068 + mx.f); } static inline v4sf vfastlog (v4sf x) { const v4sf c_0_69314718 = v4sfl (0.69314718f); return c_0_69314718 * vfastlog2 (x); } static inline v4sf vfasterlog2 (v4sf x) { union { v4sf f; v4si i; } vx = { x }; v4sf y = v4si_to_v4sf (vx.i); y *= v4sfl (1.1920928955078125e-7f); const v4sf c_126_94269504 = v4sfl (126.94269504f); return y - c_126_94269504; } static inline v4sf vfasterlog (v4sf x) { // const v4sf c_0_69314718 = v4sfl (0.69314718f); // // return c_0_69314718 * vfasterlog2 (x); union { v4sf f; v4si i; } vx = { x }; v4sf y = v4si_to_v4sf (vx.i); y *= v4sfl (8.2629582881927490e-8f); const v4sf c_87_989971088 = v4sfl (87.989971088f); return y - c_87_989971088; } #endif // __SSE2__ #endif // __FAST_LOG_H_ /*=====================================================================* * Copyright (C) 2011 Paul Mineiro * * All rights reserved. * * * * Redistribution and use in source and binary forms, with * * or without modification, are permitted provided that the * * following conditions are met: * * * * * Redistributions of source code must retain the * * above copyright notice, this list of conditions and * * the following disclaimer. * * * * * Redistributions in binary form must reproduce the * * above copyright notice, this list of conditions and * * the following disclaimer in the documentation and/or * * other materials provided with the distribution. * * * * * Neither the name of Paul Mineiro nor the names * * of other contributors may be used to endorse or promote * * products derived from this software without specific * * prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * * * * Contact: Paul Mineiro <[email protected]> * *=====================================================================*/ #ifndef __FAST_ERF_H_ #define __FAST_ERF_H_ #include <math.h> #include <stdint.h> // fasterfc: not actually faster than erfcf(3) on newer machines! // ... although vectorized version is interesting // and fastererfc is very fast static inline float fasterfc (float x) { static const float k = 3.3509633149424609f; static const float a = 0.07219054755431126f; static const float b = 15.418191568719577f; static const float c = 5.609846028328545f; union { float f; uint32_t i; } vc = { c * x }; float xsq = x * x; float xquad = xsq * xsq; vc.i |= 0x80000000; return 2.0f / (1.0f + fastpow2 (k * x)) - a * x * (b * xquad - 1.0f) * fasterpow2 (vc.f); } static inline float fastererfc (float x) { static const float k = 3.3509633149424609f; return 2.0f / (1.0f + fasterpow2 (k * x)); } // fasterf: not actually faster than erff(3) on newer machines! // ... although vectorized version is interesting // and fastererf is very fast static inline float fasterf (float x) { return 1.0f - fasterfc (x); } static inline float fastererf (float x) { return 1.0f - fastererfc (x); } static inline float fastinverseerf (float x) { static const float invk = 0.30004578719350504f; static const float a = 0.020287853348211326f; static const float b = 0.07236892874789555f; static const float c = 0.9913030456864257f; static const float d = 0.8059775923760193f; float xsq = x * x; return invk * fastlog2 ((1.0f + x) / (1.0f - x)) + x * (a - b * xsq) / (c - d * xsq); } static inline float fasterinverseerf (float x) { static const float invk = 0.30004578719350504f; return invk * fasterlog2 ((1.0f + x) / (1.0f - x)); } #ifdef __SSE2__ static inline v4sf vfasterfc (v4sf x) { const v4sf k = v4sfl (3.3509633149424609f); const v4sf a = v4sfl (0.07219054755431126f); const v4sf b = v4sfl (15.418191568719577f); const v4sf c = v4sfl (5.609846028328545f); union { v4sf f; v4si i; } vc; vc.f = c * x; vc.i |= v4sil (0x80000000); v4sf xsq = x * x; v4sf xquad = xsq * xsq; return v4sfl (2.0f) / (v4sfl (1.0f) + vfastpow2 (k * x)) - a * x * (b * xquad - v4sfl (1.0f)) * vfasterpow2 (vc.f); } static inline v4sf vfastererfc (const v4sf x) { const v4sf k = v4sfl (3.3509633149424609f); return v4sfl (2.0f) / (v4sfl (1.0f) + vfasterpow2 (k * x)); } static inline v4sf vfasterf (v4sf x) { return v4sfl (1.0f) - vfasterfc (x); } static inline v4sf vfastererf (const v4sf x) { return v4sfl (1.0f) - vfastererfc (x); } static inline v4sf vfastinverseerf (v4sf x) { const v4sf invk = v4sfl (0.30004578719350504f); const v4sf a = v4sfl (0.020287853348211326f); const v4sf b = v4sfl (0.07236892874789555f); const v4sf c = v4sfl (0.9913030456864257f); const v4sf d = v4sfl (0.8059775923760193f); v4sf xsq = x * x; return invk * vfastlog2 ((v4sfl (1.0f) + x) / (v4sfl (1.0f) - x)) + x * (a - b * xsq) / (c - d * xsq); } static inline v4sf vfasterinverseerf (v4sf x) { const v4sf invk = v4sfl (0.30004578719350504f); return invk * vfasterlog2 ((v4sfl (1.0f) + x) / (v4sfl (1.0f) - x)); } #endif //__SSE2__ #endif // __FAST_ERF_H_ /*=====================================================================* * Copyright (C) 2011 Paul Mineiro * * All rights reserved. * * * * Redistribution and use in source and binary forms, with * * or without modification, are permitted provided that the * * following conditions are met: * * * * * Redistributions of source code must retain the * * above copyright notice, this list of conditions and * * the following disclaimer. * * * * * Redistributions in binary form must reproduce the * * above copyright notice, this list of conditions and * * the following disclaimer in the documentation and/or * * other materials provided with the distribution. * * * * * Neither the name of Paul Mineiro nor the names * * of other contributors may be used to endorse or promote * * products derived from this software without specific * * prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * * * * Contact: Paul Mineiro <[email protected]> * *=====================================================================*/ #ifndef __FAST_GAMMA_H_ #define __FAST_GAMMA_H_ #include <stdint.h> /* gamma/digamma functions only work for positive inputs */ static inline float fastlgamma (float x) { float logterm = fastlog (x * (1.0f + x) * (2.0f + x)); float xp3 = 3.0f + x; return - 2.081061466f - x + 0.0833333f / xp3 - logterm + (2.5f + x) * fastlog (xp3); } static inline float fasterlgamma (float x) { return - 0.0810614667f - x - fasterlog (x) + (0.5f + x) * fasterlog (1.0f + x); } static inline float fastdigamma (float x) { float twopx = 2.0f + x; float logterm = fastlog (twopx); return (-48.0f + x * (-157.0f + x * (-127.0f - 30.0f * x))) / (12.0f * x * (1.0f + x) * twopx * twopx) + logterm; } static inline float fasterdigamma (float x) { float onepx = 1.0f + x; return -1.0f / x - 1.0f / (2 * onepx) + fasterlog (onepx); } #ifdef __SSE2__ static inline v4sf vfastlgamma (v4sf x) { const v4sf c_1_0 = v4sfl (1.0f); const v4sf c_2_0 = v4sfl (2.0f); const v4sf c_3_0 = v4sfl (3.0f); const v4sf c_2_081061466 = v4sfl (2.081061466f); const v4sf c_0_0833333 = v4sfl (0.0833333f); const v4sf c_2_5 = v4sfl (2.5f); v4sf logterm = vfastlog (x * (c_1_0 + x) * (c_2_0 + x)); v4sf xp3 = c_3_0 + x; return - c_2_081061466 - x + c_0_0833333 / xp3 - logterm + (c_2_5 + x) * vfastlog (xp3); } static inline v4sf vfasterlgamma (v4sf x) { const v4sf c_0_0810614667 = v4sfl (0.0810614667f); const v4sf c_0_5 = v4sfl (0.5f); const v4sf c_1 = v4sfl (1.0f); return - c_0_0810614667 - x - vfasterlog (x) + (c_0_5 + x) * vfasterlog (c_1 + x); } static inline v4sf vfastdigamma (v4sf x) { v4sf twopx = v4sfl (2.0f) + x; v4sf logterm = vfastlog (twopx); return (v4sfl (-48.0f) + x * (v4sfl (-157.0f) + x * (v4sfl (-127.0f) - v4sfl (30.0f) * x))) / (v4sfl (12.0f) * x * (v4sfl (1.0f) + x) * twopx * twopx) + logterm; } static inline v4sf vfasterdigamma (v4sf x) { const v4sf c_1_0 = v4sfl (1.0f); const v4sf c_2_0 = v4sfl (2.0f); v4sf onepx = c_1_0 + x; return -c_1_0 / x - c_1_0 / (c_2_0 * onepx) + vfasterlog (onepx); } #endif //__SSE2__ #endif // __FAST_GAMMA_H_ /*=====================================================================* * Copyright (C) 2011 Paul Mineiro * * All rights reserved. * * * * Redistribution and use in source and binary forms, with * * or without modification, are permitted provided that the * * following conditions are met: * * * * * Redistributions of source code must retain the * * above copyright notice, this list of conditions and * * the following disclaimer. * * * * * Redistributions in binary form must reproduce the * * above copyright notice, this list of conditions and * * the following disclaimer in the documentation and/or * * other materials provided with the distribution. * * * * * Neither the name of Paul Mineiro nor the names * * of other contributors may be used to endorse or promote * * products derived from this software without specific * * prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * * * * Contact: Paul Mineiro <[email protected]> * *=====================================================================*/ #ifndef __FAST_HYPERBOLIC_H_ #define __FAST_HYPERBOLIC_H_ #include <stdint.h> static inline float fastsinh (float p) { return 0.5f * (fastexp (p) - fastexp (-p)); } static inline float fastersinh (float p) { return 0.5f * (fasterexp (p) - fasterexp (-p)); } static inline float fastcosh (float p) { return 0.5f * (fastexp (p) + fastexp (-p)); } static inline float fastercosh (float p) { return 0.5f * (fasterexp (p) + fasterexp (-p)); } static inline float fasttanh (float p) { return -1.0f + 2.0f / (1.0f + fastexp (-2.0f * p)); } static inline float fastertanh (float p) { return -1.0f + 2.0f / (1.0f + fasterexp (-2.0f * p)); } #ifdef __SSE2__ static inline v4sf vfastsinh (const v4sf p) { const v4sf c_0_5 = v4sfl (0.5f); return c_0_5 * (vfastexp (p) - vfastexp (-p)); } static inline v4sf vfastersinh (const v4sf p) { const v4sf c_0_5 = v4sfl (0.5f); return c_0_5 * (vfasterexp (p) - vfasterexp (-p)); } static inline v4sf vfastcosh (const v4sf p) { const v4sf c_0_5 = v4sfl (0.5f); return c_0_5 * (vfastexp (p) + vfastexp (-p)); } static inline v4sf vfastercosh (const v4sf p) { const v4sf c_0_5 = v4sfl (0.5f); return c_0_5 * (vfasterexp (p) + vfasterexp (-p)); } static inline v4sf vfasttanh (const v4sf p) { const v4sf c_1 = v4sfl (1.0f); const v4sf c_2 = v4sfl (2.0f); return -c_1 + c_2 / (c_1 + vfastexp (-c_2 * p)); } static inline v4sf vfastertanh (const v4sf p) { const v4sf c_1 = v4sfl (1.0f); const v4sf c_2 = v4sfl (2.0f); return -c_1 + c_2 / (c_1 + vfasterexp (-c_2 * p)); } #endif //__SSE2__ #endif // __FAST_HYPERBOLIC_H_ /*=====================================================================* * Copyright (C) 2011 Paul Mineiro * * All rights reserved. * * * * Redistribution and use in source and binary forms, with * * or without modification, are permitted provided that the * * following conditions are met: * * * * * Redistributions of source code must retain the * * above copyright notice, this list of conditions and * * the following disclaimer. * * * * * Redistributions in binary form must reproduce the * * above copyright notice, this list of conditions and * * the following disclaimer in the documentation and/or * * other materials provided with the distribution. * * * * * Neither the name of Paul Mineiro nor the names * * of other contributors may be used to endorse or promote * * products derived from this software without specific * * prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * * * * Contact: Paul Mineiro <[email protected]> * *=====================================================================*/ #ifndef __FAST_LAMBERT_W_H_ #define __FAST_LAMBERT_W_H_ #include <stdint.h> // these functions compute the upper branch aka W_0 static inline float fastlambertw (float x) { static const float threshold = 2.26445f; float c = (x < threshold) ? 1.546865557f : 1.0f; float d = (x < threshold) ? 2.250366841f : 0.0f; float a = (x < threshold) ? -0.737769969f : 0.0f; float logterm = fastlog (c * x + d); float loglogterm = fastlog (logterm); float minusw = -a - logterm + loglogterm - loglogterm / logterm; float expminusw = fastexp (minusw); float xexpminusw = x * expminusw; float pexpminusw = xexpminusw - minusw; return (2.0f * xexpminusw - minusw * (4.0f * xexpminusw - minusw * pexpminusw)) / (2.0f + pexpminusw * (2.0f - minusw)); } static inline float fasterlambertw (float x) { static const float threshold = 2.26445f; float c = (x < threshold) ? 1.546865557f : 1.0f; float d = (x < threshold) ? 2.250366841f : 0.0f; float a = (x < threshold) ? -0.737769969f : 0.0f; float logterm = fasterlog (c * x + d); float loglogterm = fasterlog (logterm); float w = a + logterm - loglogterm + loglogterm / logterm; float expw = fasterexp (-w); return (w * w + expw * x) / (1.0f + w); } static inline float fastlambertwexpx (float x) { static const float k = 1.1765631309f; static const float a = 0.94537622168f; float logarg = fmaxf (x, k); float powarg = (x < k) ? a * (x - k) : 0; float logterm = fastlog (logarg); float powterm = fasterpow2 (powarg); // don't need accuracy here float w = powterm * (logarg - logterm + logterm / logarg); float logw = fastlog (w); float p = x - logw; return w * (2.0f + p + w * (3.0f + 2.0f * p)) / (2.0f - p + w * (5.0f + 2.0f * w)); } static inline float fasterlambertwexpx (float x) { static const float k = 1.1765631309f; static const float a = 0.94537622168f; float logarg = fmaxf (x, k); float powarg = (x < k) ? a * (x - k) : 0; float logterm = fasterlog (logarg); float powterm = fasterpow2 (powarg); float w = powterm * (logarg - logterm + logterm / logarg); float logw = fasterlog (w); return w * (1.0f + x - logw) / (1.0f + w); } #ifdef __SSE2__ static inline v4sf vfastlambertw (v4sf x) { const v4sf threshold = v4sfl (2.26445f); v4sf under = _mm_cmplt_ps (x, threshold); v4sf c = _mm_or_ps (_mm_and_ps (under, v4sfl (1.546865557f)), _mm_andnot_ps (under, v4sfl (1.0f))); v4sf d = _mm_and_ps (under, v4sfl (2.250366841f)); v4sf a = _mm_and_ps (under, v4sfl (-0.737769969f)); v4sf logterm = vfastlog (c * x + d); v4sf loglogterm = vfastlog (logterm); v4sf minusw = -a - logterm + loglogterm - loglogterm / logterm; v4sf expminusw = vfastexp (minusw); v4sf xexpminusw = x * expminusw; v4sf pexpminusw = xexpminusw - minusw; return (v4sfl (2.0f) * xexpminusw - minusw * (v4sfl (4.0f) * xexpminusw - minusw * pexpminusw)) / (v4sfl (2.0f) + pexpminusw * (v4sfl (2.0f) - minusw)); } static inline v4sf vfasterlambertw (v4sf x) { const v4sf threshold = v4sfl (2.26445f); v4sf under = _mm_cmplt_ps (x, threshold); v4sf c = _mm_or_ps (_mm_and_ps (under, v4sfl (1.546865557f)), _mm_andnot_ps (under, v4sfl (1.0f))); v4sf d = _mm_and_ps (under, v4sfl (2.250366841f)); v4sf a = _mm_and_ps (under, v4sfl (-0.737769969f)); v4sf logterm = vfasterlog (c * x + d); v4sf loglogterm = vfasterlog (logterm); v4sf w = a + logterm - loglogterm + loglogterm / logterm; v4sf expw = vfasterexp (-w); return (w * w + expw * x) / (v4sfl (1.0f) + w); } static inline v4sf vfastlambertwexpx (v4sf x) { const v4sf k = v4sfl (1.1765631309f); const v4sf a = v4sfl (0.94537622168f); const v4sf two = v4sfl (2.0f); const v4sf three = v4sfl (3.0f); const v4sf five = v4sfl (5.0f); v4sf logarg = _mm_max_ps (x, k); v4sf powarg = _mm_and_ps (_mm_cmplt_ps (x, k), a * (x - k)); v4sf logterm = vfastlog (logarg); v4sf powterm = vfasterpow2 (powarg); // don't need accuracy here v4sf w = powterm * (logarg - logterm + logterm / logarg); v4sf logw = vfastlog (w); v4sf p = x - logw; return w * (two + p + w * (three + two * p)) / (two - p + w * (five + two * w)); } static inline v4sf vfasterlambertwexpx (v4sf x) { const v4sf k = v4sfl (1.1765631309f); const v4sf a = v4sfl (0.94537622168f); v4sf logarg = _mm_max_ps (x, k); v4sf powarg = _mm_and_ps (_mm_cmplt_ps (x, k), a * (x - k)); v4sf logterm = vfasterlog (logarg); v4sf powterm = vfasterpow2 (powarg); v4sf w = powterm * (logarg - logterm + logterm / logarg); v4sf logw = vfasterlog (w); return w * (v4sfl (1.0f) + x - logw) / (v4sfl (1.0f) + w); } #endif // __SSE2__ #endif // __FAST_LAMBERT_W_H_ /*=====================================================================* * Copyright (C) 2011 Paul Mineiro * * All rights reserved. * * * * Redistribution and use in source and binary forms, with * * or without modification, are permitted provided that the * * following conditions are met: * * * * * Redistributions of source code must retain the * * above copyright notice, this list of conditions and * * the following disclaimer. * * * * * Redistributions in binary form must reproduce the * * above copyright notice, this list of conditions and * * the following disclaimer in the documentation and/or * * other materials provided with the distribution. * * * * * Neither the name of Paul Mineiro nor the names * * of other contributors may be used to endorse or promote * * products derived from this software without specific * * prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * * * * Contact: Paul Mineiro <[email protected]> * *=====================================================================*/ #ifndef __FAST_POW_H_ #define __FAST_POW_H_ #include <stdint.h> static inline float fastpow (float x, float p) { return fastpow2 (p * fastlog2 (x)); } static inline float fasterpow (float x, float p) { return fasterpow2 (p * fasterlog2 (x)); } #ifdef __SSE2__ static inline v4sf vfastpow (const v4sf x, const v4sf p) { return vfastpow2 (p * vfastlog2 (x)); } static inline v4sf vfasterpow (const v4sf x, const v4sf p) { return vfasterpow2 (p * vfasterlog2 (x)); } #endif //__SSE2__ #endif // __FAST_POW_H_ /*=====================================================================* * Copyright (C) 2011 Paul Mineiro * * All rights reserved. * * * * Redistribution and use in source and binary forms, with * * or without modification, are permitted provided that the * * following conditions are met: * * * * * Redistributions of source code must retain the * * above copyright notice, this list of conditions and * * the following disclaimer. * * * * * Redistributions in binary form must reproduce the * * above copyright notice, this list of conditions and * * the following disclaimer in the documentation and/or * * other materials provided with the distribution. * * * * * Neither the name of Paul Mineiro nor the names * * of other contributors may be used to endorse or promote * * products derived from this software without specific * * prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * * * * Contact: Paul Mineiro <[email protected]> * *=====================================================================*/ #ifndef __FAST_SIGMOID_H_ #define __FAST_SIGMOID_H_ #include <stdint.h> static inline float fastsigmoid (float x) { return 1.0f / (1.0f + fastexp (-x)); } static inline float fastersigmoid (float x) { return 1.0f / (1.0f + fasterexp (-x)); } #ifdef __SSE2__ static inline v4sf vfastsigmoid (const v4sf x) { const v4sf c_1 = v4sfl (1.0f); return c_1 / (c_1 + vfastexp (-x)); } static inline v4sf vfastersigmoid (const v4sf x) { const v4sf c_1 = v4sfl (1.0f); return c_1 / (c_1 + vfasterexp (-x)); } #endif //__SSE2__ #endif // __FAST_SIGMOID_H_ /*=====================================================================* * Copyright (C) 2011 Paul Mineiro * * All rights reserved. * * * * Redistribution and use in source and binary forms, with * * or without modification, are permitted provided that the * * following conditions are met: * * * * * Redistributions of source code must retain the * * above copyright notice, this list of conditions and * * the following disclaimer. * * * * * Redistributions in binary form must reproduce the * * above copyright notice, this list of conditions and * * the following disclaimer in the documentation and/or * * other materials provided with the distribution. * * * * * Neither the name of Paul Mineiro nor the names * * of other contributors may be used to endorse or promote * * products derived from this software without specific * * prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * * * * Contact: Paul Mineiro <[email protected]> * *=====================================================================*/ #ifndef __FAST_TRIG_H_ #define __FAST_TRIG_H_ #include <stdint.h> // http://www.devmaster.net/forums/showthread.php?t=5784 // fast sine variants are for x \in [ -\pi, pi ] // fast cosine variants are for x \in [ -\pi, pi ] // fast tangent variants are for x \in [ -\pi / 2, pi / 2 ] // "full" versions of functions handle the entire range of inputs // although the range reduction technique used here will be hopelessly // inaccurate for |x| >> 1000 // // WARNING: fastsinfull, fastcosfull, and fasttanfull can be slower than // libc calls on older machines (!) and on newer machines are only // slighly faster. however: // * vectorized versions are competitive // * faster full versions are competitive static inline float fastsin (float x) { static const float fouroverpi = 1.2732395447351627f; static const float fouroverpisq = 0.40528473456935109f; static const float q = 0.78444488374548933f; union { float f; uint32_t i; } p = { 0.20363937680730309f }; union { float f; uint32_t i; } r = { 0.015124940802184233f }; union { float f; uint32_t i; } s = { -0.0032225901625579573f }; union { float f; uint32_t i; } vx = { x }; uint32_t sign = vx.i & 0x80000000; vx.i = vx.i & 0x7FFFFFFF; float qpprox = fouroverpi * x - fouroverpisq * x * vx.f; float qpproxsq = qpprox * qpprox; p.i |= sign; r.i |= sign; s.i ^= sign; return q * qpprox + qpproxsq * (p.f + qpproxsq * (r.f + qpproxsq * s.f)); } static inline float fastersin (float x) { static const float fouroverpi = 1.2732395447351627f; static const float fouroverpisq = 0.40528473456935109f; static const float q = 0.77633023248007499f; union { float f; uint32_t i; } p = { 0.22308510060189463f }; union { float f; uint32_t i; } vx = { x }; uint32_t sign = vx.i & 0x80000000; vx.i &= 0x7FFFFFFF; float qpprox = fouroverpi * x - fouroverpisq * x * vx.f; p.i |= sign; return qpprox * (q + p.f * qpprox); } static inline float fastsinfull (float x) { static const float twopi = 6.2831853071795865f; static const float invtwopi = 0.15915494309189534f; int k = x * invtwopi; float half = (x < 0) ? -0.5f : 0.5f; return fastsin ((half + k) * twopi - x); } static inline float fastersinfull (float x) { static const float twopi = 6.2831853071795865f; static const float invtwopi = 0.15915494309189534f; int k = x * invtwopi; float half = (x < 0) ? -0.5f : 0.5f; return fastersin ((half + k) * twopi - x); } static inline float fastcos (float x) { static const float halfpi = 1.5707963267948966f; static const float halfpiminustwopi = -4.7123889803846899f; float offset = (x > halfpi) ? halfpiminustwopi : halfpi; return fastsin (x + offset); } static inline float fastercos (float x) { static const float twooverpi = 0.63661977236758134f; static const float p = 0.54641335845679634f; union { float f; uint32_t i; } vx = { x }; vx.i &= 0x7FFFFFFF; float qpprox = 1.0f - twooverpi * vx.f; return qpprox + p * qpprox * (1.0f - qpprox * qpprox); } static inline float fastcosfull (float x) { static const float halfpi = 1.5707963267948966f; return fastsinfull (x + halfpi); } static inline float fastercosfull (float x) { static const float halfpi = 1.5707963267948966f; return fastersinfull (x + halfpi); } static inline float fasttan (float x) { static const float halfpi = 1.5707963267948966f; return fastsin (x) / fastsin (x + halfpi); } static inline float fastertan (float x) { return fastersin (x) / fastercos (x); } static inline float fasttanfull (float x) { static const float twopi = 6.2831853071795865f; static const float invtwopi = 0.15915494309189534f; int k = x * invtwopi; float half = (x < 0) ? -0.5f : 0.5f; float xnew = x - (half + k) * twopi; return fastsin (xnew) / fastcos (xnew); } static inline float fastertanfull (float x) { static const float twopi = 6.2831853071795865f; static const float invtwopi = 0.15915494309189534f; int k = x * invtwopi; float half = (x < 0) ? -0.5f : 0.5f; float xnew = x - (half + k) * twopi; return fastersin (xnew) / fastercos (xnew); } #ifdef __SSE2__ static inline v4sf vfastsin (const v4sf x) { const v4sf fouroverpi = v4sfl (1.2732395447351627f); const v4sf fouroverpisq = v4sfl (0.40528473456935109f); const v4sf q = v4sfl (0.78444488374548933f); const v4sf p = v4sfl (0.20363937680730309f); const v4sf r = v4sfl (0.015124940802184233f); const v4sf s = v4sfl (-0.0032225901625579573f); union { v4sf f; v4si i; } vx = { x }; v4si sign = vx.i & v4sil (0x80000000); vx.i &= v4sil (0x7FFFFFFF); v4sf qpprox = fouroverpi * x - fouroverpisq * x * vx.f; v4sf qpproxsq = qpprox * qpprox; union { v4sf f; v4si i; } vy; vy.f = qpproxsq * (p + qpproxsq * (r + qpproxsq * s)); vy.i ^= sign; return q * qpprox + vy.f; } static inline v4sf vfastersin (const v4sf x) { const v4sf fouroverpi = v4sfl (1.2732395447351627f); const v4sf fouroverpisq = v4sfl (0.40528473456935109f); const v4sf q = v4sfl (0.77633023248007499f); const v4sf plit = v4sfl (0.22308510060189463f); union { v4sf f; v4si i; } p = { plit }; union { v4sf f; v4si i; } vx = { x }; v4si sign = vx.i & v4sil (0x80000000); vx.i &= v4sil (0x7FFFFFFF); v4sf qpprox = fouroverpi * x - fouroverpisq * x * vx.f; p.i |= sign; return qpprox * (q + p.f * qpprox); } static inline v4sf vfastsinfull (const v4sf x) { const v4sf twopi = v4sfl (6.2831853071795865f); const v4sf invtwopi = v4sfl (0.15915494309189534f); v4si k = v4sf_to_v4si (x * invtwopi); v4sf ltzero = _mm_cmplt_ps (x, v4sfl (0.0f)); v4sf half = _mm_or_ps (_mm_and_ps (ltzero, v4sfl (-0.5f)), _mm_andnot_ps (ltzero, v4sfl (0.5f))); return vfastsin ((half + v4si_to_v4sf (k)) * twopi - x); } static inline v4sf vfastersinfull (const v4sf x) { const v4sf twopi = v4sfl (6.2831853071795865f); const v4sf invtwopi = v4sfl (0.15915494309189534f); v4si k = v4sf_to_v4si (x * invtwopi); v4sf ltzero = _mm_cmplt_ps (x, v4sfl (0.0f)); v4sf half = _mm_or_ps (_mm_and_ps (ltzero, v4sfl (-0.5f)), _mm_andnot_ps (ltzero, v4sfl (0.5f))); return vfastersin ((half + v4si_to_v4sf (k)) * twopi - x); } static inline v4sf vfastcos (const v4sf x) { const v4sf halfpi = v4sfl (1.5707963267948966f); const v4sf halfpiminustwopi = v4sfl (-4.7123889803846899f); v4sf lthalfpi = _mm_cmpnlt_ps (x, halfpi); v4sf offset = _mm_or_ps (_mm_and_ps (lthalfpi, halfpiminustwopi), _mm_andnot_ps (lthalfpi, halfpi)); return vfastsin (x + offset); } static inline v4sf vfastercos (v4sf x) { const v4sf twooverpi = v4sfl (0.63661977236758134f); const v4sf p = v4sfl (0.54641335845679634); v4sf vx = v4sf_fabs (x); v4sf qpprox = v4sfl (1.0f) - twooverpi * vx; return qpprox + p * qpprox * (v4sfl (1.0f) - qpprox * qpprox); } static inline v4sf vfastcosfull (const v4sf x) { const v4sf halfpi = v4sfl (1.5707963267948966f); return vfastsinfull (x + halfpi); } static inline v4sf vfastercosfull (const v4sf x) { const v4sf halfpi = v4sfl (1.5707963267948966f); return vfastersinfull (x + halfpi); } static inline v4sf vfasttan (const v4sf x) { const v4sf halfpi = v4sfl (1.5707963267948966f); return vfastsin (x) / vfastsin (x + halfpi); } static inline v4sf vfastertan (const v4sf x) { return vfastersin (x) / vfastercos (x); } static inline v4sf vfasttanfull (const v4sf x) { const v4sf twopi = v4sfl (6.2831853071795865f); const v4sf invtwopi = v4sfl (0.15915494309189534f); v4si k = v4sf_to_v4si (x * invtwopi); v4sf ltzero = _mm_cmplt_ps (x, v4sfl (0.0f)); v4sf half = _mm_or_ps (_mm_and_ps (ltzero, v4sfl (-0.5f)), _mm_andnot_ps (ltzero, v4sfl (0.5f))); v4sf xnew = x - (half + v4si_to_v4sf (k)) * twopi; return vfastsin (xnew) / vfastcos (xnew); } static inline v4sf vfastertanfull (const v4sf x) { const v4sf twopi = v4sfl (6.2831853071795865f); const v4sf invtwopi = v4sfl (0.15915494309189534f); v4si k = v4sf_to_v4si (x * invtwopi); v4sf ltzero = _mm_cmplt_ps (x, v4sfl (0.0f)); v4sf half = _mm_or_ps (_mm_and_ps (ltzero, v4sfl (-0.5f)), _mm_andnot_ps (ltzero, v4sfl (0.5f))); v4sf xnew = x - (half + v4si_to_v4sf (k)) * twopi; return vfastersin (xnew) / vfastercos (xnew); } #endif //__SSE2__ #endif // __FAST_TRIG_H_
{ "pile_set_name": "Github" }
package com.spun.util.io; import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.DataOutputStream; import java.io.File; import java.io.FileFilter; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.Reader; import java.nio.channels.FileChannel; import java.nio.charset.CharsetDecoder; import java.nio.charset.CodingErrorAction; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import javax.imageio.ImageIO; import com.spun.util.ArrayUtils; import com.spun.util.Asserts; import com.spun.util.FormattedException; import com.spun.util.ObjectUtils; /** * A static class of convenience functions for Files **/ public class FileUtils { public static File createTempDirectory() throws IOException { File tempFile = File.createTempFile("TEMP", null); tempFile.delete(); tempFile.mkdirs(); return tempFile; } public static void deleteDirectory(File directory) throws IOException { // delete all directory File directories[] = directory.listFiles(new SimpleDirectoryFilter()); for (int i = 0; i < directories.length; i++) { deleteDirectory(directories[i]); } // Delete all Files. File files[] = directory.listFiles(new SimpleFileFilter()); for (int i = 0; i < files.length; i++) { files[i].delete(); } // delete self. directory.delete(); } public static String readFromClassPath(Class<?> clazz, String string) { final InputStream resourceAsStream = clazz.getResourceAsStream(string); if (resourceAsStream == null) { String message = String.format("Could not find %s from %s", string, clazz.getName()); throw new RuntimeException(message); } String resource = FileUtils.readStream(resourceAsStream); return resource; } public static File[] getRecursiveFileList(File directory) { return getRecursiveFileList(directory, new SimpleFileFilter()); } public static File[] getRecursiveFileList(File directory, FileFilter filter) { ArrayList<File> list = new ArrayList<File>(); if (!directory.isDirectory()) { throw new Error("File is not a directory: " + directory.getName()); } File directories[] = directory.listFiles(new SimpleDirectoryFilter()); for (int i = 0; i < directories.length; i++) { ArrayUtils.addArray(list, getRecursiveFileList(directories[i], filter)); } File files[] = directory.listFiles(filter); ArrayUtils.addArray(list, files); return list.toArray(new File[list.size()]); } public static void copyFile(File in, File out) { try { out.getParentFile().mkdirs(); try (FileInputStream sIn = new FileInputStream(in)) { try (FileChannel inChannel = sIn.getChannel()) { try (FileOutputStream sOut = new FileOutputStream(out)) { try (FileChannel outChannel = sOut.getChannel()) { outChannel.transferFrom(inChannel, 0, inChannel.size()); } } } } } catch (Exception e) { ObjectUtils.throwAsError(e); } } public static void copyStream(InputStream in, OutputStream out) { try { byte[] buf = new byte[1024]; int i = 0; while ((i = in.read(buf)) != -1) { out.write(buf, 0, i); } in.close(); out.close(); } catch (Throwable t) { throw ObjectUtils.throwAsError(t); } } public static void redirectInputToFile(String fileName, InputStream in) { try { FileOutputStream fos = new FileOutputStream(new File(fileName), false); copyStream(in, fos); } catch (Throwable t) { throw ObjectUtils.throwAsError(t); } } public static void copyFileToDirectory(String file, File tempDir) { try { File in = new File(file); File out = new File(tempDir, in.getName()); copyFile(in, out); } catch (Throwable t) { throw ObjectUtils.throwAsError(t); } } public static void writeFile(File file, String text) { try { Asserts.assertNotNull("Writing to file: " + file, text); file.getCanonicalFile().getParentFile().mkdirs(); try (BufferedWriter out = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8)) { out.write(text); } } catch (Throwable t) { throw ObjectUtils.throwAsError(t); } } public static void writeFileQuietly(File file, String text) { writeFile(file, text); } public static void writeFile(File file, CharSequence data) { try { Asserts.assertNotNull("Writing to file: " + file, data); file.getCanonicalFile().getParentFile().mkdirs(); try (DataOutputStream writer = new DataOutputStream(new FileOutputStream(file))) { for (int i = 0; i < data.length(); i++) { writer.write(data.charAt(i)); } } } catch (Throwable t) { throw ObjectUtils.throwAsError(t); } } public static void writeFile(File file, InputStream data) { try { Asserts.assertNotNull("Writing to file: " + file, data); file.getCanonicalFile().getParentFile().mkdirs(); copyStream(data, new FileOutputStream(file)); } catch (Throwable t) { throw ObjectUtils.throwAsError(t); } } public static String readFile(String absolutePath) { return readFile(new File(absolutePath)); } public static String readFile(File file) { try { if (!file.exists()) { throw new RuntimeException("Invalid file '" + file.getAbsolutePath() + "'"); } CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder(); decoder.onMalformedInput(CodingErrorAction.IGNORE); Reader reader = new InputStreamReader(Files.newInputStream(file.toPath()), decoder); BufferedReader in = new BufferedReader(reader); return readBuffer(in); } catch (Throwable t) { throw ObjectUtils.throwAsError(t); } } public static String readBuffer(BufferedReader in) { try { StringBuffer string = new StringBuffer(); while (in.ready()) { string.append(in.readLine()); string.append("\n"); } in.close(); return string.toString(); } catch (Throwable t) { throw ObjectUtils.throwAsError(t); } } public static String readFileWithSuppressedExceptions(File databaseFile) { return FileUtils.readFile(databaseFile); } public static File saveToFile(String prefix, Reader input) { try { File file = File.createTempFile(prefix, null); try (BufferedWriter bw = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8)) { try (BufferedReader inputReader = new BufferedReader(input)) { String thisLine; while ((thisLine = inputReader.readLine()) != null) { bw.write(thisLine); bw.newLine(); } } } return file; } catch (IOException e) { throw new FormattedException("Failed to save file (prefix, message): %s, %s", prefix, e.getMessage()); } } public static String getDirectoryFriendlyName(String name) { if (name == null) { return ""; } StringBuffer result = new StringBuffer(); for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); switch (c) { case '.' : break; default : result.append(c); break; } } return result.toString(); } public static String getExtensionWithDot(String filename) { int p = filename.lastIndexOf('.'); return filename.substring(p); } public static String getExtensionWithoutDot(String filename) { return getExtensionWithDot(filename).substring(1); } public static void createIfNeeded(String file) { try { File f = new File(file); if (!f.exists()) { if (isImage(file)) { createEmptyImage(f); } else { writeFile(f, ""); } } } catch (Throwable e) { throw ObjectUtils.throwAsError(e); } } private static void createEmptyImage(File file) { try { BufferedImage image = new BufferedImage(2, 2, BufferedImage.TYPE_INT_ARGB); ImageIO.write(image, "png", file); } catch (IOException e) { throw ObjectUtils.throwAsError(e); } } private static boolean isImage(String file) { return file.endsWith(".png"); } public static String readStream(InputStream resourceAsStream) { BufferedReader reader = new BufferedReader(new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8)); return FileUtils.readBuffer(reader); } public static char[] loadResourceFromClasspathAsBytes(Class<?> clazz, String name) { return extractBytes(clazz.getResourceAsStream(name)); } public static char[] extractBytes(final InputStream resourceAsStream) { try { ArrayList<Character> data = new ArrayList<Character>(); int b = resourceAsStream.read(); while (b != -1) { data.add(new Character((char) b)); b = resourceAsStream.read(); } return FileUtils.toChars(data); } catch (Throwable t) { throw ObjectUtils.throwAsError(t); } } public static char[] toChars(List<Character> data) { char[] out = new char[data.size()]; for (int i = 0; i < out.length; i++) { out[i] = data.get(i); } return out; } public static boolean isNonEmptyFile(String approved) { File file = new File(approved); return file.exists() && file.length() > 0; } public static void ensureParentDirectoriesExist(File file) { File dir = file.getParentFile(); if (!dir.exists()) { dir.mkdirs(); } } public static String readFile(File file, String defaultText) { try { return readFile(file); } catch (Throwable e) { return defaultText; } } public static String getCurrentDirectory() { try { return new File(".").getCanonicalPath(); } catch (Throwable e) { throw ObjectUtils.throwAsError(e); } } }
{ "pile_set_name": "Github" }
import { CreateConfigurationSetCommandInput, CreateConfigurationSetCommandOutput, } from "./commands/CreateConfigurationSetCommand"; import { CreateConfigurationSetEventDestinationCommandInput, CreateConfigurationSetEventDestinationCommandOutput, } from "./commands/CreateConfigurationSetEventDestinationCommand"; import { DeleteConfigurationSetCommandInput, DeleteConfigurationSetCommandOutput, } from "./commands/DeleteConfigurationSetCommand"; import { DeleteConfigurationSetEventDestinationCommandInput, DeleteConfigurationSetEventDestinationCommandOutput, } from "./commands/DeleteConfigurationSetEventDestinationCommand"; import { GetConfigurationSetEventDestinationsCommandInput, GetConfigurationSetEventDestinationsCommandOutput, } from "./commands/GetConfigurationSetEventDestinationsCommand"; import { ListConfigurationSetsCommandInput, ListConfigurationSetsCommandOutput, } from "./commands/ListConfigurationSetsCommand"; import { SendVoiceMessageCommandInput, SendVoiceMessageCommandOutput } from "./commands/SendVoiceMessageCommand"; import { UpdateConfigurationSetEventDestinationCommandInput, UpdateConfigurationSetEventDestinationCommandOutput, } from "./commands/UpdateConfigurationSetEventDestinationCommand"; import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, RegionInputConfig, RegionResolvedConfig, resolveEndpointsConfig, resolveRegionConfig, } from "@aws-sdk/config-resolver"; import { getContentLengthPlugin } from "@aws-sdk/middleware-content-length"; import { HostHeaderInputConfig, HostHeaderResolvedConfig, getHostHeaderPlugin, resolveHostHeaderConfig, } from "@aws-sdk/middleware-host-header"; import { getLoggerPlugin } from "@aws-sdk/middleware-logger"; import { RetryInputConfig, RetryResolvedConfig, getRetryPlugin, resolveRetryConfig } from "@aws-sdk/middleware-retry"; import { AwsAuthInputConfig, AwsAuthResolvedConfig, getAwsAuthPlugin, resolveAwsAuthConfig, } from "@aws-sdk/middleware-signing"; import { UserAgentInputConfig, UserAgentResolvedConfig, getUserAgentPlugin, resolveUserAgentConfig, } from "@aws-sdk/middleware-user-agent"; import { HttpHandler as __HttpHandler } from "@aws-sdk/protocol-http"; import { Client as __Client, SmithyConfiguration as __SmithyConfiguration, SmithyResolvedConfiguration as __SmithyResolvedConfiguration, } from "@aws-sdk/smithy-client"; import { RegionInfoProvider, Credentials as __Credentials, Decoder as __Decoder, Encoder as __Encoder, HashConstructor as __HashConstructor, HttpHandlerOptions as __HttpHandlerOptions, Logger as __Logger, Provider as __Provider, StreamCollector as __StreamCollector, UrlParser as __UrlParser, } from "@aws-sdk/types"; export type ServiceInputTypes = | CreateConfigurationSetCommandInput | CreateConfigurationSetEventDestinationCommandInput | DeleteConfigurationSetCommandInput | DeleteConfigurationSetEventDestinationCommandInput | GetConfigurationSetEventDestinationsCommandInput | ListConfigurationSetsCommandInput | SendVoiceMessageCommandInput | UpdateConfigurationSetEventDestinationCommandInput; export type ServiceOutputTypes = | CreateConfigurationSetCommandOutput | CreateConfigurationSetEventDestinationCommandOutput | DeleteConfigurationSetCommandOutput | DeleteConfigurationSetEventDestinationCommandOutput | GetConfigurationSetEventDestinationsCommandOutput | ListConfigurationSetsCommandOutput | SendVoiceMessageCommandOutput | UpdateConfigurationSetEventDestinationCommandOutput; export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__HttpHandlerOptions>> { /** * The HTTP handler to use. Fetch in browser and Https in Nodejs. */ requestHandler?: __HttpHandler; /** * A constructor for a class implementing the @aws-sdk/types.Hash interface * that computes the SHA-256 HMAC or checksum of a string or binary buffer. */ sha256?: __HashConstructor; /** * The function that will be used to convert strings into HTTP endpoints. */ urlParser?: __UrlParser; /** * A function that can calculate the length of a request body. */ bodyLengthChecker?: (body: any) => number | undefined; /** * A function that converts a stream into an array of bytes. */ streamCollector?: __StreamCollector; /** * The function that will be used to convert a base64-encoded string to a byte array */ base64Decoder?: __Decoder; /** * The function that will be used to convert binary data to a base64-encoded string */ base64Encoder?: __Encoder; /** * The function that will be used to convert a UTF8-encoded string to a byte array */ utf8Decoder?: __Decoder; /** * The function that will be used to convert binary data to a UTF-8 encoded string */ utf8Encoder?: __Encoder; /** * The string that will be used to populate default value in 'User-Agent' header */ defaultUserAgent?: string; /** * The runtime environment */ runtime?: string; /** * Disable dyanamically changing the endpoint of the client based on the hostPrefix * trait of an operation. */ disableHostPrefix?: boolean; /** * The service name with which to sign requests. */ signingName?: string; /** * Default credentials provider; Not available in browser runtime */ credentialDefaultProvider?: (input: any) => __Provider<__Credentials>; /** * The AWS region to which this client will send requests */ region?: string | __Provider<string>; /** * Value for how many times a request will be made at most in case of retry. */ maxAttempts?: number | __Provider<number>; /** * Optional logger for logging debug/info/warn/error. */ logger?: __Logger; /** * Fetch related hostname, signing name or signing region with given region. */ regionInfoProvider?: RegionInfoProvider; } export type PinpointSMSVoiceClientConfig = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & ClientDefaults & RegionInputConfig & EndpointsInputConfig & AwsAuthInputConfig & RetryInputConfig & UserAgentInputConfig & HostHeaderInputConfig; export type PinpointSMSVoiceClientResolvedConfig = __SmithyResolvedConfiguration<__HttpHandlerOptions> & Required<ClientDefaults> & RegionResolvedConfig & EndpointsResolvedConfig & AwsAuthResolvedConfig & RetryResolvedConfig & UserAgentResolvedConfig & HostHeaderResolvedConfig; /** * Pinpoint SMS and Voice Messaging public facing APIs */ export class PinpointSMSVoiceClient extends __Client< __HttpHandlerOptions, ServiceInputTypes, ServiceOutputTypes, PinpointSMSVoiceClientResolvedConfig > { readonly config: PinpointSMSVoiceClientResolvedConfig; constructor(configuration: PinpointSMSVoiceClientConfig) { let _config_0 = { ...__ClientDefaultValues, ...configuration, }; let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveAwsAuthConfig(_config_2); let _config_4 = resolveRetryConfig(_config_3); let _config_5 = resolveUserAgentConfig(_config_4); let _config_6 = resolveHostHeaderConfig(_config_5); super(_config_6); this.config = _config_6; this.middlewareStack.use(getAwsAuthPlugin(this.config)); this.middlewareStack.use(getRetryPlugin(this.config)); this.middlewareStack.use(getUserAgentPlugin(this.config)); this.middlewareStack.use(getContentLengthPlugin(this.config)); this.middlewareStack.use(getHostHeaderPlugin(this.config)); this.middlewareStack.use(getLoggerPlugin(this.config)); } destroy(): void { super.destroy(); } }
{ "pile_set_name": "Github" }
(be color (R)) (be color (B)) (be tree (@ E)) (be tree (@P (T @C @L @X @R)) (color @C) (tree @P @L) (call @P @X) (tree @P @R) ) (be bal (B (T R (T R @A @X @B) @Y @C) @Z @D (T R (T B @A @X @B) @Y (T B @C @Z @D)))) (be bal (B (T R @A @X (T R @B @Y @C)) @Z @D (T R (T B @A @X @B) @Y (T B @C @Z @D)))) (be bal (B @A @X (T R (T R @B @Y @C) @Z @D) (T R (T B @A @X @B) @Y (T B @C @Z @D)))) (be bal (B @A @X (T R @B @Y (T R @C @Z @D)) (T R (T B @A @X @B) @Y (T B @C @Z @D)))) (be balance (@C @A @X @B @S) (bal @C @A @X @B @S) T ) (be balance (@C @A @X @B (T @C @A @X @B))) (be ins (@X E (T R E @X E))) (be ins (@X (T @C @A @Y @B) @R) (^ @ (> (-> @Y) (-> @X))) (ins @X @A @Ao) (balance @C @Ao @Y @B @R) T ) (be ins (@X (T @C @A @Y @B) @R) (^ @ (> (-> @X) (-> @Y))) (ins @X @B @Bo) (balance @C @A @Y @Bo @R) T ) (be ins (@X (T @C @A @Y @B) (T @C @A @Y @B))) (be insert (@X @S (T B @A @Y @B)) (ins @X @S (T @ @A @Y @B)) )
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <!--<string name="pref_tools_title">"Supported tools"</string>--> <!--<string name="pref_tools_summary">"List of experimental tools"</string>--> <!--<string name="pref_tools_text_title">"Text selection"</string>--> <!--<string name="pref_tools_text_summary">"Text selection tools: copy, translate and search in Google"</string>--> <!--<string name="pref_tools_highlight_title">"Text highlight"</string>--> <!--<string name="pref_tools_highlight_summary">"Text highlight tools"</string>--> <!--<string name="pref_tools_drawing_title">"Free-hand drawing"</string>--> <!--<string name="pref_tools_drawing_summary">"Free-hand drawing tools"</string>--> <!--<string name="pref_tools_notes_title">"Notes"</string>--> <!--<string name="pref_tools_notes_summary">"Text notes and notebook tools"</string>--> <!--<string name="pref_dictionarytype_title">"Dictionary"</string>--> <!--<string name="pref_dictionarytype_summary">"Third party application to lookup words translation"</string>--> </resources>
{ "pile_set_name": "Github" }
// Copyright 2015, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // The Google C++ Testing Framework (Google Test) // // This header file defines the GTEST_OS_* macro. // It is separate from gtest-port.h so that custom/gtest-port.h can include it. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_ // Determines the platform on which Google Test is compiled. #ifdef __CYGWIN__ # define GTEST_OS_CYGWIN 1 #elif defined __SYMBIAN32__ # define GTEST_OS_SYMBIAN 1 #elif defined _WIN32 # define GTEST_OS_WINDOWS 1 # ifdef _WIN32_WCE # define GTEST_OS_WINDOWS_MOBILE 1 # elif defined(__MINGW__) || defined(__MINGW32__) # define GTEST_OS_WINDOWS_MINGW 1 # elif defined(WINAPI_FAMILY) # include <winapifamily.h> # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) # define GTEST_OS_WINDOWS_DESKTOP 1 # elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) # define GTEST_OS_WINDOWS_PHONE 1 # elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) # define GTEST_OS_WINDOWS_RT 1 # else // WINAPI_FAMILY defined but no known partition matched. // Default to desktop. # define GTEST_OS_WINDOWS_DESKTOP 1 # endif # else # define GTEST_OS_WINDOWS_DESKTOP 1 # endif // _WIN32_WCE #elif defined __APPLE__ # define GTEST_OS_MAC 1 # if TARGET_OS_IPHONE # define GTEST_OS_IOS 1 # endif #elif defined __FreeBSD__ # define GTEST_OS_FREEBSD 1 #elif defined __linux__ # define GTEST_OS_LINUX 1 # if defined __ANDROID__ # define GTEST_OS_LINUX_ANDROID 1 # endif #elif defined __MVS__ # define GTEST_OS_ZOS 1 #elif defined(__sun) && defined(__SVR4) # define GTEST_OS_SOLARIS 1 #elif defined(_AIX) # define GTEST_OS_AIX 1 #elif defined(__hpux) # define GTEST_OS_HPUX 1 #elif defined __native_client__ # define GTEST_OS_NACL 1 #elif defined __OpenBSD__ # define GTEST_OS_OPENBSD 1 #elif defined __QNX__ # define GTEST_OS_QNX 1 #endif // __CYGWIN__ #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
{ "pile_set_name": "Github" }
True : object.conclusion = "NN" object.tag == "VERB" : object.conclusion = "VERB" object.prevTag1 == "ADP" : object.conclusion = "NOUN" object.nextTag1 == "" : object.conclusion = "NOUN" object.prevTag1 == "PRON" : object.conclusion = "VERB" object.suffixL2 == "VÁ" : object.conclusion = "ADJ" object.prevTag2 == "ADP" and object.prevTag1 == "ADJ" : object.conclusion = "NOUN" object.prevWord1 == "druhou" : object.conclusion = "VERB" object.prevWord2 == "po" : object.conclusion = "VERB" object.suffixL3 == "val" : object.conclusion = "VERB" object.nextTag1 == "VERB" and object.nextTag2 == "" : object.conclusion = "NOUN" object.prevTag1 == "ADJ" and object.nextTag1 == "VERB" : object.conclusion = "NOUN" object.prevWord2 == "M" : object.conclusion = "PROPN" object.word == "Bylo" and object.nextWord1 == "to" : object.conclusion = "AUX" object.nextWord1 == "má" : object.conclusion = "NOUN" object.suffixL3 == "hel" : object.conclusion = "NOUN" object.prevWord1 == "jsou" : object.conclusion = "ADJ" object.nextWord1 == "byl" : object.conclusion = "PROPN" object.prevTag1 == "" and object.word == "Bylo" and object.nextTag1 == "ADJ" : object.conclusion = "AUX" object.tag == "ADP" : object.conclusion = "ADP" object.nextWord1 == "." : object.conclusion = "PROPN" object.suffixL3 == "lem" : object.conclusion = "ADV" object.nextTag1 == "ADP" and object.nextTag2 == "NOUN" : object.conclusion = "ADV" object.tag == "NOUN" : object.conclusion = "NOUN" object.prevTag1 == "ADV" and object.word == "večer" : object.conclusion = "ADV" object.prevWord1 == "tak" : object.conclusion = "ADJ" object.prevWord1 == "byli" : object.conclusion = "ADJ" object.prevTag1 == "PUNCT" and object.word == "světle" and object.nextTag1 == "ADJ" : object.conclusion = "ADV" object.suffixL2 == "bý" : object.conclusion = "ADJ" object.prevWord1 == "a" and object.word == "večer" : object.conclusion = "ADV" object.prevTag1 == "PRON" and object.word == "večer" and object.nextTag1 == "VERB" : object.conclusion = "ADV" object.prevWord1 == "někdo" : object.conclusion = "VERB" object.suffixL3 == "dni" : object.conclusion = "VERB" object.suffixL3 == "nuv" : object.conclusion = "VERB" object.suffixL3 == "žeň" : object.conclusion = "VERB" object.word == "místo" and object.nextTag1 == "ADJ" and object.nextTag2 == "NOUN" : object.conclusion = "ADP" object.word == "místo" and object.nextTag1 == "NOUN" : object.conclusion = "ADP" object.tag == "ADJ" : object.conclusion = "ADJ" object.prevTag1 == "ADJ" and object.nextTag1 == "PUNCT" : object.conclusion = "NOUN" object.nextTag1 == "PUNCT" and object.nextTag2 == "AUX" : object.conclusion = "ADJ" object.suffixL2 == "tá" : object.conclusion = "ADJ" object.prevWord2 == "v" : object.conclusion = "ADJ" object.prevWord1 == "k" and object.nextWord1 == "a" : object.conclusion = "NOUN" object.suffixL3 == "pou" : object.conclusion = "VERB" object.prevTag2 == "NOUN" : object.conclusion = "NOUN" object.prevWord1 == "se" and object.word == "stará" : object.conclusion = "VERB" object.suffixL3 == "éká" : object.conclusion = "VERB" object.suffixL3 == "och" : object.conclusion = "NOUN" object.suffixL3 == "kcí" : object.conclusion = "NOUN" object.nextWord2 == "pár" : object.conclusion = "NOUN" object.suffixL3 == "yho" : object.conclusion = "PROPN" object.tag == "PUNCT" : object.conclusion = "PUNCT" object.tag == "DET" : object.conclusion = "DET" object.prevTag1 == "CCONJ" and object.word == "to" and object.nextTag1 == "ADV" : object.conclusion = "PART" object.word == "hodně" and object.nextTag1 == "VERB" : object.conclusion = "ADV" object.prevTag1 == "PUNCT" and object.word == "to" and object.nextTag1 == "PART" : object.conclusion = "PART" object.prevTag2 == "VERB" and object.prevTag1 == "ADV" and object.word == "málo" : object.conclusion = "ADV" object.word == "hodně" and object.nextTag1 == "ADV" : object.conclusion = "ADV" object.prevWord1 == "" and object.word == "To" and object.nextWord1 == "jsem" : object.conclusion = "PART" object.word == "to" and object.nextWord1 == "ocitl" : object.conclusion = "PART" object.prevWord2 == "Co" and object.prevWord1 == "jsi" and object.word == "to" : object.conclusion = "PART" object.tag == "AUX" : object.conclusion = "AUX" object.word == "je" and object.nextTag1 == "VERB" : object.conclusion = "PRON" object.nextWord1 == "vidět" : object.conclusion = "VERB" object.prevTag1 == "VERB" and object.word == "je" : object.conclusion = "PRON" object.prevTag1 == "ADV" and object.nextTag1 == "PUNCT" : object.conclusion = "VERB" object.prevTag1 == "AUX" and object.word == "je" : object.conclusion = "PRON" object.prevTag1 == "PRON" and object.nextTag1 == "PUNCT" : object.conclusion = "VERB" object.prevWord2 == "," and object.word == "je" : object.conclusion = "AUX" object.prevTag2 == "VERB" and object.prevTag1 == "PRON" and object.word == "je" : object.conclusion = "PRON" object.prevTag1 == "NOUN" and object.nextTag1 == "PUNCT" : object.conclusion = "VERB" object.nextWord2 == "že" : object.conclusion = "AUX" object.prevWord2 == "ani" and object.word == "není" : object.conclusion = "AUX" object.suffixL2 == "ou" : object.conclusion = "AUX" object.word == "bylo" and object.nextTag1 == "ADP" : object.conclusion = "VERB" object.nextWord1 == "pro" : object.conclusion = "AUX" object.word == "byla" and object.nextTag1 == "ADP" : object.conclusion = "VERB" object.nextTag1 == "ADP" and object.nextTag2 == "DET" : object.conclusion = "AUX" object.word == "je" and object.nextWord1 == "v" : object.conclusion = "VERB" object.prevTag2 == "ADP" and object.prevTag1 == "NOUN" and object.word == "je" : object.conclusion = "VERB" object.prevWord1 == "kde" and object.word == "je" : object.conclusion = "VERB" object.word == "je" and object.nextTag1 == "ADV" and object.nextTag2 == "PUNCT" : object.conclusion = "VERB" object.word == "je" and object.nextTag1 == "ADV" and object.nextTag2 == "VERB" : object.conclusion = "PRON" object.word == "být" and object.nextTag1 == "PUNCT" : object.conclusion = "VERB" object.prevWord1 == "si" and object.word == "je" : object.conclusion = "PRON" object.nextWord1 == "vidět" : object.conclusion = "VERB" object.word == "být" and object.nextTag1 == "ADP" : object.conclusion = "VERB" object.prevTag2 == "PUNCT" and object.prevTag1 == "SCONJ" and object.word == "byla" : object.conclusion = "VERB" object.word == "není" and object.nextTag1 == "ADV" and object.nextTag2 == "PUNCT" : object.conclusion = "VERB" object.word == "je" and object.nextTag1 == "PRON" and object.nextTag2 == "ADP" : object.conclusion = "VERB" object.word == "bude" and object.nextTag1 == "ADV" and object.nextTag2 == "PUNCT" : object.conclusion = "VERB" object.prevWord1 == "" and object.nextWord1 == "tam" : object.conclusion = "VERB" object.prevTag1 == "PART" and object.nextTag1 == "PUNCT" : object.conclusion = "VERB" object.word == "je" and object.nextTag1 == "ADV" and object.nextTag2 == "ADP" : object.conclusion = "VERB" object.prevTag1 == "ADV" and object.word == "jsou" : object.conclusion = "VERB" object.nextWord1 == "tolik" : object.conclusion = "VERB" object.prevWord1 == "," and object.nextWord1 == "tam" : object.conclusion = "VERB" object.nextWord1 == "tady" : object.conclusion = "VERB" object.nextTag2 == "VERB" : object.conclusion = "AUX" object.prevWord1 == "''" and object.nextWord1 == "jsem" : object.conclusion = "VERB" object.prevTag2 == "" and object.prevTag1 == "CCONJ" and object.word == "je" : object.conclusion = "VERB" object.nextTag1 == "SCONJ" : object.conclusion = "VERB" object.word == "jsem" and object.nextWord1 == "jako" : object.conclusion = "AUX" object.word == "byl" and object.nextWord1 == "už" : object.conclusion = "VERB" object.word == "nebyl" and object.nextWord2 == "." : object.conclusion = "VERB" object.prevWord1 == "," and object.nextWord1 == "tu" : object.conclusion = "VERB" object.prevWord1 == "už" and object.word == "je" : object.conclusion = "VERB" object.prevTag2 == "SCONJ" and object.prevTag1 == "ADV" and object.word == "je" : object.conclusion = "AUX" object.nextWord1 == "pryč" : object.conclusion = "VERB" object.prevWord1 == "že" and object.nextWord1 == "." : object.conclusion = "VERB" object.prevTag1 == "PUNCT" and object.nextTag1 == "PUNCT" : object.conclusion = "VERB" object.prevTag2 == "VERB" : object.conclusion = "AUX" object.prevTag2 == "ADJ" and object.prevTag1 == "PUNCT" and object.word == "je" : object.conclusion = "AUX" object.prevWord2 == "''" and object.prevWord1 == "Kde" and object.word == "je" : object.conclusion = "VERB" object.prevWord2 == "kdy" : object.conclusion = "VERB" object.prevWord1 == "," and object.word == "není" : object.conclusion = "VERB" object.word == "byli" and object.nextWord2 == "spolu" : object.conclusion = "VERB" object.prevTag1 == "NOUN" and object.word == "byla" and object.nextTag1 == "PART" : object.conclusion = "VERB" object.prevTag1 == "ADV" and object.word == "bylo" and object.nextTag1 == "ADV" : object.conclusion = "VERB" object.word == "je" and object.nextWord1 == "s" : object.conclusion = "VERB" object.prevWord1 == "," and object.nextWord1 == "toho" : object.conclusion = "VERB" object.nextTag1 == "INTJ" and object.nextTag2 == "PUNCT" : object.conclusion = "VERB" object.prevWord1 == "" and object.nextWord1 == "tu" : object.conclusion = "VERB" object.prevTag1 == "" and object.nextTag1 == "ADP" : object.conclusion = "VERB" object.nextWord1 == "o" : object.conclusion = "AUX" object.nextWord2 == "zima" : object.conclusion = "VERB" object.word == "být" and object.nextTag1 == "ADV" and object.nextTag2 == "PUNCT" : object.conclusion = "VERB" object.prevWord2 == "V" and object.word == "bylo" : object.conclusion = "VERB" object.nextWord1 == "sami" : object.conclusion = "VERB" object.word == "není" and object.nextWord1 == "v" : object.conclusion = "VERB" object.nextWord1 == "dokořán" : object.conclusion = "VERB" object.prevWord2 == "" and object.prevWord1 == "Možná" and object.word == "je" : object.conclusion = "VERB" object.nextWord1 == "zima" : object.conclusion = "VERB" object.word == "je" and object.nextWord1 == "jich" : object.conclusion = "VERB" object.prevTag2 == "VERB" and object.prevTag1 == "PRON" and object.word == "je" : object.conclusion = "PRON" object.tag == "ADV" : object.conclusion = "ADV" object.prevWord2 == "," and object.prevWord1 == "a" and object.word == "tak" : object.conclusion = "CCONJ" object.word == "tu" and object.nextTag1 == "NOUN" : object.conclusion = "DET" object.prevTag2 == "" and object.prevTag1 == "VERB" and object.word == "tu" : object.conclusion = "ADV" object.prevTag2 == "PUNCT" and object.prevTag1 == "AUX" : object.conclusion = "ADV" object.prevTag2 == "" and object.prevTag1 == "AUX" : object.conclusion = "ADV" object.prevTag2 == "PUNCT" and object.prevTag1 == "VERB" and object.word == "tu" : object.conclusion = "ADV" object.prevWord2 == "" and object.prevWord1 == "A" and object.word == "tak" : object.conclusion = "CCONJ" object.word == "tak" and object.nextWord1 == "to" : object.conclusion = "ADV" object.word == "tu" and object.nextTag1 == "ADJ" : object.conclusion = "DET" object.word == "jak" and object.nextTag1 == "NOUN" : object.conclusion = "SCONJ" object.prevTag1 == "ADP" and object.nextTag1 == "PUNCT" : object.conclusion = "NOUN" object.word == "zítra" : object.conclusion = "ADV" object.word == "jak" and object.nextTag1 == "ADP" : object.conclusion = "SCONJ" object.word == "stejně" and object.nextTag1 == "VERB" : object.conclusion = "PART" object.word == "přece" and object.nextTag1 == "ADV" : object.conclusion = "PART" object.prevTag2 == "AUX" : object.conclusion = "ADV" object.prevWord1 == "a" and object.word == "jak" : object.conclusion = "SCONJ" object.nextTag2 == "PUNCT" : object.conclusion = "ADV" object.prevTag2 == "ADP" and object.prevTag1 == "ADJ" : object.conclusion = "NOUN" object.nextTag1 == "VERB" : object.conclusion = "ADV" object.prevWord2 == "s" : object.conclusion = "ADV" object.prevTag1 == "DET" and object.word == "ráno" : object.conclusion = "NOUN" object.prevTag2 == "NOUN" and object.prevTag1 == "VERB" and object.word == "už" : object.conclusion = "PART" object.word == "stejně" and object.nextTag1 == "AUX" : object.conclusion = "PART" object.prevTag2 == "CCONJ" and object.prevTag1 == "ADJ" : object.conclusion = "NOUN" object.prevTag1 == "PUNCT" and object.word == "tak" and object.nextTag1 == "PRON" : object.conclusion = "PART" object.word == "přece" and object.nextWord1 == "jen" : object.conclusion = "PART" object.prevTag1 == "AUX" : object.conclusion = "ADV" object.nextWord1 == "proč" : object.conclusion = "PART" object.word == "jak" and object.nextTag1 == "PRON" and object.nextTag2 == "NOUN" : object.conclusion = "SCONJ" object.prevTag1 == "ADJ" and object.word == "ráno" : object.conclusion = "NOUN" object.prevTag2 == "" and object.prevTag1 == "ADP" : object.conclusion = "NOUN" object.nextTag1 == "ADJ" : object.conclusion = "ADV" object.word == "tak" and object.nextTag1 == "ADP" : object.conclusion = "PART" object.word == "vůbec" and object.nextTag1 == "DET" : object.conclusion = "PART" object.word == "moc" and object.nextTag1 == "NOUN" : object.conclusion = "DET" object.word == "víc" and object.nextTag1 == "NOUN" : object.conclusion = "DET" object.prevTag1 == "ADP" and object.nextTag1 == "SCONJ" : object.conclusion = "DET" object.word == "jak" and object.nextWord2 == "po" : object.conclusion = "SCONJ" object.word == "jak" and object.nextWord2 == "v" : object.conclusion = "SCONJ" object.word == "jak" and object.nextTag1 == "PRON" and object.nextTag2 == "PROPN" : object.conclusion = "SCONJ" object.prevTag1 == "ADP" and object.nextTag1 == "NOUN" : object.conclusion = "ADJ" object.word == "trochu" : object.conclusion = "NOUN" object.prevTag1 == "ADP" and object.nextTag1 == "CCONJ" : object.conclusion = "NOUN" object.prevTag2 == "DET" and object.prevTag1 == "ADJ" : object.conclusion = "NOUN" object.nextWord2 == "." : object.conclusion = "ADV" object.word == "už" and object.nextWord1 == "nikdy" : object.conclusion = "PART" object.word == "vůbec" and object.nextTag1 == "ADV" and object.nextTag2 == "VERB" : object.conclusion = "PART" object.word == "stejně" and object.nextTag1 == "PRON" : object.conclusion = "PART" object.prevWord1 == "" and object.nextWord1 == "proto" : object.conclusion = "PART" object.nextWord1 == "léta" : object.conclusion = "PART" object.word == "zrovna" and object.nextWord2 == "." : object.conclusion = "PART" object.prevWord1 == "," and object.word == "jak" and object.nextWord1 == "jsi" : object.conclusion = "SCONJ" object.prevWord2 == "pozoroval" and object.prevWord1 == "," and object.word == "jak" : object.conclusion = "SCONJ" object.prevWord2 == "vidět" and object.prevWord1 == "," and object.word == "jak" : object.conclusion = "SCONJ" object.prevWord2 == "se" and object.word == "jak" : object.conclusion = "SCONJ" object.prevWord2 == "viděl" and object.prevWord1 == "," and object.word == "jak" : object.conclusion = "SCONJ" object.word == "blízko" and object.nextTag1 == "NOUN" : object.conclusion = "ADP" object.tag == "PRON" : object.conclusion = "PRON" object.word == "se" and object.nextWord1 == "mnou" : object.conclusion = "ADP" object.word == "ty" and object.nextTag1 == "NOUN" : object.conclusion = "DET" object.prevTag2 == "PRON" and object.prevTag1 == "PUNCT" : object.conclusion = "PRON" object.nextWord1 == "svým" : object.conclusion = "ADP" object.word == "se" and object.nextWord1 == "svou" : object.conclusion = "ADP" object.prevWord1 == "a" and object.word == "se" : object.conclusion = "ADP" object.prevTag1 == "NOUN" and object.word == "co" : object.conclusion = "ADV" object.word == "ty" and object.nextTag1 == "ADJ" : object.conclusion = "DET" object.word == "ti" and object.nextTag1 == "NUM" : object.conclusion = "DET" object.prevTag1 == "PUNCT" and object.word == "se" and object.nextTag1 == "DET" : object.conclusion = "ADP" object.prevTag2 == "ADV" and object.prevTag1 == "PUNCT" and object.word == "co" : object.conclusion = "SCONJ" object.word == "co" and object.nextWord1 == "nejrychleji" : object.conclusion = "ADV" object.word == "se" and object.nextWord1 == "životem" : object.conclusion = "ADP" object.prevTag1 == "NOUN" and object.word == "se" and object.nextTag1 == "ADJ" : object.conclusion = "ADP" object.word == "ti" and object.nextWord2 == "kteří" : object.conclusion = "DET" object.word == "Ty" and object.nextTag1 == "NUM" : object.conclusion = "DET" object.prevTag1 == "" and object.word == "Ty" and object.nextTag1 == "ADJ" : object.conclusion = "DET" object.word == "se" and object.nextWord1 == "ženou" : object.conclusion = "ADP" object.word == "se" and object.nextWord1 == "všemi" : object.conclusion = "ADP" object.prevWord1 == "i" and object.word == "se" : object.conclusion = "ADP" object.word == "se" and object.nextWord1 == "svými" : object.conclusion = "ADP" object.prevWord2 == "doby" and object.prevWord1 == "," and object.word == "co" : object.conclusion = "SCONJ" object.word == "ti" and object.nextWord2 == "co" : object.conclusion = "DET" object.prevWord1 == "," and object.word == "co" and object.nextWord1 == "?" : object.conclusion = "PART" object.prevTag1 == "VERB" and object.word == "co" and object.nextTag1 == "ADV" : object.conclusion = "ADV" object.prevWord1 == "Jen" and object.word == "co" : object.conclusion = "ADV" object.tag == "CCONJ" : object.conclusion = "CCONJ" object.word == "proto" and object.nextTag1 == "PUNCT" : object.conclusion = "ADV" object.prevWord1 == "jednak" : object.conclusion = "CCONJ" object.prevTag1 == "AUX" and object.word == "i" : object.conclusion = "PART" object.prevWord1 == "jsem" : object.conclusion = "CCONJ" object.word == "A" and object.nextTag1 == "PUNCT" and object.nextTag2 == "PROPN" : object.conclusion = "PROPN" object.prevWord1 == "právě" : object.conclusion = "ADV" object.prevTag1 == "VERB" and object.word == "i" and object.nextTag1 == "NOUN" : object.conclusion = "PART" object.prevWord1 == "nimi" and object.word == "i" : object.conclusion = "PART" object.prevTag1 == "CCONJ" and object.nextTag1 == "DET" : object.conclusion = "PART" object.word == "i" and object.nextWord1 == "něco" : object.conclusion = "PART" object.tag == "NUM" : object.conclusion = "NUM" object.tag == "SCONJ" : object.conclusion = "SCONJ" object.prevTag1 == "PART" and object.word == "že" and object.nextTag1 == "AUX" : object.conclusion = "PART" object.prevWord1 == "," and object.word == "že" and object.nextWord1 == "?" : object.conclusion = "PART" object.prevTag1 == "PART" and object.word == "ať" : object.conclusion = "PART" object.word == "Až" and object.nextTag1 == "ADV" : object.conclusion = "PART" object.nextTag2 == "VERB" : object.conclusion = "SCONJ" object.tag == "PART" : object.conclusion = "PART" object.prevTag1 == "PUNCT" and object.word == "až" : object.conclusion = "SCONJ" object.word == "až" and object.nextTag1 == "ADP" and object.nextTag2 == "NOUN" : object.conclusion = "PART" object.word == "právě" and object.nextTag1 == "VERB" : object.conclusion = "ADV" object.prevTag1 == "AUX" and object.word == "třeba" : object.conclusion = "ADV" object.word == "již" and object.nextTag1 == "VERB" : object.conclusion = "ADV" object.prevTag1 == "NOUN" and object.word == "ani" and object.nextTag1 == "NOUN" : object.conclusion = "CCONJ" object.word == "ani" and object.nextTag1 == "ADJ" and object.nextTag2 == "PUNCT" : object.conclusion = "CCONJ" object.word == "Možná" and object.nextTag1 == "PUNCT" and object.nextTag2 == "SCONJ" : object.conclusion = "ADV" object.prevTag1 == "PUNCT" and object.word == "ani" and object.nextTag1 == "ADP" : object.conclusion = "CCONJ" object.prevTag1 == "PUNCT" and object.word == "ani" and object.nextTag1 == "NOUN" : object.conclusion = "CCONJ" object.word == "ani" and object.nextWord2 == "ani" : object.conclusion = "CCONJ" object.prevWord2 == "jen" : object.conclusion = "ADV" object.word == "Tak" and object.nextWord2 == "to" : object.conclusion = "ADV" object.prevTag1 == "PUNCT" and object.word == "ovšem" : object.conclusion = "CCONJ" object.prevTag2 == "SCONJ" and object.prevTag1 == "VERB" and object.word == "ani" : object.conclusion = "CCONJ" object.prevWord2 == "ani" and object.word == "ani" : object.conclusion = "CCONJ" object.word == "jen" and object.nextWord1 == "a" : object.conclusion = "ADV" object.word == "Tak" and object.nextTag1 == "ADV" and object.nextTag2 == "PUNCT" : object.conclusion = "ADV" object.word == "právě" and object.nextTag1 == "ADP" and object.nextTag2 == "NOUN" : object.conclusion = "ADV" object.word == "rozhodně" and object.nextTag1 == "PUNCT" and object.nextTag2 == "" : object.conclusion = "ADV" object.word == "prostě" and object.nextWord1 == "a" : object.conclusion = "ADV" object.tag == "PROPN" : object.conclusion = "PROPN" object.prevWord2 == "" and object.word == "K" : object.conclusion = "ADP" object.tag == "INTJ" : object.conclusion = "INTJ" object.tag == "X" : object.conclusion = "X"
{ "pile_set_name": "Github" }
{ "id": "nl.fokkezb.pullToRefresh", "name": "nl.fokkezb.pullToRefresh", "description" : "Implementation of the pull-to-refresh header for table views.", "author": "Fokke Zandbergen", "version": "1.5.1", "copyright":"Copyright (c) 2013", "license":"Apache 2.0", "min-alloy-version": "1.1", "min-titanium-version":"3.0", "tags":"tableview,headerpullview,pulltorefresh", "platforms":"ios,android,blackberry,mobileweb" }
{ "pile_set_name": "Github" }
{ "extends": "./tsconfig.json", "compilerOptions": { "module": "commonjs", "outDir": "production-server/" }, "include": ["./server/**/*.ts"], "exclude": ["./server/**/*.test.ts"] }
{ "pile_set_name": "Github" }
&input title='N', zed=7.0, rel=2, config='[He] 2s2 2p3 3d-1' iswitch=3, dft='LDA', / &inputp lloc=2, pseudotype=3, file_pseudopw='N.rel-pz-rrkjus.UPF', author='ADC', nlcc=.true., rcore=0.7, / 8 2S 1 0 2.00 0.00 1.30 1.60 0.50 2S 1 0 0.00 0.05 1.30 1.60 0.50 2P 2 1 2.00 0.00 1.30 1.60 0.50 2P 2 1 0.00 0.05 1.30 1.60 0.50 2P 2 1 1.00 0.00 1.30 1.60 1.50 2P 2 1 0.00 0.05 1.30 1.60 1.50 3D 3 2 -2.00 0.15 1.30 1.30 1.50 3D 3 2 -2.00 0.15 1.30 1.30 2.50
{ "pile_set_name": "Github" }
// @flow import React from 'react'; class MyComponent extends React.Component<{a: number, b: number, c: number}, Props> { static defaultProps: {a: number, b: number, c: number} = {a: 1, b: 2, c: 3}; defaultProps: T; static props: T; static state: T; a: T; b = 5; c: T = 5; method() {} } const expression = () => class extends React.Component<{a: number, b: number, c: number}, Props> { static defaultProps: {a: number, b: number, c: number} = {a: 1, b: 2, c: 3}; defaultProps: T; static props: T; static state: T; a: T; b = 5; c: T = 5; method() {} }
{ "pile_set_name": "Github" }
//===-- sanitizer_allocator_primary32.h -------------------------*- C++ -*-===// // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // Part of the Sanitizer Allocator. // //===----------------------------------------------------------------------===// #ifndef SANITIZER_ALLOCATOR_H #error This file must be included inside sanitizer_allocator.h #endif template<class SizeClassAllocator> struct SizeClassAllocator32LocalCache; // SizeClassAllocator32 -- allocator for 32-bit address space. // This allocator can theoretically be used on 64-bit arch, but there it is less // efficient than SizeClassAllocator64. // // [kSpaceBeg, kSpaceBeg + kSpaceSize) is the range of addresses which can // be returned by MmapOrDie(). // // Region: // a result of a single call to MmapAlignedOrDieOnFatalError(kRegionSize, // kRegionSize). // Since the regions are aligned by kRegionSize, there are exactly // kNumPossibleRegions possible regions in the address space and so we keep // a ByteMap possible_regions to store the size classes of each Region. // 0 size class means the region is not used by the allocator. // // One Region is used to allocate chunks of a single size class. // A Region looks like this: // UserChunk1 .. UserChunkN <gap> MetaChunkN .. MetaChunk1 // // In order to avoid false sharing the objects of this class should be // chache-line aligned. struct SizeClassAllocator32FlagMasks { // Bit masks. enum { kRandomShuffleChunks = 1, kUseSeparateSizeClassForBatch = 2, }; }; template <class Params> class SizeClassAllocator32 { public: static const uptr kSpaceBeg = Params::kSpaceBeg; static const u64 kSpaceSize = Params::kSpaceSize; static const uptr kMetadataSize = Params::kMetadataSize; typedef typename Params::SizeClassMap SizeClassMap; static const uptr kRegionSizeLog = Params::kRegionSizeLog; typedef typename Params::ByteMap ByteMap; typedef typename Params::MapUnmapCallback MapUnmapCallback; COMPILER_CHECK(!SANITIZER_SIGN_EXTENDED_ADDRESSES || (kSpaceSize & (kSpaceSize - 1)) == 0); static const bool kRandomShuffleChunks = Params::kFlags & SizeClassAllocator32FlagMasks::kRandomShuffleChunks; static const bool kUseSeparateSizeClassForBatch = Params::kFlags & SizeClassAllocator32FlagMasks::kUseSeparateSizeClassForBatch; struct TransferBatch { static const uptr kMaxNumCached = SizeClassMap::kMaxNumCachedHint - 2; void SetFromArray(void *batch[], uptr count) { DCHECK_LE(count, kMaxNumCached); count_ = count; for (uptr i = 0; i < count; i++) batch_[i] = batch[i]; } uptr Count() const { return count_; } void Clear() { count_ = 0; } void Add(void *ptr) { batch_[count_++] = ptr; DCHECK_LE(count_, kMaxNumCached); } void CopyToArray(void *to_batch[]) const { for (uptr i = 0, n = Count(); i < n; i++) to_batch[i] = batch_[i]; } // How much memory do we need for a batch containing n elements. static uptr AllocationSizeRequiredForNElements(uptr n) { return sizeof(uptr) * 2 + sizeof(void *) * n; } static uptr MaxCached(uptr size) { return Min(kMaxNumCached, SizeClassMap::MaxCachedHint(size)); } TransferBatch *next; private: uptr count_; void *batch_[kMaxNumCached]; }; static const uptr kBatchSize = sizeof(TransferBatch); COMPILER_CHECK((kBatchSize & (kBatchSize - 1)) == 0); COMPILER_CHECK(kBatchSize == SizeClassMap::kMaxNumCachedHint * sizeof(uptr)); static uptr ClassIdToSize(uptr class_id) { return (class_id == SizeClassMap::kBatchClassID) ? kBatchSize : SizeClassMap::Size(class_id); } typedef SizeClassAllocator32<Params> ThisT; typedef SizeClassAllocator32LocalCache<ThisT> AllocatorCache; void Init(s32 release_to_os_interval_ms) { possible_regions.Init(); internal_memset(size_class_info_array, 0, sizeof(size_class_info_array)); } s32 ReleaseToOSIntervalMs() const { return kReleaseToOSIntervalNever; } void SetReleaseToOSIntervalMs(s32 release_to_os_interval_ms) { // This is empty here. Currently only implemented in 64-bit allocator. } void ForceReleaseToOS() { // Currently implemented in 64-bit allocator only. } void *MapWithCallback(uptr size) { void *res = MmapOrDie(size, PrimaryAllocatorName); MapUnmapCallback().OnMap((uptr)res, size); return res; } void UnmapWithCallback(uptr beg, uptr size) { MapUnmapCallback().OnUnmap(beg, size); UnmapOrDie(reinterpret_cast<void *>(beg), size); } static bool CanAllocate(uptr size, uptr alignment) { return size <= SizeClassMap::kMaxSize && alignment <= SizeClassMap::kMaxSize; } void *GetMetaData(const void *p) { CHECK(PointerIsMine(p)); uptr mem = reinterpret_cast<uptr>(p); uptr beg = ComputeRegionBeg(mem); uptr size = ClassIdToSize(GetSizeClass(p)); u32 offset = mem - beg; uptr n = offset / (u32)size; // 32-bit division uptr meta = (beg + kRegionSize) - (n + 1) * kMetadataSize; return reinterpret_cast<void*>(meta); } NOINLINE TransferBatch *AllocateBatch(AllocatorStats *stat, AllocatorCache *c, uptr class_id) { DCHECK_LT(class_id, kNumClasses); SizeClassInfo *sci = GetSizeClassInfo(class_id); SpinMutexLock l(&sci->mutex); if (sci->free_list.empty()) { if (UNLIKELY(!PopulateFreeList(stat, c, sci, class_id))) return nullptr; DCHECK(!sci->free_list.empty()); } TransferBatch *b = sci->free_list.front(); sci->free_list.pop_front(); return b; } NOINLINE void DeallocateBatch(AllocatorStats *stat, uptr class_id, TransferBatch *b) { DCHECK_LT(class_id, kNumClasses); CHECK_GT(b->Count(), 0); SizeClassInfo *sci = GetSizeClassInfo(class_id); SpinMutexLock l(&sci->mutex); sci->free_list.push_front(b); } bool PointerIsMine(const void *p) { uptr mem = reinterpret_cast<uptr>(p); if (SANITIZER_SIGN_EXTENDED_ADDRESSES) mem &= (kSpaceSize - 1); if (mem < kSpaceBeg || mem >= kSpaceBeg + kSpaceSize) return false; return GetSizeClass(p) != 0; } uptr GetSizeClass(const void *p) { return possible_regions[ComputeRegionId(reinterpret_cast<uptr>(p))]; } void *GetBlockBegin(const void *p) { CHECK(PointerIsMine(p)); uptr mem = reinterpret_cast<uptr>(p); uptr beg = ComputeRegionBeg(mem); uptr size = ClassIdToSize(GetSizeClass(p)); u32 offset = mem - beg; u32 n = offset / (u32)size; // 32-bit division uptr res = beg + (n * (u32)size); return reinterpret_cast<void*>(res); } uptr GetActuallyAllocatedSize(void *p) { CHECK(PointerIsMine(p)); return ClassIdToSize(GetSizeClass(p)); } uptr ClassID(uptr size) { return SizeClassMap::ClassID(size); } uptr TotalMemoryUsed() { // No need to lock here. uptr res = 0; for (uptr i = 0; i < kNumPossibleRegions; i++) if (possible_regions[i]) res += kRegionSize; return res; } void TestOnlyUnmap() { for (uptr i = 0; i < kNumPossibleRegions; i++) if (possible_regions[i]) UnmapWithCallback((i * kRegionSize), kRegionSize); } // ForceLock() and ForceUnlock() are needed to implement Darwin malloc zone // introspection API. void ForceLock() { for (uptr i = 0; i < kNumClasses; i++) { GetSizeClassInfo(i)->mutex.Lock(); } } void ForceUnlock() { for (int i = kNumClasses - 1; i >= 0; i--) { GetSizeClassInfo(i)->mutex.Unlock(); } } // Iterate over all existing chunks. // The allocator must be locked when calling this function. void ForEachChunk(ForEachChunkCallback callback, void *arg) { for (uptr region = 0; region < kNumPossibleRegions; region++) if (possible_regions[region]) { uptr chunk_size = ClassIdToSize(possible_regions[region]); uptr max_chunks_in_region = kRegionSize / (chunk_size + kMetadataSize); uptr region_beg = region * kRegionSize; for (uptr chunk = region_beg; chunk < region_beg + max_chunks_in_region * chunk_size; chunk += chunk_size) { // Too slow: CHECK_EQ((void *)chunk, GetBlockBegin((void *)chunk)); callback(chunk, arg); } } } void PrintStats() {} static uptr AdditionalSize() { return 0; } typedef SizeClassMap SizeClassMapT; static const uptr kNumClasses = SizeClassMap::kNumClasses; private: static const uptr kRegionSize = 1 << kRegionSizeLog; static const uptr kNumPossibleRegions = kSpaceSize / kRegionSize; struct ALIGNED(SANITIZER_CACHE_LINE_SIZE) SizeClassInfo { StaticSpinMutex mutex; IntrusiveList<TransferBatch> free_list; u32 rand_state; }; COMPILER_CHECK(sizeof(SizeClassInfo) % kCacheLineSize == 0); uptr ComputeRegionId(uptr mem) { if (SANITIZER_SIGN_EXTENDED_ADDRESSES) mem &= (kSpaceSize - 1); const uptr res = mem >> kRegionSizeLog; CHECK_LT(res, kNumPossibleRegions); return res; } uptr ComputeRegionBeg(uptr mem) { return mem & ~(kRegionSize - 1); } uptr AllocateRegion(AllocatorStats *stat, uptr class_id) { DCHECK_LT(class_id, kNumClasses); const uptr res = reinterpret_cast<uptr>(MmapAlignedOrDieOnFatalError( kRegionSize, kRegionSize, PrimaryAllocatorName)); if (UNLIKELY(!res)) return 0; MapUnmapCallback().OnMap(res, kRegionSize); stat->Add(AllocatorStatMapped, kRegionSize); CHECK(IsAligned(res, kRegionSize)); possible_regions.set(ComputeRegionId(res), static_cast<u8>(class_id)); return res; } SizeClassInfo *GetSizeClassInfo(uptr class_id) { DCHECK_LT(class_id, kNumClasses); return &size_class_info_array[class_id]; } bool PopulateBatches(AllocatorCache *c, SizeClassInfo *sci, uptr class_id, TransferBatch **current_batch, uptr max_count, uptr *pointers_array, uptr count) { // If using a separate class for batches, we do not need to shuffle it. if (kRandomShuffleChunks && (!kUseSeparateSizeClassForBatch || class_id != SizeClassMap::kBatchClassID)) RandomShuffle(pointers_array, count, &sci->rand_state); TransferBatch *b = *current_batch; for (uptr i = 0; i < count; i++) { if (!b) { b = c->CreateBatch(class_id, this, (TransferBatch*)pointers_array[i]); if (UNLIKELY(!b)) return false; b->Clear(); } b->Add((void*)pointers_array[i]); if (b->Count() == max_count) { sci->free_list.push_back(b); b = nullptr; } } *current_batch = b; return true; } bool PopulateFreeList(AllocatorStats *stat, AllocatorCache *c, SizeClassInfo *sci, uptr class_id) { const uptr region = AllocateRegion(stat, class_id); if (UNLIKELY(!region)) return false; if (kRandomShuffleChunks) if (UNLIKELY(sci->rand_state == 0)) // The random state is initialized from ASLR (PIE) and time. sci->rand_state = reinterpret_cast<uptr>(sci) ^ NanoTime(); const uptr size = ClassIdToSize(class_id); const uptr n_chunks = kRegionSize / (size + kMetadataSize); const uptr max_count = TransferBatch::MaxCached(size); DCHECK_GT(max_count, 0); TransferBatch *b = nullptr; constexpr uptr kShuffleArraySize = 48; uptr shuffle_array[kShuffleArraySize]; uptr count = 0; for (uptr i = region; i < region + n_chunks * size; i += size) { shuffle_array[count++] = i; if (count == kShuffleArraySize) { if (UNLIKELY(!PopulateBatches(c, sci, class_id, &b, max_count, shuffle_array, count))) return false; count = 0; } } if (count) { if (UNLIKELY(!PopulateBatches(c, sci, class_id, &b, max_count, shuffle_array, count))) return false; } if (b) { CHECK_GT(b->Count(), 0); sci->free_list.push_back(b); } return true; } ByteMap possible_regions; SizeClassInfo size_class_info_array[kNumClasses]; };
{ "pile_set_name": "Github" }
<!DOCTYPE html> <html> <head> <title>FLOOR.PRECISE Function</title> <meta charset="utf-8" /> <meta name="description" content="" /> <link type="text/css" rel="stylesheet" href="../editor.css" /> </head> <body> <div class="mainpart"> <h1>FLOOR.PRECISE Function</h1> <p>The <b>FLOOR.PRECISE</b> function is one of the math and trigonometry functions. It is used to return a number that is rounded down to the nearest integer or to the nearest multiple of significance. The number is always rounded down regardless of its sing.</p> <p>The <b>FLOOR.PRECISE</b> function syntax is:</p> <p style="text-indent: 150px;"><b><em>FLOOR.PRECISE(x [, significance])</em></b></p> <p><em>where</em></p> <p style="text-indent: 50px;"><b><em>x</em></b> is the number you wish to round down.</p> <p style="text-indent: 50px;"><b><em>significance</em></b> is the multiple of significance you wish to round down to. It is an optional parameter. If it is omitted, the default value of 1 is used. If it is set to zero, the function returns 0.</p> <p>The numeric values can be entered manually or included into the cell you make reference to.</p> <p>To apply the <b>FLOOR.PRECISE</b> function,</p> <ol> <li>select the cell where you wish to display the result,</li> <li>click the <b>Insert Function</b> <img alt="Insert Function icon" src="../images/insertfunction.png" /> icon situated at the top toolbar, <br />or right-click within a selected cell and select the <b>Insert Function</b> option from the menu, <br />or click the <img alt="Function icon" src="../images/function.png" /> icon situated at the formula bar, </li> <li>select the <b>Math and trigonometry</b> function group from the list,</li> <li>click the <b>FLOOR.PRECISE</b> function,</li> <li>enter the required arguments separating them by comma,</li> <li>press the <b>Enter</b> button.</li> </ol> <p>The result will be displayed in the selected cell.</p> <p style="text-indent: 150px;"><img alt="FLOOR.PRECISE Function" src="../images/floorprecise.png" /></p> </div> </body> </html>
{ "pile_set_name": "Github" }
/* * Copyright (C) 2008 Ole André Vadla Ravnås <[email protected]> * * Licence: wxWindows Library Licence, Version 3.1 */ #ifndef __GUM_COBJECT_H__ #define __GUM_COBJECT_H__ #include <gum/gumdefs.h> #include <gum/gumreturnaddress.h> typedef struct _GumCObject GumCObject; struct _GumCObject { gpointer address; gchar type_name[GUM_MAX_TYPE_NAME + 1]; GumReturnAddressArray return_addresses; /*< private */ gpointer data; }; #define GUM_COBJECT(b) ((GumCObject *) (b)) G_BEGIN_DECLS GUM_API GumCObject * gum_cobject_new (gpointer address, const gchar * type_name); GUM_API GumCObject * gum_cobject_copy ( const GumCObject * cobject); GUM_API void gum_cobject_free (GumCObject * cobject); GUM_API void gum_cobject_list_free (GList * cobject_list); G_END_DECLS #endif
{ "pile_set_name": "Github" }
min-conflicts,9,0.0
{ "pile_set_name": "Github" }
import Foundation #if canImport(Darwin) @objcMembers public class _ExampleMetadataBase: NSObject {} #else public class _ExampleMetadataBase: NSObject {} #endif /** A class that encapsulates information about an example, including the index at which the example was executed, as well as the example itself. */ final public class ExampleMetadata: _ExampleMetadataBase { /** The example for which this metadata was collected. */ public let example: Example /** The index at which this example was executed in the test suite. */ public let exampleIndex: Int internal init(example: Example, exampleIndex: Int) { self.example = example self.exampleIndex = exampleIndex } }
{ "pile_set_name": "Github" }
<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="refresh" content="0;URL=../../../../libc/unix/notbsd/linux/constant._SC_NPROCESSORS_ONLN.html"> </head> <body> <p>Redirecting to <a href="../../../../libc/unix/notbsd/linux/constant._SC_NPROCESSORS_ONLN.html">../../../../libc/unix/notbsd/linux/constant._SC_NPROCESSORS_ONLN.html</a>...</p> <script>location.replace("../../../../libc/unix/notbsd/linux/constant._SC_NPROCESSORS_ONLN.html" + location.search + location.hash);</script> </body> </html>
{ "pile_set_name": "Github" }
/* Application : Functional Programming Version 2 Author : Ahmed Mohamed Date : 2019/11/1 */ test(func { ? "Anonymous Functions" }) func test f1 ? "Hello" call f1()
{ "pile_set_name": "Github" }
/** * Copyright 2020 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. */ package com.amazonaws.mobileconnectors.s3.transferutility; import android.content.Context; import androidx.test.core.app.ApplicationProvider; import com.amazonaws.services.s3.S3IntegrationTestBase; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import java.io.File; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; public final class PauseTransferIntegrationTest extends S3IntegrationTestBase { private static final String BUCKET_NAME = "android-sdk-transfer-util-integ-test-" + System.currentTimeMillis(); private static TransferUtility util; private static Context context = ApplicationProvider.getApplicationContext(); private File file; private CountDownLatch started; private CountDownLatch paused; private CountDownLatch resumed; private CountDownLatch completed; /** * Creates and initializes all the test resources needed for these tests. */ @BeforeClass public static void setUpBeforeClass() throws Exception { setUp(); TransferNetworkLossHandler.getInstance(context); util = TransferUtility.builder() .context(context) .s3Client(s3) .build(); try { s3.createBucket(BUCKET_NAME); waitForBucketCreation(BUCKET_NAME); } catch (final Exception e) { System.out.println("Error in creating the bucket. " + "Please manually create the bucket " + BUCKET_NAME); } } @AfterClass public static void tearDown() { try { deleteBucketAndAllContents(BUCKET_NAME); } catch (final Exception e) { System.out.println("Error in deleting the bucket. " + "Please manually delete the bucket " + BUCKET_NAME); e.printStackTrace(); } } @Before public void setUpLatches() { started = new CountDownLatch(1); paused = new CountDownLatch(1); resumed = new CountDownLatch(1); completed = new CountDownLatch(1); } @Test public void testSinglePartUploadPause() throws Exception { // Small (1KB) file upload file = getRandomTempFile("small", 1000L); testUploadPause(); } @Test public void testMultiPartUploadPause() throws Exception { // Large (10MB) file upload file = getRandomSparseFile("large", 10L * 1024 * 1024); testUploadPause(); } private void testUploadPause() throws Exception { // start transfer and wait for progress TransferObserver observer = util.upload(BUCKET_NAME, file.getName(), file); observer.setTransferListener(new TestListener()); started.await(100, TimeUnit.MILLISECONDS); // pause and wait util.pause(observer.getId()); paused.await(100, TimeUnit.MILLISECONDS); Thread.sleep(1000); // throws if progress is made // resume if pause was properly executed util.resume(observer.getId()); resumed.await(100, TimeUnit.MILLISECONDS); // cancel early to avoid having to wait for completion util.cancel(observer.getId()); completed.await(1000, TimeUnit.MILLISECONDS); } private final class TestListener implements TransferListener { @Override public void onStateChanged(int id, TransferState state) { switch (state) { case CANCELED: case COMPLETED: completed.countDown(); break; case PAUSED: paused.countDown(); break; case IN_PROGRESS: if (paused.getCount() == 0) { // Post-pause resumed.countDown(); } else { // Pre-pause started.countDown(); } break; case FAILED: throw new RuntimeException("Failed transfer."); } } @Override public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) { if (paused.getCount() == 0 && resumed.getCount() > 0) { throw new RuntimeException("Progress made even while paused."); } } @Override public void onError(int id, Exception ex) { throw new RuntimeException(ex); } } }
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8" ?> <plugin pluginId="Gallio.AutoCAD" recommendedInstallationPath="AutoCAD" xmlns="http://www.gallio.org/"> <traits> <name>AutoCAD Integration Plugin</name> <version>3.2.0.0</version> <description>Provides support for testing ObjectARX extensions within AutoCAD.</description> <icon>plugin://Gallio.AutoCAD/Resources/Gallio.AutoCAD.ico</icon> </traits> <dependencies> <dependency pluginId="Gallio" /> </dependencies> <files> <file path="Gallio.AutoCAD.plugin" /> <file path="Gallio.AutoCAD.dll" /> <file path="Gallio.AutoCAD.Plugin.dll" /> <file path="Resources\Gallio.AutoCAD.ico" /> </files> <assemblies> <assembly fullName="Gallio.AutoCAD, Version=3.2.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e" codeBase="Gallio.AutoCAD.dll" qualifyPartialName="true" /> </assemblies> <services> <service serviceId="Gallio.AutoCAD.AcadLocator" serviceType="Gallio.AutoCAD.IAcadLocator, Gallio.AutoCAD" /> <service serviceId="Gallio.AutoCAD.Preferences.AcadPreferenceManager" serviceType="Gallio.AutoCAD.Preferences.IAcadPreferenceManager, Gallio.AutoCAD" /> <service serviceId="Gallio.AutoCAD.ProcessManagement.AcadProcessFactory" serviceType="Gallio.AutoCAD.ProcessManagement.IAcadProcessFactory, Gallio.AutoCAD" /> </services> <components> <component componentId="Gallio.AutoCAD.AcadLocator" serviceId="Gallio.AutoCAD.AcadLocator" componentType="Gallio.AutoCAD.AcadLocator, Gallio.AutoCAD" /> <component componentId="Gallio.AutoCAD.Preferences.AcadPreferenceManager" serviceId="Gallio.AutoCAD.Preferences.AcadPreferenceManager" componentType="Gallio.AutoCAD.Preferences.AcadPreferenceManager, Gallio.AutoCAD" /> <component componentId="Gallio.AutoCAD.ProcessManagement.AcadProcessFactory" serviceId="Gallio.AutoCAD.ProcessManagement.AcadProcessFactory" componentType="Gallio.AutoCAD.ProcessManagement.AcadProcessFactory, Gallio.AutoCAD" /> <component componentId="AutoCAD.AcadTestRunnerFactory" serviceId="Gallio.TestRunnerFactory" componentType="Gallio.Runner.DefaultTestRunnerFactory, Gallio"> <parameters> <testIsolationProvider>${AutoCAD.AcadTestIsolationProvider}</testIsolationProvider> </parameters> <traits> <name>AutoCAD</name> <description> Runs tests within an AutoCAD process. Supported test runner properties: - AcadAttachToExisting: If "true" attaches to an existing AutoCAD process, otherwise starts a new one. - AcadExePath: Specifies the full path of the "acad.exe" program. </description> </traits> </component> <component componentId="AutoCAD.AcadTestIsolationProvider" serviceId="Gallio.TestIsolationProvider" componentType="Gallio.AutoCAD.Isolation.AcadTestIsolationProvider, Gallio.AutoCAD" /> </components> </plugin>
{ "pile_set_name": "Github" }
Какую проблему с точки зрения LSP решает класс `Contract`? *[LSP]:Liskov Substitution Principle
{ "pile_set_name": "Github" }
[ { "metric" : "OVERALL", "measurement" : "RunTime(ms)", "value" : 391477.0 }, { "metric" : "OVERALL", "measurement" : "Throughput(ops/sec)", "value" : 25544.284849429212 }, { "metric" : "CLEANUP", "measurement" : "Operations", "value" : 64.0 }, { "metric" : "CLEANUP", "measurement" : "AverageLatency(us)", "value" : 80.53125 }, { "metric" : "CLEANUP", "measurement" : "MinLatency(us)", "value" : 20.0 }, { "metric" : "CLEANUP", "measurement" : "MaxLatency(us)", "value" : 2689.0 }, { "metric" : "CLEANUP", "measurement" : "95thPercentileLatency(us)", "value" : 57.0 }, { "metric" : "CLEANUP", "measurement" : "99thPercentileLatency(us)", "value" : 208.0 }, { "metric" : "READ", "measurement" : "Operations", "value" : 9499398.0 }, { "metric" : "READ", "measurement" : "AverageLatency(us)", "value" : 2513.110372046734 }, { "metric" : "READ", "measurement" : "MinLatency(us)", "value" : 686.0 }, { "metric" : "READ", "measurement" : "MaxLatency(us)", "value" : 258047.0 }, { "metric" : "READ", "measurement" : "95thPercentileLatency(us)", "value" : 4651.0 }, { "metric" : "READ", "measurement" : "99thPercentileLatency(us)", "value" : 6731.0 }, { "metric" : "READ", "measurement" : "Return=0", "value" : 9499398 }, { "metric" : "UPDATE", "measurement" : "Operations", "value" : 500602.0 }, { "metric" : "UPDATE", "measurement" : "AverageLatency(us)", "value" : 1766.2885885393985 }, { "metric" : "UPDATE", "measurement" : "MinLatency(us)", "value" : 830.0 }, { "metric" : "UPDATE", "measurement" : "MaxLatency(us)", "value" : 149503.0 }, { "metric" : "UPDATE", "measurement" : "95thPercentileLatency(us)", "value" : 2501.0 }, { "metric" : "UPDATE", "measurement" : "99thPercentileLatency(us)", "value" : 13191.0 }, { "metric" : "UPDATE", "measurement" : "Return=0", "value" : 500602 } ]
{ "pile_set_name": "Github" }
#include <setjmp.h> #include <stdlib.h> #include <stdio.h> jmp_buf main_loop; void abort_to_main_loop (int status) { longjmp (main_loop, status); } int main (void) { while (1) if (setjmp (main_loop)) puts ("Back at main loop...."); else do_command (); } void do_command (void) { char buffer[128]; if (fgets (buffer, 128, stdin) == NULL) abort_to_main_loop (-1); else exit (EXIT_SUCCESS); }
{ "pile_set_name": "Github" }
/* * Copyright (c) 2013 NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. */ #include <linux/clk.h> #include <linux/clk-provider.h> #include <linux/err.h> #include <linux/slab.h> static u8 clk_composite_get_parent(struct clk_hw *hw) { struct clk_composite *composite = to_clk_composite(hw); const struct clk_ops *mux_ops = composite->mux_ops; struct clk_hw *mux_hw = composite->mux_hw; __clk_hw_set_clk(mux_hw, hw); return mux_ops->get_parent(mux_hw); } static int clk_composite_set_parent(struct clk_hw *hw, u8 index) { struct clk_composite *composite = to_clk_composite(hw); const struct clk_ops *mux_ops = composite->mux_ops; struct clk_hw *mux_hw = composite->mux_hw; __clk_hw_set_clk(mux_hw, hw); return mux_ops->set_parent(mux_hw, index); } static unsigned long clk_composite_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) { struct clk_composite *composite = to_clk_composite(hw); const struct clk_ops *rate_ops = composite->rate_ops; struct clk_hw *rate_hw = composite->rate_hw; __clk_hw_set_clk(rate_hw, hw); return rate_ops->recalc_rate(rate_hw, parent_rate); } static int clk_composite_determine_rate(struct clk_hw *hw, struct clk_rate_request *req) { struct clk_composite *composite = to_clk_composite(hw); const struct clk_ops *rate_ops = composite->rate_ops; const struct clk_ops *mux_ops = composite->mux_ops; struct clk_hw *rate_hw = composite->rate_hw; struct clk_hw *mux_hw = composite->mux_hw; struct clk_hw *parent; unsigned long parent_rate; long tmp_rate, best_rate = 0; unsigned long rate_diff; unsigned long best_rate_diff = ULONG_MAX; long rate; int i; if (rate_hw && rate_ops && rate_ops->determine_rate) { __clk_hw_set_clk(rate_hw, hw); return rate_ops->determine_rate(rate_hw, req); } else if (rate_hw && rate_ops && rate_ops->round_rate && mux_hw && mux_ops && mux_ops->set_parent) { req->best_parent_hw = NULL; if (clk_hw_get_flags(hw) & CLK_SET_RATE_NO_REPARENT) { parent = clk_hw_get_parent(mux_hw); req->best_parent_hw = parent; req->best_parent_rate = clk_hw_get_rate(parent); rate = rate_ops->round_rate(rate_hw, req->rate, &req->best_parent_rate); if (rate < 0) return rate; req->rate = rate; return 0; } for (i = 0; i < clk_hw_get_num_parents(mux_hw); i++) { parent = clk_hw_get_parent_by_index(mux_hw, i); if (!parent) continue; parent_rate = clk_hw_get_rate(parent); tmp_rate = rate_ops->round_rate(rate_hw, req->rate, &parent_rate); if (tmp_rate < 0) continue; rate_diff = abs(req->rate - tmp_rate); if (!rate_diff || !req->best_parent_hw || best_rate_diff > rate_diff) { req->best_parent_hw = parent; req->best_parent_rate = parent_rate; best_rate_diff = rate_diff; best_rate = tmp_rate; } if (!rate_diff) return 0; } req->rate = best_rate; return 0; } else if (mux_hw && mux_ops && mux_ops->determine_rate) { __clk_hw_set_clk(mux_hw, hw); return mux_ops->determine_rate(mux_hw, req); } else { pr_err("clk: clk_composite_determine_rate function called, but no mux or rate callback set!\n"); return -EINVAL; } } static long clk_composite_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *prate) { struct clk_composite *composite = to_clk_composite(hw); const struct clk_ops *rate_ops = composite->rate_ops; struct clk_hw *rate_hw = composite->rate_hw; __clk_hw_set_clk(rate_hw, hw); return rate_ops->round_rate(rate_hw, rate, prate); } static int clk_composite_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) { struct clk_composite *composite = to_clk_composite(hw); const struct clk_ops *rate_ops = composite->rate_ops; struct clk_hw *rate_hw = composite->rate_hw; __clk_hw_set_clk(rate_hw, hw); return rate_ops->set_rate(rate_hw, rate, parent_rate); } static int clk_composite_set_rate_and_parent(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate, u8 index) { struct clk_composite *composite = to_clk_composite(hw); const struct clk_ops *rate_ops = composite->rate_ops; const struct clk_ops *mux_ops = composite->mux_ops; struct clk_hw *rate_hw = composite->rate_hw; struct clk_hw *mux_hw = composite->mux_hw; unsigned long temp_rate; __clk_hw_set_clk(rate_hw, hw); __clk_hw_set_clk(mux_hw, hw); temp_rate = rate_ops->recalc_rate(rate_hw, parent_rate); if (temp_rate > rate) { rate_ops->set_rate(rate_hw, rate, parent_rate); mux_ops->set_parent(mux_hw, index); } else { mux_ops->set_parent(mux_hw, index); rate_ops->set_rate(rate_hw, rate, parent_rate); } return 0; } static int clk_composite_is_enabled(struct clk_hw *hw) { struct clk_composite *composite = to_clk_composite(hw); const struct clk_ops *gate_ops = composite->gate_ops; struct clk_hw *gate_hw = composite->gate_hw; __clk_hw_set_clk(gate_hw, hw); return gate_ops->is_enabled(gate_hw); } static int clk_composite_enable(struct clk_hw *hw) { struct clk_composite *composite = to_clk_composite(hw); const struct clk_ops *gate_ops = composite->gate_ops; struct clk_hw *gate_hw = composite->gate_hw; __clk_hw_set_clk(gate_hw, hw); return gate_ops->enable(gate_hw); } static void clk_composite_disable(struct clk_hw *hw) { struct clk_composite *composite = to_clk_composite(hw); const struct clk_ops *gate_ops = composite->gate_ops; struct clk_hw *gate_hw = composite->gate_hw; __clk_hw_set_clk(gate_hw, hw); gate_ops->disable(gate_hw); } struct clk_hw *clk_hw_register_composite(struct device *dev, const char *name, const char * const *parent_names, int num_parents, struct clk_hw *mux_hw, const struct clk_ops *mux_ops, struct clk_hw *rate_hw, const struct clk_ops *rate_ops, struct clk_hw *gate_hw, const struct clk_ops *gate_ops, unsigned long flags) { struct clk_hw *hw; struct clk_init_data init; struct clk_composite *composite; struct clk_ops *clk_composite_ops; int ret; composite = kzalloc(sizeof(*composite), GFP_KERNEL); if (!composite) return ERR_PTR(-ENOMEM); init.name = name; init.flags = flags | CLK_IS_BASIC; init.parent_names = parent_names; init.num_parents = num_parents; hw = &composite->hw; clk_composite_ops = &composite->ops; if (mux_hw && mux_ops) { if (!mux_ops->get_parent) { hw = ERR_PTR(-EINVAL); goto err; } composite->mux_hw = mux_hw; composite->mux_ops = mux_ops; clk_composite_ops->get_parent = clk_composite_get_parent; if (mux_ops->set_parent) clk_composite_ops->set_parent = clk_composite_set_parent; if (mux_ops->determine_rate) clk_composite_ops->determine_rate = clk_composite_determine_rate; } if (rate_hw && rate_ops) { if (!rate_ops->recalc_rate) { hw = ERR_PTR(-EINVAL); goto err; } clk_composite_ops->recalc_rate = clk_composite_recalc_rate; if (rate_ops->determine_rate) clk_composite_ops->determine_rate = clk_composite_determine_rate; else if (rate_ops->round_rate) clk_composite_ops->round_rate = clk_composite_round_rate; /* .set_rate requires either .round_rate or .determine_rate */ if (rate_ops->set_rate) { if (rate_ops->determine_rate || rate_ops->round_rate) clk_composite_ops->set_rate = clk_composite_set_rate; else WARN(1, "%s: missing round_rate op is required\n", __func__); } composite->rate_hw = rate_hw; composite->rate_ops = rate_ops; } if (mux_hw && mux_ops && rate_hw && rate_ops) { if (mux_ops->set_parent && rate_ops->set_rate) clk_composite_ops->set_rate_and_parent = clk_composite_set_rate_and_parent; } if (gate_hw && gate_ops) { if (!gate_ops->is_enabled || !gate_ops->enable || !gate_ops->disable) { hw = ERR_PTR(-EINVAL); goto err; } composite->gate_hw = gate_hw; composite->gate_ops = gate_ops; clk_composite_ops->is_enabled = clk_composite_is_enabled; clk_composite_ops->enable = clk_composite_enable; clk_composite_ops->disable = clk_composite_disable; } init.ops = clk_composite_ops; composite->hw.init = &init; ret = clk_hw_register(dev, hw); if (ret) { hw = ERR_PTR(ret); goto err; } if (composite->mux_hw) composite->mux_hw->clk = hw->clk; if (composite->rate_hw) composite->rate_hw->clk = hw->clk; if (composite->gate_hw) composite->gate_hw->clk = hw->clk; return hw; err: kfree(composite); return hw; } struct clk *clk_register_composite(struct device *dev, const char *name, const char * const *parent_names, int num_parents, struct clk_hw *mux_hw, const struct clk_ops *mux_ops, struct clk_hw *rate_hw, const struct clk_ops *rate_ops, struct clk_hw *gate_hw, const struct clk_ops *gate_ops, unsigned long flags) { struct clk_hw *hw; hw = clk_hw_register_composite(dev, name, parent_names, num_parents, mux_hw, mux_ops, rate_hw, rate_ops, gate_hw, gate_ops, flags); if (IS_ERR(hw)) return ERR_CAST(hw); return hw->clk; } void clk_unregister_composite(struct clk *clk) { struct clk_composite *composite; struct clk_hw *hw; hw = __clk_get_hw(clk); if (!hw) return; composite = to_clk_composite(hw); clk_unregister(clk); kfree(composite); }
{ "pile_set_name": "Github" }
$TestsPath = Split-Path $MyInvocation.MyCommand.Path $RootFolder = (Get-Item $TestsPath).Parent Push-Location -Path $RootFolder.FullName Set-Location -Path $RootFolder.FullName #Hack to load the [System.Drawing.Color] ahead of time #read more here -> https://github.com/PowerShell/vscode-powershell/issues/219 #Microsoft.PowerShell.Management\Get-Clipboard | Out-Null Add-Type -Assembly System.Drawing #Could also be loaded directly via Add-Type -Assembly System.Drawing but apperently, Get-ClipBoard thingy is better.. Write-Verbose "Importing module" Import-Module .\PSHTML -Force InModuleScope -ModuleName PSHTML { Describe "Basic Get-PSHTMLColor Tests" { It "Get-PSHTMLColor should return correct W3C rgb values when no -Type parameter is supplied" { $red = Get-PSHTMLColor -Color "red" $green = Get-PSHTMLColor -Color "green" $blue = Get-PSHTMLColor -Color "blue" $white = Get-PSHTMLColor -Color "white" $black = Get-PSHTMLColor -Color "black" $red | should be 'rgb(255,0,0)' $green | should be 'rgb(0,128,0)' $blue | should be 'rgb(0,0,255)' $white | should be 'rgb(255,255,255)' $black | should be 'rgb(0,0,0)' } It "Get-PSHTMLColor should return correct W3C rgb values when -Type parameter is 'rgb'" { $red = Get-PSHTMLColor -Type 'rgb' -Color "red" $green = Get-PSHTMLColor -Type 'rgb' -Color "green" $blue = Get-PSHTMLColor -Type 'rgb' -Color "blue" $white = Get-PSHTMLColor -Type 'rgb' -Color "white" $black = Get-PSHTMLColor -Type 'rgb' -Color "black" $red | should be 'rgb(255,0,0)' $green | should be 'rgb(0,128,0)' $blue | should be 'rgb(0,0,255)' $white | should be 'rgb(255,255,255)' $black | should be 'rgb(0,0,0)' } It "Get-PSHTMLColor should return correct W3C hex values when -Type parameter is 'hex'" { $red = Get-PSHTMLColor -Type 'hex' -Color "red" $green = Get-PSHTMLColor -Type 'hex' -Color "green" $blue = Get-PSHTMLColor -Type 'hex' -Color "blue" $white = Get-PSHTMLColor -Type 'hex' -Color "white" $black = Get-PSHTMLColor -Type 'hex' -Color "black" $red | should be '#FF0000' $green | should be '#008000' $blue | should be '#0000FF' $white | should be '#FFFFFF' $black | should be '#000000' } It "Get-PSHTMLColor should return correct W3C hsl values when -Type parameter is 'hsl'" { $red = Get-PSHTMLColor -Type 'hsl' -Color "red" $green = Get-PSHTMLColor -Type 'hsl' -Color "green" $blue = Get-PSHTMLColor -Type 'hsl' -Color "blue" $white = Get-PSHTMLColor -Type 'hsl' -Color "white" $black = Get-PSHTMLColor -Type 'hsl' -Color "black" $red | should be 'hsl(0,100%,50%)' $green | should be 'hsl(120,100%,25%)' $blue | should be 'hsl(240,100%,50%)' $white | should be 'hsl(0,0%,100%)' $black | should be 'hsl(0,0%,0%)' } } }
{ "pile_set_name": "Github" }
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ /* * (C) 2001 by Argonne National Laboratory. * See COPYRIGHT in top-level directory. */ #include "mpiimpl.h" #include "mpiinfo.h" /* -- Begin Profiling Symbol Block for routine MPI_Info_delete */ #if defined(HAVE_PRAGMA_WEAK) #pragma weak MPI_Info_delete = PMPI_Info_delete #elif defined(HAVE_PRAGMA_HP_SEC_DEF) #pragma _HP_SECONDARY_DEF PMPI_Info_delete MPI_Info_delete #elif defined(HAVE_PRAGMA_CRI_DUP) #pragma _CRI duplicate MPI_Info_delete as PMPI_Info_delete #endif /* -- End Profiling Symbol Block */ /* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build the MPI routines */ #ifndef MPICH_MPI_FROM_PMPI #undef MPI_Info_delete #define MPI_Info_delete PMPI_Info_delete #endif #undef FUNCNAME #define FUNCNAME MPI_Info_delete /*@ MPI_Info_delete - Deletes a (key,value) pair from info Input Parameters: + info - info object (handle) - key - key (string) .N NotThreadSafe .N Fortran .N Errors .N MPI_SUCCESS @*/ int MPI_Info_delete( MPI_Info info, const char *key ) { static const char FCNAME[] = "MPI_Info_delete"; int mpi_errno = MPI_SUCCESS; MPID_Info *info_ptr=0, *prev_ptr, *curr_ptr; MPID_MPI_STATE_DECL(MPID_STATE_MPI_INFO_DELETE); MPIR_ERRTEST_INITIALIZED_ORDIE(); MPIU_THREAD_CS_ENTER(ALLFUNC,); MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_INFO_DELETE); /* Validate parameters, especially handles needing to be converted */ # ifdef HAVE_ERROR_CHECKING { MPID_BEGIN_ERROR_CHECKS; { MPIR_ERRTEST_INFO(info, mpi_errno); } MPID_END_ERROR_CHECKS; } # endif /* HAVE_ERROR_CHECKING */ /* Convert MPI object handles to object pointers */ MPID_Info_get_ptr( info, info_ptr ); /* Validate parameters and objects (post conversion) */ # ifdef HAVE_ERROR_CHECKING { MPID_BEGIN_ERROR_CHECKS; { int keylen; /* Validate info_ptr */ MPID_Info_valid_ptr( info_ptr, mpi_errno ); if (mpi_errno) goto fn_fail; /* Check key */ MPIU_ERR_CHKANDJUMP((!key), mpi_errno, MPI_ERR_INFO_KEY, "**infokeynull"); keylen = (int)strlen(key); MPIU_ERR_CHKANDJUMP((keylen > MPI_MAX_INFO_KEY), mpi_errno, MPI_ERR_INFO_KEY, "**infokeylong"); MPIU_ERR_CHKANDJUMP((keylen == 0), mpi_errno, MPI_ERR_INFO_KEY, "**infokeyempty"); } MPID_END_ERROR_CHECKS; } # endif /* HAVE_ERROR_CHECKING */ /* ... body of routine ... */ prev_ptr = info_ptr; curr_ptr = info_ptr->next; while (curr_ptr) { if (!strncmp(curr_ptr->key, key, MPI_MAX_INFO_KEY)) { MPIU_Free(curr_ptr->key); MPIU_Free(curr_ptr->value); prev_ptr->next = curr_ptr->next; MPIU_Handle_obj_free( &MPID_Info_mem, curr_ptr ); break; } prev_ptr = curr_ptr; curr_ptr = curr_ptr->next; } /* If curr_ptr is not defined, we never found the key */ MPIU_ERR_CHKANDJUMP1((!curr_ptr), mpi_errno, MPI_ERR_INFO_NOKEY, "**infonokey", "**infonokey %s", key); /* ... end of body of routine ... */ fn_exit: MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_INFO_DELETE); MPIU_THREAD_CS_EXIT(ALLFUNC,); return mpi_errno; fn_fail: /* --BEGIN ERROR HANDLING-- */ # ifdef HAVE_ERROR_CHECKING { mpi_errno = MPIR_Err_create_code( mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER, "**mpi_info_delete", "**mpi_info_delete %I %s", info, key); } # endif mpi_errno = MPIR_Err_return_comm( NULL, FCNAME, mpi_errno ); goto fn_exit; /* --END ERROR HANDLING-- */ }
{ "pile_set_name": "Github" }
__resources__["/applyJoinTeamHandler.js"] = {meta: {mimetype: "application/javascript"}, data: function(exports, require, module, __filename, __dirname) { var pomelo = window.pomelo; var btns = require('consts').BtnAction4Player; /** * Execute player action */ function exec(type, params) { switch (type) { case btns.ACCEPT_APPLICANT_JOIN_TEAM: { applyJoinTeamReply(params); } break; } } /** * Apply join team action. */ function applyJoinTeamReply(params) { pomelo.notify("area.teamHandler.applyJoinTeamReply", {teamId: params.teamId, applicantId: params.id, reply: params.reply}); } exports.exec = exec; }};
{ "pile_set_name": "Github" }
# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # If cmake variable HDFSPP_LIBRARY_ONLY is set, then tests, examples, and # tools will not be built. This allows for faster builds of the libhdfspp # library alone, avoids looking for a JDK, valgrind, and gmock, and # prevents the generation of multiple binaries that might not be relevant # to other projects during normal use. # Example of cmake invocation with HDFSPP_LIBRARY_ONLY enabled: # cmake -DHDFSPP_LIBRARY_ONLY=1 project (libhdfspp) cmake_minimum_required(VERSION 2.8) find_package (Boost 1.72.0 REQUIRED) enable_testing() include (CTest) SET(BUILD_SHARED_HDFSPP TRUE CACHE STRING "BUILD_SHARED_HDFSPP defaulting to 'TRUE'") SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH}) # If there's a better way to inform FindCyrusSASL.cmake, let's make this cleaner: SET(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${CYRUS_SASL_DIR};${GSASL_DIR};$ENV{PROTOBUF_HOME}") # Specify PROTOBUF_HOME so that find_package picks up the correct version SET(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};$ENV{PROTOBUF_HOME}") find_package(Doxygen) find_package(OpenSSL REQUIRED) find_package(Protobuf REQUIRED) find_package(CyrusSASL) find_package(GSasl) find_package(Threads) include(CheckCXXSourceCompiles) # Check if thread_local is supported unset (THREAD_LOCAL_SUPPORTED CACHE) set (CMAKE_CXX_STANDARD 11) set (CMAKE_CXX_STANDARD_REQUIRED ON) set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) check_cxx_source_compiles( "#include <thread> int main(void) { thread_local int s; return 0; }" THREAD_LOCAL_SUPPORTED) if (NOT THREAD_LOCAL_SUPPORTED) message(FATAL_ERROR "FATAL ERROR: The required feature thread_local storage is not supported by your compiler. \ Known compilers that support this feature: GCC 4.8+, Visual Studio 2015+, Clang (community \ version 3.3+), Clang (version for Xcode 8+ and iOS 9+).") endif (NOT THREAD_LOCAL_SUPPORTED) # Check if PROTOC library was compiled with the compatible compiler by trying # to compile some dummy code unset (PROTOC_IS_COMPATIBLE CACHE) set (CMAKE_REQUIRED_INCLUDES ${PROTOBUF_INCLUDE_DIRS}) set (CMAKE_REQUIRED_LIBRARIES ${PROTOBUF_LIBRARY} ${PROTOBUF_PROTOC_LIBRARY}) check_cxx_source_compiles( "#include <google/protobuf/io/printer.h> #include <string> int main(void) { ::google::protobuf::io::ZeroCopyOutputStream *out = NULL; ::google::protobuf::io::Printer printer(out, '$'); printer.PrintRaw(std::string(\"test\")); return 0; }" PROTOC_IS_COMPATIBLE) if (NOT PROTOC_IS_COMPATIBLE) message(WARNING "WARNING: the Protocol Buffers Library and the Libhdfs++ Library must both be compiled \ with the same (or compatible) compiler. Normally only the same major versions of the same \ compiler are compatible with each other.") endif (NOT PROTOC_IS_COMPATIBLE) find_program(MEMORYCHECK_COMMAND valgrind HINTS ${VALGRIND_DIR} ) set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=no --leak-check=full --error-exitcode=1 --suppressions=${PROJECT_SOURCE_DIR}/tests/memcheck.supp") message(STATUS "valgrind location: ${MEMORYCHECK_COMMAND}") if (REQUIRE_VALGRIND AND MEMORYCHECK_COMMAND MATCHES "MEMORYCHECK_COMMAND-NOTFOUND" ) message(FATAL_ERROR "valgrind was required but not found. " "The path can be included via a -DVALGRIND_DIR=... flag passed to CMake.") endif (REQUIRE_VALGRIND AND MEMORYCHECK_COMMAND MATCHES "MEMORYCHECK_COMMAND-NOTFOUND" ) # Find the SASL library to use. If you don't want to require a sasl library, # define -DNO_SASL=1 in your cmake call # Prefer Cyrus SASL, but use GSASL if it is found # Note that the packages can be disabled by setting CMAKE_DISABLE_FIND_PACKAGE_GSasl or # CMAKE_DISABLE_FIND_PACKAGE_CyrusSASL, respectively (case sensitive) set (SASL_LIBRARIES) set (SASL_INCLUDE_DIR) if (NOT NO_SASL) if (CYRUS_SASL_FOUND) message(STATUS "Using Cyrus SASL; link with ${CYRUS_SASL_SHARED_LIB}") set (SASL_INCLUDE_DIR ${CYRUS_SASL_INCLUDE_DIR}) set (SASL_LIBRARIES ${CYRUS_SASL_SHARED_LIB}) set (CMAKE_USING_CYRUS_SASL 1) add_definitions(-DUSE_SASL -DUSE_CYRUS_SASL) else (CYRUS_SASL_FOUND) if (REQUIRE_CYRUS_SASL) message(FATAL_ERROR "Cyrus SASL was required but not found. " "The path can be included via a -DCYRUS_SASL_DIR=... flag passed to CMake.") endif (REQUIRE_CYRUS_SASL) # If we didn't pick Cyrus, use GSASL instead if (GSASL_FOUND) message(STATUS "Using GSASL; link with ${GSASL_LIBRARIES}") set (SASL_INCLUDE_DIR ${GSASL_INCLUDE_DIR}) set (SASL_LIBRARIES ${GSASL_LIBRARIES}) set (CMAKE_USING_GSASL 1) add_definitions(-DUSE_SASL -DUSE_GSASL) else (GSASL_FOUND) if (REQUIRE_GSASL) message(FATAL_ERROR "GSASL was required but not found. " "The path can be included via a -DGSASL_DIR=... flag passed to CMake.") endif (REQUIRE_GSASL) # No SASL was found, but NO_SASL was not defined message(FATAL_ERROR "Cound not find a SASL library (GSASL (gsasl) or Cyrus SASL (libsasl2). " "Install/configure one of them or define NO_SASL=1 in your cmake call") endif (GSASL_FOUND) endif (CYRUS_SASL_FOUND) else (NOT NO_SASL) message(STATUS "Compiling with NO SASL SUPPORT") endif (NOT NO_SASL) add_definitions(-DASIO_STANDALONE -DASIO_CPP11_DATE_TIME) # Disable optimizations if compiling debug set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0") if(UNIX) set (CMAKE_CXX_STANDARD 11) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -g -fPIC -fno-strict-aliasing") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fPIC -fno-strict-aliasing") endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(CMAKE_CXX_STANDARD 11) add_definitions(-DASIO_HAS_STD_ADDRESSOF -DASIO_HAS_STD_ARRAY -DASIO_HAS_STD_ATOMIC -DASIO_HAS_CSTDINT -DASIO_HAS_STD_SHARED_PTR -DASIO_HAS_STD_TYPE_TRAITS -DASIO_HAS_VARIADIC_TEMPLATES -DASIO_HAS_STD_FUNCTION -DASIO_HAS_STD_CHRONO -DASIO_HAS_STD_SYSTEM_ERROR) endif () # Mac OS 10.7 and later deprecates most of the methods in OpenSSL. # Add -Wno-deprecated-declarations to avoid the warnings. if(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -Wno-deprecated-declarations -Wno-unused-local-typedef") endif() if(DOXYGEN_FOUND) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile @ONLY) add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating API documentation with Doxygen" VERBATIM) endif(DOXYGEN_FOUND) # Copy files from the hadoop tree into the output/extern directory if # they've changed function (copy_on_demand input_src_glob input_dest_dir) get_filename_component(src_glob ${input_src_glob} REALPATH) get_filename_component(dest_dir ${input_dest_dir} REALPATH) get_filename_component(src_dir ${src_glob} PATH) message(STATUS "Syncing ${src_glob} to ${dest_dir}") file(GLOB_RECURSE src_files ${src_glob}) foreach(src_path ${src_files}) file(RELATIVE_PATH relative_src ${src_dir} ${src_path}) set(dest_path "${dest_dir}/${relative_src}") add_custom_command(TARGET copy_hadoop_files COMMAND ${CMAKE_COMMAND} -E copy_if_different "${src_path}" "${dest_path}" ) endforeach() endfunction() # If we're building in the hadoop tree, pull the Hadoop files that # libhdfspp depends on. This allows us to ensure that # the distribution will have a consistent set of headers and # .proto files if(HADOOP_BUILD) set(HADOOP_IMPORT_DIR ${PROJECT_BINARY_DIR}/extern) get_filename_component(HADOOP_IMPORT_DIR ${HADOOP_IMPORT_DIR} REALPATH) add_custom_target(copy_hadoop_files ALL) # Gather the Hadoop files and resources that libhdfs++ needs to build copy_on_demand(../libhdfs/include/*.h* ${HADOOP_IMPORT_DIR}/include) copy_on_demand(${CMAKE_CURRENT_LIST_DIR}/../../../../../hadoop-hdfs-client/src/main/proto/*.proto ${HADOOP_IMPORT_DIR}/proto/hdfs) copy_on_demand(${CMAKE_CURRENT_LIST_DIR}/../../../../../../hadoop-common-project/hadoop-common/src/main/proto/*.proto ${HADOOP_IMPORT_DIR}/proto/hadoop) copy_on_demand(${CMAKE_CURRENT_LIST_DIR}/../../../../../../hadoop-common-project/hadoop-common/src/test/proto/*.proto ${HADOOP_IMPORT_DIR}/proto/hadoop_test) else(HADOOP_BUILD) set(HADOOP_IMPORT_DIR ${CMAKE_CURRENT_LIST_DIR}/extern) endif(HADOOP_BUILD) # Paths to find the imported files set(PROTO_HDFS_DIR ${HADOOP_IMPORT_DIR}/proto/hdfs) set(PROTO_HADOOP_DIR ${HADOOP_IMPORT_DIR}/proto/hadoop) set(PROTO_HADOOP_TEST_DIR ${HADOOP_IMPORT_DIR}/proto/hadoop_test) include_directories( include lib ${HADOOP_IMPORT_DIR}/include ) include_directories( SYSTEM ${PROJECT_BINARY_DIR}/lib/proto ${Boost_INCLUDE_DIRS} third_party/rapidxml-1.13 third_party/gmock-1.7.0 third_party/tr2 third_party/protobuf third_party/uriparser2 ${OPENSSL_INCLUDE_DIR} ${SASL_INCLUDE_DIR} ${PROTOBUF_INCLUDE_DIRS} ) add_subdirectory(third_party/gmock-1.7.0) add_subdirectory(third_party/uriparser2) add_subdirectory(lib) if(NOT HDFSPP_LIBRARY_ONLY) add_subdirectory(tests) add_subdirectory(examples) add_subdirectory(tools) endif() # create an empty file; hadoop_add_dual_library wraps add_library which # requires at least one file as an argument set(EMPTY_FILE_CC ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/empty.cc) file(WRITE ${EMPTY_FILE_CC} "") # Build the output libraries if(NEED_LINK_DL) set(LIB_DL dl) endif() set(LIBHDFSPP_VERSION "0.1.0") set(LIBHDFSPP_ALL_OBJECTS $<TARGET_OBJECTS:bindings_c_obj> $<TARGET_OBJECTS:fs_obj> $<TARGET_OBJECTS:rpc_obj> $<TARGET_OBJECTS:reader_obj> $<TARGET_OBJECTS:proto_obj> $<TARGET_OBJECTS:connection_obj> $<TARGET_OBJECTS:common_obj> $<TARGET_OBJECTS:uriparser2_obj>) if (HADOOP_BUILD) hadoop_add_dual_library(hdfspp ${EMPTY_FILE_CC} ${LIBHDFSPP_ALL_OBJECTS}) hadoop_target_link_dual_libraries(hdfspp ${LIB_DL} ${PROTOBUF_LIBRARY} ${OPENSSL_LIBRARIES} ${SASL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) set_target_properties(hdfspp PROPERTIES SOVERSION ${LIBHDFSPP_VERSION}) hadoop_dual_output_directory(hdfspp ${OUT_DIR}) else (HADOOP_BUILD) add_library(hdfspp_static STATIC ${EMPTY_FILE_CC} ${LIBHDFSPP_ALL_OBJECTS}) target_link_libraries(hdfspp_static ${LIB_DL} ${PROTOBUF_LIBRARY} ${OPENSSL_LIBRARIES} ${SASL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) if(BUILD_SHARED_HDFSPP) add_library(hdfspp SHARED ${EMPTY_FILE_CC} ${LIBHDFSPP_ALL_OBJECTS}) set_target_properties(hdfspp PROPERTIES SOVERSION ${LIBHDFSPP_VERSION}) endif(BUILD_SHARED_HDFSPP) endif (HADOOP_BUILD) # Set up make install targets # Can be installed to a particular location via "make DESTDIR=... install" file(GLOB_RECURSE LIBHDFSPP_HEADER_FILES "${CMAKE_CURRENT_LIST_DIR}/include/*.h*") file(GLOB_RECURSE LIBHDFS_HEADER_FILES "${HADOOP_IMPORT_DIR}/include/*.h*") install(FILES ${LIBHDFSPP_HEADER_FILES} DESTINATION include/hdfspp) install(FILES ${LIBHDFS_HEADER_FILES} DESTINATION include/hdfs) install(TARGETS hdfspp_static ARCHIVE DESTINATION lib) if(BUILD_SHARED_HDFSPP) install(TARGETS hdfspp LIBRARY DESTINATION lib) endif(BUILD_SHARED_HDFSPP) add_custom_target( InstallToBuildDirectory COMMAND "${CMAKE_MAKE_PROGRAM}" install DESTDIR=${PROJECT_BINARY_DIR}/output ) set(LIBHDFSPP_DIR ${PROJECT_BINARY_DIR}/output)
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <resources> <!-- FTDI Chips --> <!-- (Smart Interface), Heinrichs Weikamp --> <usb-device vendor-id="0x0403" product-id="0x6001"/> <usb-device vendor-id="0x0403" product-id="0x6010"/> <usb-device vendor-id="0x0403" product-id="0x6011"/> <!-- May be Aqualung custom PID? --> <usb-device vendor-id="0x0403" product-id="0x6015"/> <!-- Oceanic Custom PID --> <usb-device vendor-id="0x0403" product-id="0xf460"/> <!-- Suunto Custom PID --> <usb-device vendor-id="0x0403" product-id="0xf680"/> <!-- Cressi (Leonardo) Custom PID --> <usb-device vendor-id="0x0403" product-id="0x87d0"/> <!-- USB devices --> <!-- EON Steel --> <usb-device vendor-id="0x1493" product-id="0x30"/> <!-- EON Steel core --> <usb-device vendor-id="0x1493" product-id="0x33"/> <!-- Scubapro G2 (wrist/console/hud) --> <usb-device vendor-id="0x2e6c" product-id="0x3201"/> <usb-device vendor-id="0x2e6c" product-id="0x3211"/> <usb-device vendor-id="0x2e6c" product-id="0x4201"/> <!-- Scubapro Aladin Square --> <usb-device vendor-id="0xc251" product-id="0x2006"/> <!-- Atomics Aquatics Cobalt --> <usb-device vendor-id="0x0471" product-id="0x0888"/> </resources>
{ "pile_set_name": "Github" }
{ "type": "minecraft:chest", "pools": [ { "rolls": { "min": 1.0, "max": 5.0, "type": "minecraft:uniform" }, "entries": [ { "type": "minecraft:item", "name": "minecraft:emerald" }, { "type": "minecraft:item", "weight": 2, "functions": [ { "function": "minecraft:set_count", "count": { "min": 1.0, "max": 3.0, "type": "minecraft:uniform" } } ], "name": "minecraft:cod" }, { "type": "minecraft:item", "functions": [ { "function": "minecraft:set_count", "count": { "min": 1.0, "max": 3.0, "type": "minecraft:uniform" } } ], "name": "minecraft:salmon" }, { "type": "minecraft:item", "functions": [ { "function": "minecraft:set_count", "count": { "min": 1.0, "max": 3.0, "type": "minecraft:uniform" } } ], "name": "minecraft:water_bucket" }, { "type": "minecraft:item", "functions": [ { "function": "minecraft:set_count", "count": { "min": 1.0, "max": 3.0, "type": "minecraft:uniform" } } ], "name": "minecraft:barrel" }, { "type": "minecraft:item", "weight": 3, "functions": [ { "function": "minecraft:set_count", "count": { "min": 1.0, "max": 3.0, "type": "minecraft:uniform" } } ], "name": "minecraft:wheat_seeds" }, { "type": "minecraft:item", "weight": 2, "functions": [ { "function": "minecraft:set_count", "count": { "min": 1.0, "max": 3.0, "type": "minecraft:uniform" } } ], "name": "minecraft:coal" } ] } ] }
{ "pile_set_name": "Github" }
! ! Copyright (C) 2001-2009 Quantum ESPRESSO group ! This file is distributed under the terms of the ! GNU General Public License. See the file `License' ! in the root directory of the present distribution, ! or http://www.gnu.org/copyleft/gpl.txt . ! ! !----------------------------------------------------------------------- SUBROUTINE qvan2( ngy, ih, jh, np, qmod, qg, ylmk0 ) !----------------------------------------------------------------------- !! This routine computes the Fourier transform of the Q functions. ! !! The interpolation table for the radial Fourier transform is stored !! in qrad. ! !! The formula implemented here is: !! \[ q(g,i,j) = \sum_\text{lm} (-i)^l \text{ap}(\text{lm},i,j) !! \text{yr}_\text{lm}(g) \text{qrad}(g,l,i,j) \] ! USE kinds, ONLY: DP USE us, ONLY: dq, qrad USE uspp_param, ONLY: lmaxq, nbetam USE uspp, ONLY: nlx, lpl, lpx, ap, indv, nhtolm ! IMPLICIT NONE ! INTEGER, INTENT(IN) :: ngy !! number of G vectors to compute INTEGER, INTENT(IN) :: ih !! first index of Q INTEGER, INTENT(IN) :: jh !! second index of Q INTEGER, INTENT(IN) :: np !! index of pseudopotentials REAL(DP), INTENT(IN) :: ylmk0(ngy,lmaxq*lmaxq) !! spherical harmonics REAL(DP), INTENT(IN) :: qmod(ngy) !! moduli of the q+g vectors REAL(DP), INTENT(OUT) :: qg(2,ngy) !! the Fourier transform of interest ! ! ... local variables ! REAL(DP) :: sig ! the nonzero real or imaginary part of (-i)^L ! REAL(DP), PARAMETER :: sixth = 1.0_DP / 6.0_DP ! INTEGER :: nb, mb, ijv, ivl, jvl, ig, lp, l, lm, i0, i1, i2, i3, ind ! nb,mb : atomic index corresponding to ih,jh ! ijv : combined index (nb,mb) ! ivl,jvl: combined LM index corresponding to ih,jh ! ig : counter on g vectors ! lp : combined LM index ! l-1 is the angular momentum L ! lm : all possible LM's compatible with ih,jh ! i0-i3 : counters for interpolation table ! ind : ind=1 if the results is real (l even), ind=2 if complex (l odd) ! REAL(DP) :: dqi, qm, px, ux, vx, wx, uvx, pwx, work, qm1 ! 1 divided dq ! qmod/dq ! measures for interpolation table ! auxiliary variables for intepolation ! auxiliary variables ! ! ... computes the indices which correspond to ih,jh ! dqi = 1.0_DP / dq nb = indv(ih,np) mb = indv(jh,np) ! IF (nb >= mb) THEN ijv = nb * (nb - 1) / 2 + mb ELSE ijv = mb * (mb - 1) / 2 + nb ENDIF ! ivl = nhtolm(ih,np) jvl = nhtolm(jh,np) ! IF (nb > nbetam .OR. mb > nbetam) & CALL errore( ' qvan2 ', ' wrong dimensions (1)', MAX(nb,mb) ) IF (ivl > nlx .OR. jvl > nlx) & CALL errore( ' qvan2 ', ' wrong dimensions (2)', MAX(ivl,jvl) ) ! qg = 0.0_DP ! ! ... and makes the sum over the non zero LM ! DO lm = 1, lpx(ivl,jvl) lp = lpl(ivl,jvl,lm) IF ( lp < 1 .OR. lp > 49 ) CALL errore( 'qvan2', ' lp wrong ', MAX(lp,1) ) ! ! ... finds angular momentum l corresponding to combined index lp (l is ! actually l+1 because this is the way qrad is stored, check init_us_1) ! IF ( lp == 1 ) THEN l = 1 sig = 1.0_DP ind = 1 ELSEIF ( lp <= 4 ) THEN l = 2 sig =-1.0_DP ind = 2 ELSEIF ( lp <= 9 ) THEN l = 3 sig =-1.0_DP ind = 1 ELSEIF ( lp <= 16 ) THEN l = 4 sig = 1.0_DP ind = 2 ELSEIF ( lp <= 25 ) THEN l = 5 sig = 1.0_DP ind = 1 ELSEIF ( lp <= 36 ) THEN l = 6 sig =-1.0_DP ind = 2 ELSE l = 7 sig =-1.0_DP ind = 1 ENDIF ! sig = sig * ap(lp, ivl, jvl) ! qm1 = -1.0_DP ! any number smaller than qmod(1) ! !$omp parallel do default(shared), private(qm,px,ux,vx,wx,i0,i1,i2,i3,uvx,pwx,work) DO ig = 1, ngy ! ! ... calculates quantites depending on the module of G only when needed ! #if ! defined _OPENMP IF ( ABS( qmod(ig) - qm1 ) > 1.0D-6 ) THEN #endif ! qm = qmod (ig) * dqi px = qm - INT(qm) ux = 1.0_DP - px vx = 2.0_DP - px wx = 3.0_DP - px i0 = INT(qm) + 1 i1 = i0 + 1 i2 = i0 + 2 i3 = i0 + 3 uvx = ux * vx * sixth pwx = px * wx * 0.5_DP work = qrad(i0,ijv,l,np) * uvx * wx + & qrad(i1,ijv,l,np) * pwx * vx - & qrad(i2,ijv,l,np) * pwx * ux + & qrad(i3,ijv,l,np) * px * uvx #if ! defined _OPENMP qm1 = qmod(ig) END IF #endif qg(ind,ig) = qg(ind,ig) + sig * ylmk0(ig,lp) * work ! ENDDO !$omp end parallel do ! ENDDO ! ! RETURN ! END SUBROUTINE qvan2
{ "pile_set_name": "Github" }
/* MIT LICENSE Copyright 2017 Digital Ruby, LLC - http://www.digitalruby.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ using System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace ExchangeSharp { public class SimplePeakValleyTrader : Trader { public double AnchorPrice { get; private set; } public bool HitValley { get; private set; } public bool HitPeak { get; private set; } [MethodImpl(MethodImplOptions.AggressiveInlining)] protected override async Task InitializeAsync(ExchangeTradeInfo tradeInfo) { await base.InitializeAsync(tradeInfo); SetPlotListCount(1); AnchorPrice = TradeInfo.Trade.Price; HitValley = HitPeak = false; await ProcessTradeAsync(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] protected override async Task ProcessTradeAsync() { double diff = TradeInfo.Trade.Price - AnchorPrice; PlotPoints[0].Add(new KeyValuePair<float, float>(TradeInfo.Trade.Ticks, TradeInfo.Trade.Price)); if (HitValley && diff <= ((BuyThresholdPercent * AnchorPrice) + (BuyReverseThresholdPercent * AnchorPrice))) { // valley reversal, buy // lower anchor price just a bit in case price drops so we will buy more AnchorPrice -= (BuyFalseReverseThresholdPercent * AnchorPrice); HitPeak = false; await PerformBuyAsync(); } else if (HitPeak && diff >= ((SellThresholdPercent * AnchorPrice) + (SellReverseThresholdPercent * AnchorPrice)) && BuyPrices.Count != 0 && TradeInfo.Trade.Price > BuyPrices[BuyPrices.Count - 1].Value + (SellReverseThresholdPercent * AnchorPrice)) { // peak reversal, sell AnchorPrice = TradeInfo.Trade.Price; HitPeak = HitValley = false; await PerformSellAsync(); } else if (diff < (BuyThresholdPercent * AnchorPrice)) { // valley HitValley = true; HitPeak = false; AnchorPrice = TradeInfo.Trade.Price; } else if (diff > (SellThresholdPercent * AnchorPrice)) { // peak HitPeak = true; HitValley = false; AnchorPrice = TradeInfo.Trade.Price; } else { // watch } } } }
{ "pile_set_name": "Github" }
require 'sql_helper' module Bmg module Sql class Processor describe Merge, "on_with_exp" do subject{ Merge.new(:intersect, false, right, builder(1)).on_with_exp(expr) } context 'when right is a simple exp' do let(:expr){ # with t1 AS ... # SELECT * FROM t1 with_exp({t1: select_all}, select_all) } let(:right){ # SELECT * FROM t2 select_all_t2 } let(:expected){ # WITH t1 AS ... # SELECT * FROM t1 INTERSECT SELECT * FROM t2 with_exp({t1: select_all}, intersect) } it{ should eq(expected) } end context 'when right is a with_exp' do let(:expr){ # WITH t1 AS ... # SELECT * FROM t1 with_exp({t1: select_all}, select_all) } let(:right){ # WITH t2 AS ... # SELECT * FROM t2 with_exp({t2: select_all_t2}, select_all_t2) } let(:expected){ # WITH t1 AS ... # t2 AS ... # SELECT * FROM t1 INTERSECT SELECT * FROM t2 with_exp({t1: select_all, t2: select_all_t2}, intersect) } it{ should eq(expected) } end end end end end
{ "pile_set_name": "Github" }
/* * Hierarchical Budget Worst-case Fair Weighted Fair Queueing * (B-WF2Q+): hierarchical scheduling algorithm by which the BFQ I/O * scheduler schedules generic entities. The latter can represent * either single bfq queues (associated with processes) or groups of * bfq queues (associated with cgroups). * * 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. */ #include "bfq-iosched.h" /** * bfq_gt - compare two timestamps. * @a: first ts. * @b: second ts. * * Return @a > @b, dealing with wrapping correctly. */ static int bfq_gt(u64 a, u64 b) { return (s64)(a - b) > 0; } static struct bfq_entity *bfq_root_active_entity(struct rb_root *tree) { struct rb_node *node = tree->rb_node; return rb_entry(node, struct bfq_entity, rb_node); } static unsigned int bfq_class_idx(struct bfq_entity *entity) { struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); return bfqq ? bfqq->ioprio_class - 1 : BFQ_DEFAULT_GRP_CLASS - 1; } static struct bfq_entity *bfq_lookup_next_entity(struct bfq_sched_data *sd, bool expiration); static bool bfq_update_parent_budget(struct bfq_entity *next_in_service); /** * bfq_update_next_in_service - update sd->next_in_service * @sd: sched_data for which to perform the update. * @new_entity: if not NULL, pointer to the entity whose activation, * requeueing or repositionig triggered the invocation of * this function. * @expiration: id true, this function is being invoked after the * expiration of the in-service entity * * This function is called to update sd->next_in_service, which, in * its turn, may change as a consequence of the insertion or * extraction of an entity into/from one of the active trees of * sd. These insertions/extractions occur as a consequence of * activations/deactivations of entities, with some activations being * 'true' activations, and other activations being requeueings (i.e., * implementing the second, requeueing phase of the mechanism used to * reposition an entity in its active tree; see comments on * __bfq_activate_entity and __bfq_requeue_entity for details). In * both the last two activation sub-cases, new_entity points to the * just activated or requeued entity. * * Returns true if sd->next_in_service changes in such a way that * entity->parent may become the next_in_service for its parent * entity. */ static bool bfq_update_next_in_service(struct bfq_sched_data *sd, struct bfq_entity *new_entity, bool expiration) { struct bfq_entity *next_in_service = sd->next_in_service; bool parent_sched_may_change = false; bool change_without_lookup = false; /* * If this update is triggered by the activation, requeueing * or repositiong of an entity that does not coincide with * sd->next_in_service, then a full lookup in the active tree * can be avoided. In fact, it is enough to check whether the * just-modified entity has the same priority as * sd->next_in_service, is eligible and has a lower virtual * finish time than sd->next_in_service. If this compound * condition holds, then the new entity becomes the new * next_in_service. Otherwise no change is needed. */ if (new_entity && new_entity != sd->next_in_service) { /* * Flag used to decide whether to replace * sd->next_in_service with new_entity. Tentatively * set to true, and left as true if * sd->next_in_service is NULL. */ change_without_lookup = true; /* * If there is already a next_in_service candidate * entity, then compare timestamps to decide whether * to replace sd->service_tree with new_entity. */ if (next_in_service) { unsigned int new_entity_class_idx = bfq_class_idx(new_entity); struct bfq_service_tree *st = sd->service_tree + new_entity_class_idx; change_without_lookup = (new_entity_class_idx == bfq_class_idx(next_in_service) && !bfq_gt(new_entity->start, st->vtime) && bfq_gt(next_in_service->finish, new_entity->finish)); } if (change_without_lookup) next_in_service = new_entity; } if (!change_without_lookup) /* lookup needed */ next_in_service = bfq_lookup_next_entity(sd, expiration); if (next_in_service) { bool new_budget_triggers_change = bfq_update_parent_budget(next_in_service); parent_sched_may_change = !sd->next_in_service || new_budget_triggers_change; } sd->next_in_service = next_in_service; if (!next_in_service) return parent_sched_may_change; return parent_sched_may_change; } #ifdef CONFIG_BFQ_GROUP_IOSCHED struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq) { struct bfq_entity *group_entity = bfqq->entity.parent; if (!group_entity) group_entity = &bfqq->bfqd->root_group->entity; return container_of(group_entity, struct bfq_group, entity); } /* * Returns true if this budget changes may let next_in_service->parent * become the next_in_service entity for its parent entity. */ static bool bfq_update_parent_budget(struct bfq_entity *next_in_service) { struct bfq_entity *bfqg_entity; struct bfq_group *bfqg; struct bfq_sched_data *group_sd; bool ret = false; group_sd = next_in_service->sched_data; bfqg = container_of(group_sd, struct bfq_group, sched_data); /* * bfq_group's my_entity field is not NULL only if the group * is not the root group. We must not touch the root entity * as it must never become an in-service entity. */ bfqg_entity = bfqg->my_entity; if (bfqg_entity) { if (bfqg_entity->budget > next_in_service->budget) ret = true; bfqg_entity->budget = next_in_service->budget; } return ret; } /* * This function tells whether entity stops being a candidate for next * service, according to the restrictive definition of the field * next_in_service. In particular, this function is invoked for an * entity that is about to be set in service. * * If entity is a queue, then the entity is no longer a candidate for * next service according to the that definition, because entity is * about to become the in-service queue. This function then returns * true if entity is a queue. * * In contrast, entity could still be a candidate for next service if * it is not a queue, and has more than one active child. In fact, * even if one of its children is about to be set in service, other * active children may still be the next to serve, for the parent * entity, even according to the above definition. As a consequence, a * non-queue entity is not a candidate for next-service only if it has * only one active child. And only if this condition holds, then this * function returns true for a non-queue entity. */ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity) { struct bfq_group *bfqg; if (bfq_entity_to_bfqq(entity)) return true; bfqg = container_of(entity, struct bfq_group, entity); /* * The field active_entities does not always contain the * actual number of active children entities: it happens to * not account for the in-service entity in case the latter is * removed from its active tree (which may get done after * invoking the function bfq_no_longer_next_in_service in * bfq_get_next_queue). Fortunately, here, i.e., while * bfq_no_longer_next_in_service is not yet completed in * bfq_get_next_queue, bfq_active_extract has not yet been * invoked, and thus active_entities still coincides with the * actual number of active entities. */ if (bfqg->active_entities == 1) return true; return false; } #else /* CONFIG_BFQ_GROUP_IOSCHED */ struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq) { return bfqq->bfqd->root_group; } static bool bfq_update_parent_budget(struct bfq_entity *next_in_service) { return false; } static bool bfq_no_longer_next_in_service(struct bfq_entity *entity) { return true; } #endif /* CONFIG_BFQ_GROUP_IOSCHED */ /* * Shift for timestamp calculations. This actually limits the maximum * service allowed in one timestamp delta (small shift values increase it), * the maximum total weight that can be used for the queues in the system * (big shift values increase it), and the period of virtual time * wraparounds. */ #define WFQ_SERVICE_SHIFT 22 struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity) { struct bfq_queue *bfqq = NULL; if (!entity->my_sched_data) bfqq = container_of(entity, struct bfq_queue, entity); return bfqq; } /** * bfq_delta - map service into the virtual time domain. * @service: amount of service. * @weight: scale factor (weight of an entity or weight sum). */ static u64 bfq_delta(unsigned long service, unsigned long weight) { u64 d = (u64)service << WFQ_SERVICE_SHIFT; do_div(d, weight); return d; } /** * bfq_calc_finish - assign the finish time to an entity. * @entity: the entity to act upon. * @service: the service to be charged to the entity. */ static void bfq_calc_finish(struct bfq_entity *entity, unsigned long service) { struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); entity->finish = entity->start + bfq_delta(service, entity->weight); if (bfqq) { bfq_log_bfqq(bfqq->bfqd, bfqq, "calc_finish: serv %lu, w %d", service, entity->weight); bfq_log_bfqq(bfqq->bfqd, bfqq, "calc_finish: start %llu, finish %llu, delta %llu", entity->start, entity->finish, bfq_delta(service, entity->weight)); } } /** * bfq_entity_of - get an entity from a node. * @node: the node field of the entity. * * Convert a node pointer to the relative entity. This is used only * to simplify the logic of some functions and not as the generic * conversion mechanism because, e.g., in the tree walking functions, * the check for a %NULL value would be redundant. */ struct bfq_entity *bfq_entity_of(struct rb_node *node) { struct bfq_entity *entity = NULL; if (node) entity = rb_entry(node, struct bfq_entity, rb_node); return entity; } /** * bfq_extract - remove an entity from a tree. * @root: the tree root. * @entity: the entity to remove. */ static void bfq_extract(struct rb_root *root, struct bfq_entity *entity) { entity->tree = NULL; rb_erase(&entity->rb_node, root); } /** * bfq_idle_extract - extract an entity from the idle tree. * @st: the service tree of the owning @entity. * @entity: the entity being removed. */ static void bfq_idle_extract(struct bfq_service_tree *st, struct bfq_entity *entity) { struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); struct rb_node *next; if (entity == st->first_idle) { next = rb_next(&entity->rb_node); st->first_idle = bfq_entity_of(next); } if (entity == st->last_idle) { next = rb_prev(&entity->rb_node); st->last_idle = bfq_entity_of(next); } bfq_extract(&st->idle, entity); if (bfqq) list_del(&bfqq->bfqq_list); } /** * bfq_insert - generic tree insertion. * @root: tree root. * @entity: entity to insert. * * This is used for the idle and the active tree, since they are both * ordered by finish time. */ static void bfq_insert(struct rb_root *root, struct bfq_entity *entity) { struct bfq_entity *entry; struct rb_node **node = &root->rb_node; struct rb_node *parent = NULL; while (*node) { parent = *node; entry = rb_entry(parent, struct bfq_entity, rb_node); if (bfq_gt(entry->finish, entity->finish)) node = &parent->rb_left; else node = &parent->rb_right; } rb_link_node(&entity->rb_node, parent, node); rb_insert_color(&entity->rb_node, root); entity->tree = root; } /** * bfq_update_min - update the min_start field of a entity. * @entity: the entity to update. * @node: one of its children. * * This function is called when @entity may store an invalid value for * min_start due to updates to the active tree. The function assumes * that the subtree rooted at @node (which may be its left or its right * child) has a valid min_start value. */ static void bfq_update_min(struct bfq_entity *entity, struct rb_node *node) { struct bfq_entity *child; if (node) { child = rb_entry(node, struct bfq_entity, rb_node); if (bfq_gt(entity->min_start, child->min_start)) entity->min_start = child->min_start; } } /** * bfq_update_active_node - recalculate min_start. * @node: the node to update. * * @node may have changed position or one of its children may have moved, * this function updates its min_start value. The left and right subtrees * are assumed to hold a correct min_start value. */ static void bfq_update_active_node(struct rb_node *node) { struct bfq_entity *entity = rb_entry(node, struct bfq_entity, rb_node); entity->min_start = entity->start; bfq_update_min(entity, node->rb_right); bfq_update_min(entity, node->rb_left); } /** * bfq_update_active_tree - update min_start for the whole active tree. * @node: the starting node. * * @node must be the deepest modified node after an update. This function * updates its min_start using the values held by its children, assuming * that they did not change, and then updates all the nodes that may have * changed in the path to the root. The only nodes that may have changed * are the ones in the path or their siblings. */ static void bfq_update_active_tree(struct rb_node *node) { struct rb_node *parent; up: bfq_update_active_node(node); parent = rb_parent(node); if (!parent) return; if (node == parent->rb_left && parent->rb_right) bfq_update_active_node(parent->rb_right); else if (parent->rb_left) bfq_update_active_node(parent->rb_left); node = parent; goto up; } /** * bfq_active_insert - insert an entity in the active tree of its * group/device. * @st: the service tree of the entity. * @entity: the entity being inserted. * * The active tree is ordered by finish time, but an extra key is kept * per each node, containing the minimum value for the start times of * its children (and the node itself), so it's possible to search for * the eligible node with the lowest finish time in logarithmic time. */ static void bfq_active_insert(struct bfq_service_tree *st, struct bfq_entity *entity) { struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); struct rb_node *node = &entity->rb_node; #ifdef CONFIG_BFQ_GROUP_IOSCHED struct bfq_sched_data *sd = NULL; struct bfq_group *bfqg = NULL; struct bfq_data *bfqd = NULL; #endif bfq_insert(&st->active, entity); if (node->rb_left) node = node->rb_left; else if (node->rb_right) node = node->rb_right; bfq_update_active_tree(node); #ifdef CONFIG_BFQ_GROUP_IOSCHED sd = entity->sched_data; bfqg = container_of(sd, struct bfq_group, sched_data); bfqd = (struct bfq_data *)bfqg->bfqd; #endif if (bfqq) list_add(&bfqq->bfqq_list, &bfqq->bfqd->active_list); #ifdef CONFIG_BFQ_GROUP_IOSCHED if (bfqg != bfqd->root_group) bfqg->active_entities++; #endif } /** * bfq_ioprio_to_weight - calc a weight from an ioprio. * @ioprio: the ioprio value to convert. */ unsigned short bfq_ioprio_to_weight(int ioprio) { return (IOPRIO_BE_NR - ioprio) * BFQ_WEIGHT_CONVERSION_COEFF; } /** * bfq_weight_to_ioprio - calc an ioprio from a weight. * @weight: the weight value to convert. * * To preserve as much as possible the old only-ioprio user interface, * 0 is used as an escape ioprio value for weights (numerically) equal or * larger than IOPRIO_BE_NR * BFQ_WEIGHT_CONVERSION_COEFF. */ static unsigned short bfq_weight_to_ioprio(int weight) { return max_t(int, 0, IOPRIO_BE_NR * BFQ_WEIGHT_CONVERSION_COEFF - weight); } static void bfq_get_entity(struct bfq_entity *entity) { struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); if (bfqq) { bfqq->ref++; bfq_log_bfqq(bfqq->bfqd, bfqq, "get_entity: %p %d", bfqq, bfqq->ref); } } /** * bfq_find_deepest - find the deepest node that an extraction can modify. * @node: the node being removed. * * Do the first step of an extraction in an rb tree, looking for the * node that will replace @node, and returning the deepest node that * the following modifications to the tree can touch. If @node is the * last node in the tree return %NULL. */ static struct rb_node *bfq_find_deepest(struct rb_node *node) { struct rb_node *deepest; if (!node->rb_right && !node->rb_left) deepest = rb_parent(node); else if (!node->rb_right) deepest = node->rb_left; else if (!node->rb_left) deepest = node->rb_right; else { deepest = rb_next(node); if (deepest->rb_right) deepest = deepest->rb_right; else if (rb_parent(deepest) != node) deepest = rb_parent(deepest); } return deepest; } /** * bfq_active_extract - remove an entity from the active tree. * @st: the service_tree containing the tree. * @entity: the entity being removed. */ static void bfq_active_extract(struct bfq_service_tree *st, struct bfq_entity *entity) { struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); struct rb_node *node; #ifdef CONFIG_BFQ_GROUP_IOSCHED struct bfq_sched_data *sd = NULL; struct bfq_group *bfqg = NULL; struct bfq_data *bfqd = NULL; #endif node = bfq_find_deepest(&entity->rb_node); bfq_extract(&st->active, entity); if (node) bfq_update_active_tree(node); #ifdef CONFIG_BFQ_GROUP_IOSCHED sd = entity->sched_data; bfqg = container_of(sd, struct bfq_group, sched_data); bfqd = (struct bfq_data *)bfqg->bfqd; #endif if (bfqq) list_del(&bfqq->bfqq_list); #ifdef CONFIG_BFQ_GROUP_IOSCHED if (bfqg != bfqd->root_group) bfqg->active_entities--; #endif } /** * bfq_idle_insert - insert an entity into the idle tree. * @st: the service tree containing the tree. * @entity: the entity to insert. */ static void bfq_idle_insert(struct bfq_service_tree *st, struct bfq_entity *entity) { struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); struct bfq_entity *first_idle = st->first_idle; struct bfq_entity *last_idle = st->last_idle; if (!first_idle || bfq_gt(first_idle->finish, entity->finish)) st->first_idle = entity; if (!last_idle || bfq_gt(entity->finish, last_idle->finish)) st->last_idle = entity; bfq_insert(&st->idle, entity); if (bfqq) list_add(&bfqq->bfqq_list, &bfqq->bfqd->idle_list); } /** * bfq_forget_entity - do not consider entity any longer for scheduling * @st: the service tree. * @entity: the entity being removed. * @is_in_service: true if entity is currently the in-service entity. * * Forget everything about @entity. In addition, if entity represents * a queue, and the latter is not in service, then release the service * reference to the queue (the one taken through bfq_get_entity). In * fact, in this case, there is really no more service reference to * the queue, as the latter is also outside any service tree. If, * instead, the queue is in service, then __bfq_bfqd_reset_in_service * will take care of putting the reference when the queue finally * stops being served. */ static void bfq_forget_entity(struct bfq_service_tree *st, struct bfq_entity *entity, bool is_in_service) { struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); entity->on_st = false; st->wsum -= entity->weight; if (bfqq && !is_in_service) bfq_put_queue(bfqq); } /** * bfq_put_idle_entity - release the idle tree ref of an entity. * @st: service tree for the entity. * @entity: the entity being released. */ void bfq_put_idle_entity(struct bfq_service_tree *st, struct bfq_entity *entity) { bfq_idle_extract(st, entity); bfq_forget_entity(st, entity, entity == entity->sched_data->in_service_entity); } /** * bfq_forget_idle - update the idle tree if necessary. * @st: the service tree to act upon. * * To preserve the global O(log N) complexity we only remove one entry here; * as the idle tree will not grow indefinitely this can be done safely. */ static void bfq_forget_idle(struct bfq_service_tree *st) { struct bfq_entity *first_idle = st->first_idle; struct bfq_entity *last_idle = st->last_idle; if (RB_EMPTY_ROOT(&st->active) && last_idle && !bfq_gt(last_idle->finish, st->vtime)) { /* * Forget the whole idle tree, increasing the vtime past * the last finish time of idle entities. */ st->vtime = last_idle->finish; } if (first_idle && !bfq_gt(first_idle->finish, st->vtime)) bfq_put_idle_entity(st, first_idle); } struct bfq_service_tree *bfq_entity_service_tree(struct bfq_entity *entity) { struct bfq_sched_data *sched_data = entity->sched_data; unsigned int idx = bfq_class_idx(entity); return sched_data->service_tree + idx; } /* * Update weight and priority of entity. If update_class_too is true, * then update the ioprio_class of entity too. * * The reason why the update of ioprio_class is controlled through the * last parameter is as follows. Changing the ioprio class of an * entity implies changing the destination service trees for that * entity. If such a change occurred when the entity is already on one * of the service trees for its previous class, then the state of the * entity would become more complex: none of the new possible service * trees for the entity, according to bfq_entity_service_tree(), would * match any of the possible service trees on which the entity * is. Complex operations involving these trees, such as entity * activations and deactivations, should take into account this * additional complexity. To avoid this issue, this function is * invoked with update_class_too unset in the points in the code where * entity may happen to be on some tree. */ struct bfq_service_tree * __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st, struct bfq_entity *entity, bool update_class_too) { struct bfq_service_tree *new_st = old_st; if (entity->prio_changed) { struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); unsigned int prev_weight, new_weight; struct bfq_data *bfqd = NULL; struct rb_root *root; #ifdef CONFIG_BFQ_GROUP_IOSCHED struct bfq_sched_data *sd; struct bfq_group *bfqg; #endif if (bfqq) bfqd = bfqq->bfqd; #ifdef CONFIG_BFQ_GROUP_IOSCHED else { sd = entity->my_sched_data; bfqg = container_of(sd, struct bfq_group, sched_data); bfqd = (struct bfq_data *)bfqg->bfqd; } #endif old_st->wsum -= entity->weight; if (entity->new_weight != entity->orig_weight) { if (entity->new_weight < BFQ_MIN_WEIGHT || entity->new_weight > BFQ_MAX_WEIGHT) { pr_crit("update_weight_prio: new_weight %d\n", entity->new_weight); if (entity->new_weight < BFQ_MIN_WEIGHT) entity->new_weight = BFQ_MIN_WEIGHT; else entity->new_weight = BFQ_MAX_WEIGHT; } entity->orig_weight = entity->new_weight; if (bfqq) bfqq->ioprio = bfq_weight_to_ioprio(entity->orig_weight); } if (bfqq && update_class_too) bfqq->ioprio_class = bfqq->new_ioprio_class; /* * Reset prio_changed only if the ioprio_class change * is not pending any longer. */ if (!bfqq || bfqq->ioprio_class == bfqq->new_ioprio_class) entity->prio_changed = 0; /* * NOTE: here we may be changing the weight too early, * this will cause unfairness. The correct approach * would have required additional complexity to defer * weight changes to the proper time instants (i.e., * when entity->finish <= old_st->vtime). */ new_st = bfq_entity_service_tree(entity); prev_weight = entity->weight; new_weight = entity->orig_weight * (bfqq ? bfqq->wr_coeff : 1); /* * If the weight of the entity changes, remove the entity * from its old weight counter (if there is a counter * associated with the entity), and add it to the counter * associated with its new weight. */ if (prev_weight != new_weight) { root = bfqq ? &bfqd->queue_weights_tree : &bfqd->group_weights_tree; __bfq_weights_tree_remove(bfqd, entity, root); } entity->weight = new_weight; /* * Add the entity to its weights tree only if it is * not associated with a weight-raised queue. */ if (prev_weight != new_weight && (bfqq ? bfqq->wr_coeff == 1 : 1)) /* If we get here, root has been initialized. */ bfq_weights_tree_add(bfqd, entity, root); new_st->wsum += entity->weight; if (new_st != old_st) entity->start = new_st->vtime; } return new_st; } /** * bfq_bfqq_served - update the scheduler status after selection for * service. * @bfqq: the queue being served. * @served: bytes to transfer. * * NOTE: this can be optimized, as the timestamps of upper level entities * are synchronized every time a new bfqq is selected for service. By now, * we keep it to better check consistency. */ void bfq_bfqq_served(struct bfq_queue *bfqq, int served) { struct bfq_entity *entity = &bfqq->entity; struct bfq_service_tree *st; if (!bfqq->service_from_backlogged) bfqq->first_IO_time = jiffies; if (bfqq->wr_coeff > 1) bfqq->service_from_wr += served; bfqq->service_from_backlogged += served; for_each_entity(entity) { st = bfq_entity_service_tree(entity); entity->service += served; st->vtime += bfq_delta(served, st->wsum); bfq_forget_idle(st); } bfq_log_bfqq(bfqq->bfqd, bfqq, "bfqq_served %d secs", served); } /** * bfq_bfqq_charge_time - charge an amount of service equivalent to the length * of the time interval during which bfqq has been in * service. * @bfqd: the device * @bfqq: the queue that needs a service update. * @time_ms: the amount of time during which the queue has received service * * If a queue does not consume its budget fast enough, then providing * the queue with service fairness may impair throughput, more or less * severely. For this reason, queues that consume their budget slowly * are provided with time fairness instead of service fairness. This * goal is achieved through the BFQ scheduling engine, even if such an * engine works in the service, and not in the time domain. The trick * is charging these queues with an inflated amount of service, equal * to the amount of service that they would have received during their * service slot if they had been fast, i.e., if their requests had * been dispatched at a rate equal to the estimated peak rate. * * It is worth noting that time fairness can cause important * distortions in terms of bandwidth distribution, on devices with * internal queueing. The reason is that I/O requests dispatched * during the service slot of a queue may be served after that service * slot is finished, and may have a total processing time loosely * correlated with the duration of the service slot. This is * especially true for short service slots. */ void bfq_bfqq_charge_time(struct bfq_data *bfqd, struct bfq_queue *bfqq, unsigned long time_ms) { struct bfq_entity *entity = &bfqq->entity; unsigned long timeout_ms = jiffies_to_msecs(bfq_timeout); unsigned long bounded_time_ms = min(time_ms, timeout_ms); int serv_to_charge_for_time = (bfqd->bfq_max_budget * bounded_time_ms) / timeout_ms; int tot_serv_to_charge = max(serv_to_charge_for_time, entity->service); /* Increase budget to avoid inconsistencies */ if (tot_serv_to_charge > entity->budget) entity->budget = tot_serv_to_charge; bfq_bfqq_served(bfqq, max_t(int, 0, tot_serv_to_charge - entity->service)); } static void bfq_update_fin_time_enqueue(struct bfq_entity *entity, struct bfq_service_tree *st, bool backshifted) { struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); /* * When this function is invoked, entity is not in any service * tree, then it is safe to invoke next function with the last * parameter set (see the comments on the function). */ st = __bfq_entity_update_weight_prio(st, entity, true); bfq_calc_finish(entity, entity->budget); /* * If some queues enjoy backshifting for a while, then their * (virtual) finish timestamps may happen to become lower and * lower than the system virtual time. In particular, if * these queues often happen to be idle for short time * periods, and during such time periods other queues with * higher timestamps happen to be busy, then the backshifted * timestamps of the former queues can become much lower than * the system virtual time. In fact, to serve the queues with * higher timestamps while the ones with lower timestamps are * idle, the system virtual time may be pushed-up to much * higher values than the finish timestamps of the idle * queues. As a consequence, the finish timestamps of all new * or newly activated queues may end up being much larger than * those of lucky queues with backshifted timestamps. The * latter queues may then monopolize the device for a lot of * time. This would simply break service guarantees. * * To reduce this problem, push up a little bit the * backshifted timestamps of the queue associated with this * entity (only a queue can happen to have the backshifted * flag set): just enough to let the finish timestamp of the * queue be equal to the current value of the system virtual * time. This may introduce a little unfairness among queues * with backshifted timestamps, but it does not break * worst-case fairness guarantees. * * As a special case, if bfqq is weight-raised, push up * timestamps much less, to keep very low the probability that * this push up causes the backshifted finish timestamps of * weight-raised queues to become higher than the backshifted * finish timestamps of non weight-raised queues. */ if (backshifted && bfq_gt(st->vtime, entity->finish)) { unsigned long delta = st->vtime - entity->finish; if (bfqq) delta /= bfqq->wr_coeff; entity->start += delta; entity->finish += delta; } bfq_active_insert(st, entity); } /** * __bfq_activate_entity - handle activation of entity. * @entity: the entity being activated. * @non_blocking_wait_rq: true if entity was waiting for a request * * Called for a 'true' activation, i.e., if entity is not active and * one of its children receives a new request. * * Basically, this function updates the timestamps of entity and * inserts entity into its active tree, after possibly extracting it * from its idle tree. */ static void __bfq_activate_entity(struct bfq_entity *entity, bool non_blocking_wait_rq) { struct bfq_service_tree *st = bfq_entity_service_tree(entity); bool backshifted = false; unsigned long long min_vstart; /* See comments on bfq_fqq_update_budg_for_activation */ if (non_blocking_wait_rq && bfq_gt(st->vtime, entity->finish)) { backshifted = true; min_vstart = entity->finish; } else min_vstart = st->vtime; if (entity->tree == &st->idle) { /* * Must be on the idle tree, bfq_idle_extract() will * check for that. */ bfq_idle_extract(st, entity); entity->start = bfq_gt(min_vstart, entity->finish) ? min_vstart : entity->finish; } else { /* * The finish time of the entity may be invalid, and * it is in the past for sure, otherwise the queue * would have been on the idle tree. */ entity->start = min_vstart; st->wsum += entity->weight; /* * entity is about to be inserted into a service tree, * and then set in service: get a reference to make * sure entity does not disappear until it is no * longer in service or scheduled for service. */ bfq_get_entity(entity); entity->on_st = true; } #ifdef CONFIG_BFQ_GROUP_IOSCHED if (!bfq_entity_to_bfqq(entity)) { /* bfq_group */ struct bfq_group *bfqg = container_of(entity, struct bfq_group, entity); struct bfq_data *bfqd = bfqg->bfqd; bfq_weights_tree_add(bfqg->bfqd, entity, &bfqd->group_weights_tree); } #endif bfq_update_fin_time_enqueue(entity, st, backshifted); } /** * __bfq_requeue_entity - handle requeueing or repositioning of an entity. * @entity: the entity being requeued or repositioned. * * Requeueing is needed if this entity stops being served, which * happens if a leaf descendant entity has expired. On the other hand, * repositioning is needed if the next_inservice_entity for the child * entity has changed. See the comments inside the function for * details. * * Basically, this function: 1) removes entity from its active tree if * present there, 2) updates the timestamps of entity and 3) inserts * entity back into its active tree (in the new, right position for * the new values of the timestamps). */ static void __bfq_requeue_entity(struct bfq_entity *entity) { struct bfq_sched_data *sd = entity->sched_data; struct bfq_service_tree *st = bfq_entity_service_tree(entity); if (entity == sd->in_service_entity) { /* * We are requeueing the current in-service entity, * which may have to be done for one of the following * reasons: * - entity represents the in-service queue, and the * in-service queue is being requeued after an * expiration; * - entity represents a group, and its budget has * changed because one of its child entities has * just been either activated or requeued for some * reason; the timestamps of the entity need then to * be updated, and the entity needs to be enqueued * or repositioned accordingly. * * In particular, before requeueing, the start time of * the entity must be moved forward to account for the * service that the entity has received while in * service. This is done by the next instructions. The * finish time will then be updated according to this * new value of the start time, and to the budget of * the entity. */ bfq_calc_finish(entity, entity->service); entity->start = entity->finish; /* * In addition, if the entity had more than one child * when set in service, then it was not extracted from * the active tree. This implies that the position of * the entity in the active tree may need to be * changed now, because we have just updated the start * time of the entity, and we will update its finish * time in a moment (the requeueing is then, more * precisely, a repositioning in this case). To * implement this repositioning, we: 1) dequeue the * entity here, 2) update the finish time and requeue * the entity according to the new timestamps below. */ if (entity->tree) bfq_active_extract(st, entity); } else { /* The entity is already active, and not in service */ /* * In this case, this function gets called only if the * next_in_service entity below this entity has * changed, and this change has caused the budget of * this entity to change, which, finally implies that * the finish time of this entity must be * updated. Such an update may cause the scheduling, * i.e., the position in the active tree, of this * entity to change. We handle this change by: 1) * dequeueing the entity here, 2) updating the finish * time and requeueing the entity according to the new * timestamps below. This is the same approach as the * non-extracted-entity sub-case above. */ bfq_active_extract(st, entity); } bfq_update_fin_time_enqueue(entity, st, false); } static void __bfq_activate_requeue_entity(struct bfq_entity *entity, struct bfq_sched_data *sd, bool non_blocking_wait_rq) { struct bfq_service_tree *st = bfq_entity_service_tree(entity); if (sd->in_service_entity == entity || entity->tree == &st->active) /* * in service or already queued on the active tree, * requeue or reposition */ __bfq_requeue_entity(entity); else /* * Not in service and not queued on its active tree: * the activity is idle and this is a true activation. */ __bfq_activate_entity(entity, non_blocking_wait_rq); } /** * bfq_activate_requeue_entity - activate or requeue an entity representing a * bfq_queue, and activate, requeue or reposition * all ancestors for which such an update becomes * necessary. * @entity: the entity to activate. * @non_blocking_wait_rq: true if this entity was waiting for a request * @requeue: true if this is a requeue, which implies that bfqq is * being expired; thus ALL its ancestors stop being served and must * therefore be requeued * @expiration: true if this function is being invoked in the expiration path * of the in-service queue */ static void bfq_activate_requeue_entity(struct bfq_entity *entity, bool non_blocking_wait_rq, bool requeue, bool expiration) { struct bfq_sched_data *sd; for_each_entity(entity) { sd = entity->sched_data; __bfq_activate_requeue_entity(entity, sd, non_blocking_wait_rq); if (!bfq_update_next_in_service(sd, entity, expiration) && !requeue) break; } } /** * __bfq_deactivate_entity - deactivate an entity from its service tree. * @entity: the entity to deactivate. * @ins_into_idle_tree: if false, the entity will not be put into the * idle tree. * * Deactivates an entity, independently of its previous state. Must * be invoked only if entity is on a service tree. Extracts the entity * from that tree, and if necessary and allowed, puts it into the idle * tree. */ bool __bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree) { struct bfq_sched_data *sd = entity->sched_data; struct bfq_service_tree *st; bool is_in_service; if (!entity->on_st) /* entity never activated, or already inactive */ return false; /* * If we get here, then entity is active, which implies that * bfq_group_set_parent has already been invoked for the group * represented by entity. Therefore, the field * entity->sched_data has been set, and we can safely use it. */ st = bfq_entity_service_tree(entity); is_in_service = entity == sd->in_service_entity; bfq_calc_finish(entity, entity->service); if (is_in_service) sd->in_service_entity = NULL; else /* * Non in-service entity: nobody will take care of * resetting its service counter on expiration. Do it * now. */ entity->service = 0; if (entity->tree == &st->active) bfq_active_extract(st, entity); else if (!is_in_service && entity->tree == &st->idle) bfq_idle_extract(st, entity); if (!ins_into_idle_tree || !bfq_gt(entity->finish, st->vtime)) bfq_forget_entity(st, entity, is_in_service); else bfq_idle_insert(st, entity); return true; } /** * bfq_deactivate_entity - deactivate an entity representing a bfq_queue. * @entity: the entity to deactivate. * @ins_into_idle_tree: true if the entity can be put into the idle tree * @expiration: true if this function is being invoked in the expiration path * of the in-service queue */ static void bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree, bool expiration) { struct bfq_sched_data *sd; struct bfq_entity *parent = NULL; for_each_entity_safe(entity, parent) { sd = entity->sched_data; if (!__bfq_deactivate_entity(entity, ins_into_idle_tree)) { /* * entity is not in any tree any more, so * this deactivation is a no-op, and there is * nothing to change for upper-level entities * (in case of expiration, this can never * happen). */ return; } if (sd->next_in_service == entity) /* * entity was the next_in_service entity, * then, since entity has just been * deactivated, a new one must be found. */ bfq_update_next_in_service(sd, NULL, expiration); if (sd->next_in_service || sd->in_service_entity) { /* * The parent entity is still active, because * either next_in_service or in_service_entity * is not NULL. So, no further upwards * deactivation must be performed. Yet, * next_in_service has changed. Then the * schedule does need to be updated upwards. * * NOTE If in_service_entity is not NULL, then * next_in_service may happen to be NULL, * although the parent entity is evidently * active. This happens if 1) the entity * pointed by in_service_entity is the only * active entity in the parent entity, and 2) * according to the definition of * next_in_service, the in_service_entity * cannot be considered as * next_in_service. See the comments on the * definition of next_in_service for details. */ break; } /* * If we get here, then the parent is no more * backlogged and we need to propagate the * deactivation upwards. Thus let the loop go on. */ /* * Also let parent be queued into the idle tree on * deactivation, to preserve service guarantees, and * assuming that who invoked this function does not * need parent entities too to be removed completely. */ ins_into_idle_tree = true; } /* * If the deactivation loop is fully executed, then there are * no more entities to touch and next loop is not executed at * all. Otherwise, requeue remaining entities if they are * about to stop receiving service, or reposition them if this * is not the case. */ entity = parent; for_each_entity(entity) { /* * Invoke __bfq_requeue_entity on entity, even if * already active, to requeue/reposition it in the * active tree (because sd->next_in_service has * changed) */ __bfq_requeue_entity(entity); sd = entity->sched_data; if (!bfq_update_next_in_service(sd, entity, expiration) && !expiration) /* * next_in_service unchanged or not causing * any change in entity->parent->sd, and no * requeueing needed for expiration: stop * here. */ break; } } /** * bfq_calc_vtime_jump - compute the value to which the vtime should jump, * if needed, to have at least one entity eligible. * @st: the service tree to act upon. * * Assumes that st is not empty. */ static u64 bfq_calc_vtime_jump(struct bfq_service_tree *st) { struct bfq_entity *root_entity = bfq_root_active_entity(&st->active); if (bfq_gt(root_entity->min_start, st->vtime)) return root_entity->min_start; return st->vtime; } static void bfq_update_vtime(struct bfq_service_tree *st, u64 new_value) { if (new_value > st->vtime) { st->vtime = new_value; bfq_forget_idle(st); } } /** * bfq_first_active_entity - find the eligible entity with * the smallest finish time * @st: the service tree to select from. * @vtime: the system virtual to use as a reference for eligibility * * This function searches the first schedulable entity, starting from the * root of the tree and going on the left every time on this side there is * a subtree with at least one eligible (start <= vtime) entity. The path on * the right is followed only if a) the left subtree contains no eligible * entities and b) no eligible entity has been found yet. */ static struct bfq_entity *bfq_first_active_entity(struct bfq_service_tree *st, u64 vtime) { struct bfq_entity *entry, *first = NULL; struct rb_node *node = st->active.rb_node; while (node) { entry = rb_entry(node, struct bfq_entity, rb_node); left: if (!bfq_gt(entry->start, vtime)) first = entry; if (node->rb_left) { entry = rb_entry(node->rb_left, struct bfq_entity, rb_node); if (!bfq_gt(entry->min_start, vtime)) { node = node->rb_left; goto left; } } if (first) break; node = node->rb_right; } return first; } /** * __bfq_lookup_next_entity - return the first eligible entity in @st. * @st: the service tree. * * If there is no in-service entity for the sched_data st belongs to, * then return the entity that will be set in service if: * 1) the parent entity this st belongs to is set in service; * 2) no entity belonging to such parent entity undergoes a state change * that would influence the timestamps of the entity (e.g., becomes idle, * becomes backlogged, changes its budget, ...). * * In this first case, update the virtual time in @st too (see the * comments on this update inside the function). * * In constrast, if there is an in-service entity, then return the * entity that would be set in service if not only the above * conditions, but also the next one held true: the currently * in-service entity, on expiration, * 1) gets a finish time equal to the current one, or * 2) is not eligible any more, or * 3) is idle. */ static struct bfq_entity * __bfq_lookup_next_entity(struct bfq_service_tree *st, bool in_service) { struct bfq_entity *entity; u64 new_vtime; if (RB_EMPTY_ROOT(&st->active)) return NULL; /* * Get the value of the system virtual time for which at * least one entity is eligible. */ new_vtime = bfq_calc_vtime_jump(st); /* * If there is no in-service entity for the sched_data this * active tree belongs to, then push the system virtual time * up to the value that guarantees that at least one entity is * eligible. If, instead, there is an in-service entity, then * do not make any such update, because there is already an * eligible entity, namely the in-service one (even if the * entity is not on st, because it was extracted when set in * service). */ if (!in_service) bfq_update_vtime(st, new_vtime); entity = bfq_first_active_entity(st, new_vtime); return entity; } /** * bfq_lookup_next_entity - return the first eligible entity in @sd. * @sd: the sched_data. * @expiration: true if we are on the expiration path of the in-service queue * * This function is invoked when there has been a change in the trees * for sd, and we need to know what is the new next entity to serve * after this change. */ static struct bfq_entity *bfq_lookup_next_entity(struct bfq_sched_data *sd, bool expiration) { struct bfq_service_tree *st = sd->service_tree; struct bfq_service_tree *idle_class_st = st + (BFQ_IOPRIO_CLASSES - 1); struct bfq_entity *entity = NULL; int class_idx = 0; /* * Choose from idle class, if needed to guarantee a minimum * bandwidth to this class (and if there is some active entity * in idle class). This should also mitigate * priority-inversion problems in case a low priority task is * holding file system resources. */ if (time_is_before_jiffies(sd->bfq_class_idle_last_service + BFQ_CL_IDLE_TIMEOUT)) { if (!RB_EMPTY_ROOT(&idle_class_st->active)) class_idx = BFQ_IOPRIO_CLASSES - 1; /* About to be served if backlogged, or not yet backlogged */ sd->bfq_class_idle_last_service = jiffies; } /* * Find the next entity to serve for the highest-priority * class, unless the idle class needs to be served. */ for (; class_idx < BFQ_IOPRIO_CLASSES; class_idx++) { /* * If expiration is true, then bfq_lookup_next_entity * is being invoked as a part of the expiration path * of the in-service queue. In this case, even if * sd->in_service_entity is not NULL, * sd->in_service_entiy at this point is actually not * in service any more, and, if needed, has already * been properly queued or requeued into the right * tree. The reason why sd->in_service_entity is still * not NULL here, even if expiration is true, is that * sd->in_service_entiy is reset as a last step in the * expiration path. So, if expiration is true, tell * __bfq_lookup_next_entity that there is no * sd->in_service_entity. */ entity = __bfq_lookup_next_entity(st + class_idx, sd->in_service_entity && !expiration); if (entity) break; } if (!entity) return NULL; return entity; } bool next_queue_may_preempt(struct bfq_data *bfqd) { struct bfq_sched_data *sd = &bfqd->root_group->sched_data; return sd->next_in_service != sd->in_service_entity; } /* * Get next queue for service. */ struct bfq_queue *bfq_get_next_queue(struct bfq_data *bfqd) { struct bfq_entity *entity = NULL; struct bfq_sched_data *sd; struct bfq_queue *bfqq; if (bfqd->busy_queues == 0) return NULL; /* * Traverse the path from the root to the leaf entity to * serve. Set in service all the entities visited along the * way. */ sd = &bfqd->root_group->sched_data; for (; sd ; sd = entity->my_sched_data) { /* * WARNING. We are about to set the in-service entity * to sd->next_in_service, i.e., to the (cached) value * returned by bfq_lookup_next_entity(sd) the last * time it was invoked, i.e., the last time when the * service order in sd changed as a consequence of the * activation or deactivation of an entity. In this * respect, if we execute bfq_lookup_next_entity(sd) * in this very moment, it may, although with low * probability, yield a different entity than that * pointed to by sd->next_in_service. This rare event * happens in case there was no CLASS_IDLE entity to * serve for sd when bfq_lookup_next_entity(sd) was * invoked for the last time, while there is now one * such entity. * * If the above event happens, then the scheduling of * such entity in CLASS_IDLE is postponed until the * service of the sd->next_in_service entity * finishes. In fact, when the latter is expired, * bfq_lookup_next_entity(sd) gets called again, * exactly to update sd->next_in_service. */ /* Make next_in_service entity become in_service_entity */ entity = sd->next_in_service; sd->in_service_entity = entity; /* * If entity is no longer a candidate for next * service, then it must be extracted from its active * tree, so as to make sure that it won't be * considered when computing next_in_service. See the * comments on the function * bfq_no_longer_next_in_service() for details. */ if (bfq_no_longer_next_in_service(entity)) bfq_active_extract(bfq_entity_service_tree(entity), entity); /* * Even if entity is not to be extracted according to * the above check, a descendant entity may get * extracted in one of the next iterations of this * loop. Such an event could cause a change in * next_in_service for the level of the descendant * entity, and thus possibly back to this level. * * However, we cannot perform the resulting needed * update of next_in_service for this level before the * end of the whole loop, because, to know which is * the correct next-to-serve candidate entity for each * level, we need first to find the leaf entity to set * in service. In fact, only after we know which is * the next-to-serve leaf entity, we can discover * whether the parent entity of the leaf entity * becomes the next-to-serve, and so on. */ } bfqq = bfq_entity_to_bfqq(entity); /* * We can finally update all next-to-serve entities along the * path from the leaf entity just set in service to the root. */ for_each_entity(entity) { struct bfq_sched_data *sd = entity->sched_data; if (!bfq_update_next_in_service(sd, NULL, false)) break; } return bfqq; } void __bfq_bfqd_reset_in_service(struct bfq_data *bfqd) { struct bfq_queue *in_serv_bfqq = bfqd->in_service_queue; struct bfq_entity *in_serv_entity = &in_serv_bfqq->entity; struct bfq_entity *entity = in_serv_entity; bfq_clear_bfqq_wait_request(in_serv_bfqq); hrtimer_try_to_cancel(&bfqd->idle_slice_timer); bfqd->in_service_queue = NULL; /* * When this function is called, all in-service entities have * been properly deactivated or requeued, so we can safely * execute the final step: reset in_service_entity along the * path from entity to the root. */ for_each_entity(entity) entity->sched_data->in_service_entity = NULL; /* * in_serv_entity is no longer in service, so, if it is in no * service tree either, then release the service reference to * the queue it represents (taken with bfq_get_entity). */ if (!in_serv_entity->on_st) bfq_put_queue(in_serv_bfqq); } void bfq_deactivate_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, bool ins_into_idle_tree, bool expiration) { struct bfq_entity *entity = &bfqq->entity; bfq_deactivate_entity(entity, ins_into_idle_tree, expiration); } void bfq_activate_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq) { struct bfq_entity *entity = &bfqq->entity; bfq_activate_requeue_entity(entity, bfq_bfqq_non_blocking_wait_rq(bfqq), false, false); bfq_clear_bfqq_non_blocking_wait_rq(bfqq); } void bfq_requeue_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, bool expiration) { struct bfq_entity *entity = &bfqq->entity; bfq_activate_requeue_entity(entity, false, bfqq == bfqd->in_service_queue, expiration); } /* * Called when the bfqq no longer has requests pending, remove it from * the service tree. As a special case, it can be invoked during an * expiration. */ void bfq_del_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq, bool expiration) { bfq_log_bfqq(bfqd, bfqq, "del from busy"); bfq_clear_bfqq_busy(bfqq); bfqd->busy_queues--; if (!bfqq->dispatched) bfq_weights_tree_remove(bfqd, bfqq); if (bfqq->wr_coeff > 1) bfqd->wr_busy_queues--; bfqg_stats_update_dequeue(bfqq_group(bfqq)); bfq_deactivate_bfqq(bfqd, bfqq, true, expiration); } /* * Called when an inactive queue receives a new request. */ void bfq_add_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq) { bfq_log_bfqq(bfqd, bfqq, "add to busy"); bfq_activate_bfqq(bfqd, bfqq); bfq_mark_bfqq_busy(bfqq); bfqd->busy_queues++; if (!bfqq->dispatched) if (bfqq->wr_coeff == 1) bfq_weights_tree_add(bfqd, &bfqq->entity, &bfqd->queue_weights_tree); if (bfqq->wr_coeff > 1) bfqd->wr_busy_queues++; }
{ "pile_set_name": "Github" }
create table Users ( Id int primary key autoincrement , Email string(256) unique , Name string(64) ); create table Groups ( Id int primary key autoincrement , Name string(64) unique ); create table UserGroups ( UserId int references Users(Id) , GroupId int references Groups(Id) , primary key(UserId, GroupId) ); create table RecycleItems ( Id int primary key autoincrement , RecycledUtc datetime , RecycledById int references Users(Id) ); create table Folders ( Id int primary key autoincrement -- only the root folder will have ParentId = null , ParentId int null references Folders(Id) , Name string(128) , RecycleItemId int null references RecycleItems(Id) ); create table Files ( Id int primary key autoincrement , ParentId int references Folders(Id) , Name string(128) , Content binary , RecycleItemId int null references RecycleItems(Id) ); create table FolderUserPermissions ( FolderId int references Folders(Id) , UserId int references Users(Id) -- Permissions apply *within* the folder, not *to* it , DeletePermission bool null , CreatePermission bool null , primary key(FolderId, UserId) ); create table FolderGroupPermissions ( FolderId int references Folders(Id) , GroupId int references Groups(Id) -- Permissions apply *within* the folder, not *to* it , DeletePermission bool null , CreatePermission bool null , primary key(FolderId, GroupId) ); create view ActiveFolders as select * from Folders where RecycleItemId is null; create view ActiveFiles as select * from Files where RecycleItemId is null;
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="UTF-8"?> <spirit:design xmlns:xilinx="http://www.xilinx.com" xmlns:spirit="http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <spirit:vendor>xilinx.com</spirit:vendor> <spirit:library>xci</spirit:library> <spirit:name>unknown</spirit:name> <spirit:version>1.0</spirit:version> <spirit:componentInstances> <spirit:componentInstance> <spirit:instanceName>PCIeGen2x8If128</spirit:instanceName> <spirit:componentRef spirit:vendor="xilinx.com" spirit:library="ip" spirit:name="pcie3_7x" spirit:version="4.1"/> <spirit:configurableElementValues> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.ARI_CAP_ENABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.AXISTEN_IF_CC_ALIGNMENT_MODE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.AXISTEN_IF_CQ_ALIGNMENT_MODE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.AXISTEN_IF_ENABLE_CLIENT_TAG">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.AXISTEN_IF_ENABLE_MSG_ROUTE">0x00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.AXISTEN_IF_ENABLE_RX_MSG_INTFC">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.AXISTEN_IF_RC_ALIGNMENT_MODE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.AXISTEN_IF_RC_STRADDLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.AXISTEN_IF_RQ_ALIGNMENT_MODE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.CFG_CTL_IF">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.CFG_EXT_IF">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.CFG_FC_IF">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.CFG_MGMT_IF">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.CFG_STATUS_IF">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.CFG_TX_MSG_IF">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.COMPLETION_SPACE">16KB</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.C_DATA_WIDTH">128</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.DEV_PORT_TYPE">00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.EXT_CH_GT_DRP">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.EXT_PIPE_INTERFACE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.EXT_STARTUP_PRIMITIVE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.MSIX_EN">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.MSI_EN">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PCIE_DRP">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PCIE_EXT_CLK">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PCIE_EXT_GT_COMMON">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PCIE_FAST_CONFIG">NONE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PCIE_LINK_SPEED">3</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PCIE_USE_MODE">2.1</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PER_FUNC_STATUS_IF">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_AER_CAP_ECRC_CHECK_CAPABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_AER_CAP_ECRC_GEN_CAPABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_AER_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_ARI_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_ARI_CAP_NEXT_FUNC">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_BAR0_APERTURE_SIZE">0b00011</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_BAR0_CONTROL">0b100</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_BAR1_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_BAR1_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_BAR2_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_BAR2_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_BAR3_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_BAR3_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_BAR4_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_BAR4_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_BAR5_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_BAR5_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_CAPABILITY_POINTER">0x80</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_CLASS_CODE">0x058000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DEVICE_ID">0x7028</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DEV_CAP2_128B_CAS_ATOMIC_COMPLETER_SUPPORT">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DEV_CAP2_32B_ATOMIC_COMPLETER_SUPPORT">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DEV_CAP2_64B_ATOMIC_COMPLETER_SUPPORT">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DEV_CAP2_LTR_SUPPORT">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DEV_CAP2_OBFF_SUPPORT">00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DEV_CAP2_TPH_COMPLETER_SUPPORT">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DEV_CAP_EXT_TAG_SUPPORTED">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DEV_CAP_FUNCTION_LEVEL_RESET_CAPABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DEV_CAP_MAX_PAYLOAD_SIZE">0b010</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DPA_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DPA_CAP_SUB_STATE_POWER_ALLOCATION0">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DPA_CAP_SUB_STATE_POWER_ALLOCATION1">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DPA_CAP_SUB_STATE_POWER_ALLOCATION2">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DPA_CAP_SUB_STATE_POWER_ALLOCATION3">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DPA_CAP_SUB_STATE_POWER_ALLOCATION4">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DPA_CAP_SUB_STATE_POWER_ALLOCATION5">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DPA_CAP_SUB_STATE_POWER_ALLOCATION6">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DPA_CAP_SUB_STATE_POWER_ALLOCATION7">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_DSN_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_EXPANSION_ROM_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_EXPANSION_ROM_ENABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_INTERRUPT_PIN">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_LINK_CAP_ASPM_SUPPORT">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_LINK_STATUS_SLOT_CLOCK_CONFIG">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_LTR_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_MSIX_CAP_NEXTPTR">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_MSIX_CAP_PBA_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_MSIX_CAP_PBA_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_MSIX_CAP_TABLE_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_MSIX_CAP_TABLE_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_MSIX_CAP_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_MSI_CAP_MULTIMSGCAP">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_MSI_CAP_NEXTPTR">0xC0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_PB_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_PM_CAP_NEXTPTR">0x90</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_PM_CAP_PMESUPPORT_D0">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_PM_CAP_PMESUPPORT_D1">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_PM_CAP_PMESUPPORT_D3HOT">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_PM_CAP_SUPP_D1_STATE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_RBAR_CAP_ENABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_RBAR_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_RBAR_CAP_SIZE0">0x00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_RBAR_CAP_SIZE1">0x00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_RBAR_CAP_SIZE2">0x00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_REVISION_ID">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_BAR0_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_BAR0_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_BAR1_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_BAR1_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_BAR2_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_BAR2_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_BAR3_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_BAR3_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_BAR4_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_BAR4_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_BAR5_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_BAR5_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_CAP_INITIAL_VF">0x0000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_CAP_TOTAL_VF">0x0000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_CAP_VER">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_FIRST_VF_OFFSET">0x0000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_FUNC_DEP_LINK">0x0000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_SUPPORTED_PAGE_SIZE">0x00000553</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SRIOV_VF_DEVICE_ID">0x0000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SUBSYSTEM_ID">0x0007</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_SUBSYSTEM_VENDOR_ID">0x10EE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_TPHR_CAP_DEV_SPECIFIC_MODE">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_TPHR_CAP_ENABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_TPHR_CAP_INT_VEC_MODE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_TPHR_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_TPHR_CAP_ST_MODE_SEL">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_TPHR_CAP_ST_TABLE_LOC">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_TPHR_CAP_ST_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_TPHR_CAP_VER">0x1</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_VC_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF0_VENDOR_ID">0x10EE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_AER_CAP_ECRC_CHECK_CAPABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_AER_CAP_ECRC_GEN_CAPABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_AER_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_ARI_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_BAR0_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_BAR0_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_BAR1_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_BAR1_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_BAR2_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_BAR2_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_BAR3_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_BAR3_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_BAR4_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_BAR4_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_BAR5_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_BAR5_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_CAPABILITY_POINTER">0x80</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_CLASS_CODE">0x058000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_DEVICE_ID">0x7011</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_DEV_CAP_MAX_PAYLOAD_SIZE">0b010</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_DPA_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_DPA_CAP_SUB_STATE_POWER_ALLOCATION0">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_DPA_CAP_SUB_STATE_POWER_ALLOCATION1">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_DPA_CAP_SUB_STATE_POWER_ALLOCATION2">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_DPA_CAP_SUB_STATE_POWER_ALLOCATION3">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_DPA_CAP_SUB_STATE_POWER_ALLOCATION4">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_DPA_CAP_SUB_STATE_POWER_ALLOCATION5">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_DPA_CAP_SUB_STATE_POWER_ALLOCATION6">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_DPA_CAP_SUB_STATE_POWER_ALLOCATION7">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_DSN_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_EXPANSION_ROM_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_EXPANSION_ROM_ENABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_INTERRUPT_PIN">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_MSIX_CAP_NEXTPTR">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_MSIX_CAP_PBA_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_MSIX_CAP_PBA_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_MSIX_CAP_TABLE_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_MSIX_CAP_TABLE_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_MSIX_CAP_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_MSI_CAP_MULTIMSGCAP">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_MSI_CAP_NEXTPTR">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_PB_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_PM_CAP_NEXTPTR">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_RBAR_CAP_ENABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_RBAR_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_RBAR_CAP_SIZE0">0x00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_RBAR_CAP_SIZE1">0x00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_RBAR_CAP_SIZE2">0x00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_REVISION_ID">0x00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_BAR0_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_BAR0_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_BAR1_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_BAR1_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_BAR2_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_BAR2_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_BAR3_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_BAR3_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_BAR4_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_BAR4_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_BAR5_APERTURE_SIZE">0b00000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_BAR5_CONTROL">0b000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_CAP_INITIAL_VF">0x0000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_CAP_TOTAL_VF">0x0000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_CAP_VER">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_FIRST_VF_OFFSET">0x0000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_FUNC_DEP_LINK">0x0001</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_SUPPORTED_PAGE_SIZE">0x00000553</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SRIOV_VF_DEVICE_ID">0x0000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_SUBSYSTEM_ID">0x0007</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_TPHR_CAP_DEV_SPECIFIC_MODE">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_TPHR_CAP_ENABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_TPHR_CAP_INT_VEC_MODE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_TPHR_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_TPHR_CAP_ST_MODE_SEL">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_TPHR_CAP_ST_TABLE_LOC">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_TPHR_CAP_ST_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PF1_TPHR_CAP_VER">0x1</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PIPE_SIM">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PL_LINK_CAP_MAX_LINK_SPEED">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PL_LINK_CAP_MAX_LINK_WIDTH">8</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.PL_UPSTREAM_FACING">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.POWER_DOWN">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.RCV_MSG_IF">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.REF_CLK_FREQ">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.SHARED_LOGIC_IN_CORE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.SPARE_WORD1">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.SRIOV_CAP_ENABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.TL_CREDITS_CD">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.TL_CREDITS_CH">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.TL_CREDITS_NPD">0x028</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.TL_CREDITS_NPH">0x20</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.TL_CREDITS_PD">0x198</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.TL_CREDITS_PH">0x20</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.TL_EXTENDED_CFG_EXTEND_INTERFACE_ENABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.TL_LEGACY_MODE_ENABLE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.TL_PF_ENABLE_REG">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.TRANSCEIVER_CTRL_STATUS_PORTS">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.TX_FC_IF">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.USER_CLK2_FREQ">4</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_ARI_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_CAPABILITY_POINTER">0x80</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_MSIX_CAP_PBA_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_MSIX_CAP_PBA_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_MSIX_CAP_TABLE_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_MSIX_CAP_TABLE_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_MSIX_CAP_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_MSI_CAP_MULTIMSGCAP">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_PM_CAP_NEXTPTR">&quot;00000000&quot;</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_TPHR_CAP_DEV_SPECIFIC_MODE">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_TPHR_CAP_INT_VEC_MODE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_TPHR_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_TPHR_CAP_ST_MODE_SEL">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_TPHR_CAP_ST_TABLE_LOC">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_TPHR_CAP_ST_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF0_TPHR_CAP_VER">0x1</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_ARI_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_MSIX_CAP_PBA_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_MSIX_CAP_PBA_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_MSIX_CAP_TABLE_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_MSIX_CAP_TABLE_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_MSIX_CAP_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_MSI_CAP_MULTIMSGCAP">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_PM_CAP_NEXTPTR">&quot;00000000&quot;</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_TPHR_CAP_DEV_SPECIFIC_MODE">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_TPHR_CAP_INT_VEC_MODE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_TPHR_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_TPHR_CAP_ST_MODE_SEL">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_TPHR_CAP_ST_TABLE_LOC">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_TPHR_CAP_ST_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF1_TPHR_CAP_VER">0x1</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_ARI_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_MSIX_CAP_PBA_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_MSIX_CAP_PBA_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_MSIX_CAP_TABLE_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_MSIX_CAP_TABLE_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_MSIX_CAP_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_MSI_CAP_MULTIMSGCAP">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_PM_CAP_NEXTPTR">&quot;00000000&quot;</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_TPHR_CAP_DEV_SPECIFIC_MODE">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_TPHR_CAP_INT_VEC_MODE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_TPHR_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_TPHR_CAP_ST_MODE_SEL">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_TPHR_CAP_ST_TABLE_LOC">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_TPHR_CAP_ST_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF2_TPHR_CAP_VER">0x1</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_ARI_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_MSIX_CAP_PBA_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_MSIX_CAP_PBA_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_MSIX_CAP_TABLE_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_MSIX_CAP_TABLE_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_MSIX_CAP_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_MSI_CAP_MULTIMSGCAP">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_PM_CAP_NEXTPTR">&quot;00000000&quot;</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_TPHR_CAP_DEV_SPECIFIC_MODE">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_TPHR_CAP_INT_VEC_MODE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_TPHR_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_TPHR_CAP_ST_MODE_SEL">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_TPHR_CAP_ST_TABLE_LOC">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_TPHR_CAP_ST_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF3_TPHR_CAP_VER">0x1</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_ARI_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_MSIX_CAP_PBA_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_MSIX_CAP_PBA_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_MSIX_CAP_TABLE_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_MSIX_CAP_TABLE_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_MSIX_CAP_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_MSI_CAP_MULTIMSGCAP">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_PM_CAP_NEXTPTR">&quot;00000000&quot;</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_TPHR_CAP_DEV_SPECIFIC_MODE">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_TPHR_CAP_INT_VEC_MODE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_TPHR_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_TPHR_CAP_ST_MODE_SEL">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_TPHR_CAP_ST_TABLE_LOC">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_TPHR_CAP_ST_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF4_TPHR_CAP_VER">0x1</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_ARI_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_MSIX_CAP_PBA_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_MSIX_CAP_PBA_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_MSIX_CAP_TABLE_BIR">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_MSIX_CAP_TABLE_OFFSET">0x00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_MSIX_CAP_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_MSI_CAP_MULTIMSGCAP">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_PM_CAP_NEXTPTR">&quot;00000000&quot;</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_TPHR_CAP_DEV_SPECIFIC_MODE">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_TPHR_CAP_INT_VEC_MODE">FALSE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_TPHR_CAP_NEXTPTR">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_TPHR_CAP_ST_MODE_SEL">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_TPHR_CAP_ST_TABLE_LOC">0x0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_TPHR_CAP_ST_TABLE_SIZE">0x000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.VF5_TPHR_CAP_VER">0x1</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.gen_x0y0_ucf">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.gen_x0y1_ucf">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.gen_x0y2_ucf">1</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.gen_x0y3_ucf">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.pcie_blk_locn">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.silicon_revision">Production</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="MODELPARAM_VALUE.xlnx_ref_board">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_ENABLEMENT.xlnx_ref_board">true</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.AXISTEN_IF_RC_STRADDLE">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.Component_Name">PCIeGen2x8If128</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_AER_CAP_ECRC_CHECK_CAPABLE">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_AER_CAP_ECRC_GEN_CAPABLE">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_CLASS_CODE">058000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_DEVICE_ID">7028</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_DEV_CAP2_128B_CAS_ATOMIC_COMPLETER_SUPPORT">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_DEV_CAP2_32B_ATOMIC_COMPLETER_SUPPORT">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_DEV_CAP2_64B_ATOMIC_COMPLETER_SUPPORT">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_DEV_CAP2_OBFF_SUPPORT">00_Not_Supported</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_DEV_CAP2_TPH_COMPLETER_SUPPORT">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_DEV_CAP_FUNCTION_LEVEL_RESET_CAPABLE">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_INTERRUPT_PIN">NONE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_LINK_STATUS_SLOT_CLOCK_CONFIG">true</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_MSIX_CAP_PBA_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_MSIX_CAP_PBA_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_MSIX_CAP_TABLE_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_MSIX_CAP_TABLE_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_MSIX_CAP_TABLE_SIZE">000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_MSI_CAP_MULTIMSGCAP">1_vector</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_PM_CAP_PMESUPPORT_D0">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_PM_CAP_PMESUPPORT_D1">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_PM_CAP_PMESUPPORT_D3HOT">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_PM_CAP_SUPP_D1_STATE">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_REVISION_ID">00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_SRIOV_CAP_INITIAL_VF">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_SRIOV_FIRST_VF_OFFSET">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_SRIOV_FUNC_DEP_LINK">0000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_SRIOV_SUPPORTED_PAGE_SIZE">00000553</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_SRIOV_VF_DEVICE_ID">0000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_SUBSYSTEM_ID">0007</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_SUBSYSTEM_VENDOR_ID">10EE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF0_Use_Class_Code_Lookup_Assistant">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_AER_CAP_ECRC_CHECK_CAPABLE">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_AER_CAP_ECRC_GEN_CAPABLE">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_CLASS_CODE">058000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_DEVICE_ID">7011</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_INTERRUPT_PIN">NONE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_MSIX_CAP_PBA_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_MSIX_CAP_PBA_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_MSIX_CAP_TABLE_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_MSIX_CAP_TABLE_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_MSIX_CAP_TABLE_SIZE">000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_MSI_CAP_MULTIMSGCAP">1_vector</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_REVISION_ID">00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_SRIOV_CAP_INITIAL_VF">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_SRIOV_CAP_VER">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_SRIOV_FIRST_VF_OFFSET">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_SRIOV_FUNC_DEP_LINK">0001</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_SRIOV_SUPPORTED_PAGE_SIZE">00000553</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_SRIOV_VF_DEVICE_ID">0000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_SUBSYSTEM_ID">0007</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PF1_Use_Class_Code_Lookup_Assistant">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PL_LINK_CAP_MAX_LINK_SPEED">5.0_GT/s</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.PL_LINK_CAP_MAX_LINK_WIDTH">X8</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.REF_CLK_FREQ">100_MHz</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.RESET_BOARD_INTERFACE">Custom</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.SRIOV_CAP_ENABLE">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.SRIOV_CAP_ENABLE_EXT">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.TL_PF_ENABLE_REG">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.USE_BOARD_FLOW">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF0_MSIX_CAP_PBA_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF0_MSIX_CAP_PBA_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF0_MSIX_CAP_TABLE_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF0_MSIX_CAP_TABLE_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF0_MSIX_CAP_TABLE_SIZE">000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF0_MSI_CAP_MULTIMSGCAP">1_vector</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF1_MSIX_CAP_PBA_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF1_MSIX_CAP_PBA_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF1_MSIX_CAP_TABLE_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF1_MSIX_CAP_TABLE_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF1_MSIX_CAP_TABLE_SIZE">000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF1_MSI_CAP_MULTIMSGCAP">1_vector</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF2_MSIX_CAP_PBA_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF2_MSIX_CAP_PBA_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF2_MSIX_CAP_TABLE_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF2_MSIX_CAP_TABLE_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF2_MSIX_CAP_TABLE_SIZE">000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF2_MSI_CAP_MULTIMSGCAP">1_vector</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF3_MSIX_CAP_PBA_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF3_MSIX_CAP_PBA_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF3_MSIX_CAP_TABLE_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF3_MSIX_CAP_TABLE_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF3_MSIX_CAP_TABLE_SIZE">000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF3_MSI_CAP_MULTIMSGCAP">1_vector</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF4_MSIX_CAP_PBA_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF4_MSIX_CAP_PBA_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF4_MSIX_CAP_TABLE_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF4_MSIX_CAP_TABLE_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF4_MSIX_CAP_TABLE_SIZE">000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF4_MSI_CAP_MULTIMSGCAP">1_vector</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF5_MSIX_CAP_PBA_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF5_MSIX_CAP_PBA_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF5_MSIX_CAP_TABLE_BIR">BAR_0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF5_MSIX_CAP_TABLE_OFFSET">00000000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF5_MSIX_CAP_TABLE_SIZE">000</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.VF5_MSI_CAP_MULTIMSGCAP">1_vector</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.alignment_mode">DWORD_Aligned</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.aspm_support">No_ASPM</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.axisten_freq">250</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.axisten_if_enable_client_tag">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.axisten_if_enable_msg_route">2FFFF</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.axisten_if_enable_rx_msg_intfc">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.axisten_if_width">128_bit</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.cfg_ctl_if">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.cfg_ext_if">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.cfg_fc_if">true</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.cfg_mgmt_if">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.cfg_status_if">true</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.cfg_tx_msg_if">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.device_port_type">PCI_Express_Endpoint_device</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.en_ext_ch_gt_drp">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.en_ext_clk">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.en_ext_gt_common">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.en_ext_pipe_interface">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.en_ext_startup">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.en_msi_per_vec_masking">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.en_pcie_drp">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.en_powerdown">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.en_transceiver_status_ports">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.ext_pcie_cfg_space_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.extended_tag_field">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.gen_x0y0">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.gen_x0y1">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.gen_x0y2">true</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.gen_x0y3">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.mode_selection">Advanced</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pcie_blk_locn">X0Y2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.per_func_status_if">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.perf_level">Extreme</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.performance">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_aer_enabled">true</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_ari_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar0_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar0_enabled">true</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar0_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar0_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar0_size">1</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar0_type">Memory</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar1_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar1_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar1_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar1_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar1_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar1_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar2_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar2_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar2_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar2_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar2_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar2_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar3_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar3_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar3_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar3_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar3_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar3_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar4_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar4_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar4_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar4_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar4_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar4_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar5_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar5_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar5_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar5_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_bar5_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_base_class_menu">Simple_communication_controllers</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_class_code_base">05</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_class_code_interface">00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_class_code_sub">80</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_dev_cap_max_payload">512_bytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_dpa_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_dsn_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_expansion_rom_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_expansion_rom_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_expansion_rom_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_ltr_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_msi_enabled">true</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_msix_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_pb_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_rbar_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar0_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar0_enabled">true</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar0_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar0_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar0_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar0_type">Memory</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar1_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar1_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar1_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar1_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar1_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar1_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar2_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar2_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar2_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar2_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar2_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar2_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar3_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar3_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar3_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar3_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar3_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar3_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar4_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar4_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar4_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar4_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar4_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar4_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar5_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar5_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar5_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar5_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_bar5_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sriov_cap_ver">0</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_sub_class_interface_menu">Generic_XT_compatible_serial_controller</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_tphr_enable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf0_vc_cap_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_aer_enabled">true</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_ari_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar0_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar0_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar0_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar0_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar0_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar0_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar1_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar1_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar1_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar1_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar1_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar1_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar2_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar2_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar2_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar2_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar2_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar2_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar3_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar3_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar3_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar3_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar3_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar3_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar4_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar4_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar4_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar4_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar4_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar4_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar5_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar5_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar5_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar5_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_bar5_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_base_class_menu">Simple_communication_controllers</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_class_code_base">05</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_class_code_interface">00</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_class_code_sub">80</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_dev_cap_max_payload">512_bytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_dpa_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_dsn_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_expansion_rom_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_expansion_rom_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_expansion_rom_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_msi_enabled">true</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_msix_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_pb_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_rbar_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar0_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar0_enabled">true</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar0_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar0_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar0_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar0_type">Memory</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar1_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar1_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar1_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar1_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar1_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar1_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar2_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar2_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar2_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar2_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar2_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar2_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar3_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar3_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar3_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar3_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar3_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar3_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar4_64bit">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar4_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar4_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar4_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar4_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar4_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar5_enabled">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar5_prefetchable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar5_scale">Kilobytes</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar5_size">2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sriov_bar5_type">N/A</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_sub_class_interface_menu">Generic_XT_compatible_serial_controller</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pf1_tphr_enable">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pipe_mode_sim">None</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.pipe_sim">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.rcv_msg_if">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.shared_logic_in_core">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.silicon_rev">Production</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.tandem_mode">None</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.tl_pf0_enable_reg">true</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.tx_fc_if">false</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.vendor_id">10EE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PARAM_VALUE.xlnx_ref_board">None</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PROJECT_PARAM.ARCHITECTURE">virtex7</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PROJECT_PARAM.BOARD"/> <spirit:configurableElementValue spirit:referenceId="PROJECT_PARAM.DEVICE">xc7vx690t</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PROJECT_PARAM.PACKAGE">ffg1157</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PROJECT_PARAM.PREFHDL">VERILOG</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PROJECT_PARAM.SILICON_REVISION"/> <spirit:configurableElementValue spirit:referenceId="PROJECT_PARAM.SIMULATOR_LANGUAGE">MIXED</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PROJECT_PARAM.SPEEDGRADE">-2</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PROJECT_PARAM.TEMPERATURE_GRADE">C</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PROJECT_PARAM.USE_RDI_CUSTOMIZATION">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="PROJECT_PARAM.USE_RDI_GENERATION">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="RUNTIME_PARAM.IPCONTEXT">IP_Flow</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="RUNTIME_PARAM.IPREVISION">1</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="RUNTIME_PARAM.MANAGED">TRUE</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="RUNTIME_PARAM.OUTPUTDIR">.</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="RUNTIME_PARAM.SELECTEDSIMMODEL"/> <spirit:configurableElementValue spirit:referenceId="RUNTIME_PARAM.SHAREDDIR">.</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="RUNTIME_PARAM.SWVERSION">2015.4</spirit:configurableElementValue> <spirit:configurableElementValue spirit:referenceId="RUNTIME_PARAM.SYNTHESISFLOW">OUT_OF_CONTEXT</spirit:configurableElementValue> </spirit:configurableElementValues> </spirit:componentInstance> </spirit:componentInstances> </spirit:design>
{ "pile_set_name": "Github" }
(* Copyright 2001, 2002, 2003 Maxence Guesdon, b52_simon INRIA *) (* This file is part of mldonkey. mldonkey 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. mldonkey 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 mldonkey; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *) open Printf2 open GtkBase open Gtk type content = | String of string | Pixmap of GDraw.pixmap | Pixtext of string * GDraw.pixmap type line = content list * GDraw.optcolor option type 'a ptree = { data : 'a; mutable children : 'a ptree list } let dummy_line = [], None class virtual ['a] filtered_plist sel_mode titles titles_show get_key = let wscroll = GBin.scrolled_window ~hpolicy: `AUTOMATIC ~vpolicy: `AUTOMATIC () in let (wlist : 'a GList.clist) = GList.clist_poly ~titles_show: titles_show ~titles: titles ~selection_mode: sel_mode ~packing: wscroll#add () in let tooltips = GData.tooltips () in object (self) val mutable items = ([||] : 'a array) val mutable contents = ([||] : line array) val mutable nitems = 0 val mutable current_sort = 0 val mutable selection = ([] : 'a list) val mutable wlist = wlist val mutable filtered = Intmap.empty val mutable nfiltered = 0 val mutable columns_width = ([] : (int * int) list) val mutable first_click_done = false; method box = wscroll#coerce method wlist = wlist method virtual content : 'a -> line method compare = Pervasives.compare method selection = selection method on_select (d:'a) = () method on_deselect (d:'a) = () method on_double_click (d:'a) = () method private sort = Array.fill contents 0 nitems dummy_line; let array = Array.init nitems (fun i -> (items.(i),i)) in Array.sort (fun (v1,n1) (v2,n2) -> let cmp = self#compare v1 v2 in if cmp = 0 then compare n1 n2 else cmp ) array; for i = 0 to nitems - 1 do let item, _ = array.(i) in items.(i) <- item done method set_titles l = wscroll#remove wlist#coerce; let (w : 'a GList.clist) = GList.clist_poly ~titles_show: titles_show ~titles: l ~selection_mode: sel_mode ~packing: wscroll#add () in wlist <- w; self#connect_events method update_row d row = if row >= 0 then begin try let line = self#content d in if line <> contents.(row) then begin contents.(row) <- line; let (l, col_opt) = line in let rec iter n l = match l with [] -> () | (String s) :: q -> wlist#set_cell ~text: s row n; iter (n+1) q | (Pixmap p) :: q -> wlist#set_cell ~pixmap: p row n; iter (n+1) q | (Pixtext (s, p)) :: q -> wlist#set_cell ~text:s ~pixmap:p ~spacing:5 row n; iter (n+1) q in iter 0 l; (* tooltips#set_tip ((wlist:int)#get_row row)#coerce ~text: "Tooltip";*) match col_opt with None -> () | Some c -> wlist#set_row ~foreground: c row; end with e -> lprintf "Exception %s in update_row\n" (Printexc2.to_string e); end else begin lprintf "update_row < 0\n" end method insert ?row d = let r = match row with None -> ignore (wlist#append []) ; wlist#rows - 1 | Some p -> ignore (wlist#insert ~row: p []) ; p in self#update_row d r method update = wlist#freeze (); wlist#clear (); self#sort; selection <- []; for i = 0 to nitems - 1 do self#insert items.(i); done; (* self#wlist#columns_autosize (); *) wlist#thaw () method clear = wlist#clear (); nitems <- 0; items <- [||]; contents <- [||]; filtered <- Intmap.empty; selection <- [] method menu = ([] : GToolbox.menu_entry list) method private connect_events = let check_double_click event d = ( match event with None -> () | Some ev -> let t = GdkEvent.get_type ev in match t with `TWO_BUTTON_PRESS -> self#on_double_click d | _ -> () ) in let f_select_table ~row ~column ~event = try let d = items.(row) in selection <- d :: (List.filter (fun d2 -> d <> d2) selection); self#on_select d; check_double_click event d with Failure _ -> () in let f_unselect_table ~row ~column ~event = try let d = items.(row) in selection <- (List.filter (fun d2 -> d <> d2) selection); self#on_deselect d; check_double_click event d with Failure _ -> () in ignore (wlist#connect#select_row f_select_table); ignore (wlist#connect#unselect_row f_unselect_table); ignore (wlist#connect#click_column (fun c -> if not first_click_done then begin wlist#columns_autosize (); first_click_done <- true end; (* GToolbox.autosize_clist self#wlist; *) self#resort_column c () ) ); (* connect the press on button 3 for contextual menu *) ignore (wlist#event#connect#button_press ~callback: ( fun ev -> GdkEvent.Button.button ev = 3 && GdkEvent.get_type ev = `BUTTON_PRESS && ( GAutoconf.popup_menu ~button: 1 ~time: 0 ~entries: self#menu; true ) ) ); (* connect the press on button 3 for title contextual menu *) for col = 0 to wlist#columns - 1 do let w = wlist#column_widget col in let b = Widget.get_ancestor w#as_widget (Type.from_name "GtkButton") in let button = new GButton.button (Object.unsafe_cast b) in ignore (button#event#connect#button_press ~callback: ( fun ev -> GdkEvent.Button.button ev = 3 && GdkEvent.get_type ev = `BUTTON_PRESS && ( GAutoconf.popup_menu ~button: 1 ~time: 0 ~entries: (self#column_menu col); true ) ) ); (* connect the columns resizing to draw what could need a column width *) ignore (w#misc#connect#size_allocate ~callback: (fun rect -> let width = rect.width in if col < (wlist#columns - 1) then columns_width <- List.append columns_width [(col, width)] else begin columns_width <- List.append columns_width [(col, width)]; self#has_changed_width columns_width; columns_width <- [] end )); done; initializer self#connect_events; self#wlist#columns_autosize () method resort_column i () = let n = i + 1 in if current_sort = n or (- current_sort) = n then current_sort <- (- current_sort) else current_sort <- n; self#update method column_menu i = [ `I ("sort", self#resort_column i); ] method has_changed_width l = () method find key = let rec iter i len = if i = len then (-1, Intmap.find key filtered) else if get_key items.(i) = key then (i, items.(i)) else iter (i+1) len in iter 0 nitems method get_data n = if (n > nitems) || (n < 0) then raise Not_found else items.(n) method get_all_items = let l = ref [] in l := Intmap.to_list filtered; for n = 0 to (nitems - 1) do l := items.(n)::!l done; !l method add_item i = if self#filter i then self#add_filtered_item i else begin let pos = nitems in self#add_hidden_item i; self#insert ~row: pos i; end method size = nitems + nfiltered method private add_hidden_item i = if nitems = Array.length items then begin let nis = nitems * 2 + 8 in let is = Array.make nis i in Array.blit items 0 is 0 nitems; contents <- Array.make nis dummy_line; items <- is end else begin items.(nitems) <- i; contents.(nitems) <- dummy_line; end; nitems <- nitems+1 method private add_filtered_item i = let key = get_key i in filtered <- Intmap.add key i filtered; nfiltered <- nfiltered + 1 method refresh_filter = let filter = self#filter in let add_filtered_item = self#add_filtered_item in let add_hidden_item = self#add_hidden_item in let old_items = Array.sub items 0 nitems in let old_map = filtered in (* freeze & clear reverted to show the user that something appened if it takes too long time *) wlist#clear (); wlist#freeze (); nitems <- 0; filtered <- Intmap.empty; selection <- []; nfiltered <- 0; items <- [||]; contents <- [||]; Array.iter (fun i -> if filter i then add_filtered_item i else add_hidden_item i ) old_items; Intmap.iter (fun _ i -> if filter i then add_filtered_item i else add_hidden_item i ) old_map; self#sort; for i = 0 to nitems - 1 do self#insert items.(i); done; self#wlist#columns_autosize (); wlist#thaw () method reset_data data = let filter = self#filter in let add_filtered_item = self#add_filtered_item in let add_hidden_item = self#add_hidden_item in (* freeze & clear reverted to show the user that something appened if it takes too long time *) wlist#clear (); wlist#freeze (); nitems <- 0; filtered <- Intmap.empty; selection <- []; nfiltered <- 0; items <- [||]; contents <- [||]; List.iter (fun i -> if filter i then add_filtered_item i else add_hidden_item i ) data; self#sort; for i = 0 to nitems - 1 do self#insert items.(i); done; self#wlist#columns_autosize (); wlist#thaw () method virtual filter : 'a -> bool method refresh_item old_pos i = let old_filtered = old_pos < 0 in let new_filtered = self#filter i in match old_filtered, new_filtered with true, false -> filtered <- Intmap.remove (get_key i) filtered; nfiltered <- nfiltered - 1; let pos = nitems in self#add_hidden_item i; self#insert ~row: pos i; | false, true -> Array.blit items (old_pos+1) items old_pos (nitems - old_pos - 1); Array.blit contents (old_pos+1) contents old_pos (nitems - old_pos - 1); nitems <- nitems - 1; items <- Array.sub items 0 nitems; contents <- Array.sub contents 0 nitems; self#wlist#remove old_pos; selection <- List.filter (fun fi -> get_key fi <> get_key i) selection; self#add_filtered_item i | false, _ -> self#update_row i old_pos | _ -> () method remove_item pos i = if pos < 0 then begin filtered <- Intmap.remove (get_key i) filtered; nfiltered <- nfiltered - 1 end else begin self#wlist#remove pos; Array.blit items (pos+1) items pos (nitems - pos - 1); Array.blit contents (pos+1) contents pos (nitems - pos - 1); nitems <- nitems - 1; items <- Array.sub items 0 nitems; contents <- Array.sub contents 0 nitems; selection <- List.filter (fun fi -> get_key fi <> get_key i) selection end method iter (f : 'a -> unit) = for i = 0 to nitems - 1 do f items.(i) done end class virtual ['a] plist sel_mode titles titles_show get_key = object inherit ['a] filtered_plist sel_mode titles titles_show get_key method filter i = false end class virtual ['a] filtered_ptree sel_mode titles titles_show get_key = let wscroll = GBin.scrolled_window ~hpolicy: `AUTOMATIC ~vpolicy: `AUTOMATIC () in let (wlist : 'a GList.clist) = GList.clist_poly ~titles_show: titles_show ~titles: titles ~selection_mode: sel_mode ~packing: wscroll#add () in let tooltips = GData.tooltips () in object (self) constraint 'a = 'b ptree val mutable items = ([||] : 'a array) val mutable contents = ([||] : line array) val mutable nitems = 0 val mutable current_sort = 0 val mutable selection = ([] : 'a list) val mutable wlist = wlist val mutable filtered = Intmap.empty val mutable nfiltered = 0 val mutable columns_width = ([] : (int * int) list) val mutable is_expanded = ([] : (int list * int ) list) method is_expanded = is_expanded method box = wscroll#coerce method wlist = wlist method virtual content : 'a -> line method compare = Pervasives.compare method selection = selection method on_select (d : 'a ) = () method on_deselect (d : 'a ) = () method on_double_click (d : 'a ) = () method private sort = Array.fill contents 0 nitems dummy_line; let depth = let d = ref 0 in for i = 0 to nitems - 1 do let l = List.length (get_key (items.(i))) - 1 in if l > !d then d := l done; !d in let array = Array.init nitems (fun i -> (items.(i),i)) in (* we sort only items belonging to the max depth *) Array.sort (fun (v1,n1) (v2,n2) -> if (List.length (get_key (v1)) - 1) = depth && (List.length (get_key (v2)) - 1) = depth then if depth >= 1 then if List.nth (get_key (v1)) (depth - 1) = List.nth (get_key (v2)) (depth - 1) then begin let cmp = self#compare v1 v2 in if cmp = 0 then compare n1 n2 else cmp end else compare n1 n2 else begin let cmp = self#compare v1 v2 in if cmp = 0 then compare n1 n2 else cmp end else compare n1 n2 ) array; for i = 0 to nitems - 1 do let item, _ = array.(i) in items.(i) <- item done method set_titles l = wscroll#remove wlist#coerce; let (w : 'a GList.clist) = GList.clist_poly ~titles_show: titles_show ~titles: l ~selection_mode: sel_mode ~packing: wscroll#add () in wlist <- w; self#connect_events method update_row d row = if row >= 0 then begin try let line = self#content d in if line <> contents.(row) then begin contents.(row) <- line; let (l, col_opt) = line in let rec iter n l = match l with [] -> () | (String s) :: q -> wlist#set_cell ~text:s row n; iter (n+1) q | (Pixmap p) :: q -> wlist#set_cell ~pixmap:p row n; iter (n+1) q | (Pixtext (s, p)) :: q -> wlist#set_cell ~text:s ~pixmap:p ~spacing:5 row n; iter (n+1) q in iter 0 l; (* tooltips#set_tip ((wlist:int)#get_row row)#coerce ~text: "Tooltip";*) match col_opt with None -> () | Some c -> wlist#set_row ~foreground: c row; end with e -> lprintf "Exception %s in update_row\n" (Printexc2.to_string e); end else begin lprintf "update_row < 0\n" end method insert ?row d = let r = match row with None -> ignore (wlist#append []) ; wlist#rows - 1 | Some p -> ignore (wlist#insert ~row: p []) ; p in self#update_row d r method expand i = if not (List.mem_assoc (get_key i) is_expanded) then begin let (row, _) = self#find (get_key i) in match i.children with [] -> true | l -> begin wlist#freeze (); let array_of_children = ref [||] in List.iter (fun c -> (* we will just not display children that match the filter rules *) if not (self#filter c) then array_of_children := Array.append !array_of_children [|c|] ) l; let length = Array.length !array_of_children in let new_nitems = nitems + length in let new_items = Array.make new_nitems {data = i.data; children = []} in Array.blit items 0 new_items 0 (row + 1); Array.blit !array_of_children 0 new_items (row + 1) length; Array.blit items (row + 1) new_items (row + length + 1) (nitems - row - 1); let new_contents = Array.make new_nitems dummy_line in Array.blit contents 0 new_contents 0 (row + 1); Array.blit contents row new_contents (row + length + 1) (nitems - row - 1); nitems <- new_nitems; items <- new_items; contents <- new_contents; for r = 0 to length - 1 do self#insert ~row:(row + r + 1) items.(row + r + 1) done; is_expanded <- ((get_key i), length)::is_expanded; wlist#thaw (); true end end else true method collapse i = if (List.mem_assoc (get_key i) is_expanded) then begin wlist#freeze (); let (row, _) = self#find (get_key i) in let length = List.assoc (get_key i) is_expanded in let new_nitems = nitems - length in let new_items = Array.make new_nitems {data = i.data; children = []} in Array.blit items 0 new_items 0 (row + 1); Array.blit items (row + length + 1) new_items (row + 1) (nitems - row - length - 1); let new_contents = Array.make new_nitems dummy_line in Array.blit contents 0 new_contents 0 (row + 1); Array.blit contents (row + length + 1) new_contents (row + 1) (nitems - row - length - 1); nitems <- new_nitems; items <- new_items; contents <- new_contents; for r = 0 to (length - 1) do self#wlist#remove (row + 1) done; is_expanded <- List.remove_assoc (get_key i) is_expanded; wlist#thaw (); true end else true method update = wlist#freeze (); wlist#clear (); self#sort; selection <- []; for i = 0 to nitems - 1 do self#insert items.(i); done; (* the autosize function increases tremendeously the time to display the items with pixmaps depending on the column size. So I suppressed it *) (* self#wlist#columns_autosize ();*) wlist#thaw () method clear = wlist#clear (); nitems <- 0; items <- [||]; contents <- [||]; filtered <- Intmap.empty; selection <- [] method menu = ([] : GToolbox.menu_entry list) method private connect_events = let check_double_click event d = ( match event with None -> () | Some ev -> let t = GdkEvent.get_type ev in match t with `TWO_BUTTON_PRESS -> self#on_double_click d | _ -> () ) in let f_select_table ~row ~column ~event = try let d = items.(row) in selection <- d :: (List.filter (fun d2 -> d <> d2) selection); self#on_select d; check_double_click event d with Failure _ -> () in let f_unselect_table ~row ~column ~event = try let d = items.(row) in selection <- (List.filter (fun d2 -> d <> d2) selection); self#on_deselect d; check_double_click event d with Failure _ -> () in ignore (wlist#connect#select_row f_select_table); ignore (wlist#connect#unselect_row f_unselect_table); ignore (wlist#connect#click_column (fun c -> (* GToolbox.autosize_clist self#wlist; *) self#resort_column c () ) ); (* connect the press on button 3 for contextual menu *) ignore (wlist#event#connect#button_press ~callback: ( fun ev -> GdkEvent.Button.button ev = 3 && GdkEvent.get_type ev = `BUTTON_PRESS && ( GAutoconf.popup_menu ~button: 1 ~time: 0 ~entries: self#menu; true ) ) ); (* connect the press on button 3 for title contextual menu *) for col = 0 to wlist#columns - 1 do let w = wlist#column_widget col in let b = Widget.get_ancestor w#as_widget (Type.from_name "GtkButton") in let button = new GButton.button (Object.unsafe_cast b) in ignore (button#event#connect#button_press ~callback: ( fun ev -> GdkEvent.Button.button ev = 3 && GdkEvent.get_type ev = `BUTTON_PRESS && ( GAutoconf.popup_menu ~button: 1 ~time: 0 ~entries: (self#column_menu col); true ) ) ); (* connect the columns resizing to draw what could need a column width *) ignore (w#misc#connect#size_allocate ~callback: (fun rect -> let width = rect.width in if col < (wlist#columns - 1) then columns_width <- List.append columns_width [(col, width)] else begin columns_width <- List.append columns_width [(col, width)]; self#has_changed_width columns_width; columns_width <- [] end )); done; initializer self#connect_events; self#wlist#columns_autosize () method resort_column i () = let n = i + 1 in if current_sort = n or (- current_sort) = n then current_sort <- (- current_sort) else current_sort <- n; self#update method column_menu i = [ `I ("sort", self#resort_column i); ] method has_changed_width l = () method find key = let rec iter i len = if i = len then if (List.length key) = 1 then (-1, Intmap.find (List.hd key) filtered) else raise Not_found else if get_key items.(i) = key then (i, items.(i)) else iter (i+1) len in iter 0 nitems method get_data n = if (n > nitems) || (n < 0) then raise Not_found else items.(n) method get_all_items = let l = ref [] in l := Intmap.to_list filtered; for n = 0 to (nitems - 1) do l := items.(n)::!l done; !l method add_item i = if self#filter i then self#add_filtered_item i else begin let pos = nitems in self#add_hidden_item i; self#insert ~row: pos i; end method size = nitems + nfiltered method private add_hidden_item i = if nitems = Array.length items then begin let nis = nitems * 2 + 8 in let is = Array.make nis i in Array.blit items 0 is 0 nitems; contents <- Array.make nis dummy_line; items <- is end else begin items.(nitems) <- i; contents.(nitems) <- dummy_line; end; nitems <- nitems+1 method private add_filtered_item i = if (List.length (get_key i)) = 1 then begin let key = List.hd (get_key i) in filtered <- Intmap.add key i filtered; nfiltered <- nfiltered + 1 end method refresh_filter = let filter = self#filter in let add_filtered_item = self#add_filtered_item in let add_hidden_item = self#add_hidden_item in let old_items = Array.sub items 0 nitems in let old_map = filtered in (* freeze & clear reverted to show the user that something appened if it takes too long time *) wlist#clear (); wlist#freeze (); nitems <- 0; filtered <- Intmap.empty; selection <- []; nfiltered <- 0; items <- [||]; contents <- [||]; Array.iter (fun i -> if filter i then add_filtered_item i else add_hidden_item i ) old_items; Intmap.iter (fun _ i -> if filter i then add_filtered_item i else add_hidden_item i ) old_map; self#sort; for i = 0 to nitems - 1 do self#insert items.(i) done; self#wlist#columns_autosize (); wlist#thaw () method reset_data data = let filter = self#filter in let add_filtered_item = self#add_filtered_item in let add_hidden_item = self#add_hidden_item in (* freeze & clear reverted to show the user that something appened if it takes too long time *) wlist#clear (); wlist#freeze (); nitems <- 0; filtered <- Intmap.empty; nfiltered <- 0; selection <- []; items <- [||]; contents <- [||]; List.iter (fun i -> if filter i then add_filtered_item i else add_hidden_item i ) data; self#sort; for i = 0 to nitems - 1 do self#insert items.(i) done; self#wlist#columns_autosize (); wlist#thaw () method virtual filter : 'a -> bool method refresh_item old_pos i = let old_filtered = old_pos < 0 in let new_filtered = self#filter i in match old_filtered, new_filtered with true, false -> if (List.length (get_key i)) = 1 then begin let key = List.hd (get_key i) in filtered <- Intmap.remove key filtered; nfiltered <- nfiltered - 1; let pos = nitems in self#add_hidden_item i; self#insert ~row:pos i; end | false, true -> Array.blit items (old_pos+1) items old_pos (nitems - old_pos - 1); Array.blit contents (old_pos+1) contents old_pos (nitems - old_pos - 1); nitems <- nitems - 1; items <- Array.sub items 0 nitems; contents <- Array.sub contents 0 nitems; self#wlist#remove old_pos; selection <- List.filter (fun fi -> get_key fi <> get_key i) selection; if (List.length (get_key i)) = 1 then self#add_filtered_item i | false, _ -> self#update_row i old_pos | _ -> () method remove_item pos i = if pos < 0 then begin if (List.length (get_key i)) = 1 then begin let key = List.hd (get_key i) in filtered <- Intmap.remove key filtered; nfiltered <- nfiltered - 1 end end else begin let b = if (List.mem_assoc (get_key i) is_expanded) then self#collapse i else false in self#wlist#remove pos; Array.blit items (pos+1) items pos (nitems - pos - 1); Array.blit contents (pos+1) contents pos (nitems - pos - 1); nitems <- nitems - 1; items <- Array.sub items 0 nitems; contents <- Array.sub contents 0 nitems; selection <- List.filter (fun fi -> get_key fi <> get_key i) selection end method iter (f : 'a -> unit) = for i = 0 to nitems - 1 do f items.(i) done end
{ "pile_set_name": "Github" }
/* * 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) * * Copyright (c) 2009 Helge Bahmann * Copyright (c) 2012 Tim Blechmann * Copyright (c) 2014 Andrey Semashev */ /*! * \file atomic/detail/ops_msvc_arm.hpp * * This header contains implementation of the \c operations template. */ #ifndef BOOST_ATOMIC_DETAIL_OPS_MSVC_ARM_HPP_INCLUDED_ #define BOOST_ATOMIC_DETAIL_OPS_MSVC_ARM_HPP_INCLUDED_ #include <intrin.h> #include <boost/memory_order.hpp> #include <boost/type_traits/make_signed.hpp> #include <boost/atomic/detail/config.hpp> #include <boost/atomic/detail/interlocked.hpp> #include <boost/atomic/detail/storage_type.hpp> #include <boost/atomic/detail/operations_fwd.hpp> #include <boost/atomic/capabilities.hpp> #include <boost/atomic/detail/ops_msvc_common.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif #define BOOST_ATOMIC_DETAIL_ARM_LOAD8(p) __iso_volatile_load8((const volatile __int8*)(p)) #define BOOST_ATOMIC_DETAIL_ARM_LOAD16(p) __iso_volatile_load16((const volatile __int16*)(p)) #define BOOST_ATOMIC_DETAIL_ARM_LOAD32(p) __iso_volatile_load32((const volatile __int32*)(p)) #define BOOST_ATOMIC_DETAIL_ARM_LOAD64(p) __iso_volatile_load64((const volatile __int64*)(p)) #define BOOST_ATOMIC_DETAIL_ARM_STORE8(p, v) __iso_volatile_store8((volatile __int8*)(p), (__int8)(v)) #define BOOST_ATOMIC_DETAIL_ARM_STORE16(p, v) __iso_volatile_store16((volatile __int16*)(p), (__int16)(v)) #define BOOST_ATOMIC_DETAIL_ARM_STORE32(p, v) __iso_volatile_store32((volatile __int32*)(p), (__int32)(v)) #define BOOST_ATOMIC_DETAIL_ARM_STORE64(p, v) __iso_volatile_store64((volatile __int64*)(p), (__int64)(v)) namespace boost { namespace atomics { namespace detail { // A note about memory_order_consume. Technically, this architecture allows to avoid // unnecessary memory barrier after consume load since it supports data dependency ordering. // However, some compiler optimizations may break a seemingly valid code relying on data // dependency tracking by injecting bogus branches to aid out of order execution. // This may happen not only in Boost.Atomic code but also in user's code, which we have no // control of. See this thread: http://lists.boost.org/Archives/boost/2014/06/213890.php. // For this reason we promote memory_order_consume to memory_order_acquire. struct msvc_arm_operations_base { static BOOST_CONSTEXPR_OR_CONST bool is_always_lock_free = true; static BOOST_FORCEINLINE void hardware_full_fence() BOOST_NOEXCEPT { __dmb(0xB); // _ARM_BARRIER_ISH, see armintr.h from MSVC 11 and later } static BOOST_FORCEINLINE void fence_before_store(memory_order order) BOOST_NOEXCEPT { BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); if ((order & memory_order_release) != 0) hardware_full_fence(); BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); } static BOOST_FORCEINLINE void fence_after_store(memory_order order) BOOST_NOEXCEPT { BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); if (order == memory_order_seq_cst) hardware_full_fence(); BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); } static BOOST_FORCEINLINE void fence_after_load(memory_order order) BOOST_NOEXCEPT { BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); if ((order & (memory_order_consume | memory_order_acquire)) != 0) hardware_full_fence(); BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); } static BOOST_FORCEINLINE BOOST_CONSTEXPR memory_order cas_common_order(memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT { // Combine order flags together and promote memory_order_consume to memory_order_acquire return static_cast< memory_order >(((failure_order | success_order) & ~memory_order_consume) | (((failure_order | success_order) & memory_order_consume) << 1u)); } }; template< typename T, typename Derived > struct msvc_arm_operations : public msvc_arm_operations_base { typedef T storage_type; static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { typedef typename make_signed< storage_type >::type signed_storage_type; return Derived::fetch_add(storage, static_cast< storage_type >(-static_cast< signed_storage_type >(v)), order); } static BOOST_FORCEINLINE bool compare_exchange_weak( storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT { return Derived::compare_exchange_strong(storage, expected, desired, success_order, failure_order); } static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT { return !!Derived::exchange(storage, (storage_type)1, order); } static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT { Derived::store(storage, (storage_type)0, order); } static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT { return true; } }; template< bool Signed > struct operations< 1u, Signed > : public msvc_arm_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > { typedef msvc_arm_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > base_type; typedef typename base_type::storage_type storage_type; typedef typename make_storage_type< 1u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { base_type::fence_before_store(order); BOOST_ATOMIC_DETAIL_ARM_STORE8(&storage, v); base_type::fence_after_store(order); } static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT { storage_type v = BOOST_ATOMIC_DETAIL_ARM_LOAD8(&storage); base_type::fence_after_load(order); return v; } static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD8_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD8_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD8_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD8(&storage, v)); break; } return v; } static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE8_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE8_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE8_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE8(&storage, v)); break; } return v; } static BOOST_FORCEINLINE bool compare_exchange_strong( storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT { storage_type previous = expected, old_val; switch (cas_common_order(success_order, failure_order)) { case memory_order_relaxed: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8_RELAXED(&storage, desired, previous)); break; case memory_order_consume: case memory_order_acquire: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8_ACQUIRE(&storage, desired, previous)); break; case memory_order_release: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8_RELEASE(&storage, desired, previous)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8(&storage, desired, previous)); break; } expected = old_val; return (previous == old_val); } static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND8_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND8_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND8_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND8(&storage, v)); break; } return v; } static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR8_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR8_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR8_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR8(&storage, v)); break; } return v; } static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR8_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR8_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR8_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR8(&storage, v)); break; } return v; } }; template< bool Signed > struct operations< 2u, Signed > : public msvc_arm_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > { typedef msvc_arm_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > base_type; typedef typename base_type::storage_type storage_type; typedef typename make_storage_type< 2u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { base_type::fence_before_store(order); BOOST_ATOMIC_DETAIL_ARM_STORE16(&storage, v); base_type::fence_after_store(order); } static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT { storage_type v = BOOST_ATOMIC_DETAIL_ARM_LOAD16(&storage); base_type::fence_after_load(order); return v; } static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD16_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD16_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD16_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD16(&storage, v)); break; } return v; } static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE16_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE16_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE16_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE16(&storage, v)); break; } return v; } static BOOST_FORCEINLINE bool compare_exchange_strong( storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT { storage_type previous = expected, old_val; switch (cas_common_order(success_order, failure_order)) { case memory_order_relaxed: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16_RELAXED(&storage, desired, previous)); break; case memory_order_consume: case memory_order_acquire: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16_ACQUIRE(&storage, desired, previous)); break; case memory_order_release: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16_RELEASE(&storage, desired, previous)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16(&storage, desired, previous)); break; } expected = old_val; return (previous == old_val); } static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND16_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND16_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND16_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND16(&storage, v)); break; } return v; } static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR16_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR16_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR16_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR16(&storage, v)); break; } return v; } static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR16_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR16_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR16_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR16(&storage, v)); break; } return v; } }; template< bool Signed > struct operations< 4u, Signed > : public msvc_arm_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > { typedef msvc_arm_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > base_type; typedef typename base_type::storage_type storage_type; typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { base_type::fence_before_store(order); BOOST_ATOMIC_DETAIL_ARM_STORE32(&storage, v); base_type::fence_after_store(order); } static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT { storage_type v = BOOST_ATOMIC_DETAIL_ARM_LOAD32(&storage); base_type::fence_after_load(order); return v; } static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD(&storage, v)); break; } return v; } static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE(&storage, v)); break; } return v; } static BOOST_FORCEINLINE bool compare_exchange_strong( storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT { storage_type previous = expected, old_val; switch (cas_common_order(success_order, failure_order)) { case memory_order_relaxed: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_RELAXED(&storage, desired, previous)); break; case memory_order_consume: case memory_order_acquire: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_ACQUIRE(&storage, desired, previous)); break; case memory_order_release: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_RELEASE(&storage, desired, previous)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE(&storage, desired, previous)); break; } expected = old_val; return (previous == old_val); } static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND(&storage, v)); break; } return v; } static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR(&storage, v)); break; } return v; } static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR(&storage, v)); break; } return v; } }; template< bool Signed > struct operations< 8u, Signed > : public msvc_arm_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > > { typedef msvc_arm_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > > base_type; typedef typename base_type::storage_type storage_type; typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { base_type::fence_before_store(order); BOOST_ATOMIC_DETAIL_ARM_STORE64(&storage, v); base_type::fence_after_store(order); } static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT { storage_type v = BOOST_ATOMIC_DETAIL_ARM_LOAD64(&storage); base_type::fence_after_load(order); return v; } static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64(&storage, v)); break; } return v; } static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE64_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE64_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE64_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE64(&storage, v)); break; } return v; } static BOOST_FORCEINLINE bool compare_exchange_strong( storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT { storage_type previous = expected, old_val; switch (cas_common_order(success_order, failure_order)) { case memory_order_relaxed: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64_RELAXED(&storage, desired, previous)); break; case memory_order_consume: case memory_order_acquire: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64_ACQUIRE(&storage, desired, previous)); break; case memory_order_release: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64_RELEASE(&storage, desired, previous)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64(&storage, desired, previous)); break; } expected = old_val; return (previous == old_val); } static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND64_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND64_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND64_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND64(&storage, v)); break; } return v; } static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR64_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR64_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR64_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR64(&storage, v)); break; } return v; } static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { switch (order) { case memory_order_relaxed: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR64_RELAXED(&storage, v)); break; case memory_order_consume: case memory_order_acquire: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR64_ACQUIRE(&storage, v)); break; case memory_order_release: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR64_RELEASE(&storage, v)); break; case memory_order_acq_rel: case memory_order_seq_cst: default: v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR64(&storage, v)); break; } return v; } }; BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT { BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); if (order != memory_order_relaxed) msvc_arm_operations_base::hardware_full_fence(); BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); } BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT { if (order != memory_order_relaxed) BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); } } // namespace detail } // namespace atomics } // namespace boost #undef BOOST_ATOMIC_DETAIL_ARM_LOAD8 #undef BOOST_ATOMIC_DETAIL_ARM_LOAD16 #undef BOOST_ATOMIC_DETAIL_ARM_LOAD32 #undef BOOST_ATOMIC_DETAIL_ARM_LOAD64 #undef BOOST_ATOMIC_DETAIL_ARM_STORE8 #undef BOOST_ATOMIC_DETAIL_ARM_STORE16 #undef BOOST_ATOMIC_DETAIL_ARM_STORE32 #undef BOOST_ATOMIC_DETAIL_ARM_STORE64 #endif // BOOST_ATOMIC_DETAIL_OPS_MSVC_ARM_HPP_INCLUDED_
{ "pile_set_name": "Github" }
// Copyright 2009 the Sputnik authors. All rights reserved. /** * When the [[Construct]] property for a Function object F is called: * A new native ECMAScript object is created. * Gets the value of the [[Prototype]] property of the F(Denote it PROTO_VAL). * If PROTO_VAL is an object, sets the [[Prototype]] property of native ECMAScript object just created * to the PROTO_VAL * * @path ch13/13.2/S13.2.2_A4_T1.js * @description Declaring a function with "function __FACTORY()" */ var __CUBE="cube"; function __FACTORY(){ }; __FACTORY.prototype={ shape:__CUBE, printShape:function(){return this.shape;} }; var __device = new __FACTORY(); ////////////////////////////////////////////////////////////////////////////// //CHECK#1 if (__device.printShape === undefined) { $ERROR('#1: __device.printShape !== undefined. Actual: __device.printShape ==='+__device.printShape); } // ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// //CHECK#2 if (__device.printShape() !== __CUBE) { $ERROR('#2: __device.printShape() === __CUBE. Actual: __device.printShape() ==='+__device.printShape()); } // //////////////////////////////////////////////////////////////////////////////
{ "pile_set_name": "Github" }
#ifndef CAFFE_SOFTMAX_LAYER_HPP_ #define CAFFE_SOFTMAX_LAYER_HPP_ #include <vector> #include "caffe/blob.hpp" #include "caffe/layer.hpp" #include "caffe/proto/caffe.pb.h" namespace caffe { /** * @brief Computes the softmax function. * * TODO(dox): thorough documentation for Forward, Backward, and proto params. */ template <typename Dtype> class SoftmaxLayer : public Layer<Dtype> { public: explicit SoftmaxLayer(const LayerParameter& param) : Layer<Dtype>(param) {} virtual void Reshape(const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top); virtual inline const char* type() const { return "Softmax"; } virtual inline int ExactNumBottomBlobs() const { return 1; } virtual inline int ExactNumTopBlobs() const { return 1; } protected: virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top); virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top); virtual void Backward_cpu(const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom); virtual void Backward_gpu(const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom); int outer_num_; int inner_num_; int softmax_axis_; /// sum_multiplier is used to carry out sum using BLAS Blob<Dtype> sum_multiplier_; /// scale is an intermediate Blob to hold temporary results. Blob<Dtype> scale_; }; } // namespace caffe #endif // CAFFE_SOFTMAX_LAYER_HPP_
{ "pile_set_name": "Github" }
# (c) 2014 David Douard <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License (LGPL) # as published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # for detail see the LICENCE text file. # # FCGear is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with FCGear; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 from PyQt4 import QtGui as qt import fcgear import FreeCAD, FreeCADGui class GearCreationFrame(qt.QFrame): def __init__(self, parent=None): super(GearCreationFrame, self).__init__(parent) self.Z = qt.QSpinBox(value=26) self.m = qt.QDoubleSpinBox(value=2.5) self.angle = qt.QDoubleSpinBox(value=20) self.split = qt.QComboBox() self.split.addItems(['2x3', '1x4']) l = qt.QFormLayout(self) l.setFieldGrowthPolicy(l.ExpandingFieldsGrow) l.addRow('Number of teeth:', self.Z) l.addRow('Modules (mm):', self.m) l.addRow('Pressure angle:', self.angle) l.addRow('Number of curves:', self.split) class GearDialog(qt.QDialog): def __init__(self, parent=None): super(GearDialog, self).__init__(parent) self.gc = GearCreationFrame() btns = qt.QDialogButtonBox.Ok | qt.QDialogButtonBox.Cancel buttonBox = qt.QDialogButtonBox(btns, accepted=self.accept, rejected=self.reject) l = qt.QVBoxLayout(self) l.addWidget(self.gc) l.addWidget(buttonBox) self.setWindowTitle('Gear cration dialog') def accept(self): if FreeCAD.ActiveDocument is None: FreeCAD.newDocument("Gear") gear = fcgear.makeGear(self.gc.m.value(), self.gc.Z.value(), self.gc.angle.value(), not self.gc.split.currentIndex()) FreeCADGui.SendMsgToActiveView("ViewFit") return super(GearDialog, self).accept() if __name__ == '__main__': a = qt.QApplication([]) w = GearDialog() w.show() a.exec_()
{ "pile_set_name": "Github" }
/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * 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. */ package org.jboss.weld.module.web.el; import jakarta.el.ELContext; import jakarta.el.ExpressionFactory; import jakarta.el.MethodExpression; import jakarta.el.ValueExpression; import org.jboss.weld.logging.ElLogger; import org.jboss.weld.module.web.util.el.ForwardingExpressionFactory; /** * @author pmuir */ public class WeldExpressionFactory extends ForwardingExpressionFactory { private final ExpressionFactory delegate; public WeldExpressionFactory(ExpressionFactory expressionFactory) { if (expressionFactory == null) { throw ElLogger.LOG.nullExpressionFactory(); } this.delegate = expressionFactory; } @Override protected ExpressionFactory delegate() { return delegate; } @Override public ValueExpression createValueExpression(ELContext context, String expression, @SuppressWarnings("rawtypes") Class expectedType) { return new WeldValueExpression(super.createValueExpression(context, expression, expectedType)); } @Override public MethodExpression createMethodExpression(ELContext context, String expression, @SuppressWarnings("rawtypes") Class expectedReturnType, @SuppressWarnings("rawtypes") Class[] expectedParamTypes) { return new WeldMethodExpression(super.createMethodExpression(context, expression, expectedReturnType, expectedParamTypes)); } }
{ "pile_set_name": "Github" }
--- title: "Bracketed identifier is missing closing ']'" ms.date: 07/20/2015 f1_keywords: - "bc30034" - "vbc30034" helpviewer_keywords: - "BC30034" ms.assetid: 46f25ddb-0d9f-48f8-8656-1a880ba8a1ba --- # Bracketed identifier is missing closing ']' Brackets in an escaped name must occur in matching pairs. **Error ID:** BC30034 ## To correct this error - Place a closing bracket at the end of the escaped name. ## See also - [Declared Element Names](../programming-guide/language-features/declared-elements/declared-element-names.md)
{ "pile_set_name": "Github" }
import React from 'react'; import { cleanup, fireEvent, waitFor } from '@testing-library/react'; import { renderConnected } from 'test/utils'; import Search from './index'; import { pushNewQuery, initializeIndex } from 'state/search'; global.window = Object.create(window); Object.defineProperty(window, 'location', { value: { href: 'https://localhost/', }, }); Object.defineProperty(window, 'history', { value: { replaceState: jest.fn(), pushState: jest.fn(), }, }); describe('<Search />', () => { let wrapper, store, input, rerender; beforeEach(() => { const utils = renderConnected(<Search />); wrapper = utils.container; store = utils.store; store.dispatch = jest.fn(); input = wrapper.querySelector('input'); rerender = utils.rerenderConnected; }); afterEach(cleanup); it('should render correctly', () => { expect(wrapper.querySelectorAll('input[type="search"]')).toHaveLength(1); expect(wrapper.querySelectorAll('a.btn.icon.icon-search.search-btn')).toHaveLength(1); }); describe('on keyUp event', () => { it('should call dispatch', () => { fireEvent.keyUp(input, { target: { value: 'p'} }); waitFor(() => expect(store.dispatch.mock.calls.length).toBeGreaterThan(0) ); }); }); describe('when entering a keyphrase from non-main search', () => { it('should redirect to search', () => { fireEvent.keyPress(input, { charCode: 13 }); expect(window.location.href.indexOf('/search/')).not.toBe(-1); }); }); describe('when clicked and isMainSearch', () => { it('should push the state to history', () => { store.dispatch(initializeIndex([])); store.dispatch(pushNewQuery('tes')); wrapper = rerender(<Search isMainSearch />).container; input = wrapper.querySelector('input'); fireEvent.keyUp(input, { target: { value: 'test'} }); expect(window.history.pushState.mock.calls.length).toBeGreaterThan(0); }); }); });
{ "pile_set_name": "Github" }
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // serializer_map.cpp: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . // 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) // See http://www.boost.org for updates, documentation, and revision history. #if (defined _MSC_VER) && (_MSC_VER == 1200) # pragma warning (disable : 4786) // too long name, harmless warning #endif #include <set> #include <utility> #define BOOST_ARCHIVE_SOURCE // include this to prevent linker errors when the // same modules are marked export and import. #define BOOST_SERIALIZATION_SOURCE #include <boost/archive/archive_exception.hpp> #include <boost/serialization/throw_exception.hpp> #include <boost/archive/detail/basic_serializer.hpp> #include <boost/archive/detail/basic_serializer_map.hpp> namespace boost { namespace serialization { class extended_type_info; } namespace archive { namespace detail { bool basic_serializer_map::type_info_pointer_compare::operator()( const basic_serializer * lhs, const basic_serializer * rhs ) const { return *lhs < *rhs; } BOOST_ARCHIVE_DECL(bool) basic_serializer_map::insert(const basic_serializer * bs){ // attempt to insert serializer into it's map const std::pair<map_type::iterator, bool> result = m_map.insert(bs); // the following is commented out - rather than being just // deleted as a reminder not to try this. // At first it seemed like a good idea. It enforced the // idea that a type be exported from at most one code module // (DLL or mainline). This would enforce a "one definition rule" // across code modules. This seems a good idea to me. // But it seems that it's just too hard for many users to implement. // Ideally, I would like to make this exception a warning - // but there isn't anyway to do that. // if this fails, it's because it's been instantiated // in multiple modules - DLLS - a recipe for problems. // So trap this here // if(!result.second){ // boost::serialization::throw_exception( // archive_exception( // archive_exception::multiple_code_instantiation, // bs->get_debug_info() // ) // ); // } return true; } BOOST_ARCHIVE_DECL(void) basic_serializer_map::erase(const basic_serializer * bs){ map_type::iterator it = m_map.begin(); map_type::iterator it_end = m_map.end(); while(it != it_end){ // note item 9 from Effective STL !!! it++ if(*it == bs) m_map.erase(it++); else it++; } // note: we can't do this since some of the eti records // we're pointing to might be expired and the comparison // won't work. Leave this as a reminder not to "optimize" this. //it = m_map.find(bs); //assert(it != m_map.end()); //if(*it == bs) // m_map.erase(it); } BOOST_ARCHIVE_DECL(const basic_serializer *) basic_serializer_map::find( const boost::serialization::extended_type_info & eti ) const { const basic_serializer_arg bs(eti); map_type::const_iterator it; it = m_map.find(& bs); if(it == m_map.end()){ BOOST_ASSERT(false); return 0; } return *it; } } // namespace detail } // namespace archive } // namespace boost
{ "pile_set_name": "Github" }
/* * Skin: Red * --------- */ .skin-red .main-header .navbar { background-color: #dd4b39; } .skin-red .main-header .navbar .nav > li > a { color: #ffffff; } .skin-red .main-header .navbar .nav > li > a:hover, .skin-red .main-header .navbar .nav > li > a:active, .skin-red .main-header .navbar .nav > li > a:focus, .skin-red .main-header .navbar .nav .open > a, .skin-red .main-header .navbar .nav .open > a:hover, .skin-red .main-header .navbar .nav .open > a:focus, .skin-red .main-header .navbar .nav > .active > a { background: rgba(0, 0, 0, 0.1); color: #f6f6f6; } .skin-red .main-header .navbar .sidebar-toggle { color: #ffffff; } .skin-red .main-header .navbar .sidebar-toggle:hover { color: #f6f6f6; background: rgba(0, 0, 0, 0.1); } .skin-red .main-header .navbar .sidebar-toggle { color: #fff; } .skin-red .main-header .navbar .sidebar-toggle:hover { background-color: #d73925; } @media (max-width: 767px) { .skin-red .main-header .navbar .dropdown-menu li.divider { background-color: rgba(255, 255, 255, 0.1); } .skin-red .main-header .navbar .dropdown-menu li a { color: #fff; } .skin-red .main-header .navbar .dropdown-menu li a:hover { background: #d73925; } } .skin-red .main-header .logo { background-color: #d73925; color: #ffffff; border-bottom: 0 solid transparent; } .skin-red .main-header .logo:hover { background-color: #d33724; } .skin-red .main-header li.user-header { background-color: #dd4b39; } .skin-red .content-header { background: transparent; } .skin-red .wrapper, .skin-red .main-sidebar, .skin-red .left-side { background-color: #222d32; } .skin-red .user-panel > .info, .skin-red .user-panel > .info > a { color: #fff; } .skin-red .sidebar-menu > li.header { color: #4b646f; background: #1a2226; } .skin-red .sidebar-menu > li > a { border-left: 3px solid transparent; } .skin-red .sidebar-menu > li:hover > a, .skin-red .sidebar-menu > li.active > a, .skin-red .sidebar-menu > li.menu-open > a { color: #ffffff; background: #1e282c; } .skin-red .sidebar-menu > li.active > a { border-left-color: #dd4b39; } .skin-red .sidebar-menu > li > .treeview-menu { margin: 0 1px; background: #2c3b41; } .skin-red .sidebar a { color: #b8c7ce; } .skin-red .sidebar a:hover { text-decoration: none; } .skin-red .sidebar-menu .treeview-menu > li > a { color: #8aa4af; } .skin-red .sidebar-menu .treeview-menu > li.active > a, .skin-red .sidebar-menu .treeview-menu > li > a:hover { color: #ffffff; } .skin-red .sidebar-form { border-radius: 3px; border: 1px solid #374850; margin: 10px 10px; } .skin-red .sidebar-form input[type="text"], .skin-red .sidebar-form .btn { box-shadow: none; background-color: #374850; border: 1px solid transparent; height: 35px; } .skin-red .sidebar-form input[type="text"] { color: #666; border-top-left-radius: 2px; border-top-right-radius: 0; border-bottom-right-radius: 0; border-bottom-left-radius: 2px; } .skin-red .sidebar-form input[type="text"]:focus, .skin-red .sidebar-form input[type="text"]:focus + .input-group-btn .btn { background-color: #fff; color: #666; } .skin-red .sidebar-form input[type="text"]:focus + .input-group-btn .btn { border-left-color: #fff; } .skin-red .sidebar-form .btn { color: #999; border-top-left-radius: 0; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 0; }
{ "pile_set_name": "Github" }
/*------------------------------------------------------------------------- * * spell.h * * Declarations for ISpell dictionary * * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group * * src/include/tsearch/dicts/spell.h * *------------------------------------------------------------------------- */ #ifndef __SPELL_H__ #define __SPELL_H__ #include "regex/regex.h" #include "tsearch/dicts/regis.h" #include "tsearch/ts_public.h" /* * SPNode and SPNodeData are used to represent prefix tree (Trie) to store * a words list. */ struct SPNode; typedef struct { uint32 val:8, isword:1, /* Stores compound flags listed below */ compoundflag:4, /* Reference to an entry of the AffixData field */ affix:19; struct SPNode *node; } SPNodeData; /* * Names of FF_ are correlated with Hunspell options in affix file * http://hunspell.sourceforge.net/ */ #define FF_COMPOUNDONLY 0x01 #define FF_COMPOUNDBEGIN 0x02 #define FF_COMPOUNDMIDDLE 0x04 #define FF_COMPOUNDLAST 0x08 #define FF_COMPOUNDFLAG ( FF_COMPOUNDBEGIN | FF_COMPOUNDMIDDLE | \ FF_COMPOUNDLAST ) #define FF_COMPOUNDFLAGMASK 0x0f typedef struct SPNode { uint32 length; SPNodeData data[FLEXIBLE_ARRAY_MEMBER]; } SPNode; #define SPNHDRSZ (offsetof(SPNode,data)) /* * Represents an entry in a words list. */ typedef struct spell_struct { union { /* * flag is filled in by NIImportDictionary(). After * NISortDictionary(), d is used instead of flag. */ char *flag; /* d is used in mkSPNode() */ struct { /* Reference to an entry of the AffixData field */ int affix; /* Length of the word */ int len; } d; } p; char word[FLEXIBLE_ARRAY_MEMBER]; } SPELL; #define SPELLHDRSZ (offsetof(SPELL, word)) /* * Represents an entry in an affix list. */ typedef struct aff_struct { char *flag; /* FF_SUFFIX or FF_PREFIX */ uint32 type:1, flagflags:7, issimple:1, isregis:1, replen:14; char *find; char *repl; union { regex_t regex; Regis regis; } reg; } AFFIX; /* * affixes use dictionary flags too */ #define FF_COMPOUNDPERMITFLAG 0x10 #define FF_COMPOUNDFORBIDFLAG 0x20 #define FF_CROSSPRODUCT 0x40 /* * Don't change the order of these. Initialization sorts by these, * and expects prefixes to come first after sorting. */ #define FF_SUFFIX 1 #define FF_PREFIX 0 /* * AffixNode and AffixNodeData are used to represent prefix tree (Trie) to store * an affix list. */ struct AffixNode; typedef struct { uint32 val:8, naff:24; AFFIX **aff; struct AffixNode *node; } AffixNodeData; typedef struct AffixNode { uint32 isvoid:1, length:31; AffixNodeData data[FLEXIBLE_ARRAY_MEMBER]; } AffixNode; #define ANHRDSZ (offsetof(AffixNode, data)) typedef struct { char *affix; int len; bool issuffix; } CMPDAffix; /* * Type of encoding affix flags in Hunspell dictionaries */ typedef enum { FM_CHAR, /* one character (like ispell) */ FM_LONG, /* two characters */ FM_NUM /* number, >= 0 and < 65536 */ } FlagMode; /* * Structure to store Hunspell options. Flag representation depends on flag * type. These flags are about support of compound words. */ typedef struct CompoundAffixFlag { union { /* Flag name if flagMode is FM_CHAR or FM_LONG */ char *s; /* Flag name if flagMode is FM_NUM */ uint32 i; } flag; /* we don't have a bsearch_arg version, so, copy FlagMode */ FlagMode flagMode; uint32 value; } CompoundAffixFlag; #define FLAGNUM_MAXSIZE (1 << 16) typedef struct { int maffixes; int naffixes; AFFIX *Affix; AffixNode *Suffix; AffixNode *Prefix; SPNode *Dictionary; /* Array of sets of affixes */ char **AffixData; int lenAffixData; int nAffixData; bool useFlagAliases; CMPDAffix *CompoundAffix; bool usecompound; FlagMode flagMode; /* * All follow fields are actually needed only for initialization */ /* Array of Hunspell options in affix file */ CompoundAffixFlag *CompoundAffixFlags; /* number of entries in CompoundAffixFlags array */ int nCompoundAffixFlag; /* allocated length of CompoundAffixFlags array */ int mCompoundAffixFlag; /* * Remaining fields are only used during dictionary construction; they are * set up by NIStartBuild and cleared by NIFinishBuild. */ MemoryContext buildCxt; /* temp context for construction */ /* Temporary array of all words in the dict file */ SPELL **Spell; int nspell; /* number of valid entries in Spell array */ int mspell; /* allocated length of Spell array */ /* These are used to allocate "compact" data without palloc overhead */ char *firstfree; /* first free address (always maxaligned) */ size_t avail; /* free space remaining at firstfree */ } IspellDict; extern TSLexeme *NINormalizeWord(IspellDict *Conf, char *word); extern void NIStartBuild(IspellDict *Conf); extern void NIImportAffixes(IspellDict *Conf, const char *filename); extern void NIImportDictionary(IspellDict *Conf, const char *filename); extern void NISortDictionary(IspellDict *Conf); extern void NISortAffixes(IspellDict *Conf); extern void NIFinishBuild(IspellDict *Conf); #endif
{ "pile_set_name": "Github" }
function WPATH(s) { var index = s.lastIndexOf("/"); var path = -1 === index ? "starrating/" + s : s.substring(0, index) + "/starrating/" + s.substring(index + 1); return path; } function __processArg(obj, key) { var arg = null; if (obj) { arg = obj[key] || null; delete obj[key]; } return arg; } function Controller() { new (require("alloy/widget"))("starrating"); this.__widgetId = "starrating"; require("alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments)); this.__controllerPath = "widget"; this.args = arguments[0] || {}; if (arguments[0]) { __processArg(arguments[0], "__parentSymbol"); __processArg(arguments[0], "$model"); __processArg(arguments[0], "__itemTemplate"); } var $ = this; var exports = {}; $.__views.starrating = Ti.UI.createView({ layout: "horizontal", width: Ti.UI.SIZE, backgroundColor: "transparent", id: "starrating" }); $.__views.starrating && $.addTopLevelView($.__views.starrating); exports.destroy = function() {}; _.extend($, $.__views); var args = arguments[0] || {}, stars = [], rating = 0, max = 5; var setRating = function(newRating) { newRating > max && (newRating = max); rating = newRating; for (var i = 0, l = stars.length; l > i; i++) stars[i].image = WPATH(i >= rating ? "star_off.png" : rating > i && i + 1 > rating ? "star_half.png" : "star.png"); }; exports.setRating = setRating; exports.getRating = function() { return rating; }; var createStars = function(num, cb) { for (var i = 0; num > i; i++) { var star = Alloy.createWidget("starrating", "star").getView(); !function() { var index = i; star.addEventListener("click", function() { setRating(index + 1); cb(index + 1); }); }(); stars.push(star); $.starrating.add(star); } }; exports.init = function(callback) { var max = args.max || 5, initialRating = args.initialRating || 0, cb = callback || function() {}; createStars(max, cb); setRating(initialRating); _.extend($.starrating, args); }; _.extend($, exports); } var Alloy = require("alloy"), Backbone = Alloy.Backbone, _ = Alloy._; module.exports = Controller;
{ "pile_set_name": "Github" }
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team // // Permission is hereby granted, free of charge, to any person obtaining a copy of this // software and associated documentation files (the "Software"), to deal in the Software // without restriction, including without limitation the rights to use, copy, modify, merge, // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons // to whom the Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all copies or // substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. using System; using System.Collections.Generic; using ICSharpCode.NRefactory.Semantics; using ICSharpCode.NRefactory.Utils; namespace ICSharpCode.NRefactory.TypeSystem.Implementation { /// <summary> /// Default implementation of <see cref="IUnresolvedAttribute"/>. /// </summary> [Serializable] public sealed class DefaultUnresolvedAttribute : AbstractFreezable, IUnresolvedAttribute, IFreezable, ISupportsInterning { ITypeReference attributeType; DomRegion region; IList<ITypeReference> constructorParameterTypes; IList<IConstantValue> positionalArguments; IList<KeyValuePair<IMemberReference, IConstantValue>> namedArguments; public DefaultUnresolvedAttribute(ITypeReference attributeType) { if (attributeType == null) throw new ArgumentNullException("attributeType"); this.attributeType = attributeType; } public DefaultUnresolvedAttribute(ITypeReference attributeType, IEnumerable<ITypeReference> constructorParameterTypes) { if (attributeType == null) throw new ArgumentNullException("attributeType"); this.attributeType = attributeType; this.ConstructorParameterTypes.AddRange(constructorParameterTypes); } protected override void FreezeInternal() { base.FreezeInternal(); constructorParameterTypes = FreezableHelper.FreezeList(constructorParameterTypes); positionalArguments = FreezableHelper.FreezeListAndElements(positionalArguments); namedArguments = FreezableHelper.FreezeList(namedArguments); foreach (var pair in namedArguments) { FreezableHelper.Freeze(pair.Key); FreezableHelper.Freeze(pair.Value); } } public ITypeReference AttributeType { get { return attributeType; } } public DomRegion Region { get { return region; } set { FreezableHelper.ThrowIfFrozen(this); region = value; } } public IList<ITypeReference> ConstructorParameterTypes { get { if (constructorParameterTypes == null) constructorParameterTypes = new List<ITypeReference>(); return constructorParameterTypes; } } public IList<IConstantValue> PositionalArguments { get { if (positionalArguments == null) positionalArguments = new List<IConstantValue>(); return positionalArguments; } } public IList<KeyValuePair<IMemberReference, IConstantValue>> NamedArguments { get { if (namedArguments == null) namedArguments = new List<KeyValuePair<IMemberReference, IConstantValue>>(); return namedArguments; } } public void AddNamedFieldArgument(string fieldName, IConstantValue value) { this.NamedArguments.Add(new KeyValuePair<IMemberReference, IConstantValue>( new DefaultMemberReference(EntityType.Field, attributeType, fieldName), value )); } public void AddNamedFieldArgument(string fieldName, ITypeReference valueType, object value) { AddNamedFieldArgument(fieldName, new SimpleConstantValue(valueType, value)); } public void AddNamedPropertyArgument(string propertyName, IConstantValue value) { this.NamedArguments.Add(new KeyValuePair<IMemberReference, IConstantValue>( new DefaultMemberReference(EntityType.Property, attributeType, propertyName), value )); } public void AddNamedPropertyArgument(string propertyName, ITypeReference valueType, object value) { AddNamedPropertyArgument(propertyName, new SimpleConstantValue(valueType, value)); } public IAttribute CreateResolvedAttribute(ITypeResolveContext context) { return new DefaultResolvedAttribute(this, context); } void ISupportsInterning.PrepareForInterning(IInterningProvider provider) { if (!this.IsFrozen) { attributeType = provider.Intern(attributeType); constructorParameterTypes = provider.InternList(constructorParameterTypes); positionalArguments = provider.InternList(positionalArguments); if (namedArguments != null) { for (int i = 0; i < namedArguments.Count; i++) { namedArguments[i] = new KeyValuePair<IMemberReference, IConstantValue>( provider.Intern(namedArguments[i].Key), provider.Intern(namedArguments[i].Value) ); } } Freeze(); } } int ISupportsInterning.GetHashCodeForInterning() { int hash = attributeType.GetHashCode() ^ constructorParameterTypes.GetHashCode() ^ positionalArguments.GetHashCode(); if (namedArguments != null) { foreach (var pair in namedArguments) { unchecked { hash *= 71; hash += pair.Key.GetHashCode() + pair.Value.GetHashCode() * 73; } } } return hash; } bool ISupportsInterning.EqualsForInterning(ISupportsInterning other) { DefaultUnresolvedAttribute o = other as DefaultUnresolvedAttribute; return o != null && attributeType == o.attributeType && constructorParameterTypes == o.constructorParameterTypes && positionalArguments == o.positionalArguments && ListEquals(namedArguments ?? EmptyList<KeyValuePair<IMemberReference, IConstantValue>>.Instance, o.namedArguments ?? EmptyList<KeyValuePair<IMemberReference, IConstantValue>>.Instance); } static bool ListEquals(IList<KeyValuePair<IMemberReference, IConstantValue>> list1, IList<KeyValuePair<IMemberReference, IConstantValue>> list2) { if (list1.Count != list2.Count) return false; for (int i = 0; i < list1.Count; i++) { var a = list1[i]; var b = list2[i]; if (!(a.Key == b.Key && a.Value == b.Value)) return false; } return true; } sealed class DefaultResolvedAttribute : IAttribute, IResolved { readonly DefaultUnresolvedAttribute unresolved; readonly ITypeResolveContext context; readonly IType attributeType; readonly IList<ResolveResult> positionalArguments; // cannot use ProjectedList because KeyValuePair is value type IList<KeyValuePair<IMember, ResolveResult>> namedArguments; IMethod constructor; volatile bool constructorResolved; public DefaultResolvedAttribute(DefaultUnresolvedAttribute unresolved, ITypeResolveContext context) { this.unresolved = unresolved; this.context = context; this.attributeType = unresolved.AttributeType.Resolve(context); this.positionalArguments = unresolved.PositionalArguments.Resolve(context); } public IType AttributeType { get { return attributeType; } } public DomRegion Region { get { return unresolved.Region; } } public IMethod Constructor { get { if (!constructorResolved) { constructor = ResolveConstructor(); constructorResolved = true; } return constructor; } } IMethod ResolveConstructor() { var parameterTypes = unresolved.ConstructorParameterTypes.Resolve(context); foreach (var ctor in attributeType.GetConstructors(m => m.Parameters.Count == parameterTypes.Count)) { bool ok = true; for (int i = 0; i < parameterTypes.Count; i++) { if (!ctor.Parameters[i].Type.Equals(parameterTypes[i])) { ok = false; break; } } if (ok) return ctor; } return null; } public IList<ResolveResult> PositionalArguments { get { return positionalArguments; } } public IList<KeyValuePair<IMember, ResolveResult>> NamedArguments { get { var namedArgs = LazyInit.VolatileRead(ref this.namedArguments); if (namedArgs != null) { return namedArgs; } else { namedArgs = new List<KeyValuePair<IMember, ResolveResult>>(); foreach (var pair in unresolved.NamedArguments) { IMember member = pair.Key.Resolve(context); if (member != null) { ResolveResult val = pair.Value.Resolve(context); namedArgs.Add(new KeyValuePair<IMember, ResolveResult>(member, val)); } } return LazyInit.GetOrSet(ref this.namedArguments, namedArgs); } } } public ICompilation Compilation { get { return context.Compilation; } } public override string ToString() { if (positionalArguments.Count == 0) return "[" + attributeType.ToString() + "]"; else return "[" + attributeType.ToString() + "(...)]"; } } } }
{ "pile_set_name": "Github" }
<?php defined('IN_TS') or die('Access Denied.'); //统计代码 function gobad($w){ global $tsMySqlCache; $code = fileRead('data/plugins_pubs_gobad.php'); if($code==''){ $code = $tsMySqlCache->get('plugins_pubs_gobad'); } echo stripslashes($code[$w]); } addAction('gobad','gobad');
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- ~ /* ~ * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com) ~ * ~ * 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. ~ * ~ * For more information: http://www.orientechnologies.com ~ */ --> <orient-server> <handlers> <handler class="com.orientechnologies.orient.graph.handler.OGraphServerHandler"> <parameters> <parameter name="enabled" value="true"/> <parameter name="graph.pool.max" value="50"/> </parameters> </handler> <!-- CLUSTER PLUGIN, TO TURN ON SET THE 'ENABLED' PARAMETER TO 'true' --> <handler class="com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin"> <parameters> <!-- <parameter name="nodeName" value="europe1" /> --> <parameter name="enabled" value="${distributed}"/> <parameter name="configuration.db.default" value="${ORIENTDB_HOME}/config/default-distributed-db-config.json"/> <parameter name="configuration.hazelcast" value="${ORIENTDB_HOME}/config/hazelcast.xml"/> <parameter name="conflict.resolver.impl" value="com.orientechnologies.orient.server.distributed.conflict.ODefaultReplicationConflictResolver"/> </parameters> </handler> <!-- JMX SERVER, TO TURN ON SET THE 'ENABLED' PARAMETER TO 'true' --> <handler class="com.orientechnologies.orient.server.handler.OJMXPlugin"> <parameters> <parameter name="enabled" value="false"/> <parameter name="profilerManaged" value="true"/> </parameters> </handler> <!-- AUTOMATIC BACKUP, TO TURN ON SET THE 'ENABLED' PARAMETER TO 'true' --> <handler class="com.orientechnologies.orient.server.handler.OAutomaticBackup"> <parameters> <parameter name="enabled" value="false"/> <parameter name="delay" value="4h"/> <parameter name="target.directory" value="backup"/> <parameter name="target.fileName" value="${DBNAME}-${DATE:yyyyMMddHHmmss}.zip"/> <parameter name="compressionLevel" value="9"/> <parameter name="bufferSize" value="1048576"/> <!--${DBNAME} AND ${DATE:} VARIABLES ARE SUPPORTED --> <parameter name="db.include" value=""/> <!-- DEFAULT: NO ONE, THAT MEANS ALL DATABASES. USE COMMA TO SEPARATE MULTIPLE DATABASE NAMES --> <parameter name="db.exclude" value=""/> <!-- USE COMMA TO SEPARATE MULTIPLE DATABASE NAMES --> </parameters> </handler> <!-- SERVER SIDE SCRIPT INTERPRETER. WARNING! THIS CAN BE A SECURITY HOLE: ENABLE IT ONLY IF CLIENTS ARE TRUCT, TO TURN ON SET THE 'ENABLED' PARAMETER TO 'true' --> <handler class="com.orientechnologies.orient.server.handler.OServerSideScriptInterpreter"> <parameters> <parameter name="enabled" value="true"/> <parameter name="allowedLanguages" value="SQL"/> </parameters> </handler> <!-- USE SESSION TOKEN, TO TURN ON SET THE 'ENABLED' PARAMETER TO 'true' --> <handler class="com.orientechnologies.orient.server.token.OrientTokenHandler"> <parameters> <parameter name="enabled" value="true"/> <!-- PRIVATE KEY --> <parameter name="oAuth2Key" value="a_little_pass"/> <!-- SESSION LENGTH IN MINUTES, DEFAULT=1 HOUR --> <parameter name="sessionLength" value="60"/> <!-- ENCRYPTION ALGORITHM, DEFAULT=HmacSHA256 --> <parameter name="encryptionAlgorithm" value="HmacSHA256"/> </parameters> </handler> </handlers> <network> <sockets> <socket implementation="com.orientechnologies.orient.server.network.OServerSSLSocketFactory" name="ssl"> <parameters> <parameter value="false" name="network.ssl.clientAuth"/> <parameter value="config/cert/orientdb.ks" name="network.ssl.keyStore"/> <parameter value="password" name="network.ssl.keyStorePassword"/> <parameter value="config/cert/orientdb.ks" name="network.ssl.trustStore"/> <parameter value="password" name="network.ssl.trustStorePassword"/> </parameters> </socket> <socket implementation="com.orientechnologies.orient.server.network.OServerSSLSocketFactory" name="https"> <parameters> <parameter value="false" name="network.ssl.clientAuth"/> <parameter value="config/cert/orientdb.ks" name="network.ssl.keyStore"/> <parameter value="password" name="network.ssl.keyStorePassword"/> <parameter value="config/cert/orientdb.ks" name="network.ssl.trustStore"/> <parameter value="password" name="network.ssl.trustStorePassword"/> </parameters> </socket> </sockets> <protocols> <!-- Default registered protocol. It reads commands using the HTTP protocol and write data locally --> <protocol name="binary" implementation="com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary"/> <protocol name="http" implementation="com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpDb"/> </protocols> <listeners> <listener protocol="binary" socket="default" port-range="2424-2430" ip-address="0.0.0.0"> <parameters> <parameter name="network.binary.debug" value="true" /> </parameters> </listener> <!-- <listener protocol="binary" ip-address="0.0.0.0" port-range="2434-2440" socket="ssl"/> --> <listener protocol="http" ip-address="0.0.0.0" port-range="2480-2490" socket="default"> <parameters> <!-- Connection's custom parameters. If not specified the global configuration will be taken --> <parameter name="network.http.charset" value="utf-8"/> <!-- Define additional HTTP headers to always send as response --> <!-- Allow cross-site scripting --> <!-- parameter name="network.http.additionalResponseHeaders" value="Access-Control-Allow-Origin: *;Access-Control-Allow-Credentials: true" / --> </parameters> <commands> <command pattern="GET|www GET|studio/ GET| GET|*.htm GET|*.html GET|*.xml GET|*.jpeg GET|*.jpg GET|*.png GET|*.gif GET|*.js GET|*.css GET|*.swf GET|*.ico GET|*.txt GET|*.otf GET|*.pjs GET|*.svg GET|*.json GET|*.woff GET|*.ttf GET|*.svgz" implementation="com.orientechnologies.orient.server.network.protocol.http.command.get.OServerCommandGetStaticContent"> <parameters> <!-- Don't cache html resources in development mode --> <entry name="http.cache:*.htm *.html" value="Cache-Control: no-cache, no-store, max-age=0, must-revalidate\r\nPragma: no-cache"/> <!-- Default caching --> <entry name="http.cache:default" value="Cache-Control: max-age=120"/> </parameters> </command> <command pattern="GET|gephi/*" implementation="com.orientechnologies.orient.graph.server.command.OServerCommandGetGephi"/> </commands> </listener> </listeners> <cluster> </cluster> </network> <storages> </storages> <users> <user resources="*" password="root" name="root"/> <!-- user resources="*" password="admin" name="admin"/ --> <user resources="connect,server.listDatabases,server.dblist" password="guest" name="guest"/> </users> <properties> <!-- DATABASE POOL: size min/max --> <entry name="db.pool.min" value="1"/> <entry name="db.pool.max" value="50"/> <!-- PROFILER: configures the profiler as <seconds-for-snapshot>,<archive-snapshot-size>,<summary-size> --> <entry name="profiler.enabled" value="true"/> <!-- <entry name="profiler.config" value="30,10,10" /> --> <!-- LOG: enable/Disable logging. Levels are: finer, fine, finest, info, warning --> <entry value="finest" name="log.console.level"/> <entry value="finest" name="log.file.level"/> </properties> </orient-server>
{ "pile_set_name": "Github" }
<?xml version="1.0"?> <package > <metadata> <id>nanoFramework.Targets.ST_STM32F769I_DISCOVERY</id> <title>nanoFramework.Targets.ST_STM32F769I_DISCOVERY</title> <version>1.0.0</version> <authors>nanoFramework project contributors</authors> <owners>nanoFramework project contributors</owners> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description> Helper classes to use ST_STM32F769I_DISCOVERY target in C# applications. </description> <releaseNotes> </releaseNotes> <summary> This is an extension for .NET nanoFramework enhacing support for Windows.Devices.Gpio.GpioController when using STM32 MCUs. </summary> <projectUrl>https://github.com/nanoframework</projectUrl> <iconUrl>https://secure.gravatar.com/avatar/97d0e092247f0716db6d4b47b7d1d1ad</iconUrl> <licenseUrl>https://github.com/nanoframework/nf-interpreter/blob/develop/LICENSE.md</licenseUrl> <copyright>Copyright (c) .NET Foundation and Contributors</copyright> <references></references> <tags>nanoFramework, nano Framework, NETNF, NETMF, Micro Framework, STM32, .net, STM32F769I </tags> </metadata> <files> <file src="STM32F769I_DISCOVERY.Adc.cs" target="content" /> </files> </package>
{ "pile_set_name": "Github" }
#define TFM_DEFINES #include "fp_sqr_comba.c" #if defined(TFM_SQR24) && FP_SIZE >= 48 void fp_sqr_comba24(fp_int *A, fp_int *B) { fp_digit *a, b[48], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[0], a[17]); SQRADDAC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADDSC(a[0], a[18]); SQRADDAC(a[1], a[17]); SQRADDAC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADDSC(a[0], a[19]); SQRADDAC(a[1], a[18]); SQRADDAC(a[2], a[17]); SQRADDAC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADDSC(a[0], a[20]); SQRADDAC(a[1], a[19]); SQRADDAC(a[2], a[18]); SQRADDAC(a[3], a[17]); SQRADDAC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADDSC(a[0], a[21]); SQRADDAC(a[1], a[20]); SQRADDAC(a[2], a[19]); SQRADDAC(a[3], a[18]); SQRADDAC(a[4], a[17]); SQRADDAC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADDSC(a[0], a[22]); SQRADDAC(a[1], a[21]); SQRADDAC(a[2], a[20]); SQRADDAC(a[3], a[19]); SQRADDAC(a[4], a[18]); SQRADDAC(a[5], a[17]); SQRADDAC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); COMBA_STORE(b[22]); /* output 23 */ CARRY_FORWARD; SQRADDSC(a[0], a[23]); SQRADDAC(a[1], a[22]); SQRADDAC(a[2], a[21]); SQRADDAC(a[3], a[20]); SQRADDAC(a[4], a[19]); SQRADDAC(a[5], a[18]); SQRADDAC(a[6], a[17]); SQRADDAC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; COMBA_STORE(b[23]); /* output 24 */ CARRY_FORWARD; SQRADDSC(a[1], a[23]); SQRADDAC(a[2], a[22]); SQRADDAC(a[3], a[21]); SQRADDAC(a[4], a[20]); SQRADDAC(a[5], a[19]); SQRADDAC(a[6], a[18]); SQRADDAC(a[7], a[17]); SQRADDAC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); COMBA_STORE(b[24]); /* output 25 */ CARRY_FORWARD; SQRADDSC(a[2], a[23]); SQRADDAC(a[3], a[22]); SQRADDAC(a[4], a[21]); SQRADDAC(a[5], a[20]); SQRADDAC(a[6], a[19]); SQRADDAC(a[7], a[18]); SQRADDAC(a[8], a[17]); SQRADDAC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; COMBA_STORE(b[25]); /* output 26 */ CARRY_FORWARD; SQRADDSC(a[3], a[23]); SQRADDAC(a[4], a[22]); SQRADDAC(a[5], a[21]); SQRADDAC(a[6], a[20]); SQRADDAC(a[7], a[19]); SQRADDAC(a[8], a[18]); SQRADDAC(a[9], a[17]); SQRADDAC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); COMBA_STORE(b[26]); /* output 27 */ CARRY_FORWARD; SQRADDSC(a[4], a[23]); SQRADDAC(a[5], a[22]); SQRADDAC(a[6], a[21]); SQRADDAC(a[7], a[20]); SQRADDAC(a[8], a[19]); SQRADDAC(a[9], a[18]); SQRADDAC(a[10], a[17]); SQRADDAC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; COMBA_STORE(b[27]); /* output 28 */ CARRY_FORWARD; SQRADDSC(a[5], a[23]); SQRADDAC(a[6], a[22]); SQRADDAC(a[7], a[21]); SQRADDAC(a[8], a[20]); SQRADDAC(a[9], a[19]); SQRADDAC(a[10], a[18]); SQRADDAC(a[11], a[17]); SQRADDAC(a[12], a[16]); SQRADDAC(a[13], a[15]); SQRADDDB; SQRADD(a[14], a[14]); COMBA_STORE(b[28]); /* output 29 */ CARRY_FORWARD; SQRADDSC(a[6], a[23]); SQRADDAC(a[7], a[22]); SQRADDAC(a[8], a[21]); SQRADDAC(a[9], a[20]); SQRADDAC(a[10], a[19]); SQRADDAC(a[11], a[18]); SQRADDAC(a[12], a[17]); SQRADDAC(a[13], a[16]); SQRADDAC(a[14], a[15]); SQRADDDB; COMBA_STORE(b[29]); /* output 30 */ CARRY_FORWARD; SQRADDSC(a[7], a[23]); SQRADDAC(a[8], a[22]); SQRADDAC(a[9], a[21]); SQRADDAC(a[10], a[20]); SQRADDAC(a[11], a[19]); SQRADDAC(a[12], a[18]); SQRADDAC(a[13], a[17]); SQRADDAC(a[14], a[16]); SQRADDDB; SQRADD(a[15], a[15]); COMBA_STORE(b[30]); /* output 31 */ CARRY_FORWARD; SQRADDSC(a[8], a[23]); SQRADDAC(a[9], a[22]); SQRADDAC(a[10], a[21]); SQRADDAC(a[11], a[20]); SQRADDAC(a[12], a[19]); SQRADDAC(a[13], a[18]); SQRADDAC(a[14], a[17]); SQRADDAC(a[15], a[16]); SQRADDDB; COMBA_STORE(b[31]); /* output 32 */ CARRY_FORWARD; SQRADDSC(a[9], a[23]); SQRADDAC(a[10], a[22]); SQRADDAC(a[11], a[21]); SQRADDAC(a[12], a[20]); SQRADDAC(a[13], a[19]); SQRADDAC(a[14], a[18]); SQRADDAC(a[15], a[17]); SQRADDDB; SQRADD(a[16], a[16]); COMBA_STORE(b[32]); /* output 33 */ CARRY_FORWARD; SQRADDSC(a[10], a[23]); SQRADDAC(a[11], a[22]); SQRADDAC(a[12], a[21]); SQRADDAC(a[13], a[20]); SQRADDAC(a[14], a[19]); SQRADDAC(a[15], a[18]); SQRADDAC(a[16], a[17]); SQRADDDB; COMBA_STORE(b[33]); /* output 34 */ CARRY_FORWARD; SQRADDSC(a[11], a[23]); SQRADDAC(a[12], a[22]); SQRADDAC(a[13], a[21]); SQRADDAC(a[14], a[20]); SQRADDAC(a[15], a[19]); SQRADDAC(a[16], a[18]); SQRADDDB; SQRADD(a[17], a[17]); COMBA_STORE(b[34]); /* output 35 */ CARRY_FORWARD; SQRADDSC(a[12], a[23]); SQRADDAC(a[13], a[22]); SQRADDAC(a[14], a[21]); SQRADDAC(a[15], a[20]); SQRADDAC(a[16], a[19]); SQRADDAC(a[17], a[18]); SQRADDDB; COMBA_STORE(b[35]); /* output 36 */ CARRY_FORWARD; SQRADDSC(a[13], a[23]); SQRADDAC(a[14], a[22]); SQRADDAC(a[15], a[21]); SQRADDAC(a[16], a[20]); SQRADDAC(a[17], a[19]); SQRADDDB; SQRADD(a[18], a[18]); COMBA_STORE(b[36]); /* output 37 */ CARRY_FORWARD; SQRADDSC(a[14], a[23]); SQRADDAC(a[15], a[22]); SQRADDAC(a[16], a[21]); SQRADDAC(a[17], a[20]); SQRADDAC(a[18], a[19]); SQRADDDB; COMBA_STORE(b[37]); /* output 38 */ CARRY_FORWARD; SQRADDSC(a[15], a[23]); SQRADDAC(a[16], a[22]); SQRADDAC(a[17], a[21]); SQRADDAC(a[18], a[20]); SQRADDDB; SQRADD(a[19], a[19]); COMBA_STORE(b[38]); /* output 39 */ CARRY_FORWARD; SQRADDSC(a[16], a[23]); SQRADDAC(a[17], a[22]); SQRADDAC(a[18], a[21]); SQRADDAC(a[19], a[20]); SQRADDDB; COMBA_STORE(b[39]); /* output 40 */ CARRY_FORWARD; SQRADDSC(a[17], a[23]); SQRADDAC(a[18], a[22]); SQRADDAC(a[19], a[21]); SQRADDDB; SQRADD(a[20], a[20]); COMBA_STORE(b[40]); /* output 41 */ CARRY_FORWARD; SQRADDSC(a[18], a[23]); SQRADDAC(a[19], a[22]); SQRADDAC(a[20], a[21]); SQRADDDB; COMBA_STORE(b[41]); /* output 42 */ CARRY_FORWARD; SQRADD2(a[19], a[23]); SQRADD2(a[20], a[22]); SQRADD(a[21], a[21]); COMBA_STORE(b[42]); /* output 43 */ CARRY_FORWARD; SQRADD2(a[20], a[23]); SQRADD2(a[21], a[22]); COMBA_STORE(b[43]); /* output 44 */ CARRY_FORWARD; SQRADD2(a[21], a[23]); SQRADD(a[22], a[22]); COMBA_STORE(b[44]); /* output 45 */ CARRY_FORWARD; SQRADD2(a[22], a[23]); COMBA_STORE(b[45]); /* output 46 */ CARRY_FORWARD; SQRADD(a[23], a[23]); COMBA_STORE(b[46]); COMBA_STORE2(b[47]); COMBA_FINI; B->used = 48; B->sign = FP_ZPOS; memcpy(B->dp, b, 48 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source$ */ /* $Revision$ */ /* $Date$ */
{ "pile_set_name": "Github" }
> [!IMPORTANT] > You should limit the HTML content of email messages to a maximum size of 100KB. This size limit includes all HTML text, styles, comments, and embedded graphics (but not anchored external graphics). If the HTML content exceeds 128KB, you'll receive a size warning, but you can still go live with the email and any customer journey that includes the email. > > When you go live with a message, [!INCLUDE[pn-marketing-business-app-module-name](../includes/pn-marketing-business-app-module-name.md)] processes the HTML content to create inline styles, compress spaces, and more, so it can be hard to know the exact final size of the message. If you have a message that you suspect violates the HTML size limit, do the following: > > 1. Open a web browser and enter a URL of the form: `https://<your_domain>/api/data/v9.0/msdyncrm_marketingemails(<email_id>)` > Where: > - _&lt;your_domain&gt;_ is the root of your [!INCLUDE[pn-marketing-business-app-module-name](../includes/pn-marketing-business-app-module-name.md)] instance (such as "contoso.crm.dynamics.com"). > - _&lt;email_id&gt;_ is the ID for the message you want to check. To find this ID, open the message in [!INCLUDE[pn-marketing-business-app-module-name](../includes/pn-marketing-business-app-module-name.md)] and find the value of the `id=` parameter shown in your browser's address bar. > 1. Search for the value of the field "msdyncrm_emailbody" in the returned JSON. > 1. Copy the value of that field into a text program that can tell you the exact size of the HTML content.
{ "pile_set_name": "Github" }
id: dsq-747526789 date: 2008-11-12T12:20:01.0000000-08:00 name: Andrea Balducci avatar: https://disqus.com/api/users/avatars/Andrea Balducci.jpg message: <p>I forgot to say that the whole app is compiled (static resources, scripts, views, controllers, masterpages) and deployed as embedded resources. By now i've implemented a virtualpathprovider to mix filesystem and embedded resources, so you can easily create a portal just mixing the apps you want to deploy from an application library (or in the future from an application store :)</p>
{ "pile_set_name": "Github" }
{ "case_insensitive": true, "keywords": { "keyword": "div mod in and or not xor asserterror begin case do downto else end exit for if of repeat then to until while with var", "literal": "false true" }, "illegal": "\\\/\\*", "contains": [ { "className": "string", "begin": "'", "end": "'", "contains": [ { "begin": "''" } ] }, { "className": "string", "begin": "(#\\d+)+" }, { "className": "number", "begin": "\\b\\d+(\\.\\d+)?(DT|D|T)", "relevance": 0 }, { "className": "string", "begin": "\"", "end": "\"" }, { "className": "number", "begin": "\\b\\d+(\\.\\d+)?", "relevance": 0 }, { "className": "class", "begin": "OBJECT (Table|Form|Report|Dataport|Codeunit|XMLport|MenuSuite|Page|Query) (\\d+) ([^\\r\\n]+)", "returnBegin": true, "contains": [ { "className": "title", "begin": "[a-zA-Z]\\w*", "relevance": 0 }, { "className": "function", "beginKeywords": "procedure", "end": "[:;]", "keywords": "procedure|10", "contains": [ { "$ref": "#contains.5.contains.0" }, { "className": "params", "begin": "\\(", "end": "\\)", "keywords": "div mod in and or not xor asserterror begin case do downto else end exit for if of repeat then to until while with var", "contains": [ { "$ref": "#contains.0" }, { "$ref": "#contains.1" } ] }, { "className": "comment", "begin": "\/\/", "end": "$", "contains": [ { "begin": "\\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\\b" }, { "className": "doctag", "begin": "(?:TODO|FIXME|NOTE|BUG|XXX):", "relevance": 0 } ] }, { "className": "comment", "begin": "\\{", "end": "\\}", "contains": [ { "$ref": "#contains.5.contains.1.contains.2.contains.0" }, { "className": "doctag", "begin": "(?:TODO|FIXME|NOTE|BUG|XXX):", "relevance": 0 } ], "relevance": 0 }, { "className": "comment", "begin": "\\(\\*", "end": "\\*\\)", "contains": [ { "$ref": "#contains.5.contains.1.contains.2.contains.0" }, { "className": "doctag", "begin": "(?:TODO|FIXME|NOTE|BUG|XXX):", "relevance": 0 } ], "relevance": 10 } ] } ] }, { "$ref": "#contains.5.contains.1" } ] }
{ "pile_set_name": "Github" }
/** * Module dependencies. */ var parser = require('socket.io-parser'); var debug = require('debug')('socket.io:client'); var url = require('url'); /** * Module exports. */ module.exports = Client; /** * Client constructor. * * @param {Server} server instance * @param {Socket} conn * @api private */ function Client(server, conn){ this.server = server; this.conn = conn; this.encoder = new parser.Encoder(); this.decoder = new parser.Decoder(); this.id = conn.id; this.request = conn.request; this.setup(); this.sockets = {}; this.nsps = {}; this.connectBuffer = []; } /** * Sets up event listeners. * * @api private */ Client.prototype.setup = function(){ this.onclose = this.onclose.bind(this); this.ondata = this.ondata.bind(this); this.onerror = this.onerror.bind(this); this.ondecoded = this.ondecoded.bind(this); this.decoder.on('decoded', this.ondecoded); this.conn.on('data', this.ondata); this.conn.on('error', this.onerror); this.conn.on('close', this.onclose); }; /** * Connects a client to a namespace. * * @param {String} name namespace * @api private */ Client.prototype.connect = function(name, query){ debug('connecting to namespace %s', name); var nsp = this.server.nsps[name]; if (!nsp) { this.packet({ type: parser.ERROR, nsp: name, data : 'Invalid namespace'}); return; } if ('/' != name && !this.nsps['/']) { this.connectBuffer.push(name); return; } var self = this; var socket = nsp.add(this, query, function(){ self.sockets[socket.id] = socket; self.nsps[nsp.name] = socket; if ('/' == nsp.name && self.connectBuffer.length > 0) { self.connectBuffer.forEach(self.connect, self); self.connectBuffer = []; } }); }; /** * Disconnects from all namespaces and closes transport. * * @api private */ Client.prototype.disconnect = function(){ for (var id in this.sockets) { if (this.sockets.hasOwnProperty(id)) { this.sockets[id].disconnect(); } } this.sockets = {}; this.close(); }; /** * Removes a socket. Called by each `Socket`. * * @api private */ Client.prototype.remove = function(socket){ if (this.sockets.hasOwnProperty(socket.id)) { var nsp = this.sockets[socket.id].nsp.name; delete this.sockets[socket.id]; delete this.nsps[nsp]; } else { debug('ignoring remove for %s', socket.id); } }; /** * Closes the underlying connection. * * @api private */ Client.prototype.close = function(){ if ('open' == this.conn.readyState) { debug('forcing transport close'); this.conn.close(); this.onclose('forced server close'); } }; /** * Writes a packet to the transport. * * @param {Object} packet object * @param {Object} opts * @api private */ Client.prototype.packet = function(packet, opts){ opts = opts || {}; var self = this; // this writes to the actual connection function writeToEngine(encodedPackets) { if (opts.volatile && !self.conn.transport.writable) return; for (var i = 0; i < encodedPackets.length; i++) { self.conn.write(encodedPackets[i], { compress: opts.compress }); } } if ('open' == this.conn.readyState) { debug('writing packet %j', packet); if (!opts.preEncoded) { // not broadcasting, need to encode this.encoder.encode(packet, function (encodedPackets) { // encode, then write results to engine writeToEngine(encodedPackets); }); } else { // a broadcast pre-encodes a packet writeToEngine(packet); } } else { debug('ignoring packet write %j', packet); } }; /** * Called with incoming transport data. * * @api private */ Client.prototype.ondata = function(data){ // try/catch is needed for protocol violations (GH-1880) try { this.decoder.add(data); } catch(e) { this.onerror(e); } }; /** * Called when parser fully decodes a packet. * * @api private */ Client.prototype.ondecoded = function(packet) { if (parser.CONNECT == packet.type) { this.connect(url.parse(packet.nsp).pathname, url.parse(packet.nsp, true).query); } else { var socket = this.nsps[packet.nsp]; if (socket) { process.nextTick(function() { socket.onpacket(packet); }); } else { debug('no socket for namespace %s', packet.nsp); } } }; /** * Handles an error. * * @param {Object} err object * @api private */ Client.prototype.onerror = function(err){ for (var id in this.sockets) { if (this.sockets.hasOwnProperty(id)) { this.sockets[id].onerror(err); } } this.onclose('client error'); }; /** * Called upon transport close. * * @param {String} reason * @api private */ Client.prototype.onclose = function(reason){ debug('client close with reason %s', reason); // ignore a potential subsequent `close` event this.destroy(); // `nsps` and `sockets` are cleaned up seamlessly for (var id in this.sockets) { if (this.sockets.hasOwnProperty(id)) { this.sockets[id].onclose(reason); } } this.sockets = {}; this.decoder.destroy(); // clean up decoder }; /** * Cleans up event listeners. * * @api private */ Client.prototype.destroy = function(){ this.conn.removeListener('data', this.ondata); this.conn.removeListener('error', this.onerror); this.conn.removeListener('close', this.onclose); this.decoder.removeListener('decoded', this.ondecoded); };
{ "pile_set_name": "Github" }
/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_fax3.h,v 1.8 92/02/10 19:06:37 sam Exp $ */ /* * Copyright (c) 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _FAX3_ #define _FAX3_ /* * CCITT Group 3 compression/decompression definitions. */ #define FAX3_CLASSF TIFF_OPT0 /* use Class F protocol */ /* the following are for use by Compression=2, 32771, and 4 (T.6) algorithms */ #define FAX3_NOEOL TIFF_OPT1 /* no EOL code at end of row */ #define FAX3_BYTEALIGN TIFF_OPT2 /* force byte alignment at end of row */ #define FAX3_WORDALIGN TIFF_OPT3 /* force word alignment at end of row */ /* * Compression+decompression state blocks are * derived from this ``base state'' block. */ typedef struct { short data; /* current i/o byte */ short bit; /* current i/o bit in byte */ short white; /* value of the color ``white'' */ u_long rowbytes; /* XXX maybe should be a long? */ u_long rowpixels; /* XXX maybe should be a long? */ enum { /* decoding/encoding mode */ G3_1D, /* basic 1-d mode */ G3_2D /* optional 2-d mode */ } tag; #if defined(__STDC__) || defined(__EXTENDED__) || USE_CONST u_char const *bitmap; /* bit reversal table */ #else u_char *bitmap; /* bit reversal table */ #endif u_char *refline; /* reference line for 2d decoding */ } Fax3BaseState; /* these routines are used for Group 4 (T.6) */ #if USE_PROTOTYPES extern int Fax3Decode2DRow(TIFF*, u_char *, int); extern int Fax3Encode2DRow(TIFF*, u_char *, u_char *, int); extern void Fax3PutEOL(TIFF*); #else extern int Fax3Decode2DRow(); extern int Fax3Encode2DRow(); extern void Fax3PutEOL(); #endif #define Fax3FlushBits(tif, sp) { \ if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ (void) TIFFFlushData1(tif); \ *(tif)->tif_rawcp++ = (sp)->bitmap[(sp)->data]; \ (tif)->tif_rawcc++; \ (sp)->data = 0; \ (sp)->bit = 8; \ } #endif /* _FAX3_ */
{ "pile_set_name": "Github" }
import cv2 import matplotlib.pyplot as plt def main(): path = "D:\\Youtube Code\\Python\\Python OpenCV3\\Python-OpenCV3\\Dataset\\" imgpath = path + "Damaged Image.tiff" maskpath = path + "Mask.tiff" img = cv2.imread(imgpath, 1) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) mask= cv2.imread(maskpath, 0) output1 = cv2.inpaint(img, mask, 5, cv2.INPAINT_TELEA) output2 = cv2.inpaint(img, mask, 5, cv2.INPAINT_NS) output = [img, mask, output1, output2] titles = ['Damaged Image', 'Mask', 'TELEA', 'NS'] for i in range(4): plt.subplot(2, 2, i+1) if i == 1: plt.imshow(output[i], cmap='gray') else: plt.imshow(output[i]) plt.title(titles[i]) plt.xticks([]) plt.yticks([]) plt.show() if __name__ == "__main__": main()
{ "pile_set_name": "Github" }
<?php /* * @copyright 2015 Mautic Contributors. All rights reserved * @author Mautic * * @link http://mautic.org * * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ // Include local paths include 'paths.php'; // Closure to replace %kernel.root_dir% placeholders $replaceRootPlaceholder = function (&$value) use ($root, &$replaceRootPlaceholder) { if (is_array($value)) { foreach ($value as &$v) { $replaceRootPlaceholder($v); } } elseif (false !== strpos($value, '%kernel.root_dir%')) { $value = str_replace('%kernel.root_dir%', $root, $value); } }; // Handle paths $replaceRootPlaceholder($paths);
{ "pile_set_name": "Github" }
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 1999-2017 Alibaba Group Holding Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from .. import serializers from .cache import cache, del_cache from ..compat import six, quote_plus class XMLRemoteModel(serializers.XMLSerializableModel): __slots__ = '_parent', '_client' def __init__(self, **kwargs): if 'parent' in kwargs: kwargs['_parent'] = kwargs.pop('parent') if 'client' in kwargs: kwargs['_client'] = kwargs.pop('client') if not frozenset(kwargs).issubset(self.__slots__): unexpected = sorted(set(kwargs) - set(self.__slots__)) raise TypeError("%s() meet illegal arguments (%s)" % ( type(self).__name__, ', '.join(unexpected))) super(XMLRemoteModel, self).__init__(**kwargs) @classmethod def parse(cls, client, response, obj=None, **kw): kw['_client'] = client return super(XMLRemoteModel, cls).parse(response, obj=obj, **kw) class AbstractXMLRemoteModel(XMLRemoteModel): __slots__ = '_type_indicator', class JSONRemoteModel(serializers.JSONSerializableModel): __slots__ = '_parent', '_client' def __init__(self, **kwargs): if 'parent' in kwargs: kwargs['_parent'] = kwargs.pop('parent') if 'client' in kwargs: kwargs['_client'] = kwargs.pop('client') if not frozenset(kwargs).issubset(self.__slots__): unexpected = sorted(set(kwargs) - set(self.__slots__)) raise TypeError("%s() meet illegal arguments (%s)" % ( type(self).__name__, ', '.join(unexpected))) super(JSONRemoteModel, self).__init__(**kwargs) @classmethod def parse(cls, client, response, obj=None, **kw): kw['_client'] = client return super(JSONRemoteModel, cls).parse(response, obj=obj, **kw) class RestModel(XMLRemoteModel): def _name(self): return type(self).__name__.lower() @classmethod def _encode(cls, name): name = quote_plus(name).replace('+', '%20') return name def resource(self, client=None): parent = self._parent if parent is None: parent_res = (client or self._client).endpoint else: parent_res = parent.resource(client=client) name = self._name() if name is None: return parent_res return '/'.join([parent_res, self._encode(name)]) def __eq__(self, other): if other is None: return False if not isinstance(other, type(self)): return False return self._name() == other._name() and \ self.parent == other.parent def __hash__(self): return hash(type(self)) * hash(self._parent) * hash(self._name()) class LazyLoad(RestModel): __slots__ = '_loaded', @cache def __new__(cls, *args, **kwargs): return object.__new__(cls) def __init__(self, **kwargs): self._loaded = False kwargs.pop('no_cache', None) super(LazyLoad, self).__init__(**kwargs) def _name(self): return self._getattr('name') def _getattr(self, attr): return object.__getattribute__(self, attr) def __getattribute__(self, attr): val = object.__getattribute__(self, attr) if val is None and not self._loaded: fields = getattr(type(self), '__fields') if attr in fields: self.reload() val = self._getattr(attr) return val def reload(self): raise NotImplementedError def reset(self): self._loaded = False @property def is_loaded(self): return self._loaded def __repr__(self): try: r = self._repr() except: r = None if r: return r else: return super(LazyLoad, self).__repr__() def _repr(self): name = self._name() if name: return '<%s %s>' % (type(self).__name__, name) else: raise ValueError def __hash__(self): return hash((self._name(), self.parent)) def __eq__(self, other): if not isinstance(other, type(self)): return False return self._name() == other._name() and self.parent == other.parent def __getstate__(self): return self._name(), self._parent, self._client def __setstate__(self, state): name, parent, client = state self._set_state(name, parent, client) def _set_state(self, name, parent, client): self.__init__(name=name, _parent=parent, _client=client) class Container(RestModel): skip_null = False @cache def __new__(cls, *args, **kwargs): return object.__new__(cls) def _get(self, item): raise NotImplementedError def __getitem__(self, item): if isinstance(item, six.string_types): return self._get(item) raise ValueError('Unsupported getitem value: %s' % item) @del_cache def __delitem__(self, key): pass def __contains__(self, item): raise NotImplementedError def __getstate__(self): return self._parent, self._client def __setstate__(self, state): parent, client = state self.__init__(_parent=parent, _client=client) class Iterable(Container): __slots__ = '_iter', def __init__(self, **kwargs): super(Iterable, self).__init__(**kwargs) self._iter = iter(self) def __iter__(self): raise NotImplementedError def __next__(self): return next(self._iter) next = __next__
{ "pile_set_name": "Github" }
using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace ExampleMod.NPCs { // This ModNPC serves as an example of a complete AI example. public class FlutterSlime : ModNPC { public override void SetStaticDefaults() { // DisplayName.SetDefault("Flutter Slime"); // Automatic from .lang files Main.npcFrameCount[npc.type] = 6; // make sure to set this for your modnpcs. } public override void SetDefaults() { npc.width = 32; npc.height = 32; npc.aiStyle = -1; // This npc has a completely unique AI, so we set this to -1. The default aiStyle 0 will face the player, which might conflict with custom AI code. npc.damage = 7; npc.defense = 2; npc.lifeMax = 25; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; //npc.alpha = 175; //npc.color = new Color(0, 80, 255, 100); npc.value = 25f; npc.buffImmune[BuffID.Poisoned] = true; npc.buffImmune[BuffID.Confused] = false; // npc default to being immune to the Confused debuff. Allowing confused could be a little more work depending on the AI. npc.confused is true while the npc is confused. } public override float SpawnChance(NPCSpawnInfo spawnInfo) { // we would like this npc to spawn in the overworld. return SpawnCondition.OverworldDaySlime.Chance * 0.1f; } // These const ints are for the benefit of the programmer. Organization is key to making an AI that behaves properly without driving you crazy. // Here I lay out what I will use each of the 4 npc.ai slots for. private const int AI_State_Slot = 0; private const int AI_Timer_Slot = 1; private const int AI_Flutter_Time_Slot = 2; private const int AI_Unused_Slot_3 = 3; // npc.localAI will also have 4 float variables available to use. With ModNPC, using just a local class member variable would have the same effect. private const int Local_AI_Unused_Slot_0 = 0; private const int Local_AI_Unused_Slot_1 = 1; private const int Local_AI_Unused_Slot_2 = 2; private const int Local_AI_Unused_Slot_3 = 3; // Here I define some values I will use with the State slot. Using an ai slot as a means to store "state" can simplify things greatly. Think flowchart. private const int State_Asleep = 0; private const int State_Notice = 1; private const int State_Jump = 2; private const int State_Hover = 3; private const int State_Fall = 4; // This is a property (https://msdn.microsoft.com/en-us/library/x9fsa0sw.aspx), it is very useful and helps keep out AI code clear of clutter. // Without it, every instance of "AI_State" in the AI code below would be "npc.ai[AI_State_Slot]". // Also note that without the "AI_State_Slot" defined above, this would be "npc.ai[0]". // This is all to just make beautiful, manageable, and clean code. public float AI_State { get => npc.ai[AI_State_Slot]; set => npc.ai[AI_State_Slot] = value; } public float AI_Timer { get => npc.ai[AI_Timer_Slot]; set => npc.ai[AI_Timer_Slot] = value; } public float AI_FlutterTime { get => npc.ai[AI_Flutter_Time_Slot]; set => npc.ai[AI_Flutter_Time_Slot] = value; } // AdvancedFlutterSlime will need: float in water, diminishing aggo, spawn projectiles. // Our AI here makes our NPC sit waiting for a player to enter range, jumps to attack, flutter mid-fall to stay afloat a little longer, then falls to the ground. Note that animation should happen in FindFrame public override void AI() { // The npc starts in the asleep state, waiting for a player to enter range if (AI_State == State_Asleep) { // TargetClosest sets npc.target to the player.whoAmI of the closest player. the faceTarget parameter means that npc.direction will automatically be 1 or -1 if the targeted player is to the right or left. This is also automatically flipped if npc.confused npc.TargetClosest(true); // Now we check the make sure the target is still valid and within our specified notice range (500) if (npc.HasValidTarget && Main.player[npc.target].Distance(npc.Center) < 500f) { // Since we have a target in range, we change to the Notice state. (and zero out the Timer for good measure) AI_State = State_Notice; AI_Timer = 0; } } // In this state, a player has been targeted else if (AI_State == State_Notice) { // If the targeted player is in attack range (250). if (Main.player[npc.target].Distance(npc.Center) < 250f) { // Here we use our Timer to wait .33 seconds before actually jumping. In FindFrame you'll notice AI_Timer also being used to animate the pre-jump crouch AI_Timer++; if (AI_Timer >= 20) { AI_State = State_Jump; AI_Timer = 0; } } else { npc.TargetClosest(true); if (!npc.HasValidTarget || Main.player[npc.target].Distance(npc.Center) > 500f) { // Out targeted player seems to have left our range, so we'll go back to sleep. AI_State = State_Asleep; AI_Timer = 0; } } } // In this state, we are in the jump. else if (AI_State == State_Jump) { AI_Timer++; if (AI_Timer == 1) { // We apply an initial velocity the first tick we are in the Jump frame. Remember that -Y is up. npc.velocity = new Vector2(npc.direction * 2, -10f); } else if (AI_Timer > 40) { // after .66 seconds, we go to the hover state. // TODO, gravity? AI_State = State_Hover; AI_Timer = 0; } } // In this state, our npc starts to flutter/fly a little to make it's movement a little bit interesting. else if (AI_State == State_Hover) { AI_Timer += 1; // Here we make a decision on how long this flutter will last. We check netmode != 1 to prevent Multiplayer Clients from running this code. (similarly, spawning projectiles should also be wrapped like this) // netmode == 0 is SP, netmode == 1 is MP Client, netmode == 2 is MP Server. // Typically in MP, Client and Server maintain the same state by running deterministic code individually. When we want to do something random, we must do that on the server and then inform MP Clients. // Informing MP Clients is done automatically by syncing the npc.ai array over the network whenever npc.netUpdate is set. Don't set netUpdate unless you do something non-deterministic ("random") if (AI_Timer == 1 && Main.netMode != NetmodeID.MultiplayerClient) { // For reference: without proper syncing: https://gfycat.com/BackAnxiousFerret and with proper syncing: https://gfycat.com/TatteredKindlyDalmatian AI_FlutterTime = Main.rand.NextBool() ? 100 : 50; npc.netUpdate = true; } // Here we add a tiny bit of upward velocity to our npc. npc.velocity += new Vector2(0, -.35f); // ... and some additional X velocity when traveling slow. if (Math.Abs(npc.velocity.X) < 2) { npc.velocity += new Vector2(npc.direction * .05f, 0); } if (AI_Timer > AI_FlutterTime) { // after fluttering for 100 ticks (1.66 seconds), our Flutter Slime is tired, so he decides to go into the Fall state. AI_State = State_Fall; AI_Timer = 0; } } // In this state, we fall untill we hit the ground. Since npc.noTileCollide is false, our npc collides with ground it lands on and will have a zero y velocity once it has landed. else if (AI_State == State_Fall) { if (npc.velocity.Y == 0) { npc.velocity.X = 0; AI_State = State_Asleep; AI_Timer = 0; } } } // Our texture is 32x32 with 2 pixels of padding vertically, so 34 is the vertical spacing. These are for my benefit and the numbers could easily be used directly in the code below, but this is how I keep code organized. private const int Frame_Asleep = 0; private const int Frame_Notice = 1; private const int Frame_Falling = 2; private const int Frame_Flutter_1 = 3; private const int Frame_Flutter_2 = 4; private const int Frame_Flutter_3 = 5; // Here in FindFrame, we want to set the animation frame our npc will use depending on what it is doing. // We set npc.frame.Y to x * frameHeight where x is the xth frame in our spritesheet, counting from 0. For convenience, I have defined some consts above. public override void FindFrame(int frameHeight) { // This makes the sprite flip horizontally in conjunction with the npc.direction. npc.spriteDirection = npc.direction; // For the most part, our animation matches up with our states. if (AI_State == State_Asleep) { // npc.frame.Y is the goto way of changing animation frames. npc.frame starts from the top left corner in pixel coordinates, so keep that in mind. npc.frame.Y = Frame_Asleep * frameHeight; } else if (AI_State == State_Notice) { // Going from Notice to Asleep makes our npc look like it's crouching to jump. if (AI_Timer < 10) { npc.frame.Y = Frame_Notice * frameHeight; } else { npc.frame.Y = Frame_Asleep * frameHeight; } } else if (AI_State == State_Jump) { npc.frame.Y = Frame_Falling * frameHeight; } else if (AI_State == State_Hover) { // Here we have 3 frames that we want to cycle through. npc.frameCounter++; if (npc.frameCounter < 10) { npc.frame.Y = Frame_Flutter_1 * frameHeight; } else if (npc.frameCounter < 20) { npc.frame.Y = Frame_Flutter_2 * frameHeight; } else if (npc.frameCounter < 30) { npc.frame.Y = Frame_Flutter_3 * frameHeight; } else { npc.frameCounter = 0; } } else if (AI_State == State_Fall) { npc.frame.Y = Frame_Falling * frameHeight; } } } }
{ "pile_set_name": "Github" }
/* * EHCI HCD (Host Controller Driver) for USB. * * Bus Glue for PPC On-Chip EHCI driver on the of_platform bus * Tested on AMCC PPC 440EPx * * Valentine Barshak <[email protected]> * * Based on "ehci-ppc-soc.c" by Stefan Roese <[email protected]> * and "ohci-ppc-of.c" by Sylvain Munaut <[email protected]> * * This file is licenced under the GPL. */ #include <linux/err.h> #include <linux/signal.h> #include <linux/of.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/of_platform.h> static const struct hc_driver ehci_ppc_of_hc_driver = { .description = hcd_name, .product_desc = "OF EHCI", .hcd_priv_size = sizeof(struct ehci_hcd), /* * generic hardware linkage */ .irq = ehci_irq, .flags = HCD_MEMORY | HCD_USB2 | HCD_BH, /* * basic lifecycle operations */ .reset = ehci_setup, .start = ehci_run, .stop = ehci_stop, .shutdown = ehci_shutdown, /* * managing i/o requests and associated device resources */ .urb_enqueue = ehci_urb_enqueue, .urb_dequeue = ehci_urb_dequeue, .endpoint_disable = ehci_endpoint_disable, .endpoint_reset = ehci_endpoint_reset, /* * scheduling support */ .get_frame_number = ehci_get_frame, /* * root hub support */ .hub_status_data = ehci_hub_status_data, .hub_control = ehci_hub_control, #ifdef CONFIG_PM .bus_suspend = ehci_bus_suspend, .bus_resume = ehci_bus_resume, #endif .relinquish_port = ehci_relinquish_port, .port_handed_over = ehci_port_handed_over, .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, }; /* * 440EPx Errata USBH_3 * Fix: Enable Break Memory Transfer (BMT) in INSNREG3 */ #define PPC440EPX_EHCI0_INSREG_BMT (0x1 << 0) static int ppc44x_enable_bmt(struct device_node *dn) { __iomem u32 *insreg_virt; insreg_virt = of_iomap(dn, 1); if (!insreg_virt) return -EINVAL; out_be32(insreg_virt + 3, PPC440EPX_EHCI0_INSREG_BMT); iounmap(insreg_virt); return 0; } static int ehci_hcd_ppc_of_probe(struct platform_device *op) { struct device_node *dn = op->dev.of_node; struct usb_hcd *hcd; struct ehci_hcd *ehci = NULL; struct resource res; int irq; int rv; struct device_node *np; if (usb_disabled()) return -ENODEV; dev_dbg(&op->dev, "initializing PPC-OF USB Controller\n"); rv = of_address_to_resource(dn, 0, &res); if (rv) return rv; hcd = usb_create_hcd(&ehci_ppc_of_hc_driver, &op->dev, "PPC-OF USB"); if (!hcd) return -ENOMEM; hcd->rsrc_start = res.start; hcd->rsrc_len = resource_size(&res); irq = irq_of_parse_and_map(dn, 0); if (irq == NO_IRQ) { dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n", __FILE__); rv = -EBUSY; goto err_irq; } hcd->regs = devm_ioremap_resource(&op->dev, &res); if (IS_ERR(hcd->regs)) { rv = PTR_ERR(hcd->regs); goto err_ioremap; } ehci = hcd_to_ehci(hcd); np = of_find_compatible_node(NULL, NULL, "ibm,usb-ohci-440epx"); if (np != NULL) { /* claim we really affected by usb23 erratum */ if (!of_address_to_resource(np, 0, &res)) ehci->ohci_hcctrl_reg = devm_ioremap(&op->dev, res.start + OHCI_HCCTRL_OFFSET, OHCI_HCCTRL_LEN); else pr_debug("%s: no ohci offset in fdt\n", __FILE__); if (!ehci->ohci_hcctrl_reg) { pr_debug("%s: ioremap for ohci hcctrl failed\n", __FILE__); } else { ehci->has_amcc_usb23 = 1; } } if (of_get_property(dn, "big-endian", NULL)) { ehci->big_endian_mmio = 1; ehci->big_endian_desc = 1; } if (of_get_property(dn, "big-endian-regs", NULL)) ehci->big_endian_mmio = 1; if (of_get_property(dn, "big-endian-desc", NULL)) ehci->big_endian_desc = 1; ehci->caps = hcd->regs; if (of_device_is_compatible(dn, "ibm,usb-ehci-440epx")) { rv = ppc44x_enable_bmt(dn); ehci_dbg(ehci, "Break Memory Transfer (BMT) is %senabled!\n", rv ? "NOT ": ""); } rv = usb_add_hcd(hcd, irq, 0); if (rv) goto err_ioremap; device_wakeup_enable(hcd->self.controller); return 0; err_ioremap: irq_dispose_mapping(irq); err_irq: usb_put_hcd(hcd); return rv; } static int ehci_hcd_ppc_of_remove(struct platform_device *op) { struct usb_hcd *hcd = platform_get_drvdata(op); struct ehci_hcd *ehci = hcd_to_ehci(hcd); struct device_node *np; struct resource res; dev_dbg(&op->dev, "stopping PPC-OF USB Controller\n"); usb_remove_hcd(hcd); irq_dispose_mapping(hcd->irq); /* use request_mem_region to test if the ohci driver is loaded. if so * ensure the ohci core is operational. */ if (ehci->has_amcc_usb23) { np = of_find_compatible_node(NULL, NULL, "ibm,usb-ohci-440epx"); if (np != NULL) { if (!of_address_to_resource(np, 0, &res)) if (!request_mem_region(res.start, 0x4, hcd_name)) set_ohci_hcfs(ehci, 1); else release_mem_region(res.start, 0x4); else pr_debug("%s: no ohci offset in fdt\n", __FILE__); of_node_put(np); } } usb_put_hcd(hcd); return 0; } static const struct of_device_id ehci_hcd_ppc_of_match[] = { { .compatible = "usb-ehci", }, {}, }; MODULE_DEVICE_TABLE(of, ehci_hcd_ppc_of_match); static struct platform_driver ehci_hcd_ppc_of_driver = { .probe = ehci_hcd_ppc_of_probe, .remove = ehci_hcd_ppc_of_remove, .shutdown = usb_hcd_platform_shutdown, .driver = { .name = "ppc-of-ehci", .of_match_table = ehci_hcd_ppc_of_match, }, };
{ "pile_set_name": "Github" }
#!/usr/bin/env python # Copyright (c) 2015-2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. ''' This checks if all command line args are documented. Return value is 0 to indicate no error. Author: @MarcoFalke ''' from subprocess import check_output import re import sys FOLDER_GREP = 'src' FOLDER_TEST = 'src/test/' CMD_ROOT_DIR = '`git rev-parse --show-toplevel`/%s' % FOLDER_GREP CMD_GREP_ARGS = r"egrep -r -I '(map(Multi)?Args(\.count\(|\[)|Get(Bool)?Arg\()\"\-[^\"]+?\"' %s | grep -v '%s'" % (CMD_ROOT_DIR, FOLDER_TEST) CMD_GREP_DOCS = r"egrep -r -I 'HelpMessageOpt\(\"\-[^\"=]+?(=|\")' %s" % (CMD_ROOT_DIR) REGEX_ARG = re.compile(r'(?:map(?:Multi)?Args(?:\.count\(|\[)|Get(?:Bool)?Arg\()\"(\-[^\"]+?)\"') REGEX_DOC = re.compile(r'HelpMessageOpt\(\"(\-[^\"=]+?)(?:=|\")') # list unsupported, deprecated and duplicate args as they need no documentation SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor', '-debugnet', '-whitelistalwaysrelay', '-prematurewitness', '-walletprematurewitness', '-promiscuousmempoolflags', '-blockminsize', '-dbcrashratio', '-forcecompactdb']) def main(): used = check_output(CMD_GREP_ARGS, shell=True) docd = check_output(CMD_GREP_DOCS, shell=True) args_used = set(re.findall(REGEX_ARG,used)) args_docd = set(re.findall(REGEX_DOC,docd)).union(SET_DOC_OPTIONAL) args_need_doc = args_used.difference(args_docd) args_unknown = args_docd.difference(args_used) print "Args used : %s" % len(args_used) print "Args documented : %s" % len(args_docd) print "Args undocumented: %s" % len(args_need_doc) print args_need_doc print "Args unknown : %s" % len(args_unknown) print args_unknown sys.exit(len(args_need_doc)) if __name__ == "__main__": main()
{ "pile_set_name": "Github" }
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Threading.Tasks; using Pulumi.Serialization; namespace Pulumi.Aws.Alb.Outputs { [OutputType] public sealed class ListenerRuleActionForwardTargetGroup { /// <summary> /// The Amazon Resource Name (ARN) of the target group. /// </summary> public readonly string Arn; /// <summary> /// The weight. The range is 0 to 999. /// </summary> public readonly int? Weight; [OutputConstructor] private ListenerRuleActionForwardTargetGroup( string arn, int? weight) { Arn = arn; Weight = weight; } } }
{ "pile_set_name": "Github" }
#coding=utf-8 from django.contrib import admin # Register your models here.
{ "pile_set_name": "Github" }
import {Request} from '../lib/request'; import {Response} from '../lib/response'; import {AWSError} from '../lib/error'; import {Service} from '../lib/service'; import {ServiceConfigurationOptions} from '../lib/service'; import {ConfigBase as Config} from '../lib/config-base'; interface Blob {} declare class SavingsPlans extends Service { /** * Constructs a service object. This object has one method for each API operation. */ constructor(options?: SavingsPlans.Types.ClientConfiguration) config: Config & SavingsPlans.Types.ClientConfiguration; /** * Creates a Savings Plan. */ createSavingsPlan(params: SavingsPlans.Types.CreateSavingsPlanRequest, callback?: (err: AWSError, data: SavingsPlans.Types.CreateSavingsPlanResponse) => void): Request<SavingsPlans.Types.CreateSavingsPlanResponse, AWSError>; /** * Creates a Savings Plan. */ createSavingsPlan(callback?: (err: AWSError, data: SavingsPlans.Types.CreateSavingsPlanResponse) => void): Request<SavingsPlans.Types.CreateSavingsPlanResponse, AWSError>; /** * Deletes the queued purchase for the specified Savings Plan. */ deleteQueuedSavingsPlan(params: SavingsPlans.Types.DeleteQueuedSavingsPlanRequest, callback?: (err: AWSError, data: SavingsPlans.Types.DeleteQueuedSavingsPlanResponse) => void): Request<SavingsPlans.Types.DeleteQueuedSavingsPlanResponse, AWSError>; /** * Deletes the queued purchase for the specified Savings Plan. */ deleteQueuedSavingsPlan(callback?: (err: AWSError, data: SavingsPlans.Types.DeleteQueuedSavingsPlanResponse) => void): Request<SavingsPlans.Types.DeleteQueuedSavingsPlanResponse, AWSError>; /** * Describes the specified Savings Plans rates. */ describeSavingsPlanRates(params: SavingsPlans.Types.DescribeSavingsPlanRatesRequest, callback?: (err: AWSError, data: SavingsPlans.Types.DescribeSavingsPlanRatesResponse) => void): Request<SavingsPlans.Types.DescribeSavingsPlanRatesResponse, AWSError>; /** * Describes the specified Savings Plans rates. */ describeSavingsPlanRates(callback?: (err: AWSError, data: SavingsPlans.Types.DescribeSavingsPlanRatesResponse) => void): Request<SavingsPlans.Types.DescribeSavingsPlanRatesResponse, AWSError>; /** * Describes the specified Savings Plans. */ describeSavingsPlans(params: SavingsPlans.Types.DescribeSavingsPlansRequest, callback?: (err: AWSError, data: SavingsPlans.Types.DescribeSavingsPlansResponse) => void): Request<SavingsPlans.Types.DescribeSavingsPlansResponse, AWSError>; /** * Describes the specified Savings Plans. */ describeSavingsPlans(callback?: (err: AWSError, data: SavingsPlans.Types.DescribeSavingsPlansResponse) => void): Request<SavingsPlans.Types.DescribeSavingsPlansResponse, AWSError>; /** * Describes the specified Savings Plans offering rates. */ describeSavingsPlansOfferingRates(params: SavingsPlans.Types.DescribeSavingsPlansOfferingRatesRequest, callback?: (err: AWSError, data: SavingsPlans.Types.DescribeSavingsPlansOfferingRatesResponse) => void): Request<SavingsPlans.Types.DescribeSavingsPlansOfferingRatesResponse, AWSError>; /** * Describes the specified Savings Plans offering rates. */ describeSavingsPlansOfferingRates(callback?: (err: AWSError, data: SavingsPlans.Types.DescribeSavingsPlansOfferingRatesResponse) => void): Request<SavingsPlans.Types.DescribeSavingsPlansOfferingRatesResponse, AWSError>; /** * Describes the specified Savings Plans offerings. */ describeSavingsPlansOfferings(params: SavingsPlans.Types.DescribeSavingsPlansOfferingsRequest, callback?: (err: AWSError, data: SavingsPlans.Types.DescribeSavingsPlansOfferingsResponse) => void): Request<SavingsPlans.Types.DescribeSavingsPlansOfferingsResponse, AWSError>; /** * Describes the specified Savings Plans offerings. */ describeSavingsPlansOfferings(callback?: (err: AWSError, data: SavingsPlans.Types.DescribeSavingsPlansOfferingsResponse) => void): Request<SavingsPlans.Types.DescribeSavingsPlansOfferingsResponse, AWSError>; /** * Lists the tags for the specified resource. */ listTagsForResource(params: SavingsPlans.Types.ListTagsForResourceRequest, callback?: (err: AWSError, data: SavingsPlans.Types.ListTagsForResourceResponse) => void): Request<SavingsPlans.Types.ListTagsForResourceResponse, AWSError>; /** * Lists the tags for the specified resource. */ listTagsForResource(callback?: (err: AWSError, data: SavingsPlans.Types.ListTagsForResourceResponse) => void): Request<SavingsPlans.Types.ListTagsForResourceResponse, AWSError>; /** * Adds the specified tags to the specified resource. */ tagResource(params: SavingsPlans.Types.TagResourceRequest, callback?: (err: AWSError, data: SavingsPlans.Types.TagResourceResponse) => void): Request<SavingsPlans.Types.TagResourceResponse, AWSError>; /** * Adds the specified tags to the specified resource. */ tagResource(callback?: (err: AWSError, data: SavingsPlans.Types.TagResourceResponse) => void): Request<SavingsPlans.Types.TagResourceResponse, AWSError>; /** * Removes the specified tags from the specified resource. */ untagResource(params: SavingsPlans.Types.UntagResourceRequest, callback?: (err: AWSError, data: SavingsPlans.Types.UntagResourceResponse) => void): Request<SavingsPlans.Types.UntagResourceResponse, AWSError>; /** * Removes the specified tags from the specified resource. */ untagResource(callback?: (err: AWSError, data: SavingsPlans.Types.UntagResourceResponse) => void): Request<SavingsPlans.Types.UntagResourceResponse, AWSError>; } declare namespace SavingsPlans { export type Amount = string; export type ClientToken = string; export interface CreateSavingsPlanRequest { /** * The ID of the offering. */ savingsPlanOfferingId: SavingsPlanOfferingId; /** * The hourly commitment, in USD. This is a value between 0.001 and 1 million. You cannot specify more than three digits after the decimal point. */ commitment: Amount; /** * The up-front payment amount. This is a whole number between 50 and 99 percent of the total value of the Savings Plan. This parameter is supported only if the payment option is Partial Upfront. */ upfrontPaymentAmount?: Amount; /** * The time at which to purchase the Savings Plan, in UTC format (YYYY-MM-DDTHH:MM:SSZ). */ purchaseTime?: DateTime; /** * Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. */ clientToken?: ClientToken; /** * One or more tags. */ tags?: TagMap; } export interface CreateSavingsPlanResponse { /** * The ID of the Savings Plan. */ savingsPlanId?: SavingsPlanId; } export type CurrencyCode = "CNY"|"USD"|string; export type CurrencyList = CurrencyCode[]; export type DateTime = Date; export interface DeleteQueuedSavingsPlanRequest { /** * The ID of the Savings Plan. */ savingsPlanId: SavingsPlanId; } export interface DeleteQueuedSavingsPlanResponse { } export interface DescribeSavingsPlanRatesRequest { /** * The ID of the Savings Plan. */ savingsPlanId: SavingsPlanId; /** * The filters. */ filters?: SavingsPlanRateFilterList; /** * The token for the next page of results. */ nextToken?: PaginationToken; /** * The maximum number of results to return with a single call. To retrieve additional results, make another call with the returned token value. */ maxResults?: MaxResults; } export interface DescribeSavingsPlanRatesResponse { /** * The ID of the Savings Plan. */ savingsPlanId?: SavingsPlanId; /** * Information about the Savings Plans rates. */ searchResults?: SavingsPlanRateList; /** * The token to use to retrieve the next page of results. This value is null when there are no more results to return. */ nextToken?: PaginationToken; } export interface DescribeSavingsPlansOfferingRatesRequest { /** * The IDs of the offerings. */ savingsPlanOfferingIds?: UUIDs; /** * The payment options. */ savingsPlanPaymentOptions?: SavingsPlanPaymentOptionList; /** * The plan types. */ savingsPlanTypes?: SavingsPlanTypeList; /** * The AWS products. */ products?: SavingsPlanProductTypeList; /** * The services. */ serviceCodes?: SavingsPlanRateServiceCodeList; /** * The usage details of the line item in the billing report. */ usageTypes?: SavingsPlanRateUsageTypeList; /** * The specific AWS operation for the line item in the billing report. */ operations?: SavingsPlanRateOperationList; /** * The filters. */ filters?: SavingsPlanOfferingRateFiltersList; /** * The token for the next page of results. */ nextToken?: PaginationToken; /** * The maximum number of results to return with a single call. To retrieve additional results, make another call with the returned token value. */ maxResults?: PageSize; } export interface DescribeSavingsPlansOfferingRatesResponse { /** * Information about the Savings Plans offering rates. */ searchResults?: SavingsPlanOfferingRatesList; /** * The token to use to retrieve the next page of results. This value is null when there are no more results to return. */ nextToken?: PaginationToken; } export interface DescribeSavingsPlansOfferingsRequest { /** * The IDs of the offerings. */ offeringIds?: UUIDs; /** * The payment options. */ paymentOptions?: SavingsPlanPaymentOptionList; /** * The product type. */ productType?: SavingsPlanProductType; /** * The plan type. */ planTypes?: SavingsPlanTypeList; /** * The durations, in seconds. */ durations?: DurationsList; /** * The currencies. */ currencies?: CurrencyList; /** * The descriptions. */ descriptions?: SavingsPlanDescriptionsList; /** * The services. */ serviceCodes?: SavingsPlanServiceCodeList; /** * The usage details of the line item in the billing report. */ usageTypes?: SavingsPlanUsageTypeList; /** * The specific AWS operation for the line item in the billing report. */ operations?: SavingsPlanOperationList; /** * The filters. */ filters?: SavingsPlanOfferingFiltersList; /** * The token for the next page of results. */ nextToken?: PaginationToken; /** * The maximum number of results to return with a single call. To retrieve additional results, make another call with the returned token value. */ maxResults?: PageSize; } export interface DescribeSavingsPlansOfferingsResponse { /** * Information about the Savings Plans offerings. */ searchResults?: SavingsPlanOfferingsList; /** * The token to use to retrieve the next page of results. This value is null when there are no more results to return. */ nextToken?: PaginationToken; } export interface DescribeSavingsPlansRequest { /** * The Amazon Resource Names (ARN) of the Savings Plans. */ savingsPlanArns?: SavingsPlanArnList; /** * The IDs of the Savings Plans. */ savingsPlanIds?: SavingsPlanIdList; /** * The token for the next page of results. */ nextToken?: PaginationToken; /** * The maximum number of results to return with a single call. To retrieve additional results, make another call with the returned token value. */ maxResults?: MaxResults; /** * The states. */ states?: SavingsPlanStateList; /** * The filters. */ filters?: SavingsPlanFilterList; } export interface DescribeSavingsPlansResponse { /** * Information about the Savings Plans. */ savingsPlans?: SavingsPlanList; /** * The token to use to retrieve the next page of results. This value is null when there are no more results to return. */ nextToken?: PaginationToken; } export type DurationsList = SavingsPlansDuration[]; export type EC2InstanceFamily = string; export type FilterValuesList = JsonSafeFilterValueString[]; export type JsonSafeFilterValueString = string; export type ListOfStrings = String[]; export interface ListTagsForResourceRequest { /** * The Amazon Resource Name (ARN) of the resource. */ resourceArn: SavingsPlanArn; } export interface ListTagsForResourceResponse { /** * Information about the tags. */ tags?: TagMap; } export type MaxResults = number; export type PageSize = number; export type PaginationToken = string; export interface ParentSavingsPlanOffering { /** * The ID of the offering. */ offeringId?: UUID; /** * The payment option. */ paymentOption?: SavingsPlanPaymentOption; /** * The plan type. */ planType?: SavingsPlanType; /** * The duration, in seconds. */ durationSeconds?: SavingsPlansDuration; /** * The currency. */ currency?: CurrencyCode; /** * The description. */ planDescription?: SavingsPlanDescription; } export type Region = string; export interface SavingsPlan { /** * The ID of the offering. */ offeringId?: SavingsPlanOfferingId; /** * The ID of the Savings Plan. */ savingsPlanId?: SavingsPlanId; /** * The Amazon Resource Name (ARN) of the Savings Plan. */ savingsPlanArn?: SavingsPlanArn; /** * The description. */ description?: String; /** * The start time. */ start?: String; /** * The end time. */ end?: String; /** * The state. */ state?: SavingsPlanState; /** * The AWS Region. */ region?: Region; /** * The EC2 instance family. */ ec2InstanceFamily?: EC2InstanceFamily; /** * The plan type. */ savingsPlanType?: SavingsPlanType; /** * The payment option. */ paymentOption?: SavingsPlanPaymentOption; /** * The product types. */ productTypes?: SavingsPlanProductTypeList; /** * The currency. */ currency?: CurrencyCode; /** * The hourly commitment, in USD. */ commitment?: Amount; /** * The up-front payment amount. */ upfrontPaymentAmount?: Amount; /** * The recurring payment amount. */ recurringPaymentAmount?: Amount; /** * The duration of the term, in seconds. */ termDurationInSeconds?: TermDurationInSeconds; /** * One or more tags. */ tags?: TagMap; } export type SavingsPlanArn = string; export type SavingsPlanArnList = SavingsPlanArn[]; export type SavingsPlanDescription = string; export type SavingsPlanDescriptionsList = SavingsPlanDescription[]; export interface SavingsPlanFilter { /** * The filter name. */ name?: SavingsPlansFilterName; /** * The filter value. */ values?: ListOfStrings; } export type SavingsPlanFilterList = SavingsPlanFilter[]; export type SavingsPlanId = string; export type SavingsPlanIdList = SavingsPlanId[]; export type SavingsPlanList = SavingsPlan[]; export interface SavingsPlanOffering { /** * The ID of the offering. */ offeringId?: UUID; /** * The product type. */ productTypes?: SavingsPlanProductTypeList; /** * The plan type. */ planType?: SavingsPlanType; /** * The description. */ description?: SavingsPlanDescription; /** * The payment option. */ paymentOption?: SavingsPlanPaymentOption; /** * The duration, in seconds. */ durationSeconds?: SavingsPlansDuration; /** * The currency. */ currency?: CurrencyCode; /** * The service. */ serviceCode?: SavingsPlanServiceCode; /** * The usage details of the line item in the billing report. */ usageType?: SavingsPlanUsageType; /** * The specific AWS operation for the line item in the billing report. */ operation?: SavingsPlanOperation; /** * The properties. */ properties?: SavingsPlanOfferingPropertyList; } export type SavingsPlanOfferingFilterAttribute = "region"|"instanceFamily"|string; export interface SavingsPlanOfferingFilterElement { /** * The filter name. */ name?: SavingsPlanOfferingFilterAttribute; /** * The filter values. */ values?: FilterValuesList; } export type SavingsPlanOfferingFiltersList = SavingsPlanOfferingFilterElement[]; export type SavingsPlanOfferingId = string; export interface SavingsPlanOfferingProperty { /** * The property name. */ name?: SavingsPlanOfferingPropertyKey; /** * The property value. */ value?: JsonSafeFilterValueString; } export type SavingsPlanOfferingPropertyKey = "region"|"instanceFamily"|string; export type SavingsPlanOfferingPropertyList = SavingsPlanOfferingProperty[]; export interface SavingsPlanOfferingRate { /** * The Savings Plan offering. */ savingsPlanOffering?: ParentSavingsPlanOffering; /** * The Savings Plan rate. */ rate?: SavingsPlanRatePricePerUnit; /** * The unit. */ unit?: SavingsPlanRateUnit; /** * The product type. */ productType?: SavingsPlanProductType; /** * The service. */ serviceCode?: SavingsPlanRateServiceCode; /** * The usage details of the line item in the billing report. */ usageType?: SavingsPlanRateUsageType; /** * The specific AWS operation for the line item in the billing report. */ operation?: SavingsPlanRateOperation; /** * The properties. */ properties?: SavingsPlanOfferingRatePropertyList; } export interface SavingsPlanOfferingRateFilterElement { /** * The filter name. */ name?: SavingsPlanRateFilterAttribute; /** * The filter values. */ values?: FilterValuesList; } export type SavingsPlanOfferingRateFiltersList = SavingsPlanOfferingRateFilterElement[]; export interface SavingsPlanOfferingRateProperty { /** * The property name. */ name?: JsonSafeFilterValueString; /** * The property value. */ value?: JsonSafeFilterValueString; } export type SavingsPlanOfferingRatePropertyList = SavingsPlanOfferingRateProperty[]; export type SavingsPlanOfferingRatesList = SavingsPlanOfferingRate[]; export type SavingsPlanOfferingsList = SavingsPlanOffering[]; export type SavingsPlanOperation = string; export type SavingsPlanOperationList = SavingsPlanOperation[]; export type SavingsPlanPaymentOption = "All Upfront"|"Partial Upfront"|"No Upfront"|string; export type SavingsPlanPaymentOptionList = SavingsPlanPaymentOption[]; export type SavingsPlanProductType = "EC2"|"Fargate"|"Lambda"|string; export type SavingsPlanProductTypeList = SavingsPlanProductType[]; export interface SavingsPlanRate { /** * The rate. */ rate?: Amount; /** * The currency. */ currency?: CurrencyCode; /** * The unit. */ unit?: SavingsPlanRateUnit; /** * The product type. */ productType?: SavingsPlanProductType; /** * The service. */ serviceCode?: SavingsPlanRateServiceCode; /** * The usage details of the line item in the billing report. */ usageType?: SavingsPlanRateUsageType; /** * The specific AWS operation for the line item in the billing report. */ operation?: SavingsPlanRateOperation; /** * The properties. */ properties?: SavingsPlanRatePropertyList; } export interface SavingsPlanRateFilter { /** * The filter name. */ name?: SavingsPlanRateFilterName; /** * The filter values. */ values?: ListOfStrings; } export type SavingsPlanRateFilterAttribute = "region"|"instanceFamily"|"instanceType"|"productDescription"|"tenancy"|"productId"|string; export type SavingsPlanRateFilterList = SavingsPlanRateFilter[]; export type SavingsPlanRateFilterName = "region"|"instanceType"|"productDescription"|"tenancy"|"productType"|"serviceCode"|"usageType"|"operation"|string; export type SavingsPlanRateList = SavingsPlanRate[]; export type SavingsPlanRateOperation = string; export type SavingsPlanRateOperationList = SavingsPlanRateOperation[]; export type SavingsPlanRatePricePerUnit = string; export interface SavingsPlanRateProperty { /** * The property name. */ name?: SavingsPlanRatePropertyKey; /** * The property value. */ value?: JsonSafeFilterValueString; } export type SavingsPlanRatePropertyKey = "region"|"instanceType"|"instanceFamily"|"productDescription"|"tenancy"|string; export type SavingsPlanRatePropertyList = SavingsPlanRateProperty[]; export type SavingsPlanRateServiceCode = "AmazonEC2"|"AmazonECS"|"AWSLambda"|string; export type SavingsPlanRateServiceCodeList = SavingsPlanRateServiceCode[]; export type SavingsPlanRateUnit = "Hrs"|"Lambda-GB-Second"|"Request"|string; export type SavingsPlanRateUsageType = string; export type SavingsPlanRateUsageTypeList = SavingsPlanRateUsageType[]; export type SavingsPlanServiceCode = string; export type SavingsPlanServiceCodeList = SavingsPlanServiceCode[]; export type SavingsPlanState = "payment-pending"|"payment-failed"|"active"|"retired"|"queued"|"queued-deleted"|string; export type SavingsPlanStateList = SavingsPlanState[]; export type SavingsPlanType = "Compute"|"EC2Instance"|string; export type SavingsPlanTypeList = SavingsPlanType[]; export type SavingsPlanUsageType = string; export type SavingsPlanUsageTypeList = SavingsPlanUsageType[]; export type SavingsPlansDuration = number; export type SavingsPlansFilterName = "region"|"ec2-instance-family"|"commitment"|"upfront"|"term"|"savings-plan-type"|"payment-option"|"start"|"end"|string; export type String = string; export type TagKey = string; export type TagKeyList = TagKey[]; export type TagMap = {[key: string]: TagValue}; export interface TagResourceRequest { /** * The Amazon Resource Name (ARN) of the resource. */ resourceArn: SavingsPlanArn; /** * One or more tags. For example, { "tags": {"key1":"value1", "key2":"value2"} }. */ tags: TagMap; } export interface TagResourceResponse { } export type TagValue = string; export type TermDurationInSeconds = number; export type UUID = string; export type UUIDs = UUID[]; export interface UntagResourceRequest { /** * The Amazon Resource Name (ARN) of the resource. */ resourceArn: SavingsPlanArn; /** * The tag keys. */ tagKeys: TagKeyList; } export interface UntagResourceResponse { } /** * A string in YYYY-MM-DD format that represents the latest possible API version that can be used in this service. Specify 'latest' to use the latest possible version. */ export type apiVersion = "2019-06-28"|"latest"|string; export interface ClientApiVersions { /** * A string in YYYY-MM-DD format that represents the latest possible API version that can be used in this service. Specify 'latest' to use the latest possible version. */ apiVersion?: apiVersion; } export type ClientConfiguration = ServiceConfigurationOptions & ClientApiVersions; /** * Contains interfaces for use with the SavingsPlans client. */ export import Types = SavingsPlans; } export = SavingsPlans;
{ "pile_set_name": "Github" }
// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2013, Intel Corporation. * * MEI Library for mei bus nfc device access */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> #include <linux/slab.h> #include <linux/nfc.h> #include "mei_phy.h" struct mei_nfc_hdr { u8 cmd; u8 status; u16 req_id; u32 reserved; u16 data_size; } __packed; struct mei_nfc_cmd { struct mei_nfc_hdr hdr; u8 sub_command; u8 data[]; } __packed; struct mei_nfc_reply { struct mei_nfc_hdr hdr; u8 sub_command; u8 reply_status; u8 data[]; } __packed; struct mei_nfc_if_version { u8 radio_version_sw[3]; u8 reserved[3]; u8 radio_version_hw[3]; u8 i2c_addr; u8 fw_ivn; u8 vendor_id; u8 radio_type; } __packed; struct mei_nfc_connect { u8 fw_ivn; u8 vendor_id; } __packed; struct mei_nfc_connect_resp { u8 fw_ivn; u8 vendor_id; u16 me_major; u16 me_minor; u16 me_hotfix; u16 me_build; } __packed; #define MEI_NFC_CMD_MAINTENANCE 0x00 #define MEI_NFC_CMD_HCI_SEND 0x01 #define MEI_NFC_CMD_HCI_RECV 0x02 #define MEI_NFC_SUBCMD_CONNECT 0x00 #define MEI_NFC_SUBCMD_IF_VERSION 0x01 #define MEI_NFC_MAX_READ (MEI_NFC_HEADER_SIZE + MEI_NFC_MAX_HCI_PAYLOAD) #define MEI_DUMP_SKB_IN(info, skb) \ do { \ pr_debug("%s:\n", info); \ print_hex_dump_debug("mei in : ", DUMP_PREFIX_OFFSET, \ 16, 1, (skb)->data, (skb)->len, false); \ } while (0) #define MEI_DUMP_SKB_OUT(info, skb) \ do { \ pr_debug("%s:\n", info); \ print_hex_dump_debug("mei out: ", DUMP_PREFIX_OFFSET, \ 16, 1, (skb)->data, (skb)->len, false); \ } while (0) #define MEI_DUMP_NFC_HDR(info, _hdr) \ do { \ pr_debug("%s:\n", info); \ pr_debug("cmd=%02d status=%d req_id=%d rsvd=%d size=%d\n", \ (_hdr)->cmd, (_hdr)->status, (_hdr)->req_id, \ (_hdr)->reserved, (_hdr)->data_size); \ } while (0) static int mei_nfc_if_version(struct nfc_mei_phy *phy) { struct mei_nfc_cmd cmd; struct mei_nfc_reply *reply = NULL; struct mei_nfc_if_version *version; size_t if_version_length; int bytes_recv, r; pr_info("%s\n", __func__); memset(&cmd, 0, sizeof(struct mei_nfc_cmd)); cmd.hdr.cmd = MEI_NFC_CMD_MAINTENANCE; cmd.hdr.data_size = 1; cmd.sub_command = MEI_NFC_SUBCMD_IF_VERSION; MEI_DUMP_NFC_HDR("version", &cmd.hdr); r = mei_cldev_send(phy->cldev, (u8 *)&cmd, sizeof(struct mei_nfc_cmd)); if (r < 0) { pr_err("Could not send IF version cmd\n"); return r; } /* to be sure on the stack we alloc memory */ if_version_length = sizeof(struct mei_nfc_reply) + sizeof(struct mei_nfc_if_version); reply = kzalloc(if_version_length, GFP_KERNEL); if (!reply) return -ENOMEM; bytes_recv = mei_cldev_recv(phy->cldev, (u8 *)reply, if_version_length); if (bytes_recv < 0 || bytes_recv < if_version_length) { pr_err("Could not read IF version\n"); r = -EIO; goto err; } version = (struct mei_nfc_if_version *)reply->data; phy->fw_ivn = version->fw_ivn; phy->vendor_id = version->vendor_id; phy->radio_type = version->radio_type; err: kfree(reply); return r; } static int mei_nfc_connect(struct nfc_mei_phy *phy) { struct mei_nfc_cmd *cmd, *reply; struct mei_nfc_connect *connect; struct mei_nfc_connect_resp *connect_resp; size_t connect_length, connect_resp_length; int bytes_recv, r; pr_info("%s\n", __func__); connect_length = sizeof(struct mei_nfc_cmd) + sizeof(struct mei_nfc_connect); connect_resp_length = sizeof(struct mei_nfc_cmd) + sizeof(struct mei_nfc_connect_resp); cmd = kzalloc(connect_length, GFP_KERNEL); if (!cmd) return -ENOMEM; connect = (struct mei_nfc_connect *)cmd->data; reply = kzalloc(connect_resp_length, GFP_KERNEL); if (!reply) { kfree(cmd); return -ENOMEM; } connect_resp = (struct mei_nfc_connect_resp *)reply->data; cmd->hdr.cmd = MEI_NFC_CMD_MAINTENANCE; cmd->hdr.data_size = 3; cmd->sub_command = MEI_NFC_SUBCMD_CONNECT; connect->fw_ivn = phy->fw_ivn; connect->vendor_id = phy->vendor_id; MEI_DUMP_NFC_HDR("connect request", &cmd->hdr); r = mei_cldev_send(phy->cldev, (u8 *)cmd, connect_length); if (r < 0) { pr_err("Could not send connect cmd %d\n", r); goto err; } bytes_recv = mei_cldev_recv(phy->cldev, (u8 *)reply, connect_resp_length); if (bytes_recv < 0) { r = bytes_recv; pr_err("Could not read connect response %d\n", r); goto err; } MEI_DUMP_NFC_HDR("connect reply", &reply->hdr); pr_info("IVN 0x%x Vendor ID 0x%x\n", connect_resp->fw_ivn, connect_resp->vendor_id); pr_info("ME FW %d.%d.%d.%d\n", connect_resp->me_major, connect_resp->me_minor, connect_resp->me_hotfix, connect_resp->me_build); r = 0; err: kfree(reply); kfree(cmd); return r; } static int mei_nfc_send(struct nfc_mei_phy *phy, u8 *buf, size_t length) { struct mei_nfc_hdr *hdr; u8 *mei_buf; int err; err = -ENOMEM; mei_buf = kzalloc(length + MEI_NFC_HEADER_SIZE, GFP_KERNEL); if (!mei_buf) goto out; hdr = (struct mei_nfc_hdr *)mei_buf; hdr->cmd = MEI_NFC_CMD_HCI_SEND; hdr->status = 0; hdr->req_id = phy->req_id; hdr->reserved = 0; hdr->data_size = length; MEI_DUMP_NFC_HDR("send", hdr); memcpy(mei_buf + MEI_NFC_HEADER_SIZE, buf, length); err = mei_cldev_send(phy->cldev, mei_buf, length + MEI_NFC_HEADER_SIZE); if (err < 0) goto out; if (!wait_event_interruptible_timeout(phy->send_wq, phy->recv_req_id == phy->req_id, HZ)) { pr_err("NFC MEI command timeout\n"); err = -ETIME; } else { phy->req_id++; } out: kfree(mei_buf); return err; } /* * Writing a frame must not return the number of written bytes. * It must return either zero for success, or <0 for error. * In addition, it must not alter the skb */ static int nfc_mei_phy_write(void *phy_id, struct sk_buff *skb) { struct nfc_mei_phy *phy = phy_id; int r; MEI_DUMP_SKB_OUT("mei frame sent", skb); r = mei_nfc_send(phy, skb->data, skb->len); if (r > 0) r = 0; return r; } static int mei_nfc_recv(struct nfc_mei_phy *phy, u8 *buf, size_t length) { struct mei_nfc_hdr *hdr; int received_length; received_length = mei_cldev_recv(phy->cldev, buf, length); if (received_length < 0) return received_length; hdr = (struct mei_nfc_hdr *) buf; MEI_DUMP_NFC_HDR("receive", hdr); if (hdr->cmd == MEI_NFC_CMD_HCI_SEND) { phy->recv_req_id = hdr->req_id; wake_up(&phy->send_wq); return 0; } return received_length; } static void nfc_mei_rx_cb(struct mei_cl_device *cldev) { struct nfc_mei_phy *phy = mei_cldev_get_drvdata(cldev); struct sk_buff *skb; int reply_size; if (!phy) return; if (phy->hard_fault != 0) return; skb = alloc_skb(MEI_NFC_MAX_READ, GFP_KERNEL); if (!skb) return; reply_size = mei_nfc_recv(phy, skb->data, MEI_NFC_MAX_READ); if (reply_size < MEI_NFC_HEADER_SIZE) { kfree_skb(skb); return; } skb_put(skb, reply_size); skb_pull(skb, MEI_NFC_HEADER_SIZE); MEI_DUMP_SKB_IN("mei frame read", skb); nfc_hci_recv_frame(phy->hdev, skb); } static int nfc_mei_phy_enable(void *phy_id) { int r; struct nfc_mei_phy *phy = phy_id; pr_info("%s\n", __func__); if (phy->powered == 1) return 0; r = mei_cldev_enable(phy->cldev); if (r < 0) { pr_err("Could not enable device %d\n", r); return r; } r = mei_nfc_if_version(phy); if (r < 0) { pr_err("Could not enable device %d\n", r); goto err; } r = mei_nfc_connect(phy); if (r < 0) { pr_err("Could not connect to device %d\n", r); goto err; } r = mei_cldev_register_rx_cb(phy->cldev, nfc_mei_rx_cb); if (r) { pr_err("Event cb registration failed %d\n", r); goto err; } phy->powered = 1; return 0; err: phy->powered = 0; mei_cldev_disable(phy->cldev); return r; } static void nfc_mei_phy_disable(void *phy_id) { struct nfc_mei_phy *phy = phy_id; pr_info("%s\n", __func__); mei_cldev_disable(phy->cldev); phy->powered = 0; } struct nfc_phy_ops mei_phy_ops = { .write = nfc_mei_phy_write, .enable = nfc_mei_phy_enable, .disable = nfc_mei_phy_disable, }; EXPORT_SYMBOL_GPL(mei_phy_ops); struct nfc_mei_phy *nfc_mei_phy_alloc(struct mei_cl_device *cldev) { struct nfc_mei_phy *phy; phy = kzalloc(sizeof(struct nfc_mei_phy), GFP_KERNEL); if (!phy) return NULL; phy->cldev = cldev; init_waitqueue_head(&phy->send_wq); mei_cldev_set_drvdata(cldev, phy); return phy; } EXPORT_SYMBOL_GPL(nfc_mei_phy_alloc); void nfc_mei_phy_free(struct nfc_mei_phy *phy) { mei_cldev_disable(phy->cldev); kfree(phy); } EXPORT_SYMBOL_GPL(nfc_mei_phy_free); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("mei bus NFC device interface");
{ "pile_set_name": "Github" }
/* * Copyright 2014 Red Hat Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Authors: Ben Skeggs <[email protected]> */ #include <core/notify.h> #include <core/event.h> static inline void nvkm_notify_put_locked(struct nvkm_notify *notify) { if (notify->block++ == 0) nvkm_event_put(notify->event, notify->types, notify->index); } void nvkm_notify_put(struct nvkm_notify *notify) { struct nvkm_event *event = notify->event; unsigned long flags; if (likely(event) && test_and_clear_bit(NVKM_NOTIFY_USER, &notify->flags)) { spin_lock_irqsave(&event->refs_lock, flags); nvkm_notify_put_locked(notify); spin_unlock_irqrestore(&event->refs_lock, flags); if (test_bit(NVKM_NOTIFY_WORK, &notify->flags)) flush_work(&notify->work); } } static inline void nvkm_notify_get_locked(struct nvkm_notify *notify) { if (--notify->block == 0) nvkm_event_get(notify->event, notify->types, notify->index); } void nvkm_notify_get(struct nvkm_notify *notify) { struct nvkm_event *event = notify->event; unsigned long flags; if (likely(event) && !test_and_set_bit(NVKM_NOTIFY_USER, &notify->flags)) { spin_lock_irqsave(&event->refs_lock, flags); nvkm_notify_get_locked(notify); spin_unlock_irqrestore(&event->refs_lock, flags); } } static inline void nvkm_notify_func(struct nvkm_notify *notify) { struct nvkm_event *event = notify->event; int ret = notify->func(notify); unsigned long flags; if ((ret == NVKM_NOTIFY_KEEP) || !test_and_clear_bit(NVKM_NOTIFY_USER, &notify->flags)) { spin_lock_irqsave(&event->refs_lock, flags); nvkm_notify_get_locked(notify); spin_unlock_irqrestore(&event->refs_lock, flags); } } static void nvkm_notify_work(struct work_struct *work) { struct nvkm_notify *notify = container_of(work, typeof(*notify), work); nvkm_notify_func(notify); } void nvkm_notify_send(struct nvkm_notify *notify, void *data, u32 size) { struct nvkm_event *event = notify->event; unsigned long flags; assert_spin_locked(&event->list_lock); BUG_ON(size != notify->size); spin_lock_irqsave(&event->refs_lock, flags); if (notify->block) { spin_unlock_irqrestore(&event->refs_lock, flags); return; } nvkm_notify_put_locked(notify); spin_unlock_irqrestore(&event->refs_lock, flags); if (test_bit(NVKM_NOTIFY_WORK, &notify->flags)) { memcpy((void *)notify->data, data, size); schedule_work(&notify->work); } else { notify->data = data; nvkm_notify_func(notify); notify->data = NULL; } } void nvkm_notify_fini(struct nvkm_notify *notify) { unsigned long flags; if (notify->event) { nvkm_notify_put(notify); spin_lock_irqsave(&notify->event->list_lock, flags); list_del(&notify->head); spin_unlock_irqrestore(&notify->event->list_lock, flags); kfree((void *)notify->data); notify->event = NULL; } } int nvkm_notify_init(struct nvkm_object *object, struct nvkm_event *event, int (*func)(struct nvkm_notify *), bool work, void *data, u32 size, u32 reply, struct nvkm_notify *notify) { unsigned long flags; int ret = -ENODEV; if ((notify->event = event), event->refs) { ret = event->func->ctor(object, data, size, notify); if (ret == 0 && (ret = -EINVAL, notify->size == reply)) { notify->flags = 0; notify->block = 1; notify->func = func; notify->data = NULL; if (ret = 0, work) { INIT_WORK(&notify->work, nvkm_notify_work); set_bit(NVKM_NOTIFY_WORK, &notify->flags); notify->data = kmalloc(reply, GFP_KERNEL); if (!notify->data) ret = -ENOMEM; } } if (ret == 0) { spin_lock_irqsave(&event->list_lock, flags); list_add_tail(&notify->head, &event->list); spin_unlock_irqrestore(&event->list_lock, flags); } } if (ret) notify->event = NULL; return ret; }
{ "pile_set_name": "Github" }
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Jun 9 2015 22:53:21). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2014 by Steve Nygard. // #import "IPropertyTextExtractor.h" @interface TPropertySavedSearchQueryExtractor : IPropertyTextExtractor { } - (_Bool)isApplicableToNodes:(const struct TFENodeVector *)arg1; - (_Bool)needsUpdateForProperty:(unsigned int)arg1; - (id)extractValueFromNodes:(const struct TFENodeVector *)arg1; @end
{ "pile_set_name": "Github" }
// Catalano Android Imaging Library // The Catalano Framework // // Copyright © Diego Catalano, 2012-2016 // diego.catalano at live.com // // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // package Catalano.Imaging.Filters; import Catalano.Imaging.FastBitmap; import Catalano.Imaging.IApplyInPlace; /** * Minimum filter. * <br /> Minimum filter - set minimum pixel values using radius. * @author Diego Catalano */ public class Minimum implements IApplyInPlace{ private int radius = 1; /** * Initialize a new instance of the Maximum class. */ public Minimum() {} /** * Initialize a new instance of the Maximum class. * @param radius Radius. */ public Minimum(int radius){ radius = radius < 1 ? 1 : radius; this.radius = radius; } /** * Radius. * @return Radius. */ public int getRadius() { return radius; } /** * Radius. * @param radius Radius. */ public void setRadius(int radius) { this.radius = radius; } @Override public void applyInPlace(FastBitmap sourceImage){ int width = sourceImage.getWidth(); int height = sourceImage.getHeight(); FastBitmap copy = new FastBitmap(sourceImage); int Xline,Yline; int lines = CalcLines(radius); if (sourceImage.isGrayscale()) { int minG; for (int x = 0; x < height; x++) { for (int y = 0; y < width; y++) { minG = 255; for (int i = 0; i < lines; i++) { Xline = x + (i-radius); for (int j = 0; j < lines; j++) { Yline = y + (j-radius); if ((Xline >= 0) && (Xline < height) && (Yline >=0) && (Yline < width)) { minG = Math.min(minG,copy.getGray(Xline, Yline)); } } } sourceImage.setGray(x, y, minG); } } } if (sourceImage.isRGB()){ int minR; int minG; int minB; for (int x = 0; x < height; x++) { for (int y = 0; y < width; y++) { minR = minG = minB = 255; for (int i = 0; i < lines; i++) { Xline = x + (i-radius); for (int j = 0; j < lines; j++) { Yline = y + (j-radius); if ((Xline >= 0) && (Xline < height) && (Yline >=0) && (Yline < width)) { minR = Math.min(minR,copy.getRed(Xline, Yline)); minG = Math.min(minG,copy.getGreen(Xline, Yline)); minB = Math.min(minB,copy.getBlue(Xline, Yline)); } } } sourceImage.setRGB(x, y, minR, minG, minB); } } } } private int CalcLines(int radius){ return radius * 2 + 1; } }
{ "pile_set_name": "Github" }
<html> <head> <title>vorbisfile - vorbisfile_example.c</title> <link rel=stylesheet href="style.css" type="text/css"> </head> <body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff"> <table border=0 width=100%> <tr> <td><p class=tiny>Vorbisfile documentation</p></td> <td align=right><p class=tiny>vorbisfile version 1.3.2 - 20101101</p></td> </tr> </table> <h1>vorbisfile_example.c</h1> <p> The example program source: <br><br> <table border=0 width=100% color=black cellspacing=0 cellpadding=7> <tr bgcolor=#cccccc> <td> <pre><b> #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;math.h&gt; #include "vorbis/codec.h" #include "vorbis/vorbisfile.h" #ifdef _WIN32 #include &lt;io.h&gt; #include &lt;fcntl.h&gt; #endif char pcmout[4096]; int main(int argc, char **argv){ OggVorbis_File vf; int eof=0; int current_section; #ifdef _WIN32 _setmode( _fileno( stdin ), _O_BINARY ); _setmode( _fileno( stdout ), _O_BINARY ); #endif if(ov_open_callbacks(stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE) < 0) { fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n"); exit(1); } { char **ptr=ov_comment(&vf,-1)->user_comments; vorbis_info *vi=ov_info(&vf,-1); while(*ptr){ fprintf(stderr,"%s\n",*ptr); ++ptr; } fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate); fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor); } while(!eof){ long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,&current_section); if (ret == 0) { /* EOF */ eof=1; } else if (ret < 0) { /* error in the stream. Not a problem, just reporting it in case we (the app) cares. In this case, we don't. */ } else { /* we don't bother dealing with sample rate changes, etc, but you'll have to */ fwrite(pcmout,1,ret,stdout); } } ov_clear(&vf); fprintf(stderr,"Done.\n"); return(0); } </b></pre> </td> </tr> </table> <br><br> <hr noshade> <table border=0 width=100%> <tr valign=top> <td><p class=tiny>copyright &copy; 2000-2010 Xiph.Org</p></td> <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/index.html">Ogg Vorbis</a></p></td> </tr><tr> <td><p class=tiny>Vorbisfile documentation</p></td> <td align=right><p class=tiny>vorbisfile version 1.3.2 - 20101101</p></td> </tr> </table> </body> </html>
{ "pile_set_name": "Github" }
/************************************************************************* * * Copyright 2016 Realm 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. * **************************************************************************/ #ifndef REALM_ARRAY_BASIC_TPL_HPP #define REALM_ARRAY_BASIC_TPL_HPP #include <algorithm> #include <limits> #include <stdexcept> #include <iomanip> #include <realm/impl/destroy_guard.hpp> namespace realm { template <class T> inline BasicArray<T>::BasicArray(Allocator& allocator) noexcept : Array(allocator) { } template <class T> inline MemRef BasicArray<T>::create_array(size_t init_size, Allocator& allocator) { size_t byte_size_0 = calc_aligned_byte_size(init_size); // Throws // Adding zero to Array::initial_capacity to avoid taking the // address of that member size_t byte_size = std::max(byte_size_0, Array::initial_capacity + 0); // Throws MemRef mem = allocator.alloc(byte_size); // Throws bool is_inner_bptree_node = false; bool has_refs = false; bool context_flag = false; int width = sizeof(T); init_header(mem.get_addr(), is_inner_bptree_node, has_refs, context_flag, wtype_Multiply, width, init_size, byte_size); return mem; } template <class T> inline MemRef BasicArray<T>::create_array(Array::Type type, bool context_flag, size_t init_size, T value, Allocator& allocator) { REALM_ASSERT(type == Array::type_Normal); REALM_ASSERT(!context_flag); MemRef mem = create_array(init_size, allocator); if (init_size) { BasicArray<T> tmp(allocator); tmp.init_from_mem(mem); T* p = reinterpret_cast<T*>(tmp.m_data); T* end = p + init_size; while (p < end) { *p++ = value; } } return mem; } template <class T> inline void BasicArray<T>::create(Array::Type type, bool context_flag) { REALM_ASSERT(type == Array::type_Normal); REALM_ASSERT(!context_flag); size_t length = 0; MemRef mem = create_array(length, get_alloc()); // Throws init_from_mem(mem); } template <class T> MemRef BasicArray<T>::slice(size_t offset, size_t slice_size, Allocator& target_alloc) const { REALM_ASSERT(is_attached()); // FIXME: This can be optimized as a single contiguous copy // operation. BasicArray array_slice(target_alloc); _impl::ShallowArrayDestroyGuard dg(&array_slice); array_slice.create(); // Throws size_t begin = offset; size_t end = offset + slice_size; for (size_t i = begin; i != end; ++i) { T value = get(i); array_slice.add(value); // Throws } dg.release(); return array_slice.get_mem(); } template <class T> MemRef BasicArray<T>::slice_and_clone_children(size_t offset, size_t slice_size, Allocator& target_alloc) const { // BasicArray<T> never contains refs, so never has children. return slice(offset, slice_size, target_alloc); } template <class T> inline void BasicArray<T>::add(T value) { insert(m_size, value); } template <class T> inline T BasicArray<T>::get(size_t ndx) const noexcept { return *(reinterpret_cast<const T*>(m_data) + ndx); } template <class T> inline bool BasicArray<T>::is_null(size_t ndx) const noexcept { // FIXME: This assumes BasicArray will only ever be instantiated for float-like T. static_assert(realm::is_any<T, float, double>::value, "T can only be float or double"); auto x = get(ndx); return null::is_null_float(x); } template <class T> inline T BasicArray<T>::get(const char* header, size_t ndx) noexcept { const char* data = get_data_from_header(header); // This casting assumes that T can be aliged on an 8-bype // boundary (since data is aligned on an 8-byte boundary.) return *(reinterpret_cast<const T*>(data) + ndx); } template <class T> inline void BasicArray<T>::set(size_t ndx, T value) { REALM_ASSERT_3(ndx, <, m_size); if (get(ndx) == value) return; // Check if we need to copy before modifying copy_on_write(); // Throws // Set the value T* data = reinterpret_cast<T*>(m_data) + ndx; *data = value; } template <class T> inline void BasicArray<T>::set_null(size_t ndx) { // FIXME: This assumes BasicArray will only ever be instantiated for float-like T. set(ndx, null::get_null_float<T>()); } template <class T> void BasicArray<T>::insert(size_t ndx, T value) { REALM_ASSERT_3(ndx, <=, m_size); // Check if we need to copy before modifying copy_on_write(); // Throws // Make room for the new value alloc(m_size + 1, m_width); // Throws // Move values below insertion if (ndx != m_size) { char* src_begin = m_data + ndx * m_width; char* src_end = m_data + m_size * m_width; char* dst_end = src_end + m_width; std::copy_backward(src_begin, src_end, dst_end); } // Set the value T* data = reinterpret_cast<T*>(m_data) + ndx; *data = value; ++m_size; } template <class T> void BasicArray<T>::erase(size_t ndx) { REALM_ASSERT_3(ndx, <, m_size); // Check if we need to copy before modifying copy_on_write(); // Throws // move data under deletion up if (ndx < m_size - 1) { char* dst_begin = m_data + ndx * m_width; const char* src_begin = dst_begin + m_width; const char* src_end = m_data + m_size * m_width; realm::safe_copy_n(src_begin, src_end - src_begin, dst_begin); } // Update size (also in header) --m_size; set_header_size(m_size); } template <class T> void BasicArray<T>::truncate(size_t to_size) { REALM_ASSERT(is_attached()); REALM_ASSERT_3(to_size, <=, m_size); copy_on_write(); // Throws // Update size in accessor and in header. This leaves the capacity // unchanged. m_size = to_size; set_header_size(to_size); } template <class T> inline void BasicArray<T>::clear() { truncate(0); // Throws } template <class T> bool BasicArray<T>::compare(const BasicArray<T>& a) const { size_t n = size(); if (a.size() != n) return false; const T* data_1 = reinterpret_cast<const T*>(m_data); const T* data_2 = reinterpret_cast<const T*>(a.m_data); return realm::safe_equal(data_1, data_1 + n, data_2); } template <class T> size_t BasicArray<T>::calc_byte_len(size_t for_size, size_t) const { // FIXME: Consider calling `calc_aligned_byte_size(size)` // instead. Note however, that calc_byte_len() is supposed to return // the unaligned byte size. It is probably the case that no harm // is done by returning the aligned version, and most callers of // calc_byte_len() will actually benefit if calc_byte_len() was // changed to always return the aligned byte size. return header_size + for_size * sizeof(T); } template <class T> size_t BasicArray<T>::calc_item_count(size_t bytes, size_t) const noexcept { size_t bytes_without_header = bytes - header_size; return bytes_without_header / sizeof(T); } template <class T> size_t BasicArray<T>::find(T value, size_t begin, size_t end) const { if (end == npos) end = m_size; REALM_ASSERT(begin <= m_size && end <= m_size && begin <= end); const T* data = reinterpret_cast<const T*>(m_data); const T* i = std::find(data + begin, data + end, value); return i == data + end ? not_found : size_t(i - data); } template <class T> inline size_t BasicArray<T>::find_first(T value, size_t begin, size_t end) const { return this->find(value, begin, end); } template <class T> void BasicArray<T>::find_all(IntegerColumn* result, T value, size_t add_offset, size_t begin, size_t end) const { size_t first = begin - 1; for (;;) { first = this->find(value, first + 1, end); if (first == not_found) break; Array::add_to_column(result, first + add_offset); } } template <class T> size_t BasicArray<T>::count(T value, size_t begin, size_t end) const { if (end == npos) end = m_size; REALM_ASSERT(begin <= m_size && end <= m_size && begin <= end); const T* data = reinterpret_cast<const T*>(m_data); return std::count(data + begin, data + end, value); } #if 0 // currently unused template <class T> double BasicArray<T>::sum(size_t begin, size_t end) const { if (end == npos) end = m_size; REALM_ASSERT(begin <= m_size && end <= m_size && begin <= end); const T* data = reinterpret_cast<const T*>(m_data); return std::accumulate(data + begin, data + end, double(0)); } #endif template <class T> template <bool find_max> bool BasicArray<T>::minmax(T& result, size_t begin, size_t end) const { if (end == npos) end = m_size; if (m_size == 0) return false; REALM_ASSERT(begin < m_size && end <= m_size && begin < end); T m = get(begin); ++begin; for (; begin < end; ++begin) { T val = get(begin); if (find_max ? val > m : val < m) m = val; } result = m; return true; } template <class T> bool BasicArray<T>::maximum(T& result, size_t begin, size_t end) const { return minmax<true>(result, begin, end); } template <class T> bool BasicArray<T>::minimum(T& result, size_t begin, size_t end) const { return minmax<false>(result, begin, end); } template <class T> ref_type BasicArray<T>::bptree_leaf_insert(size_t ndx, T value, TreeInsertBase& state) { size_t leaf_size = size(); REALM_ASSERT_3(leaf_size, <=, REALM_MAX_BPNODE_SIZE); if (leaf_size < ndx) ndx = leaf_size; if (REALM_LIKELY(leaf_size < REALM_MAX_BPNODE_SIZE)) { insert(ndx, value); return 0; // Leaf was not split } // Split leaf node BasicArray<T> new_leaf(get_alloc()); new_leaf.create(); // Throws if (ndx == leaf_size) { new_leaf.add(value); state.m_split_offset = ndx; } else { // FIXME: Could be optimized by first resizing the target // array, then copy elements with std::copy(). for (size_t i = ndx; i != leaf_size; ++i) new_leaf.add(get(i)); truncate(ndx); add(value); state.m_split_offset = ndx + 1; } state.m_split_size = leaf_size + 1; return new_leaf.get_ref(); } template <class T> inline size_t BasicArray<T>::lower_bound(T value) const noexcept { const T* begin = reinterpret_cast<const T*>(m_data); const T* end = begin + size(); return std::lower_bound(begin, end, value) - begin; } template <class T> inline size_t BasicArray<T>::upper_bound(T value) const noexcept { const T* begin = reinterpret_cast<const T*>(m_data); const T* end = begin + size(); return std::upper_bound(begin, end, value) - begin; } template <class T> inline size_t BasicArray<T>::calc_aligned_byte_size(size_t size) { size_t max = std::numeric_limits<size_t>::max(); size_t max_2 = max & ~size_t(7); // Allow for upwards 8-byte alignment if (size > (max_2 - header_size) / sizeof(T)) throw std::runtime_error("Byte size overflow"); size_t byte_size = header_size + size * sizeof(T); REALM_ASSERT_3(byte_size, >, 0); size_t aligned_byte_size = ((byte_size - 1) | 7) + 1; // 8-byte alignment return aligned_byte_size; } #ifdef REALM_DEBUG // LCOV_EXCL_START template <class T> void BasicArray<T>::to_dot(std::ostream& out, StringData title) const { ref_type ref = get_ref(); if (title.size() != 0) { out << "subgraph cluster_" << ref << " {\n"; out << " label = \"" << title << "\";\n"; out << " color = white;\n"; } out << "n" << std::hex << ref << std::dec << "[shape=none,label=<"; out << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"4\"><TR>\n"; // Header out << "<TD BGCOLOR=\"lightgrey\"><FONT POINT-SIZE=\"7\"> "; out << "0x" << std::hex << ref << std::dec << "<BR/>"; out << "</FONT></TD>\n"; // Values size_t n = m_size; for (size_t i = 0; i != n; ++i) out << "<TD>" << get(i) << "</TD>\n"; out << "</TR></TABLE>>];\n"; if (title.size() != 0) out << "}\n"; to_dot_parent_edge(out); } // LCOV_EXCL_STOP #endif // REALM_DEBUG } // namespace realm #endif // REALM_ARRAY_BASIC_TPL_HPP
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2"> <file source-language="en" target-language="es" datatype="plaintext" original="not.available"> <body> <trans-unit id="58893b99e0cc6" resname="menu.media"> <source>menu.media</source> <target>Mediateca</target> </trans-unit> <trans-unit id="58893b99e0ce2" resname="nothing"> <source>nothing</source> <target>Vacío</target> </trans-unit> <trans-unit id="58893b99e0ced" resname="title"> <source>title</source> <target>Título</target> </trans-unit> <trans-unit id="58893b99e0cf7" resname="dailymotion"> <source>dailymotion</source> <target>Dailymotion</target> </trans-unit> <trans-unit id="58893b99e0d00" resname="cancel"> <source>cancel</source> <target>Cancelar</target> </trans-unit> <trans-unit id="58893b99e0d0a" resname="delete"> <source>delete</source> <target>Eliminar</target> </trans-unit> <trans-unit id="58893b99e0d13" resname="save"> <source>save</source> <target>Registrar</target> </trans-unit> <trans-unit id="58893b99e0d1d" resname="image"> <source>image</source> <target>Imagen</target> </trans-unit> <trans-unit id="58893b99e0d26" resname="media"> <source>media</source> <target>Media</target> </trans-unit> <trans-unit id="58893b99e0d30" resname="media.aviary.nothing"> <source>media.aviary.nothing</source> <target>No hay nada aquí</target> </trans-unit> <trans-unit id="58893b99e0d39" resname="media.aviary.title"> <source>media.aviary.title</source> <target>Aviary</target> </trans-unit> <trans-unit id="58893b99e0d43" resname="media.bulkupload.bulkupload"> <source>media.bulkupload.bulkupload</source> <target>Importación múltiple</target> </trans-unit> <trans-unit id="58893b99e0d4d" resname="media.bulkupload.upload"> <source>media.bulkupload.upload</source> <target>Importación</target> </trans-unit> <trans-unit id="58893b99e0d56" resname="media.file.add"> <source>media.file.add</source> <target>Agregar archivo</target> </trans-unit> <trans-unit id="58893b99e0d60" resname="media.file.modal.save"> <source>media.file.modal.save</source> <target>Añadir</target> </trans-unit> <trans-unit id="58893b99e0d6d" resname="media.file.modal.title"> <source>media.file.modal.title</source> <target>Agregar archivo</target> </trans-unit> <trans-unit id="58893b99e0d7a" resname="media.folder.addsub.action"> <source>media.folder.addsub.action</source> <target>Agregar una subcarpeta</target> </trans-unit> <trans-unit id="58893b99e0d87" resname="media.folder.addsub.modal.save"> <source>media.folder.addsub.modal.save</source> <target>Agregar</target> </trans-unit> <trans-unit id="58893b99e0d94" resname="media.folder.addsub.modal.title"> <source>media.folder.addsub.modal.title</source> <target>Agregar una subcarpeta</target> </trans-unit> <trans-unit id="58893b99e0d9e" resname="media.folder.contenttab.title"> <source>media.folder.contenttab.title</source> <target>Contenido</target> </trans-unit> <trans-unit id="58893b99e0da8" resname="media.folder.delete.action"> <source>media.folder.delete.action</source> <target>Eliminar esta carpeta</target> </trans-unit> <trans-unit id="58893b99e0db5" resname="media.folder.delete.modal.text"> <source>media.folder.delete.modal.text</source> <target>¿ Seguro que quieres eliminar "%carpeta%" ?</target> </trans-unit> <trans-unit id="58893b99e0dc0" resname="media.folder.delete.modal.title"> <source>media.folder.delete.modal.title</source> <target>Eliminar carpeta</target> </trans-unit> <trans-unit id="58893b99e0dca" resname="media.folder.propertiestab.title"> <source>media.folder.propertiestab.title</source> <target>Propiedades</target> </trans-unit> <trans-unit id="58893b99e0dd3" resname="media.folder.save"> <source>media.folder.save</source> <target>Guardar</target> </trans-unit> <trans-unit id="58893b99e0ddd" resname="media.folder.sub.no"> <source>media.folder.sub.no</source> <target>No subcarpeta</target> </trans-unit> <trans-unit id="58893b99e0de6" resname="media.media.addto"> <source>media.media.addto</source> <target>Agregar el media en %folder%</target> </trans-unit> <trans-unit id="58893b99e0df0" resname="media.media.bulkupload.addto"> <source>media.media.bulkupload.addto</source> <target>Importación de archivos a la carpeta "%folder%"</target> </trans-unit> <trans-unit id="58893b99e0df9" resname="media.media.contenttab.title"> <source>media.media.contenttab.title</source> <target>Contenido</target> </trans-unit> <trans-unit id="58893b99e0e03" resname="media.media.deletesure"> <source>media.media.deletesure</source> <target>¿ Seguro que quieres eliminar este contenido ?</target> </trans-unit> <trans-unit id="58893b99e0e0c" resname="media.media.download.action"> <source>media.media.download.action</source> <target>Descargar</target> </trans-unit> <trans-unit id="58893b99e0e16" resname="media.media.edit.action"> <source>media.media.edit.action</source> <target>Modificar</target> </trans-unit> <trans-unit id="58893b99e0e1f" resname="media.media.mediainfo.contenttype"> <source>media.media.mediainfo.contenttype</source> <target>Tipo de contenido</target> </trans-unit> <trans-unit id="58893b99e0e29" resname="media.media.mediainfo.createdat"> <source>media.media.mediainfo.createdat</source> <target>Añadido</target> </trans-unit> <trans-unit id="58893b99e0e32" resname="media.media.mediainfo.downloadlink"> <source>media.media.mediainfo.downloadlink</source> <target>Enlace de descarga</target> </trans-unit> <trans-unit id="58893b99e0e3c" resname="media.media.mediainfo.name"> <source>media.media.mediainfo.name</source> <target>Nombre</target> </trans-unit> <trans-unit id="58893b99e0e45" resname="media.media.mediainfo.updatedat"> <source>media.media.mediainfo.updatedat</source> <target>Actualizado</target> </trans-unit> <trans-unit id="58893b99e0e4f" resname="media.media.new"> <source>media.media.new</source> <target>Añadir el media en la carpeta "%folder%</target> </trans-unit> <trans-unit id="58893b99e0e58" resname="media.media.no"> <source>media.media.no</source> <target>Esa carpeta no tiene archivo</target> </trans-unit> <trans-unit id="58893b99e0e61" resname="media.media.propertiestab.title"> <source>media.media.propertiestab.title</source> <target>Propiedades</target> </trans-unit> <trans-unit id="58893b99e0e6b" resname="media.media.title"> <source>media.media.title</source> <target>Media</target> </trans-unit> <trans-unit id="58893b99e0e74" resname="media.slide.add"> <source>media.slide.add</source> <target>Agregar un slideshow</target> </trans-unit> <trans-unit id="58893b99e0e7d" resname="media.slide.modal.save"> <source>media.slide.modal.save</source> <target>Agregar</target> </trans-unit> <trans-unit id="58893b99e0e86" resname="media.slide.modal.title"> <source>media.slide.modal.title</source> <target>Agregar un slideshow</target> </trans-unit> <trans-unit id="58893b99e0e90" resname="media.video.add"> <source>media.video.add</source> <target>Agregar un video</target> </trans-unit> <trans-unit id="58893b99e0e99" resname="media.video.modal.save"> <source>media.video.modal.save</source> <target>Agregar</target> </trans-unit> <trans-unit id="58893b99e0ea2" resname="media.video.modal.title"> <source>media.video.modal.title</source> <target>Agregar un video</target> </trans-unit> <trans-unit id="58893b99e0eac" resname="media.widget.choose"> <source>media.widget.choose</source> <target>Elegir</target> </trans-unit> <trans-unit id="58893b99e0eb5" resname="media.widget.delete"> <source>media.widget.delete</source> <target>Eliminar</target> </trans-unit> <trans-unit id="58893b99e0ebe" resname="media.video.add"> <source>media.video.add</source> <target>Agregar un video</target> </trans-unit> <trans-unit id="58893b99e0ec7" resname="media.slide.add"> <source>media.slide.add</source> <target>Agregar un slideshow</target> </trans-unit> <trans-unit id="58893b99e0ed0" resname="Name"> <source>Name</source> <target>Nombre </target> </trans-unit> <trans-unit id="58893b99e0eda" resname="Rel"> <source>Rel</source> <target>Tipo de media</target> </trans-unit> <trans-unit id="58893b99e0ee3" resname="Parent"> <source>Parent</source> <target>Carpeta padre</target> </trans-unit> <trans-unit id="58893b99e0eec" resname="Code"> <source>Code</source> <target>URL</target> </trans-unit> <trans-unit id="58893b99e0ef6" resname="Files"> <source>Files</source> <target>Carpetas</target> </trans-unit> <trans-unit id="58893b99e0eff" resname="Create"> <source>Create</source> <target>Importar</target> </trans-unit> <trans-unit id="58893b99e0f08" resname="Show Media"> <source>Show Media</source> <target>Mostrar el archivo multimedia</target> </trans-unit> <trans-unit id="58893b99e0f11" resname="File"> <source>File</source> <target>Carpeta</target> </trans-unit> <trans-unit id="58893b99e0f1a" resname="Bulk upload"> <source>Bulk upload</source> <target>Importación múltiple</target> </trans-unit> <trans-unit id="58893b99e0f24" resname="slideshare"> <source>slideshare</source> <target>Slideshare</target> </trans-unit> <trans-unit id="58893b99e0f2d" resname="slideshow"> <source>slideshow</source> <target>Slideshow</target> </trans-unit> <trans-unit id="58893b99e0f36" resname="video"> <source>video</source> <target>Video</target> </trans-unit> <trans-unit id="58893b99e0f40" resname="vimeo"> <source>vimeo</source> <target>Vimeo</target> </trans-unit> <trans-unit id="58893b99e0f49" resname="youtube"> <source>youtube</source> <target>Youtube</target> </trans-unit> <trans-unit id="58893b99e0f52" resname="form.cancel"> <source>form.cancel</source> <target>Cancelar</target> </trans-unit> <trans-unit id="58893b99e0f5d" resname="form.save"> <source>form.save</source> <target>Guardar</target> </trans-unit> <trans-unit id="58893b99e0f8b" resname="form.delete"> <source>form.delete</source> <target>Borrar</target> </trans-unit> <trans-unit id="58893b99e0f95" resname="Type"> <source>Type</source> <target>Origen</target> </trans-unit> <trans-unit id="58893b99e0f9e" resname="media.select.helper"> <source>media.select.helper</source> <target>Clic para seleccionar</target> </trans-unit> <trans-unit id="58893b99e0fa7" resname="media.edit.helper"> <source>media.edit.helper</source> <target>Clic para editar</target> </trans-unit> </body> </file> </xliff>
{ "pile_set_name": "Github" }
/** * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version * 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package org.apache.storm.trident.state; import org.apache.storm.shade.org.apache.commons.lang.builder.ToStringBuilder; public class OpaqueValue<T> { Long currTxid; T prev; T curr; public OpaqueValue(Long currTxid, T val, T prev) { this.curr = val; this.currTxid = currTxid; this.prev = prev; } public OpaqueValue(Long currTxid, T val) { this(currTxid, val, null); } public OpaqueValue<T> update(Long batchTxid, T newVal) { T prev; if (batchTxid == null || (this.currTxid < batchTxid)) { prev = this.curr; } else if (batchTxid.equals(this.currTxid)) { prev = this.prev; } else { throw new RuntimeException("Current batch (" + batchTxid + ") is behind state's batch: " + this.toString()); } return new OpaqueValue<T>(batchTxid, newVal, prev); } public T get(Long batchTxid) { if (batchTxid == null || (this.currTxid < batchTxid)) { return curr; } else if (batchTxid.equals(this.currTxid)) { return prev; } else { throw new RuntimeException("Current batch (" + batchTxid + ") is behind state's batch: " + this.toString()); } } public T getCurr() { return curr; } public Long getCurrTxid() { return currTxid; } public T getPrev() { return prev; } @Override public String toString() { return ToStringBuilder.reflectionToString(this); } }
{ "pile_set_name": "Github" }
// go run mksysnum.go http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master // Code generated by the command above; see README.md. DO NOT EDIT. // +build arm,netbsd package unix const ( SYS_EXIT = 1 // { void|sys||exit(int rval); } SYS_FORK = 2 // { int|sys||fork(void); } SYS_READ = 3 // { ssize_t|sys||read(int fd, void *buf, size_t nbyte); } SYS_WRITE = 4 // { ssize_t|sys||write(int fd, const void *buf, size_t nbyte); } SYS_OPEN = 5 // { int|sys||open(const char *path, int flags, ... mode_t mode); } SYS_CLOSE = 6 // { int|sys||close(int fd); } SYS_LINK = 9 // { int|sys||link(const char *path, const char *link); } SYS_UNLINK = 10 // { int|sys||unlink(const char *path); } SYS_CHDIR = 12 // { int|sys||chdir(const char *path); } SYS_FCHDIR = 13 // { int|sys||fchdir(int fd); } SYS_CHMOD = 15 // { int|sys||chmod(const char *path, mode_t mode); } SYS_CHOWN = 16 // { int|sys||chown(const char *path, uid_t uid, gid_t gid); } SYS_BREAK = 17 // { int|sys||obreak(char *nsize); } SYS_GETPID = 20 // { pid_t|sys||getpid_with_ppid(void); } SYS_UNMOUNT = 22 // { int|sys||unmount(const char *path, int flags); } SYS_SETUID = 23 // { int|sys||setuid(uid_t uid); } SYS_GETUID = 24 // { uid_t|sys||getuid_with_euid(void); } SYS_GETEUID = 25 // { uid_t|sys||geteuid(void); } SYS_PTRACE = 26 // { int|sys||ptrace(int req, pid_t pid, void *addr, int data); } SYS_RECVMSG = 27 // { ssize_t|sys||recvmsg(int s, struct msghdr *msg, int flags); } SYS_SENDMSG = 28 // { ssize_t|sys||sendmsg(int s, const struct msghdr *msg, int flags); } SYS_RECVFROM = 29 // { ssize_t|sys||recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlenaddr); } SYS_ACCEPT = 30 // { int|sys||accept(int s, struct sockaddr *name, socklen_t *anamelen); } SYS_GETPEERNAME = 31 // { int|sys||getpeername(int fdes, struct sockaddr *asa, socklen_t *alen); } SYS_GETSOCKNAME = 32 // { int|sys||getsockname(int fdes, struct sockaddr *asa, socklen_t *alen); } SYS_ACCESS = 33 // { int|sys||access(const char *path, int flags); } SYS_CHFLAGS = 34 // { int|sys||chflags(const char *path, u_long flags); } SYS_FCHFLAGS = 35 // { int|sys||fchflags(int fd, u_long flags); } SYS_SYNC = 36 // { void|sys||sync(void); } SYS_KILL = 37 // { int|sys||kill(pid_t pid, int signum); } SYS_GETPPID = 39 // { pid_t|sys||getppid(void); } SYS_DUP = 41 // { int|sys||dup(int fd); } SYS_PIPE = 42 // { int|sys||pipe(void); } SYS_GETEGID = 43 // { gid_t|sys||getegid(void); } SYS_PROFIL = 44 // { int|sys||profil(char *samples, size_t size, u_long offset, u_int scale); } SYS_KTRACE = 45 // { int|sys||ktrace(const char *fname, int ops, int facs, pid_t pid); } SYS_GETGID = 47 // { gid_t|sys||getgid_with_egid(void); } SYS___GETLOGIN = 49 // { int|sys||__getlogin(char *namebuf, size_t namelen); } SYS___SETLOGIN = 50 // { int|sys||__setlogin(const char *namebuf); } SYS_ACCT = 51 // { int|sys||acct(const char *path); } SYS_IOCTL = 54 // { int|sys||ioctl(int fd, u_long com, ... void *data); } SYS_REVOKE = 56 // { int|sys||revoke(const char *path); } SYS_SYMLINK = 57 // { int|sys||symlink(const char *path, const char *link); } SYS_READLINK = 58 // { ssize_t|sys||readlink(const char *path, char *buf, size_t count); } SYS_EXECVE = 59 // { int|sys||execve(const char *path, char * const *argp, char * const *envp); } SYS_UMASK = 60 // { mode_t|sys||umask(mode_t newmask); } SYS_CHROOT = 61 // { int|sys||chroot(const char *path); } SYS_VFORK = 66 // { int|sys||vfork(void); } SYS_SBRK = 69 // { int|sys||sbrk(intptr_t incr); } SYS_SSTK = 70 // { int|sys||sstk(int incr); } SYS_VADVISE = 72 // { int|sys||ovadvise(int anom); } SYS_MUNMAP = 73 // { int|sys||munmap(void *addr, size_t len); } SYS_MPROTECT = 74 // { int|sys||mprotect(void *addr, size_t len, int prot); } SYS_MADVISE = 75 // { int|sys||madvise(void *addr, size_t len, int behav); } SYS_MINCORE = 78 // { int|sys||mincore(void *addr, size_t len, char *vec); } SYS_GETGROUPS = 79 // { int|sys||getgroups(int gidsetsize, gid_t *gidset); } SYS_SETGROUPS = 80 // { int|sys||setgroups(int gidsetsize, const gid_t *gidset); } SYS_GETPGRP = 81 // { int|sys||getpgrp(void); } SYS_SETPGID = 82 // { int|sys||setpgid(pid_t pid, pid_t pgid); } SYS_DUP2 = 90 // { int|sys||dup2(int from, int to); } SYS_FCNTL = 92 // { int|sys||fcntl(int fd, int cmd, ... void *arg); } SYS_FSYNC = 95 // { int|sys||fsync(int fd); } SYS_SETPRIORITY = 96 // { int|sys||setpriority(int which, id_t who, int prio); } SYS_CONNECT = 98 // { int|sys||connect(int s, const struct sockaddr *name, socklen_t namelen); } SYS_GETPRIORITY = 100 // { int|sys||getpriority(int which, id_t who); } SYS_BIND = 104 // { int|sys||bind(int s, const struct sockaddr *name, socklen_t namelen); } SYS_SETSOCKOPT = 105 // { int|sys||setsockopt(int s, int level, int name, const void *val, socklen_t valsize); } SYS_LISTEN = 106 // { int|sys||listen(int s, int backlog); } SYS_GETSOCKOPT = 118 // { int|sys||getsockopt(int s, int level, int name, void *val, socklen_t *avalsize); } SYS_READV = 120 // { ssize_t|sys||readv(int fd, const struct iovec *iovp, int iovcnt); } SYS_WRITEV = 121 // { ssize_t|sys||writev(int fd, const struct iovec *iovp, int iovcnt); } SYS_FCHOWN = 123 // { int|sys||fchown(int fd, uid_t uid, gid_t gid); } SYS_FCHMOD = 124 // { int|sys||fchmod(int fd, mode_t mode); } SYS_SETREUID = 126 // { int|sys||setreuid(uid_t ruid, uid_t euid); } SYS_SETREGID = 127 // { int|sys||setregid(gid_t rgid, gid_t egid); } SYS_RENAME = 128 // { int|sys||rename(const char *from, const char *to); } SYS_FLOCK = 131 // { int|sys||flock(int fd, int how); } SYS_MKFIFO = 132 // { int|sys||mkfifo(const char *path, mode_t mode); } SYS_SENDTO = 133 // { ssize_t|sys||sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); } SYS_SHUTDOWN = 134 // { int|sys||shutdown(int s, int how); } SYS_SOCKETPAIR = 135 // { int|sys||socketpair(int domain, int type, int protocol, int *rsv); } SYS_MKDIR = 136 // { int|sys||mkdir(const char *path, mode_t mode); } SYS_RMDIR = 137 // { int|sys||rmdir(const char *path); } SYS_SETSID = 147 // { int|sys||setsid(void); } SYS_SYSARCH = 165 // { int|sys||sysarch(int op, void *parms); } SYS_PREAD = 173 // { ssize_t|sys||pread(int fd, void *buf, size_t nbyte, int PAD, off_t offset); } SYS_PWRITE = 174 // { ssize_t|sys||pwrite(int fd, const void *buf, size_t nbyte, int PAD, off_t offset); } SYS_NTP_ADJTIME = 176 // { int|sys||ntp_adjtime(struct timex *tp); } SYS_SETGID = 181 // { int|sys||setgid(gid_t gid); } SYS_SETEGID = 182 // { int|sys||setegid(gid_t egid); } SYS_SETEUID = 183 // { int|sys||seteuid(uid_t euid); } SYS_PATHCONF = 191 // { long|sys||pathconf(const char *path, int name); } SYS_FPATHCONF = 192 // { long|sys||fpathconf(int fd, int name); } SYS_GETRLIMIT = 194 // { int|sys||getrlimit(int which, struct rlimit *rlp); } SYS_SETRLIMIT = 195 // { int|sys||setrlimit(int which, const struct rlimit *rlp); } SYS_MMAP = 197 // { void *|sys||mmap(void *addr, size_t len, int prot, int flags, int fd, long PAD, off_t pos); } SYS_LSEEK = 199 // { off_t|sys||lseek(int fd, int PAD, off_t offset, int whence); } SYS_TRUNCATE = 200 // { int|sys||truncate(const char *path, int PAD, off_t length); } SYS_FTRUNCATE = 201 // { int|sys||ftruncate(int fd, int PAD, off_t length); } SYS___SYSCTL = 202 // { int|sys||__sysctl(const int *name, u_int namelen, void *old, size_t *oldlenp, const void *new, size_t newlen); } SYS_MLOCK = 203 // { int|sys||mlock(const void *addr, size_t len); } SYS_MUNLOCK = 204 // { int|sys||munlock(const void *addr, size_t len); } SYS_UNDELETE = 205 // { int|sys||undelete(const char *path); } SYS_GETPGID = 207 // { pid_t|sys||getpgid(pid_t pid); } SYS_REBOOT = 208 // { int|sys||reboot(int opt, char *bootstr); } SYS_POLL = 209 // { int|sys||poll(struct pollfd *fds, u_int nfds, int timeout); } SYS_SEMGET = 221 // { int|sys||semget(key_t key, int nsems, int semflg); } SYS_SEMOP = 222 // { int|sys||semop(int semid, struct sembuf *sops, size_t nsops); } SYS_SEMCONFIG = 223 // { int|sys||semconfig(int flag); } SYS_MSGGET = 225 // { int|sys||msgget(key_t key, int msgflg); } SYS_MSGSND = 226 // { int|sys||msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg); } SYS_MSGRCV = 227 // { ssize_t|sys||msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); } SYS_SHMAT = 228 // { void *|sys||shmat(int shmid, const void *shmaddr, int shmflg); } SYS_SHMDT = 230 // { int|sys||shmdt(const void *shmaddr); } SYS_SHMGET = 231 // { int|sys||shmget(key_t key, size_t size, int shmflg); } SYS_TIMER_CREATE = 235 // { int|sys||timer_create(clockid_t clock_id, struct sigevent *evp, timer_t *timerid); } SYS_TIMER_DELETE = 236 // { int|sys||timer_delete(timer_t timerid); } SYS_TIMER_GETOVERRUN = 239 // { int|sys||timer_getoverrun(timer_t timerid); } SYS_FDATASYNC = 241 // { int|sys||fdatasync(int fd); } SYS_MLOCKALL = 242 // { int|sys||mlockall(int flags); } SYS_MUNLOCKALL = 243 // { int|sys||munlockall(void); } SYS_SIGQUEUEINFO = 245 // { int|sys||sigqueueinfo(pid_t pid, const siginfo_t *info); } SYS_MODCTL = 246 // { int|sys||modctl(int cmd, void *arg); } SYS___POSIX_RENAME = 270 // { int|sys||__posix_rename(const char *from, const char *to); } SYS_SWAPCTL = 271 // { int|sys||swapctl(int cmd, void *arg, int misc); } SYS_MINHERIT = 273 // { int|sys||minherit(void *addr, size_t len, int inherit); } SYS_LCHMOD = 274 // { int|sys||lchmod(const char *path, mode_t mode); } SYS_LCHOWN = 275 // { int|sys||lchown(const char *path, uid_t uid, gid_t gid); } SYS_MSYNC = 277 // { int|sys|13|msync(void *addr, size_t len, int flags); } SYS___POSIX_CHOWN = 283 // { int|sys||__posix_chown(const char *path, uid_t uid, gid_t gid); } SYS___POSIX_FCHOWN = 284 // { int|sys||__posix_fchown(int fd, uid_t uid, gid_t gid); } SYS___POSIX_LCHOWN = 285 // { int|sys||__posix_lchown(const char *path, uid_t uid, gid_t gid); } SYS_GETSID = 286 // { pid_t|sys||getsid(pid_t pid); } SYS___CLONE = 287 // { pid_t|sys||__clone(int flags, void *stack); } SYS_FKTRACE = 288 // { int|sys||fktrace(int fd, int ops, int facs, pid_t pid); } SYS_PREADV = 289 // { ssize_t|sys||preadv(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); } SYS_PWRITEV = 290 // { ssize_t|sys||pwritev(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); } SYS___GETCWD = 296 // { int|sys||__getcwd(char *bufp, size_t length); } SYS_FCHROOT = 297 // { int|sys||fchroot(int fd); } SYS_LCHFLAGS = 304 // { int|sys||lchflags(const char *path, u_long flags); } SYS_ISSETUGID = 305 // { int|sys||issetugid(void); } SYS_UTRACE = 306 // { int|sys||utrace(const char *label, void *addr, size_t len); } SYS_GETCONTEXT = 307 // { int|sys||getcontext(struct __ucontext *ucp); } SYS_SETCONTEXT = 308 // { int|sys||setcontext(const struct __ucontext *ucp); } SYS__LWP_CREATE = 309 // { int|sys||_lwp_create(const struct __ucontext *ucp, u_long flags, lwpid_t *new_lwp); } SYS__LWP_EXIT = 310 // { int|sys||_lwp_exit(void); } SYS__LWP_SELF = 311 // { lwpid_t|sys||_lwp_self(void); } SYS__LWP_WAIT = 312 // { int|sys||_lwp_wait(lwpid_t wait_for, lwpid_t *departed); } SYS__LWP_SUSPEND = 313 // { int|sys||_lwp_suspend(lwpid_t target); } SYS__LWP_CONTINUE = 314 // { int|sys||_lwp_continue(lwpid_t target); } SYS__LWP_WAKEUP = 315 // { int|sys||_lwp_wakeup(lwpid_t target); } SYS__LWP_GETPRIVATE = 316 // { void *|sys||_lwp_getprivate(void); } SYS__LWP_SETPRIVATE = 317 // { void|sys||_lwp_setprivate(void *ptr); } SYS__LWP_KILL = 318 // { int|sys||_lwp_kill(lwpid_t target, int signo); } SYS__LWP_DETACH = 319 // { int|sys||_lwp_detach(lwpid_t target); } SYS__LWP_UNPARK = 321 // { int|sys||_lwp_unpark(lwpid_t target, const void *hint); } SYS__LWP_UNPARK_ALL = 322 // { ssize_t|sys||_lwp_unpark_all(const lwpid_t *targets, size_t ntargets, const void *hint); } SYS__LWP_SETNAME = 323 // { int|sys||_lwp_setname(lwpid_t target, const char *name); } SYS__LWP_GETNAME = 324 // { int|sys||_lwp_getname(lwpid_t target, char *name, size_t len); } SYS__LWP_CTL = 325 // { int|sys||_lwp_ctl(int features, struct lwpctl **address); } SYS___SIGACTION_SIGTRAMP = 340 // { int|sys||__sigaction_sigtramp(int signum, const struct sigaction *nsa, struct sigaction *osa, const void *tramp, int vers); } SYS_PMC_GET_INFO = 341 // { int|sys||pmc_get_info(int ctr, int op, void *args); } SYS_PMC_CONTROL = 342 // { int|sys||pmc_control(int ctr, int op, void *args); } SYS_RASCTL = 343 // { int|sys||rasctl(void *addr, size_t len, int op); } SYS_KQUEUE = 344 // { int|sys||kqueue(void); } SYS__SCHED_SETPARAM = 346 // { int|sys||_sched_setparam(pid_t pid, lwpid_t lid, int policy, const struct sched_param *params); } SYS__SCHED_GETPARAM = 347 // { int|sys||_sched_getparam(pid_t pid, lwpid_t lid, int *policy, struct sched_param *params); } SYS__SCHED_SETAFFINITY = 348 // { int|sys||_sched_setaffinity(pid_t pid, lwpid_t lid, size_t size, const cpuset_t *cpuset); } SYS__SCHED_GETAFFINITY = 349 // { int|sys||_sched_getaffinity(pid_t pid, lwpid_t lid, size_t size, cpuset_t *cpuset); } SYS_SCHED_YIELD = 350 // { int|sys||sched_yield(void); } SYS_FSYNC_RANGE = 354 // { int|sys||fsync_range(int fd, int flags, off_t start, off_t length); } SYS_UUIDGEN = 355 // { int|sys||uuidgen(struct uuid *store, int count); } SYS_GETVFSSTAT = 356 // { int|sys||getvfsstat(struct statvfs *buf, size_t bufsize, int flags); } SYS_STATVFS1 = 357 // { int|sys||statvfs1(const char *path, struct statvfs *buf, int flags); } SYS_FSTATVFS1 = 358 // { int|sys||fstatvfs1(int fd, struct statvfs *buf, int flags); } SYS_EXTATTRCTL = 360 // { int|sys||extattrctl(const char *path, int cmd, const char *filename, int attrnamespace, const char *attrname); } SYS_EXTATTR_SET_FILE = 361 // { int|sys||extattr_set_file(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); } SYS_EXTATTR_GET_FILE = 362 // { ssize_t|sys||extattr_get_file(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); } SYS_EXTATTR_DELETE_FILE = 363 // { int|sys||extattr_delete_file(const char *path, int attrnamespace, const char *attrname); } SYS_EXTATTR_SET_FD = 364 // { int|sys||extattr_set_fd(int fd, int attrnamespace, const char *attrname, const void *data, size_t nbytes); } SYS_EXTATTR_GET_FD = 365 // { ssize_t|sys||extattr_get_fd(int fd, int attrnamespace, const char *attrname, void *data, size_t nbytes); } SYS_EXTATTR_DELETE_FD = 366 // { int|sys||extattr_delete_fd(int fd, int attrnamespace, const char *attrname); } SYS_EXTATTR_SET_LINK = 367 // { int|sys||extattr_set_link(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); } SYS_EXTATTR_GET_LINK = 368 // { ssize_t|sys||extattr_get_link(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); } SYS_EXTATTR_DELETE_LINK = 369 // { int|sys||extattr_delete_link(const char *path, int attrnamespace, const char *attrname); } SYS_EXTATTR_LIST_FD = 370 // { ssize_t|sys||extattr_list_fd(int fd, int attrnamespace, void *data, size_t nbytes); } SYS_EXTATTR_LIST_FILE = 371 // { ssize_t|sys||extattr_list_file(const char *path, int attrnamespace, void *data, size_t nbytes); } SYS_EXTATTR_LIST_LINK = 372 // { ssize_t|sys||extattr_list_link(const char *path, int attrnamespace, void *data, size_t nbytes); } SYS_SETXATTR = 375 // { int|sys||setxattr(const char *path, const char *name, const void *value, size_t size, int flags); } SYS_LSETXATTR = 376 // { int|sys||lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags); } SYS_FSETXATTR = 377 // { int|sys||fsetxattr(int fd, const char *name, const void *value, size_t size, int flags); } SYS_GETXATTR = 378 // { int|sys||getxattr(const char *path, const char *name, void *value, size_t size); } SYS_LGETXATTR = 379 // { int|sys||lgetxattr(const char *path, const char *name, void *value, size_t size); } SYS_FGETXATTR = 380 // { int|sys||fgetxattr(int fd, const char *name, void *value, size_t size); } SYS_LISTXATTR = 381 // { int|sys||listxattr(const char *path, char *list, size_t size); } SYS_LLISTXATTR = 382 // { int|sys||llistxattr(const char *path, char *list, size_t size); } SYS_FLISTXATTR = 383 // { int|sys||flistxattr(int fd, char *list, size_t size); } SYS_REMOVEXATTR = 384 // { int|sys||removexattr(const char *path, const char *name); } SYS_LREMOVEXATTR = 385 // { int|sys||lremovexattr(const char *path, const char *name); } SYS_FREMOVEXATTR = 386 // { int|sys||fremovexattr(int fd, const char *name); } SYS_GETDENTS = 390 // { int|sys|30|getdents(int fd, char *buf, size_t count); } SYS_SOCKET = 394 // { int|sys|30|socket(int domain, int type, int protocol); } SYS_GETFH = 395 // { int|sys|30|getfh(const char *fname, void *fhp, size_t *fh_size); } SYS_MOUNT = 410 // { int|sys|50|mount(const char *type, const char *path, int flags, void *data, size_t data_len); } SYS_MREMAP = 411 // { void *|sys||mremap(void *old_address, size_t old_size, void *new_address, size_t new_size, int flags); } SYS_PSET_CREATE = 412 // { int|sys||pset_create(psetid_t *psid); } SYS_PSET_DESTROY = 413 // { int|sys||pset_destroy(psetid_t psid); } SYS_PSET_ASSIGN = 414 // { int|sys||pset_assign(psetid_t psid, cpuid_t cpuid, psetid_t *opsid); } SYS__PSET_BIND = 415 // { int|sys||_pset_bind(idtype_t idtype, id_t first_id, id_t second_id, psetid_t psid, psetid_t *opsid); } SYS_POSIX_FADVISE = 416 // { int|sys|50|posix_fadvise(int fd, int PAD, off_t offset, off_t len, int advice); } SYS_SELECT = 417 // { int|sys|50|select(int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tv); } SYS_GETTIMEOFDAY = 418 // { int|sys|50|gettimeofday(struct timeval *tp, void *tzp); } SYS_SETTIMEOFDAY = 419 // { int|sys|50|settimeofday(const struct timeval *tv, const void *tzp); } SYS_UTIMES = 420 // { int|sys|50|utimes(const char *path, const struct timeval *tptr); } SYS_ADJTIME = 421 // { int|sys|50|adjtime(const struct timeval *delta, struct timeval *olddelta); } SYS_FUTIMES = 423 // { int|sys|50|futimes(int fd, const struct timeval *tptr); } SYS_LUTIMES = 424 // { int|sys|50|lutimes(const char *path, const struct timeval *tptr); } SYS_SETITIMER = 425 // { int|sys|50|setitimer(int which, const struct itimerval *itv, struct itimerval *oitv); } SYS_GETITIMER = 426 // { int|sys|50|getitimer(int which, struct itimerval *itv); } SYS_CLOCK_GETTIME = 427 // { int|sys|50|clock_gettime(clockid_t clock_id, struct timespec *tp); } SYS_CLOCK_SETTIME = 428 // { int|sys|50|clock_settime(clockid_t clock_id, const struct timespec *tp); } SYS_CLOCK_GETRES = 429 // { int|sys|50|clock_getres(clockid_t clock_id, struct timespec *tp); } SYS_NANOSLEEP = 430 // { int|sys|50|nanosleep(const struct timespec *rqtp, struct timespec *rmtp); } SYS___SIGTIMEDWAIT = 431 // { int|sys|50|__sigtimedwait(const sigset_t *set, siginfo_t *info, struct timespec *timeout); } SYS__LWP_PARK = 434 // { int|sys|50|_lwp_park(const struct timespec *ts, lwpid_t unpark, const void *hint, const void *unparkhint); } SYS_KEVENT = 435 // { int|sys|50|kevent(int fd, const struct kevent *changelist, size_t nchanges, struct kevent *eventlist, size_t nevents, const struct timespec *timeout); } SYS_PSELECT = 436 // { int|sys|50|pselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, const struct timespec *ts, const sigset_t *mask); } SYS_POLLTS = 437 // { int|sys|50|pollts(struct pollfd *fds, u_int nfds, const struct timespec *ts, const sigset_t *mask); } SYS_STAT = 439 // { int|sys|50|stat(const char *path, struct stat *ub); } SYS_FSTAT = 440 // { int|sys|50|fstat(int fd, struct stat *sb); } SYS_LSTAT = 441 // { int|sys|50|lstat(const char *path, struct stat *ub); } SYS___SEMCTL = 442 // { int|sys|50|__semctl(int semid, int semnum, int cmd, ... union __semun *arg); } SYS_SHMCTL = 443 // { int|sys|50|shmctl(int shmid, int cmd, struct shmid_ds *buf); } SYS_MSGCTL = 444 // { int|sys|50|msgctl(int msqid, int cmd, struct msqid_ds *buf); } SYS_GETRUSAGE = 445 // { int|sys|50|getrusage(int who, struct rusage *rusage); } SYS_TIMER_SETTIME = 446 // { int|sys|50|timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue); } SYS_TIMER_GETTIME = 447 // { int|sys|50|timer_gettime(timer_t timerid, struct itimerspec *value); } SYS_NTP_GETTIME = 448 // { int|sys|50|ntp_gettime(struct ntptimeval *ntvp); } SYS_WAIT4 = 449 // { int|sys|50|wait4(pid_t pid, int *status, int options, struct rusage *rusage); } SYS_MKNOD = 450 // { int|sys|50|mknod(const char *path, mode_t mode, dev_t dev); } SYS_FHSTAT = 451 // { int|sys|50|fhstat(const void *fhp, size_t fh_size, struct stat *sb); } SYS_PIPE2 = 453 // { int|sys||pipe2(int *fildes, int flags); } SYS_DUP3 = 454 // { int|sys||dup3(int from, int to, int flags); } SYS_KQUEUE1 = 455 // { int|sys||kqueue1(int flags); } SYS_PACCEPT = 456 // { int|sys||paccept(int s, struct sockaddr *name, socklen_t *anamelen, const sigset_t *mask, int flags); } SYS_LINKAT = 457 // { int|sys||linkat(int fd1, const char *name1, int fd2, const char *name2, int flags); } SYS_RENAMEAT = 458 // { int|sys||renameat(int fromfd, const char *from, int tofd, const char *to); } SYS_MKFIFOAT = 459 // { int|sys||mkfifoat(int fd, const char *path, mode_t mode); } SYS_MKNODAT = 460 // { int|sys||mknodat(int fd, const char *path, mode_t mode, uint32_t dev); } SYS_MKDIRAT = 461 // { int|sys||mkdirat(int fd, const char *path, mode_t mode); } SYS_FACCESSAT = 462 // { int|sys||faccessat(int fd, const char *path, int amode, int flag); } SYS_FCHMODAT = 463 // { int|sys||fchmodat(int fd, const char *path, mode_t mode, int flag); } SYS_FCHOWNAT = 464 // { int|sys||fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag); } SYS_FEXECVE = 465 // { int|sys||fexecve(int fd, char * const *argp, char * const *envp); } SYS_FSTATAT = 466 // { int|sys||fstatat(int fd, const char *path, struct stat *buf, int flag); } SYS_UTIMENSAT = 467 // { int|sys||utimensat(int fd, const char *path, const struct timespec *tptr, int flag); } SYS_OPENAT = 468 // { int|sys||openat(int fd, const char *path, int oflags, ... mode_t mode); } SYS_READLINKAT = 469 // { int|sys||readlinkat(int fd, const char *path, char *buf, size_t bufsize); } SYS_SYMLINKAT = 470 // { int|sys||symlinkat(const char *path1, int fd, const char *path2); } SYS_UNLINKAT = 471 // { int|sys||unlinkat(int fd, const char *path, int flag); } SYS_FUTIMENS = 472 // { int|sys||futimens(int fd, const struct timespec *tptr); } SYS___QUOTACTL = 473 // { int|sys||__quotactl(const char *path, struct quotactl_args *args); } SYS_POSIX_SPAWN = 474 // { int|sys||posix_spawn(pid_t *pid, const char *path, const struct posix_spawn_file_actions *file_actions, const struct posix_spawnattr *attrp, char *const *argv, char *const *envp); } SYS_RECVMMSG = 475 // { int|sys||recvmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags, struct timespec *timeout); } SYS_SENDMMSG = 476 // { int|sys||sendmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags); } )
{ "pile_set_name": "Github" }
# Import the types this way so they do not need prefixing for execution. from fprime.common.models.serialize.type_exceptions import * from fprime.common.models.serialize.type_base import * from fprime.common.models.serialize.bool_type import * from fprime.common.models.serialize.enum_type import * from fprime.common.models.serialize.f32_type import * from fprime.common.models.serialize.f64_type import * from fprime.common.models.serialize.u8_type import * from fprime.common.models.serialize.u16_type import * from fprime.common.models.serialize.u32_type import * from fprime.common.models.serialize.u64_type import * from fprime.common.models.serialize.i8_type import * from fprime.common.models.serialize.i16_type import * from fprime.common.models.serialize.i32_type import * from fprime.common.models.serialize.i64_type import * from fprime.common.models.serialize.string_type import * from fprime.common.models.serialize.serializable_type import * from fprime_gds.common.models.common import command # Each file represents the information for a single command # These module variables are used to instance the command object within the Gse COMPONENT = "DictGen::TestComponent" MNEMONIC = "Inst2_Test_Cmd3" OP_CODE = 0x17 CMD_DESCRIPTION = "Test Cmd2" # Set arguments list with default values here. ARGUMENTS = [ ("arg1","",EnumType("enum1",{"item1":0,"item2":1,})), ] if __name__ == '__main__': testcmd = command.Command(COMPONENT, MNEMONIC, OP_CODE, CMD_DESCRIPTION, ARGUMENTS) data = testcmd.serialize() type_base.showBytes(data)
{ "pile_set_name": "Github" }
/* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.support.customtabs.browseractions; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.app.Dialog; import android.content.Context; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.support.v4.view.animation.LinearOutSlowInInterpolator; import android.view.MotionEvent; import android.view.View; import android.view.Window; /** * The dialog class showing the context menu and ensures proper animation is played upon calling * {@link #show()} and {@link #dismiss()}. */ class BrowserActionsFallbackMenuDialog extends Dialog { private static final long ENTER_ANIMATION_DURATION_MS = 250; // Exit animation duration should be set to 60% of the enter animation duration. private static final long EXIT_ANIMATION_DURATION_MS = 150; private final View mContentView; BrowserActionsFallbackMenuDialog(Context context, View contentView) { super(context, android.support.v7.appcompat.R.style.Theme_AppCompat_Light_Dialog); mContentView = contentView; } @Override public void show() { Window dialogWindow = getWindow(); dialogWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); startAnimation(true); super.show(); } @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { dismiss(); return true; } return false; } @Override public void dismiss() { startAnimation(false); } private void startAnimation(final boolean isEnterAnimation) { float from = isEnterAnimation ? 0f : 1f; float to = isEnterAnimation ? 1f : 0f; long duration = isEnterAnimation ? ENTER_ANIMATION_DURATION_MS : EXIT_ANIMATION_DURATION_MS; mContentView.setScaleX(from); mContentView.setScaleY(from); mContentView.animate() .scaleX(to) .scaleY(to) .setDuration(duration) .setInterpolator(new LinearOutSlowInInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (!isEnterAnimation) { BrowserActionsFallbackMenuDialog.super.dismiss(); } } }) .start(); } }
{ "pile_set_name": "Github" }
/* * NOTE: This copyright does *not* cover user programs that use HQ * program services by normal system calls through the application * program interfaces provided as part of the Hyperic Plug-in Development * Kit or the Hyperic Client Development Kit - this is merely considered * normal use of the program, and does *not* fall under the heading of * "derived work". * * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. * This file is part of HQ. * * HQ is free software; you can redistribute it and/or modify * it under the terms version 2 of the GNU 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 General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA. */ package org.hyperic.tools.db; import java.util.Collection; import java.util.List; import org.hyperic.util.jdbc.JDBC; import org.w3c.dom.Node; import org.xml.sax.SAXException; class OracleColumn extends Column { protected OracleColumn(Node node, Table table) throws SAXException { super(node, table); } protected String getCreateCommand ( List cmds, Collection typemaps, int dbtype ) { String defaultValue = this.getsDefault(); if ( defaultValue != null ) { if ( defaultValue.equalsIgnoreCase("TRUE") ) { this.m_sDefault = "1"; } else if ( defaultValue.equalsIgnoreCase("FALSE") ) { this.m_sDefault = "0"; } } return super.getCreateCommand(cmds, typemaps, dbtype); } protected String getDefaultCommand(List cmds) { if(this.hasDefault() == true) { switch(this.getDefault()) { case Column.DEFAULT_AUTO_INCREMENT: case Column.DEFAULT_SEQUENCE_ONLY: String strSeqName = this.m_strTableName + '_' + this.getName() + "_SEQ"; cmds.add(0, "CREATE SEQUENCE " + this.m_strTableName + '_' + this.getName() + "_SEQ" + " START WITH " + this.getInitialSequence() + " INCREMENT BY " + this.getIncrementSequence() + " NOMAXVALUE NOCYCLE CACHE 10"); break; } } return ""; } protected void getPostCreateCommands (List cmds) { String strSeqName = this.m_strTableName + '_' + this.getName() + "_SEQ"; if ( hasDefault() ) { switch(this.getDefault()) { case Column.DEFAULT_AUTO_INCREMENT: cmds.add("CREATE OR REPLACE TRIGGER " + strSeqName + "_T " + "BEFORE INSERT ON " + this.m_strTableName + " " + "FOR EACH ROW " + "BEGIN " + "SELECT " + strSeqName + ".NEXTVAL INTO :NEW." + this.getName() + " FROM DUAL; " + "END;"); break; } } } protected void getDropCommands(List cmds) { String strSeqName = this.m_strTableName + '_' + this.getName() + "_SEQ"; if(this.hasDefault() == true) { switch(this.getDefault()) { case Column.DEFAULT_SEQUENCE_ONLY: case Column.DEFAULT_AUTO_INCREMENT: cmds.add("DROP SEQUENCE " + strSeqName); // Dropping the table automatically drops the sequence // before this command gets executed. //-- you must mean it drops the trigger automatically, yea? //cmds.add("DROP TRIGGER " + strSeqName + "_t"); break; } } } protected static int getClassType() { return JDBC.ORACLE_TYPE; } }
{ "pile_set_name": "Github" }
/* * Copyright (c) 2020 EKA2L1 Team. * * This file is part of EKA2L1 project. * * 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 3 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, see <http://www.gnu.org/licenses/>. */ #ifndef MEDIA_CLIENT_AUDIO_COMMON_H_ #define MEDIA_CLIENT_AUDIO_COMMON_H_ #if defined(__SERIES60_1X_) #define MCA_NEW 1 #elif defined(__SERIES80__) #define MCA_NEW 2 #else #define MCA_NEW 3 #endif #endif
{ "pile_set_name": "Github" }
# # Makefile for the kernel mmc device drivers. # ifeq ($(CONFIG_MMC_DEBUG),y) EXTRA_CFLAGS += -DDEBUG endif obj-$(CONFIG_MMC) += core/ obj-$(CONFIG_MMC) += card/ obj-$(CONFIG_MMC) += host/
{ "pile_set_name": "Github" }
<style> #logger { height: 80px; overflow-y: auto; color: red; } </style> <strong>Logger: </strong> <ul id="logger"></ul> <div id="editor1" > <p>@</p> <p>@</p> <p>@</p> </div> <script> if ( bender.tools.env.mobile ) { bender.ignore(); } var logger = document.getElementById( 'logger' ), editor = CKEDITOR.replace( 'editor1', { on: { instanceReady: function() { var textWatcher = new CKEDITOR.plugins.textWatcher( editor, function( selectionRange ) { var match = document.createElement( 'li' ); match.innerText = 'Check logged! The test failed!'; logger.appendChild( match ); } ); textWatcher.attach(); } } } ); </script>
{ "pile_set_name": "Github" }
/* ********************************************************************** * Copyright (C) 1998-2010, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * * File ustring.h * * Modification History: * * Date Name Description * 12/07/98 bertrand Creation. ****************************************************************************** */ #ifndef USTRING_H #define USTRING_H #include "unicode/utypes.h" #include "unicode/putil.h" #include "unicode/uiter.h" /** Simple declaration for u_strToTitle() to avoid including unicode/ubrk.h. @stable ICU 2.1*/ #ifndef UBRK_TYPEDEF_UBREAK_ITERATOR # define UBRK_TYPEDEF_UBREAK_ITERATOR typedef struct UBreakIterator UBreakIterator; #endif /** * \file * \brief C API: Unicode string handling functions * * These C API functions provide general Unicode string handling. * * Some functions are equivalent in name, signature, and behavior to the ANSI C <string.h> * functions. (For example, they do not check for bad arguments like NULL string pointers.) * In some cases, only the thread-safe variant of such a function is implemented here * (see u_strtok_r()). * * Other functions provide more Unicode-specific functionality like locale-specific * upper/lower-casing and string comparison in code point order. * * ICU uses 16-bit Unicode (UTF-16) in the form of arrays of UChar code units. * UTF-16 encodes each Unicode code point with either one or two UChar code units. * (This is the default form of Unicode, and a forward-compatible extension of the original, * fixed-width form that was known as UCS-2. UTF-16 superseded UCS-2 with Unicode 2.0 * in 1996.) * * Some APIs accept a 32-bit UChar32 value for a single code point. * * ICU also handles 16-bit Unicode text with unpaired surrogates. * Such text is not well-formed UTF-16. * Code-point-related functions treat unpaired surrogates as surrogate code points, * i.e., as separate units. * * Although UTF-16 is a variable-width encoding form (like some legacy multi-byte encodings), * it is much more efficient even for random access because the code unit values * for single-unit characters vs. lead units vs. trail units are completely disjoint. * This means that it is easy to determine character (code point) boundaries from * random offsets in the string. * * Unicode (UTF-16) string processing is optimized for the single-unit case. * Although it is important to support supplementary characters * (which use pairs of lead/trail code units called "surrogates"), * their occurrence is rare. Almost all characters in modern use require only * a single UChar code unit (i.e., their code point values are <=0xffff). * * For more details see the User Guide Strings chapter (http://icu-project.org/userguide/strings.html). * For a discussion of the handling of unpaired surrogates see also * Jitterbug 2145 and its icu mailing list proposal on 2002-sep-18. */ /** * \defgroup ustring_ustrlen String Length * \ingroup ustring_strlen */ /*@{*/ /** * Determine the length of an array of UChar. * * @param s The array of UChars, NULL (U+0000) terminated. * @return The number of UChars in <code>chars</code>, minus the terminator. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_strlen(const UChar *s); /*@}*/ /** * Count Unicode code points in the length UChar code units of the string. * A code point may occupy either one or two UChar code units. * Counting code points involves reading all code units. * * This functions is basically the inverse of the U16_FWD_N() macro (see utf.h). * * @param s The input string. * @param length The number of UChar code units to be checked, or -1 to count all * code points before the first NUL (U+0000). * @return The number of code points in the specified code units. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_countChar32(const UChar *s, int32_t length); /** * Check if the string contains more Unicode code points than a certain number. * This is more efficient than counting all code points in the entire string * and comparing that number with a threshold. * This function may not need to scan the string at all if the length is known * (not -1 for NUL-termination) and falls within a certain range, and * never needs to count more than 'number+1' code points. * Logically equivalent to (u_countChar32(s, length)>number). * A Unicode code point may occupy either one or two UChar code units. * * @param s The input string. * @param length The length of the string, or -1 if it is NUL-terminated. * @param number The number of code points in the string is compared against * the 'number' parameter. * @return Boolean value for whether the string contains more Unicode code points * than 'number'. Same as (u_countChar32(s, length)>number). * @stable ICU 2.4 */ U_STABLE UBool U_EXPORT2 u_strHasMoreChar32Than(const UChar *s, int32_t length, int32_t number); /** * Concatenate two ustrings. Appends a copy of <code>src</code>, * including the null terminator, to <code>dst</code>. The initial copied * character from <code>src</code> overwrites the null terminator in <code>dst</code>. * * @param dst The destination string. * @param src The source string. * @return A pointer to <code>dst</code>. * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 u_strcat(UChar *dst, const UChar *src); /** * Concatenate two ustrings. * Appends at most <code>n</code> characters from <code>src</code> to <code>dst</code>. * Adds a terminating NUL. * If src is too long, then only <code>n-1</code> characters will be copied * before the terminating NUL. * If <code>n&lt;=0</code> then dst is not modified. * * @param dst The destination string. * @param src The source string. * @param n The maximum number of characters to append. * @return A pointer to <code>dst</code>. * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 u_strncat(UChar *dst, const UChar *src, int32_t n); /** * Find the first occurrence of a substring in a string. * The substring is found at code point boundaries. * That means that if the substring begins with * a trail surrogate or ends with a lead surrogate, * then it is found only if these surrogates stand alone in the text. * Otherwise, the substring edge units would be matched against * halves of surrogate pairs. * * @param s The string to search (NUL-terminated). * @param substring The substring to find (NUL-terminated). * @return A pointer to the first occurrence of <code>substring</code> in <code>s</code>, * or <code>s</code> itself if the <code>substring</code> is empty, * or <code>NULL</code> if <code>substring</code> is not in <code>s</code>. * @stable ICU 2.0 * * @see u_strrstr * @see u_strFindFirst * @see u_strFindLast */ U_STABLE UChar * U_EXPORT2 u_strstr(const UChar *s, const UChar *substring); /** * Find the first occurrence of a substring in a string. * The substring is found at code point boundaries. * That means that if the substring begins with * a trail surrogate or ends with a lead surrogate, * then it is found only if these surrogates stand alone in the text. * Otherwise, the substring edge units would be matched against * halves of surrogate pairs. * * @param s The string to search. * @param length The length of s (number of UChars), or -1 if it is NUL-terminated. * @param substring The substring to find (NUL-terminated). * @param subLength The length of substring (number of UChars), or -1 if it is NUL-terminated. * @return A pointer to the first occurrence of <code>substring</code> in <code>s</code>, * or <code>s</code> itself if the <code>substring</code> is empty, * or <code>NULL</code> if <code>substring</code> is not in <code>s</code>. * @stable ICU 2.4 * * @see u_strstr * @see u_strFindLast */ U_STABLE UChar * U_EXPORT2 u_strFindFirst(const UChar *s, int32_t length, const UChar *substring, int32_t subLength); /** * Find the first occurrence of a BMP code point in a string. * A surrogate code point is found only if its match in the text is not * part of a surrogate pair. * A NUL character is found at the string terminator. * * @param s The string to search (NUL-terminated). * @param c The BMP code point to find. * @return A pointer to the first occurrence of <code>c</code> in <code>s</code> * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. * @stable ICU 2.0 * * @see u_strchr32 * @see u_memchr * @see u_strstr * @see u_strFindFirst */ U_STABLE UChar * U_EXPORT2 u_strchr(const UChar *s, UChar c); /** * Find the first occurrence of a code point in a string. * A surrogate code point is found only if its match in the text is not * part of a surrogate pair. * A NUL character is found at the string terminator. * * @param s The string to search (NUL-terminated). * @param c The code point to find. * @return A pointer to the first occurrence of <code>c</code> in <code>s</code> * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. * @stable ICU 2.0 * * @see u_strchr * @see u_memchr32 * @see u_strstr * @see u_strFindFirst */ U_STABLE UChar * U_EXPORT2 u_strchr32(const UChar *s, UChar32 c); /** * Find the last occurrence of a substring in a string. * The substring is found at code point boundaries. * That means that if the substring begins with * a trail surrogate or ends with a lead surrogate, * then it is found only if these surrogates stand alone in the text. * Otherwise, the substring edge units would be matched against * halves of surrogate pairs. * * @param s The string to search (NUL-terminated). * @param substring The substring to find (NUL-terminated). * @return A pointer to the last occurrence of <code>substring</code> in <code>s</code>, * or <code>s</code> itself if the <code>substring</code> is empty, * or <code>NULL</code> if <code>substring</code> is not in <code>s</code>. * @stable ICU 2.4 * * @see u_strstr * @see u_strFindFirst * @see u_strFindLast */ U_STABLE UChar * U_EXPORT2 u_strrstr(const UChar *s, const UChar *substring); /** * Find the last occurrence of a substring in a string. * The substring is found at code point boundaries. * That means that if the substring begins with * a trail surrogate or ends with a lead surrogate, * then it is found only if these surrogates stand alone in the text. * Otherwise, the substring edge units would be matched against * halves of surrogate pairs. * * @param s The string to search. * @param length The length of s (number of UChars), or -1 if it is NUL-terminated. * @param substring The substring to find (NUL-terminated). * @param subLength The length of substring (number of UChars), or -1 if it is NUL-terminated. * @return A pointer to the last occurrence of <code>substring</code> in <code>s</code>, * or <code>s</code> itself if the <code>substring</code> is empty, * or <code>NULL</code> if <code>substring</code> is not in <code>s</code>. * @stable ICU 2.4 * * @see u_strstr * @see u_strFindLast */ U_STABLE UChar * U_EXPORT2 u_strFindLast(const UChar *s, int32_t length, const UChar *substring, int32_t subLength); /** * Find the last occurrence of a BMP code point in a string. * A surrogate code point is found only if its match in the text is not * part of a surrogate pair. * A NUL character is found at the string terminator. * * @param s The string to search (NUL-terminated). * @param c The BMP code point to find. * @return A pointer to the last occurrence of <code>c</code> in <code>s</code> * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. * @stable ICU 2.4 * * @see u_strrchr32 * @see u_memrchr * @see u_strrstr * @see u_strFindLast */ U_STABLE UChar * U_EXPORT2 u_strrchr(const UChar *s, UChar c); /** * Find the last occurrence of a code point in a string. * A surrogate code point is found only if its match in the text is not * part of a surrogate pair. * A NUL character is found at the string terminator. * * @param s The string to search (NUL-terminated). * @param c The code point to find. * @return A pointer to the last occurrence of <code>c</code> in <code>s</code> * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. * @stable ICU 2.4 * * @see u_strrchr * @see u_memchr32 * @see u_strrstr * @see u_strFindLast */ U_STABLE UChar * U_EXPORT2 u_strrchr32(const UChar *s, UChar32 c); /** * Locates the first occurrence in the string <code>string</code> of any of the characters * in the string <code>matchSet</code>. * Works just like C's strpbrk but with Unicode. * * @param string The string in which to search, NUL-terminated. * @param matchSet A NUL-terminated string defining a set of code points * for which to search in the text string. * @return A pointer to the character in <code>string</code> that matches one of the * characters in <code>matchSet</code>, or NULL if no such character is found. * @stable ICU 2.0 */ U_STABLE UChar * U_EXPORT2 u_strpbrk(const UChar *string, const UChar *matchSet); /** * Returns the number of consecutive characters in <code>string</code>, * beginning with the first, that do not occur somewhere in <code>matchSet</code>. * Works just like C's strcspn but with Unicode. * * @param string The string in which to search, NUL-terminated. * @param matchSet A NUL-terminated string defining a set of code points * for which to search in the text string. * @return The number of initial characters in <code>string</code> that do not * occur in <code>matchSet</code>. * @see u_strspn * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_strcspn(const UChar *string, const UChar *matchSet); /** * Returns the number of consecutive characters in <code>string</code>, * beginning with the first, that occur somewhere in <code>matchSet</code>. * Works just like C's strspn but with Unicode. * * @param string The string in which to search, NUL-terminated. * @param matchSet A NUL-terminated string defining a set of code points * for which to search in the text string. * @return The number of initial characters in <code>string</code> that do * occur in <code>matchSet</code>. * @see u_strcspn * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_strspn(const UChar *string, const UChar *matchSet); /** * The string tokenizer API allows an application to break a string into * tokens. Unlike strtok(), the saveState (the current pointer within the * original string) is maintained in saveState. In the first call, the * argument src is a pointer to the string. In subsequent calls to * return successive tokens of that string, src must be specified as * NULL. The value saveState is set by this function to maintain the * function's position within the string, and on each subsequent call * you must give this argument the same variable. This function does * handle surrogate pairs. This function is similar to the strtok_r() * the POSIX Threads Extension (1003.1c-1995) version. * * @param src String containing token(s). This string will be modified. * After the first call to u_strtok_r(), this argument must * be NULL to get to the next token. * @param delim Set of delimiter characters (Unicode code points). * @param saveState The current pointer within the original string, * which is set by this function. The saveState * parameter should the address of a local variable of type * UChar *. (i.e. defined "Uhar *myLocalSaveState" and use * &myLocalSaveState for this parameter). * @return A pointer to the next token found in src, or NULL * when there are no more tokens. * @stable ICU 2.0 */ U_STABLE UChar * U_EXPORT2 u_strtok_r(UChar *src, const UChar *delim, UChar **saveState); /** * Compare two Unicode strings for bitwise equality (code unit order). * * @param s1 A string to compare. * @param s2 A string to compare. * @return 0 if <code>s1</code> and <code>s2</code> are bitwise equal; a negative * value if <code>s1</code> is bitwise less than <code>s2,</code>; a positive * value if <code>s1</code> is bitwise greater than <code>s2</code>. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_strcmp(const UChar *s1, const UChar *s2); /** * Compare two Unicode strings in code point order. * See u_strCompare for details. * * @param s1 A string to compare. * @param s2 A string to compare. * @return a negative/zero/positive integer corresponding to whether * the first string is less than/equal to/greater than the second one * in code point order * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_strcmpCodePointOrder(const UChar *s1, const UChar *s2); /** * Compare two Unicode strings (binary order). * * The comparison can be done in code unit order or in code point order. * They differ only in UTF-16 when * comparing supplementary code points (U+10000..U+10ffff) * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff). * In code unit order, high BMP code points sort after supplementary code points * because they are stored as pairs of surrogates which are at U+d800..U+dfff. * * This functions works with strings of different explicitly specified lengths * unlike the ANSI C-like u_strcmp() and u_memcmp() etc. * NUL-terminated strings are possible with length arguments of -1. * * @param s1 First source string. * @param length1 Length of first source string, or -1 if NUL-terminated. * * @param s2 Second source string. * @param length2 Length of second source string, or -1 if NUL-terminated. * * @param codePointOrder Choose between code unit order (FALSE) * and code point order (TRUE). * * @return <0 or 0 or >0 as usual for string comparisons * * @stable ICU 2.2 */ U_STABLE int32_t U_EXPORT2 u_strCompare(const UChar *s1, int32_t length1, const UChar *s2, int32_t length2, UBool codePointOrder); /** * Compare two Unicode strings (binary order) * as presented by UCharIterator objects. * Works otherwise just like u_strCompare(). * * Both iterators are reset to their start positions. * When the function returns, it is undefined where the iterators * have stopped. * * @param iter1 First source string iterator. * @param iter2 Second source string iterator. * @param codePointOrder Choose between code unit order (FALSE) * and code point order (TRUE). * * @return <0 or 0 or >0 as usual for string comparisons * * @see u_strCompare * * @stable ICU 2.6 */ U_STABLE int32_t U_EXPORT2 u_strCompareIter(UCharIterator *iter1, UCharIterator *iter2, UBool codePointOrder); #ifndef U_COMPARE_CODE_POINT_ORDER /* see also unistr.h and unorm.h */ /** * Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc: * Compare strings in code point order instead of code unit order. * @stable ICU 2.2 */ #define U_COMPARE_CODE_POINT_ORDER 0x8000 #endif /** * Compare two strings case-insensitively using full case folding. * This is equivalent to * u_strCompare(u_strFoldCase(s1, options), * u_strFoldCase(s2, options), * (options&U_COMPARE_CODE_POINT_ORDER)!=0). * * The comparison can be done in UTF-16 code unit order or in code point order. * They differ only when comparing supplementary code points (U+10000..U+10ffff) * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff). * In code unit order, high BMP code points sort after supplementary code points * because they are stored as pairs of surrogates which are at U+d800..U+dfff. * * This functions works with strings of different explicitly specified lengths * unlike the ANSI C-like u_strcmp() and u_memcmp() etc. * NUL-terminated strings are possible with length arguments of -1. * * @param s1 First source string. * @param length1 Length of first source string, or -1 if NUL-terminated. * * @param s2 Second source string. * @param length2 Length of second source string, or -1 if NUL-terminated. * * @param options A bit set of options: * - U_FOLD_CASE_DEFAULT or 0 is used for default options: * Comparison in code unit order with default case folding. * * - U_COMPARE_CODE_POINT_ORDER * Set to choose code point order instead of code unit order * (see u_strCompare for details). * * - U_FOLD_CASE_EXCLUDE_SPECIAL_I * * @param pErrorCode Must be a valid pointer to an error code value, * which must not indicate a failure before the function call. * * @return <0 or 0 or >0 as usual for string comparisons * * @stable ICU 2.2 */ U_STABLE int32_t U_EXPORT2 u_strCaseCompare(const UChar *s1, int32_t length1, const UChar *s2, int32_t length2, uint32_t options, UErrorCode *pErrorCode); /** * Compare two ustrings for bitwise equality. * Compares at most <code>n</code> characters. * * @param ucs1 A string to compare. * @param ucs2 A string to compare. * @param n The maximum number of characters to compare. * @return 0 if <code>s1</code> and <code>s2</code> are bitwise equal; a negative * value if <code>s1</code> is bitwise less than <code>s2</code>; a positive * value if <code>s1</code> is bitwise greater than <code>s2</code>. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_strncmp(const UChar *ucs1, const UChar *ucs2, int32_t n); /** * Compare two Unicode strings in code point order. * This is different in UTF-16 from u_strncmp() if supplementary characters are present. * For details, see u_strCompare(). * * @param s1 A string to compare. * @param s2 A string to compare. * @param n The maximum number of characters to compare. * @return a negative/zero/positive integer corresponding to whether * the first string is less than/equal to/greater than the second one * in code point order * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_strncmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t n); /** * Compare two strings case-insensitively using full case folding. * This is equivalent to u_strcmp(u_strFoldCase(s1, options), u_strFoldCase(s2, options)). * * @param s1 A string to compare. * @param s2 A string to compare. * @param options A bit set of options: * - U_FOLD_CASE_DEFAULT or 0 is used for default options: * Comparison in code unit order with default case folding. * * - U_COMPARE_CODE_POINT_ORDER * Set to choose code point order instead of code unit order * (see u_strCompare for details). * * - U_FOLD_CASE_EXCLUDE_SPECIAL_I * * @return A negative, zero, or positive integer indicating the comparison result. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_strcasecmp(const UChar *s1, const UChar *s2, uint32_t options); /** * Compare two strings case-insensitively using full case folding. * This is equivalent to u_strcmp(u_strFoldCase(s1, at most n, options), * u_strFoldCase(s2, at most n, options)). * * @param s1 A string to compare. * @param s2 A string to compare. * @param n The maximum number of characters each string to case-fold and then compare. * @param options A bit set of options: * - U_FOLD_CASE_DEFAULT or 0 is used for default options: * Comparison in code unit order with default case folding. * * - U_COMPARE_CODE_POINT_ORDER * Set to choose code point order instead of code unit order * (see u_strCompare for details). * * - U_FOLD_CASE_EXCLUDE_SPECIAL_I * * @return A negative, zero, or positive integer indicating the comparison result. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_strncasecmp(const UChar *s1, const UChar *s2, int32_t n, uint32_t options); /** * Compare two strings case-insensitively using full case folding. * This is equivalent to u_strcmp(u_strFoldCase(s1, n, options), * u_strFoldCase(s2, n, options)). * * @param s1 A string to compare. * @param s2 A string to compare. * @param length The number of characters in each string to case-fold and then compare. * @param options A bit set of options: * - U_FOLD_CASE_DEFAULT or 0 is used for default options: * Comparison in code unit order with default case folding. * * - U_COMPARE_CODE_POINT_ORDER * Set to choose code point order instead of code unit order * (see u_strCompare for details). * * - U_FOLD_CASE_EXCLUDE_SPECIAL_I * * @return A negative, zero, or positive integer indicating the comparison result. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options); /** * Copy a ustring. Adds a null terminator. * * @param dst The destination string. * @param src The source string. * @return A pointer to <code>dst</code>. * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 u_strcpy(UChar *dst, const UChar *src); /** * Copy a ustring. * Copies at most <code>n</code> characters. The result will be null terminated * if the length of <code>src</code> is less than <code>n</code>. * * @param dst The destination string. * @param src The source string. * @param n The maximum number of characters to copy. * @return A pointer to <code>dst</code>. * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 u_strncpy(UChar *dst, const UChar *src, int32_t n); #if !UCONFIG_NO_CONVERSION /** * Copy a byte string encoded in the default codepage to a ustring. * Adds a null terminator. * Performs a host byte to UChar conversion * * @param dst The destination string. * @param src The source string. * @return A pointer to <code>dst</code>. * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 u_uastrcpy(UChar *dst, const char *src ); /** * Copy a byte string encoded in the default codepage to a ustring. * Copies at most <code>n</code> characters. The result will be null terminated * if the length of <code>src</code> is less than <code>n</code>. * Performs a host byte to UChar conversion * * @param dst The destination string. * @param src The source string. * @param n The maximum number of characters to copy. * @return A pointer to <code>dst</code>. * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 u_uastrncpy(UChar *dst, const char *src, int32_t n); /** * Copy ustring to a byte string encoded in the default codepage. * Adds a null terminator. * Performs a UChar to host byte conversion * * @param dst The destination string. * @param src The source string. * @return A pointer to <code>dst</code>. * @stable ICU 2.0 */ U_STABLE char* U_EXPORT2 u_austrcpy(char *dst, const UChar *src ); /** * Copy ustring to a byte string encoded in the default codepage. * Copies at most <code>n</code> characters. The result will be null terminated * if the length of <code>src</code> is less than <code>n</code>. * Performs a UChar to host byte conversion * * @param dst The destination string. * @param src The source string. * @param n The maximum number of characters to copy. * @return A pointer to <code>dst</code>. * @stable ICU 2.0 */ U_STABLE char* U_EXPORT2 u_austrncpy(char *dst, const UChar *src, int32_t n ); #endif /** * Synonym for memcpy(), but with UChars only. * @param dest The destination string * @param src The source string * @param count The number of characters to copy * @return A pointer to <code>dest</code> * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 u_memcpy(UChar *dest, const UChar *src, int32_t count); /** * Synonym for memmove(), but with UChars only. * @param dest The destination string * @param src The source string * @param count The number of characters to move * @return A pointer to <code>dest</code> * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 u_memmove(UChar *dest, const UChar *src, int32_t count); /** * Initialize <code>count</code> characters of <code>dest</code> to <code>c</code>. * * @param dest The destination string. * @param c The character to initialize the string. * @param count The maximum number of characters to set. * @return A pointer to <code>dest</code>. * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 u_memset(UChar *dest, UChar c, int32_t count); /** * Compare the first <code>count</code> UChars of each buffer. * * @param buf1 The first string to compare. * @param buf2 The second string to compare. * @param count The maximum number of UChars to compare. * @return When buf1 < buf2, a negative number is returned. * When buf1 == buf2, 0 is returned. * When buf1 > buf2, a positive number is returned. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_memcmp(const UChar *buf1, const UChar *buf2, int32_t count); /** * Compare two Unicode strings in code point order. * This is different in UTF-16 from u_memcmp() if supplementary characters are present. * For details, see u_strCompare(). * * @param s1 A string to compare. * @param s2 A string to compare. * @param count The maximum number of characters to compare. * @return a negative/zero/positive integer corresponding to whether * the first string is less than/equal to/greater than the second one * in code point order * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_memcmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t count); /** * Find the first occurrence of a BMP code point in a string. * A surrogate code point is found only if its match in the text is not * part of a surrogate pair. * A NUL character is found at the string terminator. * * @param s The string to search (contains <code>count</code> UChars). * @param c The BMP code point to find. * @param count The length of the string. * @return A pointer to the first occurrence of <code>c</code> in <code>s</code> * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. * @stable ICU 2.0 * * @see u_strchr * @see u_memchr32 * @see u_strFindFirst */ U_STABLE UChar* U_EXPORT2 u_memchr(const UChar *s, UChar c, int32_t count); /** * Find the first occurrence of a code point in a string. * A surrogate code point is found only if its match in the text is not * part of a surrogate pair. * A NUL character is found at the string terminator. * * @param s The string to search (contains <code>count</code> UChars). * @param c The code point to find. * @param count The length of the string. * @return A pointer to the first occurrence of <code>c</code> in <code>s</code> * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. * @stable ICU 2.0 * * @see u_strchr32 * @see u_memchr * @see u_strFindFirst */ U_STABLE UChar* U_EXPORT2 u_memchr32(const UChar *s, UChar32 c, int32_t count); /** * Find the last occurrence of a BMP code point in a string. * A surrogate code point is found only if its match in the text is not * part of a surrogate pair. * A NUL character is found at the string terminator. * * @param s The string to search (contains <code>count</code> UChars). * @param c The BMP code point to find. * @param count The length of the string. * @return A pointer to the last occurrence of <code>c</code> in <code>s</code> * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. * @stable ICU 2.4 * * @see u_strrchr * @see u_memrchr32 * @see u_strFindLast */ U_STABLE UChar* U_EXPORT2 u_memrchr(const UChar *s, UChar c, int32_t count); /** * Find the last occurrence of a code point in a string. * A surrogate code point is found only if its match in the text is not * part of a surrogate pair. * A NUL character is found at the string terminator. * * @param s The string to search (contains <code>count</code> UChars). * @param c The code point to find. * @param count The length of the string. * @return A pointer to the last occurrence of <code>c</code> in <code>s</code> * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. * @stable ICU 2.4 * * @see u_strrchr32 * @see u_memrchr * @see u_strFindLast */ U_STABLE UChar* U_EXPORT2 u_memrchr32(const UChar *s, UChar32 c, int32_t count); /** * Unicode String literals in C. * We need one macro to declare a variable for the string * and to statically preinitialize it if possible, * and a second macro to dynamically intialize such a string variable if necessary. * * The macros are defined for maximum performance. * They work only for strings that contain "invariant characters", i.e., * only latin letters, digits, and some punctuation. * See utypes.h for details. * * A pair of macros for a single string must be used with the same * parameters. * The string parameter must be a C string literal. * The length of the string, not including the terminating * <code>NUL</code>, must be specified as a constant. * The U_STRING_DECL macro should be invoked exactly once for one * such string variable before it is used. * * Usage: * <pre> * U_STRING_DECL(ustringVar1, "Quick-Fox 2", 11); * U_STRING_DECL(ustringVar2, "jumps 5%", 8); * static UBool didInit=FALSE; * * int32_t function() { * if(!didInit) { * U_STRING_INIT(ustringVar1, "Quick-Fox 2", 11); * U_STRING_INIT(ustringVar2, "jumps 5%", 8); * didInit=TRUE; * } * return u_strcmp(ustringVar1, ustringVar2); * } * </pre> * * Note that the macros will NOT consistently work if their argument is another #define. * The following will not work on all platforms, don't use it. * * <pre> * #define GLUCK "Mr. Gluck" * U_STRING_DECL(var, GLUCK, 9) * U_STRING_INIT(var, GLUCK, 9) * </pre> * * Instead, use the string literal "Mr. Gluck" as the argument to both macro * calls. * * * @stable ICU 2.0 */ #if defined(U_DECLARE_UTF16) # define U_STRING_DECL(var, cs, length) static const UChar var[(length)+1]=U_DECLARE_UTF16(cs) /**@stable ICU 2.0 */ # define U_STRING_INIT(var, cs, length) #elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16))) # define U_STRING_DECL(var, cs, length) static const UChar var[(length)+1]=L ## cs /**@stable ICU 2.0 */ # define U_STRING_INIT(var, cs, length) #elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY # define U_STRING_DECL(var, cs, length) static const UChar var[(length)+1]=cs /**@stable ICU 2.0 */ # define U_STRING_INIT(var, cs, length) #else # define U_STRING_DECL(var, cs, length) static UChar var[(length)+1] /**@stable ICU 2.0 */ # define U_STRING_INIT(var, cs, length) u_charsToUChars(cs, var, length+1) #endif /** * Unescape a string of characters and write the resulting * Unicode characters to the destination buffer. The following escape * sequences are recognized: * * \\uhhhh 4 hex digits; h in [0-9A-Fa-f] * \\Uhhhhhhhh 8 hex digits * \\xhh 1-2 hex digits * \\x{h...} 1-8 hex digits * \\ooo 1-3 octal digits; o in [0-7] * \\cX control-X; X is masked with 0x1F * * as well as the standard ANSI C escapes: * * \\a => U+0007, \\b => U+0008, \\t => U+0009, \\n => U+000A, * \\v => U+000B, \\f => U+000C, \\r => U+000D, \\e => U+001B, * \\&quot; => U+0022, \\' => U+0027, \\? => U+003F, \\\\ => U+005C * * Anything else following a backslash is generically escaped. For * example, "[a\\-z]" returns "[a-z]". * * If an escape sequence is ill-formed, this method returns an empty * string. An example of an ill-formed sequence is "\\u" followed by * fewer than 4 hex digits. * * The above characters are recognized in the compiler's codepage, * that is, they are coded as 'u', '\\', etc. Characters that are * not parts of escape sequences are converted using u_charsToUChars(). * * This function is similar to UnicodeString::unescape() but not * identical to it. The latter takes a source UnicodeString, so it * does escape recognition but no conversion. * * @param src a zero-terminated string of invariant characters * @param dest pointer to buffer to receive converted and unescaped * text and, if there is room, a zero terminator. May be NULL for * preflighting, in which case no UChars will be written, but the * return value will still be valid. On error, an empty string is * stored here (if possible). * @param destCapacity the number of UChars that may be written at * dest. Ignored if dest == NULL. * @return the length of unescaped string. * @see u_unescapeAt * @see UnicodeString#unescape() * @see UnicodeString#unescapeAt() * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_unescape(const char *src, UChar *dest, int32_t destCapacity); U_CDECL_BEGIN /** * Callback function for u_unescapeAt() that returns a character of * the source text given an offset and a context pointer. The context * pointer will be whatever is passed into u_unescapeAt(). * * @param offset pointer to the offset that will be passed to u_unescapeAt(). * @param context an opaque pointer passed directly into u_unescapeAt() * @return the character represented by the escape sequence at * offset * @see u_unescapeAt * @stable ICU 2.0 */ typedef UChar (U_CALLCONV *UNESCAPE_CHAR_AT)(int32_t offset, void *context); U_CDECL_END /** * Unescape a single sequence. The character at offset-1 is assumed * (without checking) to be a backslash. This method takes a callback * pointer to a function that returns the UChar at a given offset. By * varying this callback, ICU functions are able to unescape char* * strings, UnicodeString objects, and UFILE pointers. * * If offset is out of range, or if the escape sequence is ill-formed, * (UChar32)0xFFFFFFFF is returned. See documentation of u_unescape() * for a list of recognized sequences. * * @param charAt callback function that returns a UChar of the source * text given an offset and a context pointer. * @param offset pointer to the offset that will be passed to charAt. * The offset value will be updated upon return to point after the * last parsed character of the escape sequence. On error the offset * is unchanged. * @param length the number of characters in the source text. The * last character of the source text is considered to be at offset * length-1. * @param context an opaque pointer passed directly into charAt. * @return the character represented by the escape sequence at * offset, or (UChar32)0xFFFFFFFF on error. * @see u_unescape() * @see UnicodeString#unescape() * @see UnicodeString#unescapeAt() * @stable ICU 2.0 */ U_STABLE UChar32 U_EXPORT2 u_unescapeAt(UNESCAPE_CHAR_AT charAt, int32_t *offset, int32_t length, void *context); /** * Uppercase the characters in a string. * Casing is locale-dependent and context-sensitive. * The result may be longer or shorter than the original. * The source string and the destination buffer are allowed to overlap. * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then * dest may be NULL and the function will only return the length of the result * without writing any of the result string. * @param src The original string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param locale The locale to consider, or "" for the root locale or NULL for the default locale. * @param pErrorCode Must be a valid pointer to an error code value, * which must not indicate a failure before the function call. * @return The length of the result string. It may be greater than destCapacity. In that case, * only some of the result was written to the destination buffer. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_strToUpper(UChar *dest, int32_t destCapacity, const UChar *src, int32_t srcLength, const char *locale, UErrorCode *pErrorCode); /** * Lowercase the characters in a string. * Casing is locale-dependent and context-sensitive. * The result may be longer or shorter than the original. * The source string and the destination buffer are allowed to overlap. * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then * dest may be NULL and the function will only return the length of the result * without writing any of the result string. * @param src The original string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param locale The locale to consider, or "" for the root locale or NULL for the default locale. * @param pErrorCode Must be a valid pointer to an error code value, * which must not indicate a failure before the function call. * @return The length of the result string. It may be greater than destCapacity. In that case, * only some of the result was written to the destination buffer. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_strToLower(UChar *dest, int32_t destCapacity, const UChar *src, int32_t srcLength, const char *locale, UErrorCode *pErrorCode); #if !UCONFIG_NO_BREAK_ITERATION /** * Titlecase a string. * Casing is locale-dependent and context-sensitive. * Titlecasing uses a break iterator to find the first characters of words * that are to be titlecased. It titlecases those characters and lowercases * all others. * * The titlecase break iterator can be provided to customize for arbitrary * styles, using rules and dictionaries beyond the standard iterators. * It may be more efficient to always provide an iterator to avoid * opening and closing one for each string. * The standard titlecase iterator for the root locale implements the * algorithm of Unicode TR 21. * * This function uses only the setText(), first() and next() methods of the * provided break iterator. * * The result may be longer or shorter than the original. * The source string and the destination buffer are allowed to overlap. * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then * dest may be NULL and the function will only return the length of the result * without writing any of the result string. * @param src The original string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param titleIter A break iterator to find the first characters of words * that are to be titlecased. * If none is provided (NULL), then a standard titlecase * break iterator is opened. * @param locale The locale to consider, or "" for the root locale or NULL for the default locale. * @param pErrorCode Must be a valid pointer to an error code value, * which must not indicate a failure before the function call. * @return The length of the result string. It may be greater than destCapacity. In that case, * only some of the result was written to the destination buffer. * @stable ICU 2.1 */ U_STABLE int32_t U_EXPORT2 u_strToTitle(UChar *dest, int32_t destCapacity, const UChar *src, int32_t srcLength, UBreakIterator *titleIter, const char *locale, UErrorCode *pErrorCode); #endif /** * Case-fold the characters in a string. * Case-folding is locale-independent and not context-sensitive, * but there is an option for whether to include or exclude mappings for dotted I * and dotless i that are marked with 'I' in CaseFolding.txt. * The result may be longer or shorter than the original. * The source string and the destination buffer are allowed to overlap. * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then * dest may be NULL and the function will only return the length of the result * without writing any of the result string. * @param src The original string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param options Either U_FOLD_CASE_DEFAULT or U_FOLD_CASE_EXCLUDE_SPECIAL_I * @param pErrorCode Must be a valid pointer to an error code value, * which must not indicate a failure before the function call. * @return The length of the result string. It may be greater than destCapacity. In that case, * only some of the result was written to the destination buffer. * @stable ICU 2.0 */ U_STABLE int32_t U_EXPORT2 u_strFoldCase(UChar *dest, int32_t destCapacity, const UChar *src, int32_t srcLength, uint32_t options, UErrorCode *pErrorCode); #if defined(U_WCHAR_IS_UTF16) || defined(U_WCHAR_IS_UTF32) || !UCONFIG_NO_CONVERSION /** * Convert a UTF-16 string to a wchar_t string. * If it is known at compile time that wchar_t strings are in UTF-16 or UTF-32, then * this function simply calls the fast, dedicated function for that. * Otherwise, two conversions UTF-16 -> default charset -> wchar_t* are performed. * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of wchar_t's). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param pDestLength A pointer to receive the number of units written to the destination. If * pDestLength!=NULL then *pDestLength is always set to the * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param pErrorCode Must be a valid pointer to an error code value, * which must not indicate a failure before the function call. * @return The pointer to destination buffer. * @stable ICU 2.0 */ U_STABLE wchar_t* U_EXPORT2 u_strToWCS(wchar_t *dest, int32_t destCapacity, int32_t *pDestLength, const UChar *src, int32_t srcLength, UErrorCode *pErrorCode); /** * Convert a wchar_t string to UTF-16. * If it is known at compile time that wchar_t strings are in UTF-16 or UTF-32, then * this function simply calls the fast, dedicated function for that. * Otherwise, two conversions wchar_t* -> default charset -> UTF-16 are performed. * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param pDestLength A pointer to receive the number of units written to the destination. If * pDestLength!=NULL then *pDestLength is always set to the * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param pErrorCode Must be a valid pointer to an error code value, * which must not indicate a failure before the function call. * @return The pointer to destination buffer. * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 u_strFromWCS(UChar *dest, int32_t destCapacity, int32_t *pDestLength, const wchar_t *src, int32_t srcLength, UErrorCode *pErrorCode); #endif /* defined(U_WCHAR_IS_UTF16) || defined(U_WCHAR_IS_UTF32) || !UCONFIG_NO_CONVERSION */ /** * Convert a UTF-16 string to UTF-8. * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set. * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of chars). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param pDestLength A pointer to receive the number of units written to the destination. If * pDestLength!=NULL then *pDestLength is always set to the * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param pErrorCode Must be a valid pointer to an error code value, * which must not indicate a failure before the function call. * @return The pointer to destination buffer. * @stable ICU 2.0 * @see u_strToUTF8WithSub * @see u_strFromUTF8 */ U_STABLE char* U_EXPORT2 u_strToUTF8(char *dest, int32_t destCapacity, int32_t *pDestLength, const UChar *src, int32_t srcLength, UErrorCode *pErrorCode); /** * Convert a UTF-8 string to UTF-16. * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set. * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param pDestLength A pointer to receive the number of units written to the destination. If * pDestLength!=NULL then *pDestLength is always set to the * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param pErrorCode Must be a valid pointer to an error code value, * which must not indicate a failure before the function call. * @return The pointer to destination buffer. * @stable ICU 2.0 * @see u_strFromUTF8WithSub * @see u_strFromUTF8Lenient */ U_STABLE UChar* U_EXPORT2 u_strFromUTF8(UChar *dest, int32_t destCapacity, int32_t *pDestLength, const char *src, int32_t srcLength, UErrorCode *pErrorCode); /** * Convert a UTF-16 string to UTF-8. * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set. * * Same as u_strToUTF8() except for the additional subchar which is output for * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code. * With subchar==U_SENTINEL, this function behaves exactly like u_strToUTF8(). * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of chars). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param pDestLength A pointer to receive the number of units written to the destination. If * pDestLength!=NULL then *pDestLength is always set to the * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param subchar The substitution character to use in place of an illegal input sequence, * or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead. * A substitution character can be any valid Unicode code point (up to U+10FFFF) * except for surrogate code points (U+D800..U+DFFF). * The recommended value is U+FFFD "REPLACEMENT CHARACTER". * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0. * Set to 0 if no substitutions occur or subchar<0. * pNumSubstitutions can be NULL. * @param pErrorCode Pointer to a standard ICU error code. Its input value must * pass the U_SUCCESS() test, or else the function returns * immediately. Check for U_FAILURE() on output or use with * function chaining. (See User Guide for details.) * @return The pointer to destination buffer. * @see u_strToUTF8 * @see u_strFromUTF8WithSub * @stable ICU 3.6 */ U_STABLE char* U_EXPORT2 u_strToUTF8WithSub(char *dest, int32_t destCapacity, int32_t *pDestLength, const UChar *src, int32_t srcLength, UChar32 subchar, int32_t *pNumSubstitutions, UErrorCode *pErrorCode); /** * Convert a UTF-8 string to UTF-16. * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set. * * Same as u_strFromUTF8() except for the additional subchar which is output for * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code. * With subchar==U_SENTINEL, this function behaves exactly like u_strFromUTF8(). * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param pDestLength A pointer to receive the number of units written to the destination. If * pDestLength!=NULL then *pDestLength is always set to the * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param subchar The substitution character to use in place of an illegal input sequence, * or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead. * A substitution character can be any valid Unicode code point (up to U+10FFFF) * except for surrogate code points (U+D800..U+DFFF). * The recommended value is U+FFFD "REPLACEMENT CHARACTER". * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0. * Set to 0 if no substitutions occur or subchar<0. * pNumSubstitutions can be NULL. * @param pErrorCode Pointer to a standard ICU error code. Its input value must * pass the U_SUCCESS() test, or else the function returns * immediately. Check for U_FAILURE() on output or use with * function chaining. (See User Guide for details.) * @return The pointer to destination buffer. * @see u_strFromUTF8 * @see u_strFromUTF8Lenient * @see u_strToUTF8WithSub * @stable ICU 3.6 */ U_STABLE UChar* U_EXPORT2 u_strFromUTF8WithSub(UChar *dest, int32_t destCapacity, int32_t *pDestLength, const char *src, int32_t srcLength, UChar32 subchar, int32_t *pNumSubstitutions, UErrorCode *pErrorCode); /** * Convert a UTF-8 string to UTF-16. * * Same as u_strFromUTF8() except that this function is designed to be very fast, * which it achieves by being lenient about malformed UTF-8 sequences. * This function is intended for use in environments where UTF-8 text is * expected to be well-formed. * * Its semantics are: * - Well-formed UTF-8 text is correctly converted to well-formed UTF-16 text. * - The function will not read beyond the input string, nor write beyond * the destCapacity. * - Malformed UTF-8 results in "garbage" 16-bit Unicode strings which may not * be well-formed UTF-16. * The function will resynchronize to valid code point boundaries * within a small number of code points after an illegal sequence. * - Non-shortest forms are not detected and will result in "spoofing" output. * * For further performance improvement, if srcLength is given (>=0), * then it must be destCapacity>=srcLength. * * There is no inverse u_strToUTF8Lenient() function because there is practically * no performance gain from not checking that a UTF-16 string is well-formed. * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * Unlike for other ICU functions, if srcLength>=0 then it * must be destCapacity>=srcLength. * @param pDestLength A pointer to receive the number of units written to the destination. If * pDestLength!=NULL then *pDestLength is always set to the * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * Unlike for other ICU functions, if srcLength>=0 but * destCapacity<srcLength, then *pDestLength will be set to srcLength * (and U_BUFFER_OVERFLOW_ERROR will be set) * regardless of the actual result length. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param pErrorCode Pointer to a standard ICU error code. Its input value must * pass the U_SUCCESS() test, or else the function returns * immediately. Check for U_FAILURE() on output or use with * function chaining. (See User Guide for details.) * @return The pointer to destination buffer. * @see u_strFromUTF8 * @see u_strFromUTF8WithSub * @see u_strToUTF8WithSub * @stable ICU 3.6 */ U_STABLE UChar * U_EXPORT2 u_strFromUTF8Lenient(UChar *dest, int32_t destCapacity, int32_t *pDestLength, const char *src, int32_t srcLength, UErrorCode *pErrorCode); /** * Convert a UTF-16 string to UTF-32. * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set. * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChar32s). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param pDestLength A pointer to receive the number of units written to the destination. If * pDestLength!=NULL then *pDestLength is always set to the * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param pErrorCode Must be a valid pointer to an error code value, * which must not indicate a failure before the function call. * @return The pointer to destination buffer. * @see u_strToUTF32WithSub * @see u_strFromUTF32 * @stable ICU 2.0 */ U_STABLE UChar32* U_EXPORT2 u_strToUTF32(UChar32 *dest, int32_t destCapacity, int32_t *pDestLength, const UChar *src, int32_t srcLength, UErrorCode *pErrorCode); /** * Convert a UTF-32 string to UTF-16. * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set. * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param pDestLength A pointer to receive the number of units written to the destination. If * pDestLength!=NULL then *pDestLength is always set to the * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param pErrorCode Must be a valid pointer to an error code value, * which must not indicate a failure before the function call. * @return The pointer to destination buffer. * @see u_strFromUTF32WithSub * @see u_strToUTF32 * @stable ICU 2.0 */ U_STABLE UChar* U_EXPORT2 u_strFromUTF32(UChar *dest, int32_t destCapacity, int32_t *pDestLength, const UChar32 *src, int32_t srcLength, UErrorCode *pErrorCode); /** * Convert a UTF-16 string to UTF-32. * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set. * * Same as u_strToUTF32() except for the additional subchar which is output for * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code. * With subchar==U_SENTINEL, this function behaves exactly like u_strToUTF32(). * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChar32s). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param pDestLength A pointer to receive the number of units written to the destination. If * pDestLength!=NULL then *pDestLength is always set to the * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param subchar The substitution character to use in place of an illegal input sequence, * or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead. * A substitution character can be any valid Unicode code point (up to U+10FFFF) * except for surrogate code points (U+D800..U+DFFF). * The recommended value is U+FFFD "REPLACEMENT CHARACTER". * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0. * Set to 0 if no substitutions occur or subchar<0. * pNumSubstitutions can be NULL. * @param pErrorCode Pointer to a standard ICU error code. Its input value must * pass the U_SUCCESS() test, or else the function returns * immediately. Check for U_FAILURE() on output or use with * function chaining. (See User Guide for details.) * @return The pointer to destination buffer. * @see u_strToUTF32 * @see u_strFromUTF32WithSub * @stable ICU 4.2 */ U_STABLE UChar32* U_EXPORT2 u_strToUTF32WithSub(UChar32 *dest, int32_t destCapacity, int32_t *pDestLength, const UChar *src, int32_t srcLength, UChar32 subchar, int32_t *pNumSubstitutions, UErrorCode *pErrorCode); /** * Convert a UTF-32 string to UTF-16. * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set. * * Same as u_strFromUTF32() except for the additional subchar which is output for * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code. * With subchar==U_SENTINEL, this function behaves exactly like u_strFromUTF32(). * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param pDestLength A pointer to receive the number of units written to the destination. If * pDestLength!=NULL then *pDestLength is always set to the * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param subchar The substitution character to use in place of an illegal input sequence, * or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead. * A substitution character can be any valid Unicode code point (up to U+10FFFF) * except for surrogate code points (U+D800..U+DFFF). * The recommended value is U+FFFD "REPLACEMENT CHARACTER". * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0. * Set to 0 if no substitutions occur or subchar<0. * pNumSubstitutions can be NULL. * @param pErrorCode Pointer to a standard ICU error code. Its input value must * pass the U_SUCCESS() test, or else the function returns * immediately. Check for U_FAILURE() on output or use with * function chaining. (See User Guide for details.) * @return The pointer to destination buffer. * @see u_strFromUTF32 * @see u_strToUTF32WithSub * @stable ICU 4.2 */ U_STABLE UChar* U_EXPORT2 u_strFromUTF32WithSub(UChar *dest, int32_t destCapacity, int32_t *pDestLength, const UChar32 *src, int32_t srcLength, UChar32 subchar, int32_t *pNumSubstitutions, UErrorCode *pErrorCode); /** * Convert a 16-bit Unicode string to Java Modified UTF-8. * See http://java.sun.com/javase/6/docs/api/java/io/DataInput.html#modified-utf-8 * * This function behaves according to the documentation for Java DataOutput.writeUTF() * except that it does not encode the output length in the destination buffer * and does not have an output length restriction. * See http://java.sun.com/javase/6/docs/api/java/io/DataOutput.html#writeUTF(java.lang.String) * * The input string need not be well-formed UTF-16. * (Therefore there is no subchar parameter.) * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of chars). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param pDestLength A pointer to receive the number of units written to the destination. If * pDestLength!=NULL then *pDestLength is always set to the * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param pErrorCode Pointer to a standard ICU error code. Its input value must * pass the U_SUCCESS() test, or else the function returns * immediately. Check for U_FAILURE() on output or use with * function chaining. (See User Guide for details.) * @return The pointer to destination buffer. * @stable ICU 4.4 * @see u_strToUTF8WithSub * @see u_strFromJavaModifiedUTF8WithSub */ U_STABLE char* U_EXPORT2 u_strToJavaModifiedUTF8( char *dest, int32_t destCapacity, int32_t *pDestLength, const UChar *src, int32_t srcLength, UErrorCode *pErrorCode); /** * Convert a Java Modified UTF-8 string to a 16-bit Unicode string. * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set. * * This function behaves according to the documentation for Java DataInput.readUTF() * except that it takes a length parameter rather than * interpreting the first two input bytes as the length. * See http://java.sun.com/javase/6/docs/api/java/io/DataInput.html#readUTF() * * The output string may not be well-formed UTF-16. * * @param dest A buffer for the result string. The result will be zero-terminated if * the buffer is large enough. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param pDestLength A pointer to receive the number of units written to the destination. If * pDestLength!=NULL then *pDestLength is always set to the * number of output units corresponding to the transformation of * all the input units, even in case of a buffer overflow. * @param src The original source string * @param srcLength The length of the original string. If -1, then src must be zero-terminated. * @param subchar The substitution character to use in place of an illegal input sequence, * or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead. * A substitution character can be any valid Unicode code point (up to U+10FFFF) * except for surrogate code points (U+D800..U+DFFF). * The recommended value is U+FFFD "REPLACEMENT CHARACTER". * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0. * Set to 0 if no substitutions occur or subchar<0. * pNumSubstitutions can be NULL. * @param pErrorCode Pointer to a standard ICU error code. Its input value must * pass the U_SUCCESS() test, or else the function returns * immediately. Check for U_FAILURE() on output or use with * function chaining. (See User Guide for details.) * @return The pointer to destination buffer. * @see u_strFromUTF8WithSub * @see u_strFromUTF8Lenient * @see u_strToJavaModifiedUTF8 * @stable ICU 4.4 */ U_STABLE UChar* U_EXPORT2 u_strFromJavaModifiedUTF8WithSub( UChar *dest, int32_t destCapacity, int32_t *pDestLength, const char *src, int32_t srcLength, UChar32 subchar, int32_t *pNumSubstitutions, UErrorCode *pErrorCode); #endif
{ "pile_set_name": "Github" }
from pyqrllib.pyqrllib import bin2hstr from qrl.core.State import State from qrl.core.StateContainer import StateContainer from qrl.core.misc import logger from qrl.core.txs.Transaction import Transaction from qrl.generated.qrl_pb2 import LatticePKMetadata class LatticeTransaction(Transaction): def __init__(self, protobuf_transaction=None): super(LatticeTransaction, self).__init__(protobuf_transaction) @property def pk1(self): # kyber_pk return self._data.latticePK.pk1 @property def pk2(self): # dilithium_pk return self._data.latticePK.pk2 @property def pk3(self): # ecdsa_pk return self._data.latticePK.pk3 def get_data_bytes(self): return self.master_addr + \ self.fee.to_bytes(8, byteorder='big', signed=False) + \ self.pk1 + \ self.pk2 + \ self.pk3 @staticmethod def create(pk1: bytes, pk2: bytes, pk3: bytes, fee: int, xmss_pk: bytes, master_addr: bytes = None): transaction = LatticeTransaction() if master_addr: transaction._data.master_addr = master_addr transaction._data.fee = fee transaction._data.public_key = xmss_pk transaction._data.latticePK.pk1 = bytes(pk1) transaction._data.latticePK.pk2 = bytes(pk2) transaction._data.latticePK.pk3 = bytes(pk3) transaction.validate_or_raise(verify_signature=False) return transaction def _validate_custom(self) -> bool: if self.fee < 0: logger.info('State validation failed for %s because: Negative send', bin2hstr(self.txhash)) return False return True def _validate_extended(self, state_container: StateContainer) -> bool: if state_container.block_number < state_container.current_dev_config.hard_fork_heights[0]: logger.warning("[LatticeTransaction] Hard Fork Feature not yet activated") return False dev_config = state_container.current_dev_config if len(self.pk1) > dev_config.lattice_pk1_max_length: # TODO: to fix kyber pk value logger.warning('Kyber PK length cannot be more than %s bytes', dev_config.lattice_pk1_max_length) logger.warning('Found length %s', len(self.pk1)) return False if len(self.pk2) > dev_config.lattice_pk2_max_length: # TODO: to fix dilithium pk value logger.warning('Dilithium PK length cannot be more than %s bytes', dev_config.lattice_pk2_max_length) logger.warning('Found length %s', len(self.pk2)) return False if len(self.pk3) > dev_config.lattice_pk3_max_length: # TODO: to fix ecdsa pk value logger.warning('ECDSA PK length cannot be more than %s bytes', dev_config.lattice_pk3_max_length) logger.warning('Found length %s', len(self.pk3)) return False tx_balance = state_container.addresses_state[self.addr_from].balance if tx_balance < self.fee: logger.info('State validation failed for %s because: Insufficient funds', bin2hstr(self.txhash)) logger.info('balance: %s, amount: %s', tx_balance, self.fee) return False if (self.addr_from, self.pk1, self.pk2, self.pk3) in state_container.lattice_pk.data: logger.info('State validation failed for %s because: Lattice PKs already exists for this address', bin2hstr(self.txhash)) return False return True def set_affected_address(self, addresses_set: set): super().set_affected_address(addresses_set) def apply(self, state: State, state_container: StateContainer) -> bool: address_state = state_container.addresses_state[self.addr_from] address_state.update_balance(state_container, self.fee, subtract=True) state_container.paginated_lattice_pk.insert(address_state, self.txhash) state_container.paginated_tx_hash.insert(address_state, self.txhash) state_container.lattice_pk.data[(self.addr_from, self.pk1, self.pk2, self.pk3)] = LatticePKMetadata(enabled=True) return self._apply_state_changes_for_PK(state_container) def revert(self, state: State, state_container: StateContainer) -> bool: address_state = state_container.addresses_state[self.addr_from] address_state.update_balance(state_container, self.fee) state_container.paginated_lattice_pk.remove(address_state, self.txhash) state_container.paginated_tx_hash.remove(address_state, self.txhash) state_container.lattice_pk.data[(self.addr_from, self.pk1, self.pk2, self.pk3)] = LatticePKMetadata(enabled=False, delete=True) return self._revert_state_changes_for_PK(state_container)
{ "pile_set_name": "Github" }
package de_LU import ( "testing" "time" "github.com/go-playground/locales" "github.com/go-playground/locales/currency" ) func TestLocale(t *testing.T) { trans := New() expected := "de_LU" if trans.Locale() != expected { t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) } } func TestPluralsRange(t *testing.T) { trans := New() tests := []struct { expected locales.PluralRule }{ // { // expected: locales.PluralRuleOther, // }, } rules := trans.PluralsRange() // expected := 1 // if len(rules) != expected { // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) // } for _, tt := range tests { r := locales.PluralRuleUnknown for i := 0; i < len(rules); i++ { if rules[i] == tt.expected { r = rules[i] break } } if r == locales.PluralRuleUnknown { t.Errorf("Expected '%s' Got '%s'", tt.expected, r) } } } func TestPluralsOrdinal(t *testing.T) { trans := New() tests := []struct { expected locales.PluralRule }{ // { // expected: locales.PluralRuleOne, // }, // { // expected: locales.PluralRuleTwo, // }, // { // expected: locales.PluralRuleFew, // }, // { // expected: locales.PluralRuleOther, // }, } rules := trans.PluralsOrdinal() // expected := 4 // if len(rules) != expected { // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) // } for _, tt := range tests { r := locales.PluralRuleUnknown for i := 0; i < len(rules); i++ { if rules[i] == tt.expected { r = rules[i] break } } if r == locales.PluralRuleUnknown { t.Errorf("Expected '%s' Got '%s'", tt.expected, r) } } } func TestPluralsCardinal(t *testing.T) { trans := New() tests := []struct { expected locales.PluralRule }{ // { // expected: locales.PluralRuleOne, // }, // { // expected: locales.PluralRuleOther, // }, } rules := trans.PluralsCardinal() // expected := 2 // if len(rules) != expected { // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) // } for _, tt := range tests { r := locales.PluralRuleUnknown for i := 0; i < len(rules); i++ { if rules[i] == tt.expected { r = rules[i] break } } if r == locales.PluralRuleUnknown { t.Errorf("Expected '%s' Got '%s'", tt.expected, r) } } } func TestRangePlurals(t *testing.T) { trans := New() tests := []struct { num1 float64 v1 uint64 num2 float64 v2 uint64 expected locales.PluralRule }{ // { // num1: 1, // v1: 1, // num2: 2, // v2: 2, // expected: locales.PluralRuleOther, // }, } for _, tt := range tests { rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) if rule != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) } } } func TestOrdinalPlurals(t *testing.T) { trans := New() tests := []struct { num float64 v uint64 expected locales.PluralRule }{ // { // num: 1, // v: 0, // expected: locales.PluralRuleOne, // }, // { // num: 2, // v: 0, // expected: locales.PluralRuleTwo, // }, // { // num: 3, // v: 0, // expected: locales.PluralRuleFew, // }, // { // num: 4, // v: 0, // expected: locales.PluralRuleOther, // }, } for _, tt := range tests { rule := trans.OrdinalPluralRule(tt.num, tt.v) if rule != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) } } } func TestCardinalPlurals(t *testing.T) { trans := New() tests := []struct { num float64 v uint64 expected locales.PluralRule }{ // { // num: 1, // v: 0, // expected: locales.PluralRuleOne, // }, // { // num: 4, // v: 0, // expected: locales.PluralRuleOther, // }, } for _, tt := range tests { rule := trans.CardinalPluralRule(tt.num, tt.v) if rule != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) } } } func TestDaysAbbreviated(t *testing.T) { trans := New() days := trans.WeekdaysAbbreviated() for i, day := range days { s := trans.WeekdayAbbreviated(time.Weekday(i)) if s != day { t.Errorf("Expected '%s' Got '%s'", day, s) } } tests := []struct { idx int expected string }{ // { // idx: 0, // expected: "Sun", // }, // { // idx: 1, // expected: "Mon", // }, // { // idx: 2, // expected: "Tue", // }, // { // idx: 3, // expected: "Wed", // }, // { // idx: 4, // expected: "Thu", // }, // { // idx: 5, // expected: "Fri", // }, // { // idx: 6, // expected: "Sat", // }, } for _, tt := range tests { s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestDaysNarrow(t *testing.T) { trans := New() days := trans.WeekdaysNarrow() for i, day := range days { s := trans.WeekdayNarrow(time.Weekday(i)) if s != day { t.Errorf("Expected '%s' Got '%s'", string(day), s) } } tests := []struct { idx int expected string }{ // { // idx: 0, // expected: "S", // }, // { // idx: 1, // expected: "M", // }, // { // idx: 2, // expected: "T", // }, // { // idx: 3, // expected: "W", // }, // { // idx: 4, // expected: "T", // }, // { // idx: 5, // expected: "F", // }, // { // idx: 6, // expected: "S", // }, } for _, tt := range tests { s := trans.WeekdayNarrow(time.Weekday(tt.idx)) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestDaysShort(t *testing.T) { trans := New() days := trans.WeekdaysShort() for i, day := range days { s := trans.WeekdayShort(time.Weekday(i)) if s != day { t.Errorf("Expected '%s' Got '%s'", day, s) } } tests := []struct { idx int expected string }{ // { // idx: 0, // expected: "Su", // }, // { // idx: 1, // expected: "Mo", // }, // { // idx: 2, // expected: "Tu", // }, // { // idx: 3, // expected: "We", // }, // { // idx: 4, // expected: "Th", // }, // { // idx: 5, // expected: "Fr", // }, // { // idx: 6, // expected: "Sa", // }, } for _, tt := range tests { s := trans.WeekdayShort(time.Weekday(tt.idx)) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestDaysWide(t *testing.T) { trans := New() days := trans.WeekdaysWide() for i, day := range days { s := trans.WeekdayWide(time.Weekday(i)) if s != day { t.Errorf("Expected '%s' Got '%s'", day, s) } } tests := []struct { idx int expected string }{ // { // idx: 0, // expected: "Sunday", // }, // { // idx: 1, // expected: "Monday", // }, // { // idx: 2, // expected: "Tuesday", // }, // { // idx: 3, // expected: "Wednesday", // }, // { // idx: 4, // expected: "Thursday", // }, // { // idx: 5, // expected: "Friday", // }, // { // idx: 6, // expected: "Saturday", // }, } for _, tt := range tests { s := trans.WeekdayWide(time.Weekday(tt.idx)) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestMonthsAbbreviated(t *testing.T) { trans := New() months := trans.MonthsAbbreviated() for i, month := range months { s := trans.MonthAbbreviated(time.Month(i + 1)) if s != month { t.Errorf("Expected '%s' Got '%s'", month, s) } } tests := []struct { idx int expected string }{ // { // idx: 1, // expected: "Jan", // }, // { // idx: 2, // expected: "Feb", // }, // { // idx: 3, // expected: "Mar", // }, // { // idx: 4, // expected: "Apr", // }, // { // idx: 5, // expected: "May", // }, // { // idx: 6, // expected: "Jun", // }, // { // idx: 7, // expected: "Jul", // }, // { // idx: 8, // expected: "Aug", // }, // { // idx: 9, // expected: "Sep", // }, // { // idx: 10, // expected: "Oct", // }, // { // idx: 11, // expected: "Nov", // }, // { // idx: 12, // expected: "Dec", // }, } for _, tt := range tests { s := trans.MonthAbbreviated(time.Month(tt.idx)) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestMonthsNarrow(t *testing.T) { trans := New() months := trans.MonthsNarrow() for i, month := range months { s := trans.MonthNarrow(time.Month(i + 1)) if s != month { t.Errorf("Expected '%s' Got '%s'", month, s) } } tests := []struct { idx int expected string }{ // { // idx: 1, // expected: "J", // }, // { // idx: 2, // expected: "F", // }, // { // idx: 3, // expected: "M", // }, // { // idx: 4, // expected: "A", // }, // { // idx: 5, // expected: "M", // }, // { // idx: 6, // expected: "J", // }, // { // idx: 7, // expected: "J", // }, // { // idx: 8, // expected: "A", // }, // { // idx: 9, // expected: "S", // }, // { // idx: 10, // expected: "O", // }, // { // idx: 11, // expected: "N", // }, // { // idx: 12, // expected: "D", // }, } for _, tt := range tests { s := trans.MonthNarrow(time.Month(tt.idx)) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestMonthsWide(t *testing.T) { trans := New() months := trans.MonthsWide() for i, month := range months { s := trans.MonthWide(time.Month(i + 1)) if s != month { t.Errorf("Expected '%s' Got '%s'", month, s) } } tests := []struct { idx int expected string }{ // { // idx: 1, // expected: "January", // }, // { // idx: 2, // expected: "February", // }, // { // idx: 3, // expected: "March", // }, // { // idx: 4, // expected: "April", // }, // { // idx: 5, // expected: "May", // }, // { // idx: 6, // expected: "June", // }, // { // idx: 7, // expected: "July", // }, // { // idx: 8, // expected: "August", // }, // { // idx: 9, // expected: "September", // }, // { // idx: 10, // expected: "October", // }, // { // idx: 11, // expected: "November", // }, // { // idx: 12, // expected: "December", // }, } for _, tt := range tests { s := string(trans.MonthWide(time.Month(tt.idx))) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestFmtTimeFull(t *testing.T) { // loc, err := time.LoadLocation("America/Toronto") // if err != nil { // t.Errorf("Expected '<nil>' Got '%s'", err) // } // fixed := time.FixedZone("OTHER", -4) tests := []struct { t time.Time expected string }{ // { // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), // expected: "9:05:01 am Eastern Standard Time", // }, // { // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), // expected: "8:05:01 pm OTHER", // }, } trans := New() for _, tt := range tests { s := trans.FmtTimeFull(tt.t) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestFmtTimeLong(t *testing.T) { // loc, err := time.LoadLocation("America/Toronto") // if err != nil { // t.Errorf("Expected '<nil>' Got '%s'", err) // } tests := []struct { t time.Time expected string }{ // { // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), // expected: "9:05:01 am EST", // }, // { // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), // expected: "8:05:01 pm EST", // }, } trans := New() for _, tt := range tests { s := trans.FmtTimeLong(tt.t) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestFmtTimeMedium(t *testing.T) { tests := []struct { t time.Time expected string }{ // { // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), // expected: "9:05:01 am", // }, // { // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), // expected: "8:05:01 pm", // }, } trans := New() for _, tt := range tests { s := trans.FmtTimeMedium(tt.t) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestFmtTimeShort(t *testing.T) { tests := []struct { t time.Time expected string }{ // { // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), // expected: "9:05 am", // }, // { // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), // expected: "8:05 pm", // }, } trans := New() for _, tt := range tests { s := trans.FmtTimeShort(tt.t) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestFmtDateFull(t *testing.T) { tests := []struct { t time.Time expected string }{ // { // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), // expected: "Wednesday, February 3, 2016", // }, } trans := New() for _, tt := range tests { s := trans.FmtDateFull(tt.t) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestFmtDateLong(t *testing.T) { tests := []struct { t time.Time expected string }{ // { // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), // expected: "February 3, 2016", // }, } trans := New() for _, tt := range tests { s := trans.FmtDateLong(tt.t) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestFmtDateMedium(t *testing.T) { tests := []struct { t time.Time expected string }{ // { // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), // expected: "Feb 3, 2016", // }, } trans := New() for _, tt := range tests { s := trans.FmtDateMedium(tt.t) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestFmtDateShort(t *testing.T) { tests := []struct { t time.Time expected string }{ // { // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), // expected: "2/3/16", // }, // { // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), // expected: "2/3/500", // }, } trans := New() for _, tt := range tests { s := trans.FmtDateShort(tt.t) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestFmtNumber(t *testing.T) { tests := []struct { num float64 v uint64 expected string }{ // { // num: 1123456.5643, // v: 2, // expected: "1,123,456.56", // }, // { // num: 1123456.5643, // v: 1, // expected: "1,123,456.6", // }, // { // num: 221123456.5643, // v: 3, // expected: "221,123,456.564", // }, // { // num: -221123456.5643, // v: 3, // expected: "-221,123,456.564", // }, // { // num: -221123456.5643, // v: 3, // expected: "-221,123,456.564", // }, // { // num: 0, // v: 2, // expected: "0.00", // }, // { // num: -0, // v: 2, // expected: "0.00", // }, // { // num: -0, // v: 2, // expected: "0.00", // }, } trans := New() for _, tt := range tests { s := trans.FmtNumber(tt.num, tt.v) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestFmtCurrency(t *testing.T) { tests := []struct { num float64 v uint64 currency currency.Type expected string }{ // { // num: 1123456.5643, // v: 2, // currency: currency.USD, // expected: "$1,123,456.56", // }, // { // num: 1123456.5643, // v: 1, // currency: currency.USD, // expected: "$1,123,456.60", // }, // { // num: 221123456.5643, // v: 3, // currency: currency.USD, // expected: "$221,123,456.564", // }, // { // num: -221123456.5643, // v: 3, // currency: currency.USD, // expected: "-$221,123,456.564", // }, // { // num: -221123456.5643, // v: 3, // currency: currency.CAD, // expected: "-CAD 221,123,456.564", // }, // { // num: 0, // v: 2, // currency: currency.USD, // expected: "$0.00", // }, // { // num: -0, // v: 2, // currency: currency.USD, // expected: "$0.00", // }, // { // num: -0, // v: 2, // currency: currency.CAD, // expected: "CAD 0.00", // }, // { // num: 1.23, // v: 0, // currency: currency.USD, // expected: "$1.00", // }, } trans := New() for _, tt := range tests { s := trans.FmtCurrency(tt.num, tt.v, tt.currency) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestFmtAccounting(t *testing.T) { tests := []struct { num float64 v uint64 currency currency.Type expected string }{ // { // num: 1123456.5643, // v: 2, // currency: currency.USD, // expected: "$1,123,456.56", // }, // { // num: 1123456.5643, // v: 1, // currency: currency.USD, // expected: "$1,123,456.60", // }, // { // num: 221123456.5643, // v: 3, // currency: currency.USD, // expected: "$221,123,456.564", // }, // { // num: -221123456.5643, // v: 3, // currency: currency.USD, // expected: "($221,123,456.564)", // }, // { // num: -221123456.5643, // v: 3, // currency: currency.CAD, // expected: "(CAD 221,123,456.564)", // }, // { // num: -0, // v: 2, // currency: currency.USD, // expected: "$0.00", // }, // { // num: -0, // v: 2, // currency: currency.CAD, // expected: "CAD 0.00", // }, // { // num: 1.23, // v: 0, // currency: currency.USD, // expected: "$1.00", // }, } trans := New() for _, tt := range tests { s := trans.FmtAccounting(tt.num, tt.v, tt.currency) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } } func TestFmtPercent(t *testing.T) { tests := []struct { num float64 v uint64 expected string }{ // { // num: 15, // v: 0, // expected: "15%", // }, // { // num: 15, // v: 2, // expected: "15.00%", // }, // { // num: 434.45, // v: 0, // expected: "434%", // }, // { // num: 34.4, // v: 2, // expected: "34.40%", // }, // { // num: -34, // v: 0, // expected: "-34%", // }, } trans := New() for _, tt := range tests { s := trans.FmtPercent(tt.num, tt.v) if s != tt.expected { t.Errorf("Expected '%s' Got '%s'", tt.expected, s) } } }
{ "pile_set_name": "Github" }
{ "id": "kerokerokeroppi-cake", "name": "Kerokerokeroppi Cake", "category": "Furniture", "games": { "nl": { "orderable": false, "interiorThemes": [ "Fairy Tale" ], "set": "Welcome amiibo Update", "rvs": [ "toby" ], "buyPrices": [ { "currency": "meow", "value": 3 } ] } } }
{ "pile_set_name": "Github" }
{ "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "SubscriptionId": { "type": "string", "metadata": { "description": "Subscrption Id where Org Policy is setup and monitoring dashboard needs to be setup." } }, "ResourceGroups": { "type": "string", "metadata": { "description": "ResourceGroup name where Org Policy is present and monitoring dashboard resource need to be setup." } }, "AIName": { "type": "string", "metadata": { "description": "Org Policy application insight Resource name." } }, "DashboardName":{ "type": "string", "metadata": { "description": "Monitoring dashboard resource name" }, "defaultValue" : "DevOpsKitMonitoring" }, "DashboardTitle":{ "type": "string", "metadata": { "description": "Monitoring dashboard Title" }, "defaultValue" : "DevOps Kit Monitoring Dashboard" }, "Location":{ "type": "string", "metadata": { "description": "Monitoring dashboard resource location" }, "defaultValue" : "DevOps Kit Monitoring Dashboard" } }, "resources": [ { "properties": { "lenses": { "0": { "order": 0, "parts": { "0": { "position": { "x": 0, "y": 0, "colSpan": 5, "rowSpan": 4 }, "metadata": { "inputs": [], "type": "Extension[azure]/HubsExtension/PartType/MarkdownPart", "settings": { "content": { "settings": { "content": "__How to use this dashboard:__\n\nThis dashboard lets you monitor the operations for various DevOps Kit workflows at your org. Each blade lets you monitor the health of some aspect of your DevOps Kit deployment (e.g., CA issues, anomalous control drifts, evaluation errors, etc.). You can click on the 'Open Chart in Analytics' link at the top right corner of any view to see the underlying data/query. (Note that some views will show 'error retrieving data' initially.)\n\n__Useful Links__: \n<br>\n[Updates on Org Policy](https://aka.ms/devopskit/orgpolicy/updates)\n<br>[Release Notes](https://aka.ms/devopskit/releasenotes)\n<br>[Org Policy Docs](https://aka.ms/devopskit/orgpolicy/docs)\n<br>[DevOps Kit Docs](http://aka.ms/devopskit/docs)\n<br>[Support](mailto:[email protected])\n\n", "title": "Monitoring your Org AzSK Setup", "subtitle": "Instructions" } } } } }, "1": { "position": { "x": 5, "y": 0, "colSpan": 6, "rowSpan": 4 }, "metadata": { "inputs": [ { "name": "ComponentId", "value": { "SubscriptionId": "[parameters('SubscriptionId')]", "ResourceGroup": "[parameters('ResourceGroups')]", "Name": "[parameters('AIName')]" } }, { "name": "Query", "value": "customEvents\r\n| where timestamp > ago(15d) and name == \"Control Scanned\" and customDimensions.ScanSource== \"Runbook\"\r\n| summarize count() by bin(timestamp, 1d),tostring(customDimensions.SubscriptionId)\r\n| summarize TotalCount=count() by timestamp\r\n| render barchart\n" }, { "name": "Dimensions", "value": { "xAxis": { "name": "timestamp", "type": "DateTime" }, "yAxis": [ { "name": "TotalCount", "type": "Int64" } ], "splitBy": [], "aggregation": "Sum" } }, { "name": "Version", "value": "1.0" }, { "name": "DashboardId", "value": "[resourceId(parameters('ResourceGroups'),'Microsoft.Portal/dashboards', parameters('DashboardName'))]" }, { "name": "resourceTypeMode", "value": "components" } ], "type": "Extension/AppInsightsExtension/PartType/AnalyticsBarChartPart", "settings": { "content": { "dashboardPartTitle": "CA - Subs Reporting Scans", "dashboardPartSubTitle": "Number of subscriptions reporting CA scans" } }, "asset": { "idInputName": "ComponentId", "type": "ApplicationInsights" } } }, "2": { "position": { "x": 11, "y": 0, "colSpan": 6, "rowSpan": 4 }, "metadata": { "inputs": [ { "name": "ComponentId", "value": { "SubscriptionId": "[parameters('SubscriptionId')]", "ResourceGroup": "[parameters('ResourceGroups')]", "Name": "[parameters('AIName')]" } }, { "name": "Query", "value": "//Negative Drift\nlet ControlResults = customEvents\n| where timestamp < ago(2d) and timestamp >= ago(4d)\n| where name == \"Control Scanned\" and customDimensions.HasAttestationReadPermissions == \"True\" and customDimensions.HasRequiredAccess == \"True\"\n| summarize arg_max(timestamp, *) by tostring(customDimensions.SubscriptionId), tostring(customDimensions.SubscriptionName), tostring(customDimensions.ControlId)\n| project tostring(customDimensions.SubscriptionId), tostring(customDimensions.SubscriptionName),tostring(customDimensions.ResourceId), tostring(customDimensions.ControlId), Oldresult =tostring(customDimensions.VerificationResult)\n| join\n(\n customEvents\n | where timestamp >= ago(2d)\n | where name == \"Control Scanned\" and customDimensions.HasAttestationReadPermissions == \"True\" and customDimensions.HasRequiredAccess == \"True\"\n | summarize arg_max(timestamp, *) by tostring(customDimensions.SubscriptionId), tostring(customDimensions.SubscriptionName), tostring(customDimensions.ControlId)\n | project tostring(customDimensions.SubscriptionId), tostring(customDimensions.SubscriptionName),tostring(customDimensions.ResourceId), tostring(customDimensions.ControlId), Latestresult = tostring(customDimensions.VerificationResult)\n)\non customDimensions_SubscriptionId, customDimensions_SubscriptionName,customDimensions_ResourceId, customDimensions_ControlId\n| project tostring(customDimensions_SubscriptionId), tostring(customDimensions_SubscriptionName),tostring(customDimensions_ResourceId), tostring(customDimensions_ControlId),Oldresult,Latestresult;\nlet OldScan = ControlResults\n| where Oldresult == \"Passed\"\n| summarize OldScanCount = count() by tostring(customDimensions_ControlId);\nlet LatestScan = ControlResults\n| where Latestresult == \"Passed\"\n| summarize LatestScanCount = count() by tostring(customDimensions_ControlId);\nOldScan\n| join\n(\n LatestScan\n)\non customDimensions_ControlId\n| project ControlId=tostring(customDimensions_ControlId),OldStatusCount=OldScanCount,LatestStatusCount=LatestScanCount\n| where OldStatusCount != LatestStatusCount and LatestStatusCount < OldStatusCount\n| extend Change =OldStatusCount-LatestStatusCount\n| order by Change desc\n| project ControlId,OldStatusCount,LatestStatusCount,Change\n" }, { "name": "Version", "value": "1.0" }, { "name": "DashboardId", "value": "[resourceId(parameters('ResourceGroups'),'Microsoft.Portal/dashboards', parameters('DashboardName'))]" }, { "name": "PartId", "value": "038d1915-4387-402f-88e1-0b0f029afc36" }, { "name": "PartTitle", "value": "Analytics" }, { "name": "PartSubTitle", "value": "" }, { "name": "resourceTypeMode", "value": "components" } ], "type": "Extension/AppInsightsExtension/PartType/AnalyticsGridPart", "settings": { "content": { "dashboardPartTitle": "Negative Drift for Controls", "dashboardPartSubTitle": "Shows controls drifting from 'passed' to 'not passed' in the 2 Days" } }, "asset": { "idInputName": "ComponentId", "type": "ApplicationInsights" } } }, "3": { "position": { "x": 17, "y": 0, "colSpan": 6, "rowSpan": 4 }, "metadata": { "inputs": [ { "name": "ComponentId", "value": { "SubscriptionId": "[parameters('SubscriptionId')]", "ResourceGroup": "[parameters('ResourceGroups')]", "Name": "[parameters('AIName')]" } }, { "name": "Query", "value": "exceptions\n| where timestamp > ago(7d)\n| summarize Count=count() by tostring(outerMessage),Date=bin(timestamp,1d)\n" }, { "name": "Dimensions", "value": { "xAxis": { "name": "Date", "type": "DateTime" }, "yAxis": [ { "name": "Count", "type": "Int64" } ], "splitBy": [ { "name": "outerMessage", "type": "String" } ], "aggregation": "Sum" } }, { "name": "Version", "value": "1.0" }, { "name": "DashboardId", "value": "[resourceId(parameters('ResourceGroups'),'Microsoft.Portal/dashboards', parameters('DashboardName'))]" }, { "name": "resourceTypeMode", "value": "components" } ], "type": "Extension/AppInsightsExtension/PartType/AnalyticsBarChartPart", "settings": { "content": { "dashboardPartTitle": "Exceptions Summary", "dashboardPartSubTitle": "Errors during DevOps Kit cmdlet execution" } }, "asset": { "idInputName": "ComponentId", "type": "ApplicationInsights" } } }, "4": { "position": { "x": 23, "y": 0, "colSpan": 6, "rowSpan": 4 }, "metadata": { "inputs": [ { "name": "ComponentId", "value": { "SubscriptionId": "[parameters('SubscriptionId')]", "ResourceGroup": "[parameters('ResourceGroups')]", "Name": "[parameters('AIName')]" } }, { "name": "Query", "value": "customEvents\r\n| where timestamp > ago(2d) and name == \"Control Scanned\" \r\n| summarize arg_max(timestamp, *) \r\n| project OrgAzSKVersion=tostring(customDimensions.OrgVersion),LatestAzSKVersion=tostring(tostring(customDimensions.LatestVersion))\r\n" }, { "name": "Version", "value": "1.0" }, { "name": "DashboardId", "value": "[resourceId(parameters('ResourceGroups'),'Microsoft.Portal/dashboards', parameters('DashboardName'))]" }, { "name": "resourceTypeMode", "value": "components" } ], "type": "Extension/AppInsightsExtension/PartType/AnalyticsGridPart", "settings": { "content": { "PartTitle": "Current Org AzSK Version Vs Latest AzSK Version", "PartSubTitle": "To update org version refer: http://aka.ms/deveopskit/updateOrgAzSKVersion" } }, "asset": { "idInputName": "ComponentId", "type": "ApplicationInsights" } } }, "5": { "position": { "x": 0, "y": 4, "colSpan": 5, "rowSpan": 4 }, "metadata": { "inputs": [ { "name": "resourceGroup", "isOptional": true }, { "name": "id", "value": "[concat(subscription().id,'/resourceGroups/',parameters('ResourceGroups'))]", "isOptional": true } ], "type": "Extension/HubsExtension/PartType/ResourceGroupMapPinnedPart" } }, "6": { "position": { "x": 5, "y": 4, "colSpan": 6, "rowSpan": 4 }, "metadata": { "inputs": [ { "name": "ComponentId", "value": { "SubscriptionId": "[parameters('SubscriptionId')]", "ResourceGroup": "[parameters('ResourceGroups')]", "Name": "[parameters('AIName')]" } }, { "name": "Query", "value": "customEvents\r\n| where timestamp > ago(90d) \r\n| where customDimensions.ScanSource ==\"Runbook\" and name == \"Control Scanned\"\r\n| summarize LastScanDate = max(timestamp) by tostring(customDimensions.SubscriptionId),tostring(customDimensions.SubscriptionName)\r\n| where LastScanDate <= ago(2d)\r\n| order by LastScanDate desc \r\n| project SubId = customDimensions_SubscriptionId,SubName= customDimensions_SubscriptionName,LastScanDate\n" }, { "name": "Version", "value": "1.0" }, { "name": "DashboardId", "value": "[resourceId(parameters('ResourceGroups'),'Microsoft.Portal/dashboards', parameters('DashboardName'))]" }, { "name": "resourceTypeMode", "value": "components" } ], "type": "Extension/AppInsightsExtension/PartType/AnalyticsGridPart", "settings": { "content": { "dashboardPartTitle": "CA - No Recent Scans", "dashboardPartSubTitle": "Subscriptions that have not reported scan events in last the 2 days" } }, "asset": { "idInputName": "ComponentId", "type": "ApplicationInsights" } } }, "7": { "position": { "x": 11, "y": 4, "colSpan": 6, "rowSpan": 4 }, "metadata": { "inputs": [ { "name": "ComponentId", "value": { "SubscriptionId": "[parameters('SubscriptionId')]", "ResourceGroup": "[parameters('ResourceGroups')]", "Name": "[parameters('AIName')]" } }, { "name": "Query", "value": "//Positive Drift\nlet ControlResults = customEvents\n| where timestamp < ago(2d) and timestamp >= ago(4d)\n| where name == \"Control Scanned\" and customDimensions.HasAttestationReadPermissions == \"True\" and customDimensions.HasRequiredAccess == \"True\"\n| summarize arg_max(timestamp, *) by tostring(customDimensions.SubscriptionId), tostring(customDimensions.SubscriptionName), tostring(customDimensions.ControlId)\n| project tostring(customDimensions.SubscriptionId), tostring(customDimensions.SubscriptionName),tostring(customDimensions.ResourceId), tostring(customDimensions.ControlId), oldresult =tostring(customDimensions.VerificationResult)\n| join\n(\n customEvents\n | where timestamp >= ago(2d)\n | where name == \"Control Scanned\" and customDimensions.HasAttestationReadPermissions == \"True\" and customDimensions.HasRequiredAccess == \"True\"\n | summarize arg_max(timestamp, *) by tostring(customDimensions.SubscriptionId), tostring(customDimensions.SubscriptionName), tostring(customDimensions.ControlId)\n | project tostring(customDimensions.SubscriptionId), tostring(customDimensions.SubscriptionName),tostring(customDimensions.ResourceId), tostring(customDimensions.ControlId), Latestresult = tostring(customDimensions.VerificationResult)\n)\non customDimensions_SubscriptionId, customDimensions_SubscriptionName,customDimensions_ResourceId, customDimensions_ControlId\n| project tostring(customDimensions_SubscriptionId), tostring(customDimensions_SubscriptionName),tostring(customDimensions_ResourceId), tostring(customDimensions_ControlId),oldresult,Latestresult;\nlet oldScan = ControlResults\n| where oldresult == \"Passed\"\n| summarize oldScanCount = count() by tostring(customDimensions_ControlId);\nlet LatestScan = ControlResults\n| where Latestresult == \"Passed\"\n| summarize LatestScanCount = count() by tostring(customDimensions_ControlId);\noldScan\n| join\n(\n LatestScan\n)\non customDimensions_ControlId\n| project ControlId=tostring(customDimensions_ControlId),OldStatusCount=oldScanCount,LatestStatusCount=LatestScanCount\n| where OldStatusCount != LatestStatusCount and LatestStatusCount > OldStatusCount\n| extend Change =LatestStatusCount-OldStatusCount\n| order by Change desc\n| project ControlId,OldStatusCount,LatestStatusCount,Change\n" }, { "name": "Version", "value": "1.0" }, { "name": "DashboardId", "value": "[resourceId(parameters('ResourceGroups'),'Microsoft.Portal/dashboards', parameters('DashboardName'))]" }, { "name": "resourceTypeMode", "value": "components" } ], "type": "Extension/AppInsightsExtension/PartType/AnalyticsGridPart", "settings": { "content": { "dashboardPartTitle": "Positive Drift for Controls", "dashboardPartSubTitle": "Shows controls drifting from 'not passed' to 'passed' in the 2 days" } }, "asset": { "idInputName": "ComponentId", "type": "ApplicationInsights" } } }, "8": { "position": { "x": 17, "y": 4, "colSpan": 6, "rowSpan": 4 }, "metadata": { "inputs": [ { "name": "ComponentId", "value": { "SubscriptionId": "[parameters('SubscriptionId')]", "ResourceGroup": "[parameters('ResourceGroups')]", "Name": "[parameters('AIName')]" } }, { "name": "Query", "value": "customEvents\r\n| where name == \"CA Job Error\"\r\n| where timestamp > ago(7d)\r\n| extend SubId=tostring(customDimensions.SubscriptionId)\r\n| summarize Count=count() by tostring(customDimensions.ErrorRecord),Date=bin(timestamp,1d)\r\n| order by Date,Count" }, { "name": "Dimensions", "value": { "xAxis": { "name": "Date", "type": "DateTime" }, "yAxis": [ { "name": "Count", "type": "Int64" } ], "splitBy": [ { "name": "customDimensions_ErrorRecord", "type": "String" } ], "aggregation": "Sum" } }, { "name": "Version", "value": "1.0" }, { "name": "DashboardId", "value": "[resourceId(parameters('ResourceGroups'),'Microsoft.Portal/dashboards', parameters('DashboardName'))]" }, { "name": "resourceTypeMode", "value": "components" } ], "type": "Extension/AppInsightsExtension/PartType/AnalyticsBarChartPart", "settings": { "content": { "dashboardPartTitle": "CA Exceptions", "dashboardPartSubTitle": "Errors during CA runbook execution" } }, "asset": { "idInputName": "ComponentId", "type": "ApplicationInsights" } } } } } } }, "name": "[parameters('DashboardName')]", "type": "Microsoft.Portal/dashboards", "location": "[parameters('Location')]", "tags": { "hidden-title": "[parameters('DashboardTitle')]" }, "apiVersion": "2015-08-01-preview" } ] }
{ "pile_set_name": "Github" }
{ "nome": "San Valentino Torio", "codice": "065132", "zona": { "codice": "4", "nome": "Sud" }, "regione": { "codice": "15", "nome": "Campania" }, "provincia": { "codice": "065", "nome": "Salerno" }, "sigla": "SA", "codiceCatastale": "I377", "cap": [ "84010" ], "popolazione": 10439 }
{ "pile_set_name": "Github" }
infodir=usr/share/info filelist="libgomp.info libquadmath.info" post_upgrade() { [ -x usr/bin/install-info ] || return 0 for file in ${filelist}; do install-info $infodir/$file.gz $infodir/dir 2> /dev/null done } pre_remove() { [ -x usr/bin/install-info ] || return 0 for file in ${filelist}; do install-info --delete $infodir/$file.gz $infodir/dir 2> /dev/null done }
{ "pile_set_name": "Github" }
import React from 'react'; import Structure from './Structure'; export default function NotFoundPage() { return ( <Structure title="¯\_(ツ)_/¯"> <p> Nothing to see here. 🚶🏾‍♀️ </p> </Structure> ) }
{ "pile_set_name": "Github" }
import flask app = flask.Flask(__name__)
{ "pile_set_name": "Github" }
syntax = "proto3"; package touches; message Vector { double x = 1; double y = 2; } message Sample { double time = 1; Vector position = 2; double major_radius = 3; } message Stroke { repeated Sample samples = 1; } message Drawing { repeated Stroke strokes = 1; } message DrawingList { repeated Drawing drawings = 1; } message RawDataSet { DrawingList drawingList = 1; repeated Label labels = 2; } message Image { int32 height = 1; int32 width = 2; bytes values = 15; } message LabelledImage { Image image = 1; Label label = 2; } message TrainingSet { repeated LabelledImage labelledImages = 1; } message ImageList { repeated Image images = 1; } enum Label { OTHER = 0; // Common basic symbols CHECKMARK = 1; XMARK = 2; // Lines // LINE_VERTICAL = 16; LINE_ASCENDING = 18; SCRIBBLE = 23; // Shapes CIRCLE = 24; // TRIANGLE = 25; // SQUARE = 27; SEMICIRCLE_OPEN_UP = 30; // SEMICIRCLE_OPEN_DOWN = 31; // V_OPEN_UP = 34; // V_OPEN_DOWN = 35; HEART = 39; // Math PLUS_SIGN = 40; // MINUS_SIGN = 41; // Punctuation QUESTION_MARK = 50; // TILDE = 54; // Letters and numbers LETTER_A_CAPITAL = 60; LETTER_B_CAPITAL = 61; // LETTER_C_CAPITAL = 62; // Faces FACE_HAPPY = 130; FACE_SAD = 131; }
{ "pile_set_name": "Github" }