text
stringlengths 2
100k
| meta
dict |
---|---|
//
// Thumbnails
// --------------------------------------------------
// Mixin and adjust the regular image class
.thumbnail {
display: block;
padding: @thumbnail-padding;
margin-bottom: @line-height-computed;
line-height: @line-height-base;
background-color: @thumbnail-bg;
border: 1px solid @thumbnail-border;
border-radius: @thumbnail-border-radius;
.transition(all .2s ease-in-out);
> img,
a > img {
&:extend(.img-responsive);
margin-left: auto;
margin-right: auto;
}
// Add a hover state for linked versions only
a&:hover,
a&:focus,
a&.active {
border-color: @link-color;
}
// Image captions
.caption {
padding: @thumbnail-caption-padding;
color: @thumbnail-caption-color;
}
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package org.webrtc.audio;
import android.media.audiofx.AcousticEchoCanceler;
import android.media.audiofx.AudioEffect;
import android.media.audiofx.AudioEffect.Descriptor;
import android.media.audiofx.NoiseSuppressor;
import android.os.Build;
import android.support.annotation.Nullable;
import java.util.UUID;
import org.webrtc.Logging;
// This class wraps control of three different platform effects. Supported
// effects are: AcousticEchoCanceler (AEC) and NoiseSuppressor (NS).
// Calling enable() will active all effects that are
// supported by the device if the corresponding |shouldEnableXXX| member is set.
class WebRtcAudioEffects {
private static final boolean DEBUG = false;
private static final String TAG = "WebRtcAudioEffectsExternal";
// UUIDs for Software Audio Effects that we want to avoid using.
// The implementor field will be set to "The Android Open Source Project".
private static final UUID AOSP_ACOUSTIC_ECHO_CANCELER =
UUID.fromString("bb392ec0-8d4d-11e0-a896-0002a5d5c51b");
private static final UUID AOSP_NOISE_SUPPRESSOR =
UUID.fromString("c06c8400-8e06-11e0-9cb6-0002a5d5c51b");
// Contains the available effect descriptors returned from the
// AudioEffect.getEffects() call. This result is cached to avoid doing the
// slow OS call multiple times.
private static @Nullable Descriptor[] cachedEffects;
// Contains the audio effect objects. Created in enable() and destroyed
// in release().
private @Nullable AcousticEchoCanceler aec;
private @Nullable NoiseSuppressor ns;
// Affects the final state given to the setEnabled() method on each effect.
// The default state is set to "disabled" but each effect can also be enabled
// by calling setAEC() and setNS().
private boolean shouldEnableAec;
private boolean shouldEnableNs;
// Returns true if all conditions for supporting HW Acoustic Echo Cancellation (AEC) are
// fulfilled.
public static boolean isAcousticEchoCancelerSupported() {
if (Build.VERSION.SDK_INT < 18)
return false;
return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_AEC, AOSP_ACOUSTIC_ECHO_CANCELER);
}
// Returns true if all conditions for supporting HW Noise Suppression (NS) are fulfilled.
public static boolean isNoiseSuppressorSupported() {
if (Build.VERSION.SDK_INT < 18)
return false;
return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_NS, AOSP_NOISE_SUPPRESSOR);
}
public WebRtcAudioEffects() {
Logging.d(TAG, "ctor" + WebRtcAudioUtils.getThreadInfo());
}
// Call this method to enable or disable the platform AEC. It modifies
// |shouldEnableAec| which is used in enable() where the actual state
// of the AEC effect is modified. Returns true if HW AEC is supported and
// false otherwise.
public boolean setAEC(boolean enable) {
Logging.d(TAG, "setAEC(" + enable + ")");
if (!isAcousticEchoCancelerSupported()) {
Logging.w(TAG, "Platform AEC is not supported");
shouldEnableAec = false;
return false;
}
if (aec != null && (enable != shouldEnableAec)) {
Logging.e(TAG, "Platform AEC state can't be modified while recording");
return false;
}
shouldEnableAec = enable;
return true;
}
// Call this method to enable or disable the platform NS. It modifies
// |shouldEnableNs| which is used in enable() where the actual state
// of the NS effect is modified. Returns true if HW NS is supported and
// false otherwise.
public boolean setNS(boolean enable) {
Logging.d(TAG, "setNS(" + enable + ")");
if (!isNoiseSuppressorSupported()) {
Logging.w(TAG, "Platform NS is not supported");
shouldEnableNs = false;
return false;
}
if (ns != null && (enable != shouldEnableNs)) {
Logging.e(TAG, "Platform NS state can't be modified while recording");
return false;
}
shouldEnableNs = enable;
return true;
}
public void enable(int audioSession) {
Logging.d(TAG, "enable(audioSession=" + audioSession + ")");
assertTrue(aec == null);
assertTrue(ns == null);
if (DEBUG) {
// Add logging of supported effects but filter out "VoIP effects", i.e.,
// AEC, AEC and NS. Avoid calling AudioEffect.queryEffects() unless the
// DEBUG flag is set since we have seen crashes in this API.
for (Descriptor d : AudioEffect.queryEffects()) {
if (effectTypeIsVoIP(d.type)) {
Logging.d(TAG,
"name: " + d.name + ", "
+ "mode: " + d.connectMode + ", "
+ "implementor: " + d.implementor + ", "
+ "UUID: " + d.uuid);
}
}
}
if (isAcousticEchoCancelerSupported()) {
// Create an AcousticEchoCanceler and attach it to the AudioRecord on
// the specified audio session.
aec = AcousticEchoCanceler.create(audioSession);
if (aec != null) {
boolean enabled = aec.getEnabled();
boolean enable = shouldEnableAec && isAcousticEchoCancelerSupported();
if (aec.setEnabled(enable) != AudioEffect.SUCCESS) {
Logging.e(TAG, "Failed to set the AcousticEchoCanceler state");
}
Logging.d(TAG,
"AcousticEchoCanceler: was " + (enabled ? "enabled" : "disabled") + ", enable: "
+ enable + ", is now: " + (aec.getEnabled() ? "enabled" : "disabled"));
} else {
Logging.e(TAG, "Failed to create the AcousticEchoCanceler instance");
}
}
if (isNoiseSuppressorSupported()) {
// Create an NoiseSuppressor and attach it to the AudioRecord on the
// specified audio session.
ns = NoiseSuppressor.create(audioSession);
if (ns != null) {
boolean enabled = ns.getEnabled();
boolean enable = shouldEnableNs && isNoiseSuppressorSupported();
if (ns.setEnabled(enable) != AudioEffect.SUCCESS) {
Logging.e(TAG, "Failed to set the NoiseSuppressor state");
}
Logging.d(TAG,
"NoiseSuppressor: was " + (enabled ? "enabled" : "disabled") + ", enable: " + enable
+ ", is now: " + (ns.getEnabled() ? "enabled" : "disabled"));
} else {
Logging.e(TAG, "Failed to create the NoiseSuppressor instance");
}
}
}
// Releases all native audio effect resources. It is a good practice to
// release the effect engine when not in use as control can be returned
// to other applications or the native resources released.
public void release() {
Logging.d(TAG, "release");
if (aec != null) {
aec.release();
aec = null;
}
if (ns != null) {
ns.release();
ns = null;
}
}
// Returns true for effect types in |type| that are of "VoIP" types:
// Acoustic Echo Canceler (AEC) or Automatic Gain Control (AGC) or
// Noise Suppressor (NS). Note that, an extra check for support is needed
// in each comparison since some devices includes effects in the
// AudioEffect.Descriptor array that are actually not available on the device.
// As an example: Samsung Galaxy S6 includes an AGC in the descriptor but
// AutomaticGainControl.isAvailable() returns false.
private boolean effectTypeIsVoIP(UUID type) {
if (Build.VERSION.SDK_INT < 18)
return false;
return (AudioEffect.EFFECT_TYPE_AEC.equals(type) && isAcousticEchoCancelerSupported())
|| (AudioEffect.EFFECT_TYPE_NS.equals(type) && isNoiseSuppressorSupported());
}
// Helper method which throws an exception when an assertion has failed.
private static void assertTrue(boolean condition) {
if (!condition) {
throw new AssertionError("Expected condition to be true");
}
}
// Returns the cached copy of the audio effects array, if available, or
// queries the operating system for the list of effects.
private static @Nullable Descriptor[] getAvailableEffects() {
if (cachedEffects != null) {
return cachedEffects;
}
// The caching is best effort only - if this method is called from several
// threads in parallel, they may end up doing the underlying OS call
// multiple times. It's normally only called on one thread so there's no
// real need to optimize for the multiple threads case.
cachedEffects = AudioEffect.queryEffects();
return cachedEffects;
}
// Returns true if an effect of the specified type is available. Functionally
// equivalent to (NoiseSuppressor|AutomaticGainControl|...).isAvailable(), but
// faster as it avoids the expensive OS call to enumerate effects.
private static boolean isEffectTypeAvailable(UUID effectType, UUID blackListedUuid) {
Descriptor[] effects = getAvailableEffects();
if (effects == null) {
return false;
}
for (Descriptor d : effects) {
if (d.type.equals(effectType)) {
return !d.uuid.equals(blackListedUuid);
}
}
return false;
}
}
| {
"pile_set_name": "Github"
} |
---
title: Concentric Layout
order: 6
---
Concentric Layout places the nodes on concentric circles.
## Usage
As the demo below, you can deploy it in `layout` while instantiating Graph. it can also be used for [Subgraph Layout](/en/docs/manual/middle/layout/sub-layout). This algorithm will order the nodes according to the parameters first, then the node in the front of the order will be placed on the center of the concentric circles.
| {
"pile_set_name": "Github"
} |
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1
import (
internalinterfaces "k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// TestTypes returns a TestTypeInformer.
TestTypes() TestTypeInformer
}
type version struct {
factory internalinterfaces.SharedInformerFactory
namespace string
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// TestTypes returns a TestTypeInformer.
func (v *version) TestTypes() TestTypeInformer {
return &testTypeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
| {
"pile_set_name": "Github"
} |
///
/// \file integrated_snarl_finder.cpp
///
///
#include "integrated_snarl_finder.hpp"
#include "algorithms/three_edge_connected_components.hpp"
#include "algorithms/weakly_connected_components.hpp"
#include "subgraph_overlay.hpp"
#include <bdsg/overlays/overlay_helper.hpp>
#include <structures/union_find.hpp>
#include <array>
#include <iostream>
namespace vg {
//#define debug
using namespace std;
class IntegratedSnarlFinder::MergedAdjacencyGraph {
protected:
/// Hold onto the backing RankedHandleGraph.
/// Union find index is handle rank - 1 (to make it 0-based).
const RankedHandleGraph* graph;
/// Keep a union-find over the ranks of the merged oriented handles that
/// make up each component. Runs with include_children=true so we can find
/// all the members of each group.
///
/// Needs to be mutable because union-find find operations do internal tree
/// massaging and aren't const.
/// TODO: this makes read operations not thread safe!
mutable structures::UnionFind union_find;
/// Get the rank corresponding to the given handle, in the union-find.
/// Our ranks are 0-based.
size_t uf_rank(handle_t into) const;
/// Get the handle with the given rank in union-find space.
/// Our ranks are 0-based.
handle_t uf_handle(size_t rank) const;
public:
/// Make a MergedAdjacencyGraph representing the graph of adjacency components of the given RankedHandleGraph.
MergedAdjacencyGraph(const RankedHandleGraph* graph);
/// Copy a MergedAdjacencyGraph by re-doing all the merges. Uses its own internal vectorization.
MergedAdjacencyGraph(const MergedAdjacencyGraph& other);
/// Given handles reading into two components, a and b, merge them into a single component.
void merge(handle_t into_a, handle_t into_b);
/// Find the handle heading the component that the given handle is in.
handle_t find(handle_t into) const;
/// For each head, call the iteratee.
void for_each_head(const function<void(handle_t)>& iteratee) const;
/// For each item other than the head in the component headed by the given
/// handle, calls the iteratee with the that other item. Does not call the
/// iteratee for single-item components.
void for_each_other_member(handle_t head, const function<void(handle_t)>& iteratee) const;
/// For each item, including the head, in the component headed by the given
/// handle, calls the iteratee with the that other item. Does not call the
/// iteratee for single-item components.
void for_each_member(handle_t head, const function<void(handle_t)>& iteratee) const;
/// For each item other than the head in each component, calls the iteratee
/// with the head and the other item. Does not call the iteratee for
/// single-item components.
void for_each_membership(const function<void(handle_t, handle_t)>& iteratee) const;
/// In a graph where all 3-edge-connected components have had their nodes
/// merged, find all the cycles. Cycles are guaranteed to overlap at at
/// most one node, so no special handling of overlapping regions is done.
///
/// Returns a list of cycle edge length (in bp) and an edge on each cycle
/// (for the longest cycle in each connected component), and a map from
/// each edge on the cycle to the next edge, going around each cycle in one
/// direction (for all cycles).
///
/// Ignores self loops.
pair<vector<pair<size_t, handle_t>>, unordered_map<handle_t, handle_t>> cycles_in_cactus() const;
/// Find a path of cycles connecting two components in a Cactus graph.
/// Cycles are represented by the handle that brings that cyle into the component where it intersects the previous cycle.
/// Because the graph is a Cactus graph, cycles are a tree and intersect at at most one node.
/// Uses the given map of cycles, stored in one orientation only, to traverse cycles.
vector<handle_t> find_cycle_path_in_cactus(const unordered_map<handle_t, handle_t>& next_along_cycle, handle_t start_cactus_head, handle_t end_cactus_head) const;
/// Return the path length (total edge length in bp) and edges for the
/// longest path in each tree in a forest. Ignores self loops on tree nodes.
///
/// Also return the map from the head of each component to the edge into
/// the child that is first along the longest path to a leaf. For
/// components not themselves on the longest leaf-leaf path in their tree,
/// these will always be dangling off/rooted by the longest leaf-leaf path
/// or longest simple cycle merged away, whichever is longer.
///
/// Needs access to the longest simple cycles that were merged out, if any.
/// If a path in the forest doesn't match or beat the length of the cycle
/// that lives in its tree, it is omitted.
pair<vector<pair<size_t, vector<handle_t>>>, unordered_map<handle_t, handle_t>> longest_paths_in_forest(const vector<pair<size_t, handle_t>>& longest_simple_cycles) const;
/// Describe the graph in dot format to the given stream;
void to_dot(ostream& out) const;
};
void IntegratedSnarlFinder::MergedAdjacencyGraph::to_dot(ostream& out) const {
out << "digraph G {" << endl;
for_each_head([&](handle_t head) {
// Have a node for every head
out << "\tn" << graph->get_id(head) << (graph->get_is_reverse(head) ? "r" : "f") << "[shape=\"point\"];" << endl;
for_each_member(head, [&](handle_t edge) {
// For everything reading into here
if (graph->get_is_reverse(edge)) {
// If it is coming here backward (we are its start)
handle_t flipped_head = find(graph->flip(edge));
// Only draw edges in one direction. Label them with their nodes.
out << "\tn" << graph->get_id(head) << (graph->get_is_reverse(head) ? "r" : "f")
<< " -> n" << graph->get_id(flipped_head) << (graph->get_is_reverse(flipped_head) ? "r" : "f")
<< " [label=" << graph->get_id(edge) << "];" << endl;
}
});
});
out << "}" << endl;
}
size_t IntegratedSnarlFinder::MergedAdjacencyGraph::uf_rank(handle_t into) const {
// We need to 0-base the backing rank
return graph->handle_to_rank(into) - 1;
}
handle_t IntegratedSnarlFinder::MergedAdjacencyGraph::uf_handle(size_t rank) const {
// We need to 1-base the rank and then get the handle.
return graph->rank_to_handle(rank + 1);
}
IntegratedSnarlFinder::MergedAdjacencyGraph::MergedAdjacencyGraph(const RankedHandleGraph* graph) : graph(graph),
union_find(graph->get_node_count() * 2, true) {
// TODO: we want the adjacency components that are just single edges
// between two handles (i.e. trivial snarls) to be implicit, so we don't
// have to do O(n) work for so much of the graph. But to do that we need a
// union-find that lets us declare it over a potentially large space
// without filling it all in.
// So we do this the easy way and compute all the merges for all adjacency
// components, including tiny/numerous ones, right now.
// If we ever change this, we should also make MergedAdjacencyGraph
// stackable, to save a copy when we want to do further merges but keep the
// old state.
graph->for_each_edge([&](const handlegraph::edge_t& e) {
// Get the inward-facing version of the second handle
auto into_b = graph->flip(e.second);
// Merge to create initial adjacency components
merge(e.first, into_b);
});
}
IntegratedSnarlFinder::MergedAdjacencyGraph::MergedAdjacencyGraph(const MergedAdjacencyGraph& other) : MergedAdjacencyGraph(other.graph) {
other.for_each_membership([&](handle_t head, handle_t member) {
// For anything in a component, other than its head, do the merge with the head.
merge(head, member);
});
}
void IntegratedSnarlFinder::MergedAdjacencyGraph::merge(handle_t into_a, handle_t into_b) {
// Get ranks and merge
union_find.union_groups(uf_rank(into_a), uf_rank(into_b));
}
handle_t IntegratedSnarlFinder::MergedAdjacencyGraph::find(handle_t into) const {
// Get rank, find head, and get handle
return uf_handle(union_find.find_group(uf_rank(into)));
}
void IntegratedSnarlFinder::MergedAdjacencyGraph::for_each_head(const function<void(handle_t)>& iteratee) const {
// TODO: is this better or worse than getting the vector of vectors of the whole union-find?
// TODO: make iterating groups an actual capability that the union-find has, in O(groups).
// This lets us do it in O(total items).
// We track if we have seen a head yet. If we haven't, we emit it and mark it seen.
vector<bool> seen_heads(union_find.size(), false);
for (size_t i = 0; i < union_find.size(); i++) {
// For each item in the union-find
if (!seen_heads[i]) {
// If we haven't emitted it, find the head of its group
size_t head = union_find.find_group(i);
if (!seen_heads[head]) {
// If we haven't emitted that head either, say we have
seen_heads[head] = true;
// And emit its corresponding inward-facing handle
iteratee(uf_handle(head));
}
}
}
}
void IntegratedSnarlFinder::MergedAdjacencyGraph::for_each_other_member(handle_t head, const function<void(handle_t)>& iteratee) const {
size_t head_rank = uf_rank(head);
// Find the group the head is in
vector<size_t> group = union_find.group(head_rank);
for (auto& member_rank : group) {
// And go through all the members
if (member_rank != head_rank) {
// We filter out the given head.
// This function will happen to work for non-head inputs, leaving out that input, but we don't guarantee it!
iteratee(uf_handle(member_rank));
}
}
}
void IntegratedSnarlFinder::MergedAdjacencyGraph::for_each_member(handle_t head, const function<void(handle_t)>& iteratee) const {
size_t head_rank = uf_rank(head);
// Find the group the head is in
vector<size_t> group = union_find.group(head_rank);
for (auto& member_rank : group) {
// And go through all the members, including the head.
// This function will happen to work for non-head inputs, leaving out that input, but we don't guarantee it!
iteratee(uf_handle(member_rank));
}
}
void IntegratedSnarlFinder::MergedAdjacencyGraph::for_each_membership(const function<void(handle_t, handle_t)>& iteratee) const {
// We do this weird iteration because it's vaguely efficient in the union-find we use.
vector<vector<size_t>> uf_components = union_find.all_groups();
for (auto& component : uf_components) {
// For each component
for (size_t i = 1; i < component.size(); i++) {
// For everything other than the head, announce with the head.
iteratee(uf_handle(component[0]), uf_handle(component[i]));
}
}
}
pair<vector<pair<size_t, handle_t>>, unordered_map<handle_t, handle_t>> IntegratedSnarlFinder::MergedAdjacencyGraph::cycles_in_cactus() const {
// Do a DFS over all connected components of the graph
// We will fill this in
pair<vector<pair<size_t, handle_t>>, unordered_map<handle_t, handle_t>> to_return;
auto& longest_cycles = to_return.first;
auto& next_edge = to_return.second;
// When we see a back edge that isn't a self loop, we jump up the stack and
// walk down it, writing the cycle relationships. We know the cycles can't
// overlap (due to merged 3 edge connected components) so we also know we
// won't ever re-walk the same part of the stack, so this is efficient.
// To let us actually find the cycle paths when we see back edges, we need
// to remember stack frame index as our visit marker. No record = not
// visited, record = visited.
//
// If you see something visited already, it must still be on the stack.
// Otherwise it would have already visited you when it was on the stack.
//
// This is on heads, representing nodes.
unordered_map<handle_t, size_t> visited_frame;
// We need a stack.
// Stack is actually in terms of inward edges followed.
struct DFSFrame {
handle_t here;
vector<handle_t> todo;
};
vector<DFSFrame> stack;
for_each_head([&](handle_t component_root) {
// For every node in the graph
if (!visited_frame.count(component_root)) {
#ifdef debug
cerr << "Root simple cycle search at " << graph->get_id(component_root) << (graph->get_is_reverse(component_root) ? "-" : "+") << endl;
#endif
// If it hasn't been searched yet, start a search of its connected component.
stack.emplace_back();
stack.back().here = component_root;
// We'll put the longest cycle start edge result here, or get rid of it if we find no cycle.
longest_cycles.emplace_back();
auto& longest_cycle = longest_cycles.back();
while (!stack.empty()) {
// Until the DFS is done
auto& frame = stack.back();
// Find the node that following this edge got us to.
auto frame_head = find(frame.here);
#ifdef debug
cerr << "At stack frame " << stack.size() - 1 << " for edge " << graph->get_id(frame.here) << (graph->get_is_reverse(frame.here) ? "-" : "+")
<< " on component " << graph->get_id(frame_head) << (graph->get_is_reverse(frame_head) ? "-" : "+") << endl;
#endif
auto frame_it = visited_frame.find(frame_head);
if (frame_it == visited_frame.end()) {
// First visit to here.
#ifdef debug
cerr << "\tFirst visit" << endl;
#endif
// Mark visited at this stack level
frame_it = visited_frame.emplace_hint(frame_it, frame_head, stack.size() - 1);
// Queue up edges
for_each_member(frame_head, [&](handle_t member) {
if (member != frame.here || stack.size() == 1) {
// If it's not just turning around and looking up
// the edge we took to get here, or if we're the
// top stack frame and we didn't come from anywhere
// anyway
// Follow edge by flipping. But queue up the edge
// followed instead of the node reached (head), so we
// can emit the cycle later in terms of edges.
frame.todo.push_back(graph->flip(member));
#ifdef debug
cerr << "\t\tNeed to follow " << graph->get_id(frame.todo.back()) << (graph->get_is_reverse(frame.todo.back()) ? "-" : "+") << endl;
#endif
}
});
}
if (!frame.todo.empty()) {
// Now do an edge
handle_t edge_into = frame.todo.back();
handle_t connected_head = find(edge_into);
frame.todo.pop_back();
#ifdef debug
cerr << "\tFollow " << graph->get_id(edge_into) << (graph->get_is_reverse(edge_into) ? "-" : "+")
<< " to component " << graph->get_id(connected_head) << (graph->get_is_reverse(connected_head) ? "-" : "+") << endl;
#endif
auto connected_it = visited_frame.find(connected_head);
if (connected_it == visited_frame.end()) {
#ifdef debug
cerr << "\t\tNot yet visited. Recurse!" << endl;
#endif
// Forward edge. Recurse.
// TODO: this immediately does a lookup in the hash table again.
stack.emplace_back();
stack.back().here = edge_into;
} else {
// Back edge
if (frame_it->second > connected_it->second) {
// We have an edge to something that was visited above
// our stack level. It can't be a self loop, and it
// must close a unique cycle.
#ifdef debug
cerr << "\tBack edge up stack to frame " << connected_it->second << endl;
#endif
#ifdef debug
cerr << "\t\tFound cycle:" << endl;
#endif
// Walk and measure the cycle. But don't count the
// frame we arrived at because its incoming edge
// isn't actually on the cycle.
size_t cycle_length_bp = graph->get_length(edge_into);
handle_t prev_edge = edge_into;
for (size_t i = connected_it->second + 1; i < stack.size(); i++) {
// For each edge along the cycle...
#ifdef debug
cerr << "\t\t\t" << graph->get_id(stack[i].here) << (graph->get_is_reverse(stack[i].here) ? "-" : "+") << endl;
#endif
// Measure it
cycle_length_bp += graph->get_length(stack[i].here);
// Record the cycle membership
next_edge[prev_edge] = stack[i].here;
// Advance
prev_edge = stack[i].here;
}
// Close the cycle
next_edge[prev_edge] = edge_into;
#ifdef debug
cerr << "\t\t\t" << graph->get_id(edge_into) << (graph->get_is_reverse(edge_into) ? "-" : "+") << endl;
#endif
#ifdef debug
cerr << "\t\tCycle length: " << cycle_length_bp << " bp" << endl;
#endif
if (cycle_length_bp > longest_cycle.first) {
// New longest cycle (or maybe only longest cycle).
#ifdef debug
cerr << "\t\t\tNew longest cycle!" << endl;
#endif
// TODO: Assumes no cycles are 0-length
longest_cycle.first = cycle_length_bp;
longest_cycle.second = edge_into;
}
}
}
} else {
// Now we're done with this stack frame.
// Clean up
stack.pop_back();
}
}
if (longest_cycle.first == 0) {
// No (non-empty) nontrivial cycle found in this connected component.
// Remove its spot.
longest_cycles.pop_back();
}
}
});
#ifdef debug
cerr << "Cycle links:" << endl;
for (auto& kv : next_edge) {
cerr << "\t" << graph->get_id(kv.first) << (graph->get_is_reverse(kv.first) ? "-" : "+")
<< " -> " << graph->get_id(kv.second) << (graph->get_is_reverse(kv.second) ? "-" : "+") << endl;
}
#endif
return to_return;
}
vector<handle_t> IntegratedSnarlFinder::MergedAdjacencyGraph::find_cycle_path_in_cactus(const unordered_map<handle_t, handle_t>& next_along_cycle, handle_t start_head, handle_t end_head) const {
// We fill this in with a path of cycles.
// Each cycle is the edge on that cycle leading into the node that it shares with the previous cycle.
vector<handle_t> cycle_path;
// We just DFS through the cycle tree until we find one that touches the
// other node. We represent each cycle by an edge on it into the node where
// it overlaps the parent cycle, and store the current cycle and the other
// cycles to do that share nodes.
vector<tuple<handle_t, vector<handle_t>, bool>> cycle_stack;
// We have a list of DFS roots we can stop early on.
vector<handle_t> roots;
for_each_member(start_head, [&](handle_t inbound) {
if (next_along_cycle.count(inbound)) {
// This edge is how a cycle comes into here. Consider this cycle.
roots.push_back(inbound);
}
});
for (auto& root : roots) {
// Root at each root
cycle_stack.emplace_back(root, vector<handle_t>(), false);
while (!cycle_stack.empty()) {
auto& cycle_frame = cycle_stack.back();
if (!get<2>(cycle_frame)) {
// First visit
get<2>(cycle_frame) = true;
// Need to fill in child cycles.
for (auto it = next_along_cycle.find(get<0>(cycle_frame)); it->second != get<0>(cycle_frame); it = next_along_cycle.find(it->second)) {
// For each other edge around the cycle (in it->second) other than the one we started at
handle_t node = find(it->second);
if (node == end_head) {
// This cycle intersects the destination. It is the last on the cycle path.
// Copy the path on the stack over.
// Note that the first think on the path is in the
// start's component, but the last thing on the path
// isn't in the end's component.
cycle_path.reserve(cycle_stack.size());
for (auto& f : cycle_stack) {
cycle_path.push_back(get<0>(f));
}
// Now the cycle path is done
return cycle_path;
}
for_each_member(node, [&](handle_t inbound) {
// For each edge in the component it enters
if (inbound != it->second && next_along_cycle.count(inbound)) {
// This edge is a cycle coming into a node our current cycle touches.
get<1>(cycle_frame).push_back(inbound);
}
});
}
}
if (!get<1>(cycle_frame).empty()) {
// Need to recurse on a connected cycle.
handle_t child = get<1>(cycle_frame).back();
get<1>(cycle_frame).pop_back();
cycle_stack.emplace_back(child, vector<handle_t>(), false);
} else {
// Need to clean up and return
cycle_stack.pop_back();
}
}
}
// If we get here, we never found a path.
// Complain! Something is wrong!
throw runtime_error("Cound not find cycle path!");
}
pair<vector<pair<size_t, vector<handle_t>>>, unordered_map<handle_t, handle_t>> IntegratedSnarlFinder::MergedAdjacencyGraph::longest_paths_in_forest(
const vector<pair<size_t, handle_t>>& longest_simple_cycles) const {
// TODO: somehow unify DFS logic with cycle-finding DFS in a way that still
// allows us to inspect our stack in each case?
// Going up the tree, we need to track the longest path from a leaf to the
// subtree root, and the longest path between leaves in the subtree. These
// ought to overlap substantially, but either may be the real winner when
// we get to where we rooted the DFS.
// Set up the return value
pair<vector<pair<size_t, vector<handle_t>>>, unordered_map<handle_t, handle_t>> to_return;
// When we find a longest path in a connected component (tree), we put its
// length and value in here. We describe it as edges followed.
auto& longest_tree_paths = to_return.first;
// We use this as part of our DFS scratch to record the first edge on the
// deepest path to a leaf in a subtree. The actual length of that path is
// stored in the main record for the head of the component the given edge
// reaches. If we find a longest leaf-leaf path in the tree that beats the
// simple cycle (if any), we rewrite this to be rooted somewhere along that
// leaf-leaf path. Indexed by head.
auto& deepest_child_edge = to_return.second;
// The DFS also needs records, one per component, indexed by head.
// Absence of a record = unvisited.
struct DFSRecord {
// Remember the edge to traverse to get back to the parent, so we can
// find the path from the longest leaf-leaf path's converging node to
// the DFS root if we need it.
handle_t parent_edge;
// How long is the deepest path to a leaf from here, plus the length of
// the edge followed to here from the parent?
// Filled in when we leave the stack, by looking at deepest_child_edge.
size_t leaf_path_length = 0;
// What edge goes to the second-deepest child, if we have one, to form
// the longest leaf-leaf path converging here?
handle_t second_deepest_child_edge;
// And do we have such a second-deepest child?
bool has_second_deepest_child = false;
// And what head in the graph is the convergance point of the longest
// leaf-leaf path in our subtree? If it points to us, and we don't have
// a second deepest child, there is no leaf-leaf path in our subtree.
//
// Actually filled in when we finish a node. When children write to it
// to max themselves in, they clobber it if it points back to us.
handle_t longest_subtree_path_root;
// We don't need to store this, because it's determined by the leaf
// path lengths of the best and second best children of the longest
// subtree path root, but to save a whole mess of transitive accesses
// we track the longest subtree paht length here as well. Will be 0
// when there is no subtree leaf-leaf path.
size_t longest_subtree_path_length;
};
unordered_map<handle_t, DFSRecord> records;
// We need a stack.
// Stack is actually in terms of inward edges followed.
struct DFSFrame {
handle_t here;
// What edges still need to be followed
vector<handle_t> todo;
};
vector<DFSFrame> stack;
// We have a function to try DFS from a root, if the root is unvisited.
// If root_cycle_length is nonzero, we will not rewrite deepest_child_edge
// to point towards the longest leaf-leaf path, if it isn't as long as the
// cycle or longer.
auto try_root = [&](handle_t traversal_root, size_t root_cycle_length) {
if (!records.count(traversal_root)) {
// If it hasn't been searched yet, start a search
stack.emplace_back();
stack.back().here = traversal_root;
#ifdef debug
cerr << "Root bridge tree traversal at " << graph->get_id(traversal_root) << (graph->get_is_reverse(traversal_root) ? "-" : "+") << endl;
#endif
while (!stack.empty()) {
// Until the DFS is done
auto& frame = stack.back();
// Find the node that following this edge got us to.
auto frame_head = find(frame.here);
#ifdef debug
cerr << "At stack frame " << stack.size() - 1 << " for edge " << graph->get_id(frame.here) << (graph->get_is_reverse(frame.here) ? "-" : "+")
<< " into component with head " << graph->get_id(frame_head) << (graph->get_is_reverse(frame_head) ? "-" : "+") << endl;
#endif
auto frame_it = records.find(frame_head);
if (frame_it == records.end()) {
// First visit to here.
#ifdef debug
cerr << "\tFirst visit. Find edges." << endl;
#endif
// Mark visited
frame_it = records.emplace_hint(frame_it, frame_head, DFSRecord());
// And fill it in with default references.
// Remember how to get back to the parent
frame_it->second.parent_edge = graph->flip(frame.here);
// Say there's no known leaf-leaf path converging anywhere under it yet.
frame_it->second.longest_subtree_path_root = frame_head;
// Queue up edges
for_each_member(frame_head, [&](handle_t member) {
// Follow edge by flipping.
auto flipped = graph->flip(member);
if (find(flipped) != frame_head) {
// Only accept non-self-loops.
#ifdef debug
cerr << "\t\tNeed to follow " << graph->get_id(flipped) << (graph->get_is_reverse(flipped) ? "-" : "+") << endl;
#endif
// Queue up the edge followed instead of the node
// reached (head), so we can emit the cycle later
// in terms of edges.
frame.todo.push_back(flipped);
}
});
}
auto& record = frame_it->second;
if (!frame.todo.empty()) {
// Now do an edge
handle_t edge_into = frame.todo.back();
handle_t connected_head = find(edge_into);
frame.todo.pop_back();
#ifdef debug
cerr << "\tFollowing " << graph->get_id(edge_into) << (graph->get_is_reverse(edge_into) ? "-" : "+") << endl;
#endif
if (!records.count(connected_head)) {
// Forward edge. Recurse.
#ifdef debug
cerr << "\t\tReaches unvisited " << graph->get_id(connected_head) << (graph->get_is_reverse(connected_head) ? "-" : "+") << "; Recurse!" << endl;
#endif
stack.emplace_back();
stack.back().here = edge_into;
}
} else {
// No children left.
#ifdef debug
cerr << "\tDone with all children." << endl;
#endif
// Did any of our children decalre themselves deepest?
// Or do we have no children.
auto deepest_child_edge_it = deepest_child_edge.find(frame_head);
if (stack.size() > 1) {
// If we have a parent
auto& parent_frame = stack[stack.size() - 2];
auto parent_head = find(parent_frame.here);
auto& parent_record = records[parent_head];
// The length of the path to a leaf will involve the edge from the parent to here.
record.leaf_path_length = graph->get_length(frame.here);
#ifdef debug
cerr << "\t\tLength of path to deepest leaf is " << record.leaf_path_length << " bp" << endl;
#endif
if (deepest_child_edge_it != deepest_child_edge.end()) {
// And if we have a child to go on with, we add the length of that path
record.leaf_path_length += records[find(deepest_child_edge_it->second)].leaf_path_length;
#ifdef debug
cerr << "\t\t\tPlus length from here to leaf via "
<< graph->get_id(deepest_child_edge_it->second) << (graph->get_is_reverse(deepest_child_edge_it->second) ? "-" : "+")
<< " for " << record.leaf_path_length << " bp total" << endl;
#endif
}
// Fill in deepest_child_edge for the parent if not filled in already, or if we beat what's there.
// Also maintain parent's second_deepest_child_edge.
auto parent_deepest_child_it = deepest_child_edge.find(parent_head);
if (parent_deepest_child_it == deepest_child_edge.end()) {
#ifdef debug
cerr << "\t\tWe are our parent's deepest child by default!" << endl;
#endif
// Emplace in the map where we didn't find anything.
deepest_child_edge.emplace_hint(parent_deepest_child_it, parent_head, frame.here);
} else if(records[find(parent_deepest_child_it->second)].leaf_path_length < record.leaf_path_length) {
// We are longer than what's there now
#ifdef debug
cerr << "\t\tWe are our parent's new deepest child!" << endl;
#endif
// Demote what's there to second-best
parent_record.second_deepest_child_edge = parent_deepest_child_it->second;
parent_record.has_second_deepest_child = true;
#ifdef debug
cerr << "\t\t\tWe demote "
<< graph->get_id(parent_record.second_deepest_child_edge) << (graph->get_is_reverse(parent_record.second_deepest_child_edge) ? "-" : "+")
<< " to second-deepest child" << endl;
#endif
// Replace the value we found
parent_deepest_child_it->second = frame.here;
} else if (!parent_record.has_second_deepest_child) {
#ifdef debug
cerr << "\t\tWe are our parent's second deepest child by default!" << endl;
#endif
// There's no second-deepest recorded so we must be it.
parent_record.second_deepest_child_edge = frame.here;
parent_record.has_second_deepest_child = true;
} else if (records[find(parent_record.second_deepest_child_edge)].leaf_path_length < record.leaf_path_length) {
#ifdef debug
cerr << "\t\tWe are our parent's new second deepest child!" << endl;
#endif
// We are a new second deepest child.
parent_record.second_deepest_child_edge = frame.here;
}
}
// The length of the longest leaf-leaf path converging at or under any child (if any) is in record.longest_subtree_path_length.
if (record.has_second_deepest_child || stack.size() == 1) {
// If there's a second incoming leaf path there's a converging leaf-leaf path here.
// If we're the root and there *isn't* a second incoming leaf-leaf path, we are ourselves a leaf.
// Grab the length of the longest leaf-leaf path converging exactly here.
// TODO: can we not look up the deepest child's record again?
size_t longest_here_path_length = 0;
if (deepest_child_edge_it != deepest_child_edge.end()) {
longest_here_path_length += records[find(deepest_child_edge_it->second)].leaf_path_length;
}
if (record.has_second_deepest_child) {
longest_here_path_length += records[find(record.second_deepest_child_edge)].leaf_path_length;
}
#ifdef debug
cerr << "\t\tPaths converge here with total length " << longest_here_path_length << " bp" << endl;
#endif
if (record.longest_subtree_path_root == frame_head || longest_here_path_length > record.longest_subtree_path_length) {
#ifdef debug
cerr << "\t\t\tNew longest path in subtree!" << endl;
#endif
// If there's no path from a child, or this path is
// longer, set record.longest_subtree_path_root
// (back) to frame_head to record that.
record.longest_subtree_path_root = frame_head;
// And save the length.
record.longest_subtree_path_length = longest_here_path_length;
// Now we are the new root of the longest leaf-leaf path converging at or under us.
}
}
if (stack.size() > 1 && record.longest_subtree_path_length > 0) {
// We have a leaf-leaf path converging at or under here, and we have a parent.
// TODO: we assume leaf-leaf paths are nonzero length here.
// TODO: save searching up the parent record again
auto& parent_frame = stack[stack.size() - 2];
auto parent_head = find(parent_frame.here);
auto& parent_record = records[parent_head];
// Max our longest leaf-leaf path in against the paths contributed by previous children.
if (parent_record.longest_subtree_path_root == parent_head ||
parent_record.longest_subtree_path_length < record.longest_subtree_path_length) {
#ifdef debug
cerr << "\t\tLongest path in our subtree converging at "
<< graph->get_id(record.longest_subtree_path_root) << (graph->get_is_reverse(record.longest_subtree_path_root) ? "-" : "+")
<< " is the new longest path in our parent's subtree." << endl;
#endif
// No child has contributed their leaf-leaf path so far, or ours is better.
parent_record.longest_subtree_path_root = record.longest_subtree_path_root;
parent_record.longest_subtree_path_length = record.longest_subtree_path_length;
}
}
if (stack.size() == 1) {
// When we get back to the root
#ifdef debug
cerr << "\t\tWe were the root of the traversal." << endl;
#endif
if (record.longest_subtree_path_length >= root_cycle_length) {
// Either we didn't root at a cycle, or we found a longer leaf-leaf path that should be the decomposition root instead.
#ifdef debug
cerr << "\t\t\tTree has leaf-leaf path that is as long as or longer than any cycle at root ("
<< record.longest_subtree_path_length << "bp)." << endl;
#endif
// We need to record the longest tree path.
longest_tree_paths.emplace_back();
longest_tree_paths.back().first = record.longest_subtree_path_length;
auto& path = longest_tree_paths.back().second;
auto& path_root_frame = records[record.longest_subtree_path_root];
if (path_root_frame.has_second_deepest_child) {
// This is an actual convergence point
#ifdef debug
cerr << "\t\t\t\tConverges at real convergence point" << endl;
#endif
// Collect the whole path down the second deepest child
path.push_back(path_root_frame.second_deepest_child_edge);
auto path_trace_it = deepest_child_edge.find(find(path.back()));
while (path_trace_it != deepest_child_edge.end()) {
// Follow the deepest child relationships until they run out.
path.push_back(path_trace_it->second);
path_trace_it = deepest_child_edge.find(find(path.back()));
}
// Reverse what's there and flip all the edges
vector<handle_t> flipped;
flipped.reserve(path.size());
for (auto path_it = path.rbegin(); path_it != path.rend(); ++path_it) {
flipped.push_back(graph->flip(*path_it));
}
path = std::move(flipped);
} else {
// There's no second-longest path; we statted at one of the most distant leaves.
#ifdef debug
cerr << "\t\t\t\tConverges at leaf" << endl;
#endif
}
if (deepest_child_edge.count(record.longest_subtree_path_root)) {
#ifdef debug
cerr << "\t\t\t\tNonempty path to distinct other leaf" << endl;
#endif
// There's a nonempty path to another leaf,
// other than the furthest one (and we aren't
// just a point).
// Trace the actual longest path from root to leaf and add it on
path.push_back(deepest_child_edge[record.longest_subtree_path_root]);
auto path_trace_it = deepest_child_edge.find(find(path.back()));
while (path_trace_it != deepest_child_edge.end()) {
// Follow the deepest child relationships until they run out.
path.push_back(path_trace_it->second);
path_trace_it = deepest_child_edge.find(find(path.back()));
}
}
// OK now we have the longest leaf-leaf path saved.
// We need to redo the path from the tree traversal
// root to the longest path convergence point, to
// fix up the subtree rooting information.
// Go to the convergence point
handle_t cursor = record.longest_subtree_path_root;
// This will be the path of edges to take from the convergence point (new root) to the traversal root (old root)
vector<handle_t> convergence_to_old_root;
while (cursor != frame_head) {
// Walk up the parent pointers to the traversal root and stack up the heads.
// We may get nothing if the root happened to already be on the longest leaf-leaf path.
auto& cursor_record = records[cursor];
convergence_to_old_root.push_back(cursor_record.parent_edge);
cursor = find(cursor_record.parent_edge);
}
#ifdef debug
cerr << "\t\t\t\tRewrite along " << convergence_to_old_root.size() << " edges..." << endl;
#endif
while (!convergence_to_old_root.empty()) {
// Then go down that stack
// Define new child and parent
handle_t parent_child_edge = convergence_to_old_root.back();
handle_t child_head = find(parent_child_edge);
handle_t parent_head = find(graph->flip(parent_child_edge));
// TODO: find a way to demote parent to child here on each iteration
auto& child_record = records[child_head];
auto& parent_record = records[parent_head];
// If the deepest child of the child is actually the parent, disqualify it
deepest_child_edge_it = deepest_child_edge.find(child_head);
if (deepest_child_edge_it != deepest_child_edge.end() && find(deepest_child_edge_it->second) == parent_head) {
// The parent was the child's deepest child. Can't have that.
if (child_record.has_second_deepest_child) {
// Promote the second deepest child.
deepest_child_edge_it->second = child_record.second_deepest_child_edge;
child_record.has_second_deepest_child = false;
} else {
// No more deepest child
deepest_child_edge.erase(deepest_child_edge_it);
deepest_child_edge_it = deepest_child_edge.end();
}
}
// The child may not have had a parent before.
// So we need to fill in its longest leaf path
// length counting its new parent edge.
// But we know all its children are done.
// The length of the path to a leaf will involve the edge from the parent to the child
child_record.leaf_path_length = graph->get_length(parent_child_edge);
if (deepest_child_edge_it != deepest_child_edge.end()) {
// And if we have a child to go on with, we add the length of that path
child_record.leaf_path_length += records[find(deepest_child_edge_it->second)].leaf_path_length;
}
// Now we have to mix ourselves into the parent.
// We do it the same way as normal. Both the deepest and second-deepest child of the parent can't be the grandparent.
// So if they both beat us we can't be the real deepest child.
// If we beat the second deepest child, and the original deepest child gets disqualified for being the grandparent, we become the parent's deepest child.
// And if we beat both it doesn't matter whether either gets disqualified, because we win.
// TODO: deduplicate code with the original DFS?
// Fill in deepest_child_edge for the parent if not filled in already, or if we beat what's there.
// Also maintain parent's second_deepest_child_edge.
auto parent_deepest_child_it = deepest_child_edge.find(parent_head);
if (parent_deepest_child_it == deepest_child_edge.end()) {
// Emplace in the map where we didn't find anything.
deepest_child_edge.emplace_hint(parent_deepest_child_it, parent_head, parent_child_edge);
} else if(records[find(parent_deepest_child_it->second)].leaf_path_length < child_record.leaf_path_length) {
// We are longer than what's there now
// Demote what's there to second-best
parent_record.second_deepest_child_edge = parent_deepest_child_it->second;
parent_record.has_second_deepest_child = true;
// Replace the value we found
parent_deepest_child_it->second = parent_child_edge;
} else if (!parent_record.has_second_deepest_child) {
// There's no second-deepest recorded so we must be it.
parent_record.second_deepest_child_edge = parent_child_edge;
parent_record.has_second_deepest_child = true;
} else if (records[find(parent_record.second_deepest_child_edge)].leaf_path_length < child_record.leaf_path_length) {
// We are a new second deepest child.
parent_record.second_deepest_child_edge = parent_child_edge;
}
// Now the new child, if its path is deep enough, is the parent's new deepest or second deepest child edge.
// Go up a level, disqualify the grandparent, and see who wins.
// The new root has no parent itself, so all its edges are eligible and the one with the longest path wins.
convergence_to_old_root.pop_back();
}
#ifdef debug
for (auto& item : path) {
cerr << "\t\t\t\tPath visits: "
<< graph->get_id(item) << (graph->get_is_reverse(item) ? "-" : "+")
<< " length " << graph->get_length(item) << endl;
}
#endif
if (path.empty()) {
// If the leaf-leaf path is empty, stick in a handle so we can actually find the single leaf in the bridge forest.
assert(longest_tree_paths.back().first == 0);
path.push_back(traversal_root);
} else {
// If anything is on the path, we shouldn't have 0 length.
assert(longest_tree_paths.back().first != 0);
}
}
}
// Now we're done with this stack frame.
// Clean up
stack.pop_back();
}
}
}
};
for (auto it = longest_simple_cycles.begin(); it != longest_simple_cycles.end(); ++it) {
// Try it from the head of the component that each longest input simple
// cycle got merged into. If we end up using that longest cycle to root
// this component, we will have everything pointing the right way
// already.
try_root(find(it->second), it->first);
}
// And then try it on every head in general to mop up anything without a simple cycle in it
for_each_head([&](handle_t head) {
try_root(head, 0);
});
// The DFS records die with this function, but the rewritten deepest child
// edges survive and let us root snarls having only their incoming ends.
// And we have all the longest tree paths that beat their components
// rooting cycles, if any.
#ifdef debug
cerr << "Edges to deepest children in bridge forest:" << endl;
for (auto& kv : deepest_child_edge) {
cerr << "\t" << graph->get_id(kv.first) << (graph->get_is_reverse(kv.first) ? "-" : "+")
<< " -> " << graph->get_id(kv.second) << (graph->get_is_reverse(kv.second) ? "-" : "+") << endl;
}
#endif
return to_return;
}
////////////////////////////////////////////////////////////////////////////////////////////
IntegratedSnarlFinder::IntegratedSnarlFinder(const HandleGraph& graph) : HandleGraphSnarlFinder(&graph) {
// Nothing to do!
}
void IntegratedSnarlFinder::traverse_decomposition(const function<void(handle_t)>& begin_chain, const function<void(handle_t)>& end_chain,
const function<void(handle_t)>& begin_snarl, const function<void(handle_t)>& end_snarl) const {
// Do the actual snarl finding work and then walk the bilayered tree.
#ifdef debug
cerr << "Ranking graph handles." << endl;
#endif
// First we need to ensure that our graph has dense handle ranks
bdsg::RankedOverlayHelper overlay_helper;
auto ranked_graph = overlay_helper.apply(graph);
#ifdef debug
cerr << "Finding snarls." << endl;
#endif
// We need a union-find over the adjacency components of the graph, in which we will build the cactus graph.
MergedAdjacencyGraph cactus(ranked_graph);
#ifdef debug
cerr << "Base adjacency components:" << endl;
cactus.to_dot(cerr);
#endif
// It magically gets the adjacency components itself.
#ifdef debug
cerr << "Finding 3 edge connected components..." << endl;
#endif
// Now we need to do the 3 edge connected component merging, using Tsin's algorithm.
// We don't really have a good dense rank space on the adjacency components, so we use the general version.
// TODO: Somehow have a nice dense rank space on components. Can we just use backing graph ranks and hope it's dense enough?
// We represent each adjacency component (node) by its heading handle.
#ifdef debug
size_t tecc_id = 0;
#endif
// Buffer merges until the algorithm is done.
vector<pair<handle_t, handle_t>> merge_list;
algorithms::three_edge_connected_component_merges<handle_t>([&](const function<void(handle_t)>& emit_node) {
// Feed all the handles that head adjacency components into the algorithm
cactus.for_each_head([&](handle_t head) {
#ifdef debug
cerr << "Three edge component node " << tecc_id << " is head " << graph->get_id(head) << (graph->get_is_reverse(head) ? "-" : "+") << endl;
tecc_id++;
#endif
emit_node(head);
});
}, [&](handle_t node, const function<void(handle_t)>& emit_edge) {
// When asked for edges, don't deduplicate or filter. We want all multi-edges.
cactus.for_each_member(node, [&](handle_t other_member) {
// For each handle in the adjacency component that this handle is heading (including the head)
// Follow as an edge again, by flipping
handle_t member_connected_head = cactus.find(graph->flip(other_member));
if (member_connected_head == node && graph->get_is_reverse(other_member)) {
// For self loops, only follow them in one direction. Skip in the other.
return;
}
// Announce it. Multi-edges are OK.
emit_edge(member_connected_head);
});
}, [&](handle_t a, handle_t b) {
// Now we got a merge to create the 3 edge connected components.
// We can't actually do the merge now, because we can't let the merges
// be visible to the algorithm while it is working.
merge_list.emplace_back(a, b);
});
// Now execute the merges, since the algorithm is done looking at the graph.
for (auto& ab : merge_list) {
cactus.merge(ab.first, ab.second);
}
merge_list.clear();
// Now our 3-edge-connected components have been condensed, and we have a proper Cactus graph.
#ifdef debug
cerr << "After 3ecc merging:" << endl;
cactus.to_dot(cerr);
#endif
#ifdef debug
cerr << "Creating bridge forest..." << endl;
#endif
// Then we need to copy the base Cactus graph so we can make the bridge forest
MergedAdjacencyGraph forest(cactus);
#ifdef debug
cerr << "Finding simple cycles..." << endl;
#endif
// Get cycle information: longest cycle in each connected component, and next edge along cycle for each edge (in one orientation)
pair<vector<pair<size_t, handle_t>>, unordered_map<handle_t, handle_t>> cycles = cactus.cycles_in_cactus();
auto& longest_cycles = cycles.first;
auto& next_along_cycle = cycles.second;
for (auto& kv : next_along_cycle) {
// Merge along all cycles in the bridge forest
forest.merge(kv.first, kv.second);
}
#ifdef debug
cerr << "Bridge forest:" << endl;
forest.to_dot(cerr);
#endif
#ifdef debug
cerr << "Finding bridge edge paths..." << endl;
#endif
// Now we find the longest path in each tree in the bridge forest, with its
// length in bases.
//
// We also find, for each bridge edge component head, the edge towards the
// deepest bridge edge tree leaf, which lets us figure out how to root
// dangly bits into chains.
//
// Make sure to root at the nodes corresponding to the collapsed longest
// cycles, if the leaf-leaf paths don't win their components.
//
// For empty leaf-leaf paths, will emit a single node "path" with a length
// of 0.
pair<vector<pair<size_t, vector<handle_t>>>, unordered_map<handle_t, handle_t>> forest_paths = forest.longest_paths_in_forest(longest_cycles);
auto& longest_paths = forest_paths.first;
auto& towards_deepest_leaf = forest_paths.second;
#ifdef debug
cerr << "Sorting candidate roots..." << endl;
#endif
// Make sure we are looking at all the cycles and leaf-leaf paths in order.
// We need basically priority queue between them. But we don't need insert so we jsut sort.
std::sort(longest_cycles.begin(), longest_cycles.end());
std::sort(longest_paths.begin(), longest_paths.end());
// Now that we have computed the graphs we need, do the traversal of them.
// This modifies the structures we have computed in-place, and also does
// some extra merges in the cactus graph to make all chains cycles.
traverse_computed_decomposition(cactus,
forest,
longest_paths,
towards_deepest_leaf,
longest_cycles,
next_along_cycle,
begin_chain,
end_chain,
begin_snarl,
end_snarl);
}
void IntegratedSnarlFinder::traverse_computed_decomposition(MergedAdjacencyGraph& cactus,
const MergedAdjacencyGraph& forest,
vector<pair<size_t, vector<handle_t>>>& longest_paths,
unordered_map<handle_t, handle_t>& towards_deepest_leaf,
vector<pair<size_t, handle_t>>& longest_cycles,
unordered_map<handle_t, handle_t>& next_along_cycle,
const function<void(handle_t)>& begin_chain, const function<void(handle_t)>& end_chain,
const function<void(handle_t)>& begin_snarl, const function<void(handle_t)>& end_snarl) const {
// Now, keep a set of all the edges that have found a place in the decomposition.
unordered_set<handle_t> visited;
#ifdef debug
cerr << "Traversing cactus graph..." << endl;
#endif
// How many handle graph nodes need to be decomposed?
size_t to_decompose = graph->get_node_count();
while(visited.size() < to_decompose) {
// While we haven't touched everything
#ifdef debug
if (!longest_cycles.empty()) {
cerr << "Longest cycle: " << longest_cycles.back().first << " bp" << endl;
}
if (!longest_paths.empty()) {
cerr << "Longest path: " << longest_paths.back().first << " bp" << endl;
}
#endif
// We have a stack.
struct SnarlChainFrame {
// Set to true if this is a snarl being generated, and false if it is a chain.
bool is_snarl = true;
// Set to true if the children have already been enumerated.
// If we get back to a frame, and this is true, and todo is empty, we are done with the frame.
bool saw_children = false;
// Into and out-of edges of this snarl or chain, within its parent.
// Only set if we aren't the root frame on the stack.
pair<handle_t, handle_t> bounds;
// Edges denoting children to process.
// If we are a snarl, an entry may be a bridge edge reading into us.
// If so, we will transform it into a cycle.
// If we are a snarl, an entry may be a cycle edge reading into us (with the next edge around the cycle reading out).
// If so, we will recurse on the chain.
// If we are a chain, an entry may be an edge reading into a child snarl.
// If so, we will find the other side of the snarl and recurse on the snarl.
vector<handle_t> todo;
};
vector<SnarlChainFrame> stack;
if (longest_cycles.empty() || (!longest_paths.empty() && longest_cycles.back().first <= longest_paths.back().first)) {
// There should be a path still
assert(!longest_paths.empty());
// It should not be empty. It should at least have a single bridge forest node to visit.
assert(!longest_paths.back().second.empty());
// We will root on a tip-tip path for its connected component, if
// not already covered, because there isn't a longer cycle.
if (!visited.count(longest_paths.back().second.front())) {
// This connected component isn't already covered.
handle_t first_edge = longest_paths.back().second.front();
if (longest_paths.back().first == 0) {
// This is a 0-length path, but we want to root the decomposition here.
// This bridge tree has no nonempty cycles and no bridge edges. It's just all one adjacency component.
// All contents spill out into the root snarl as contained nodes.
#ifdef debug
cerr << "Single node bridge tree with no real cycles for "
<< graph->get_id(first_edge) << (graph->get_is_reverse(first_edge) ? "-" : "+") << endl;
cerr << "\tSpilling contents into root snarl." << endl;
#endif
cactus.for_each_member(cactus.find(first_edge), [&](handle_t inbound) {
// The contents are all self loops
assert(cactus.find(inbound) == cactus.find(graph->flip(inbound)));
if (!graph->get_is_reverse(inbound)) {
// We only want them forward so each becomes only one empty chain.
#ifdef debug
cerr << "\t\tContain edge " << graph->get_id(inbound) << (graph->get_is_reverse(inbound) ? "-" : "+") << endl;
#endif
begin_chain(inbound);
end_chain(inbound);
visited.insert(graph->forward(inbound));
}
});
} else {
// This is a real path between distinct bridge edge tree leaves
#ifdef debug
cerr << "Rooting component at tip-tip path starting with " << graph->get_id(first_edge) << (graph->get_is_reverse(first_edge) ? "-" : "+") << endl;
#endif
for (size_t i = 1; i < longest_paths.back().second.size(); i++) {
// Rewrite the deepest bridge graph leaf path map to point from one end of the tip-tip path to the other
// TODO: bump this down into the bridge path finding function
handle_t prev_path_edge = longest_paths.back().second[i - 1];
handle_t prev_head = forest.find(prev_path_edge);
handle_t next_path_edge = longest_paths.back().second[i];
towards_deepest_leaf[prev_head] = next_path_edge;
#ifdef debug
cerr << "\tEnforce leaf path goes " << graph->get_id(prev_path_edge) << (graph->get_is_reverse(prev_path_edge) ? "-" : "+")
<< " with head " << graph->get_id(prev_head) << (graph->get_is_reverse(prev_head) ? "-" : "+")
<< " to next edge " << graph->get_id(next_path_edge) << (graph->get_is_reverse(next_path_edge) ? "-" : "+") << endl;
#endif
}
// Stack up a root/null snarl containing this bridge edge.
// Remember to queue it facing inward, toward the new new root at the start of the path.
stack.emplace_back();
stack.back().is_snarl = true;
stack.back().todo.push_back(graph->flip(first_edge));
#ifdef debug
cerr << "\tPut cycles and self edges at tip into root snarl" << endl;
#endif
// Find all the cycles and self edges that are also here and make sure to do them. Connectivity will be in the root snarl.
cactus.for_each_member(cactus.find(graph->flip(first_edge)), [&](handle_t inbound) {
if (inbound == graph->flip(first_edge)) {
// Skip the one bridge edge we started with
return;
}
#ifdef debug
cerr << "\t\tLook at edge " << graph->get_id(inbound) << (graph->get_is_reverse(inbound) ? "-" : "+") << " on " << next_along_cycle.count(inbound) << " cycles" << endl;
#endif
if (next_along_cycle.count(inbound)) {
// Put this cycle on the to do list also
#ifdef debug
cerr << "\t\t\tLook at cycle edge " << graph->get_id(inbound) << (graph->get_is_reverse(inbound) ? "-" : "+") << endl;
#endif
stack.back().todo.push_back(inbound);
} else if (cactus.find(inbound) == cactus.find(graph->flip(inbound)) && !graph->get_is_reverse(inbound)) {
// Self loop.
// We only want them forward so each becomes only one empty chain.
#ifdef debug
cerr << "\t\t\tContain edge " << graph->get_id(inbound) << (graph->get_is_reverse(inbound) ? "-" : "+") << endl;
#endif
begin_chain(inbound);
end_chain(inbound);
visited.insert(graph->forward(inbound));
}
});
}
}
longest_paths.pop_back();
} else {
// We will root on a cycle for its component, if not already covered.
if (!visited.count(longest_cycles.back().second)) {
// This connected component hasn't been done yet.
#ifdef debug
cerr << "Rooting component at cycle for " << graph->get_id(longest_cycles.back().second) << endl;
#endif
// We have an edge on the longest cycle. But it may be reading into and out of nodes that also contains other cycles, bridge edges, and so on.
// If we declare this longest cycle to be a chain, we need to make sure that both those nodes become snarls in a chain.
// So we introduce a chain that starts and ends with this edge.
// We can't quite articulate that as a todo list entry, so we forge two stack frames.
// Stack up a root/null snarl containing this cycle as a chain.
stack.emplace_back();
stack.back().is_snarl = true;
// Stack up a frame for doing the chain, with the cycle-closing edge as both ends.
stack.emplace_back();
stack.back().is_snarl = false;
stack.back().bounds = make_pair(longest_cycles.back().second, longest_cycles.back().second);
// We'll find all the self edges OK when we look in the first/last snarls on the chain.
}
longest_cycles.pop_back();
}
while (!stack.empty()) {
auto& frame = stack.back();
#ifdef debug
cerr << "At stack frame " << stack.size() - 1 << " for ";
if (stack.size() == 1) {
cerr << "root";
} else {
cerr << (frame.is_snarl ? "snarl" : "chain") << " " << graph->get_id(frame.bounds.first) << (graph->get_is_reverse(frame.bounds.first) ? "-" : "+")
<< " to " << graph->get_id(frame.bounds.second) << (graph->get_is_reverse(frame.bounds.second) ? "-" : "+");
}
cerr << endl;
#endif
if (stack.size() > 1 && !frame.saw_children) {
// We need to queue up the children; this is the first time we are doing this frame.
frame.saw_children = true;
#ifdef debug
cerr << "\tAnnouncing entry..." << endl;
#endif
// Announce entering this snarl or chain in the traversal
(frame.is_snarl ? begin_snarl : begin_chain)(frame.bounds.first);
#ifdef debug
cerr << "\tLooking for children..." << endl;
#endif
if (frame.is_snarl) {
// Visit the start and end of the snarl, for decomposition purposes.
visited.insert(graph->forward(frame.bounds.first));
visited.insert(graph->forward(frame.bounds.second));
// TODO: register as part of snarl in index
// Make sure this isn't trying to be a unary snarl
assert(frame.bounds.first != frame.bounds.second);
// For a snarl, we need to find all the bridge edges and all the incoming cycle edges
cactus.for_each_member(cactus.find(frame.bounds.first), [&](handle_t inbound) {
if (inbound == frame.bounds.first || graph->flip(inbound) == frame.bounds.second) {
// This is our boundary; don't follow it as contents.
#ifdef debug
cerr << "\t\tStay inside snarl-bounding edge " << graph->get_id(inbound) << (graph->get_is_reverse(inbound) ? "-" : "+") << endl;
#endif
} else if (forest.find(graph->flip(inbound)) != forest.find(inbound)) {
// This is a bridge edge. The other side is a different component in the bridge graph.
#ifdef debug
cerr << "\t\tLook at bridge edge " << graph->get_id(inbound) << (graph->get_is_reverse(inbound) ? "-" : "+") << endl;
#endif
frame.todo.push_back(inbound);
} else if (next_along_cycle.count(inbound)) {
// This edge is the incoming edge for a cycle. Queue it up.
#ifdef debug
cerr << "\t\tLook at cycle edge " << graph->get_id(inbound) << (graph->get_is_reverse(inbound) ? "-" : "+") << endl;
#endif
frame.todo.push_back(inbound);
} else if (cactus.find(graph->flip(inbound)) == cactus.find(inbound) && !graph->get_is_reverse(inbound)) {
// Count all self edges as empty chains, but only in one orientation.
#ifdef debug
cerr << "\t\tContain edge " << graph->get_id(inbound) << (graph->get_is_reverse(inbound) ? "-" : "+") << endl;
#endif
begin_chain(inbound);
end_chain(inbound);
visited.insert(graph->forward(inbound));
}
});
} else {
// For a chain, we need to queue up all the edges reading into child snarls, paired with the edges reading out of them.
// We know we're a cycle that can be followed.
handle_t here = frame.bounds.first;
unordered_set<handle_t> seen;
size_t region_start = frame.todo.size();
do {
#ifdef debug
cerr << "\t\tLook at cycle edge " << graph->get_id(here) << (graph->get_is_reverse(here) ? "-" : "+") << endl;
#endif
// We shouldn't loop around unless we hit the end of the chain.
assert(!seen.count(here));
seen.insert(here);
// Queue up
frame.todo.push_back(here);
here = next_along_cycle.at(here);
// TODO: when processing entries, we're going to look them up in next_along_cycle again.
// Can we dispense with the todo list and create stack frames directly?
// Keep going until we come to the end.
// We do this as a do-while because the start may be the end but we still want to go around the cycle.
} while (here != frame.bounds.second);
// Now we have put all the snarls in the chain on the to
// do list. But we process the to do list from the end, so
// as is we're going to traverse them backward along the
// chain. We want to see them forward along the chain
// instead, so reverse this part of the vector.
// TODO: should we make the to do list a list? That would
// save a reverse but require a bunch of allocations and
// pointer follows.
std::reverse(frame.todo.begin() + region_start, frame.todo.end());
}
}
if (!frame.todo.empty()) {
// Until we run out of edges to work on
handle_t task = frame.todo.back();
frame.todo.pop_back();
if (frame.is_snarl) {
// May have a bridge edge or a cycle edge, both inbound.
auto next_along_cycle_it = next_along_cycle.find(task);
if (next_along_cycle_it != next_along_cycle.end()) {
// To handle a cycle in the current snarl
#ifdef debug
cerr << "\tHandle cycle edge " << graph->get_id(task) << (graph->get_is_reverse(task) ? "-" : "+") << endl;
#endif
// We have the incoming edge, so find the outgoing edge along the same cycle
handle_t outgoing = next_along_cycle_it->second;
#ifdef debug
cerr << "\t\tEnds chain starting at " << graph->get_id(outgoing) << (graph->get_is_reverse(outgoing) ? "-" : "+") << endl;
#endif
#ifdef debug
cerr << "\t\t\tRecurse on chain " << graph->get_id(outgoing) << (graph->get_is_reverse(outgoing) ? "-" : "+") << " to "
<< graph->get_id(task) << (graph->get_is_reverse(task) ? "-" : "+") << endl;
#endif
if (stack.size() > 1) {
// We have boundaries. Make sure we don't try and
// do a chain that starts or ends with our
// boundaries. That's impossible.
assert(frame.bounds.first != outgoing);
assert(frame.bounds.second != task);
}
// Recurse on the chain bounded by those edges, as a child
stack.emplace_back();
stack.back().is_snarl = false;
stack.back().bounds = make_pair(outgoing, task);
} else {
// To handle a bridge edge in the current snarl:
#ifdef debug
cerr << "\tHandle bridge edge " << graph->get_id(task) << (graph->get_is_reverse(task) ? "-" : "+") << endl;
#endif
// Flip it to look out
handle_t edge = graph->flip(task);
#ifdef debug
cerr << "\t\tWalk edge " << graph->get_id(edge) << (graph->get_is_reverse(edge) ? "-" : "+") << endl;
#endif
// Track the head in the Cactus graph for the bridge edges we walk.
handle_t cactus_head = cactus.find(edge);
// And track where its bridge forest component points to as towards the deepest leaf.
auto deepest_it = towards_deepest_leaf.find(forest.find(cactus_head));
while (deepest_it != towards_deepest_leaf.end()) {
// Follow its path down bridge graph heads, to the
// deepest bridge graph leaf head (which has no
// deeper child)
// See what our next bridge edge comes out of in the Cactus graph
handle_t next_back_head = cactus.find(graph->flip(deepest_it->second));
#ifdef debug
cerr << "\t\t\tHead: " << graph->get_id(cactus_head) << (graph->get_is_reverse(cactus_head) ? "-" : "+") << endl;
cerr << "\t\t\tNext edge back head: " << graph->get_id(next_back_head) << (graph->get_is_reverse(next_back_head) ? "-" : "+") << endl;
#endif
if (cactus_head != next_back_head) {
// We skipped over a run of interlinked cycle in the bridge tree.
// We need to find a path of cycles to complete the path in the bridge tree.
// Each cycle needs to be cut into two pieces
// that can be alternatives in the snarl.
#ifdef debug
cerr << "\t\t\tFind skipped cycle path" << endl;
#endif
vector<handle_t> cycle_path = cactus.find_cycle_path_in_cactus(next_along_cycle, cactus_head, next_back_head);
while (!cycle_path.empty()) {
// Now pop stuff off the end of the path and
// merge it with the component next_back_head
// is in, making sure to pinch off the cycles
// we cut as we do it.
// Walk the cycle (again) to find where it hits the end component.
// TODO: Save the first traversal we did!
auto through_path_member = next_along_cycle.find(cycle_path.back());
auto through_end = through_path_member;
do {
// Follow the cycle until we reach the edge going into the end component.
through_end = next_along_cycle.find(through_end->second);
} while (cactus.find(through_end->first) != cactus.find(next_back_head));
// Now pinch the cycle
#ifdef debug
cerr << "\t\t\tPinch cycle between " << graph->get_id(cycle_path.back()) << (graph->get_is_reverse(cycle_path.back()) ? "-" : "+")
<< " and " << graph->get_id(through_end->first) << (graph->get_is_reverse(through_end->first) ? "-" : "+") << endl;
#endif
// Merge the two components where the bridge edges attach, to close the two new cycles.
cactus.merge(cycle_path.back(), next_back_head);
#ifdef debug
cerr << "\t\t\t\tExchange successors of " << graph->get_id(through_path_member->first) << (graph->get_is_reverse(through_path_member->first) ? "-" : "+")
<< " and " << graph->get_id(through_end->first) << (graph->get_is_reverse(through_end->first) ? "-" : "+") << endl;
#endif
// Exchange their destinations to pinch the cycle in two.
std::swap(through_path_member->second, through_end->second);
if (through_path_member->first == through_path_member->second) {
// Now a self loop cycle. Delete the cycle.
#ifdef debug
cerr << "\t\t\t\t\tDelete self loop cycle " << graph->get_id(through_path_member->first) << (graph->get_is_reverse(through_path_member->first) ? "-" : "+") << endl;
#endif
// Won't affect other iterators.
next_along_cycle.erase(through_path_member);
}
if (through_end->first == through_end->second) {
// Now a self loop cycle. Delete the cycle.
#ifdef debug
cerr << "\t\t\t\t\tDelete self loop cycle " << graph->get_id(through_end->first) << (graph->get_is_reverse(through_end->first) ? "-" : "+") << endl;
#endif
// Won't affect other iterators.
next_along_cycle.erase(through_end);
}
// And pop it off and merge the end (which now includes it) with whatever came before it on the path.
cycle_path.pop_back();
}
}
// Record the new cycle we are making from this bridge path
next_along_cycle[edge] = deepest_it->second;
// Advance along the bridge tree path.
edge = deepest_it->second;
#ifdef debug
cerr << "\t\tWalk edge " << graph->get_id(edge) << (graph->get_is_reverse(edge) ? "-" : "+") << endl;
#endif
cactus_head = cactus.find(edge);
deepest_it = towards_deepest_leaf.find(forest.find(cactus_head));
}
// When you get to the end
if (edge == graph->flip(task)) {
// It turns out there's only one edge here.
// It is going to become a contained self-loop, instead of a real cycle
// TODO: register as part of snarl in index
visited.insert(graph->forward(edge));
#ifdef debug
cerr << "\t\tContain new self-loop " << graph->get_id(edge) << (graph->get_is_reverse(edge) ? "-" : "+") << endl;
#endif
} else {
// Close the cycle we are making out of the bridge
// forest path.
// The last edge crossed currently reads into the end
// component, but will read into us after the merge.
// The cycle comes in through there and leaves backward
// through the inbound bridge edge we started with.
next_along_cycle[edge] = graph->flip(task);
#ifdef debug
cerr << "\t\tClose cycle between " << graph->get_id(edge) << (graph->get_is_reverse(edge) ? "-" : "+")
<< " and " << graph->get_id(task) << (graph->get_is_reverse(task) ? "-" : "+") << endl;
#endif
}
// Merge the far end of the last bridge edge (which may have cycles on it) into the current snarl
// First find all the new cycles this brings along.
// It can't bring any bridge edges.
// This will detect the cycle we just created.
cactus.for_each_member(cactus_head, [&](handle_t inbound) {
// TODO: deduplicate with snarl setup
if (next_along_cycle.count(inbound)) {
#ifdef debug
cerr << "\t\tInherit cycle edge " << graph->get_id(inbound) << (graph->get_is_reverse(inbound) ? "-" : "+") << endl;
#endif
// This edge is the incoming edge for a cycle. Queue it up.
frame.todo.push_back(inbound);
} else if (cactus.find(graph->flip(inbound)) == cactus.find(inbound)) {
#ifdef debug
cerr << "\t\tInherit contained edge " << graph->get_id(inbound) << (graph->get_is_reverse(inbound) ? "-" : "+") << endl;
#endif
// Count all self edges as empty chains.
begin_chain(inbound);
end_chain(inbound);
visited.insert(graph->forward(inbound));
}
});
// Then do the actual merge.
cactus.merge(edge, task);
// Now we've queued up the cycle we just made out of
// the bridge edges, along with any cycles we picked up
// from the end of the bridge tree path.
}
} else {
#ifdef debug
cerr << "\tHandle cycle edge " << graph->get_id(task) << (graph->get_is_reverse(task) ? "-" : "+") << endl;
#endif
// We're a chain, and WLOG a chain that represents a cycle.
// We have an edge.
// We need to find the other edge that defines the snarl, and recurse into the snarl.
handle_t out_edge = next_along_cycle.at(task);
#ifdef debug
cerr << "\t\tRecurse on snarl " << graph->get_id(task) << (graph->get_is_reverse(task) ? "-" : "+") << " to "
<< graph->get_id(out_edge) << (graph->get_is_reverse(out_edge) ? "-" : "+")<< endl;
#endif
stack.emplace_back();
stack.back().is_snarl = true;
stack.back().bounds = make_pair(task, out_edge);
}
} else {
// Now we have finished a stack frame!
if (stack.size() > 1) {
// We have bounds
#ifdef debug
cerr << "\tAnnouncing exit..." << endl;
#endif
// Announce leaving this snarl or chain in the traversal
(frame.is_snarl ? end_snarl : end_chain)(frame.bounds.second);
}
#ifdef debug
cerr << "\tReturn to parent frame" << endl;
#endif
stack.pop_back();
}
}
}
}
SnarlManager IntegratedSnarlFinder::find_snarls_parallel() {
vector<unordered_set<id_t>> weak_components = algorithms::weakly_connected_components(graph);
vector<SnarlManager> snarl_managers(weak_components.size());
#pragma omp parallel for schedule(dynamic, 1)
for (size_t i = 0; i < weak_components.size(); ++i) {
const HandleGraph* subgraph;
if (weak_components.size() == 1) {
subgraph = graph;
} else {
// turn the component into a graph
subgraph = new SubgraphOverlay(graph, &weak_components[i]);
}
IntegratedSnarlFinder finder(*subgraph);
// find the snarls without building the index
snarl_managers[i] = finder.find_snarls_unindexed();
if (weak_components.size() != 1) {
// delete our component graph overlay
delete subgraph;
}
}
// merge the managers into the biggest one.
size_t biggest_snarl_idx = 0;
for (size_t i = 1; i < snarl_managers.size(); ++i) {
if (snarl_managers[i].num_snarls() > snarl_managers[biggest_snarl_idx].num_snarls()) {
biggest_snarl_idx = i;
}
}
for (size_t i = 0; i < snarl_managers.size(); ++i) {
if (i != biggest_snarl_idx) {
snarl_managers[i].for_each_snarl_unindexed([&](const Snarl* snarl) {
snarl_managers[biggest_snarl_idx].add_snarl(*snarl);
});
}
}
snarl_managers[biggest_snarl_idx].finish();
return std::move(snarl_managers[biggest_snarl_idx]);
}
}
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{977cb199-b7a8-459a-835d-d6f3808cff21}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{60bdb20e-5fae-425f-ad97-1a402f0c5407}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{c70bb9a1-418d-4af1-901e-79ad75f82942}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\game\bg_lib.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\game\bg_misc.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\qcommon\q_math.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\qcommon\q_shared.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\ui\ui_atoms.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\ui\ui_gameinfo.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\ui\ui_main.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\ui\ui_players.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\ui\ui_shared.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\ui\ui_syscalls.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CustomBuildStep Include="..\..\ui\ui.def">
<Filter>Source Files</Filter>
</CustomBuildStep>
<CustomBuildStep Include="..\..\game\bg_public.h">
<Filter>Header Files</Filter>
</CustomBuildStep>
<CustomBuildStep Include="..\..\ui\keycodes.h">
<Filter>Header Files</Filter>
</CustomBuildStep>
<CustomBuildStep Include="..\..\..\ui\menudef.h">
<Filter>Header Files</Filter>
</CustomBuildStep>
<CustomBuildStep Include="..\..\game\q_shared.h">
<Filter>Header Files</Filter>
</CustomBuildStep>
<CustomBuildStep Include="..\..\game\surfaceflags.h">
<Filter>Header Files</Filter>
</CustomBuildStep>
<CustomBuildStep Include="..\..\cgame\tr_types.h">
<Filter>Header Files</Filter>
</CustomBuildStep>
<CustomBuildStep Include="..\..\ui\ui_local.h">
<Filter>Header Files</Filter>
</CustomBuildStep>
<CustomBuildStep Include="..\..\ui\ui_public.h">
<Filter>Header Files</Filter>
</CustomBuildStep>
<CustomBuildStep Include="..\..\ui\ui_shared.h">
<Filter>Header Files</Filter>
</CustomBuildStep>
</ItemGroup>
</Project> | {
"pile_set_name": "Github"
} |
// ---------------------------------------------------------------------
//
// Copyright (C) 2003 - 2018 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, 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.
// The full text of the license can be found in the file LICENSE.md at
// the top level directory of deal.II.
//
// ---------------------------------------------------------------------
// test ParameterHandler::log_parameters(Text)
#include <deal.II/base/parameter_handler.h>
#include "../tests.h"
int
main()
{
try
{
initlog();
ParameterHandler prm;
prm.enter_subsection("Testing testing");
{
prm.declare_entry("string list",
"a",
Patterns::List(
Patterns::Selection("a|b|c|d|e|f|g|h")),
"docs 1");
prm.declare_entry("int/int", "1", Patterns::Integer());
prm.declare_entry("double_double",
"3.1415926",
Patterns::Double(),
"docs 3");
prm.enter_subsection("Testing%testing");
{
prm.declare_entry("string&list",
"a,b,c",
Patterns::List(
Patterns::Selection("a|b|c|d|e|f|g|h")),
"docs 1");
prm.declare_entry("int*int", "2", Patterns::Integer());
prm.declare_entry("double+double",
"6.1415926",
Patterns::Double(),
"docs 3");
}
prm.leave_subsection();
}
prm.leave_subsection();
// read and then write
// parameters. take same input file
// as for parameter_handler_3, but
// use different output format
prm.parse_input(SOURCE_DIR "/prm/parameter_handler_8.prm");
prm.log_parameters(deallog);
}
catch (std::exception &exc)
{
deallog << std::endl
<< std::endl
<< "----------------------------------------------------"
<< std::endl;
deallog << "Exception on processing: " << std::endl
<< exc.what() << std::endl
<< "Aborting!" << std::endl
<< "----------------------------------------------------"
<< std::endl;
return 1;
}
catch (...)
{
deallog << std::endl
<< std::endl
<< "----------------------------------------------------"
<< std::endl;
deallog << "Unknown exception!" << std::endl
<< "Aborting!" << std::endl
<< "----------------------------------------------------"
<< std::endl;
return 1;
};
return 0;
}
| {
"pile_set_name": "Github"
} |
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, [email protected], http://libtom.org
*/
#include "tomcrypt.h"
/**
@file crypt_find_cipher_any.c
Find a cipher in the descriptor tables, Tom St Denis
*/
/**
Find a cipher flexibly. First by name then if not present by block and key size
@param name The name of the cipher desired
@param blocklen The minimum length of the block cipher desired (octets)
@param keylen The minimum length of the key size desired (octets)
@return >= 0 if found, -1 if not present
*/
int find_cipher_any(const char *name, int blocklen, int keylen)
{
int x;
LTC_ARGCHK(name != NULL);
x = find_cipher(name);
if (x != -1) return x;
LTC_MUTEX_LOCK(<c_cipher_mutex);
for (x = 0; x < TAB_SIZE; x++) {
if (cipher_descriptor[x].name == NULL) {
continue;
}
if (blocklen <= (int)cipher_descriptor[x].block_length && keylen <= (int)cipher_descriptor[x].max_key_length) {
LTC_MUTEX_UNLOCK(<c_cipher_mutex);
return x;
}
}
LTC_MUTEX_UNLOCK(<c_cipher_mutex);
return -1;
}
/* $Source$ */
/* $Revision$ */
/* $Date$ */
| {
"pile_set_name": "Github"
} |
//
// ORViewController.h
// ARAnalyticsTests
//
// Created by orta therox on 05/01/2013.
// Copyright (c) 2013 Orta Therox. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ORViewController : UIViewController
@end
| {
"pile_set_name": "Github"
} |
Ising/QUBO problem
==================
Blueqat wq module is a module for solbing Ising and Quadratic Unconstrained Binary Optimization (QUBO) problems.
It includes local solver for Simulated Annealing (SA) and Simulated Quantum Annealing (SQA).
You can also submit problems to D-Wave cloud machine using wq module.
What is Ising model
-------------------
Real Quantum Annealing (QA) machines are built upon physical model called Ising model, which can be computationally
simulated on our laptops with algorithms called Simulated Annealing (SA) or Simulated Quantum Annealing (SQA).
1-dimensional Ising model is a 1D array of quantum bits (qubits), each of them has a ‘spin’ of +1 (up) or -1 (down).
2-dimensional Ising model is similar, it consists of a plainer lattice and has more adjacent qubits than 1D.
Although the complex physics may be overwhelming to you, wq module let you easily calculate the model without knowing much about them.
Combinatorial Optimization problem and SA
-----------------------------------------
Simulated Annealing (SA) can be used to solve combinatorial optimization problems of some forms, and Ising model is one of them.
Metropolis sampling based Monte-Carlo methods are used in such procedures.
Hamiltonian
-----------
To solve Ising model with SA, we have to set Jij/hi which describes how strong a pair of qubits are coupled, and how strong a qubit is biased, respectively.
Simulated Annealing and Simulated Quantum Annealing
---------------------------------------------------
We also have algorithm called Simulated Quantum Annealing(SQA) to solve Ising problems, in which quantum effects are taken into account.
The effect of quantum superposition is approximated by the parallel execution of different world-line,
by which we can effectively simulate wilder quantum nature.
Technically, path-integral methods based on Suzuki-Trotter matrix decomposition are used in the algorithm.
Checking and Verifying solutions
--------------------------------
We can calculate how good (or bad) a solution is by calculating ‘Energy’ of the solution, which can be done by a wq module one-liner.
Repeatedly solving Ising model, comparing that energy may let you know which is the best, or better answer to the problem.
If the problem is of NP, then checking whether the constraints are fulfilled can also be calculated in polynomial time.
QUBO
----
Ising model problems are represented by Quadratic Unconstrained Binary Optimization (QUBO) problems.
Although variables in combinatorial optimization problems are of {0, 1}, quantum spins above are represented by {-1, 1},
so we have to transform their representation. wq module can automatically handle them, so you do not have to know about {-1, 1} things.
Learn more about QUBO
---------------------
Let's learn more about QUBO here.
Now there are three boxes labeled :math:`x_{0}, x_{1}, x_{2}` and we think the problem to choose some boxes from them.
First, we define the box's value = 1 when the box is chosen, and value = 0 otherwise.
For example when you choose :math:`x_{0}`, box's values are :math:`x_{0} = 1, x_{1} = 0, x_{2} = 0`.
This can be represented as computer friendly array format [1, 0, 0].
Next, we define the problem we want to solve "choose two from three boxes."
We must think of a function E(x) for the problem, which takes minimum value when the problem is solved.
We use the following function:
.. math::
E(x) = (x_{0} + x_{1} + x_{2} - 2) ^ 2
Let's check the results:
- If you choose :math:`x_{0}` alone, :math:`E(x) = (1 + 0 + 0 - 2) ^ 2 = (-1) ^ 2 = 1`
- If you choose :math:`x_{0}` and :math:`x_{1}`, :math:`E(x) = (1 + 1 + 0 - 2) ^ 2 = (0) ^ 2 = 0`
- If you choose all, :math:`E(x) = (1 + 1 + 1 - 2) ^ 2 = (1) ^ 2 = 1`
The minimum value of E(x) is 0 when you choose two of three, so you can confirm the E(x) above is the appropriate function for solving this problem.
Let's expand this E(x) as the following:
.. math::
E(x) &= (x_{0} + x_{1} + x_{2} - 2) ^ 2 \\
&= (x_{0} + x_{1} + x_{2} - 2) (x_{0} + x_{1} + x_{2} - 2) \\
&= x_{0} ^ 2 + x_{1} ^ 2 + x_{2} ^ 2 + 2 x_{0} x_{1} + 2 x_{0} x_{2} + 2 x_{1} x_{2} - 4 x_{0} - 4 x_{1} - 4 x_{2} + 4
Remember that :math:`x` takes 0 or 1.
So we can use the equation :math:`x = x ^ 2 = x x`. Apply it to E(x).
.. math::
E(x) &= x_{0} ^ 2 + x_{1} ^ 2 + x_{2} ^ 2 + 2 x_{0} x_{1} + 2 x_{0} x_{2} + 2 x_{1} x_{2} - 4 x_{0} - 4 x_{1} - 4 x_{2} + 4 \\
&= x_{0} ^ 2 + x_{1} ^ 2 + x_{2} ^ 2 + 2 x_{0} x_{1} + 2 x_{0} x_{2} + 2 x_{1} x_{2} - 4 x_{0} x_{0} - 4 x_{1} x_{1} - 4 x_{2} x_{2} + 4 \\
&= -3 x_{0} x_{0} −3 x_{1} x_{1} -3 x_{2} x_{2} + 2 x_{0} x_{1} + 2 x_{0} x_{2} + 2 x_{1} x_{2} + 4
Next, we want to convert function E(x) to a matrix which shapes like the following.
.. csv-table::
:header: , :math:`x_{0}`, :math:`x_{1}`, :math:`x_{2}`
:widths: 3, 2, 2, 2
:math:`x_{0}`, , ,
:math:`x_{1}`, , ,
:math:`x_{2}`, , ,
The first term of the last line of E(x) above multiplys :math:`x_{0}` and :math:`x_{0}`, then multiplys the product and -3.
So put -3 in the intersection cell of :math:`x_{0}` and :math:`x_{0}` like this:
.. csv-table::
:header: , :math:`x_{0}`, :math:`x_{1}`, :math:`x_{2}`
:widths: 3, 2, 2, 2
:math:`x_{0}`, -3, ,
:math:`x_{1}`, , ,
:math:`x_{2}`, , ,
For the second and third term, put -3 in the intersection cell of :math:`x_{1}` and :math:`x_{1}`, :math:`x_{2}` and :math:`x_{2}`.
.. csv-table::
:header: , :math:`x_{0}`, :math:`x_{1}`, :math:`x_{2}`
:widths: 3, 2, 2, 2
:math:`x_{0}`, -3, ,
:math:`x_{1}`, ,-3,
:math:`x_{2}`, , , -3
The next term multiplys :math:`x_{0}` and :math:`x_{1}`, then multiplys the product and 2.
So put 2 in the intersection cell of :math:`x_{0}` and :math:`x_{1}`.
.. csv-table::
:header: , :math:`x_{0}`, :math:`x_{1}`, :math:`x_{2}`
:widths: 3, 2, 2, 2
:math:`x_{0}`, -3, 2,
:math:`x_{1}`, ,-3,
:math:`x_{2}`, , , -3
For the next two terms, put 2 in the intersection cell of :math:`x_{0}` and :math:`x_{2}`, :math:`x_{1}` and :math:`x_{2}`.
And we can ignore the last term 4, because it is not affect to find the minimum value of E(x) with the combination of :math:`x_{i}`.
As a result of the steps above, the matrix is finally the following shape. This is the QUBO to solve "choose two from three boxes."
.. csv-table::
:header: , :math:`x_{0}`, :math:`x_{1}`, :math:`x_{2}`
:widths: 3, 2, 2, 2
:math:`x_{0}`, -3, 2, 2
:math:`x_{1}`, ,-3, 2
:math:`x_{2}`, , , -3
Use Simulated Annealing of wq module to solve this problem:
.. code-block:: python
import blueqat.wq as wq
a = wq.Opt()
a.qubo = [[-3,2,2], [0,-3,2], [0,0,-3]]
answer = a.sa()
print(answer)
Run the program and you will get the result [1, 1, 0]. This means :math:`x_{0}, x_{1}` are chosen.
You will find the problem is solved correctly.
Steps to solve the QUBO problem is:
1. Define E(x) that takes minimum value when the problem is solved.
2. Convert E(x) to QUBO matrix.
3. Supply the QUBO matrix to wq module and solve the problem with Simulated Annealing (SA).
The most difficult step is 1., but you can find many useful examples in our :doc:`../tutorial`.
Define the row number of QUBO matrix as :math:`i` and the column number as :math:`j`, and each cell value as :math:`Q_{ij}`.
So the E(x) can be represented as:
.. math::
E(x) = \sum_{i} \sum_{j} Q_{ij} x_{i} x_{j}
Actually this :math:`Q_{ij}` is QUBO. You can find the last equation calculating E(x) above shapes this form.
See also `Wikipedia <https://en.wikipedia.org/wiki/Quadratic_unconstrained_binary_optimization>`_.
| {
"pile_set_name": "Github"
} |
/* This is free and unencumbered software released into the public domain. */
#ifndef _STDALIGN_H
#define _STDALIGN_H
/**
* @file
*
* <stdalign.h> - C11 7.15: Alignment.
*
* @see http://libc11.org/stdalign/
*/
#if __STDC_VERSION__ < 201112L
#define _Alignas
#define _Alignof
#endif
#define alignas _Alignas
#define alignof _Alignof
#define __alignas_is_defined 1
#define __alignof_is_defined 1
#endif /* _STDALIGN_H */
| {
"pile_set_name": "Github"
} |
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
| {
"pile_set_name": "Github"
} |
// Copyright © 2020 Banzai Cloud
//
// 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 output_test
import (
"testing"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/output"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/render"
"github.com/ghodss/yaml"
)
func TestFormatSingleValueConfig(t *testing.T) {
CONFIG := []byte(`
path: /tmp/logs/${tag}/%Y/%m/%d.%H.%M
format:
type: single_value
add_newline: true
message_key: msg
`)
expected := `
<match **>
@type file
@id test
add_path_suffix true
path /tmp/logs/${tag}/%Y/%m/%d.%H.%M
<format>
@type single_value
add_newline true
message_key msg
</format>
</match>
`
f := &output.FileOutputConfig{}
yaml.Unmarshal(CONFIG, f)
test := render.NewOutputPluginTest(t, f)
test.DiffResult(expected)
}
| {
"pile_set_name": "Github"
} |
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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.elasticsearch.test.rest.yaml;
import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.DeprecationHandler;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.XContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Holds an object and allows to extract specific values from it given their path
*/
public class ObjectPath {
private final Object object;
public static ObjectPath createFromResponse(Response response) throws IOException {
byte[] bytes = EntityUtils.toByteArray(response.getEntity());
String contentType = response.getHeader("Content-Type");
XContentType xContentType = XContentType.fromMediaTypeOrFormat(contentType);
return ObjectPath.createFromXContent(xContentType.xContent(), new BytesArray(bytes));
}
public static ObjectPath createFromXContent(XContent xContent, BytesReference input) throws IOException {
try (XContentParser parser = xContent
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, input.streamInput())) {
if (parser.nextToken() == XContentParser.Token.START_ARRAY) {
return new ObjectPath(parser.listOrderedMap());
}
return new ObjectPath(parser.mapOrdered());
}
}
public ObjectPath(Object object) {
this.object = object;
}
/**
* A utility method that creates an {@link ObjectPath} via {@link #ObjectPath(Object)} returns
* the result of calling {@link #evaluate(String)} on it.
*/
public static <T> T evaluate(Object object, String path) throws IOException {
return new ObjectPath(object).evaluate(path, Stash.EMPTY);
}
/**
* Returns the object corresponding to the provided path if present, null otherwise
*/
public <T> T evaluate(String path) throws IOException {
return evaluate(path, Stash.EMPTY);
}
/**
* Returns the object corresponding to the provided path if present, null otherwise
*/
@SuppressWarnings("unchecked")
public <T> T evaluate(String path, Stash stash) throws IOException {
String[] parts = parsePath(path);
Object object = this.object;
for (String part : parts) {
object = evaluate(part, object, stash);
if (object == null) {
return null;
}
}
return (T)object;
}
@SuppressWarnings("unchecked")
private Object evaluate(String key, Object object, Stash stash) throws IOException {
if (stash.containsStashedValue(key)) {
key = stash.getValue(key).toString();
}
if (object instanceof Map) {
return ((Map<String, Object>) object).get(key);
}
if (object instanceof List) {
List<Object> list = (List<Object>) object;
try {
return list.get(Integer.valueOf(key));
} catch (NumberFormatException e) {
throw new IllegalArgumentException("element was a list, but [" + key + "] was not numeric", e);
} catch (IndexOutOfBoundsException e) {
throw new IllegalArgumentException("element was a list with " + list.size() +
" elements, but [" + key + "] was out of bounds", e);
}
}
throw new IllegalArgumentException("no object found for [" + key + "] within object of class [" + object.getClass() + "]");
}
private String[] parsePath(String path) {
List<String> list = new ArrayList<>();
StringBuilder current = new StringBuilder();
boolean escape = false;
for (int i = 0; i < path.length(); i++) {
char c = path.charAt(i);
if (c == '\\') {
escape = true;
continue;
}
if (c == '.') {
if (escape) {
escape = false;
} else {
if (current.length() > 0) {
list.add(current.toString());
current.setLength(0);
}
continue;
}
}
current.append(c);
}
if (current.length() > 0) {
list.add(current.toString());
}
return list.toArray(new String[list.size()]);
}
/**
* Create a new {@link XContentBuilder} from the xContent object underlying this {@link ObjectPath}.
* This only works for {@link ObjectPath} instances created from an xContent object, not from nested
* substructures. We throw an {@link UnsupportedOperationException} in those cases.
*/
@SuppressWarnings("unchecked")
public XContentBuilder toXContentBuilder(XContent xContent) throws IOException {
XContentBuilder builder = XContentBuilder.builder(xContent);
if (this.object instanceof Map) {
builder.map((Map<String, Object>) this.object);
} else {
throw new UnsupportedOperationException("Only ObjectPath created from a map supported.");
}
return builder;
}
}
| {
"pile_set_name": "Github"
} |
/*
* Kontalk Android client
* Copyright (C) 2020 Kontalk Devteam <[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 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/>.
*/
package org.kontalk.message;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.util.XmppStringUtils;
import android.content.AsyncQueryHandler;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import org.kontalk.BuildConfig;
import org.kontalk.Log;
import org.kontalk.client.GroupExtension;
import org.kontalk.data.GroupInfo;
import org.kontalk.provider.MessagesProviderClient;
import org.kontalk.provider.MyMessages;
import org.kontalk.provider.MyMessages.Groups;
import org.kontalk.provider.MyMessages.Messages;
import org.kontalk.provider.MyMessages.Threads.Conversations;
import org.kontalk.util.MediaStorage;
import org.kontalk.util.MessageUtils;
/**
* A composite message, made up of one or more {@link MessageComponent}.
* TODO make it a {@link Parcelable}
* @author Daniele Ricci
* @version 1.0
*/
public class CompositeMessage {
private static final String TAG = CompositeMessage.class.getSimpleName();
@SuppressWarnings("unchecked")
private static final Class<AttachmentComponent>[] TRY_COMPONENTS = new Class[] {
ImageComponent.class,
AudioComponent.class,
VCardComponent.class,
LocationComponent.class,
};
private static final String[] MESSAGE_LIST_PROJECTION = {
Messages._ID,
Messages.MESSAGE_ID,
Messages.PEER,
Messages.DIRECTION,
Messages.TIMESTAMP,
Messages.SERVER_TIMESTAMP,
Messages.STATUS_CHANGED,
Messages.STATUS,
Messages.ENCRYPTED,
Messages.SECURITY_FLAGS,
Messages.BODY_MIME,
Messages.BODY_CONTENT,
Messages.BODY_LENGTH,
Messages.ATTACHMENT_MIME,
Messages.ATTACHMENT_PREVIEW_PATH,
Messages.ATTACHMENT_LOCAL_URI,
Messages.ATTACHMENT_FETCH_URL,
Messages.ATTACHMENT_LENGTH,
Messages.ATTACHMENT_ENCRYPTED,
Messages.ATTACHMENT_SECURITY_FLAGS,
Messages.GEO_LATITUDE,
Messages.GEO_LONGITUDE,
Messages.GEO_TEXT,
Messages.GEO_STREET,
Messages.IN_REPLY_TO,
Groups.GROUP_JID,
Groups.SUBJECT,
Groups.GROUP_TYPE,
Groups.MEMBERSHIP,
};
// these indexes matches MESSAGE_LIST_PROJECTION
public static final int COLUMN_ID = 0;
public static final int COLUMN_MESSAGE_ID = 1;
public static final int COLUMN_PEER = 2;
public static final int COLUMN_DIRECTION = 3;
public static final int COLUMN_TIMESTAMP = 4;
public static final int COLUMN_SERVER_TIMESTAMP = 5;
public static final int COLUMN_STATUS_CHANGED = 6;
public static final int COLUMN_STATUS = 7;
public static final int COLUMN_ENCRYPTED = 8;
public static final int COLUMN_SECURITY = 9;
public static final int COLUMN_BODY_MIME = 10;
public static final int COLUMN_BODY_CONTENT = 11;
public static final int COLUMN_BODY_LENGTH = 12;
public static final int COLUMN_ATTACHMENT_MIME = 13;
public static final int COLUMN_ATTACHMENT_PREVIEW_PATH = 14;
public static final int COLUMN_ATTACHMENT_LOCAL_URI = 15;
public static final int COLUMN_ATTACHMENT_FETCH_URL = 16;
public static final int COLUMN_ATTACHMENT_LENGTH = 17;
public static final int COLUMN_ATTACHMENT_ENCRYPTED = 18;
public static final int COLUMN_ATTACHMENT_SECURITY_FLAGS = 19;
public static final int COLUMN_GEO_LATITUDE = 20;
public static final int COLUMN_GEO_LONGITUDE = 21;
public static final int COLUMN_GEO_TEXT = 22;
public static final int COLUMN_GEO_STREET = 23;
public static final int COLUMN_IN_REPLY_TO = 24;
public static final int COLUMN_GROUP_JID = 25;
public static final int COLUMN_GROUP_SUBJECT = 26;
public static final int COLUMN_GROUP_TYPE = 27;
public static final int COLUMN_GROUP_MEMBERSHIP = 28;
private static final int SUFFIX_LENGTH = "Component".length();
protected Context mContext;
protected long mDatabaseId;
protected String mId;
protected String mSender;
protected long mTimestamp;
protected long mServerTimestamp;
protected long mStatusChanged;
protected int mStatus;
protected boolean mEncrypted;
protected int mSecurityFlags;
protected long mInReplyTo;
/** Recipient (outgoing) */
protected String mRecipient;
/** Message components. */
protected List<MessageComponent<?>> mComponents;
/** Creates a new composite message. */
public CompositeMessage(Context context, String id, long timestamp, String sender, boolean encrypted, int securityFlags) {
this(context);
mId = id;
mSender = sender;
// will be updated if necessary
mTimestamp = System.currentTimeMillis();
mServerTimestamp = timestamp;
mEncrypted = encrypted;
mSecurityFlags = securityFlags;
}
/** Empty constructor for local use. */
private CompositeMessage(Context context) {
mContext = context;
mComponents = new ArrayList<>();
}
public String getId() {
return mId;
}
public void setId(String id) {
mId = id;
}
public String getPeer() {
if (isIncoming()) {
return getSender(true);
}
else {
return getRecipient(true);
}
}
public String getSender(boolean generic) {
return generic && XmppStringUtils.isFullJID(mSender) ?
XmppStringUtils.parseBareJid(mSender) : mSender;
}
public String getSender() {
return getSender(false);
}
public String getRecipient(boolean generic) {
return generic && XmppStringUtils.isFullJID(mRecipient) ?
XmppStringUtils.parseBareJid(mRecipient) : mRecipient;
}
public String getRecipient() {
return getRecipient(false);
}
public long getTimestamp() {
return mTimestamp;
}
public void setTimestamp(long timestamp) {
mTimestamp = timestamp;
}
public long getStatusChanged() {
return mStatusChanged;
}
public void setStatusChanged(long statusChanged) {
mStatusChanged = statusChanged;
}
public long getServerTimestamp() {
return mServerTimestamp;
}
// for internal use only.
public void setStatus(int status) {
mStatus = status;
}
public int getStatus() {
return mStatus;
}
/** Generates a text content for this message. Useful for exporting a message to a text stream. */
public String toTextContent() {
// loop until the first known component is found
for (MessageComponent<?> cmp : mComponents) {
if (cmp instanceof TextComponent) {
return ((TextComponent) cmp).getContent();
}
else if (cmp instanceof AttachmentComponent) {
return getSampleTextContent(((AttachmentComponent) cmp).getMime());
}
}
return null;
}
@Override
public String toString() {
// FIXME include components
return getClass().getSimpleName() + ": id=" + mId;
}
public int getDirection() {
return (mSender != null) ?
Messages.DIRECTION_IN : Messages.DIRECTION_OUT;
}
public boolean isIncoming() {
return getDirection() == Messages.DIRECTION_IN;
}
public boolean isOutgoing() {
return getDirection() == Messages.DIRECTION_OUT;
}
public void setDatabaseId(long databaseId) {
mDatabaseId = databaseId;
}
public long getDatabaseId() {
return mDatabaseId;
}
public boolean isEncrypted() {
return mEncrypted;
}
public void setEncrypted(boolean encrypted) {
mEncrypted = encrypted;
}
public int getSecurityFlags() {
return mSecurityFlags;
}
public void setSecurityFlags(int flags) {
mSecurityFlags = flags;
}
public void addComponent(MessageComponent<?> c) {
mComponents.add(c);
}
public void clearComponents() {
mComponents.clear();
}
public <T extends MessageComponent<?>> boolean hasComponent(Class<T> type) {
return getComponent(type) != null;
}
/** Returns the first component of the given type. */
@SuppressWarnings("unchecked")
public <T extends MessageComponent<?>> T getComponent(Class<T> type) {
for (MessageComponent<?> cmp : mComponents) {
if (type.isInstance(cmp))
return (T) cmp;
}
return null;
}
public List<MessageComponent<?>> getComponents() {
return mComponents;
}
private void populateFromCursor(Cursor c) {
// be sure to stick to our projection array
mDatabaseId = c.getLong(COLUMN_ID);
mId = c.getString(COLUMN_MESSAGE_ID);
mTimestamp = c.getLong(COLUMN_TIMESTAMP);
mStatusChanged = c.getLong(COLUMN_STATUS_CHANGED);
mStatus = c.getInt(COLUMN_STATUS);
mRecipient = null;
mEncrypted = (c.getShort(COLUMN_ENCRYPTED) > 0);
mSecurityFlags = c.getInt(COLUMN_SECURITY);
mServerTimestamp = c.getLong(COLUMN_SERVER_TIMESTAMP);
mInReplyTo = c.getLong(COLUMN_IN_REPLY_TO);
String peer = c.getString(COLUMN_PEER);
int direction = c.getInt(COLUMN_DIRECTION);
if (direction == Messages.DIRECTION_OUT) {
// we are the origin
mSender = null;
mRecipient = peer;
}
else {
mSender = peer;
// we are the origin - no recipient
}
byte[] body = c.getBlob(COLUMN_BODY_CONTENT);
// encrypted message - single raw encrypted component
if (mEncrypted) {
RawComponent raw = new RawComponent(body, true, mSecurityFlags);
addComponent(raw);
}
else {
String mime = c.getString(COLUMN_BODY_MIME);
String groupJidStr = c.getString(COLUMN_GROUP_JID);
String groupSubject = c.getString(COLUMN_GROUP_SUBJECT);
String groupType = c.getString(COLUMN_GROUP_TYPE);
int groupMembership = c.getInt(COLUMN_GROUP_MEMBERSHIP);
Jid groupJid = groupJidStr != null ?
JidCreate.fromOrThrowUnchecked(groupJidStr) : null;
if (body != null) {
// remove trailing zero
String bodyText = MessageUtils.toString(body);
// text data
if (TextComponent.supportsMimeType(mime)) {
TextComponent txt = new TextComponent(bodyText);
addComponent(txt);
}
else if (LocationComponent.supportsMimeType(mime)) {
double lat = c.getDouble(COLUMN_GEO_LATITUDE);
double lon = c.getDouble(COLUMN_GEO_LONGITUDE);
String text = c.getString(COLUMN_GEO_TEXT);
String street = c.getString(COLUMN_GEO_STREET);
// send text along
if (bodyText.length() > 0) {
addComponent(new HiddenTextComponent(bodyText));
}
LocationComponent location = new LocationComponent(lat, lon, text, street);
addComponent(location);
}
// group command
else if (GroupCommandComponent.supportsMimeType(mime)) {
if (groupJid == null) {
// impossible
throw new IllegalStateException("Trying to parse a group command without a group!?");
}
String groupId = groupJid.getLocalpartOrNull().toString();
Jid groupOwner = JidCreate.fromOrThrowUnchecked(groupJid.getDomain());
GroupExtension ext = null;
String subject;
String[] createMembers;
if ((createMembers = GroupCommandComponent.getCreateCommandMembers(bodyText)) != null) {
ext = new GroupExtension(groupId, groupOwner, GroupExtension.Type.CREATE,
groupSubject, GroupCommandComponent.membersFromJIDs(createMembers));
}
else if (GroupCommandComponent.COMMAND_PART.equals(bodyText)) {
ext = new GroupExtension(groupId, groupOwner, GroupExtension.Type.PART);
}
else if ((subject = GroupCommandComponent.getSubjectCommand(bodyText)) != null) {
ext = new GroupExtension(groupId, groupOwner, GroupExtension.Type.SET, subject);
}
else {
String[] addMembers = GroupCommandComponent.getAddCommandMembers(bodyText);
String[] removeMembers = GroupCommandComponent.getRemoveCommandMembers(bodyText);
if (addMembers != null || removeMembers != null) {
ext = new GroupExtension(groupId, groupOwner, GroupExtension.Type.SET,
groupSubject, GroupCommandComponent
// TODO what about existing members here?
.membersFromJIDs(null, addMembers, removeMembers));
}
}
if (ext != null)
addComponent(new GroupCommandComponent(ext, peer));
}
// unknown data
else {
RawComponent raw = new RawComponent(body, false, mSecurityFlags);
addComponent(raw);
}
}
// attachment
String attMime = c.getString(COLUMN_ATTACHMENT_MIME);
if (attMime != null) {
String attPreview = c.getString(COLUMN_ATTACHMENT_PREVIEW_PATH);
String attLocal = c.getString(COLUMN_ATTACHMENT_LOCAL_URI);
String attFetch = c.getString(COLUMN_ATTACHMENT_FETCH_URL);
long attLength = c.getLong(COLUMN_ATTACHMENT_LENGTH);
boolean attEncrypted = c.getInt(COLUMN_ATTACHMENT_ENCRYPTED) > 0;
int attSecurityFlags = c.getInt(COLUMN_ATTACHMENT_SECURITY_FLAGS);
AttachmentComponent att;
File previewFile = (attPreview != null) ? new File(attPreview) : null;
Uri localUri = (attLocal != null) ? Uri.parse(attLocal) : null;
if (ImageComponent.supportsMimeType(attMime)) {
att = new ImageComponent(attMime, previewFile,
localUri, attFetch, attLength,
attEncrypted, attSecurityFlags);
}
else if (VCardComponent.supportsMimeType(attMime)) {
att = new VCardComponent(previewFile,
localUri, attFetch, attLength,
attEncrypted, attSecurityFlags);
}
else if (AudioComponent.supportsMimeType(attMime)) {
att = new AudioComponent(attMime,
localUri, attFetch,
attLength, attEncrypted, attSecurityFlags);
}
else {
att = new DefaultAttachmentComponent(attMime,
localUri, attFetch,
attLength, attEncrypted, attSecurityFlags);
}
// TODO other type of attachments
att.populateFromCursor(mContext, c);
addComponent(att);
}
// in reply to
long inReplyToId = c.getLong(COLUMN_IN_REPLY_TO);
if (inReplyToId > 0) {
// load the referenced message
ReferencedMessage referencedMsg = ReferencedMessage.load(mContext, inReplyToId);
// a null message is allowed, meaning that it was not found
addComponent(new InReplyToComponent(referencedMsg));
}
// group information
if (groupJid != null) {
GroupInfo groupInfo = new GroupInfo(groupJid,
groupSubject, groupType, groupMembership);
addComponent(new GroupComponent(groupInfo));
}
}
}
/** Clears all local fields for recycle. */
protected void clear() {
// clear all fields
mContext = null;
mDatabaseId = 0;
mId = null;
mSender = null;
mTimestamp = 0;
mServerTimestamp = 0;
mStatusChanged = 0;
mStatus = 0;
mEncrypted = false;
mSecurityFlags = 0;
mInReplyTo = 0;
clearComponents();
}
/** Builds an instance from a {@link Cursor} row. */
public static CompositeMessage fromCursor(Context context, Cursor cursor) {
CompositeMessage msg = new CompositeMessage(context);
msg.populateFromCursor(cursor);
// TODO
return msg;
}
/** Holder for message delete information. */
public static final class DeleteMessageHolder {
long id;
File[] mediaFiles;
public DeleteMessageHolder(Cursor cursor) {
id = cursor.getLong(COLUMN_ID);
String filePath = cursor.getString(COLUMN_ATTACHMENT_LOCAL_URI);
if (filePath != null) {
Uri fileUri = Uri.parse(filePath);
if ("file".equals(fileUri.getScheme())) {
mediaFiles = new File[] { new File(fileUri.getPath()) };
}
}
}
}
@SuppressWarnings("ResultOfMethodCallIgnored")
public static void deleteMessage(Context context, DeleteMessageHolder holder) {
MessagesProviderClient.deleteMessage(context, holder.id);
if (holder.mediaFiles != null) {
// try to delete the original files, ignoring result
for (File media : holder.mediaFiles) {
try {
media.delete();
}
catch (Exception e) {
Log.v(TAG, "unable to delete original media: " + media);
}
}
}
}
public static CompositeMessage loadMessage(Context context, long id) {
Cursor c = context.getContentResolver().query(ContentUris
.withAppendedId(MyMessages.Messages.CONTENT_URI, id),
MESSAGE_LIST_PROJECTION, null, null, null);
try {
if (c.moveToFirst()) {
return fromCursor(context, c);
}
return null;
}
finally {
c.close();
}
}
public static void startQuery(AsyncQueryHandler handler, int token, long threadId, long count, long lastId) {
Uri.Builder builder = ContentUris.withAppendedId(Conversations.CONTENT_URI, threadId)
.buildUpon()
.appendQueryParameter("count", String.valueOf(count));
if (lastId > 0) {
builder.appendQueryParameter("last", String.valueOf(lastId));
}
// cancel previous operations
handler.cancelOperation(token);
handler.startQuery(token, lastId > 0 ? "append" : null, builder.build(),
MESSAGE_LIST_PROJECTION, null, null, Messages.DEFAULT_SORT_ORDER);
}
/** A sample text content from class name and mime type. */
public static String getSampleTextContent(String mime) {
Class<AttachmentComponent> klass = getSupportingComponent(mime);
if (klass != null) {
String cname = klass.getSimpleName();
String text = cname.substring(0, cname.length() - SUFFIX_LENGTH);
return BuildConfig.DEBUG ? (text + ": " + mime) : text;
}
// no supporting component - return mime
// TODO i18n
String text = "Unknown";
return BuildConfig.DEBUG ? (text + ": " + mime) : text;
}
private static Class<AttachmentComponent> getSupportingComponent(String mime) {
// FIXME using reflection BAD BAD BAD !!!
for (Class<AttachmentComponent> klass : TRY_COMPONENTS) {
Boolean supported = null;
try {
Method m = klass.getMethod("supportsMimeType", String.class);
supported = (Boolean) m.invoke(klass, mime);
}
catch (Exception e) {
// ignored
}
if (supported != null && supported) {
return klass;
}
}
return null;
}
/**
* Returns a correct file object for an incoming message.
* @param mime MIME type of the incoming attachment
* @param timestamp timestamp of the message
*/
public static File getIncomingFile(Context context, String mime, @NonNull Date timestamp) {
if (mime != null) {
if (ImageComponent.supportsMimeType(mime)) {
String ext = ImageComponent.getFileExtension(mime);
return MediaStorage.getIncomingImageFile(context, timestamp, ext);
}
else if (AudioComponent.supportsMimeType(mime)) {
String ext = AudioComponent.getFileExtension(mime);
return MediaStorage.getIncomingAudioFile(context, timestamp, ext);
}
// TODO maybe other file types?
}
return null;
}
/**
* Returns a correct file name for the given MIME.
* @param mime MIME type of the incoming attachment
* @param timestamp timestamp of the message
*/
public static String getFilename(String mime, @NonNull Date timestamp) {
if (ImageComponent.supportsMimeType(mime)) {
String ext = ImageComponent.getFileExtension(mime);
return MediaStorage.getOutgoingPictureFilename(timestamp, ext);
}
else if (AudioComponent.supportsMimeType(mime)) {
String ext = AudioComponent.getFileExtension(mime);
return MediaStorage.getOutgoingAudioFilename(timestamp, ext);
}
return null;
}
/* Still unused.
public static void startQuery(AsyncQueryHandler handler, int token, String peer) {
// cancel previous operations
handler.cancelOperation(token);
handler.startQuery(token, null, Messages.CONTENT_URI,
MESSAGE_LIST_PROJECTION, "peer = ?", new String[] { peer },
Messages.DEFAULT_SORT_ORDER);
}
*/
}
| {
"pile_set_name": "Github"
} |
---
layout: example
title: Wheat and Wages Example
permalink: /examples/wheat-and-wages/index.html
spec: wheat-and-wages
image: /examples/img/wheat-and-wages.png
---
A recreation of [William Playfair's](https://en.wikipedia.org/wiki/William_Playfair) classic chart visualizing the price of wheat, the wages of a mechanic, and the reigning British monarch.
{% include example spec=page.spec %}
| {
"pile_set_name": "Github"
} |
config BR2_PACKAGE_NVIDIA_TEGRA23_BINARIES
bool "nvidia-tegra23 binaries"
select BR2_PACKAGE_MESA3D_HEADERS
select BR2_PACKAGE_XLIB_LIBX11
select BR2_PACKAGE_XLIB_LIBXEXT
select BR2_PACKAGE_HAS_LIBEGL
select BR2_PACKAGE_HAS_LIBGLES
select BR2_PACKAGE_HAS_LIBOPENMAX
help
Those packages provide libraries, drivers and firmware that
comes from NVIDIA Linux For Tegra.
https://developer.nvidia.com/linux-tegra
if BR2_PACKAGE_NVIDIA_TEGRA23_BINARIES
config BR2_PACKAGE_PROVIDES_LIBEGL
default "nvidia-tegra23-binaries"
config BR2_PACKAGE_PROVIDES_LIBGLES
default "nvidia-tegra23-binaries"
config BR2_PACKAGE_PROVIDES_LIBOPENMAX
default "nvidia-tegra23-binaries"
config BR2_PACKAGE_NVIDIA_TEGRA23_BINARIES_GSTREAMER_PLUGINS
bool "GStreamer 0.10.x plugins"
depends on BR2_PACKAGE_GSTREAMER # Run-time only
select BR2_PACKAGE_XLIB_LIBXV
help
GStreamer 0.10.x plugins
config BR2_PACKAGE_NVIDIA_TEGRA23_BINARIES_NV_SAMPLE_APPS
bool "NVIDIA multimedia sample apps"
depends on BR2_PACKAGE_NVIDIA_TEGRA23_BINARIES_GSTREAMER_PLUGINS
help
nvgstplayer and nvgstcapture multimedia test applications.
comment "GStreamer 0.10.x plugins need GStreamer 0.10"
depends on !BR2_PACKAGE_GSTREAMER
endif
| {
"pile_set_name": "Github"
} |
// Tencent is pleased to support the open source community by making ncnn available.
//
// Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
//
// https://opensource.org/licenses/BSD-3-Clause
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
#include <arm_neon.h>
// tanh neon vector version
// refer the scalar version from Cephes Math Library
#define c_cephes_HALFMAXLOGF 44.014845935754205f
#define c_cephes_tanh_C1 0.625f
#define c_cephes_tanh_p0 -5.70498872745E-3
#define c_cephes_tanh_p1 +2.06390887954E-2
#define c_cephes_tanh_p2 -5.37397155531E-2
#define c_cephes_tanh_p3 +1.33314422036E-1
#define c_cephes_tanh_p4 -3.33332819422E-1
/* Single precision hyperbolic tangent computed for 4 simultaneous float */
static inline float32x4_t tanh_ps(float32x4_t x)
{
float32x4_t x2 = vabsq_f32(x);
uint32x4_t mask_l = vcgeq_f32(x2, vdupq_n_f32(c_cephes_tanh_C1));
uint32x4_t mask_l2 = vcgtq_f32(x2, vdupq_n_f32(c_cephes_HALFMAXLOGF));
// abs(x) >= 0.625
// tanh(x) = 1 − 2 / (exp(2x) + 1)
float32x4_t _one = vdupq_n_f32(1.f);
float32x4_t _two = vdupq_n_f32(2.f);
float32x4_t exp_x_x = exp_ps(vaddq_f32(x, x));
#if __aarch64__
float32x4_t y0 = vsubq_f32(_one, vdivq_f32(_two, vaddq_f32(exp_x_x, _one)));
#else
float32x4_t y0 = vsubq_f32(_one, div_ps(_two, vaddq_f32(exp_x_x, _one)));
#endif
// abs(x) < 0.625
/*
z = x2 * x2;
z =
(((( -5.70498872745E-3 * z
+ 2.06390887954E-2) * z
- 5.37397155531E-2) * z
+ 1.33314422036E-1) * z
- 3.33332819422E-1) * z * x
+ x;
*/
static const float cephes_tanh_p[5] = {c_cephes_tanh_p0, c_cephes_tanh_p1, c_cephes_tanh_p2, c_cephes_tanh_p3, c_cephes_tanh_p4};
float32x4_t y = vld1q_dup_f32(cephes_tanh_p + 0);
float32x4_t c1 = vld1q_dup_f32(cephes_tanh_p + 1);
float32x4_t c2 = vld1q_dup_f32(cephes_tanh_p + 2);
float32x4_t c3 = vld1q_dup_f32(cephes_tanh_p + 3);
float32x4_t c4 = vld1q_dup_f32(cephes_tanh_p + 4);
float32x4_t z = vmulq_f32(x, x);
y = vmulq_f32(y, z);
y = vaddq_f32(y, c1);
y = vmulq_f32(y, z);
y = vaddq_f32(y, c2);
y = vmulq_f32(y, z);
y = vaddq_f32(y, c3);
y = vmulq_f32(y, z);
y = vaddq_f32(y, c4);
y = vmulq_f32(y, z);
y = vmulq_f32(y, x);
y = vaddq_f32(y, x);
// abs(x) > HALFMAXLOGF
// return 1.0 or -1.0
uint32x4_t mask_pos = vcgtq_f32(x2, vdupq_n_f32(0.f));
float32x4_t y1 = vreinterpretq_f32_u32(vbslq_u32(mask_pos, vreinterpretq_u32_f32(vdupq_n_f32(1.f)), vreinterpretq_u32_f32(vdupq_n_f32(-1.f))));
y = vreinterpretq_f32_u32(vbslq_u32(mask_l, vreinterpretq_u32_f32(y0), vreinterpretq_u32_f32(y)));
y = vreinterpretq_f32_u32(vbslq_u32(mask_l2, vreinterpretq_u32_f32(y1), vreinterpretq_u32_f32(y)));
return y;
}
| {
"pile_set_name": "Github"
} |
#
# foobar
=begin
foo bar baz
=end
=begin
=end
#{comment}
----------------------------------------------------
[
["comment", "#"],
["comment", "# foobar"],
["comment", "=begin\r\nfoo bar baz\r\n=end"],
["comment", "=begin\r\n=end"],
["comment", "#{comment}"]
]
----------------------------------------------------
Checks for comments. | {
"pile_set_name": "Github"
} |
/**
* This code is released under the
* Apache License Version 2.0 http://www.apache.org/licenses/.
*
*/
#include "common.h"
#include "util.h"
#include "timer.h"
#include "bitpackinghelpers.h"
#include "simdbitpackinghelpers.h"
#include "delta.h"
#include "synthetic.h"
using namespace std;
using namespace SIMDCompressionLib;
vector<uint32_t> maskedcopy(const vector<uint32_t> &in, const uint32_t bit) {
vector<uint32_t> out(in);
if (bit == 32)
return out;
for (auto i = out.begin(); i != out.end(); ++i) {
*i = *i % (1U << bit);
}
return out;
}
template <class container32bit>
bool equalOnFirstBits(const container32bit &data,
const container32bit &recovered, uint32_t bit) {
if (bit == 32) {
return data == recovered;
}
for (uint32_t k = 0; k < data.size(); ++k) {
if (data[k] % (1U << bit) != recovered[k] % (1U << bit)) {
cout << " They differ at k = " << k << " data[k]= " << data[k]
<< " recovered[k]=" << recovered[k] << endl;
return false;
}
}
return true;
}
uint32_t mask(uint32_t bit) {
if (bit == 32)
return 0xFFFFFFFFU;
return (1U << bit) - 1;
}
template <class Helper>
void simplebenchmark(uint32_t N = 1U << 16, uint32_t T = 1U << 9) {
T = T + 1; // we have a warming up pass
uint32_t bogus = 0;
vector<uint32_t> data(N);
vector<uint32_t> compressed(N);
vector<uint32_t> icompressed(N);
vector<uint32_t> recovered(N);
WallClockTimer z;
double unpacktime;
double iunpacktime;
cout << "#million of integers per second: higher is better" << endl;
cout << "#bit, unpack,iunpack" << endl;
for (uint32_t bitindex = 0; bitindex < 32; ++bitindex) {
uint32_t bit = bitindex + 1;
vector<uint32_t> initdata(N);
for (size_t i = 0; 4 * i < data.size(); i += 4) {
initdata[i] = random(bit) + (i >= 4 ? initdata[i - 4] : 0);
for (size_t j = 1; j < 4; ++j) {
initdata[i + j] = initdata[i];
}
}
const vector<uint32_t> refdata = initdata;
vector<uint32_t>().swap(initdata);
icompressed.clear();
// 4 * N should be enough for all schemes
icompressed.resize(4 * N, 0);
compressed.clear();
// 4 * N should be enough for all schemes
compressed.resize(4 * N, 0);
recovered.clear();
recovered.resize(N, 0);
if (needPaddingTo128Bits(recovered.data())) {
throw logic_error("Array is not aligned on 128 bit boundary!");
}
if (needPaddingTo128Bits(icompressed.data())) {
throw logic_error("Array is not aligned on 128 bit boundary!");
}
if (needPaddingTo128Bits(compressed.data())) {
throw logic_error("Array is not aligned on 128 bit boundary!");
}
if (needPaddingTo128Bits(refdata.data())) {
throw logic_error("Array is not aligned on 128 bit boundary!");
}
for (uint32_t repeat = 0; repeat < 1; ++repeat) {
unpacktime = 0;
iunpacktime = 0;
for (uint32_t t = 0; t <= T; ++t) {
assert(data.size() == refdata.size());
fill(icompressed.begin(), icompressed.end(), 0);
fill(recovered.begin(), recovered.end(), 0);
memcpy(data.data(), refdata.data(),
data.size() * sizeof(uint32_t)); // memcpy can be slow
Helper::pack(data.data(), data.size(), icompressed.data(), bit);
z.reset();
Helper::unpack(icompressed.data(), refdata.size(), recovered.data(),
bit);
if (t > 0) // we don't count the first run
unpacktime += static_cast<double>(z.split());
if (!equalOnFirstBits(refdata, recovered, bit)) {
cout << " Bug 1a " << bit << endl;
return;
}
memcpy(data.data(), refdata.data(),
data.size() * sizeof(uint32_t)); // memcpy can be slow
Helper::pack(data.data(), data.size(), icompressed.data(), bit);
z.reset();
Helper::iunpack(icompressed.data(), refdata.size(), recovered.data(),
bit);
if (t > 0) // we don't count the first run
iunpacktime += static_cast<double>(z.split());
if (!equalOnFirstBits(refdata, recovered, bit)) {
cout << " Bug 2 " << bit << endl;
return;
}
}
cout << std::setprecision(4) << bit << "\t\t";
cout << "\t\t" << N * (T - 1) / (unpacktime) << "\t\t";
cout << "\t\t" << N * (T - 1) / (iunpacktime);
cout << endl;
}
}
cout << "# ignore this " << bogus << endl;
}
int main() {
cout << "# SIMD bit-packing (regular) cache-to-cache 2^12" << endl;
simplebenchmark<SIMDBitPackingHelpers<RegularDeltaSIMD>>(1U << 12, 1U << 14);
cout << endl;
cout << "# SIMD bit-packing (coarse delta 2) cache-to-cache 2^12" << endl;
simplebenchmark<SIMDBitPackingHelpers<CoarseDelta2SIMD>>(1U << 12, 1U << 14);
cout << endl;
cout << "# SIMD bit-packing (coarse max 4) cache-to-cache 2^12" << endl;
simplebenchmark<SIMDBitPackingHelpers<Max4DeltaSIMD>>(1U << 12, 1U << 14);
cout << endl;
cout << "# SIMD bit-packing (coarse delta 4) cache-to-cache 2^12" << endl;
simplebenchmark<SIMDBitPackingHelpers<CoarseDelta4SIMD>>(1U << 12, 1U << 14);
cout << endl;
cout << "# Scalar cache-to-cache 2^12" << endl;
simplebenchmark<BitPackingHelpers>(1U << 12, 1U << 14);
cout << endl;
return 0;
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <arch.h>
#include <asm_macros.S>
#include <assert_macros.S>
#include <platform_def.h>
.local platform_normal_stacks
.weak plat_get_my_stack
.weak plat_set_my_stack
/* ---------------------------------------------------------------------
* When the compatility layer is disabled, the platform APIs
* plat_get_my_stack() and plat_set_my_stack() are supported by the
* platform and the previous APIs platform_get_stack() and
* platform_set_stack() are defined in terms of new APIs making use of
* the fact that they are only ever invoked for the current CPU. This
* is to enable components of Trusted Firmware like SPDs using the old
* platform APIs to continue to work.
* --------------------------------------------------------------------
*/
/* -----------------------------------------------------
* uintptr_t plat_get_my_stack ()
*
* For the current CPU, this function returns the stack
* pointer for a stack allocated in device memory.
* -----------------------------------------------------
*/
func plat_get_my_stack
#if (defined(IMAGE_BL31) && RECLAIM_INIT_CODE)
#if (PLATFORM_CORE_COUNT == 1)
/* Single CPU */
adrp x0, __PRIMARY_STACK__
add x0, x0, :lo12:__PRIMARY_STACK__
ret
#else
mov x10, x30
bl plat_my_core_pos
cbnz x0, 2f
/* Primary CPU */
adrp x0, __PRIMARY_STACK__
add x0, x0, :lo12:__PRIMARY_STACK__
ret x10
/* Secondary CPU */
2: sub x0, x0, #(PLATFORM_CORE_COUNT - 1)
adrp x1, __STACKS_END__
adrp x2, __STACK_SIZE__
add x1, x1, :lo12:__STACKS_END__
add x2, x2, :lo12:__STACK_SIZE__
madd x0, x0, x2, x1
bic x0, x0, #(CACHE_WRITEBACK_GRANULE - 1)
ret x10
#endif
/* Prevent linker from removal of stack section */
.quad platform_normal_stacks
#else /* !(IMAGE_BL31 && RECLAIM_INIT_CODE) */
mov x10, x30
get_my_mp_stack platform_normal_stacks, PLATFORM_STACK_SIZE
ret x10
#endif /* IMAGE_BL31 && RECLAIM_INIT_CODE */
endfunc plat_get_my_stack
/* -----------------------------------------------------
* void plat_set_my_stack ()
*
* For the current CPU, this function sets the stack
* pointer to a stack allocated in normal memory.
* -----------------------------------------------------
*/
func plat_set_my_stack
mov x9, x30
bl plat_get_my_stack
mov sp, x0
ret x9
endfunc plat_set_my_stack
/* -----------------------------------------------------
* Per-CPU stacks in normal memory. Each CPU gets a
* stack of PLATFORM_STACK_SIZE bytes.
* -----------------------------------------------------
*/
declare_stack platform_normal_stacks, tzfw_normal_stacks, \
PLATFORM_STACK_SIZE, PLATFORM_CORE_COUNT, \
CACHE_WRITEBACK_GRANULE
| {
"pile_set_name": "Github"
} |
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
0.10754
| {
"pile_set_name": "Github"
} |
package s3crypto
// Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Portions Licensed under the MIT License. Copyright (c) 2016 Carl Jackson
import (
"bytes"
"crypto/subtle"
"github.com/aws/aws-sdk-go/aws/awserr"
)
const (
pkcs7MaxPaddingSize = 255
)
type pkcs7Padder struct {
blockSize int
}
// NewPKCS7Padder follows the RFC 2315: https://www.ietf.org/rfc/rfc2315.txt
// PKCS7 padding is subject to side-channel attacks and timing attacks. For
// the most secure data, use an authenticated crypto algorithm.
func NewPKCS7Padder(blockSize int) Padder {
return pkcs7Padder{blockSize}
}
var errPKCS7Padding = awserr.New("InvalidPadding", "invalid padding", nil)
// Pad will pad the data relative to how many bytes have been read.
// Pad follows the PKCS7 standard.
func (padder pkcs7Padder) Pad(buf []byte, n int) ([]byte, error) {
if padder.blockSize < 1 || padder.blockSize > pkcs7MaxPaddingSize {
return nil, awserr.New("InvalidBlockSize", "block size must be between 1 and 255", nil)
}
size := padder.blockSize - (n % padder.blockSize)
pad := bytes.Repeat([]byte{byte(size)}, size)
buf = append(buf, pad...)
return buf, nil
}
// Unpad will unpad the correct amount of bytes based off
// of the PKCS7 standard
func (padder pkcs7Padder) Unpad(buf []byte) ([]byte, error) {
if len(buf) == 0 {
return nil, errPKCS7Padding
}
// Here be dragons. We're attempting to check the padding in constant
// time. The only piece of information here which is public is len(buf).
// This code is modeled loosely after tls1_cbc_remove_padding from
// OpenSSL.
padLen := buf[len(buf)-1]
toCheck := pkcs7MaxPaddingSize
good := 1
if toCheck > len(buf) {
toCheck = len(buf)
}
for i := 0; i < toCheck; i++ {
b := buf[len(buf)-1-i]
outOfRange := subtle.ConstantTimeLessOrEq(int(padLen), i)
equal := subtle.ConstantTimeByteEq(padLen, b)
good &= subtle.ConstantTimeSelect(outOfRange, 1, equal)
}
good &= subtle.ConstantTimeLessOrEq(1, int(padLen))
good &= subtle.ConstantTimeLessOrEq(int(padLen), len(buf))
if good != 1 {
return nil, errPKCS7Padding
}
return buf[:len(buf)-int(padLen)], nil
}
func (padder pkcs7Padder) Name() string {
return "PKCS7Padding"
}
| {
"pile_set_name": "Github"
} |
package tarsum // import "github.com/docker/docker/pkg/tarsum"
import (
"archive/tar"
"errors"
"io"
"sort"
"strconv"
"strings"
)
// Version is used for versioning of the TarSum algorithm
// based on the prefix of the hash used
// i.e. "tarsum+sha256:e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b"
type Version int
// Prefix of "tarsum"
const (
Version0 Version = iota
Version1
// VersionDev this constant will be either the latest or an unsettled next-version of the TarSum calculation
VersionDev
)
// WriteV1Header writes a tar header to a writer in V1 tarsum format.
func WriteV1Header(h *tar.Header, w io.Writer) {
for _, elem := range v1TarHeaderSelect(h) {
w.Write([]byte(elem[0] + elem[1]))
}
}
// VersionLabelForChecksum returns the label for the given tarsum
// checksum, i.e., everything before the first `+` character in
// the string or an empty string if no label separator is found.
func VersionLabelForChecksum(checksum string) string {
// Checksums are in the form: {versionLabel}+{hashID}:{hex}
sepIndex := strings.Index(checksum, "+")
if sepIndex < 0 {
return ""
}
return checksum[:sepIndex]
}
// GetVersions gets a list of all known tarsum versions.
func GetVersions() []Version {
v := []Version{}
for k := range tarSumVersions {
v = append(v, k)
}
return v
}
var (
tarSumVersions = map[Version]string{
Version0: "tarsum",
Version1: "tarsum.v1",
VersionDev: "tarsum.dev",
}
tarSumVersionsByName = map[string]Version{
"tarsum": Version0,
"tarsum.v1": Version1,
"tarsum.dev": VersionDev,
}
)
func (tsv Version) String() string {
return tarSumVersions[tsv]
}
// GetVersionFromTarsum returns the Version from the provided string.
func GetVersionFromTarsum(tarsum string) (Version, error) {
tsv := tarsum
if strings.Contains(tarsum, "+") {
tsv = strings.SplitN(tarsum, "+", 2)[0]
}
for v, s := range tarSumVersions {
if s == tsv {
return v, nil
}
}
return -1, ErrNotVersion
}
// Errors that may be returned by functions in this package
var (
ErrNotVersion = errors.New("string does not include a TarSum Version")
ErrVersionNotImplemented = errors.New("TarSum Version is not yet implemented")
)
// tarHeaderSelector is the interface which different versions
// of tarsum should use for selecting and ordering tar headers
// for each item in the archive.
type tarHeaderSelector interface {
selectHeaders(h *tar.Header) (orderedHeaders [][2]string)
}
type tarHeaderSelectFunc func(h *tar.Header) (orderedHeaders [][2]string)
func (f tarHeaderSelectFunc) selectHeaders(h *tar.Header) (orderedHeaders [][2]string) {
return f(h)
}
func v0TarHeaderSelect(h *tar.Header) (orderedHeaders [][2]string) {
return [][2]string{
{"name", h.Name},
{"mode", strconv.FormatInt(h.Mode, 10)},
{"uid", strconv.Itoa(h.Uid)},
{"gid", strconv.Itoa(h.Gid)},
{"size", strconv.FormatInt(h.Size, 10)},
{"mtime", strconv.FormatInt(h.ModTime.UTC().Unix(), 10)},
{"typeflag", string([]byte{h.Typeflag})},
{"linkname", h.Linkname},
{"uname", h.Uname},
{"gname", h.Gname},
{"devmajor", strconv.FormatInt(h.Devmajor, 10)},
{"devminor", strconv.FormatInt(h.Devminor, 10)},
}
}
func v1TarHeaderSelect(h *tar.Header) (orderedHeaders [][2]string) {
// Get extended attributes.
xAttrKeys := make([]string, len(h.Xattrs))
for k := range h.Xattrs {
xAttrKeys = append(xAttrKeys, k)
}
sort.Strings(xAttrKeys)
// Make the slice with enough capacity to hold the 11 basic headers
// we want from the v0 selector plus however many xattrs we have.
orderedHeaders = make([][2]string, 0, 11+len(xAttrKeys))
// Copy all headers from v0 excluding the 'mtime' header (the 5th element).
v0headers := v0TarHeaderSelect(h)
orderedHeaders = append(orderedHeaders, v0headers[0:5]...)
orderedHeaders = append(orderedHeaders, v0headers[6:]...)
// Finally, append the sorted xattrs.
for _, k := range xAttrKeys {
orderedHeaders = append(orderedHeaders, [2]string{k, h.Xattrs[k]})
}
return
}
var registeredHeaderSelectors = map[Version]tarHeaderSelectFunc{
Version0: v0TarHeaderSelect,
Version1: v1TarHeaderSelect,
VersionDev: v1TarHeaderSelect,
}
func getTarHeaderSelector(v Version) (tarHeaderSelector, error) {
headerSelector, ok := registeredHeaderSelectors[v]
if !ok {
return nil, ErrVersionNotImplemented
}
return headerSelector, nil
}
| {
"pile_set_name": "Github"
} |
print <<DUMMY_TEST;
1..0 # skipping: rope
DUMMY_TEST
| {
"pile_set_name": "Github"
} |
# Display a process of packets and processed time.
# SPDX-License-Identifier: GPL-2.0
# It helps us to investigate networking or network device.
#
# options
# tx: show only tx chart
# rx: show only rx chart
# dev=: show only thing related to specified device
# debug: work with debug mode. It shows buffer status.
import os
import sys
sys.path.append(os.environ['PERF_EXEC_PATH'] + \
'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
from perf_trace_context import *
from Core import *
from Util import *
all_event_list = []; # insert all tracepoint event related with this script
irq_dic = {}; # key is cpu and value is a list which stacks irqs
# which raise NET_RX softirq
net_rx_dic = {}; # key is cpu and value include time of NET_RX softirq-entry
# and a list which stacks receive
receive_hunk_list = []; # a list which include a sequence of receive events
rx_skb_list = []; # received packet list for matching
# skb_copy_datagram_iovec
buffer_budget = 65536; # the budget of rx_skb_list, tx_queue_list and
# tx_xmit_list
of_count_rx_skb_list = 0; # overflow count
tx_queue_list = []; # list of packets which pass through dev_queue_xmit
of_count_tx_queue_list = 0; # overflow count
tx_xmit_list = []; # list of packets which pass through dev_hard_start_xmit
of_count_tx_xmit_list = 0; # overflow count
tx_free_list = []; # list of packets which is freed
# options
show_tx = 0;
show_rx = 0;
dev = 0; # store a name of device specified by option "dev="
debug = 0;
# indices of event_info tuple
EINFO_IDX_NAME= 0
EINFO_IDX_CONTEXT=1
EINFO_IDX_CPU= 2
EINFO_IDX_TIME= 3
EINFO_IDX_PID= 4
EINFO_IDX_COMM= 5
# Calculate a time interval(msec) from src(nsec) to dst(nsec)
def diff_msec(src, dst):
return (dst - src) / 1000000.0
# Display a process of transmitting a packet
def print_transmit(hunk):
if dev != 0 and hunk['dev'].find(dev) < 0:
return
print "%7s %5d %6d.%06dsec %12.3fmsec %12.3fmsec" % \
(hunk['dev'], hunk['len'],
nsecs_secs(hunk['queue_t']),
nsecs_nsecs(hunk['queue_t'])/1000,
diff_msec(hunk['queue_t'], hunk['xmit_t']),
diff_msec(hunk['xmit_t'], hunk['free_t']))
# Format for displaying rx packet processing
PF_IRQ_ENTRY= " irq_entry(+%.3fmsec irq=%d:%s)"
PF_SOFT_ENTRY=" softirq_entry(+%.3fmsec)"
PF_NAPI_POLL= " napi_poll_exit(+%.3fmsec %s)"
PF_JOINT= " |"
PF_WJOINT= " | |"
PF_NET_RECV= " |---netif_receive_skb(+%.3fmsec skb=%x len=%d)"
PF_NET_RX= " |---netif_rx(+%.3fmsec skb=%x)"
PF_CPY_DGRAM= " | skb_copy_datagram_iovec(+%.3fmsec %d:%s)"
PF_KFREE_SKB= " | kfree_skb(+%.3fmsec location=%x)"
PF_CONS_SKB= " | consume_skb(+%.3fmsec)"
# Display a process of received packets and interrputs associated with
# a NET_RX softirq
def print_receive(hunk):
show_hunk = 0
irq_list = hunk['irq_list']
cpu = irq_list[0]['cpu']
base_t = irq_list[0]['irq_ent_t']
# check if this hunk should be showed
if dev != 0:
for i in range(len(irq_list)):
if irq_list[i]['name'].find(dev) >= 0:
show_hunk = 1
break
else:
show_hunk = 1
if show_hunk == 0:
return
print "%d.%06dsec cpu=%d" % \
(nsecs_secs(base_t), nsecs_nsecs(base_t)/1000, cpu)
for i in range(len(irq_list)):
print PF_IRQ_ENTRY % \
(diff_msec(base_t, irq_list[i]['irq_ent_t']),
irq_list[i]['irq'], irq_list[i]['name'])
print PF_JOINT
irq_event_list = irq_list[i]['event_list']
for j in range(len(irq_event_list)):
irq_event = irq_event_list[j]
if irq_event['event'] == 'netif_rx':
print PF_NET_RX % \
(diff_msec(base_t, irq_event['time']),
irq_event['skbaddr'])
print PF_JOINT
print PF_SOFT_ENTRY % \
diff_msec(base_t, hunk['sirq_ent_t'])
print PF_JOINT
event_list = hunk['event_list']
for i in range(len(event_list)):
event = event_list[i]
if event['event_name'] == 'napi_poll':
print PF_NAPI_POLL % \
(diff_msec(base_t, event['event_t']), event['dev'])
if i == len(event_list) - 1:
print ""
else:
print PF_JOINT
else:
print PF_NET_RECV % \
(diff_msec(base_t, event['event_t']), event['skbaddr'],
event['len'])
if 'comm' in event.keys():
print PF_WJOINT
print PF_CPY_DGRAM % \
(diff_msec(base_t, event['comm_t']),
event['pid'], event['comm'])
elif 'handle' in event.keys():
print PF_WJOINT
if event['handle'] == "kfree_skb":
print PF_KFREE_SKB % \
(diff_msec(base_t,
event['comm_t']),
event['location'])
elif event['handle'] == "consume_skb":
print PF_CONS_SKB % \
diff_msec(base_t,
event['comm_t'])
print PF_JOINT
def trace_begin():
global show_tx
global show_rx
global dev
global debug
for i in range(len(sys.argv)):
if i == 0:
continue
arg = sys.argv[i]
if arg == 'tx':
show_tx = 1
elif arg =='rx':
show_rx = 1
elif arg.find('dev=',0, 4) >= 0:
dev = arg[4:]
elif arg == 'debug':
debug = 1
if show_tx == 0 and show_rx == 0:
show_tx = 1
show_rx = 1
def trace_end():
# order all events in time
all_event_list.sort(lambda a,b :cmp(a[EINFO_IDX_TIME],
b[EINFO_IDX_TIME]))
# process all events
for i in range(len(all_event_list)):
event_info = all_event_list[i]
name = event_info[EINFO_IDX_NAME]
if name == 'irq__softirq_exit':
handle_irq_softirq_exit(event_info)
elif name == 'irq__softirq_entry':
handle_irq_softirq_entry(event_info)
elif name == 'irq__softirq_raise':
handle_irq_softirq_raise(event_info)
elif name == 'irq__irq_handler_entry':
handle_irq_handler_entry(event_info)
elif name == 'irq__irq_handler_exit':
handle_irq_handler_exit(event_info)
elif name == 'napi__napi_poll':
handle_napi_poll(event_info)
elif name == 'net__netif_receive_skb':
handle_netif_receive_skb(event_info)
elif name == 'net__netif_rx':
handle_netif_rx(event_info)
elif name == 'skb__skb_copy_datagram_iovec':
handle_skb_copy_datagram_iovec(event_info)
elif name == 'net__net_dev_queue':
handle_net_dev_queue(event_info)
elif name == 'net__net_dev_xmit':
handle_net_dev_xmit(event_info)
elif name == 'skb__kfree_skb':
handle_kfree_skb(event_info)
elif name == 'skb__consume_skb':
handle_consume_skb(event_info)
# display receive hunks
if show_rx:
for i in range(len(receive_hunk_list)):
print_receive(receive_hunk_list[i])
# display transmit hunks
if show_tx:
print " dev len Qdisc " \
" netdevice free"
for i in range(len(tx_free_list)):
print_transmit(tx_free_list[i])
if debug:
print "debug buffer status"
print "----------------------------"
print "xmit Qdisc:remain:%d overflow:%d" % \
(len(tx_queue_list), of_count_tx_queue_list)
print "xmit netdevice:remain:%d overflow:%d" % \
(len(tx_xmit_list), of_count_tx_xmit_list)
print "receive:remain:%d overflow:%d" % \
(len(rx_skb_list), of_count_rx_skb_list)
# called from perf, when it finds a correspoinding event
def irq__softirq_entry(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
return
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
all_event_list.append(event_info)
def irq__softirq_exit(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
return
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
all_event_list.append(event_info)
def irq__softirq_raise(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
return
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
all_event_list.append(event_info)
def irq__irq_handler_entry(name, context, cpu, sec, nsec, pid, comm,
callchain, irq, irq_name):
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
irq, irq_name)
all_event_list.append(event_info)
def irq__irq_handler_exit(name, context, cpu, sec, nsec, pid, comm, callchain, irq, ret):
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, irq, ret)
all_event_list.append(event_info)
def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi,
dev_name, work=None, budget=None):
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
napi, dev_name, work, budget)
all_event_list.append(event_info)
def net__netif_receive_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr,
skblen, dev_name):
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
skbaddr, skblen, dev_name)
all_event_list.append(event_info)
def net__netif_rx(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr,
skblen, dev_name):
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
skbaddr, skblen, dev_name)
all_event_list.append(event_info)
def net__net_dev_queue(name, context, cpu, sec, nsec, pid, comm, callchain,
skbaddr, skblen, dev_name):
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
skbaddr, skblen, dev_name)
all_event_list.append(event_info)
def net__net_dev_xmit(name, context, cpu, sec, nsec, pid, comm, callchain,
skbaddr, skblen, rc, dev_name):
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
skbaddr, skblen, rc ,dev_name)
all_event_list.append(event_info)
def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, callchain,
skbaddr, protocol, location):
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
skbaddr, protocol, location)
all_event_list.append(event_info)
def skb__consume_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr):
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
skbaddr)
all_event_list.append(event_info)
def skb__skb_copy_datagram_iovec(name, context, cpu, sec, nsec, pid, comm, callchain,
skbaddr, skblen):
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
skbaddr, skblen)
all_event_list.append(event_info)
def handle_irq_handler_entry(event_info):
(name, context, cpu, time, pid, comm, irq, irq_name) = event_info
if cpu not in irq_dic.keys():
irq_dic[cpu] = []
irq_record = {'irq':irq, 'name':irq_name, 'cpu':cpu, 'irq_ent_t':time}
irq_dic[cpu].append(irq_record)
def handle_irq_handler_exit(event_info):
(name, context, cpu, time, pid, comm, irq, ret) = event_info
if cpu not in irq_dic.keys():
return
irq_record = irq_dic[cpu].pop()
if irq != irq_record['irq']:
return
irq_record.update({'irq_ext_t':time})
# if an irq doesn't include NET_RX softirq, drop.
if 'event_list' in irq_record.keys():
irq_dic[cpu].append(irq_record)
def handle_irq_softirq_raise(event_info):
(name, context, cpu, time, pid, comm, vec) = event_info
if cpu not in irq_dic.keys() \
or len(irq_dic[cpu]) == 0:
return
irq_record = irq_dic[cpu].pop()
if 'event_list' in irq_record.keys():
irq_event_list = irq_record['event_list']
else:
irq_event_list = []
irq_event_list.append({'time':time, 'event':'sirq_raise'})
irq_record.update({'event_list':irq_event_list})
irq_dic[cpu].append(irq_record)
def handle_irq_softirq_entry(event_info):
(name, context, cpu, time, pid, comm, vec) = event_info
net_rx_dic[cpu] = {'sirq_ent_t':time, 'event_list':[]}
def handle_irq_softirq_exit(event_info):
(name, context, cpu, time, pid, comm, vec) = event_info
irq_list = []
event_list = 0
if cpu in irq_dic.keys():
irq_list = irq_dic[cpu]
del irq_dic[cpu]
if cpu in net_rx_dic.keys():
sirq_ent_t = net_rx_dic[cpu]['sirq_ent_t']
event_list = net_rx_dic[cpu]['event_list']
del net_rx_dic[cpu]
if irq_list == [] or event_list == 0:
return
rec_data = {'sirq_ent_t':sirq_ent_t, 'sirq_ext_t':time,
'irq_list':irq_list, 'event_list':event_list}
# merge information realted to a NET_RX softirq
receive_hunk_list.append(rec_data)
def handle_napi_poll(event_info):
(name, context, cpu, time, pid, comm, napi, dev_name,
work, budget) = event_info
if cpu in net_rx_dic.keys():
event_list = net_rx_dic[cpu]['event_list']
rec_data = {'event_name':'napi_poll',
'dev':dev_name, 'event_t':time,
'work':work, 'budget':budget}
event_list.append(rec_data)
def handle_netif_rx(event_info):
(name, context, cpu, time, pid, comm,
skbaddr, skblen, dev_name) = event_info
if cpu not in irq_dic.keys() \
or len(irq_dic[cpu]) == 0:
return
irq_record = irq_dic[cpu].pop()
if 'event_list' in irq_record.keys():
irq_event_list = irq_record['event_list']
else:
irq_event_list = []
irq_event_list.append({'time':time, 'event':'netif_rx',
'skbaddr':skbaddr, 'skblen':skblen, 'dev_name':dev_name})
irq_record.update({'event_list':irq_event_list})
irq_dic[cpu].append(irq_record)
def handle_netif_receive_skb(event_info):
global of_count_rx_skb_list
(name, context, cpu, time, pid, comm,
skbaddr, skblen, dev_name) = event_info
if cpu in net_rx_dic.keys():
rec_data = {'event_name':'netif_receive_skb',
'event_t':time, 'skbaddr':skbaddr, 'len':skblen}
event_list = net_rx_dic[cpu]['event_list']
event_list.append(rec_data)
rx_skb_list.insert(0, rec_data)
if len(rx_skb_list) > buffer_budget:
rx_skb_list.pop()
of_count_rx_skb_list += 1
def handle_net_dev_queue(event_info):
global of_count_tx_queue_list
(name, context, cpu, time, pid, comm,
skbaddr, skblen, dev_name) = event_info
skb = {'dev':dev_name, 'skbaddr':skbaddr, 'len':skblen, 'queue_t':time}
tx_queue_list.insert(0, skb)
if len(tx_queue_list) > buffer_budget:
tx_queue_list.pop()
of_count_tx_queue_list += 1
def handle_net_dev_xmit(event_info):
global of_count_tx_xmit_list
(name, context, cpu, time, pid, comm,
skbaddr, skblen, rc, dev_name) = event_info
if rc == 0: # NETDEV_TX_OK
for i in range(len(tx_queue_list)):
skb = tx_queue_list[i]
if skb['skbaddr'] == skbaddr:
skb['xmit_t'] = time
tx_xmit_list.insert(0, skb)
del tx_queue_list[i]
if len(tx_xmit_list) > buffer_budget:
tx_xmit_list.pop()
of_count_tx_xmit_list += 1
return
def handle_kfree_skb(event_info):
(name, context, cpu, time, pid, comm,
skbaddr, protocol, location) = event_info
for i in range(len(tx_queue_list)):
skb = tx_queue_list[i]
if skb['skbaddr'] == skbaddr:
del tx_queue_list[i]
return
for i in range(len(tx_xmit_list)):
skb = tx_xmit_list[i]
if skb['skbaddr'] == skbaddr:
skb['free_t'] = time
tx_free_list.append(skb)
del tx_xmit_list[i]
return
for i in range(len(rx_skb_list)):
rec_data = rx_skb_list[i]
if rec_data['skbaddr'] == skbaddr:
rec_data.update({'handle':"kfree_skb",
'comm':comm, 'pid':pid, 'comm_t':time})
del rx_skb_list[i]
return
def handle_consume_skb(event_info):
(name, context, cpu, time, pid, comm, skbaddr) = event_info
for i in range(len(tx_xmit_list)):
skb = tx_xmit_list[i]
if skb['skbaddr'] == skbaddr:
skb['free_t'] = time
tx_free_list.append(skb)
del tx_xmit_list[i]
return
def handle_skb_copy_datagram_iovec(event_info):
(name, context, cpu, time, pid, comm, skbaddr, skblen) = event_info
for i in range(len(rx_skb_list)):
rec_data = rx_skb_list[i]
if skbaddr == rec_data['skbaddr']:
rec_data.update({'handle':"skb_copy_datagram_iovec",
'comm':comm, 'pid':pid, 'comm_t':time})
del rx_skb_list[i]
return
| {
"pile_set_name": "Github"
} |
using BrightIdeasSoftware;
using WinFwk.UITools;
using MemoScope.Core.Data;
namespace MemoScope.Modules.TypeDetails
{
public abstract class AbstractTypeInformation : TreeNodeInformationAdapter<AbstractTypeInformation>, ITypeNameData
{
[OLVColumn(Title = "Type", FillsFreeSpace = true)]
public string TypeName { get; protected set; }
}
}
| {
"pile_set_name": "Github"
} |
package com.alibaba.json.bvt.parser.deser.deny;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.ParserConfig;
import junit.framework.TestCase;
import java.util.Properties;
public class DenyTest9 extends TestCase {
public void test_autoTypeDeny() throws Exception {
ParserConfig config = new ParserConfig();
assertFalse(config.isAutoTypeSupport());
config.setAutoTypeSupport(true);
assertTrue(config.isAutoTypeSupport());
Properties properties = new Properties();
properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
properties.put(ParserConfig.AUTOTYPE_ACCEPT, "com.alibaba.json.bvt.parser.deser.deny.DenyTest9");
// -ea -Dfastjson.parser.autoTypeAccept=com.alibaba.json.bvt.parser.deser.deny.DenyTest9
config.configFromPropety(properties);
assertFalse(config.isAutoTypeSupport());
Object obj = JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest9$Model\"}", Object.class, config);
assertEquals(Model.class, obj.getClass());
}
public static class Model {
}
}
| {
"pile_set_name": "Github"
} |
module.exports = require('./').http;
| {
"pile_set_name": "Github"
} |
//
// NSStringLinqTests.m
// NSEnumeratorLinq
//
// Created by Антон Буков on 06.03.13.
// Copyright (c) 2013 Happy Nation Project. All rights reserved.
//
#import "NSEnumerator+Linq.h"
#import "NSStringLinqTests.h"
@implementation NSStringLinqTests
- (void)testEnumerateComponentsSeparatedByString
{
NSString * str = @"Helloabcworldabcxyz";
NSArray * ans = [str componentsSeparatedByString:@"abc"];
NSEnumerator * res = [str enumerateComponentsSeparatedByString:@"abc"];
STAssertEqualObjects(ans, [res allObjects], @"Components separated by string");
}
- (void)testEnumerateComponentsSeparatedByString3Empty
{
NSString * str = @"abcabc";
NSArray * ans = [str componentsSeparatedByString:@"abc"];
NSEnumerator * res = [str enumerateComponentsSeparatedByString:@"abc"];
STAssertEqualObjects(ans, [res allObjects], @"Components separated by string");
}
- (void)testEnumerateComponentsSeparatedByStringNoSeparators
{
NSString * str = @"xyz";
NSArray * ans = [str componentsSeparatedByString:@"abc"];
NSEnumerator * res = [str enumerateComponentsSeparatedByString:@"abc"];
STAssertEqualObjects(ans, [res allObjects], @"Components separated by string");
}
- (void)testEnumerateComponentsSeparatedByStringEmptyString
{
NSString * str = @"";
NSArray * ans = [str componentsSeparatedByString:@"abc"];
NSEnumerator * res = [str enumerateComponentsSeparatedByString:@"abc"];
STAssertEqualObjects(ans, [res allObjects], @"Components separated by string");
}
@end
| {
"pile_set_name": "Github"
} |
/*
* Libata driver for the highpoint 366 and 368 UDMA66 ATA controllers.
*
* This driver is heavily based upon:
*
* linux/drivers/ide/pci/hpt366.c Version 0.36 April 25, 2003
*
* Copyright (C) 1999-2003 Andre Hedrick <[email protected]>
* Portions Copyright (C) 2001 Sun Microsystems, Inc.
* Portions Copyright (C) 2003 Red Hat Inc
*
*
* TODO
* Look into engine reset on timeout errors. Should not be required.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include <scsi/scsi_host.h>
#include <linux/libata.h>
#define DRV_NAME "pata_hpt366"
#define DRV_VERSION "0.6.11"
struct hpt_clock {
u8 xfer_mode;
u32 timing;
};
/* key for bus clock timings
* bit
* 0:3 data_high_time. Inactive time of DIOW_/DIOR_ for PIO and MW DMA.
* cycles = value + 1
* 4:7 data_low_time. Active time of DIOW_/DIOR_ for PIO and MW DMA.
* cycles = value + 1
* 8:11 cmd_high_time. Inactive time of DIOW_/DIOR_ during task file
* register access.
* 12:15 cmd_low_time. Active time of DIOW_/DIOR_ during task file
* register access.
* 16:18 udma_cycle_time. Clock cycles for UDMA xfer?
* 19:21 pre_high_time. Time to initialize 1st cycle for PIO and MW DMA xfer.
* 22:24 cmd_pre_high_time. Time to initialize 1st PIO cycle for task file
* register access.
* 28 UDMA enable.
* 29 DMA enable.
* 30 PIO_MST enable. If set, the chip is in bus master mode during
* PIO xfer.
* 31 FIFO enable.
*/
static const struct hpt_clock hpt366_40[] = {
{ XFER_UDMA_4, 0x900fd943 },
{ XFER_UDMA_3, 0x900ad943 },
{ XFER_UDMA_2, 0x900bd943 },
{ XFER_UDMA_1, 0x9008d943 },
{ XFER_UDMA_0, 0x9008d943 },
{ XFER_MW_DMA_2, 0xa008d943 },
{ XFER_MW_DMA_1, 0xa010d955 },
{ XFER_MW_DMA_0, 0xa010d9fc },
{ XFER_PIO_4, 0xc008d963 },
{ XFER_PIO_3, 0xc010d974 },
{ XFER_PIO_2, 0xc010d997 },
{ XFER_PIO_1, 0xc010d9c7 },
{ XFER_PIO_0, 0xc018d9d9 },
{ 0, 0x0120d9d9 }
};
static const struct hpt_clock hpt366_33[] = {
{ XFER_UDMA_4, 0x90c9a731 },
{ XFER_UDMA_3, 0x90cfa731 },
{ XFER_UDMA_2, 0x90caa731 },
{ XFER_UDMA_1, 0x90cba731 },
{ XFER_UDMA_0, 0x90c8a731 },
{ XFER_MW_DMA_2, 0xa0c8a731 },
{ XFER_MW_DMA_1, 0xa0c8a732 }, /* 0xa0c8a733 */
{ XFER_MW_DMA_0, 0xa0c8a797 },
{ XFER_PIO_4, 0xc0c8a731 },
{ XFER_PIO_3, 0xc0c8a742 },
{ XFER_PIO_2, 0xc0d0a753 },
{ XFER_PIO_1, 0xc0d0a7a3 }, /* 0xc0d0a793 */
{ XFER_PIO_0, 0xc0d0a7aa }, /* 0xc0d0a7a7 */
{ 0, 0x0120a7a7 }
};
static const struct hpt_clock hpt366_25[] = {
{ XFER_UDMA_4, 0x90c98521 },
{ XFER_UDMA_3, 0x90cf8521 },
{ XFER_UDMA_2, 0x90cf8521 },
{ XFER_UDMA_1, 0x90cb8521 },
{ XFER_UDMA_0, 0x90cb8521 },
{ XFER_MW_DMA_2, 0xa0ca8521 },
{ XFER_MW_DMA_1, 0xa0ca8532 },
{ XFER_MW_DMA_0, 0xa0ca8575 },
{ XFER_PIO_4, 0xc0ca8521 },
{ XFER_PIO_3, 0xc0ca8532 },
{ XFER_PIO_2, 0xc0ca8542 },
{ XFER_PIO_1, 0xc0d08572 },
{ XFER_PIO_0, 0xc0d08585 },
{ 0, 0x01208585 }
};
/**
* hpt36x_find_mode - find the hpt36x timing
* @ap: ATA port
* @speed: transfer mode
*
* Return the 32bit register programming information for this channel
* that matches the speed provided.
*/
static u32 hpt36x_find_mode(struct ata_port *ap, int speed)
{
struct hpt_clock *clocks = ap->host->private_data;
while (clocks->xfer_mode) {
if (clocks->xfer_mode == speed)
return clocks->timing;
clocks++;
}
BUG();
return 0xffffffffU; /* silence compiler warning */
}
static const char * const bad_ata33[] = {
"Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3",
"Maxtor 90845U3", "Maxtor 90650U2",
"Maxtor 91360D8", "Maxtor 91190D7", "Maxtor 91020D6", "Maxtor 90845D5",
"Maxtor 90680D4", "Maxtor 90510D3", "Maxtor 90340D2",
"Maxtor 91152D8", "Maxtor 91008D7", "Maxtor 90845D6", "Maxtor 90840D6",
"Maxtor 90720D5", "Maxtor 90648D5", "Maxtor 90576D4",
"Maxtor 90510D4",
"Maxtor 90432D3", "Maxtor 90288D2", "Maxtor 90256D2",
"Maxtor 91000D8", "Maxtor 90910D8", "Maxtor 90875D7", "Maxtor 90840D7",
"Maxtor 90750D6", "Maxtor 90625D5", "Maxtor 90500D4",
"Maxtor 91728D8", "Maxtor 91512D7", "Maxtor 91303D6", "Maxtor 91080D5",
"Maxtor 90845D4", "Maxtor 90680D4", "Maxtor 90648D3", "Maxtor 90432D2",
NULL
};
static const char * const bad_ata66_4[] = {
"IBM-DTLA-307075",
"IBM-DTLA-307060",
"IBM-DTLA-307045",
"IBM-DTLA-307030",
"IBM-DTLA-307020",
"IBM-DTLA-307015",
"IBM-DTLA-305040",
"IBM-DTLA-305030",
"IBM-DTLA-305020",
"IC35L010AVER07-0",
"IC35L020AVER07-0",
"IC35L030AVER07-0",
"IC35L040AVER07-0",
"IC35L060AVER07-0",
"WDC AC310200R",
NULL
};
static const char * const bad_ata66_3[] = {
"WDC AC310200R",
NULL
};
static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr,
const char * const list[])
{
unsigned char model_num[ATA_ID_PROD_LEN + 1];
int i = 0;
ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
while (list[i] != NULL) {
if (!strcmp(list[i], model_num)) {
pr_warn("%s is not supported for %s\n",
modestr, list[i]);
return 1;
}
i++;
}
return 0;
}
/**
* hpt366_filter - mode selection filter
* @adev: ATA device
*
* Block UDMA on devices that cause trouble with this controller.
*/
static unsigned long hpt366_filter(struct ata_device *adev, unsigned long mask)
{
if (adev->class == ATA_DEV_ATA) {
if (hpt_dma_blacklisted(adev, "UDMA", bad_ata33))
mask &= ~ATA_MASK_UDMA;
if (hpt_dma_blacklisted(adev, "UDMA3", bad_ata66_3))
mask &= ~(0xF8 << ATA_SHIFT_UDMA);
if (hpt_dma_blacklisted(adev, "UDMA4", bad_ata66_4))
mask &= ~(0xF0 << ATA_SHIFT_UDMA);
} else if (adev->class == ATA_DEV_ATAPI)
mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
return mask;
}
static int hpt36x_cable_detect(struct ata_port *ap)
{
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u8 ata66;
/*
* Each channel of pata_hpt366 occupies separate PCI function
* as the primary channel and bit1 indicates the cable type.
*/
pci_read_config_byte(pdev, 0x5A, &ata66);
if (ata66 & 2)
return ATA_CBL_PATA40;
return ATA_CBL_PATA80;
}
static void hpt366_set_mode(struct ata_port *ap, struct ata_device *adev,
u8 mode)
{
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u32 addr = 0x40 + 4 * adev->devno;
u32 mask, reg, t;
/* determine timing mask and find matching clock entry */
if (mode < XFER_MW_DMA_0)
mask = 0xc1f8ffff;
else if (mode < XFER_UDMA_0)
mask = 0x303800ff;
else
mask = 0x30070000;
t = hpt36x_find_mode(ap, mode);
/*
* Combine new mode bits with old config bits and disable
* on-chip PIO FIFO/buffer (and PIO MST mode as well) to avoid
* problems handling I/O errors later.
*/
pci_read_config_dword(pdev, addr, ®);
reg = ((reg & ~mask) | (t & mask)) & ~0xc0000000;
pci_write_config_dword(pdev, addr, reg);
}
/**
* hpt366_set_piomode - PIO setup
* @ap: ATA interface
* @adev: device on the interface
*
* Perform PIO mode setup.
*/
static void hpt366_set_piomode(struct ata_port *ap, struct ata_device *adev)
{
hpt366_set_mode(ap, adev, adev->pio_mode);
}
/**
* hpt366_set_dmamode - DMA timing setup
* @ap: ATA interface
* @adev: Device being configured
*
* Set up the channel for MWDMA or UDMA modes. Much the same as with
* PIO, load the mode number and then set MWDMA or UDMA flag.
*/
static void hpt366_set_dmamode(struct ata_port *ap, struct ata_device *adev)
{
hpt366_set_mode(ap, adev, adev->dma_mode);
}
static struct scsi_host_template hpt36x_sht = {
ATA_BMDMA_SHT(DRV_NAME),
};
/*
* Configuration for HPT366/68
*/
static struct ata_port_operations hpt366_port_ops = {
.inherits = &ata_bmdma_port_ops,
.cable_detect = hpt36x_cable_detect,
.mode_filter = hpt366_filter,
.set_piomode = hpt366_set_piomode,
.set_dmamode = hpt366_set_dmamode,
};
/**
* hpt36x_init_chipset - common chip setup
* @dev: PCI device
*
* Perform the chip setup work that must be done at both init and
* resume time
*/
static void hpt36x_init_chipset(struct pci_dev *dev)
{
u8 drive_fast;
pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4));
pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x78);
pci_write_config_byte(dev, PCI_MIN_GNT, 0x08);
pci_write_config_byte(dev, PCI_MAX_LAT, 0x08);
pci_read_config_byte(dev, 0x51, &drive_fast);
if (drive_fast & 0x80)
pci_write_config_byte(dev, 0x51, drive_fast & ~0x80);
}
/**
* hpt36x_init_one - Initialise an HPT366/368
* @dev: PCI device
* @id: Entry in match table
*
* Initialise an HPT36x device. There are some interesting complications
* here. Firstly the chip may report 366 and be one of several variants.
* Secondly all the timings depend on the clock for the chip which we must
* detect and look up
*
* This is the known chip mappings. It may be missing a couple of later
* releases.
*
* Chip version PCI Rev Notes
* HPT366 4 (HPT366) 0 UDMA66
* HPT366 4 (HPT366) 1 UDMA66
* HPT368 4 (HPT366) 2 UDMA66
* HPT37x/30x 4 (HPT366) 3+ Other driver
*
*/
static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
static const struct ata_port_info info_hpt366 = {
.flags = ATA_FLAG_SLAVE_POSS,
.pio_mask = ATA_PIO4,
.mwdma_mask = ATA_MWDMA2,
.udma_mask = ATA_UDMA4,
.port_ops = &hpt366_port_ops
};
const struct ata_port_info *ppi[] = { &info_hpt366, NULL };
void *hpriv = NULL;
u32 reg1;
int rc;
rc = pcim_enable_device(dev);
if (rc)
return rc;
/* May be a later chip in disguise. Check */
/* Newer chips are not in the HPT36x driver. Ignore them */
if (dev->revision > 2)
return -ENODEV;
hpt36x_init_chipset(dev);
pci_read_config_dword(dev, 0x40, ®1);
/* PCI clocking determines the ATA timing values to use */
/* info_hpt366 is safe against re-entry so we can scribble on it */
switch ((reg1 & 0x700) >> 8) {
case 9:
hpriv = &hpt366_40;
break;
case 5:
hpriv = &hpt366_25;
break;
default:
hpriv = &hpt366_33;
break;
}
/* Now kick off ATA set up */
return ata_pci_bmdma_init_one(dev, ppi, &hpt36x_sht, hpriv, 0);
}
#ifdef CONFIG_PM
static int hpt36x_reinit_one(struct pci_dev *dev)
{
struct ata_host *host = pci_get_drvdata(dev);
int rc;
rc = ata_pci_device_do_resume(dev);
if (rc)
return rc;
hpt36x_init_chipset(dev);
ata_host_resume(host);
return 0;
}
#endif
static const struct pci_device_id hpt36x[] = {
{ PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT366), },
{ },
};
static struct pci_driver hpt36x_pci_driver = {
.name = DRV_NAME,
.id_table = hpt36x,
.probe = hpt36x_init_one,
.remove = ata_pci_remove_one,
#ifdef CONFIG_PM
.suspend = ata_pci_device_suspend,
.resume = hpt36x_reinit_one,
#endif
};
module_pci_driver(hpt36x_pci_driver);
MODULE_AUTHOR("Alan Cox");
MODULE_DESCRIPTION("low-level driver for the Highpoint HPT366/368");
MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(pci, hpt36x);
MODULE_VERSION(DRV_VERSION);
| {
"pile_set_name": "Github"
} |
class A(Int)
extension class A(Int)
| {
"pile_set_name": "Github"
} |
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ViewModels
{
public class TaskViewModel : INotifyPropertyChanged
{
public int ID
{
get
{
return id;
}
set
{
if(id != value)
{
id = value;
PropertyChanged(this, new PropertyChangedEventArgs("ID"));
}
}
}
public string Description
{
get
{
return description;
}
set
{
if(description != value)
{
description = value;
PropertyChanged(this, new PropertyChangedEventArgs("Description"));
}
}
}
public string Priority
{
get
{
return priority;
}
set
{
if(priority != value)
{
priority = value;
PropertyChanged(this, new PropertyChangedEventArgs("Priority"));
}
}
}
public DateTime DueDate
{
get
{
return dueDate;
}
set
{
if (dueDate != value)
{
dueDate = value;
PropertyChanged(this, new PropertyChangedEventArgs("DueDate"));
}
}
}
public bool Completed
{
get
{
return completed;
}
set
{
if(completed != value)
{
completed = value;
PropertyChanged(this, new PropertyChangedEventArgs("Completed"));
}
}
}
public event PropertyChangedEventHandler PropertyChanged = delegate { };
private int id;
private DateTime dueDate;
private string description;
private string priority;
private bool completed;
}
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#ifndef HEADER_MDC2_H
# define HEADER_MDC2_H
# include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_MDC2
# include <stdlib.h>
# include <openssl/des.h>
# ifdef __cplusplus
extern "C" {
# endif
# define MDC2_BLOCK 8
# define MDC2_DIGEST_LENGTH 16
typedef struct mdc2_ctx_st {
unsigned int num;
unsigned char data[MDC2_BLOCK];
DES_cblock h, hh;
int pad_type; /* either 1 or 2, default 1 */
} MDC2_CTX;
int MDC2_Init(MDC2_CTX *c);
int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len);
int MDC2_Final(unsigned char *md, MDC2_CTX *c);
unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md);
# ifdef __cplusplus
}
# endif
# endif
#endif
| {
"pile_set_name": "Github"
} |
さくら最新番号
【BRJ-002】Jewelry day さくら</a>2009-09-04BRAD-J$$$Brad-J88分钟 | {
"pile_set_name": "Github"
} |
<div class="wide form">
<?php $form=$this->beginWidget('CActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'method'=>'get',
)); ?>
<div class="row">
<?php echo $form->label($model,'id'); ?>
<?php echo $form->textField($model,'id'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'employee_id'); ?>
<?php echo $form->textField($model,'employee_id'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'subject_id'); ?>
<?php echo $form->textField($model,'subject_id'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton(Yii::t('app','Search')); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- search-form --> | {
"pile_set_name": "Github"
} |
{
"author": "Microsoft Community",
"name": "Media Player",
"description": "Una página para mostrar vídeos con los controles de los medios del sistema habilitados.",
"identity": "wts.Page.MediaPlayer.Prism"
} | {
"pile_set_name": "Github"
} |
#pragma once
#include <Register/Utility.hpp>
namespace Kvasir {
//Base Timer 0
namespace Bt6PwmTmcr{ ///<Timer Control Register
using Addr = Register::Address<0x4002528c,0xffff8080,0x00000000,unsigned>;
///Count clock selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(14,12),Register::ReadWriteAccess,unsigned> cks20{};
///Restart enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(11,11),Register::ReadWriteAccess,unsigned> rtgen{};
///Pulse output mask bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(10,10),Register::ReadWriteAccess,unsigned> pmsk{};
///Trigger input edge selection bits
constexpr Register::FieldLocation<Addr,Register::maskFromRange(9,8),Register::ReadWriteAccess,unsigned> egs{};
///Timer function selection bits
constexpr Register::FieldLocation<Addr,Register::maskFromRange(6,4),Register::ReadWriteAccess,unsigned> fmd{};
///Output polarity specification bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(3,3),Register::ReadWriteAccess,unsigned> osel{};
///Mode selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(2,2),Register::ReadWriteAccess,unsigned> mdse{};
///Count operation enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(1,1),Register::ReadWriteAccess,unsigned> cten{};
///Software trigger bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> strg{};
}
namespace Bt6PwmTmcr2{ ///<Timer Control Register 2
using Addr = Register::Address<0x40025291,0xfffffffe,0x00000000,unsigned char>;
///Count clock selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> cks3{};
}
namespace Bt6PwmStc{ ///< Status Control Register
using Addr = Register::Address<0x40025290,0xffffff88,0x00000000,unsigned char>;
///Trigger interrupt request enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(6,6),Register::ReadWriteAccess,unsigned> tgie{};
///Duty match interrupt request enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(5,5),Register::ReadWriteAccess,unsigned> dtie{};
///Underflow interrupt request enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(4,4),Register::ReadWriteAccess,unsigned> udie{};
///Trigger interrupt request bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(2,2),Register::ReadWriteAccess,unsigned> tgir{};
///Duty match interrupt request bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(1,1),Register::ReadWriteAccess,unsigned> dtir{};
///Underflow interrupt request bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> udir{};
}
namespace Bt6PwmPcsr{ ///<PWM Cycle Set Register
using Addr = Register::Address<0x40025280,0xffffffff,0x00000000,unsigned>;
}
namespace Bt6PwmPdut{ ///<PWM Duty Set Register
using Addr = Register::Address<0x40025284,0xffffffff,0x00000000,unsigned>;
}
namespace Bt6PwmTmr{ ///<Timer Register
using Addr = Register::Address<0x40025288,0xffffffff,0x00000000,unsigned>;
}
namespace Bt6PpgTmcr{ ///<Timer Control Register
using Addr = Register::Address<0x4002528c,0xffff8080,0x00000000,unsigned>;
///Count clock selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(14,12),Register::ReadWriteAccess,unsigned> cks20{};
///Restart enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(11,11),Register::ReadWriteAccess,unsigned> rtgen{};
/// Pulse output mask bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(10,10),Register::ReadWriteAccess,unsigned> pmsk{};
///Trigger input edge selection bits
constexpr Register::FieldLocation<Addr,Register::maskFromRange(9,8),Register::ReadWriteAccess,unsigned> egs{};
///Timer function selection bits
constexpr Register::FieldLocation<Addr,Register::maskFromRange(6,4),Register::ReadWriteAccess,unsigned> fmd{};
///Output polarity specification bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(3,3),Register::ReadWriteAccess,unsigned> osel{};
///Mode selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(2,2),Register::ReadWriteAccess,unsigned> mdse{};
///Count operation enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(1,1),Register::ReadWriteAccess,unsigned> cten{};
///Software trigger bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> strg{};
}
namespace Bt6PpgTmcr2{ ///<Timer Control Register 2
using Addr = Register::Address<0x40025291,0xfffffffd,0x00000000,unsigned char>;
///Count clock selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(1,1),Register::ReadWriteAccess,unsigned> cks3{};
}
namespace Bt6PpgStc{ ///<Status Control Register
using Addr = Register::Address<0x40025290,0xffffffaa,0x00000000,unsigned char>;
///Trigger interrupt request enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(6,6),Register::ReadWriteAccess,unsigned> tgie{};
///Underflow interrupt request enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(4,4),Register::ReadWriteAccess,unsigned> udie{};
///Trigger interrupt request bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(2,2),Register::ReadWriteAccess,unsigned> tgir{};
///Underflow interrupt request bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> udir{};
}
namespace Bt6PpgPrll{ ///<LOW Width Reload Register
using Addr = Register::Address<0x40025280,0xffffffff,0x00000000,unsigned>;
}
namespace Bt6PpgPrlh{ ///<HIGH Width Reload Register
using Addr = Register::Address<0x40025284,0xffffffff,0x00000000,unsigned>;
}
namespace Bt6PpgTmr{ ///<Timer Register
using Addr = Register::Address<0x40025288,0xffffffff,0x00000000,unsigned>;
}
namespace Bt6RtTmcr{ ///<Timer Control Register
using Addr = Register::Address<0x4002528c,0xffff8c00,0x00000000,unsigned>;
///Count clock selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(14,12),Register::ReadWriteAccess,unsigned> cks20{};
///Trigger input edge selection bits
constexpr Register::FieldLocation<Addr,Register::maskFromRange(9,8),Register::ReadWriteAccess,unsigned> egs{};
///32-bit timer selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(7,7),Register::ReadWriteAccess,unsigned> t32{};
///Timer function selection bits
constexpr Register::FieldLocation<Addr,Register::maskFromRange(6,4),Register::ReadWriteAccess,unsigned> fmd{};
///Output polarity specification bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(3,3),Register::ReadWriteAccess,unsigned> osel{};
///Mode selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(2,2),Register::ReadWriteAccess,unsigned> mdse{};
///Timer enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(1,1),Register::ReadWriteAccess,unsigned> cten{};
///Software trigger bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> strg{};
}
namespace Bt6RtTmcr2{ ///<Timer Control Register 2
using Addr = Register::Address<0x40025291,0xfffffffe,0x00000000,unsigned char>;
///Count clock selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> cks3{};
}
namespace Bt6RtStc{ ///<Status Control Register
using Addr = Register::Address<0x40025290,0xffffffaa,0x00000000,unsigned char>;
///Trigger interrupt request enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(6,6),Register::ReadWriteAccess,unsigned> tgie{};
///Underflow interrupt request enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(4,4),Register::ReadWriteAccess,unsigned> udie{};
///Trigger interrupt request bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(2,2),Register::ReadWriteAccess,unsigned> tgir{};
///Underflow interrupt request bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> udir{};
}
namespace Bt6RtPcsr{ ///<PWM Cycle Set Register
using Addr = Register::Address<0x40025280,0xffffffff,0x00000000,unsigned>;
}
namespace Bt6RtTmr{ ///<Timer Register
using Addr = Register::Address<0x40025288,0xffffffff,0x00000000,unsigned>;
}
namespace Bt6PwcTmcr{ ///<Timer Control Register
using Addr = Register::Address<0x4002528c,0xffff8809,0x00000000,unsigned>;
///Count clock selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(14,12),Register::ReadWriteAccess,unsigned> cks20{};
///Measurement edge selection bits
constexpr Register::FieldLocation<Addr,Register::maskFromRange(10,8),Register::ReadWriteAccess,unsigned> egs{};
///32-bit timer selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(7,7),Register::ReadWriteAccess,unsigned> t32{};
///Timer function selection bits
constexpr Register::FieldLocation<Addr,Register::maskFromRange(6,4),Register::ReadWriteAccess,unsigned> fmd{};
///Mode selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(2,2),Register::ReadWriteAccess,unsigned> mdse{};
///Timer enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(1,1),Register::ReadWriteAccess,unsigned> cten{};
}
namespace Bt6PwcTmcr2{ ///<Timer Control Register 2
using Addr = Register::Address<0x40025291,0xfffffffe,0x00000000,unsigned char>;
///Count clock selection bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> cks3{};
}
namespace Bt6PwcStc{ ///<Status Control Register
using Addr = Register::Address<0x40025290,0xffffff2a,0x00000000,unsigned char>;
///Error flag bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(7,7),Register::Access<Register::AccessType::readOnly,Register::ReadActionType::normal,Register::ModifiedWriteValueType::normal>,unsigned> err{};
///Measurement completion interrupt request enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(6,6),Register::ReadWriteAccess,unsigned> edie{};
///Overflow interrupt request enable bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(4,4),Register::ReadWriteAccess,unsigned> ovie{};
///Measurement completion interrupt request bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(2,2),Register::Access<Register::AccessType::readOnly,Register::ReadActionType::normal,Register::ModifiedWriteValueType::normal>,unsigned> edir{};
///Overflow interrupt request bit
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> ovir{};
}
namespace Bt6PwcDtbf{ ///<Data Buffer Register
using Addr = Register::Address<0x40025284,0xffffffff,0x00000000,unsigned>;
}
}
| {
"pile_set_name": "Github"
} |
import logging
from datetime import timedelta
from core.errors import ObservableValidationError
from core.feed import Feed
from core.observables import Url, Ip
class BenkowTracker(Feed):
default_values = {
"frequency": timedelta(hours=1),
"name": "BenkowTracker",
"source": "http://benkow.cc/export.php",
"description": "This feed contains known Malware C2 servers",
}
def update(self):
for index, line in self.update_csv(filter_row='date', delimiter=';',
header=0):
self.analyze(line)
def analyze(self, line):
url_obs = False
url = line['url']
ip = line['ip']
family = line['type']
context = {}
context['date_added'] = line['date']
context['source'] = self.name
tags = []
tags.append(family.lower())
try:
if url:
url_obs = Url.get_or_create(value=url)
url_obs.add_context(context)
url_obs.add_source(self.name)
url_obs.tag(tags)
except ObservableValidationError as e:
logging.error(e)
try:
if ip:
ip_obs = Ip.get_or_create(value=ip)
ip_obs.add_context(context)
ip_obs.add_source(self.name)
ip_obs.tag(tags)
if url_obs:
ip_obs.active_link_to(
url_obs, "url", self.name, clean_old=False)
except ObservableValidationError as e:
logging.error(e)
| {
"pile_set_name": "Github"
} |
<p><strong><?php _e('Critical Pages', 'event_espresso'); ?></strong></p>
<p>
<?php _e('This page shows all critical pages that Event Espresso needs to work correctly.', 'event_espresso'); ?>
</p>
<p><strong><?php _e('Shortcodes', 'event_espresso'); ?></strong></p>
<ul>
<li>
<strong><?php _e('Registration Checkout Page', 'event_espresso'); ?></strong><br />
<?php printf(__('This page displays all your events and is required. It is important that this page always contain the %s shortcode. It is not required to be in your navigation menu.', 'event_espresso'), '<strong>[ESPRESSO_CHECKOUT]</strong>'); ?>
</li>
<li>
<strong><?php _e('Transactions Page', 'event_espresso'); ?></strong><br />
<?php printf(__('This page processes the payments and is required. It should only contain the %s shortcode. No other content should be added and it should be hidden from your navigation menu.', 'event_espresso'), '<strong>[ESPRESSO_TXN_PAGE]</strong>'); ?>
</li>
<li>
<strong><?php _e('Thank You Page', 'event_espresso'); ?></strong><br />
<?php printf(__('This page is displayed after a successful transaction and is required. It should contain the %s shortcode. Additionally, you may customize this page by adding extra content to the page. It should be hidden from your navigation menu.', 'event_espresso'), '<strong>[ESPRESSO_THANK_YOU]</strong>'); ?>
</li>
<li>
<strong><?php _e('Cancel / Return Page', 'event_espresso'); ?></strong><br />
<?php printf(__('This page is displayed after an unsuccessful transaction and is required. It should contain the %s shortcode. Additionally, you may customize this page by adding extra content to the page. It should be hidden from your navigation menu.', 'event_espresso'), '<strong>[ESPRESSO_CANCELLED]</strong>'); ?>
</li>
<li>
<strong><?php _e('Event List', 'event_espresso'); ?></strong><br />
<?php printf(__('If you would like to style the look of your events archive page, then follow the WordPress instructions for %1$screating a custom template for archive pages%2$s.', 'event_espresso'), '<a href="http://codex.wordpress.org/Post_Type_Templates">', '</a>'); ?>
<ul>
<li style="list-style-type: circle;">
<?php printf(__('Build a template for your events - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', 'event_espresso'), '<strong>archive-espresso_events.php</strong>', 'wp-content/themes/twenty-fourteen'); ?>
</li>
<li style="list-style-type: circle;">
<?php printf(__('Build a template for a single event - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', 'event_espresso'), '<strong>single-espresso_events.php</strong>', 'wp-content/themes/twenty-fourteen'); ?>
</li>
</ul>
</li>
<li>
<strong><?php _e('Venue List', 'event_espresso'); ?></strong><br />
<?php printf(__('If you would like to style the look of your venues archive page, then follow the WordPress instructions for %1$screating a custom template for archive pages%2$s.', 'event_espresso'), '<a href="http://codex.wordpress.org/Post_Type_Templates">', '</a>'); ?>
<ul>
<li style="list-style-type: circle;">
<?php printf(__('Build a template for your events - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', 'event_espresso'), '<strong>archive-espresso_venues.php</strong>', 'wp-content/themes/twenty-fourteen'); ?>
</li>
<li style="list-style-type: circle;">
<?php printf(__('Build a template for a single event - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', 'event_espresso'), '<strong>single-espresso_venues.php</strong>', 'wp-content/themes/twenty-fourteen'); ?>
</li>
</ul>
</li>
</ul>
</p>
<p>
<strong><?php _e('Recommendations', 'event_espresso'); ?></strong><br />
<?php _e('Want to see a tour of this screen? Click on the Critical Pages Tour button which appears on the right side of the page. <br />To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', 'event_espresso'); ?>
</p>
<p>
<strong><?php _e('Screen Options', 'event_espresso'); ?></strong><br />
<?php _e('You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', 'event_espresso'); ?>
</p> | {
"pile_set_name": "Github"
} |
module mod {
prefix m;
namespace "urn:cesnet:mod";
feature f1;
grouping login {
leaf login {
type string {
pattern '[a-zA-Z][a-zA-Z_0-9]*';
}
}
leaf password {
type string {
length "5..255";
}
default "admin";
}
}
}
| {
"pile_set_name": "Github"
} |
#!/bin/bash
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
#
# Copyright (c) 2015, Joyent, Inc.
#
#
# publish: publish a new version of mdb_v8. This does a few local sanity
# checks, creates a git tag for the current version, and uploads bits to Manta.
# To publish a new version, run:
#
# $ git status # check that working tree is not dirty
# $ make release # makes "clean" first, then "all"
# $ ./tools/publish # sanity checks, git tags, upload
# # use "-l" option if this is a new latest
# # release.
#
# Then follow the suggested steps output by the above script.
#
arg0="$(basename ${BASH_SOURCE[0]})"
p_root="/Joyent_Dev/public/mdb_v8"
p_latest=false
p_version=
p_dir=
function usage
{
[[ -n "$@" ]] && echo "$arg0: $@" >&2
cat >&2 <<-EOF
usage: $arg0 [-fl]
Publishes the currently built version of mdb_v8 to Manta.
EOF
exit 2
}
function fail
{
echo "$arg0: $@" >&2
exit 1
}
#
# confirm MESSAGE: prompt the user with MESSAGE and returns success only if
# they reply with "y" or "Y".
#
function confirm
{
# Prompt the user with the message we were given.
read -p "$@" -n 1
# Print a newline, regardless of what they typed.
echo
# Return success iff the user typed "y" or "Y".
[[ $REPLY =~ ^[Yy]$ ]]
}
function main
{
while getopts ":l" c "$@"; do
case "$c" in
l) p_latest=true ;;
:) usage "option requires an argument -- $OPTARG" ;;
*) usage "invalid option: $OPTARG" ;;
esac
done
cd "$(dirname "${BASH_SOURCE[0]}")/.." || fail "failed to cd"
echo -n "Checking for local copy of Manta tools ... "
if ! type "mls" > /dev/null 2>&1; then
fail "mls(1) not found"
fi
echo "okay."
pub_load_version
pub_sanity_check
if ! pub_create_tag; then
confirm "Failed to apply tag. Continue? " || \
fail "aborted by user"
fi
if pub_exists_upstream; then
confirm "Overwrite published version? " || \
fail "aborted by user"
fi
pub_publish
if [[ "$p_latest" == "true" ]]; then
pub_update_latest
echo "Done."
else
echo -n "Done. "
echo "Did not update \"latest\" link (use -l to do that)."
fi
echo ""
echo "Suggested next steps:"
echo " - push new tag using \"git push --tags\""
echo " - make \"clean\" to avoid re-publishing release bits"
echo " - update \"version\" file for next development version"
echo " - commit that change and push it upstream"
}
#
# Load into p_version the semver version number (e.g., "1.2.3").
#
function pub_load_version
{
echo -n "Loading version number ... "
p_version="$(grep -v '^#' version | head -1)"
[[ -n "$p_version" ]] || fail "failed to read version"
echo "$p_version."
p_dir="$p_root/v$p_version"
}
#
# Run pre-publish sanity checks on the built binaries.
#
function pub_sanity_check
{
pub_sanity_check_file build/ia32/mdb_v8.so
pub_sanity_check_file build/amd64/mdb_v8.so
}
function pub_sanity_check_file
{
local file tmpfile pid i tag version
file="$1"
echo -n "Checking for $file ... "
if [[ ! -f "$file" ]]; then
fail "not found"
else
echo "done."
fi
#
# This is incredibly circuitous (not to mention lame), but we want to
# try to pull a specific string out of the binary, which is not all that
# easy to do.
#
tmpfile=/var/tmp/mdbv8publish.$$
rm -f /var/tmp/mdbv8publish.$$
echo -n "Checking for release tag on "$file" ... "
mdb -S -e '::load '"$file"'; !touch '"$tmpfile"'; ! sleep 300' \
"$file" > /dev/null 2>&1 &
pid="$!"
for (( i = 0; i < 30; i++ )) {
if [[ -f "$tmpfile" ]]; then
break
fi
sleep 1
}
[[ -f "$tmpfile" ]] || fail "failed"
rm -f "$tmpfile"
tag="$(mdb -S -p "$pid" -e '*mdbv8_vers_tag/s' | awk '{print $2}' |
sed -e s'#,##g')"
kill "$pid" > /dev/null 2>&1
echo "\"$tag\""
if [[ "$tag" != "release" ]]; then
fail "does not appear to be a release build (tag "\"$tag\"")"
fi
}
#
# Create a git tag for the current version.
#
function pub_create_tag
{
echo -n "Creating git tag \"v$p_version\" ... "
if ! git tag -a "v$p_version" -m "v$p_version"; then
return 1
fi
echo "done."
}
#
# Check whether the given release exists upstream.
#
function pub_exists_upstream
{
local mls output
echo -n "Listing upstream versions ... "
output="$(mls -j "$p_root" | json -ga name)" || \
fail "failed to list upstream versions"
echo "done."
echo -n "Checking whether $p_version already exists ... "
if echo "$output" | grep "^v$p_version\$" > /dev/null 2>&1; then
echo "yes"
return 0
else
echo "no"
return 1
fi
}
#
# Upload the bits to Manta.
#
function pub_publish
{
echo -n "Uploading bits to Manta ... "
if ! mmkdir -p "$p_dir" || \
! mput -f build/ia32/mdb_v8.so "$p_dir/mdb_v8_ia32.so" || \
! mput -f build/amd64/mdb_v8.so "$p_dir/mdb_v8_amd64.so"; then
fail "failed"
fi
}
#
# Update the "latest" links in Manta.
#
function pub_update_latest
{
echo "$p_dir" | mput "$p_root/latest"
}
main "$@"
| {
"pile_set_name": "Github"
} |
/*++
* NAME
* tls_scache 3
* SUMMARY
* TLS session cache manager
* SYNOPSIS
* #include <tls_scache.h>
*
* TLS_SCACHE *tls_scache_open(dbname, cache_label, verbose, timeout)
* const char *dbname
* const char *cache_label;
* int verbose;
* int timeout;
*
* void tls_scache_close(cache)
* TLS_SCACHE *cache;
*
* int tls_scache_lookup(cache, cache_id, out_session)
* TLS_SCACHE *cache;
* const char *cache_id;
* ACL_VSTRING *out_session;
*
* int tls_scache_update(cache, cache_id, session, session_len)
* TLS_SCACHE *cache;
* const char *cache_id;
* const char *session;
* ssize_t session_len;
*
* int tls_scache_sequence(cache, first_next, out_cache_id,
* ACL_VSTRING *out_session)
* TLS_SCACHE *cache;
* int first_next;
* char **out_cache_id;
* ACL_VSTRING *out_session;
*
* int tls_scache_delete(cache, cache_id)
* TLS_SCACHE *cache;
* const char *cache_id;
* DESCRIPTION
* This module maintains Postfix TLS session cache files.
* each session is stored under a lookup key (hostname or
* session ID).
*
* tls_scache_open() opens the specified TLS session cache
* and returns a handle that must be used for subsequent
* access.
*
* tls_scache_close() closes the specified TLS session cache
* and releases memory that was allocated by tls_scache_open().
*
* tls_scache_lookup() looks up the specified session in the
* specified cache, and applies session timeout restrictions.
* Entries that are too old are silently deleted.
*
* tls_scache_update() updates the specified TLS session cache
* with the specified session information.
*
* tls_scache_sequence() iterates over the specified TLS session
* cache and either returns the first or next entry that has not
* timed out, or returns no data. Entries that are too old are
* silently deleted. Specify TLS_SCACHE_SEQUENCE_NOTHING as the
* third and last argument to disable saving of cache entry
* content or cache entry ID information. This is useful when
* purging expired entries. A result value of zero means that
* the end of the cache was reached.
*
* tls_scache_delete() removes the specified cache entry from
* the specified TLS session cache.
*
* Arguments:
* .IP dbname
* The base name of the session cache file.
* .IP cache_label
* A string that is used in logging and error messages.
* .IP verbose
* Do verbose logging of cache operations? (zero == no)
* .IP timeout
* The time after wich a session cache entry is considered too old.
* .IP first_next
* One of DICT_SEQ_FUN_FIRST (first cache element) or DICT_SEQ_FUN_NEXT
* (next cache element).
* .IP cache_id
* Session cache lookup key.
* .IP session
* Storage for session information.
* .IP session_len
* The size of the session information in bytes.
* .IP out_cache_id
* .IP out_session
* Storage for saving the cache_id or session information of the
* current cache entry.
*
* Specify TLS_SCACHE_DONT_NEED_CACHE_ID to avoid saving
* the session cache ID of the cache entry.
*
* Specify TLS_SCACHE_DONT_NEED_SESSION to avoid
* saving the session information in the cache entry.
* DIAGNOSTICS
* These routines terminate with a fatal run-time error
* for unrecoverable database errors. This allows the
* program to restart and reset the database to an
* empty initial state.
*
* tls_scache_open() never returns on failure. All other
* functions return non-zero on success, zero when the
* operation could not be completed.
* LICENSE
* .ad
* .fi
* The Secure Mailer license must be distributed with this software.
* AUTHOR(S)
* Wietse Venema
* IBM T.J. Watson Research
* P.O. Box 704
* Yorktown Heights, NY 10598, USA
*--*/
#include "StdAfx.h"
#ifdef USE_TLS
#include <string.h>
#include <stddef.h>
#include "dict.h"
/* Global library. */
/* TLS library. */
#include "tls_scache.h"
/* Application-specific. */
/*
* Session cache entry format.
*/
typedef struct {
time_t timestamp; /* time when saved */
char session[1]; /* actually a bunch of bytes */
} TLS_SCACHE_ENTRY;
/*
* SLMs.
*/
#define STR(x) acl_vstring_str(x)
#define LEN(x) ACL_VSTRING_LEN(x)
/* tls_scache_encode - encode TLS session cache entry */
static ACL_VSTRING *tls_scache_encode(TLS_SCACHE *cp, const char *cache_id,
const char *session, ssize_t session_len)
{
TLS_SCACHE_ENTRY *entry;
ACL_VSTRING *hex_data;
ssize_t binary_data_len;
/*
* Assemble the TLS session cache entry.
*
* We could eliminate some copying by using incremental encoding, but
* sessions are so small that it really does not matter.
*/
binary_data_len = session_len + offsetof(TLS_SCACHE_ENTRY, session);
entry = (TLS_SCACHE_ENTRY *) acl_mymalloc(binary_data_len);
entry->timestamp = time((time_t *) 0);
memcpy(entry->session, session, session_len);
/*
* Encode the TLS session cache entry.
*/
hex_data = acl_vstring_alloc(2 * binary_data_len + 1);
acl_hex_encode(hex_data, (char *) entry, binary_data_len);
/*
* Logging.
*/
if (cp->verbose)
acl_msg_info("write %s TLS cache entry %s: time=%ld [data %ld bytes]",
cp->cache_label, cache_id, (long) entry->timestamp,
(long) session_len);
/*
* Clean up.
*/
acl_myfree(entry);
return (hex_data);
}
/* tls_scache_decode - decode TLS session cache entry */
static int tls_scache_decode(TLS_SCACHE *cp, const char *cache_id,
const char *hex_data, ssize_t hex_data_len, ACL_VSTRING *out_session)
{
const char *myname = "tls+scache_decode";
TLS_SCACHE_ENTRY *entry;
ACL_VSTRING *bin_data;
/*
* Sanity check.
*/
if (hex_data_len < (ssize_t) (2 * (offsetof(TLS_SCACHE_ENTRY, session)))) {
acl_msg_warn("%s: %s TLS cache: truncated entry for %s: %.100s",
myname, cp->cache_label, cache_id, hex_data);
return (0);
}
/*
* Disassemble the TLS session cache entry.
*
* No early returns or we have a memory leak.
*/
#define FREE_AND_RETURN(ptr, x) { acl_vstring_free(ptr); return (x); }
bin_data = acl_vstring_alloc(hex_data_len / 2 + 1);
if (acl_hex_decode(bin_data, hex_data, hex_data_len) == 0) {
acl_msg_warn("%s: %s TLS cache: malformed entry for %s: %.100s",
myname, cp->cache_label, cache_id, hex_data);
FREE_AND_RETURN(bin_data, 0);
}
entry = (TLS_SCACHE_ENTRY *) STR(bin_data);
/*
* Logging.
*/
if (cp->verbose)
acl_msg_info("read %s TLS cache entry %s: time=%ld [data %ld bytes]",
cp->cache_label, cache_id, (long) entry->timestamp,
(long) (LEN(bin_data) - offsetof(TLS_SCACHE_ENTRY, session)));
/*
* Other mandatory restrictions.
*/
if (entry->timestamp + cp->timeout < time((time_t *) 0))
FREE_AND_RETURN(bin_data, 0);
/*
* Optional output.
*/
if (out_session != 0)
acl_vstring_memcpy(out_session, entry->session,
LEN(bin_data) - offsetof(TLS_SCACHE_ENTRY, session));
/*
* Clean up.
*/
FREE_AND_RETURN(bin_data, 1);
}
/* tls_scache_lookup - load session from cache */
int tls_scache_lookup(TLS_SCACHE *cp, char *cache_id, ACL_VSTRING *session)
{
char *hex_data;
size_t size;
/*
* Logging.
*/
if (cp->verbose)
acl_msg_info("lookup %s session id=%s", cp->cache_label, cache_id);
/*
* Initialize. Don't leak data.
*/
if (session)
ACL_VSTRING_RESET(session);
/*
* Search the cache database.
*/
if ((DICT_GET(cp->db, cache_id, strlen(cache_id), &hex_data, &size)) == 0)
return (0);
/*
* Decode entry and delete if expired or malformed.
*/
if (tls_scache_decode(cp, cache_id, hex_data, (int) strlen(hex_data), session) == 0) {
tls_scache_delete(cp, cache_id);
acl_myfree(hex_data);
return (0);
} else {
acl_myfree(hex_data);
return (1);
}
}
/* tls_scache_update - save session to cache */
int tls_scache_update(TLS_SCACHE *cp, char *cache_id, const char *buf, ssize_t len)
{
ACL_VSTRING *hex_data;
/*
* Logging.
*/
if (cp->verbose)
acl_msg_info("put %s session id=%s [data %ld bytes]",
cp->cache_label, cache_id, (long) len);
/*
* Encode the cache entry.
*/
hex_data = tls_scache_encode(cp, cache_id, buf, len);
/*
* Store the cache entry.
*
* XXX Berkeley DB supports huge database keys and values. SDBM seems to
* have a finite limit, and DBM simply can't be used at all.
*/
DICT_PUT(cp->db, cache_id, strlen(cache_id), STR(hex_data), LEN(hex_data));
/*
* Clean up.
*/
acl_vstring_free(hex_data);
return (1);
}
/* tls_scache_sequence - get first/next TLS session cache entry */
int tls_scache_sequence(TLS_SCACHE *cp, int first_next,
char **out_cache_id, ACL_VSTRING *out_session)
{
char *member;
char *value;
char *saved_cursor;
int found_entry;
int keep_entry = 0;
char *saved_member = 0;
size_t key_size, val_size;
/*
* XXX Deleting entries while enumerating a map can he tricky. Some map
* types have a concept of cursor and support a "delete the current
* element" operation. Some map types without cursors don't behave well
* when the current first/next entry is deleted (example: with Berkeley
* DB < 2, the "next" operation produces garbage). To avoid trouble, we
* delete an expired entry after advancing the current first/next
* position beyond it, and ignore client requests to delete the current
* entry.
*/
/*
* Find the first or next database entry. Activate the passivated entry
* and check the time stamp. Schedule the entry for deletion if it is too
* old.
*
* Save the member (cache id) so that it will not be clobbered by the
* tls_scache_lookup() call below.
*/
found_entry = (DICT_SEQ(cp->db, first_next, &member, &key_size, &value, &val_size) == 0);
if (found_entry) {
keep_entry = tls_scache_decode(cp, member, value, (int) strlen(value),
out_session);
if (keep_entry && out_cache_id)
*out_cache_id = acl_mystrdup(member);
saved_member = acl_mystrdup(member);
acl_myfree(member);
acl_myfree(value);
}
/*
* Delete behind. This is a no-op if an expired cache entry was updated
* in the mean time. Use the saved lookup criteria so that the "delete
* behind" operation works as promised.
*/
if (cp->flags & TLS_SCACHE_FLAG_DEL_SAVED_CURSOR) {
cp->flags &= ~TLS_SCACHE_FLAG_DEL_SAVED_CURSOR;
saved_cursor = cp->saved_cursor;
cp->saved_cursor = 0;
tls_scache_lookup(cp, saved_cursor, (ACL_VSTRING *) 0);
acl_myfree(saved_cursor);
}
/*
* Otherwise, clean up if this is not the first iteration.
*/
else {
if (cp->saved_cursor)
acl_myfree(cp->saved_cursor);
cp->saved_cursor = 0;
}
/*
* Protect the current first/next entry against explicit or implied
* client delete requests, and schedule a bad or expired entry for
* deletion. Save the lookup criteria so that the "delete behind"
* operation will work as promised.
*/
if (found_entry) {
cp->saved_cursor = saved_member;
if (keep_entry == 0)
cp->flags |= TLS_SCACHE_FLAG_DEL_SAVED_CURSOR;
}
return (found_entry);
}
/* tls_scache_delete - delete session from cache */
int tls_scache_delete(TLS_SCACHE *cp, char *cache_id)
{
/*
* Logging.
*/
if (cp->verbose)
acl_msg_info("delete %s session id=%s", cp->cache_label, cache_id);
/*
* Do it, unless we would delete the current first/next entry. Some map
* types don't have cursors, and some of those don't behave when the
* "current" entry is deleted.
*/
return ((cp->saved_cursor != 0 && strcmp(cp->saved_cursor, cache_id) == 0)
|| DICT_DEL(cp->db, cache_id, strlen(cache_id)) == 0);
}
/* tls_scache_init - init dict */
void tls_scache_init()
{
dict_open_init();
}
/* tls_scache_open - open TLS session cache file */
TLS_SCACHE *tls_scache_open(const char *dbname, const char *cache_label,
int verbose, int timeout)
{
const char *myname = "tls_scache_open";
TLS_SCACHE *cp;
DICT *dict;
/*
* Logging.
*/
if (verbose)
acl_msg_info("open %s TLS cache %s", cache_label, dbname);
/*
* Open the dictionary with O_TRUNC, so that we never have to worry about
* opening a damaged file after some process terminated abnormally.
*/
#ifdef SINGLE_UPDATER
#define DICT_FLAGS (DICT_FLAG_DUP_REPLACE)
#elif defined(ACL_UNIX)
#define DICT_FLAGS \
(DICT_FLAG_DUP_REPLACE | DICT_FLAG_LOCK | DICT_FLAG_SYNC_UPDATE)
#elif defined(WIN32)
#define DICT_FLAGS \
(DICT_FLAG_DUP_REPLACE | DICT_FLAG_SYNC_UPDATE)
#endif
dict = dict_open(dbname, O_RDWR | O_CREAT | O_TRUNC, DICT_FLAGS);
/*
* Sanity checks.
*/
if (dict->lock_fd < 0)
acl_msg_fatal("%s: dictionary %s is not a regular file", myname, dbname);
#ifdef SINGLE_UPDATER
if (acl_myflock(dict->lock_fd, INTERNAL_LOCK,
MYFLOCK_OP_EXCLUSIVE | MYFLOCK_OP_NOWAIT) < 0)
acl_msg_fatal("%s: cannot lock dictionary %s for exclusive use: %s",
myname, dbname, acl_last_serror());
#endif
if (dict->update == 0)
acl_msg_fatal("%s: dictionary %s does not support update operations", myname, dbname);
if (dict->delete_it == 0)
acl_msg_fatal("%s: dictionary %s does not support delete operations", myname, dbname);
if (dict->sequence == 0)
acl_msg_fatal("%s: dictionary %s does not support sequence operations", myname, dbname);
/*
* Create the TLS_SCACHE object.
*/
cp = (TLS_SCACHE *) acl_mymalloc(sizeof(*cp));
cp->flags = 0;
cp->db = dict;
cp->cache_label = acl_mystrdup(cache_label);
cp->verbose = verbose;
cp->timeout = timeout;
cp->saved_cursor = 0;
return (cp);
}
/* tls_scache_close - close TLS session cache file */
void tls_scache_close(TLS_SCACHE *cp)
{
const char *myname = "tls_scache_close";
/*
* Logging.
*/
if (cp->verbose)
acl_msg_info("%s: close %s TLS cache %s",
myname, cp->cache_label, cp->db->name);
/*
* Destroy the TLS_SCACHE object.
*/
DICT_CLOSE(cp->db);
acl_myfree(cp->cache_label);
if (cp->saved_cursor)
acl_myfree(cp->saved_cursor);
acl_myfree(cp);
}
#endif
| {
"pile_set_name": "Github"
} |
/*
* Copyright (C) 2004-2015 FBReader.ORG Limited <[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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef __ZLUNIXFSDIR_H__
#define __ZLUNIXFSDIR_H__
#include "../../filesystem/ZLFSDir.h"
class ZLUnixFSDir : public ZLFSDir {
public:
ZLUnixFSDir(const std::string &name) : ZLFSDir(name) {}
//void collectSubDirs(std::vector<std::string> &names, bool includeSymlinks);
void collectFiles(std::vector<std::string> &names, bool includeSymlinks);
};
#endif /* __ZLUNIXFSDIR_H__ */
| {
"pile_set_name": "Github"
} |
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.h"
#include <stddef.h>
#include <memory>
#include <set>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "base/value_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.h"
#include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service_factory.h"
#include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h"
#include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_factory.h"
#include "chrome/browser/supervised_user/supervised_user_constants.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/user_manager.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
#include "components/signin/core/browser/signin_error_controller.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/referrer.h"
#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
SigninSupervisedUserImportHandler::SigninSupervisedUserImportHandler()
: weak_ptr_factory_(this) {
}
SigninSupervisedUserImportHandler::~SigninSupervisedUserImportHandler() {
}
void SigninSupervisedUserImportHandler::GetLocalizedValues(
base::DictionaryValue* localized_strings) {
DCHECK(localized_strings);
localized_strings->SetString("supervisedUserImportTitle",
l10n_util::GetStringUTF16(
IDS_IMPORT_EXISTING_LEGACY_SUPERVISED_USER_TITLE));
localized_strings->SetString("supervisedUserImportText",
l10n_util::GetStringUTF16(
IDS_IMPORT_EXISTING_LEGACY_SUPERVISED_USER_TEXT));
localized_strings->SetString("noSupervisedUserImportText",
l10n_util::GetStringUTF16(IDS_IMPORT_NO_EXISTING_SUPERVISED_USER_TEXT));
localized_strings->SetString("supervisedUserImportOk",
l10n_util::GetStringUTF16(IDS_IMPORT_EXISTING_LEGACY_SUPERVISED_USER_OK));
localized_strings->SetString("supervisedUserAlreadyOnThisDevice",
l10n_util::GetStringUTF16(
IDS_LEGACY_SUPERVISED_USER_ALREADY_ON_THIS_DEVICE));
}
void SigninSupervisedUserImportHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("getExistingSupervisedUsers",
base::Bind(&SigninSupervisedUserImportHandler::GetExistingSupervisedUsers,
base::Unretained(this)));
web_ui()->RegisterMessageCallback("openUrlInLastActiveProfileBrowser",
base::Bind(
&SigninSupervisedUserImportHandler::OpenUrlInLastActiveProfileBrowser,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"authenticateCustodian",
base::Bind(&SigninSupervisedUserImportHandler::AuthenticateCustodian,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"cancelLoadingSupervisedUsers",
base::Bind(
&SigninSupervisedUserImportHandler::HandleCancelLoadSupervisedUsers,
base::Unretained(this)));
}
void SigninSupervisedUserImportHandler::AssignWebUICallbackId(
const base::ListValue* args) {
CHECK_LE(1U, args->GetSize());
CHECK(webui_callback_id_.empty());
CHECK(args->GetString(0, &webui_callback_id_));
AllowJavascript();
}
void SigninSupervisedUserImportHandler::OpenUrlInLastActiveProfileBrowser(
const base::ListValue* args) {
CHECK_EQ(1U, args->GetSize());
std::string url;
bool success = args->GetString(0, &url);
DCHECK(success);
content::OpenURLParams params(GURL(url),
content::Referrer(),
NEW_FOREGROUND_TAB,
ui::PAGE_TRANSITION_LINK,
false);
// ProfileManager::GetLastUsedProfile() will attempt to load the default
// profile if there is no last used profile. If the default profile is not
// fully loaded and initialized, it will attempt to do so synchronously.
// Therefore we cannot use that method here. If the last used profile is not
// loaded, we do nothing. This is an edge case and should not happen often.
ProfileManager* profile_manager = g_browser_process->profile_manager();
base::FilePath last_used_profile_dir =
profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir());
Profile* last_used_profile =
profile_manager->GetProfileByPath(last_used_profile_dir);
if (last_used_profile) {
// Last used profile may be the Guest Profile.
if (ProfileManager::IncognitoModeForced(last_used_profile))
last_used_profile = last_used_profile->GetOffTheRecordProfile();
// Get the browser owned by the last used profile or create a new one if
// it doesn't exist.
Browser* browser = chrome::FindLastActiveWithProfile(last_used_profile);
if (!browser)
browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED,
last_used_profile));
browser->OpenURL(params);
}
}
void SigninSupervisedUserImportHandler::AuthenticateCustodian(
const base::ListValue* args) {
CHECK_EQ(1U, args->GetSize());
std::string email;
bool success = args->GetString(0, &email);
DCHECK(success);
UserManager::ShowReauthDialog(
web_ui()->GetWebContents()->GetBrowserContext(), email,
signin_metrics::Reason::REASON_REAUTHENTICATION);
}
void SigninSupervisedUserImportHandler::GetExistingSupervisedUsers(
const base::ListValue* args) {
CHECK_EQ(2U, args->GetSize());
AssignWebUICallbackId(args);
base::FilePath custodian_profile_path;
const base::Value* profile_path_value;
bool success = args->Get(1, &profile_path_value);
DCHECK(success);
success = base::GetValueAsFilePath(*profile_path_value,
&custodian_profile_path);
DCHECK(success);
// Load custodian profile.
g_browser_process->profile_manager()->CreateProfileAsync(
custodian_profile_path,
base::Bind(
&SigninSupervisedUserImportHandler::LoadCustodianProfileCallback,
weak_ptr_factory_.GetWeakPtr()),
base::string16(), std::string(), std::string());
}
void SigninSupervisedUserImportHandler::HandleCancelLoadSupervisedUsers(
const base::ListValue* args) {
webui_callback_id_.clear();
}
void SigninSupervisedUserImportHandler::LoadCustodianProfileCallback(
Profile* profile, Profile::CreateStatus status) {
// This method gets called once before with Profile::CREATE_STATUS_CREATED.
switch (status) {
case Profile::CREATE_STATUS_LOCAL_FAIL: {
RejectCallback(GetLocalErrorMessage());
break;
}
case Profile::CREATE_STATUS_CREATED: {
// Ignore the intermediate status.
break;
}
case Profile::CREATE_STATUS_INITIALIZED: {
// We are only interested in Profile::CREATE_STATUS_INITIALIZED when
// everything is ready.
if (profile->IsSupervised()) {
webui_callback_id_.clear();
return;
}
if (!IsAccountConnected(profile) || HasAuthError(profile)) {
RejectCallback(GetAuthErrorMessage(profile));
return;
}
SupervisedUserSyncService* supervised_user_sync_service =
SupervisedUserSyncServiceFactory::GetForProfile(profile);
if (supervised_user_sync_service) {
supervised_user_sync_service->GetSupervisedUsersAsync(
base::Bind(
&SigninSupervisedUserImportHandler::SendExistingSupervisedUsers,
weak_ptr_factory_.GetWeakPtr(), profile));
}
break;
}
case Profile::CREATE_STATUS_CANCELED:
case Profile::CREATE_STATUS_REMOTE_FAIL:
case Profile::MAX_CREATE_STATUS: {
NOTREACHED();
break;
}
}
}
void SigninSupervisedUserImportHandler::RejectCallback(
const base::string16& error) {
RejectJavascriptCallback(
base::StringValue(webui_callback_id_),
base::StringValue(error));
webui_callback_id_.clear();
}
base::string16 SigninSupervisedUserImportHandler::GetLocalErrorMessage() const {
return l10n_util::GetStringUTF16(
IDS_LEGACY_SUPERVISED_USER_IMPORT_LOCAL_ERROR);
}
base::string16 SigninSupervisedUserImportHandler::GetAuthErrorMessage(
Profile* profile) const {
return l10n_util::GetStringFUTF16(
IDS_PROFILES_CREATE_CUSTODIAN_ACCOUNT_DETAILS_OUT_OF_DATE_ERROR,
base::ASCIIToUTF16(profile->GetProfileUserName()));
}
void SigninSupervisedUserImportHandler::SendExistingSupervisedUsers(
Profile* profile,
const base::DictionaryValue* dict) {
DCHECK(dict);
std::vector<ProfileAttributesEntry*> entries =
g_browser_process->profile_manager()->GetProfileAttributesStorage().
GetAllProfilesAttributes();
// Collect the ids of local supervised user profiles.
std::set<std::string> supervised_user_ids;
for (auto& entry : entries) {
// Filter out omitted profiles. These are currently being imported, and
// shouldn't show up as "already on this device" just yet.
if (entry->IsLegacySupervised() && !entry->IsOmitted()) {
supervised_user_ids.insert(entry->GetSupervisedUserId());
}
}
base::ListValue supervised_users;
SupervisedUserSharedSettingsService* service =
SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(profile);
for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
const base::DictionaryValue* value = NULL;
bool success = it.value().GetAsDictionary(&value);
DCHECK(success);
std::string name;
value->GetString(SupervisedUserSyncService::kName, &name);
std::unique_ptr<base::DictionaryValue> supervised_user(
new base::DictionaryValue);
supervised_user->SetString("id", it.key());
supervised_user->SetString("name", name);
int avatar_index = SupervisedUserSyncService::kNoAvatar;
const base::Value* avatar_index_value =
service->GetValue(it.key(), supervised_users::kChromeAvatarIndex);
if (avatar_index_value) {
success = avatar_index_value->GetAsInteger(&avatar_index);
} else {
// Check if there is a legacy avatar index stored.
std::string avatar_str;
value->GetString(SupervisedUserSyncService::kChromeAvatar, &avatar_str);
success =
SupervisedUserSyncService::GetAvatarIndex(avatar_str, &avatar_index);
}
DCHECK(success);
std::string avatar_url =
avatar_index == SupervisedUserSyncService::kNoAvatar ?
profiles::GetDefaultAvatarIconUrl(
profiles::GetPlaceholderAvatarIndex()) :
profiles::GetDefaultAvatarIconUrl(avatar_index);
supervised_user->SetString("iconURL", avatar_url);
bool on_current_device =
supervised_user_ids.find(it.key()) != supervised_user_ids.end();
supervised_user->SetBoolean("onCurrentDevice", on_current_device);
supervised_users.Append(std::move(supervised_user));
}
// Resolve callback with response.
ResolveJavascriptCallback(
base::StringValue(webui_callback_id_),
supervised_users);
webui_callback_id_.clear();
}
bool SigninSupervisedUserImportHandler::IsAccountConnected(
Profile* profile) const {
SigninManagerBase* signin_manager =
SigninManagerFactory::GetForProfile(profile);
return signin_manager && signin_manager->IsAuthenticated();
}
bool SigninSupervisedUserImportHandler::HasAuthError(Profile* profile) const {
SigninErrorController* error_controller =
SigninErrorControllerFactory::GetForProfile(profile);
if (!error_controller)
return true;
GoogleServiceAuthError::State state = error_controller->auth_error().state();
return state != GoogleServiceAuthError::NONE;
}
| {
"pile_set_name": "Github"
} |
fileFormatVersion: 2
guid: 54a777298baef2c4f9c84ebdc5c57029
NativeFormatImporter:
userData:
assetBundleName:
| {
"pile_set_name": "Github"
} |
OSX_MIN_VERSION=10.8
OSX_SDK_VERSION=10.11
OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk
LD64_VERSION=253.9
darwin_CC=clang -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION)
darwin_CXX=clang++ -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -stdlib=libc++
darwin_CFLAGS=-pipe
darwin_CXXFLAGS=$(darwin_CFLAGS)
darwin_release_CFLAGS=-O2
darwin_release_CXXFLAGS=$(darwin_release_CFLAGS)
darwin_debug_CFLAGS=-O1
darwin_debug_CXXFLAGS=$(darwin_debug_CFLAGS)
darwin_native_toolchain=native_cctools
| {
"pile_set_name": "Github"
} |
using System.Linq;
using System.Text;
using PrtgAPI.Utilities;
namespace PrtgAPI.Tests.UnitTests.Support.TestResponses
{
public class SensorTypeResponse : IWebResponse
{
public string GetResponseText(ref string address)
{
var builder = new StringBuilder();
builder.Append("{ ");
builder.Append(" \"sensortypes\":[ ");
builder.Append(" { ");
builder.Append(" \"id\":\"ptfadsreplfailurexml\",");
builder.Append(" \"name\":\"Active Directory Replication Errors\",");
builder.Append(" \"family\":[ ");
builder.Append(" \"Availability/Uptime\",");
builder.Append(" \"Network Infrastructure\",");
builder.Append(" \"WMI\",");
builder.Append(" \"Windows\"");
builder.Append(" ],");
builder.Append(" \"description\":\"Checks Windows domain controllers for replication errors\",");
builder.Append(" \"help\":\"Needs .NET 4.0 installed on the computer running the PRTG probe and valid credentials for Windows systems defined in the parent device or group settings.\",");
builder.Append(" \"manuallink\":\"/help/active_directory_replication_errors_sensor.htm\",");
builder.Append(" \"needsprobe\":true,");
builder.Append(" \"needslocalprobe\":false,");
builder.Append(" \"needsprobedevice\":false,");
builder.Append(" \"needsvm\":false,");
builder.Append(" \"needslinux\":false,");
builder.Append(" \"needswindows\":true,");
builder.Append(" \"dotnetversion\":40,");
builder.Append(" \"notincluster\":false,");
builder.Append(" \"notonpod\":true,");
builder.Append(" \"ipv6\":true,");
builder.Append(" \"top10\":0,");
builder.Append(" \"message\":\"\",");
builder.Append(" \"resourceusage\":4,");
builder.Append(" \"linux\":false,");
builder.Append(" \"metascan\":true,");
builder.Append(" \"templatesupport\":true,");
builder.Append(" \"preselection\":false");
builder.Append(" },");
builder.Append(" { ");
builder.Append(" \"id\":\"adosqlv2\",");
builder.Append(" \"name\":\"ADO SQL v2\",");
builder.Append(" \"family\":[ ");
builder.Append(" \"LAN\",");
builder.Append(" \"Availability/Uptime\",");
builder.Append(" \"Database\",");
builder.Append(" \"Windows\"");
builder.Append(" ],");
builder.Append(" \"description\":\"Monitors any data source that is available via OLE DB or ODBC\",");
builder.Append(" \"help\":\"Needs .NET 4.0 installed on the computer running the PRTG probe.\",");
builder.Append(" \"manuallink\":\"/help/ado_sql_v2_sensor.htm\",");
builder.Append(" \"needsprobe\":true,");
builder.Append(" \"needslocalprobe\":false,");
builder.Append(" \"needsprobedevice\":false,");
builder.Append(" \"needsvm\":false,");
builder.Append(" \"needslinux\":false,");
builder.Append(" \"needswindows\":false,");
builder.Append(" \"dotnetversion\":40,");
builder.Append(" \"notincluster\":false,");
builder.Append(" \"notonpod\":true,");
builder.Append(" \"ipv6\":true,");
builder.Append(" \"top10\":0,");
builder.Append(" \"message\":\"\",");
builder.Append(" \"resourceusage\":4,");
builder.Append(" \"linux\":false,");
builder.Append(" \"metascan\":true,");
builder.Append(" \"templatesupport\":true,");
builder.Append(" \"preselection\":false");
builder.Append(" },");
builder.Append(" { ");
builder.Append(" \"id\":\"cloudwatchalarm\",");
builder.Append(" \"name\":\"Amazon CloudWatch Alarm BETA\",");
builder.Append(" \"family\":[ ");
builder.Append(" \"WAN\",");
builder.Append(" \"Bandwidth/Traffic\",");
builder.Append(" \"Speed/Performance\",");
builder.Append(" \"Disk Usage\",");
builder.Append(" \"CPU Usage\",");
builder.Append(" \"TCP\",");
builder.Append(" \"Cloud Services\"");
builder.Append(" ],");
builder.Append(" \"description\":\"Monitors the status of an Amazon CloudWatch alarm by reading its data from the AWS CloudWatch API\",");
builder.Append(" \"help\":\"Provide your credentials for Amazon CloudWatch in the settings of the parent device. You need .NET 4.5 installed on the computer running the PRTG probe.\",");
builder.Append(" \"manuallink\":\"/help/amazon_cloudwatch_alarm_sensor.htm\",");
builder.Append(" \"needsprobe\":true,");
builder.Append(" \"needslocalprobe\":false,");
builder.Append(" \"needsprobedevice\":false,");
builder.Append(" \"needsvm\":false,");
builder.Append(" \"needslinux\":false,");
builder.Append(" \"needswindows\":false,");
builder.Append(" \"dotnetversion\":45,");
builder.Append(" \"notincluster\":false,");
builder.Append(" \"notonpod\":false,");
builder.Append(" \"ipv6\":true,");
builder.Append(" \"top10\":0,");
builder.Append(" \"message\":\"\",");
builder.Append(" \"resourceusage\":3,");
builder.Append(" \"linux\":false,");
builder.Append(" \"metascan\":true,");
builder.Append(" \"templatesupport\":true,");
builder.Append(" \"preselection\":false");
builder.Append(" },");
builder.Append(" { ");
builder.Append(" \"id\":\"snmplibrary\",");
builder.Append(" \"name\":\"SNMP Library\",");
builder.Append(" \"family\":[ ");
builder.Append(" \"LAN\",");
builder.Append(" \"Hardware Parameters\",");
builder.Append(" \"SNMP\",");
builder.Append(" \"Windows\",");
builder.Append(" \"Linux/MacOS\",");
builder.Append(" \"Custom Sensors\"");
builder.Append(" ],");
builder.Append(" \"description\":\"Monitors a device using SNMP and compiled MIB files (\\\\'\\\"SNMP Libraries(oidlib)\\\\'\\\")\",");
builder.Append(" \"help\":\"Monitors Cisco interfaces and queue, Dell systems and storages, APC UPS (battery ems status), Linux (AX BGP DisMan EtherLike Host Framework Proxy Noti v2 IP Net Noti OSPF RMON SMUX Source TCP UCD UDP), etc. as well as any other SNMP devices using your imported MIB files.\",");
builder.Append(" \"manuallink\":\"/help/snmp_library_sensor.htm\",");
builder.Append(" \"needsprobe\":true,");
builder.Append(" \"needslocalprobe\":false,");
builder.Append(" \"needsprobedevice\":false,");
builder.Append(" \"needsvm\":false,");
builder.Append(" \"needslinux\":false,");
builder.Append(" \"needswindows\":false,");
builder.Append(" \"dotnetversion\":-1,");
builder.Append(" \"notincluster\":false,");
builder.Append(" \"notonpod\":false,");
builder.Append(" \"ipv6\":true,");
builder.Append(" \"top10\":0,");
builder.Append(" \"message\":\"\",");
builder.Append(" \"resourceusage\":1,");
builder.Append(" \"linux\":true,");
builder.Append(" \"metascan\":true,");
builder.Append(" \"templatesupport\":true,");
builder.Append(" \"preselection\":true,");
builder.Append(" \"preselectionlist\":\"%3Cselect%20class%3D%22combo%22%20%20name%3D%22preselection_snmplibrary%22%20id%3D%22preselection_snmplibrary%22%20%3E%3Coption%20value%3D%22%22%20selected%3D%22selected%22%20%3E%26lt%3Bplease%20select%20a%20file%26gt%3B%3C%2Foption%3E%3Coption%20value%3D%22APC%20UPS.oidlib%22%3EApc%20ups.oidlib%3C%2Foption%3E%3Coption%20value%3D%22APCSensorstationlib.oidlib%22%3EApcsensorstationlib.oidlib%3C%2Foption%3E%3Coption%20value%3D%22Basic%20Linux%20Library%20%28UCD-SNMP-MIB%29.oidlib%22%3EBasic%20linux%20library%20%28ucd-snmp-mib%29.oidlib%3C%2Foption%3E%3Coption%20value%3D%22cisco-interfaces.oidlib%22%3ECisco-interfaces.oidlib%3C%2Foption%3E%3Coption%20value%3D%22cisco-queue.oidlib%22%3ECisco-queue.oidlib%3C%2Foption%3E%3Coption%20value%3D%22Dell%20Storage%20Management.oidlib%22%3EDell%20storage%20management.oidlib%3C%2Foption%3E%3Coption%20value%3D%22Dell%20Systems%20Management%20Instrumentation.oidlib%22%3EDell%20systems%20management%20instrumentation.oidlib%3C%2Foption%3E%3Coption%20value%3D%22HP%20Laserjet%20Status.oidlib%22%3EHp%20laserjet%20status.oidlib%3C%2Foption%3E%3Coption%20value%3D%22Linux%20SNMP%20%28AX%20BGP%20DisMan%20EtherLike%20Host%29.oidlib%22%3ELinux%20snmp%20%28ax%20bgp%20disman%20etherlike%20host%29.oidlib%3C%2Foption%3E%3Coption%20value%3D%22Linux%20SNMP%20%28Framework%20Proxy%20Noti%20v2%29.oidlib%22%3ELinux%20snmp%20%28framework%20proxy%20noti%20v2%29.oidlib%3C%2Foption%3E%3Coption%20value%3D%22Linux%20SNMP%20%28IP%20Net%20SNMP%20Noti%20OSPF%20RMON%20SMUX%29.oidlib%22%3ELinux%20snmp%20%28ip%20net%20snmp%20noti%20ospf%20rmon%20smux%29.oidlib%3C%2Foption%3E%3Coption%20value%3D%22Linux%20SNMP%20%28Source%20TCP%20UCD%20UDP%29.oidlib%22%3ELinux%20snmp%20%28source%20tcp%20ucd%20udp%29.oidlib%3C%2Foption%3E%3Coption%20value%3D%22Paessler%20Common%20OID%20Library.oidlib%22%3EPaessler%20common%20oid%20library.oidlib%3C%2Foption%3E%3Coption%20value%3D%22PAN.oidlib%22%3EPan.oidlib%3C%2Foption%3E%3Coption%20value%3D%22SNMP%20Informant%20Std.oidlib%22%3ESnmp%20informant%20std.oidlib%3C%2Foption%3E%3C%2Fselect%3E\"");
builder.Append(" }");
builder.Append(AddSupported());
builder.Append(" ]");
builder.Append("}");
return builder.ToString();
}
private string AddSupported()
{
var types = typeof(SensorType).GetEnumValues().Cast<SensorType>().Select(v => v.EnumToXml());
var builder = new StringBuilder();
foreach (var type in types)
{
builder.Append(",");
builder.Append(" { ");
builder.Append($" \"id\":\"{type}\",");
builder.Append(" \"name\":\"Amazon CloudWatch Alarm BETA\",");
builder.Append(" \"family\":[ ");
builder.Append(" \"WAN\",");
builder.Append(" \"Bandwidth/Traffic\",");
builder.Append(" \"Speed/Performance\",");
builder.Append(" \"Disk Usage\",");
builder.Append(" \"CPU Usage\",");
builder.Append(" \"TCP\",");
builder.Append(" \"Cloud Services\"");
builder.Append(" ],");
builder.Append(" \"description\":\"Monitors the status of an Amazon CloudWatch alarm by reading its data from the AWS CloudWatch API\",");
builder.Append(" \"help\":\"Provide your credentials for Amazon CloudWatch in the settings of the parent device. You need .NET 4.5 installed on the computer running the PRTG probe.\",");
builder.Append(" \"manuallink\":\"/help/amazon_cloudwatch_alarm_sensor.htm\",");
builder.Append(" \"needsprobe\":true,");
builder.Append(" \"needslocalprobe\":false,");
builder.Append(" \"needsprobedevice\":false,");
builder.Append(" \"needsvm\":false,");
builder.Append(" \"needslinux\":false,");
builder.Append(" \"needswindows\":false,");
builder.Append(" \"dotnetversion\":45,");
builder.Append(" \"notincluster\":false,");
builder.Append(" \"notonpod\":false,");
builder.Append(" \"ipv6\":true,");
builder.Append(" \"top10\":0,");
builder.Append(" \"message\":\"\",");
builder.Append(" \"resourceusage\":3,");
builder.Append(" \"linux\":false,");
builder.Append(" \"metascan\":true,");
builder.Append(" \"templatesupport\":true,");
builder.Append(" \"preselection\":false");
builder.Append(" }");
}
return builder.ToString();
}
}
}
| {
"pile_set_name": "Github"
} |
package org.hypergraphdb.storage.bje;
import com.sleepycat.je.DatabaseConfig;
import com.sleepycat.je.Durability;
import com.sleepycat.je.EnvironmentConfig;
public class BJEConfig
{
// public static final long DEFAULT_STORE_CACHE = 20*1024*1024; // 20MB
public static final long DEFAULT_STORE_CACHE = 100 * 1024 * 1024; // 100MB
// Alain
// for
// tests
public static final int DEFAULT_NUMBER_OF_STORAGE_CACHES = 1;
private EnvironmentConfig envConfig;
private DatabaseConfig dbConfig;
private void resetDefaults(boolean readOnly)
{
envConfig.setReadOnly(readOnly);
dbConfig.setReadOnly(readOnly);
envConfig.setAllowCreate(!readOnly);
dbConfig.setAllowCreate(!readOnly);
// envConfig.setCacheSize(DEFAULT_STORE_CACHE);
envConfig.setCachePercent(30);
envConfig.setConfigParam(EnvironmentConfig.LOG_FILE_MAX,
Long.toString(10000000 * 10l));
envConfig.setConfigParam(
EnvironmentConfig.CLEANER_LOOK_AHEAD_CACHE_SIZE,
Long.toString(1024 * 1024));
envConfig.setConfigParam(EnvironmentConfig.CLEANER_READ_SIZE,
Long.toString(1024 * 1024));
}
public BJEConfig()
{
envConfig = new EnvironmentConfig();
dbConfig = new DatabaseConfig();
resetDefaults(false);
}
public EnvironmentConfig getEnvironmentConfig()
{
return envConfig;
}
public DatabaseConfig getDatabaseConfig()
{
return dbConfig;
}
public void configureTransactional()
{
envConfig.setTransactional(true);
dbConfig.setTransactional(true);
// envConfig.setLockDetectMode(LockDetectMode.RANDOM);
Durability defaultDurability = new Durability(
Durability.SyncPolicy.WRITE_NO_SYNC,
Durability.SyncPolicy.NO_SYNC, // unused by non-HA applications.
Durability.ReplicaAckPolicy.NONE); // unused by non-HA
// applications.
envConfig.setDurability(defaultDurability);
}
} | {
"pile_set_name": "Github"
} |
#include "Common.h"
/*int main(int, char** argv)
{
int i, n = atoi(argv[1]);
N_Body_System system;
printf("%.9f\n", system.energy());
for (i = 0; i < n; ++i)
system.advance(0.01);
printf("%.9f\n", system.energy());
return 0;
}*/
void NBody(int n);
void FastaRedux(int n);
void FannkuchRedux(int max_n);
USING_NS_BF;
BF_EXPORT void BF_CALLTYPE BFApp_RunPerfTest(const char* testName, int arg)
{
if (strcmp(testName, "nbody") == 0)
NBody(arg);
if (strcmp(testName, "fastaredux") == 0)
FastaRedux(arg);
if (strcmp(testName, "fannkuchredux") == 0)
FannkuchRedux(arg);
}
| {
"pile_set_name": "Github"
} |
require('../../modules/es7.error.is-error');
module.exports = require('../../modules/_core').Error;
| {
"pile_set_name": "Github"
} |
.0 2567.0
363.2 2605.8
1113.1 2671.4
1802.0 2706.2
2674.5 2724.7
3630.6 2739.2
4629.7 2726.9
5543.8 2686.2
6456.7 2617.0
6884.8 2579.3
7756.6 2474.9
8346.2 2364.8
9038.2 2208.2
9656.5 2044.8
10001.5 1936.2
10409.7 1790.2
10550.3 1732.2
10796.4 1619.6
11069.2 1491.1
11383.4 1364.8
11749.7 1266.4
12104.3 1220.4
12251.5 1214.7
12408.8 1218.1
12579.6 1235.0
12945.3 1326.6
13278.9 1474.8
13618.3 1675.2
13906.1 1867.7
14185.2 2061.4
14499.9 2273.4
14890.2 2514.8
15174.2 2670.1
15430.4 2788.5
15584.1 2845.9
15846.8 2918.1
16513.2 3015.9
17200.0 3079.1
17933.0 3119.0
18492.7 3114.8
19135.4 3089.7
19741.6 3068.5
20391.2 3036.2
20929.6 2987.1
21650.3 2890.7
22221.5 2823.9
22760.0 2767.7
23441.6 2688.0
23811.9 2649.8
24000.0 2638.1
1 -99999
.0 4487.7
246.1 4491.5
1121.2 4488.4
1931.6 4459.6
2916.3 4416.8
3695.9 4363.6
4404.1 4295.7
5106.2 4216.4
5703.2 4125.6
6306.6 4012.2
7233.9 3781.1
7967.3 3562.5
8613.6 3321.5
9113.0 3030.5
9753.5 2520.5
10281.7 2064.7
10476.1 1904.2
10705.2 1731.9
10911.0 1598.0
11224.4 1439.2
11573.3 1325.7
11909.9 1266.4
12251.5 1247.4
12579.6 1270.4
12945.3 1361.1
13278.9 1507.0
13618.3 1705.8
13906.1 1897.3
14185.2 2089.9
14499.9 2299.9
14890.2 2539.6
15293.3 2762.2
15584.1 2904.6
16223.4 3166.7
16869.1 3396.6
17411.1 3559.4
17935.1 3687.1
18471.1 3789.6
19018.1 3882.8
19617.9 3955.5
20296.5 4006.2
20989.0 4051.4
21586.4 4068.1
22344.0 4065.9
22924.7 4070.0
23441.0 4073.0
23847.1 4077.5
24000.0 4090.1
1 -99999
.0 6625.3
314.1 6591.2
697.8 6550.2
1169.3 6508.3
1604.2 6473.1
2022.4 6434.4
2522.9 6374.7
3168.0 6302.2
3930.0 6233.1
4659.4 6173.0
5441.2 6100.0
6207.5 6041.6
6844.6 5948.3
7524.2 5809.9
7827.1 5739.3
8385.5 5600.8
9007.8 5452.2
9789.2 5272.1
10459.6 5148.8
10962.8 5063.8
11530.3 4973.9
11863.3 4915.5
12361.0 4835.7
12555.3 4812.9
12806.4 4800.6
13057.3 4831.6
13247.7 4909.2
13489.1 5096.3
13930.2 5622.1
14164.7 5854.9
15277.2 6025.2
16471.5 6017.1
17529.2 6056.0
18516.1 6086.2
19556.7 6115.2
20479.7 6136.5
21461.9 6136.8
21988.7 6135.6
22592.0 6123.3
23295.5 6108.9
23795.2 6108.1
24000.0 6119.9
1 -99999
.0 9446.6
651.0 9307.6
1320.3 9182.7
2223.7 9025.9
3010.1 8860.6
3859.0 8664.3
4094.2 8660.8
4373.6 8738.2
4675.5 8911.5
4862.0 9021.0
5204.0 9149.7
5918.3 9108.2
6541.4 8956.7
7232.6 8787.5
7647.4 8822.9
7959.1 8970.7
8310.0 9149.3
8599.6 9210.7
9098.7 9150.2
9697.2 8974.7
10248.6 8792.8
10723.2 8700.8
11051.6 8770.3
11478.0 9056.6
11679.2 9183.6
12226.1 9292.4
12741.7 9177.7
12951.0 9109.2
13329.6 8968.7
13849.2 8761.6
14334.9 8686.0
14595.7 8767.5
14926.9 8959.4
15195.4 9083.4
15644.0 9102.8
15875.7 9046.3
16417.1 8861.5
16855.5 8711.3
17339.7 8620.6
17623.3 8680.5
17901.2 8842.3
18163.8 9015.6
18500.9 9147.0
19240.1 9068.1
20105.2 8847.5
21129.7 8598.1
22165.3 8382.0
23005.8 8231.7
23574.4 8107.2
24000.0 8036.2
1 -99999
16.3 11266.4
23844.2 11314.8
25000.0 11320.0
1 -99999
| {
"pile_set_name": "Github"
} |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>OpenNSL API Guide and Reference Manual: _shr_switch_temperature_monitor_s Struct Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen_brcm.css" rel="stylesheet" type="text/css" />
<link href="tabs_brcm.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">OpenNSL API Guide and Reference Manual
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.2 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Welcome</span></a></li>
<li><a href="pages.html"><span>OpenNSL Documentation</span></a></li>
<li><a href="modules.html"><span>API Reference</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="functions.html"><span>Data Fields</span></a></li>
</ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-attribs">Data Fields</a> </div>
<div class="headertitle">
<div class="title">_shr_switch_temperature_monitor_s Struct Reference</div> </div>
</div><!--header-->
<div class="contents">
<p><code>#include <<a class="el" href="shared_2switch_8h_source.html">switch.h</a>></code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-attribs"></a>
Data Fields</h2></td></tr>
<tr class="memitem:a01a37ce4984e45481ff95c56d4b9b6cc"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="struct__shr__switch__temperature__monitor__s.html#a01a37ce4984e45481ff95c56d4b9b6cc">curr</a></td></tr>
<tr class="separator:a01a37ce4984e45481ff95c56d4b9b6cc"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a64bdf69261e2c2b3fe4894fe68ca0c9e"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="struct__shr__switch__temperature__monitor__s.html#a64bdf69261e2c2b3fe4894fe68ca0c9e">peak</a></td></tr>
<tr class="separator:a64bdf69261e2c2b3fe4894fe68ca0c9e"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock">
<p>Definition at line <a class="el" href="shared_2switch_8h_source.html#l00040">40</a> of file <a class="el" href="shared_2switch_8h_source.html">switch.h</a>.</p>
</div><h2 class="groupheader">Field Documentation</h2>
<a class="anchor" id="a01a37ce4984e45481ff95c56d4b9b6cc"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int _shr_switch_temperature_monitor_s::curr</td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="shared_2switch_8h_source.html#l00041">41</a> of file <a class="el" href="shared_2switch_8h_source.html">switch.h</a>.</p>
</div>
</div>
<a class="anchor" id="a64bdf69261e2c2b3fe4894fe68ca0c9e"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int _shr_switch_temperature_monitor_s::peak</td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="shared_2switch_8h_source.html#l00042">42</a> of file <a class="el" href="shared_2switch_8h_source.html">switch.h</a>.</p>
</div>
</div>
<hr/>The documentation for this struct was generated from the following file:<ul>
<li>include/shared/<a class="el" href="shared_2switch_8h_source.html">switch.h</a></li>
</ul>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.5-->
<!-- start footer part -->
<!--BEGIN GENERATE_TREEVIEW -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<hr>
<p>
<table class="footer-brcm">
<tr>
<td class="footer-brcm"><img src="BRCM_Red+Black_noTag_RGB.png" align=left></td>
<td class="footer-brcm"><small><b>© 2016-17 by Broadcom Limited. All rights reserved.</b></small>
<div class="footer-brcm"><small>Broadcom Limited reserves the right to make changes without further notice to any products or data herein to improve reliability, function, or design.
Information furnished by Broadcom Limited is believed to be accurate and reliable. However, Broadcom Limited does not assume any liability arising
out of the application or use of this information, nor the application or use of any product or circuit described herein, neither does it convey any license
under its patent rights nor the rights of others. </small>
</div>
</td>
</tr>
</table>
</p>
</div>
<!--END GENERATE_TREEVIEW-->
</body>
</html>
| {
"pile_set_name": "Github"
} |
// mksysctl_openbsd.pl
// Code generated by the command above; DO NOT EDIT.
package unix
type mibentry struct {
ctlname string
ctloid []_C_int
}
var sysctlMib = []mibentry{
{"ddb.console", []_C_int{9, 6}},
{"ddb.log", []_C_int{9, 7}},
{"ddb.max_line", []_C_int{9, 3}},
{"ddb.max_width", []_C_int{9, 2}},
{"ddb.panic", []_C_int{9, 5}},
{"ddb.radix", []_C_int{9, 1}},
{"ddb.tab_stop_width", []_C_int{9, 4}},
{"ddb.trigger", []_C_int{9, 8}},
{"fs.posix.setuid", []_C_int{3, 1, 1}},
{"hw.allowpowerdown", []_C_int{6, 22}},
{"hw.byteorder", []_C_int{6, 4}},
{"hw.cpuspeed", []_C_int{6, 12}},
{"hw.diskcount", []_C_int{6, 10}},
{"hw.disknames", []_C_int{6, 8}},
{"hw.diskstats", []_C_int{6, 9}},
{"hw.machine", []_C_int{6, 1}},
{"hw.model", []_C_int{6, 2}},
{"hw.ncpu", []_C_int{6, 3}},
{"hw.ncpufound", []_C_int{6, 21}},
{"hw.pagesize", []_C_int{6, 7}},
{"hw.physmem", []_C_int{6, 19}},
{"hw.product", []_C_int{6, 15}},
{"hw.serialno", []_C_int{6, 17}},
{"hw.setperf", []_C_int{6, 13}},
{"hw.usermem", []_C_int{6, 20}},
{"hw.uuid", []_C_int{6, 18}},
{"hw.vendor", []_C_int{6, 14}},
{"hw.version", []_C_int{6, 16}},
{"kern.arandom", []_C_int{1, 37}},
{"kern.argmax", []_C_int{1, 8}},
{"kern.boottime", []_C_int{1, 21}},
{"kern.bufcachepercent", []_C_int{1, 72}},
{"kern.ccpu", []_C_int{1, 45}},
{"kern.clockrate", []_C_int{1, 12}},
{"kern.consdev", []_C_int{1, 75}},
{"kern.cp_time", []_C_int{1, 40}},
{"kern.cp_time2", []_C_int{1, 71}},
{"kern.cryptodevallowsoft", []_C_int{1, 53}},
{"kern.domainname", []_C_int{1, 22}},
{"kern.file", []_C_int{1, 73}},
{"kern.forkstat", []_C_int{1, 42}},
{"kern.fscale", []_C_int{1, 46}},
{"kern.fsync", []_C_int{1, 33}},
{"kern.hostid", []_C_int{1, 11}},
{"kern.hostname", []_C_int{1, 10}},
{"kern.intrcnt.nintrcnt", []_C_int{1, 63, 1}},
{"kern.job_control", []_C_int{1, 19}},
{"kern.malloc.buckets", []_C_int{1, 39, 1}},
{"kern.malloc.kmemnames", []_C_int{1, 39, 3}},
{"kern.maxclusters", []_C_int{1, 67}},
{"kern.maxfiles", []_C_int{1, 7}},
{"kern.maxlocksperuid", []_C_int{1, 70}},
{"kern.maxpartitions", []_C_int{1, 23}},
{"kern.maxproc", []_C_int{1, 6}},
{"kern.maxthread", []_C_int{1, 25}},
{"kern.maxvnodes", []_C_int{1, 5}},
{"kern.mbstat", []_C_int{1, 59}},
{"kern.msgbuf", []_C_int{1, 48}},
{"kern.msgbufsize", []_C_int{1, 38}},
{"kern.nchstats", []_C_int{1, 41}},
{"kern.netlivelocks", []_C_int{1, 76}},
{"kern.nfiles", []_C_int{1, 56}},
{"kern.ngroups", []_C_int{1, 18}},
{"kern.nosuidcoredump", []_C_int{1, 32}},
{"kern.nprocs", []_C_int{1, 47}},
{"kern.nselcoll", []_C_int{1, 43}},
{"kern.nthreads", []_C_int{1, 26}},
{"kern.numvnodes", []_C_int{1, 58}},
{"kern.osrelease", []_C_int{1, 2}},
{"kern.osrevision", []_C_int{1, 3}},
{"kern.ostype", []_C_int{1, 1}},
{"kern.osversion", []_C_int{1, 27}},
{"kern.pool_debug", []_C_int{1, 77}},
{"kern.posix1version", []_C_int{1, 17}},
{"kern.proc", []_C_int{1, 66}},
{"kern.random", []_C_int{1, 31}},
{"kern.rawpartition", []_C_int{1, 24}},
{"kern.saved_ids", []_C_int{1, 20}},
{"kern.securelevel", []_C_int{1, 9}},
{"kern.seminfo", []_C_int{1, 61}},
{"kern.shminfo", []_C_int{1, 62}},
{"kern.somaxconn", []_C_int{1, 28}},
{"kern.sominconn", []_C_int{1, 29}},
{"kern.splassert", []_C_int{1, 54}},
{"kern.stackgap_random", []_C_int{1, 50}},
{"kern.sysvipc_info", []_C_int{1, 51}},
{"kern.sysvmsg", []_C_int{1, 34}},
{"kern.sysvsem", []_C_int{1, 35}},
{"kern.sysvshm", []_C_int{1, 36}},
{"kern.timecounter.choice", []_C_int{1, 69, 4}},
{"kern.timecounter.hardware", []_C_int{1, 69, 3}},
{"kern.timecounter.tick", []_C_int{1, 69, 1}},
{"kern.timecounter.timestepwarnings", []_C_int{1, 69, 2}},
{"kern.tty.maxptys", []_C_int{1, 44, 6}},
{"kern.tty.nptys", []_C_int{1, 44, 7}},
{"kern.tty.tk_cancc", []_C_int{1, 44, 4}},
{"kern.tty.tk_nin", []_C_int{1, 44, 1}},
{"kern.tty.tk_nout", []_C_int{1, 44, 2}},
{"kern.tty.tk_rawcc", []_C_int{1, 44, 3}},
{"kern.tty.ttyinfo", []_C_int{1, 44, 5}},
{"kern.ttycount", []_C_int{1, 57}},
{"kern.userasymcrypto", []_C_int{1, 60}},
{"kern.usercrypto", []_C_int{1, 52}},
{"kern.usermount", []_C_int{1, 30}},
{"kern.version", []_C_int{1, 4}},
{"kern.vnode", []_C_int{1, 13}},
{"kern.watchdog.auto", []_C_int{1, 64, 2}},
{"kern.watchdog.period", []_C_int{1, 64, 1}},
{"net.bpf.bufsize", []_C_int{4, 31, 1}},
{"net.bpf.maxbufsize", []_C_int{4, 31, 2}},
{"net.inet.ah.enable", []_C_int{4, 2, 51, 1}},
{"net.inet.ah.stats", []_C_int{4, 2, 51, 2}},
{"net.inet.carp.allow", []_C_int{4, 2, 112, 1}},
{"net.inet.carp.log", []_C_int{4, 2, 112, 3}},
{"net.inet.carp.preempt", []_C_int{4, 2, 112, 2}},
{"net.inet.carp.stats", []_C_int{4, 2, 112, 4}},
{"net.inet.divert.recvspace", []_C_int{4, 2, 258, 1}},
{"net.inet.divert.sendspace", []_C_int{4, 2, 258, 2}},
{"net.inet.divert.stats", []_C_int{4, 2, 258, 3}},
{"net.inet.esp.enable", []_C_int{4, 2, 50, 1}},
{"net.inet.esp.stats", []_C_int{4, 2, 50, 4}},
{"net.inet.esp.udpencap", []_C_int{4, 2, 50, 2}},
{"net.inet.esp.udpencap_port", []_C_int{4, 2, 50, 3}},
{"net.inet.etherip.allow", []_C_int{4, 2, 97, 1}},
{"net.inet.etherip.stats", []_C_int{4, 2, 97, 2}},
{"net.inet.gre.allow", []_C_int{4, 2, 47, 1}},
{"net.inet.gre.wccp", []_C_int{4, 2, 47, 2}},
{"net.inet.icmp.bmcastecho", []_C_int{4, 2, 1, 2}},
{"net.inet.icmp.errppslimit", []_C_int{4, 2, 1, 3}},
{"net.inet.icmp.maskrepl", []_C_int{4, 2, 1, 1}},
{"net.inet.icmp.rediraccept", []_C_int{4, 2, 1, 4}},
{"net.inet.icmp.redirtimeout", []_C_int{4, 2, 1, 5}},
{"net.inet.icmp.stats", []_C_int{4, 2, 1, 7}},
{"net.inet.icmp.tstamprepl", []_C_int{4, 2, 1, 6}},
{"net.inet.igmp.stats", []_C_int{4, 2, 2, 1}},
{"net.inet.ip.arpqueued", []_C_int{4, 2, 0, 36}},
{"net.inet.ip.encdebug", []_C_int{4, 2, 0, 12}},
{"net.inet.ip.forwarding", []_C_int{4, 2, 0, 1}},
{"net.inet.ip.ifq.congestion", []_C_int{4, 2, 0, 30, 4}},
{"net.inet.ip.ifq.drops", []_C_int{4, 2, 0, 30, 3}},
{"net.inet.ip.ifq.len", []_C_int{4, 2, 0, 30, 1}},
{"net.inet.ip.ifq.maxlen", []_C_int{4, 2, 0, 30, 2}},
{"net.inet.ip.maxqueue", []_C_int{4, 2, 0, 11}},
{"net.inet.ip.mforwarding", []_C_int{4, 2, 0, 31}},
{"net.inet.ip.mrtproto", []_C_int{4, 2, 0, 34}},
{"net.inet.ip.mrtstats", []_C_int{4, 2, 0, 35}},
{"net.inet.ip.mtu", []_C_int{4, 2, 0, 4}},
{"net.inet.ip.mtudisc", []_C_int{4, 2, 0, 27}},
{"net.inet.ip.mtudisctimeout", []_C_int{4, 2, 0, 28}},
{"net.inet.ip.multipath", []_C_int{4, 2, 0, 32}},
{"net.inet.ip.portfirst", []_C_int{4, 2, 0, 7}},
{"net.inet.ip.porthifirst", []_C_int{4, 2, 0, 9}},
{"net.inet.ip.porthilast", []_C_int{4, 2, 0, 10}},
{"net.inet.ip.portlast", []_C_int{4, 2, 0, 8}},
{"net.inet.ip.redirect", []_C_int{4, 2, 0, 2}},
{"net.inet.ip.sourceroute", []_C_int{4, 2, 0, 5}},
{"net.inet.ip.stats", []_C_int{4, 2, 0, 33}},
{"net.inet.ip.ttl", []_C_int{4, 2, 0, 3}},
{"net.inet.ipcomp.enable", []_C_int{4, 2, 108, 1}},
{"net.inet.ipcomp.stats", []_C_int{4, 2, 108, 2}},
{"net.inet.ipip.allow", []_C_int{4, 2, 4, 1}},
{"net.inet.ipip.stats", []_C_int{4, 2, 4, 2}},
{"net.inet.mobileip.allow", []_C_int{4, 2, 55, 1}},
{"net.inet.pfsync.stats", []_C_int{4, 2, 240, 1}},
{"net.inet.pim.stats", []_C_int{4, 2, 103, 1}},
{"net.inet.tcp.ackonpush", []_C_int{4, 2, 6, 13}},
{"net.inet.tcp.always_keepalive", []_C_int{4, 2, 6, 22}},
{"net.inet.tcp.baddynamic", []_C_int{4, 2, 6, 6}},
{"net.inet.tcp.drop", []_C_int{4, 2, 6, 19}},
{"net.inet.tcp.ecn", []_C_int{4, 2, 6, 14}},
{"net.inet.tcp.ident", []_C_int{4, 2, 6, 9}},
{"net.inet.tcp.keepidle", []_C_int{4, 2, 6, 3}},
{"net.inet.tcp.keepinittime", []_C_int{4, 2, 6, 2}},
{"net.inet.tcp.keepintvl", []_C_int{4, 2, 6, 4}},
{"net.inet.tcp.mssdflt", []_C_int{4, 2, 6, 11}},
{"net.inet.tcp.reasslimit", []_C_int{4, 2, 6, 18}},
{"net.inet.tcp.rfc1323", []_C_int{4, 2, 6, 1}},
{"net.inet.tcp.rfc3390", []_C_int{4, 2, 6, 17}},
{"net.inet.tcp.rstppslimit", []_C_int{4, 2, 6, 12}},
{"net.inet.tcp.sack", []_C_int{4, 2, 6, 10}},
{"net.inet.tcp.sackholelimit", []_C_int{4, 2, 6, 20}},
{"net.inet.tcp.slowhz", []_C_int{4, 2, 6, 5}},
{"net.inet.tcp.stats", []_C_int{4, 2, 6, 21}},
{"net.inet.tcp.synbucketlimit", []_C_int{4, 2, 6, 16}},
{"net.inet.tcp.syncachelimit", []_C_int{4, 2, 6, 15}},
{"net.inet.udp.baddynamic", []_C_int{4, 2, 17, 2}},
{"net.inet.udp.checksum", []_C_int{4, 2, 17, 1}},
{"net.inet.udp.recvspace", []_C_int{4, 2, 17, 3}},
{"net.inet.udp.sendspace", []_C_int{4, 2, 17, 4}},
{"net.inet.udp.stats", []_C_int{4, 2, 17, 5}},
{"net.inet6.divert.recvspace", []_C_int{4, 24, 86, 1}},
{"net.inet6.divert.sendspace", []_C_int{4, 24, 86, 2}},
{"net.inet6.divert.stats", []_C_int{4, 24, 86, 3}},
{"net.inet6.icmp6.errppslimit", []_C_int{4, 24, 30, 14}},
{"net.inet6.icmp6.mtudisc_hiwat", []_C_int{4, 24, 30, 16}},
{"net.inet6.icmp6.mtudisc_lowat", []_C_int{4, 24, 30, 17}},
{"net.inet6.icmp6.nd6_debug", []_C_int{4, 24, 30, 18}},
{"net.inet6.icmp6.nd6_delay", []_C_int{4, 24, 30, 8}},
{"net.inet6.icmp6.nd6_maxnudhint", []_C_int{4, 24, 30, 15}},
{"net.inet6.icmp6.nd6_mmaxtries", []_C_int{4, 24, 30, 10}},
{"net.inet6.icmp6.nd6_prune", []_C_int{4, 24, 30, 6}},
{"net.inet6.icmp6.nd6_umaxtries", []_C_int{4, 24, 30, 9}},
{"net.inet6.icmp6.nd6_useloopback", []_C_int{4, 24, 30, 11}},
{"net.inet6.icmp6.nodeinfo", []_C_int{4, 24, 30, 13}},
{"net.inet6.icmp6.rediraccept", []_C_int{4, 24, 30, 2}},
{"net.inet6.icmp6.redirtimeout", []_C_int{4, 24, 30, 3}},
{"net.inet6.ip6.accept_rtadv", []_C_int{4, 24, 17, 12}},
{"net.inet6.ip6.auto_flowlabel", []_C_int{4, 24, 17, 17}},
{"net.inet6.ip6.dad_count", []_C_int{4, 24, 17, 16}},
{"net.inet6.ip6.dad_pending", []_C_int{4, 24, 17, 49}},
{"net.inet6.ip6.defmcasthlim", []_C_int{4, 24, 17, 18}},
{"net.inet6.ip6.forwarding", []_C_int{4, 24, 17, 1}},
{"net.inet6.ip6.forwsrcrt", []_C_int{4, 24, 17, 5}},
{"net.inet6.ip6.hdrnestlimit", []_C_int{4, 24, 17, 15}},
{"net.inet6.ip6.hlim", []_C_int{4, 24, 17, 3}},
{"net.inet6.ip6.log_interval", []_C_int{4, 24, 17, 14}},
{"net.inet6.ip6.maxdynroutes", []_C_int{4, 24, 17, 48}},
{"net.inet6.ip6.maxfragpackets", []_C_int{4, 24, 17, 9}},
{"net.inet6.ip6.maxfrags", []_C_int{4, 24, 17, 41}},
{"net.inet6.ip6.maxifdefrouters", []_C_int{4, 24, 17, 47}},
{"net.inet6.ip6.maxifprefixes", []_C_int{4, 24, 17, 46}},
{"net.inet6.ip6.mforwarding", []_C_int{4, 24, 17, 42}},
{"net.inet6.ip6.mrtproto", []_C_int{4, 24, 17, 8}},
{"net.inet6.ip6.mtudisctimeout", []_C_int{4, 24, 17, 50}},
{"net.inet6.ip6.multicast_mtudisc", []_C_int{4, 24, 17, 44}},
{"net.inet6.ip6.multipath", []_C_int{4, 24, 17, 43}},
{"net.inet6.ip6.neighborgcthresh", []_C_int{4, 24, 17, 45}},
{"net.inet6.ip6.redirect", []_C_int{4, 24, 17, 2}},
{"net.inet6.ip6.rr_prune", []_C_int{4, 24, 17, 22}},
{"net.inet6.ip6.sourcecheck", []_C_int{4, 24, 17, 10}},
{"net.inet6.ip6.sourcecheck_logint", []_C_int{4, 24, 17, 11}},
{"net.inet6.ip6.use_deprecated", []_C_int{4, 24, 17, 21}},
{"net.inet6.ip6.v6only", []_C_int{4, 24, 17, 24}},
{"net.key.sadb_dump", []_C_int{4, 30, 1}},
{"net.key.spd_dump", []_C_int{4, 30, 2}},
{"net.mpls.ifq.congestion", []_C_int{4, 33, 3, 4}},
{"net.mpls.ifq.drops", []_C_int{4, 33, 3, 3}},
{"net.mpls.ifq.len", []_C_int{4, 33, 3, 1}},
{"net.mpls.ifq.maxlen", []_C_int{4, 33, 3, 2}},
{"net.mpls.mapttl_ip", []_C_int{4, 33, 5}},
{"net.mpls.mapttl_ip6", []_C_int{4, 33, 6}},
{"net.mpls.maxloop_inkernel", []_C_int{4, 33, 4}},
{"net.mpls.ttl", []_C_int{4, 33, 2}},
{"net.pflow.stats", []_C_int{4, 34, 1}},
{"net.pipex.enable", []_C_int{4, 35, 1}},
{"vm.anonmin", []_C_int{2, 7}},
{"vm.loadavg", []_C_int{2, 2}},
{"vm.maxslp", []_C_int{2, 10}},
{"vm.nkmempages", []_C_int{2, 6}},
{"vm.psstrings", []_C_int{2, 3}},
{"vm.swapencrypt.enable", []_C_int{2, 5, 0}},
{"vm.swapencrypt.keyscreated", []_C_int{2, 5, 1}},
{"vm.swapencrypt.keysdeleted", []_C_int{2, 5, 2}},
{"vm.uspace", []_C_int{2, 11}},
{"vm.uvmexp", []_C_int{2, 4}},
{"vm.vmmeter", []_C_int{2, 1}},
{"vm.vnodemin", []_C_int{2, 9}},
{"vm.vtextmin", []_C_int{2, 8}},
}
| {
"pile_set_name": "Github"
} |
//
// AppDelegate.h
// HACClusterMapViewController
//
// Created by Hipolito Arias on 11/8/15.
// Copyright (c) 2015 MasterApp. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
| {
"pile_set_name": "Github"
} |
$ErrorActionPreference = 'Stop';
$packageArgs = @{
packageName = $env:ChocolateyPackageName
softwareName = 'X2Go Client*'
fileType = 'exe'
silentArgs = '/S'
validExitCodes= @(@(0))
}
$uninstalled = $false
[array]$key = Get-UninstallRegistryKey @packageArgs
if ($key.Count -eq 1) {
$key | ForEach-Object {
$packageArgs['file'] = "$($_.UninstallString)"
Uninstall-ChocolateyPackage @packageArgs
}
} elseif ($key.Count -eq 0) {
Write-Warning "$packageName has already been uninstalled by other means."
} elseif ($key.Count -gt 1) {
Write-Warning "$($key.Count) matches found!"
Write-Warning "To prevent accidental data loss, no programs will be uninstalled."
Write-Warning "Please alert the package maintainer that the following keys were matched:"
$key | ForEach-Object { Write-Warning "- $($_.DisplayName)" }
}
| {
"pile_set_name": "Github"
} |
//g++ -O3 -g0 -DNDEBUG sparse_product.cpp -I.. -I/home/gael/Coding/LinearAlgebra/mtl4/ -DDENSITY=0.005 -DSIZE=10000 && ./a.out
//g++ -O3 -g0 -DNDEBUG sparse_product.cpp -I.. -I/home/gael/Coding/LinearAlgebra/mtl4/ -DDENSITY=0.05 -DSIZE=2000 && ./a.out
// -DNOGMM -DNOMTL -DCSPARSE
// -I /home/gael/Coding/LinearAlgebra/CSparse/Include/ /home/gael/Coding/LinearAlgebra/CSparse/Lib/libcsparse.a
#ifndef SIZE
#define SIZE 650000
#endif
#ifndef DENSITY
#define DENSITY 0.01
#endif
#ifndef REPEAT
#define REPEAT 1
#endif
#include "BenchSparseUtil.h"
#ifndef MINDENSITY
#define MINDENSITY 0.0004
#endif
#ifndef NBTRIES
#define NBTRIES 10
#endif
#define BENCH(X) \
timer.reset(); \
for (int _j=0; _j<NBTRIES; ++_j) { \
timer.start(); \
for (int _k=0; _k<REPEAT; ++_k) { \
X \
} timer.stop(); }
#ifdef CSPARSE
cs* cs_sorted_multiply(const cs* a, const cs* b)
{
cs* A = cs_transpose (a, 1) ;
cs* B = cs_transpose (b, 1) ;
cs* D = cs_multiply (B,A) ; /* D = B'*A' */
cs_spfree (A) ;
cs_spfree (B) ;
cs_dropzeros (D) ; /* drop zeros from D */
cs* C = cs_transpose (D, 1) ; /* C = D', so that C is sorted */
cs_spfree (D) ;
return C;
}
#endif
int main(int argc, char *argv[])
{
int rows = SIZE;
int cols = SIZE;
float density = DENSITY;
EigenSparseMatrix sm1(rows,cols);
DenseVector v1(cols), v2(cols);
v1.setRandom();
BenchTimer timer;
for (float density = DENSITY; density>=MINDENSITY; density*=0.5)
{
//fillMatrix(density, rows, cols, sm1);
fillMatrix2(7, rows, cols, sm1);
// dense matrices
#ifdef DENSEMATRIX
{
std::cout << "Eigen Dense\t" << density*100 << "%\n";
DenseMatrix m1(rows,cols);
eiToDense(sm1, m1);
timer.reset();
timer.start();
for (int k=0; k<REPEAT; ++k)
v2 = m1 * v1;
timer.stop();
std::cout << " a * v:\t" << timer.best() << " " << double(REPEAT)/timer.best() << " * / sec " << endl;
timer.reset();
timer.start();
for (int k=0; k<REPEAT; ++k)
v2 = m1.transpose() * v1;
timer.stop();
std::cout << " a' * v:\t" << timer.best() << endl;
}
#endif
// eigen sparse matrices
{
std::cout << "Eigen sparse\t" << sm1.nonZeros()/float(sm1.rows()*sm1.cols())*100 << "%\n";
BENCH(asm("#myc"); v2 = sm1 * v1; asm("#myd");)
std::cout << " a * v:\t" << timer.best()/REPEAT << " " << double(REPEAT)/timer.best(REAL_TIMER) << " * / sec " << endl;
BENCH( { asm("#mya"); v2 = sm1.transpose() * v1; asm("#myb"); })
std::cout << " a' * v:\t" << timer.best()/REPEAT << endl;
}
// {
// DynamicSparseMatrix<Scalar> m1(sm1);
// std::cout << "Eigen dyn-sparse\t" << m1.nonZeros()/float(m1.rows()*m1.cols())*100 << "%\n";
//
// BENCH(for (int k=0; k<REPEAT; ++k) v2 = m1 * v1;)
// std::cout << " a * v:\t" << timer.value() << endl;
//
// BENCH(for (int k=0; k<REPEAT; ++k) v2 = m1.transpose() * v1;)
// std::cout << " a' * v:\t" << timer.value() << endl;
// }
// GMM++
#ifndef NOGMM
{
std::cout << "GMM++ sparse\t" << density*100 << "%\n";
//GmmDynSparse gmmT3(rows,cols);
GmmSparse m1(rows,cols);
eiToGmm(sm1, m1);
std::vector<Scalar> gmmV1(cols), gmmV2(cols);
Map<Matrix<Scalar,Dynamic,1> >(&gmmV1[0], cols) = v1;
Map<Matrix<Scalar,Dynamic,1> >(&gmmV2[0], cols) = v2;
BENCH( asm("#myx"); gmm::mult(m1, gmmV1, gmmV2); asm("#myy"); )
std::cout << " a * v:\t" << timer.value() << endl;
BENCH( gmm::mult(gmm::transposed(m1), gmmV1, gmmV2); )
std::cout << " a' * v:\t" << timer.value() << endl;
}
#endif
#ifndef NOUBLAS
{
std::cout << "ublas sparse\t" << density*100 << "%\n";
UBlasSparse m1(rows,cols);
eiToUblas(sm1, m1);
boost::numeric::ublas::vector<Scalar> uv1, uv2;
eiToUblasVec(v1,uv1);
eiToUblasVec(v2,uv2);
// std::vector<Scalar> gmmV1(cols), gmmV2(cols);
// Map<Matrix<Scalar,Dynamic,1> >(&gmmV1[0], cols) = v1;
// Map<Matrix<Scalar,Dynamic,1> >(&gmmV2[0], cols) = v2;
BENCH( uv2 = boost::numeric::ublas::prod(m1, uv1); )
std::cout << " a * v:\t" << timer.value() << endl;
// BENCH( boost::ublas::prod(gmm::transposed(m1), gmmV1, gmmV2); )
// std::cout << " a' * v:\t" << timer.value() << endl;
}
#endif
// MTL4
#ifndef NOMTL
{
std::cout << "MTL4\t" << density*100 << "%\n";
MtlSparse m1(rows,cols);
eiToMtl(sm1, m1);
mtl::dense_vector<Scalar> mtlV1(cols, 1.0);
mtl::dense_vector<Scalar> mtlV2(cols, 1.0);
timer.reset();
timer.start();
for (int k=0; k<REPEAT; ++k)
mtlV2 = m1 * mtlV1;
timer.stop();
std::cout << " a * v:\t" << timer.value() << endl;
timer.reset();
timer.start();
for (int k=0; k<REPEAT; ++k)
mtlV2 = trans(m1) * mtlV1;
timer.stop();
std::cout << " a' * v:\t" << timer.value() << endl;
}
#endif
std::cout << "\n\n";
}
return 0;
}
| {
"pile_set_name": "Github"
} |
/*
* intel_soc_pmic_crc.c - Device access for Crystal Cove PMIC
*
* Copyright (C) 2013, 2014 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Author: Yang, Bin <[email protected]>
* Author: Zhu, Lejun <[email protected]>
*/
#include <linux/mfd/core.h>
#include <linux/interrupt.h>
#include <linux/regmap.h>
#include <linux/mfd/intel_soc_pmic.h>
#include "intel_soc_pmic_core.h"
#define CRYSTAL_COVE_MAX_REGISTER 0xC6
#define CRYSTAL_COVE_REG_IRQLVL1 0x02
#define CRYSTAL_COVE_REG_MIRQLVL1 0x0E
#define CRYSTAL_COVE_IRQ_PWRSRC 0
#define CRYSTAL_COVE_IRQ_THRM 1
#define CRYSTAL_COVE_IRQ_BCU 2
#define CRYSTAL_COVE_IRQ_ADC 3
#define CRYSTAL_COVE_IRQ_CHGR 4
#define CRYSTAL_COVE_IRQ_GPIO 5
#define CRYSTAL_COVE_IRQ_VHDMIOCP 6
static struct resource gpio_resources[] = {
{
.name = "GPIO",
.start = CRYSTAL_COVE_IRQ_GPIO,
.end = CRYSTAL_COVE_IRQ_GPIO,
.flags = IORESOURCE_IRQ,
},
};
static struct resource pwrsrc_resources[] = {
{
.name = "PWRSRC",
.start = CRYSTAL_COVE_IRQ_PWRSRC,
.end = CRYSTAL_COVE_IRQ_PWRSRC,
.flags = IORESOURCE_IRQ,
},
};
static struct resource adc_resources[] = {
{
.name = "ADC",
.start = CRYSTAL_COVE_IRQ_ADC,
.end = CRYSTAL_COVE_IRQ_ADC,
.flags = IORESOURCE_IRQ,
},
};
static struct resource thermal_resources[] = {
{
.name = "THERMAL",
.start = CRYSTAL_COVE_IRQ_THRM,
.end = CRYSTAL_COVE_IRQ_THRM,
.flags = IORESOURCE_IRQ,
},
};
static struct resource bcu_resources[] = {
{
.name = "BCU",
.start = CRYSTAL_COVE_IRQ_BCU,
.end = CRYSTAL_COVE_IRQ_BCU,
.flags = IORESOURCE_IRQ,
},
};
static struct mfd_cell crystal_cove_byt_dev[] = {
{
.name = "crystal_cove_pwrsrc",
.num_resources = ARRAY_SIZE(pwrsrc_resources),
.resources = pwrsrc_resources,
},
{
.name = "crystal_cove_adc",
.num_resources = ARRAY_SIZE(adc_resources),
.resources = adc_resources,
},
{
.name = "crystal_cove_thermal",
.num_resources = ARRAY_SIZE(thermal_resources),
.resources = thermal_resources,
},
{
.name = "crystal_cove_bcu",
.num_resources = ARRAY_SIZE(bcu_resources),
.resources = bcu_resources,
},
{
.name = "crystal_cove_gpio",
.num_resources = ARRAY_SIZE(gpio_resources),
.resources = gpio_resources,
},
{
.name = "crystal_cove_pmic",
},
{
.name = "crystal_cove_pwm",
},
};
static struct mfd_cell crystal_cove_cht_dev[] = {
{
.name = "crystal_cove_gpio",
.num_resources = ARRAY_SIZE(gpio_resources),
.resources = gpio_resources,
},
{
.name = "crystal_cove_pwm",
},
};
static const struct regmap_config crystal_cove_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = CRYSTAL_COVE_MAX_REGISTER,
.cache_type = REGCACHE_NONE,
};
static const struct regmap_irq crystal_cove_irqs[] = {
[CRYSTAL_COVE_IRQ_PWRSRC] = {
.mask = BIT(CRYSTAL_COVE_IRQ_PWRSRC),
},
[CRYSTAL_COVE_IRQ_THRM] = {
.mask = BIT(CRYSTAL_COVE_IRQ_THRM),
},
[CRYSTAL_COVE_IRQ_BCU] = {
.mask = BIT(CRYSTAL_COVE_IRQ_BCU),
},
[CRYSTAL_COVE_IRQ_ADC] = {
.mask = BIT(CRYSTAL_COVE_IRQ_ADC),
},
[CRYSTAL_COVE_IRQ_CHGR] = {
.mask = BIT(CRYSTAL_COVE_IRQ_CHGR),
},
[CRYSTAL_COVE_IRQ_GPIO] = {
.mask = BIT(CRYSTAL_COVE_IRQ_GPIO),
},
[CRYSTAL_COVE_IRQ_VHDMIOCP] = {
.mask = BIT(CRYSTAL_COVE_IRQ_VHDMIOCP),
},
};
static const struct regmap_irq_chip crystal_cove_irq_chip = {
.name = "Crystal Cove",
.irqs = crystal_cove_irqs,
.num_irqs = ARRAY_SIZE(crystal_cove_irqs),
.num_regs = 1,
.status_base = CRYSTAL_COVE_REG_IRQLVL1,
.mask_base = CRYSTAL_COVE_REG_MIRQLVL1,
};
struct intel_soc_pmic_config intel_soc_pmic_config_byt_crc = {
.irq_flags = IRQF_TRIGGER_RISING,
.cell_dev = crystal_cove_byt_dev,
.n_cell_devs = ARRAY_SIZE(crystal_cove_byt_dev),
.regmap_config = &crystal_cove_regmap_config,
.irq_chip = &crystal_cove_irq_chip,
};
struct intel_soc_pmic_config intel_soc_pmic_config_cht_crc = {
.irq_flags = IRQF_TRIGGER_RISING,
.cell_dev = crystal_cove_cht_dev,
.n_cell_devs = ARRAY_SIZE(crystal_cove_cht_dev),
.regmap_config = &crystal_cove_regmap_config,
.irq_chip = &crystal_cove_irq_chip,
};
| {
"pile_set_name": "Github"
} |
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <array>
#include <vector>
#include <boost/serialization/array.hpp>
#include <boost/serialization/deque.hpp>
#include <boost/serialization/priority_queue.hpp>
#include <boost/serialization/vector.hpp>
#include <queue>
#include "audio_core/audio_types.h"
#include "audio_core/codec.h"
#include "audio_core/hle/common.h"
#include "audio_core/hle/filter.h"
#include "audio_core/interpolate.h"
#include "common/common_types.h"
namespace Memory {
class MemorySystem;
}
namespace AudioCore::HLE {
/**
* This module performs:
* - Buffer management
* - Decoding of buffers
* - Buffer resampling and interpolation
* - Per-source filtering (SimpleFilter, BiquadFilter)
* - Per-source gain
* - Other per-source processing
*/
class Source final {
public:
explicit Source(std::size_t source_id_) : source_id(source_id_) {
Reset();
}
/// Resets internal state.
void Reset();
/// Sets the memory system to read data from
void SetMemory(Memory::MemorySystem& memory);
/**
* This is called once every audio frame. This performs per-source processing every frame.
* @param config The new configuration we've got for this Source from the application.
* @param adpcm_coeffs ADPCM coefficients to use if config tells us to use them (may contain
* invalid values otherwise).
* @return The current status of this Source. This is given back to the emulated application via
* SharedMemory.
*/
SourceStatus::Status Tick(SourceConfiguration::Configuration& config,
const s16_le (&adpcm_coeffs)[16]);
/**
* Mix this source's output into dest, using the gains for the `intermediate_mix_id`-th
* intermediate mixer.
* @param dest The QuadFrame32 to mix into.
* @param intermediate_mix_id The id of the intermediate mix whose gains we are using.
*/
void MixInto(QuadFrame32& dest, std::size_t intermediate_mix_id) const;
private:
const std::size_t source_id;
Memory::MemorySystem* memory_system;
StereoFrame16 current_frame;
using Format = SourceConfiguration::Configuration::Format;
using InterpolationMode = SourceConfiguration::Configuration::InterpolationMode;
using MonoOrStereo = SourceConfiguration::Configuration::MonoOrStereo;
/// Internal representation of a buffer for our buffer queue
struct Buffer {
PAddr physical_address;
u32 length;
u8 adpcm_ps;
std::array<u16, 2> adpcm_yn;
bool adpcm_dirty;
bool is_looping;
u16 buffer_id;
MonoOrStereo mono_or_stereo;
Format format;
bool from_queue;
u32_dsp play_position; // = 0;
bool has_played; // = false;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& physical_address;
ar& length;
ar& adpcm_ps;
ar& adpcm_yn;
ar& adpcm_dirty;
ar& is_looping;
ar& buffer_id;
ar& mono_or_stereo;
ar& format;
ar& from_queue;
ar& play_position;
ar& has_played;
}
friend class boost::serialization::access;
};
struct BufferOrder {
bool operator()(const Buffer& a, const Buffer& b) const {
// Lower buffer_id comes first.
return a.buffer_id > b.buffer_id;
}
};
struct {
// State variables
bool enabled = false;
u16 sync = 0;
// Mixing
std::array<std::array<float, 4>, 3> gain = {};
// Buffer queue
std::priority_queue<Buffer, std::vector<Buffer>, BufferOrder> input_queue = {};
MonoOrStereo mono_or_stereo = MonoOrStereo::Mono;
Format format = Format::ADPCM;
// Current buffer
u32 current_sample_number = 0;
u32 next_sample_number = 0;
AudioInterp::StereoBuffer16 current_buffer = {};
// buffer_id state
bool buffer_update = false;
u32 current_buffer_id = 0;
// Decoding state
std::array<s16, 16> adpcm_coeffs = {};
Codec::ADPCMState adpcm_state = {};
// Resampling state
float rate_multiplier = 1.0;
InterpolationMode interpolation_mode = InterpolationMode::Polyphase;
AudioInterp::State interp_state = {};
// Filter state
SourceFilters filters = {};
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& enabled;
ar& sync;
ar& gain;
ar& input_queue;
ar& mono_or_stereo;
ar& format;
ar& current_sample_number;
ar& next_sample_number;
ar& current_buffer;
ar& buffer_update;
ar& current_buffer_id;
ar& adpcm_coeffs;
ar& rate_multiplier;
ar& interpolation_mode;
}
friend class boost::serialization::access;
} state;
// Internal functions
/// INTERNAL: Update our internal state based on the current config.
void ParseConfig(SourceConfiguration::Configuration& config, const s16_le (&adpcm_coeffs)[16]);
/// INTERNAL: Generate the current audio output for this frame based on our internal state.
void GenerateFrame();
/// INTERNAL: Dequeues a buffer and does preprocessing on it (decoding, resampling). Puts it
/// into current_buffer.
bool DequeueBuffer();
/// INTERNAL: Generates a SourceStatus::Status based on our internal state.
SourceStatus::Status GetCurrentStatus();
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& state;
}
friend class boost::serialization::access;
};
} // namespace AudioCore::HLE
| {
"pile_set_name": "Github"
} |
using System;
using System.Collections.Generic;
using System.Linq;
using AVFoundation;
using CoreFoundation;
using CoreMedia;
using Foundation;
using UIKit;
namespace AutoWait
{
public partial class PlaybackDetailsViewController : UIViewController
{
[Outlet ("rateLabel")]
UILabel RateLabel { get; set; }
[Outlet ("timeControlStatusLabel")]
UILabel TimeControlStatusLabel { get; set; }
[Outlet ("reasonForWaitingLabel")]
UILabel ReasonForWaitingLabel { get; set; }
[Outlet ("likelyToKeepUpLabel")]
UILabel LikelyToKeepUpLabel { get; set; }
[Outlet ("loadedTimeRangesLabel")]
UILabel LoadedTimeRangesLabel { get; set; }
[Outlet ("currentTimeLabel")]
UILabel CurrentTimeLabel { get; set; }
[Outlet ("playbackBufferFullLabel")]
UILabel PlaybackBufferFullLabel { get; set; }
[Outlet ("playbackBufferEmptyLabel")]
UILabel PlaybackBufferEmptyLabel { get; set; }
[Outlet ("timebaseRateLabel")]
UILabel TimebaseRateLabel { get; set; }
public AVPlayer Player { get; set; }
// AVPlayerItem.CurrentTime and the AVPlayerItem.Timebase's rate are not KVO observable. We check their values regularly using this timer.
readonly DispatchSource.Timer nonObservablePropertiesUpdateTimer = new DispatchSource.Timer (DispatchQueue.MainQueue);
IDisposable rateToken;
IDisposable timeControlStatusToken;
IDisposable reasonForWaitingToPlayToken;
IDisposable playbackLikelyToKeepUpToken;
IDisposable loadedTimeRangesToken;
IDisposable playbackBufferFullToken;
IDisposable playbackBufferEmptyToken;
public PlaybackDetailsViewController (IntPtr handle)
: base (handle)
{
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
nonObservablePropertiesUpdateTimer.SetEventHandler (UpdateNonObservableProperties);
nonObservablePropertiesUpdateTimer.SetTimer (DispatchTime.Now, 1000000, 0);
nonObservablePropertiesUpdateTimer.Resume ();
var options = NSKeyValueObservingOptions.Initial | NSKeyValueObservingOptions.New;
rateToken = Player.AddObserver ("rate", options, RateChanged);
timeControlStatusToken = Player.AddObserver ("timeControlStatus", options, timeControlStatusChanged);
reasonForWaitingToPlayToken = Player.AddObserver ("reasonForWaitingToPlay", options, ReasonForWaitingToPlayChanged);
playbackLikelyToKeepUpToken = Player.AddObserver ("currentItem.playbackLikelyToKeepUp", options, PlaybackLikelyToKeepUpChanged);
loadedTimeRangesToken = Player.AddObserver ("currentItem.loadedTimeRanges", options, LoadedTimeRangesChanged);
playbackBufferFullToken = Player.AddObserver ("currentItem.playbackBufferFull", options, PlaybackBufferFullChanged);
playbackBufferEmptyToken = Player.AddObserver ("currentItem.playbackBufferEmpty", options, PlaybackBufferEmptyChanged);
}
public override void ViewDidDisappear (bool animated)
{
base.ViewDidDisappear (animated);
rateToken?.Dispose ();
timeControlStatusToken?.Dispose ();
reasonForWaitingToPlayToken?.Dispose ();
playbackLikelyToKeepUpToken?.Dispose ();
loadedTimeRangesToken?.Dispose ();
playbackBufferFullToken?.Dispose ();
playbackBufferEmptyToken?.Dispose ();
nonObservablePropertiesUpdateTimer.Suspend ();
}
// Helper function to get a background color for the timeControlStatus label.
UIColor LabelBackgroundColor (AVPlayerTimeControlStatus status)
{
switch (status) {
case AVPlayerTimeControlStatus.Paused:
return new UIColor (0.8196078538894653f, 0.2627451121807098f, 0.2823528945446014f, 1);
case AVPlayerTimeControlStatus.Playing:
return new UIColor (0.2881325483322144f, 0.6088829636573792f, 0.261575847864151f, 1);
case AVPlayerTimeControlStatus.WaitingToPlayAtSpecifiedRate:
return new UIColor (0.8679746985435486f, 0.4876297116279602f, 0.2578189671039581f, 1);
default:
throw new InvalidProgramException ();
}
}
// Helper function to get an abbreviated description for the waiting reason.
string AbbreviatedDescription (string reason)
{
if (reason == null)
return null;
if (reason == AVPlayer.WaitingToMinimizeStallsReason)
return "Minimizing Stalls";
if (reason == AVPlayer.WaitingWhileEvaluatingBufferingRateReason)
return "Evaluating Buffering Rate";
if (reason == AVPlayer.WaitingWithNoItemToPlayReason)
return "No Item";
return "UNKOWN";
}
void UpdateNonObservableProperties ()
{
CurrentTimeLabel.Text = Seconds (Player.CurrentItem.CurrentTime);
// TODO: https://bugzilla.xamarin.com/show_bug.cgi?id=44154
//TimebaseRateLabel.Text = Player.CurrentItem.Timebase?.Rate.ToString ();
}
void RateChanged (NSObservedChange obj)
{
RateLabel.Text = (Player != null) ? Player.Rate.ToString () : "-";
}
void timeControlStatusChanged (NSObservedChange obj)
{
TimeControlStatusLabel.Text = (Player != null) ? Player.TimeControlStatus.ToString () : "-";
TimeControlStatusLabel.BackgroundColor = (Player != null)
? LabelBackgroundColor (Player.TimeControlStatus)
: new UIColor (1, 0.9999743700027466f, 0.9999912977218628f, 1);
}
void ReasonForWaitingToPlayChanged (NSObservedChange obj)
{
ReasonForWaitingLabel.Text = AbbreviatedDescription (Player?.ReasonForWaitingToPlay) ?? "-";
}
void PlaybackLikelyToKeepUpChanged (NSObservedChange obj)
{
LikelyToKeepUpLabel.Text = (Player != null) ? Player.CurrentItem.PlaybackLikelyToKeepUp.ToString () : "-";
}
void LoadedTimeRangesChanged (NSObservedChange obj)
{
var description = Descr (TimeRanges (Player?.CurrentItem?.LoadedTimeRanges));
LoadedTimeRangesLabel.Text = string.IsNullOrWhiteSpace (description) ? "-" : description;
}
void PlaybackBufferFullChanged (NSObservedChange obj)
{
PlaybackBufferFullLabel.Text = (Player != null) ? Player.CurrentItem.PlaybackBufferFull.ToString () : "-";
}
void PlaybackBufferEmptyChanged (NSObservedChange obj)
{
PlaybackBufferEmptyLabel.Text = (Player != null) ? Player.CurrentItem.PlaybackBufferEmpty.ToString () : "-";
}
IEnumerable<CMTimeRange> TimeRanges (NSValue [] values)
{
foreach (var v in values)
yield return v.CMTimeRangeValue;
}
static string Descr (IEnumerable<CMTimeRange> ranges)
{
// CMTimeRange -> [0.5s, 9.7s]
return string.Join (", ", ranges.Select (r => $"[{Seconds(r.Start)}, {Seconds(r.Start + r.Duration)}]"));
}
static string Seconds (CMTime time)
{
return $"{time.Seconds:F1}s";
}
}
}
| {
"pile_set_name": "Github"
} |
import "./module";
import f, { ns } from "./root2";
import * as r2 from "./root2";
it("should be able to import a secondary root", () => {
expect(f()).toBe("ok");
expect(f.x()).toBe("ok");
expect(ns.f()).toBe("ok");
expect(ns.f.x()).toBe("ok");
expect(r2.ns.f()).toBe("ok");
expect(r2.ns.f.x()).toBe("ok");
return import("./chunk");
});
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="search_toolbar_margin_top">5dp</dimen>
<dimen name="search_toolbar_margin_left">118dp</dimen>
<dimen name="search_toolbar_margin_right">118dp</dimen>
</resources> | {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>hs</string>
</array>
<key>keyEquivalent</key>
<string>^~H</string>
<key>name</key>
<string>Haskell</string>
<key>patterns</key>
<array>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.entity.haskell</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>punctuation.definition.entity.haskell</string>
</dict>
</dict>
<key>comment</key>
<string>In case this regex seems unusual for an infix operator, note that Haskell allows any ordinary function application (elem 4 [1..10]) to be rewritten as an infix expression (4 `elem` [1..10]).</string>
<key>match</key>
<string>(`)[a-zA-Z_']*?(`)</string>
<key>name</key>
<string>keyword.operator.function.infix.haskell</string>
</dict>
<dict> <key>match</key> <string>\(\)</string>
<key>name</key> <string>constant.language.unit.haskell</string>
</dict>
<dict> <key>match</key> <string>\[\]</string>
<key>name</key> <string>constant.language.empty-list.haskell</string>
</dict>
<dict> <key>match</key>
<string>\b(module|instance|do|if|then|else|deriving|where|data|type|case|of|
|let|in|newtype|default|import|qualified|as|hiding)\b</string>
<key>name</key> <string>keyword.other.haskell</string>
</dict>
<dict> <key>match</key> <string>\binfix[lr]?\b</string>
<key>name</key> <string>keyword.operator.haskell</string>
</dict>
<dict> <key>match</key> <string>\b(error|throw)\b</string>
<key>name</key> <string>keyword.exception.haskell</string>
</dict>
<dict>
<key>comment</key>
<string>Floats are always decimal</string>
<key>match</key>
<string>\b([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\b</string>
<key>name</key>
<string>constant.numeric.float.haskell</string>
</dict>
<dict>
<key>match</key>
<string>\b([0-9]+|0([xX][0-9a-fA-F]+|[oO][0-7]+))\b</string>
<key>name</key>
<string>constant.numeric.haskell</string>
</dict>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.preprocessor.c</string>
</dict>
</dict>
<key>comment</key>
<string>In addition to Haskell's "native" syntax, GHC permits the C preprocessor to be run on a source file.</string>
<key>match</key>
<string>^\s*(#)\s*\w+</string>
<key>name</key>
<string>meta.preprocessor.c</string>
</dict>
<dict>
<key>include</key>
<string>#pragma</string>
</dict>
<dict>
<key>begin</key>
<string>"</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.haskell</string>
</dict>
</dict>
<key>end</key>
<string>"</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.haskell</string>
</dict>
</dict>
<key>name</key>
<string>string.quoted.double.haskell</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\\(NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\"'\&])</string>
<key>name</key>
<string>constant.character.escape.haskell</string>
</dict>
<dict>
<key>match</key>
<string>\\o[0-7]+|\\x[0-9A-Fa-f]+|\\[0-9]+</string>
<key>name</key>
<string>constant.character.escape.octal.haskell</string>
</dict>
<dict>
<key>match</key>
<string>\^[A-Z@\[\]\\\^_]</string>
<key>name</key>
<string>constant.character.escape.control.haskell</string>
</dict>
</array>
</dict>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.haskell</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>constant.character.escape.haskell</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>constant.character.escape.octal.haskell</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>constant.character.escape.hexadecimal.haskell</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>constant.character.escape.control.haskell</string>
</dict>
<key>6</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.haskell</string>
</dict>
</dict>
<key>match</key>
<string>(?x)
(')
(?:
[\ -\[\]-~] # Basic Char
| (\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE
|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS
|US|SP|DEL|[abfnrtv\\\"'\&])) # Escapes
| (\\o[0-7]+) # Octal Escapes
| (\\x[0-9A-Fa-f]+) # Hexadecimal Escapes
| (\^[A-Z@\[\]\\\^_]) # Control Chars
)
(')
</string>
<key>name</key>
<string>string.quoted.single.haskell</string>
</dict>
<dict>
<key>begin</key>
<string>^\s*([a-z_][a-zA-Z0-9_']*|\([|!%$+\-.,=</>]+\))\s*(::)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.function.haskell</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>keyword.other.double-colon.haskell</string>
</dict>
</dict>
<key>end</key>
<string>$\n?</string>
<key>name</key>
<string>meta.function.type-declaration.haskell</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#type_signature</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#comments</string>
</dict>
<dict>
<key>include</key>
<string>#infix_op</string>
</dict>
<dict>
<key>comment</key>
<string>In case this regex seems overly general, note that Haskell permits the definition of new operators which can be nearly any string of punctuation characters, such as $%^&*.</string>
<key>match</key>
<string>[|!%$?~+:\-.=</>\\]+</string>
<key>name</key>
<string>keyword.operator.haskell</string>
</dict>
<dict>
<key>match</key>
<string>,</string>
<key>name</key>
<string>punctuation.separator.comma.haskell</string>
</dict>
</array>
<key>repository</key>
<dict>
<key>block_comment</key>
<dict>
<key>applyEndPatternLast</key>
<integer>1</integer>
<key>begin</key>
<string>\{-(?!#)</string>
<key>captures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.comment.haskell</string>
</dict>
</dict>
<key>end</key>
<string>-\}</string>
<key>name</key>
<string>comment.block.haskell</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#block_comment</string>
</dict>
</array>
</dict>
<key>comments</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.comment.haskell</string>
</dict>
</dict>
<key>match</key>
<string>(--).*$\n?</string>
<key>name</key>
<string>comment.line.double-dash.haskell</string>
</dict>
<dict>
<key>include</key>
<string>#block_comment</string>
</dict>
</array>
</dict>
<key>infix_op</key>
<dict>
<key>match</key>
<string>(\([|!%$+:\-.=</>]+\)|\(,+\))</string>
<key>name</key>
<string>entity.name.function.infix.haskell</string>
</dict>
<key>module_exports</key>
<dict>
<key>begin</key>
<string>\(</string>
<key>end</key>
<string>\)</string>
<key>name</key>
<string>meta.declaration.exports.haskell</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\b[a-z][a-zA-Z_'0-9]*</string>
<key>name</key>
<string>entity.name.function.haskell</string>
</dict>
<dict>
<key>match</key>
<string>\b[A-Z][A-Za-z_'0-9]*</string>
<key>name</key>
<string>storage.type.haskell</string>
</dict>
<dict>
<key>match</key>
<string>,</string>
<key>name</key>
<string>punctuation.separator.comma.haskell</string>
</dict>
<dict>
<key>include</key>
<string>#infix_op</string>
</dict>
<dict>
<key>comment</key>
<string>So named because I don't know what to call this.</string>
<key>match</key>
<string>\(.*?\)</string>
<key>name</key>
<string>meta.other.unknown.haskell</string>
</dict>
</array>
</dict>
<key>module_name</key>
<dict>
<key>match</key>
<string>[A-Z][A-Za-z._']*</string>
<key>name</key>
<string>support.other.module.haskell</string>
</dict>
<key>pragma</key>
<dict>
<key>begin</key>
<string>\{-#</string>
<key>end</key>
<string>#-\}</string>
<key>name</key>
<string>meta.preprocessor.haskell</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\b(LANGUAGE|UNPACK|INLINE)\b</string>
<key>name</key>
<string>keyword.other.preprocessor.haskell</string>
</dict>
</array>
</dict>
<key>type_signature</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#pragma</string>
</dict>
<dict>
<key>match</key>
<string>-></string>
<key>name</key>
<string>keyword.other.arrow.haskell</string>
</dict>
<dict>
<key>match</key>
<string>=></string>
<key>name</key>
<string>keyword.other.big-arrow.haskell</string>
</dict>
<dict>
<key>match</key>
<string>\b[a-z][a-zA-Z0-9_']*\b</string>
<key>name</key>
<string>variable.other.generic-type.haskell</string>
</dict>
<dict>
<key>match</key>
<string>\b[A-Z][a-zA-Z0-9_']*\b</string>
<key>name</key>
<string>storage.type.haskell</string>
</dict>
<dict>
<key>match</key>
<string>\(\)</string>
<key>name</key>
<string>support.constant.unit.haskell</string>
</dict>
<dict>
<key>include</key>
<string>#comments</string>
</dict>
</array>
</dict>
</dict>
<key>scopeName</key>
<string>source.haskell</string>
<key>uuid</key>
<string>5C034675-1F6D-497E-8073-369D37E2FD7D</string>
</dict>
</plist>
| {
"pile_set_name": "Github"
} |
using System;
namespace Substrate.Nbt
{
/// <summary>
/// A concrete <see cref="SchemaNode"/> representing a <see cref="TagNodeString"/>.
/// </summary>
public sealed class SchemaNodeString : SchemaNode
{
private string _value = "";
private int _length;
/// <summary>
/// Gets the maximum length of a valid string.
/// </summary>
public int Length
{
get { return _length; }
}
/// <summary>
/// Gets the expected value of a valid string.
/// </summary>
/// <remarks>A <see cref="TagNodeString"/> must be set to this value to be considered valid.</remarks>
public string Value
{
get { return _value; }
}
/// <summary>
/// Indicates whether there is a maximum-length constraint on strings in this node.
/// </summary>
public bool HasMaxLength
{
get { return _length > 0; }
}
/// <summary>
/// Constructs a new <see cref="SchemaNodeString"/> representing a <see cref="TagNodeString"/> named <paramref name="name"/>.
/// </summary>
/// <param name="name">The name of the corresponding <see cref="TagNodeString"/>.</param>
public SchemaNodeString (string name)
: base(name)
{
}
/// <summary>
/// Constructs a new <see cref="SchemaNodeString"/> with additional options.
/// </summary>
/// <param name="name">The name of the corresponding <see cref="TagNodeString"/>.</param>
/// <param name="options">One or more option flags modifying the processing of this node.</param>
public SchemaNodeString (string name, SchemaOptions options)
: base(name, options)
{
}
/// <summary>
/// Constructs a new <see cref="SchemaNodeString"/> representing a <see cref="TagNodeString"/> named <paramref name="name"/> set to <paramref name="value"/>.
/// </summary>
/// <param name="name">The name of the corresponding <see cref="TagNodeString"/>.</param>
/// <param name="value">The value that the corresponding <see cref="TagNodeString"/> must be set to.</param>
public SchemaNodeString (string name, string value)
: base(name)
{
_value = value;
}
/// <summary>
/// Constructs a new <see cref="SchemaNodeString"/> with additional options.
/// </summary>
/// <param name="name">The name of the corresponding <see cref="TagNodeString"/>.</param>
/// <param name="value">The value that the corresponding <see cref="TagNodeString"/> must be set to.</param>
/// <param name="options">One or more option flags modifying the processing of this node.</param>
public SchemaNodeString (string name, string value, SchemaOptions options)
: base(name, options)
{
_value = value;
}
/// <summary>
/// Constructs a new <see cref="SchemaNodeString"/> representing a <see cref="TagNodeString"/> named <paramref name="name"/> with maximum length <paramref name="length"/>.
/// </summary>
/// <param name="name">The name of the corresponding <see cref="TagNodeString"/>.</param>
/// <param name="length">The maximum length of strings in the corresponding <see cref="TagNodeString"/>.</param>
public SchemaNodeString (string name, int length)
: base(name)
{
_length = length;
}
/// <summary>
/// Constructs a new <see cref="SchemaNodeString"/> with additional options.
/// </summary>
/// <param name="name">The name of the corresponding <see cref="TagNodeString"/>.</param>
/// <param name="length">The maximum length of strings in the corresponding <see cref="TagNodeString"/>.</param>
/// <param name="options">One or more option flags modifying the processing of this node.</param>
public SchemaNodeString (string name, int length, SchemaOptions options)
: base(name, options)
{
_length = length;
}
/// <summary>
/// Constructs a default <see cref="TagNodeString"/> satisfying the constraints of this node.
/// </summary>
/// <returns>A <see cref="TagNodeString"/> with a sensible default value. If this node represents a particular string, the <see cref="TagNodeString"/> constructed will be set to that string.</returns>
public override TagNode BuildDefaultTree ()
{
if (_value.Length > 0) {
return new TagNodeString(_value);
}
return new TagNodeString();
}
}
}
| {
"pile_set_name": "Github"
} |
#define TEST_NAME "ed25519_convert"
#include "cmptest.h"
static const unsigned char keypair_seed[crypto_sign_ed25519_SEEDBYTES] = {
0x42, 0x11, 0x51, 0xa4, 0x59, 0xfa, 0xea, 0xde, 0x3d, 0x24, 0x71,
0x15, 0xf9, 0x4a, 0xed, 0xae, 0x42, 0x31, 0x81, 0x24, 0x09, 0x5a,
0xfa, 0xbe, 0x4d, 0x14, 0x51, 0xa5, 0x59, 0xfa, 0xed, 0xee
};
int
main(void)
{
unsigned char ed25519_pk[crypto_sign_ed25519_PUBLICKEYBYTES];
unsigned char ed25519_skpk[crypto_sign_ed25519_SECRETKEYBYTES];
unsigned char curve25519_pk[crypto_scalarmult_curve25519_BYTES];
unsigned char curve25519_pk2[crypto_scalarmult_curve25519_BYTES];
unsigned char curve25519_sk[crypto_scalarmult_curve25519_BYTES];
char curve25519_pk_hex[crypto_scalarmult_curve25519_BYTES * 2 + 1];
char curve25519_sk_hex[crypto_scalarmult_curve25519_BYTES * 2 + 1];
unsigned int i;
assert(crypto_sign_ed25519_SEEDBYTES <= crypto_hash_sha512_BYTES);
crypto_sign_ed25519_seed_keypair(ed25519_pk, ed25519_skpk, keypair_seed);
if (crypto_sign_ed25519_pk_to_curve25519(curve25519_pk, ed25519_pk) != 0) {
printf("conversion failed\n");
}
crypto_sign_ed25519_sk_to_curve25519(curve25519_sk, ed25519_skpk);
sodium_bin2hex(curve25519_pk_hex, sizeof curve25519_pk_hex, curve25519_pk,
sizeof curve25519_pk);
sodium_bin2hex(curve25519_sk_hex, sizeof curve25519_sk_hex, curve25519_sk,
sizeof curve25519_sk);
printf("curve25519 pk: [%s]\n", curve25519_pk_hex);
printf("curve25519 sk: [%s]\n", curve25519_sk_hex);
for (i = 0U; i < 500U; i++) {
crypto_sign_ed25519_keypair(ed25519_pk, ed25519_skpk);
if (crypto_sign_ed25519_pk_to_curve25519(curve25519_pk, ed25519_pk) !=
0) {
printf("conversion failed\n");
}
crypto_sign_ed25519_sk_to_curve25519(curve25519_sk, ed25519_skpk);
crypto_scalarmult_curve25519_base(curve25519_pk2, curve25519_sk);
if (memcmp(curve25519_pk, curve25519_pk2, sizeof curve25519_pk) != 0) {
printf("conversion failed\n");
}
}
sodium_hex2bin(ed25519_pk, crypto_sign_ed25519_PUBLICKEYBYTES,
"0000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000",
64, NULL, NULL, NULL);
assert(crypto_sign_ed25519_pk_to_curve25519(curve25519_pk, ed25519_pk) == -1);
sodium_hex2bin(ed25519_pk, crypto_sign_ed25519_PUBLICKEYBYTES,
"0200000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000",
64, NULL, NULL, NULL);
assert(crypto_sign_ed25519_pk_to_curve25519(curve25519_pk, ed25519_pk) == -1);
sodium_hex2bin(ed25519_pk, crypto_sign_ed25519_PUBLICKEYBYTES,
"0500000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000",
64, NULL, NULL, NULL);
assert(crypto_sign_ed25519_pk_to_curve25519(curve25519_pk, ed25519_pk) == -1);
printf("ok\n");
return 0;
}
| {
"pile_set_name": "Github"
} |
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"), require("../../mode/css/css"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror", "../../mode/css/css"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
var pseudoClasses = {link: 1, visited: 1, active: 1, hover: 1, focus: 1,
"first-letter": 1, "first-line": 1, "first-child": 1,
before: 1, after: 1, lang: 1};
CodeMirror.registerHelper("hint", "css", function(cm) {
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
var inner = CodeMirror.innerMode(cm.getMode(), token.state);
if (inner.mode.name != "css") return;
var start = token.start, end = cur.ch, word = token.string.slice(0, end - start);
if (/[^\w$_-]/.test(word)) {
word = ""; start = end = cur.ch;
}
var spec = CodeMirror.resolveMode("text/css");
var result = [];
function add(keywords) {
for (var name in keywords)
if (!word || name.lastIndexOf(word, 0) == 0)
result.push(name);
}
var st = inner.state.state;
if (st == "pseudo" || token.type == "variable-3") {
add(pseudoClasses);
} else if (st == "block" || st == "maybeprop") {
add(spec.propertyKeywords);
} else if (st == "prop" || st == "parens" || st == "at" || st == "params") {
add(spec.valueKeywords);
add(spec.colorKeywords);
} else if (st == "media" || st == "media_parens") {
add(spec.mediaTypes);
add(spec.mediaFeatures);
}
if (result.length) return {
list: result,
from: CodeMirror.Pos(cur.line, start),
to: CodeMirror.Pos(cur.line, end)
};
});
});
| {
"pile_set_name": "Github"
} |
#ifndef Py_INTRCHECK_H
#define Py_INTRCHECK_H
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_FUNC(int) PyOS_InterruptOccurred(void);
PyAPI_FUNC(void) PyOS_InitInterrupts(void);
PyAPI_FUNC(void) PyOS_AfterFork(void);
PyAPI_FUNC(int) _PyOS_IsMainThread(void);
#ifdef MS_WINDOWS
/* windows.h is not included by Python.h so use void* instead of HANDLE */
PyAPI_FUNC(void*) _PyOS_SigintEvent(void);
#endif
#ifdef __cplusplus
}
#endif
#endif /* !Py_INTRCHECK_H */
| {
"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.
*/
#ifndef H_BLE_UUID_PRIV_
#define H_BLE_UUID_PRIV_
#include "host/ble_uuid.h"
#ifdef __cplusplus
extern "C" {
#endif
struct os_mbuf;
int ble_uuid_init_from_att_mbuf(ble_uuid_any_t *uuid, struct os_mbuf *om,
int off, int len);
int ble_uuid_init_from_att_buf(ble_uuid_any_t *uuid, const void *buf,
size_t len);
int ble_uuid_to_any(const ble_uuid_t *uuid, ble_uuid_any_t *uuid_any);
int ble_uuid_to_mbuf(const ble_uuid_t *uuid, struct os_mbuf *om);
int ble_uuid_flat(const ble_uuid_t *uuid, void *dst);
int ble_uuid_length(const ble_uuid_t *uuid);
#ifdef __cplusplus
}
#endif
#endif
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="utf-8"?>
<!-- (c) 2006 Microsoft Corporation -->
<policyDefinitionResources xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.0" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<displayName>enter display name here</displayName>
<description>enter description here</description>
<resources>
<stringTable>
<string id="DefaultLogonDomain">Assign a default domain for logon</string>
<string id="DefaultLogonDomain_Help">This policy setting specifies a default logon domain, which might be a different domain than the domain to which the computer is joined. Without this policy setting, at logon, if a user does not specify a domain for logon, the domain to which the computer belongs is assumed as the default domain. For example if the computer belongs to the Fabrikam domain, the default domain for user logon is Fabrikam.
If you enable this policy setting, the default logon domain is set to the specified domain, which might be different than the domain to which the computer is joined.
If you disable or do not configure this policy setting, the default logon domain is always set to the domain to which the computer is joined.</string>
<string id="ExcludedCredentialProviders">Exclude credential providers</string>
<string id="ExcludedCredentialProviders_Help">This policy setting allows the administrator to exclude the specified
credential providers from use during authentication.
Note: credential providers are used to process and validate user
credentials during logon or when authentication is required.
Windows Vista provides two default credential providers:
Password and Smart Card. An administrator can install additional
credential providers for different sets of credentials
(for example, to support biometric authentication).
If you enable this policy, an administrator can specify the CLSIDs
of the credential providers to exclude from the set of installed
credential providers available for authentication purposes.
If you disable or do not configure this policy, all installed and otherwise enabled credential providers are available for authentication purposes.</string>
<string id="Logon">Logon</string>
<string id="AllowDomainPINLogon">Turn on convenience PIN sign-in</string>
<string id="AllowDomainPINLogon_Help">This policy setting allows you to control whether a domain user can sign in using a convenience PIN.
If you enable this policy setting, a domain user can set up and sign in with a convenience PIN.
If you disable or don't configure this policy setting, a domain user can't set up and use a convenience PIN.
Note: The user's domain password will be cached in the system vault when using this feature.
To configure Windows Hello for Business, use the Administrative Template policies under Windows Hello for Business.</string>
<string id="BlockDomainPicturePassword">Turn off picture password sign-in</string>
<string id="BlockDomainPicturePassword_Help">This policy setting allows you to control whether a domain user can sign in using a picture password.
If you enable this policy setting, a domain user can't set up or sign in with a picture password.
If you disable or don't configure this policy setting, a domain user can set up and use a picture password.
Note that the user's domain password will be cached in the system vault when using this feature.</string>
<string id="AllowDomainDelayLock">Allow users to select when a password is required when resuming from connected standby</string>
<string id="AllowDomainDelayLock_Help">This policy setting allows you to control whether a user can change the time before a password is required when a Connected Standby device screen turns off.
If you enable this policy setting, a user on a Connected Standby device can change the amount of time after the device's screen turns off before a password is required when waking the device. The time is limited by any EAS settings or Group Policies that affect the maximum idle time before a device locks. Additionally, if a password is required when a screensaver turns on, the screensaver timeout will limit the options the user may choose.
If you disable this policy setting, a user cannot change the amount of time after the device's screen turns off before a password is required when waking the device. Instead, a password is required immediately after the screen turns off.
If you don't configure this policy setting on a domain-joined device, a user cannot change the amount of time after the device's screen turns off before a password is required when waking the device. Instead, a password is required immediately after the screen turns off.
If you don't configure this policy setting on a workgroup device, a user on a Connected Standby device can change the amount of time after the device's screen turns off before a password is required when waking the device. The time is limited by any EAS settings or Group Policies that affect the maximum idle time before a device locks. Additionally, if a password is required when a screensaver turns on, the screensaver timeout will limit the options the user may choose.</string>
<string id="DefaultCredentialProvider">Assign a default credential provider</string>
<string id="DefaultCredentialProvider_Help">This policy setting allows the administrator to assign a specified credential provider as the default credential provider.
If you enable this policy setting, the specified credential provider is selected on other user tile.
If you disable or do not configure this policy setting, the system picks the default credential provider on other user tile.
Note: A list of registered credential providers and their GUIDs can be found in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers.</string>
</stringTable>
<presentationTable>
<presentation id="DefaultLogonDomain">
<textBox refId="DefaultLogonDomain_Message">
<label>Default Logon domain:</label>
</textBox>
<text>Enter the name of the domain</text>
</presentation>
<presentation id="ExcludedCredentialProviders">
<textBox refId="ExcludedCredentialProviders_Message">
<label>Exclude the following credential providers:</label>
</textBox>
<text>Enter the comma-separated CLSIDs for multiple credential providers
to be excluded from use during authentication.
For example: {ba0dd1d5-9754-4ba3-973c-40dce7901283},{383f1aa4-65dd-45bc-9f5a-ddd2f222f07d}</text>
</presentation>
<presentation id="DefaultCredentialProvider">
<textBox refId="DefaultCredentialProvider_Message">
<label>Assign the following credential provider as the default credential provider:</label>
</textBox>
<text>Enter the CLSID of a credential provider to be the default credential provider.
For example: {ba0dd1d5-9754-4ba3-973c-40dce7901283}</text>
</presentation>
</presentationTable>
</resources>
</policyDefinitionResources>
| {
"pile_set_name": "Github"
} |
/*
* ASoC codec driver for spear platform
*
* sound/soc/codecs/sta529.c -- spear ALSA Soc codec driver
*
* Copyright (C) 2012 ST Microelectronics
* Rajeev Kumar <[email protected]>
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
#include <linux/clk.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/pm.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/initval.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/tlv.h>
/* STA529 Register offsets */
#define STA529_FFXCFG0 0x00
#define STA529_FFXCFG1 0x01
#define STA529_MVOL 0x02
#define STA529_LVOL 0x03
#define STA529_RVOL 0x04
#define STA529_TTF0 0x05
#define STA529_TTF1 0x06
#define STA529_TTP0 0x07
#define STA529_TTP1 0x08
#define STA529_S2PCFG0 0x0A
#define STA529_S2PCFG1 0x0B
#define STA529_P2SCFG0 0x0C
#define STA529_P2SCFG1 0x0D
#define STA529_PLLCFG0 0x14
#define STA529_PLLCFG1 0x15
#define STA529_PLLCFG2 0x16
#define STA529_PLLCFG3 0x17
#define STA529_PLLPFE 0x18
#define STA529_PLLST 0x19
#define STA529_ADCCFG 0x1E /*mic_select*/
#define STA529_CKOCFG 0x1F
#define STA529_MISC 0x20
#define STA529_PADST0 0x21
#define STA529_PADST1 0x22
#define STA529_FFXST 0x23
#define STA529_PWMIN1 0x2D
#define STA529_PWMIN2 0x2E
#define STA529_POWST 0x32
#define STA529_MAX_REGISTER 0x32
#define STA529_RATES (SNDRV_PCM_RATE_8000 | \
SNDRV_PCM_RATE_11025 | \
SNDRV_PCM_RATE_16000 | \
SNDRV_PCM_RATE_22050 | \
SNDRV_PCM_RATE_32000 | \
SNDRV_PCM_RATE_44100 | \
SNDRV_PCM_RATE_48000)
#define STA529_FORMAT (SNDRV_PCM_FMTBIT_S16_LE | \
SNDRV_PCM_FMTBIT_S24_LE | \
SNDRV_PCM_FMTBIT_S32_LE)
#define S2PC_VALUE 0x98
#define CLOCK_OUT 0x60
#define DATA_FORMAT_MSK 0x0E
#define LEFT_J_DATA_FORMAT 0x00
#define I2S_DATA_FORMAT 0x02
#define RIGHT_J_DATA_FORMAT 0x04
#define CODEC_MUTE_VAL 0x80
#define POWER_CNTLMSAK 0x40
#define POWER_STDBY 0x40
#define FFX_MASK 0x80
#define FFX_OFF 0x80
#define POWER_UP 0x00
#define FFX_CLK_ENB 0x01
#define FFX_CLK_DIS 0x00
#define FFX_CLK_MSK 0x01
#define PLAY_FREQ_RANGE_MSK 0x70
#define CAP_FREQ_RANGE_MSK 0x0C
#define PDATA_LEN_MSK 0xC0
#define BCLK_TO_FS_MSK 0x30
#define AUDIO_MUTE_MSK 0x80
static const struct reg_default sta529_reg_defaults[] = {
{ 0, 0x35 }, /* R0 - FFX Configuration reg 0 */
{ 1, 0xc8 }, /* R1 - FFX Configuration reg 1 */
{ 2, 0x50 }, /* R2 - Master Volume */
{ 3, 0x00 }, /* R3 - Left Volume */
{ 4, 0x00 }, /* R4 - Right Volume */
{ 10, 0xb2 }, /* R10 - S2P Config Reg 0 */
{ 11, 0x41 }, /* R11 - S2P Config Reg 1 */
{ 12, 0x92 }, /* R12 - P2S Config Reg 0 */
{ 13, 0x41 }, /* R13 - P2S Config Reg 1 */
{ 30, 0xd2 }, /* R30 - ADC Config Reg */
{ 31, 0x40 }, /* R31 - clock Out Reg */
{ 32, 0x21 }, /* R32 - Misc Register */
};
struct sta529 {
struct regmap *regmap;
};
static bool sta529_readable(struct device *dev, unsigned int reg)
{
switch (reg) {
case STA529_FFXCFG0:
case STA529_FFXCFG1:
case STA529_MVOL:
case STA529_LVOL:
case STA529_RVOL:
case STA529_S2PCFG0:
case STA529_S2PCFG1:
case STA529_P2SCFG0:
case STA529_P2SCFG1:
case STA529_ADCCFG:
case STA529_CKOCFG:
case STA529_MISC:
return true;
default:
return false;
}
}
static const char *pwm_mode_text[] = { "Binary", "Headphone", "Ternary",
"Phase-shift"};
static const DECLARE_TLV_DB_SCALE(out_gain_tlv, -9150, 50, 0);
static const DECLARE_TLV_DB_SCALE(master_vol_tlv, -12750, 50, 0);
static SOC_ENUM_SINGLE_DECL(pwm_src, STA529_FFXCFG1, 4, pwm_mode_text);
static const struct snd_kcontrol_new sta529_snd_controls[] = {
SOC_DOUBLE_R_TLV("Digital Playback Volume", STA529_LVOL, STA529_RVOL, 0,
127, 0, out_gain_tlv),
SOC_SINGLE_TLV("Master Playback Volume", STA529_MVOL, 0, 127, 1,
master_vol_tlv),
SOC_ENUM("PWM Select", pwm_src),
};
static int sta529_set_bias_level(struct snd_soc_codec *codec, enum
snd_soc_bias_level level)
{
struct sta529 *sta529 = snd_soc_codec_get_drvdata(codec);
switch (level) {
case SND_SOC_BIAS_ON:
case SND_SOC_BIAS_PREPARE:
snd_soc_update_bits(codec, STA529_FFXCFG0, POWER_CNTLMSAK,
POWER_UP);
snd_soc_update_bits(codec, STA529_MISC, FFX_CLK_MSK,
FFX_CLK_ENB);
break;
case SND_SOC_BIAS_STANDBY:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)
regcache_sync(sta529->regmap);
snd_soc_update_bits(codec, STA529_FFXCFG0,
POWER_CNTLMSAK, POWER_STDBY);
/* Making FFX output to zero */
snd_soc_update_bits(codec, STA529_FFXCFG0, FFX_MASK,
FFX_OFF);
snd_soc_update_bits(codec, STA529_MISC, FFX_CLK_MSK,
FFX_CLK_DIS);
break;
case SND_SOC_BIAS_OFF:
break;
}
return 0;
}
static int sta529_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
int pdata, play_freq_val, record_freq_val;
int bclk_to_fs_ratio;
switch (params_width(params)) {
case 16:
pdata = 1;
bclk_to_fs_ratio = 0;
break;
case 24:
pdata = 2;
bclk_to_fs_ratio = 1;
break;
case 32:
pdata = 3;
bclk_to_fs_ratio = 2;
break;
default:
dev_err(codec->dev, "Unsupported format\n");
return -EINVAL;
}
switch (params_rate(params)) {
case 8000:
case 11025:
play_freq_val = 0;
record_freq_val = 2;
break;
case 16000:
case 22050:
play_freq_val = 1;
record_freq_val = 0;
break;
case 32000:
case 44100:
case 48000:
play_freq_val = 2;
record_freq_val = 0;
break;
default:
dev_err(codec->dev, "Unsupported rate\n");
return -EINVAL;
}
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
snd_soc_update_bits(codec, STA529_S2PCFG1, PDATA_LEN_MSK,
pdata << 6);
snd_soc_update_bits(codec, STA529_S2PCFG1, BCLK_TO_FS_MSK,
bclk_to_fs_ratio << 4);
snd_soc_update_bits(codec, STA529_MISC, PLAY_FREQ_RANGE_MSK,
play_freq_val << 4);
} else {
snd_soc_update_bits(codec, STA529_P2SCFG1, PDATA_LEN_MSK,
pdata << 6);
snd_soc_update_bits(codec, STA529_P2SCFG1, BCLK_TO_FS_MSK,
bclk_to_fs_ratio << 4);
snd_soc_update_bits(codec, STA529_MISC, CAP_FREQ_RANGE_MSK,
record_freq_val << 2);
}
return 0;
}
static int sta529_mute(struct snd_soc_dai *dai, int mute)
{
u8 val = 0;
if (mute)
val |= CODEC_MUTE_VAL;
snd_soc_update_bits(dai->codec, STA529_FFXCFG0, AUDIO_MUTE_MSK, val);
return 0;
}
static int sta529_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt)
{
struct snd_soc_codec *codec = codec_dai->codec;
u8 mode = 0;
/* interface format */
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_LEFT_J:
mode = LEFT_J_DATA_FORMAT;
break;
case SND_SOC_DAIFMT_I2S:
mode = I2S_DATA_FORMAT;
break;
case SND_SOC_DAIFMT_RIGHT_J:
mode = RIGHT_J_DATA_FORMAT;
break;
default:
return -EINVAL;
}
snd_soc_update_bits(codec, STA529_S2PCFG0, DATA_FORMAT_MSK, mode);
return 0;
}
static const struct snd_soc_dai_ops sta529_dai_ops = {
.hw_params = sta529_hw_params,
.set_fmt = sta529_set_dai_fmt,
.digital_mute = sta529_mute,
};
static struct snd_soc_dai_driver sta529_dai = {
.name = "sta529-audio",
.playback = {
.stream_name = "Playback",
.channels_min = 2,
.channels_max = 2,
.rates = STA529_RATES,
.formats = STA529_FORMAT,
},
.capture = {
.stream_name = "Capture",
.channels_min = 2,
.channels_max = 2,
.rates = STA529_RATES,
.formats = STA529_FORMAT,
},
.ops = &sta529_dai_ops,
};
static const struct snd_soc_codec_driver sta529_codec_driver = {
.set_bias_level = sta529_set_bias_level,
.suspend_bias_off = true,
.component_driver = {
.controls = sta529_snd_controls,
.num_controls = ARRAY_SIZE(sta529_snd_controls),
},
};
static const struct regmap_config sta529_regmap = {
.reg_bits = 8,
.val_bits = 8,
.max_register = STA529_MAX_REGISTER,
.readable_reg = sta529_readable,
.cache_type = REGCACHE_RBTREE,
.reg_defaults = sta529_reg_defaults,
.num_reg_defaults = ARRAY_SIZE(sta529_reg_defaults),
};
static int sta529_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct sta529 *sta529;
int ret;
sta529 = devm_kzalloc(&i2c->dev, sizeof(struct sta529), GFP_KERNEL);
if (!sta529)
return -ENOMEM;
sta529->regmap = devm_regmap_init_i2c(i2c, &sta529_regmap);
if (IS_ERR(sta529->regmap)) {
ret = PTR_ERR(sta529->regmap);
dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
return ret;
}
i2c_set_clientdata(i2c, sta529);
ret = snd_soc_register_codec(&i2c->dev,
&sta529_codec_driver, &sta529_dai, 1);
if (ret != 0)
dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
return ret;
}
static int sta529_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id sta529_i2c_id[] = {
{ "sta529", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, sta529_i2c_id);
static const struct of_device_id sta529_of_match[] = {
{ .compatible = "st,sta529", },
{ }
};
MODULE_DEVICE_TABLE(of, sta529_of_match);
static struct i2c_driver sta529_i2c_driver = {
.driver = {
.name = "sta529",
.of_match_table = sta529_of_match,
},
.probe = sta529_i2c_probe,
.remove = sta529_i2c_remove,
.id_table = sta529_i2c_id,
};
module_i2c_driver(sta529_i2c_driver);
MODULE_DESCRIPTION("ASoC STA529 codec driver");
MODULE_AUTHOR("Rajeev Kumar <[email protected]>");
MODULE_LICENSE("GPL");
| {
"pile_set_name": "Github"
} |
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause
*
* Based on the Base 64 VLQ implementation in Closure Compiler:
* https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
*
* Copyright 2011 The Closure Compiler Authors. 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.
*/
if (typeof define !== 'function') {
var define = require('amdefine')(module, require);
}
define(function (require, exports, module) {
var base64 = require('./base64');
// A single base 64 digit can contain 6 bits of data. For the base 64 variable
// length quantities we use in the source map spec, the first bit is the sign,
// the next four bits are the actual value, and the 6th bit is the
// continuation bit. The continuation bit tells us whether there are more
// digits in this value following this digit.
//
// Continuation
// | Sign
// | |
// V V
// 101011
var VLQ_BASE_SHIFT = 5;
// binary: 100000
var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
// binary: 011111
var VLQ_BASE_MASK = VLQ_BASE - 1;
// binary: 100000
var VLQ_CONTINUATION_BIT = VLQ_BASE;
/**
* Converts from a two-complement value to a value where the sign bit is
* placed in the least significant bit. For example, as decimals:
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
*/
function toVLQSigned(aValue) {
return aValue < 0
? ((-aValue) << 1) + 1
: (aValue << 1) + 0;
}
/**
* Converts to a two-complement value from a value where the sign bit is
* placed in the least significant bit. For example, as decimals:
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
*/
function fromVLQSigned(aValue) {
var isNegative = (aValue & 1) === 1;
var shifted = aValue >> 1;
return isNegative
? -shifted
: shifted;
}
/**
* Returns the base 64 VLQ encoded value.
*/
exports.encode = function base64VLQ_encode(aValue) {
var encoded = "";
var digit;
var vlq = toVLQSigned(aValue);
do {
digit = vlq & VLQ_BASE_MASK;
vlq >>>= VLQ_BASE_SHIFT;
if (vlq > 0) {
// There are still more digits in this value, so we must make sure the
// continuation bit is marked.
digit |= VLQ_CONTINUATION_BIT;
}
encoded += base64.encode(digit);
} while (vlq > 0);
return encoded;
};
/**
* Decodes the next base 64 VLQ value from the given string and returns the
* value and the rest of the string via the out parameter.
*/
exports.decode = function base64VLQ_decode(aStr, aOutParam) {
var i = 0;
var strLen = aStr.length;
var result = 0;
var shift = 0;
var continuation, digit;
do {
if (i >= strLen) {
throw new Error("Expected more digits in base 64 VLQ value.");
}
digit = base64.decode(aStr.charAt(i++));
continuation = !!(digit & VLQ_CONTINUATION_BIT);
digit &= VLQ_BASE_MASK;
result = result + (digit << shift);
shift += VLQ_BASE_SHIFT;
} while (continuation);
aOutParam.value = fromVLQSigned(result);
aOutParam.rest = aStr.slice(i);
};
});
| {
"pile_set_name": "Github"
} |
/*
* Copyright (C) 2008 Search Solution Corporation. All rights reserved by Search Solution.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of the <ORGANIZATION> 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.
*
*/
package cubrid.jdbc.driver;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.Reference;
import javax.naming.spi.ObjectFactory;
/**
* Title: CUBRID JDBC Driver Description:
*
* @version 3.0
*/
public class CUBRIDDataSourceObjectFactory implements ObjectFactory {
public Object getObjectInstance(Object refObj, Name name, Context nameCtx,
Hashtable<?, ?> env) throws Exception {
Reference ref = (Reference) refObj;
if (ref.getClassName().equals("cubrid.jdbc.driver.CUBRIDDataSource")) {
return (new CUBRIDDataSource(ref));
}
if (ref.getClassName().equals(
"cubrid.jdbc.driver.CUBRIDConnectionPoolDataSource")) {
return (new CUBRIDConnectionPoolDataSource(ref));
}
if (ref.getClassName().equals("cubrid.jdbc.driver.CUBRIDXADataSource")) {
return (new CUBRIDXADataSource(ref));
}
return null;
}
}
| {
"pile_set_name": "Github"
} |
-module(msg).
-export([send_on_heap/0
,send_off_heap/0]).
send_on_heap() -> send(on_heap).
send_off_heap() -> send(off_heap).
send(How) ->
%% Spawn a function that loops for a while
P2 = spawn(fun () -> receiver(How) end),
%% spawn a sending process
P1 = spawn(fun () -> sender(P2) end),
P1.
sender(P2) ->
%% Send a message that ends up on the heap
%% {_,S} = erlang:process_info(P2, heap_size),
M = loop(0),
P2 ! self(),
receive ready -> ok end,
P2 ! M,
%% Print the PCB of P2
hipe_bifs:show_pcb(P2),
ok.
receiver(How) ->
erlang:process_flag(message_queue_data,How),
receive P -> P ! ready end,
%% loop(100000),
receive x -> ok end,
P.
loop(0) -> [done];
loop(N) -> [loop(N-1)].
| {
"pile_set_name": "Github"
} |
% DOCKER(1) Docker User Manuals
% Docker Community
% FEBRUARY 2015
# NAME
docker-ps - List containers
# SYNOPSIS
**docker ps**
[**-a**|**--all**]
[**-f**|**--filter**[=*[]*]]
[**--format**=*"TEMPLATE"*]
[**--help**]
[**-l**|**--latest**]
[**-n**[=*-1*]]
[**--no-trunc**]
[**-q**|**--quiet**]
[**-s**|**--size**]
# DESCRIPTION
List the containers in the local repository. By default this shows only
the running containers.
# OPTIONS
**-a**, **--all**=*true*|*false*
Show all containers. Only running containers are shown by default. The default is *false*.
**-f**, **--filter**=[]
Filter output based on these conditions:
- exited=<int> an exit code of <int>
- label=<key> or label=<key>=<value>
- status=(created|restarting|running|paused|exited|dead)
- name=<string> a container's name
- id=<ID> a container's ID
- before=(<container-name>|<container-id>)
- since=(<container-name>|<container-id>)
- ancestor=(<image-name>[:tag]|<image-id>|<image@digest>) - containers created from an image or a descendant.
- volume=(<volume-name>|<mount-point-destination>)
- network=(<network-name>|<network-id>) - containers connected to the provided network
**--format**="*TEMPLATE*"
Pretty-print containers using a Go template.
Valid placeholders:
.ID - Container ID
.Image - Image ID
.Command - Quoted command
.CreatedAt - Time when the container was created.
.RunningFor - Elapsed time since the container was started.
.Ports - Exposed ports.
.Status - Container status.
.Size - Container disk size.
.Names - Container names.
.Labels - All labels assigned to the container.
.Label - Value of a specific label for this container. For example `{{.Label "com.docker.swarm.cpu"}}`
.Mounts - Names of the volumes mounted in this container.
**--help**
Print usage statement
**-l**, **--latest**=*true*|*false*
Show only the latest created container (includes all states). The default is *false*.
**-n**=*-1*
Show n last created containers (includes all states).
**--no-trunc**=*true*|*false*
Don't truncate output. The default is *false*.
**-q**, **--quiet**=*true*|*false*
Only display numeric IDs. The default is *false*.
**-s**, **--size**=*true*|*false*
Display total file sizes. The default is *false*.
# EXAMPLES
# Display all containers, including non-running
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a87ecb4f327c fedora:20 /bin/sh -c #(nop) MA 20 minutes ago Exit 0 desperate_brattain
01946d9d34d8 vpavlin/rhel7:latest /bin/sh -c #(nop) MA 33 minutes ago Exit 0 thirsty_bell
c1d3b0166030 acffc0358b9e /bin/sh -c yum -y up 2 weeks ago Exit 1 determined_torvalds
41d50ecd2f57 fedora:20 /bin/sh -c #(nop) MA 2 weeks ago Exit 0 drunk_pike
# Display only IDs of all containers, including non-running
# docker ps -a -q
a87ecb4f327c
01946d9d34d8
c1d3b0166030
41d50ecd2f57
# Display only IDs of all containers that have the name `determined_torvalds`
# docker ps -a -q --filter=name=determined_torvalds
c1d3b0166030
# Display containers with their commands
# docker ps --format "{{.ID}}: {{.Command}}"
a87ecb4f327c: /bin/sh -c #(nop) MA
01946d9d34d8: /bin/sh -c #(nop) MA
c1d3b0166030: /bin/sh -c yum -y up
41d50ecd2f57: /bin/sh -c #(nop) MA
# Display containers with their labels in a table
# docker ps --format "table {{.ID}}\t{{.Labels}}"
CONTAINER ID LABELS
a87ecb4f327c com.docker.swarm.node=ubuntu,com.docker.swarm.storage=ssd
01946d9d34d8
c1d3b0166030 com.docker.swarm.node=debian,com.docker.swarm.cpu=6
41d50ecd2f57 com.docker.swarm.node=fedora,com.docker.swarm.cpu=3,com.docker.swarm.storage=ssd
# Display containers with their node label in a table
# docker ps --format 'table {{.ID}}\t{{(.Label "com.docker.swarm.node")}}'
CONTAINER ID NODE
a87ecb4f327c ubuntu
01946d9d34d8
c1d3b0166030 debian
41d50ecd2f57 fedora
# Display containers with `remote-volume` mounted
$ docker ps --filter volume=remote-volume --format "table {{.ID}}\t{{.Mounts}}"
CONTAINER ID MOUNTS
9c3527ed70ce remote-volume
# Display containers with a volume mounted in `/data`
$ docker ps --filter volume=/data --format "table {{.ID}}\t{{.Mounts}}"
CONTAINER ID MOUNTS
9c3527ed70ce remote-volume
# HISTORY
April 2014, Originally compiled by William Henry (whenry at redhat dot com)
based on docker.com source material and internal work.
June 2014, updated by Sven Dowideit <[email protected]>
August 2014, updated by Sven Dowideit <[email protected]>
November 2014, updated by Sven Dowideit <[email protected]>
February 2015, updated by André Martins <[email protected]>
| {
"pile_set_name": "Github"
} |
FactoryGirl.define do
factory :item do
user
title {Faker::Company.bs[0..250]}
url {Faker::Internet.url}
end
end
| {
"pile_set_name": "Github"
} |
version=3
opts="uversionmangle=s/-rc/~rc/" \
http://www.openfabrics.org/downloads/mlx4/libmlx4-(.+)\.tar\.gz
| {
"pile_set_name": "Github"
} |
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Waher.Client.MqttEventViewer.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan is null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Waher.Client.MqttEventViewer.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
| {
"pile_set_name": "Github"
} |
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
var Pos = CodeMirror.Pos;
function posEq(a, b) { return a.line == b.line && a.ch == b.ch; }
// Kill 'ring'
var killRing = [];
function addToRing(str) {
killRing.push(str);
if (killRing.length > 50) killRing.shift();
}
function growRingTop(str) {
if (!killRing.length) return addToRing(str);
killRing[killRing.length - 1] += str;
}
function getFromRing(n) { return killRing[killRing.length - (n ? Math.min(n, 1) : 1)] || ""; }
function popFromRing() { if (killRing.length > 1) killRing.pop(); return getFromRing(); }
var lastKill = null;
function kill(cm, from, to, mayGrow, text) {
if (text == null) text = cm.getRange(from, to);
if (mayGrow && lastKill && lastKill.cm == cm && posEq(from, lastKill.pos) && cm.isClean(lastKill.gen))
growRingTop(text);
else
addToRing(text);
cm.replaceRange("", from, to, "+delete");
if (mayGrow) lastKill = {cm: cm, pos: from, gen: cm.changeGeneration()};
else lastKill = null;
}
// Boundaries of various units
function byChar(cm, pos, dir) {
return cm.findPosH(pos, dir, "char", true);
}
function byWord(cm, pos, dir) {
return cm.findPosH(pos, dir, "word", true);
}
function byLine(cm, pos, dir) {
return cm.findPosV(pos, dir, "line", cm.doc.sel.goalColumn);
}
function byPage(cm, pos, dir) {
return cm.findPosV(pos, dir, "page", cm.doc.sel.goalColumn);
}
function byParagraph(cm, pos, dir) {
var no = pos.line, line = cm.getLine(no);
var sawText = /\S/.test(dir < 0 ? line.slice(0, pos.ch) : line.slice(pos.ch));
var fst = cm.firstLine(), lst = cm.lastLine();
for (;;) {
no += dir;
if (no < fst || no > lst)
return cm.clipPos(Pos(no - dir, dir < 0 ? 0 : null));
line = cm.getLine(no);
var hasText = /\S/.test(line);
if (hasText) sawText = true;
else if (sawText) return Pos(no, 0);
}
}
function bySentence(cm, pos, dir) {
var line = pos.line, ch = pos.ch;
var text = cm.getLine(pos.line), sawWord = false;
for (;;) {
var next = text.charAt(ch + (dir < 0 ? -1 : 0));
if (!next) { // End/beginning of line reached
if (line == (dir < 0 ? cm.firstLine() : cm.lastLine())) return Pos(line, ch);
text = cm.getLine(line + dir);
if (!/\S/.test(text)) return Pos(line, ch);
line += dir;
ch = dir < 0 ? text.length : 0;
continue;
}
if (sawWord && /[!?.]/.test(next)) return Pos(line, ch + (dir > 0 ? 1 : 0));
if (!sawWord) sawWord = /\w/.test(next);
ch += dir;
}
}
function byExpr(cm, pos, dir) {
var wrap;
if (cm.findMatchingBracket && (wrap = cm.findMatchingBracket(pos, true))
&& wrap.match && (wrap.forward ? 1 : -1) == dir)
return dir > 0 ? Pos(wrap.to.line, wrap.to.ch + 1) : wrap.to;
for (var first = true;; first = false) {
var token = cm.getTokenAt(pos);
var after = Pos(pos.line, dir < 0 ? token.start : token.end);
if (first && dir > 0 && token.end == pos.ch || !/\w/.test(token.string)) {
var newPos = cm.findPosH(after, dir, "char");
if (posEq(after, newPos)) return pos;
else pos = newPos;
} else {
return after;
}
}
}
// Prefixes (only crudely supported)
function getPrefix(cm, precise) {
var digits = cm.state.emacsPrefix;
if (!digits) return precise ? null : 1;
clearPrefix(cm);
return digits == "-" ? -1 : Number(digits);
}
function repeated(cmd) {
var f = typeof cmd == "string" ? function(cm) { cm.execCommand(cmd); } : cmd;
return function(cm) {
var prefix = getPrefix(cm);
f(cm);
for (var i = 1; i < prefix; ++i) f(cm);
};
}
function findEnd(cm, pos, by, dir) {
var prefix = getPrefix(cm);
if (prefix < 0) { dir = -dir; prefix = -prefix; }
for (var i = 0; i < prefix; ++i) {
var newPos = by(cm, pos, dir);
if (posEq(newPos, pos)) break;
pos = newPos;
}
return pos;
}
function move(by, dir) {
var f = function(cm) {
cm.extendSelection(findEnd(cm, cm.getCursor(), by, dir));
};
f.motion = true;
return f;
}
function killTo(cm, by, dir) {
var selections = cm.listSelections(), cursor;
var i = selections.length;
while (i--) {
cursor = selections[i].head;
kill(cm, cursor, findEnd(cm, cursor, by, dir), true);
}
}
function killRegion(cm) {
if (cm.somethingSelected()) {
var selections = cm.listSelections(), selection;
var i = selections.length;
while (i--) {
selection = selections[i];
kill(cm, selection.anchor, selection.head);
}
return true;
}
}
function addPrefix(cm, digit) {
if (cm.state.emacsPrefix) {
if (digit != "-") cm.state.emacsPrefix += digit;
return;
}
// Not active yet
cm.state.emacsPrefix = digit;
cm.on("keyHandled", maybeClearPrefix);
cm.on("inputRead", maybeDuplicateInput);
}
var prefixPreservingKeys = {"Alt-G": true, "Ctrl-X": true, "Ctrl-Q": true, "Ctrl-U": true};
function maybeClearPrefix(cm, arg) {
if (!cm.state.emacsPrefixMap && !prefixPreservingKeys.hasOwnProperty(arg))
clearPrefix(cm);
}
function clearPrefix(cm) {
cm.state.emacsPrefix = null;
cm.off("keyHandled", maybeClearPrefix);
cm.off("inputRead", maybeDuplicateInput);
}
function maybeDuplicateInput(cm, event) {
var dup = getPrefix(cm);
if (dup > 1 && event.origin == "+input") {
var one = event.text.join("\n"), txt = "";
for (var i = 1; i < dup; ++i) txt += one;
cm.replaceSelection(txt);
}
}
function addPrefixMap(cm) {
cm.state.emacsPrefixMap = true;
cm.addKeyMap(prefixMap);
cm.on("keyHandled", maybeRemovePrefixMap);
cm.on("inputRead", maybeRemovePrefixMap);
}
function maybeRemovePrefixMap(cm, arg) {
if (typeof arg == "string" && (/^\d$/.test(arg) || arg == "Ctrl-U")) return;
cm.removeKeyMap(prefixMap);
cm.state.emacsPrefixMap = false;
cm.off("keyHandled", maybeRemovePrefixMap);
cm.off("inputRead", maybeRemovePrefixMap);
}
// Utilities
function setMark(cm) {
cm.setCursor(cm.getCursor());
cm.setExtending(!cm.getExtending());
cm.on("change", function() { cm.setExtending(false); });
}
function clearMark(cm) {
cm.setExtending(false);
cm.setCursor(cm.getCursor());
}
function getInput(cm, msg, f) {
if (cm.openDialog)
cm.openDialog(msg + ": <input type=\"text\" style=\"width: 10em\"/>", f, {bottom: true});
else
f(prompt(msg, ""));
}
function operateOnWord(cm, op) {
var start = cm.getCursor(), end = cm.findPosH(start, 1, "word");
cm.replaceRange(op(cm.getRange(start, end)), start, end);
cm.setCursor(end);
}
function toEnclosingExpr(cm) {
var pos = cm.getCursor(), line = pos.line, ch = pos.ch;
var stack = [];
while (line >= cm.firstLine()) {
var text = cm.getLine(line);
for (var i = ch == null ? text.length : ch; i > 0;) {
var ch = text.charAt(--i);
if (ch == ")")
stack.push("(");
else if (ch == "]")
stack.push("[");
else if (ch == "}")
stack.push("{");
else if (/[\(\{\[]/.test(ch) && (!stack.length || stack.pop() != ch))
return cm.extendSelection(Pos(line, i));
}
--line; ch = null;
}
}
function quit(cm) {
cm.execCommand("clearSearch");
clearMark(cm);
}
// Actual keymap
var keyMap = CodeMirror.keyMap.emacs = CodeMirror.normalizeKeyMap({
"Ctrl-W": function(cm) {kill(cm, cm.getCursor("start"), cm.getCursor("end"));},
"Ctrl-K": repeated(function(cm) {
var start = cm.getCursor(), end = cm.clipPos(Pos(start.line));
var text = cm.getRange(start, end);
if (!/\S/.test(text)) {
text += "\n";
end = Pos(start.line + 1, 0);
}
kill(cm, start, end, true, text);
}),
"Alt-W": function(cm) {
addToRing(cm.getSelection());
clearMark(cm);
},
"Ctrl-Y": function(cm) {
var start = cm.getCursor();
cm.replaceRange(getFromRing(getPrefix(cm)), start, start, "paste");
cm.setSelection(start, cm.getCursor());
},
"Alt-Y": function(cm) {cm.replaceSelection(popFromRing(), "around", "paste");},
"Ctrl-Space": setMark, "Ctrl-Shift-2": setMark,
"Ctrl-F": move(byChar, 1), "Ctrl-B": move(byChar, -1),
"Right": move(byChar, 1), "Left": move(byChar, -1),
"Ctrl-D": function(cm) { killTo(cm, byChar, 1); },
"Delete": function(cm) { killRegion(cm) || killTo(cm, byChar, 1); },
"Ctrl-H": function(cm) { killTo(cm, byChar, -1); },
"Backspace": function(cm) { killRegion(cm) || killTo(cm, byChar, -1); },
"Alt-F": move(byWord, 1), "Alt-B": move(byWord, -1),
"Alt-D": function(cm) { killTo(cm, byWord, 1); },
"Alt-Backspace": function(cm) { killTo(cm, byWord, -1); },
"Ctrl-N": move(byLine, 1), "Ctrl-P": move(byLine, -1),
"Down": move(byLine, 1), "Up": move(byLine, -1),
"Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
"End": "goLineEnd", "Home": "goLineStart",
"Alt-V": move(byPage, -1), "Ctrl-V": move(byPage, 1),
"PageUp": move(byPage, -1), "PageDown": move(byPage, 1),
"Ctrl-Up": move(byParagraph, -1), "Ctrl-Down": move(byParagraph, 1),
"Alt-A": move(bySentence, -1), "Alt-E": move(bySentence, 1),
"Alt-K": function(cm) { killTo(cm, bySentence, 1); },
"Ctrl-Alt-K": function(cm) { killTo(cm, byExpr, 1); },
"Ctrl-Alt-Backspace": function(cm) { killTo(cm, byExpr, -1); },
"Ctrl-Alt-F": move(byExpr, 1), "Ctrl-Alt-B": move(byExpr, -1),
"Shift-Ctrl-Alt-2": function(cm) {
var cursor = cm.getCursor();
cm.setSelection(findEnd(cm, cursor, byExpr, 1), cursor);
},
"Ctrl-Alt-T": function(cm) {
var leftStart = byExpr(cm, cm.getCursor(), -1), leftEnd = byExpr(cm, leftStart, 1);
var rightEnd = byExpr(cm, leftEnd, 1), rightStart = byExpr(cm, rightEnd, -1);
cm.replaceRange(cm.getRange(rightStart, rightEnd) + cm.getRange(leftEnd, rightStart) +
cm.getRange(leftStart, leftEnd), leftStart, rightEnd);
},
"Ctrl-Alt-U": repeated(toEnclosingExpr),
"Alt-Space": function(cm) {
var pos = cm.getCursor(), from = pos.ch, to = pos.ch, text = cm.getLine(pos.line);
while (from && /\s/.test(text.charAt(from - 1))) --from;
while (to < text.length && /\s/.test(text.charAt(to))) ++to;
cm.replaceRange(" ", Pos(pos.line, from), Pos(pos.line, to));
},
"Ctrl-O": repeated(function(cm) { cm.replaceSelection("\n", "start"); }),
"Ctrl-T": repeated(function(cm) {
cm.execCommand("transposeChars");
}),
"Alt-C": repeated(function(cm) {
operateOnWord(cm, function(w) {
var letter = w.search(/\w/);
if (letter == -1) return w;
return w.slice(0, letter) + w.charAt(letter).toUpperCase() + w.slice(letter + 1).toLowerCase();
});
}),
"Alt-U": repeated(function(cm) {
operateOnWord(cm, function(w) { return w.toUpperCase(); });
}),
"Alt-L": repeated(function(cm) {
operateOnWord(cm, function(w) { return w.toLowerCase(); });
}),
"Alt-;": "toggleComment",
"Ctrl-/": repeated("undo"), "Shift-Ctrl--": repeated("undo"),
"Ctrl-Z": repeated("undo"), "Cmd-Z": repeated("undo"),
"Shift-Alt-,": "goDocStart", "Shift-Alt-.": "goDocEnd",
"Ctrl-S": "findNext", "Ctrl-R": "findPrev", "Ctrl-G": quit, "Shift-Alt-5": "replace",
"Alt-/": "autocomplete",
"Ctrl-J": "newlineAndIndent", "Enter": false, "Tab": "indentAuto",
"Alt-G G": function(cm) {
var prefix = getPrefix(cm, true);
if (prefix != null && prefix > 0) return cm.setCursor(prefix - 1);
getInput(cm, "Goto line", function(str) {
var num;
if (str && !isNaN(num = Number(str)) && num == (num|0) && num > 0)
cm.setCursor(num - 1);
});
},
"Ctrl-X Tab": function(cm) {
cm.indentSelection(getPrefix(cm, true) || cm.getOption("indentUnit"));
},
"Ctrl-X Ctrl-X": function(cm) {
cm.setSelection(cm.getCursor("head"), cm.getCursor("anchor"));
},
"Ctrl-X Ctrl-S": "save",
"Ctrl-X Ctrl-W": "save",
"Ctrl-X S": "saveAll",
"Ctrl-X F": "open",
"Ctrl-X U": repeated("undo"),
"Ctrl-X K": "close",
"Ctrl-X Delete": function(cm) { kill(cm, cm.getCursor(), bySentence(cm, cm.getCursor(), 1), true); },
"Ctrl-X H": "selectAll",
"Ctrl-Q Tab": repeated("insertTab"),
"Ctrl-U": addPrefixMap
});
var prefixMap = {"Ctrl-G": clearPrefix};
function regPrefix(d) {
prefixMap[d] = function(cm) { addPrefix(cm, d); };
keyMap["Ctrl-" + d] = function(cm) { addPrefix(cm, d); };
prefixPreservingKeys["Ctrl-" + d] = true;
}
for (var i = 0; i < 10; ++i) regPrefix(String(i));
regPrefix("-");
});
| {
"pile_set_name": "Github"
} |
package com.bwssystems.HABridge.plugins.hue;
public class HueDeviceIdentifier {
private String hueName;
private String ipAddress;
private String deviceId;
public String getHueName() {
return hueName;
}
public void setHueName(String hueName) {
this.hueName = hueName;
}
public String getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
}
| {
"pile_set_name": "Github"
} |
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bfda56da833e2384a9677cd3c976a436, type: 3}
m_Name: CM vcam1Timeline
m_EditorClassIdentifier:
m_Version: 0
m_Tracks:
- {fileID: 114621659449839138}
m_FixedDuration: 0
m_EditorSettings:
m_Framerate: 60
m_DurationMode: 0
m_MarkerTrack: {fileID: 0}
--- !u!74 &74178678612148180
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Recorded
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 19.95
value: 4
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_PathPosition
path: Cinemachine pipeline
classID: 114
script: {fileID: 11500000, guid: 418e42c7d0405cc48a7b83f63ea53bb3, type: 3}
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 752632447
attribute: 2871404689
script: {fileID: 11500000, guid: 418e42c7d0405cc48a7b83f63ea53bb3, type: 3}
typeID: 114
customType: 0
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 19.95
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 19.95
value: 4
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_PathPosition
path: Cinemachine pipeline
classID: 114
script: {fileID: 11500000, guid: 418e42c7d0405cc48a7b83f63ea53bb3, type: 3}
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []
--- !u!114 &114621659449839138
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d21dcc2386d650c4597f3633c75a1f98, type: 3}
m_Name: Animation Track
m_EditorClassIdentifier:
m_Version: 3
m_AnimClip: {fileID: 0}
m_Locked: 0
m_Muted: 0
m_CustomPlayableFullTypename:
m_Curves: {fileID: 0}
m_Parent: {fileID: 11400000}
m_Children: []
m_Clips:
- m_Version: 1
m_Start: 0
m_ClipIn: 0
m_Asset: {fileID: 114743938705885804}
m_Duration: 39.9
m_TimeScale: 0.5
m_ParentTrack: {fileID: 114621659449839138}
m_EaseInDuration: 0
m_EaseOutDuration: 0
m_BlendInDuration: -1
m_BlendOutDuration: -1
m_MixInCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
m_MixOutCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
m_BlendInCurveMode: 0
m_BlendOutCurveMode: 0
m_ExposedParameterNames: []
m_AnimationCurves: {fileID: 0}
m_Recordable: 1
m_PostExtrapolationMode: 2
m_PreExtrapolationMode: 1
m_PostExtrapolationTime: Infinity
m_PreExtrapolationTime: 0
m_DisplayName: Recorded
m_Markers:
m_Objects: []
m_InfiniteClipPreExtrapolation: 1
m_InfiniteClipPostExtrapolation: 1
m_InfiniteClipOffsetPosition: {x: 0, y: 0, z: 0}
m_InfiniteClipOffsetEulerAngles: {x: -0, y: 0, z: 0}
m_InfiniteClipTimeOffset: 0
m_InfiniteClipRemoveOffset: 0
m_InfiniteClipApplyFootIK: 1
mInfiniteClipLoop: 0
m_MatchTargetFields: 63
m_Position: {x: 0, y: 0, z: 0}
m_EulerAngles: {x: 0, y: 0, z: 0}
m_AvatarMask: {fileID: 0}
m_ApplyAvatarMask: 1
m_TrackOffset: 2
m_InfiniteClip: {fileID: 0}
m_OpenClipOffsetRotation: {x: 0, y: 0, z: 0, w: 1}
m_Rotation: {x: 0, y: 0, z: 0, w: 1}
m_ApplyOffsets: 0
--- !u!114 &114743938705885804
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 030f85c3f73729f4f976f66ffb23b875, type: 3}
m_Name: AnimationPlayableAsset of Recorded
m_EditorClassIdentifier:
m_Clip: {fileID: 74178678612148180}
m_Position: {x: 0, y: 0, z: 0}
m_EulerAngles: {x: -0, y: 0, z: 0}
m_UseTrackMatchFields: 0
m_MatchTargetFields: 63
m_RemoveStartOffset: 0
m_ApplyFootIK: 1
m_Loop: 0
m_Version: 1
m_Rotation: {x: 0, y: 0, z: 0, w: 1}
| {
"pile_set_name": "Github"
} |
<!doctype html>
<!--
* Tabler - Premium and Open Source dashboard template with responsive and high quality UI.
* @version 1.0.0-alpha.7
* @link https://github.com/tabler/tabler
* Copyright 2018-2019 The Tabler Authors
* Copyright 2018-2019 codecalm.net Paweł Kuna
* Licensed under MIT (https://tabler.io/license)
-->
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"/>
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
<title>Ribbons - Documentation - Tabler - Premium and Open Source dashboard template with responsive and high quality UI.</title>
<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
<meta name="msapplication-TileColor" content="#206bc4"/>
<meta name="theme-color" content="#206bc4"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="mobile-web-app-capable" content="yes"/>
<meta name="HandheldFriendly" content="True"/>
<meta name="MobileOptimized" content="320"/>
<meta name="robots" content="noindex,nofollow,noarchive"/>
<link rel="icon" href="../favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"/>
<meta name="description" content="Ribbons are graphical elements which attract users' attention to a given element of an interface and make it stand out."/>
<!-- CSS files -->
<link href="../dist/css/tabler.min.css" rel="stylesheet"/>
<link href="../dist/css/demo.min.css" rel="stylesheet"/>
<style>
body {
display: none;
}
</style>
</head>
<body class="antialiased">
<div class="page">
<header class="navbar navbar-expand-md navbar-light">
<div class="container-xl">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-menu">
<span class="navbar-toggler-icon"></span>
</button>
<a href=".." class="navbar-brand navbar-brand-autodark d-none-navbar-horizontal pr-0 pr-md-3">
<img src="../static/logo.svg" alt="Tabler" class="navbar-brand-image">
</a>
<div class="navbar-nav flex-row order-md-last">
<div class="nav-item dropdown d-none d-md-flex mr-3">
<a href="#" class="nav-link px-0" data-toggle="dropdown" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z"/><path d="M10 5a2 2 0 0 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3h-16a4 4 0 0 0 2 -3v-3a7 7 0 0 1 4 -6" /><path d="M9 17v1a3 3 0 0 0 6 0v-1" /></svg>
<span class="badge bg-red"></span>
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-card">
<div class="card">
<div class="card-body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ad amet consectetur exercitationem fugiat in ipsa ipsum, natus odio quidem quod repudiandae sapiente. Amet debitis et magni maxime necessitatibus ullam.
</div>
</div>
</div>
</div>
<div class="nav-item dropdown">
<a href="#" class="nav-link d-flex lh-1 text-reset p-0" data-toggle="dropdown">
<span class="avatar" style="background-image: url(../static/avatars/000m.jpg)"></span>
<div class="d-none d-xl-block pl-2">
<div>Paweł Kuna</div>
<div class="mt-1 small text-muted">UI Designer</div>
</div>
</a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#">
<svg xmlns="http://www.w3.org/2000/svg" class="icon dropdown-item-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z"/><path d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><circle cx="12" cy="12" r="3" /></svg>
Action
</a>
<a class="dropdown-item" href="#">
<svg xmlns="http://www.w3.org/2000/svg" class="icon dropdown-item-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z"/><path d="M9 7 h-3a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-3" /><path d="M9 15h3l8.5 -8.5a1.5 1.5 0 0 0 -3 -3l-8.5 8.5v3" /><line x1="16" y1="5" x2="19" y2="8" /></svg>
Another action
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#"><svg xmlns="http://www.w3.org/2000/svg" class="icon dropdown-item-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z"/><line x1="12" y1="5" x2="12" y2="19" /><line x1="5" y1="12" x2="19" y2="12" /></svg>
Separated link</a>
</div>
</div>
</div>
</div>
</header>
<div class="navbar-expand-md">
<div class="collapse navbar-collapse" id="navbar-menu">
<div class="navbar navbar-light">
<div class="container-xl">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="../index.html" >
<span class="nav-link-icon d-md-none d-lg-inline-block"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="5 12 3 12 12 3 21 12 19 12" /><path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7" /><path d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6" /></svg>
</span>
<span class="nav-link-title">
Home
</span>
</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#navbar-base" data-toggle="dropdown" role="button" aria-expanded="false" >
<span class="nav-link-icon d-md-none d-lg-inline-block"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="12 3 20 7.5 20 16.5 12 21 4 16.5 4 7.5 12 3" /><line x1="12" y1="12" x2="20" y2="7.5" /><line x1="12" y1="12" x2="12" y2="21" /><line x1="12" y1="12" x2="4" y2="7.5" /><line x1="16" y1="5.25" x2="8" y2="9.75" /></svg>
</span>
<span class="nav-link-title">
User Interface
</span>
</a>
<ul class="dropdown-menu dropdown-menu-columns dropdown-menu-columns-2">
<li >
<a class="dropdown-item" href="../empty.html" >
Empty page
</a>
</li>
<li >
<a class="dropdown-item" href="../blank.html" >
Blank page
</a>
</li>
<li >
<a class="dropdown-item" href="../buttons.html" >
Buttons
</a>
</li>
<li >
<a class="dropdown-item" href="../cards.html" >
Cards
</a>
</li>
<li >
<a class="dropdown-item" href="../dropdowns.html" >
Dropdowns
</a>
</li>
<li >
<a class="dropdown-item" href="../icons.html" >
Icons
</a>
</li>
<li >
<a class="dropdown-item" href="../modals.html" >
Modals
</a>
</li>
<li >
<a class="dropdown-item" href="../maps.html" >
Maps
</a>
</li>
<li >
<a class="dropdown-item" href="../maps-vector.html" >
Vector maps
</a>
</li>
<li >
<a class="dropdown-item" href="../navigation.html" >
Navigation
</a>
</li>
<li >
<a class="dropdown-item" href="../charts.html" >
Charts
</a>
</li>
<li >
<a class="dropdown-item" href="../tables.html" >
Tables
</a>
</li>
<li >
<a class="dropdown-item" href="../calendar.html" >
Calendar
</a>
</li>
<li >
<a class="dropdown-item" href="../carousel.html" >
Carousel
</a>
</li>
<li >
<a class="dropdown-item" href="../lists.html" >
Lists
</a>
</li>
<li class="dropright">
<a class="dropdown-item dropdown-toggle" href="#sidebar-authentication" data-toggle="dropdown" role="button" aria-expanded="false" >
Authentication
</a>
<div class="dropdown-menu">
<a href="../sign-in.html" class="dropdown-item">Sign in</a>
<a href="../sign-up.html" class="dropdown-item">Sign up</a>
<a href="../forgot-password.html" class="dropdown-item">Forgot password</a>
<a href="../terms-of-service.html" class="dropdown-item">Terms of service</a>
</div>
</li>
<li class="dropright">
<a class="dropdown-item dropdown-toggle" href="#sidebar-error" data-toggle="dropdown" role="button" aria-expanded="false" >
Error pages
</a>
<div class="dropdown-menu">
<a href="../400.html" class="dropdown-item">400 page</a>
<a href="../401.html" class="dropdown-item">401 page</a>
<a href="../403.html" class="dropdown-item">403 page</a>
<a href="../404.html" class="dropdown-item">404 page</a>
<a href="../500.html" class="dropdown-item">500 page</a>
<a href="../503.html" class="dropdown-item">503 page</a>
<a href="../maintenance.html" class="dropdown-item">Maintenance page</a>
</div>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="../form-elements.html" >
<span class="nav-link-icon d-md-none d-lg-inline-block"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 11 12 14 20 6" /><path d="M20 12v6a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h9" /></svg>
</span>
<span class="nav-link-title">
Form elements
</span>
</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#navbar-extra" data-toggle="dropdown" role="button" aria-expanded="false" >
<span class="nav-link-icon d-md-none d-lg-inline-block"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z"/><path d="M12 17.75l-6.172 3.245 1.179-6.873-4.993-4.867 6.9-1.002L12 2l3.086 6.253 6.9 1.002-4.993 4.867 1.179 6.873z" /></svg>
</span>
<span class="nav-link-title">
Extra
</span>
</a>
<ul class="dropdown-menu">
<li >
<a class="dropdown-item" href="../invoice.html" >
Invoice
</a>
</li>
<li >
<a class="dropdown-item" href="../blog.html" >
Blog cards
</a>
</li>
<li >
<a class="dropdown-item" href="../snippets.html" >
Snippets
</a>
</li>
<li >
<a class="dropdown-item" href="../search-results.html" >
Search results
</a>
</li>
<li >
<a class="dropdown-item" href="../pricing.html" >
Pricing cards
</a>
</li>
<li >
<a class="dropdown-item" href="../users.html" >
Users
</a>
</li>
<li >
<a class="dropdown-item" href="../gallery.html" >
Gallery
</a>
</li>
<li >
<a class="dropdown-item" href="../profile.html" >
Profile
</a>
</li>
<li >
<a class="dropdown-item" href="../music.html" >
Music
</a>
</li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#navbar-layout" data-toggle="dropdown" role="button" aria-expanded="false" >
<span class="nav-link-icon d-md-none d-lg-inline-block"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z"/><rect x="4" y="4" width="6" height="5" rx="2" /><rect x="4" y="13" width="6" height="7" rx="2" /><rect x="14" y="4" width="6" height="7" rx="2" /><rect x="14" y="15" width="6" height="5" rx="2" /></svg>
</span>
<span class="nav-link-title">
Layout
</span>
</a>
<ul class="dropdown-menu">
<li >
<a class="dropdown-item" href="../layout-horizontal.html" >
Horizontal
</a>
</li>
<li >
<a class="dropdown-item" href="../layout-vertical.html" >
Vertical
</a>
</li>
<li >
<a class="dropdown-item" href="../layout-vertical-right.html" >
Right vertical
</a>
</li>
<li >
<a class="dropdown-item" href="../layout-condensed.html" >
Condensed
</a>
</li>
<li >
<a class="dropdown-item" href="../layout-condensed-dark.html" >
Condensed dark
</a>
</li>
<li >
<a class="dropdown-item" href="../layout-combo.html" >
Combined
</a>
</li>
<li >
<a class="dropdown-item" href="../layout-navbar-dark.html" >
Navbar dark
</a>
</li>
<li >
<a class="dropdown-item" href="../layout-dark.html" >
Dark mode
</a>
</li>
<li >
<a class="dropdown-item" href="../layout-fluid.html" >
Fluid
</a>
</li>
<li >
<a class="dropdown-item" href="../layout-fluid-vertical.html" >
Fluid vertical
</a>
</li>
</ul>
</li>
<li class="nav-item active dropdown">
<a class="nav-link dropdown-toggle" href="#navbar-docs" data-toggle="dropdown" role="button" aria-expanded="false" >
<span class="nav-link-icon d-md-none d-lg-inline-block"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="14 3 14 8 19 8" /><path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z" /><line x1="9" y1="9" x2="10" y2="9" /><line x1="9" y1="13" x2="15" y2="13" /><line x1="9" y1="17" x2="15" y2="17" /></svg>
</span>
<span class="nav-link-title">
Docs
</span>
</a>
<ul class="dropdown-menu dropdown-menu-columns dropdown-menu-columns-3">
<li >
<a class="dropdown-item" href="../docs/index.html" >
Introduction
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/alerts.html" >
Alerts
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/autosize.html" >
Autosize
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/avatars.html" >
Avatars
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/badges.html" >
Badges
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/breadcrumb.html" >
Breadcrumb
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/buttons.html" >
Buttons
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/cards.html" >
Cards
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/carousel.html" >
Carousel
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/colors.html" >
Colors
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/countup.html" >
Countup
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/cursors.html" >
Cursors
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/charts.html" >
Charts
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/dropdowns.html" >
Dropdowns
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/divider.html" >
Divider
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/empty.html" >
Empty states
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/flags.html" >
Flags
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/form-elements.html" >
Form elements
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/form-helpers.html" >
Form helpers
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/input-mask.html" >
Form input mask
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/modals.html" >
Modals
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/progress.html" >
Progress
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/payments.html" >
Payments
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/range-slider.html" >
Range slider
</a>
</li>
<li >
<a class="dropdown-item active" href="../docs/ribbons.html" >
Ribbons
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/spinners.html" >
Spinners
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/steps.html" >
Steps
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/tables.html" >
Tables
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/tabs.html" >
Tabs
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/timelines.html" >
Timelines
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/toasts.html" >
Toasts
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/tooltips.html" >
Tooltips
</a>
</li>
<li >
<a class="dropdown-item" href="../docs/typography.html" >
Typography
</a>
</li>
</ul>
</li>
</ul>
<div class="my-2 my-md-0 flex-grow-1 flex-md-grow-0 order-first order-md-last">
<form action="." method="get">
<div class="input-icon">
<span class="input-icon-addon">
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z"/><circle cx="10" cy="10" r="7" /><line x1="21" y1="21" x2="15" y2="15" /></svg>
</span>
<input type="text" class="form-control" placeholder="Search…">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="content">
<div class="container-xl">
<!-- Page title -->
<div class="page-header">
<div class="row align-items-center">
<div class="col-auto">
<h2 class="page-title">
Documentation
</h2>
</div>
</div>
</div>
<div class="row justify-content-center">
<div class="d-none d-lg-block col-lg-3 order-lg-1 mb-4">
<div class="sticky-top">
<a href="https://github.com/tabler/tabler" class="btn btn-white mb-6 btn-block" target="_blank" rel="noreferrer">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" class="icon" fill="currentColor"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>
Browse source code
</a>
<h5 class="subheader">On this page</h5>
<ul class="list-unstyled">
<li class="toc-entry toc-h2"><a href="#default-markup">Default markup</a></li>
<li class="toc-entry toc-h2"><a href="#ribbon-position">Ribbon position</a></li>
<li class="toc-entry toc-h2"><a href="#ribbon-color">Ribbon color</a></li>
<li class="toc-entry toc-h2"><a href="#ribbon-text">Ribbon text</a></li>
<li class="toc-entry toc-h2"><a href="#ribbon-style">Ribbon style</a></li>
</ul>
</div>
</div>
<div class="col-lg-9">
<div class="card card-lg">
<div class="card-body">
<div class="markdown">
<div class="d-flex">
<h2 class="h1 mt-0 mb-3">Ribbons</h2>
</div>
<p>Ribbons are graphical elements which attract users' attention to a given element of an interface and make it stand out.</p>
<h2 id="default-markup">Default markup</h2>
<p>Use the <code class="highlighter-rouge">ribbon</code> class to add the default ribbon to any section of your interface.</p>
<div class="example no_toc_section">
<div class="example-content">
<div class="card">
<div class="card-body h-8">
</div>
<div class="ribbon"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" /><path d="M12 17.75l-6.172 3.245 1.179-6.873-4.993-4.867 6.9-1.002L12 2l3.086 6.253 6.9 1.002-4.993 4.867 1.179 6.873z" /></svg>
</div>
</div>
</div>
</div>
<div class="example-code">
<figure class="highlight">
<pre><code class="language-html" data-lang="html"><span class="nt"><div</span> <span class="na">class=</span><span class="s">"card"</span><span class="nt">></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"card-body h-8"</span><span class="nt">></span>
<span class="nt"></div></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"ribbon"</span><span class="nt">></span><span class="c"><!-- SVG icon code --></span>
<span class="nt"></div></span>
<span class="nt"></div></span></code></pre>
</figure>
</div>
<h2 id="ribbon-position">Ribbon position</h2>
<p>You can change the position of a ribbon by adding one of the following classes to the element:</p>
<ul>
<li><code class="highlighter-rouge">ribbon-top</code> - moves it to the top</li>
<li><code class="highlighter-rouge">ribbon-right</code> - moves it to the right</li>
<li><code class="highlighter-rouge">ribbon-bottom</code> - moves it to the bottom</li>
<li><code class="highlighter-rouge">ribbon-left</code> - moves it to the lefg</li>
</ul>
<p>Using multiple classes at once will give you more position options. For example, the following class: <code class="highlighter-rouge">.ribbon.ribbon-top.ribbon-left</code> will move the ribbon to the top left corner.</p>
<div class="example no_toc_section">
<div class="example-content">
<div class="card">
<div class="card-body h-8">
</div>
<div class="ribbon ribbon-top ribbon-left"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" /><path d="M12 17.75l-6.172 3.245 1.179-6.873-4.993-4.867 6.9-1.002L12 2l3.086 6.253 6.9 1.002-4.993 4.867 1.179 6.873z" /></svg>
</div>
</div>
</div>
</div>
<div class="example-code">
<figure class="highlight">
<pre><code class="language-html" data-lang="html"><span class="nt"><div</span> <span class="na">class=</span><span class="s">"card"</span><span class="nt">></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"card-body h-8"</span><span class="nt">></span>
<span class="nt"></div></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"ribbon ribbon-top ribbon-left"</span><span class="nt">></span><span class="c"><!-- SVG icon code --></span>
<span class="nt"></div></span>
<span class="nt"></div></span></code></pre>
</figure>
</div>
<h2 id="ribbon-color">Ribbon color</h2>
<p>Customize the ribbon’s background color. You can click <a href="./colors.html">here</a> to see the list of available colors.</p>
<div class="example no_toc_section">
<div class="example-content">
<div class="card">
<div class="card-body h-8">
</div>
<div class="ribbon bg-red"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" /><path d="M12 17.75l-6.172 3.245 1.179-6.873-4.993-4.867 6.9-1.002L12 2l3.086 6.253 6.9 1.002-4.993 4.867 1.179 6.873z" /></svg>
</div>
</div>
</div>
</div>
<div class="example-code">
<figure class="highlight">
<pre><code class="language-html" data-lang="html"><span class="nt"><div</span> <span class="na">class=</span><span class="s">"card"</span><span class="nt">></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"card-body h-8"</span><span class="nt">></span>
<span class="nt"></div></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"ribbon bg-red"</span><span class="nt">></span><span class="c"><!-- SVG icon code --></span>
<span class="nt"></div></span>
<span class="nt"></div></span></code></pre>
</figure>
</div>
<h2 id="ribbon-text">Ribbon text</h2>
<p>Add your own text to a ribbon to display any additional information and make it easy to spot for users.</p>
<div class="example no_toc_section">
<div class="example-content">
<div class="card">
<div class="card-body h-8">
</div>
<div class="ribbon bg-green"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" /><path d="M12 17.75l-6.172 3.245 1.179-6.873-4.993-4.867 6.9-1.002L12 2l3.086 6.253 6.9 1.002-4.993 4.867 1.179 6.873z" /></svg>
</div>
</div>
</div>
</div>
<div class="example-code">
<figure class="highlight">
<pre><code class="language-html" data-lang="html"><span class="nt"><div</span> <span class="na">class=</span><span class="s">"card"</span><span class="nt">></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"card-body h-8"</span><span class="nt">></span>
<span class="nt"></div></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"ribbon bg-green"</span><span class="nt">></span><span class="c"><!-- SVG icon code --></span>
<span class="nt"></div></span>
<span class="nt"></div></span></code></pre>
</figure>
</div>
<h2 id="ribbon-style">Ribbon style</h2>
<p>Change the style of a ribbon to make it go well with your interface design.</p>
<div class="example no_toc_section">
<div class="example-content">
<div class="card">
<div class="card-body h-8">
</div>
<div class="ribbon ribbon-bookmark bg-orange"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" /><path d="M12 17.75l-6.172 3.245 1.179-6.873-4.993-4.867 6.9-1.002L12 2l3.086 6.253 6.9 1.002-4.993 4.867 1.179 6.873z" /></svg>
</div>
</div>
</div>
</div>
<div class="example-code">
<figure class="highlight">
<pre><code class="language-html" data-lang="html"><span class="nt"><div</span> <span class="na">class=</span><span class="s">"card"</span><span class="nt">></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"card-body h-8"</span><span class="nt">></span>
<span class="nt"></div></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"ribbon ribbon-bookmark bg-orange"</span><span class="nt">></span><span class="c"><!-- SVG icon code --></span>
<span class="nt"></div></span>
<span class="nt"></div></span></code></pre>
</figure>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<footer class="footer footer-transparent">
<div class="container">
<div class="row text-center align-items-center flex-row-reverse">
<div class="col-lg-auto ml-lg-auto">
<ul class="list-inline list-inline-dots mb-0">
<li class="list-inline-item"><a href="../docs/index.html" class="link-secondary">Documentation</a></li>
<li class="list-inline-item"><a href="../faq.html" class="link-secondary">FAQ</a></li>
<li class="list-inline-item"><a href="https://github.com/tabler/tabler" target="_blank" class="link-secondary">Source code</a></li>
</ul>
</div>
<div class="col-12 col-lg-auto mt-3 mt-lg-0">
Copyright © 2020
<a href=".." class="link-secondary">Tabler</a>.
All rights reserved.
</div>
</div>
</div>
</footer>
</div>
</div>
<!-- Libs JS -->
<script src="../dist/libs/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<!-- Tabler Core -->
<script src="../dist/js/tabler.min.js"></script>
<script>
document.body.style.display = "block"
</script>
</body>
</html> | {
"pile_set_name": "Github"
} |
# Symfony CMF Routing Bundle
[](https://packagist.org/packages/symfony-cmf/routing-bundle)
[](https://packagist.org/packages/symfony-cmf/routing-bundle)
[](https://packagist.org/packages/symfony-cmf/routing-bundle)
[](https://packagist.org/packages/symfony-cmf/routing-bundle)
[](https://packagist.org/packages/symfony-cmf/routing-bundle)
[](https://packagist.org/packages/symfony-cmf/routing-bundle)
Version/Branch | Travis | Coveralls |
------ | ------ | --------- |
2.1.1 | [![Build Status][travis_stable_badge]][travis_link] | [![Coverage Status][coveralls_stable_badge]][coveralls_stable_link] |
master | [![Build Status][travis_unstable_badge]][travis_link] | [![Coverage Status][coveralls_unstable_badge]][coveralls_unstable_link] |
This package is part of the [Symfony Content Management Framework (CMF)](http://cmf.symfony.com/) and licensed
under the [MIT License](LICENSE).
The RoutingBundle enables the
[CMF Routing component](https://github.com/symfony-cmf/Routing)
as a Symfony bundle. It provides route documents for Doctrine PHPCR-ODM and a
controller for redirection routes.
## Requirements
* See `require` section of [composer.json](composer.json)
## Documentation
For the install guide and reference, see:
* [symfony-cmf/routing-bundle Documentation](http://symfony.com/doc/master/cmf/bundles/routing/index.html)
See also:
* [All Symfony CMF documentation](http://symfony.com/doc/master/cmf/index.html) - complete Symfony CMF reference
* [Symfony CMF Website](http://cmf.symfony.com/) - introduction, live demo, support and community links
## Support
For general support and questions, please use [StackOverflow](http://stackoverflow.com/questions/tagged/symfony-cmf).
## Contributing
Pull requests are welcome. Please see our
[CONTRIBUTING](https://github.com/symfony-cmf/blob/master/CONTRIBUTING.md)
guide.
Unit and/or functional tests exist for this package. See the
[Testing documentation](http://symfony.com/doc/master/cmf/components/testing.html)
for a guide to running the tests.
Thanks to
[everyone who has contributed](contributors) already.
## License
This package is available under the [MIT license](src/Resources/meta/LICENSE).
[travis_stable_badge]: https://travis-ci.org/symfony-cmf/routing-bundle.svg?branch=2.x
[travis_unstable_badge]: https://travis-ci.org/symfony-cmf/routing-bundle.svg?branch=master
[travis_link]: https://travis-ci.org/symfony-cmf/routing-bundle
[coveralls_stable_badge]: https://coveralls.io/repos/github/symfony-cmf/routing-bundle/badge.svg?branch=2.x
[coveralls_stable_link]: https://coveralls.io/github/symfony-cmf/routing-bundle?branch=2.x
[coveralls_unstable_badge]: https://coveralls.io/repos/github/symfony-cmf/routing-bundle/badge.svg?branch=master
[coveralls_unstable_link]: https://coveralls.io/github/symfony-cmf/routing-bundle?branch=master
| {
"pile_set_name": "Github"
} |
import { Platform } from 'react-native';
import _ from 'lodash';
import variable from './../variables/platform';
export default (variables = variable) => {
const pickerTheme = {
};
return pickerTheme;
};
| {
"pile_set_name": "Github"
} |
package io.hydrosphere.mist.worker.runners
import java.io.File
import java.nio.file.Paths
import io.hydrosphere.mist.worker.SparkArtifact
import io.hydrosphere.mist.worker.runners.python.PythonRunner
import org.apache.commons.io.FileUtils
import org.scalatest.{BeforeAndAfter, FunSpecLike, Matchers}
class RunnerSelectorSpec extends FunSpecLike
with Matchers
with BeforeAndAfter {
val basePath = "./target/runner"
val pyFile = SparkArtifact(Paths.get(basePath, "test.py").toFile, "url")
val jarFile = SparkArtifact(Paths.get(basePath, "test.jar").toFile, "url")
val unknown = SparkArtifact(Paths.get(basePath, "test.unknown").toFile, "url")
before {
val f = new File(basePath)
if (f.exists()) FileUtils.deleteDirectory(f)
FileUtils.forceMkdir(f)
FileUtils.touch(pyFile.local)
FileUtils.touch(jarFile.local)
}
after {
FileUtils.deleteQuietly(pyFile.local)
FileUtils.deleteQuietly(jarFile.local)
}
it("should select runner by extension") {
val selector = new SimpleRunnerSelector
selector.selectRunner(pyFile) shouldBe a[PythonRunner]
selector.selectRunner(jarFile) shouldBe a[ScalaRunner]
}
it("should throw exception when unknown file type is passed") {
val selector = new SimpleRunnerSelector
intercept[IllegalArgumentException] {
selector.selectRunner(unknown)
}
}
}
| {
"pile_set_name": "Github"
} |
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Basic DateBox - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
<h2>Basic DateBox</h2>
<div class="demo-info">
<div class="demo-tip icon-tip"></div>
<div>Click the calendar image on the right side.</div>
</div>
<div style="margin:10px 0;"></div>
<input class="easyui-datebox"></input>
</body>
</html> | {
"pile_set_name": "Github"
} |
package de.westnordost.streetcomplete.user
import android.os.Bundle
import android.view.View
import androidx.core.view.isGone
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_FADE
import androidx.fragment.app.commit
import de.westnordost.streetcomplete.Injector
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.quest.QuestType
import de.westnordost.streetcomplete.data.user.QuestStatisticsDao
import de.westnordost.streetcomplete.data.user.UserStore
import kotlinx.android.synthetic.main.fragment_quest_statistics.*
import javax.inject.Inject
/** Shows the user's solved quests of each type in some kind of ball pit. Clicking on each opens
* a QuestTypeInfoFragment that shows the quest's details. */
class QuestStatisticsFragment : Fragment(R.layout.fragment_quest_statistics),
QuestStatisticsByQuestTypeFragment.Listener, QuestStatisticsByCountryFragment.Listener
{
@Inject internal lateinit var questStatisticsDao: QuestStatisticsDao
@Inject internal lateinit var userStore: UserStore
interface Listener {
fun onClickedQuestType(questType: QuestType<*>, solvedCount: Int, questBubbleView: View)
fun onClickedCountryFlag(country: String, solvedCount: Int, rank: Int?, countryBubbleView: View)
}
private val listener: Listener? get() = parentFragment as? Listener ?: activity as? Listener
init {
Injector.applicationComponent.inject(this)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
emptyText.isGone = questStatisticsDao.getTotalAmount() != 0
byQuestTypeButton.setOnClickListener { v -> selectorButton.check(v.id) }
byCountryButton.setOnClickListener { v -> selectorButton.check(v.id) }
selectorButton.addOnButtonCheckedListener { _, checkedId, isChecked ->
if (isChecked) {
when (checkedId) {
R.id.byQuestTypeButton -> replaceFragment(QuestStatisticsByQuestTypeFragment())
R.id.byCountryButton -> replaceFragment(QuestStatisticsByCountryFragment())
}
}
}
}
override fun onStart() {
super.onStart()
if (userStore.isSynchronizingStatistics) {
emptyText.setText(R.string.stats_are_syncing)
} else {
emptyText.setText(R.string.quests_empty)
}
}
private fun replaceFragment(fragment: Fragment) {
childFragmentManager.commit {
setTransition(TRANSIT_FRAGMENT_FADE)
replace(R.id.questStatisticsFragmentContainer, fragment)
}
}
override fun onClickedQuestType(questType: QuestType<*>, solvedCount: Int, questBubbleView: View) {
listener?.onClickedQuestType(questType, solvedCount, questBubbleView)
}
override fun onClickedCountryFlag(countryCode: String, solvedCount: Int, rank: Int?, countryBubbleView: View) {
listener?.onClickedCountryFlag(countryCode, solvedCount, rank, countryBubbleView)
}
}
| {
"pile_set_name": "Github"
} |
-----BEGIN CERTIFICATE-----
MIICKTCCAdCgAwIBAgIQWtkJW83DqWph5CL1SUe0ozAKBggqhkjOPQQDAjBzMQsw
CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy
YW5jaXNjbzEZMBcGA1UEChMQb3JnMy5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eu
b3JnMy5leGFtcGxlLmNvbTAeFw0yMDA0MjkwMjQyMDBaFw0zMDA0MjcwMjQyMDBa
MGwxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T
YW4gRnJhbmNpc2NvMQ8wDQYDVQQLEwZjbGllbnQxHzAdBgNVBAMMFkFkbWluQG9y
ZzMuZXhhbXBsZS5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASs91bwumga
dijyOtVDp+Tgk769X914i1GkHvtGdGgN/UPcWxBoTcj5vZavDSKWVNL0tL/kuw9i
U/289NNb12Ozo00wSzAOBgNVHQ8BAf8EBAMCB4AwDAYDVR0TAQH/BAIwADArBgNV
HSMEJDAigCB+vB7ApaKbyIgCxdd6weJP9GvSPB4Pvm6uJmI9WYXkjzAKBggqhkjO
PQQDAgNHADBEAiBipIlsGt0ne3ACjBLDgOwtEDTCo0+M7YoCLsim5iliEAIgKbQQ
gKPukhDTXM4j3yous9MBgpywxeSq9+xT8+jM9gg=
-----END CERTIFICATE-----
| {
"pile_set_name": "Github"
} |
# Reference Types for WebAssembly
TODO: more text, motivation, explanation
## Introduction
Motivation:
* Easier and more efficient interop with host environment (see e.g. the [Interface Types proposal](https://github.com/WebAssembly/interface-types/blob/master/proposals/interface-types/Explainer.md))
- allow host references to be represented directly by type `externref` (see [here](https://github.com/WebAssembly/interface-types/issues/9))
- without having to go through tables, allocating slots, and maintaining index bijections at the boundaries
* Basic manipulation of tables inside Wasm
- allow representing data structures containing references
by repurposing tables as a general memory for opaque data types
- allow manipulating function tables from within Wasm.
- add instructions missing from [bulk operations proposal](https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md)
* Set the stage for later additions:
- Typed function references (see [below](#typed-function-references))
- Exception references (see the [exception handling proposal](https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md) and [here](https://github.com/WebAssembly/interface-types/issues/10))
- A smoother transition path to GC (see the [GC proposal](https://github.com/WebAssembly/gc/blob/master/proposals/gc/Overview.md))
Get the most important parts soon!
Summary:
* Add new type `externref` that can be used as both a value types and a table element type.
* Also allow `funcref` as a value type.
* Introduce instructions to get and set table slots.
* Add missing table size, grow, fill instructions.
* Allow multiple tables.
Notes:
* This extension does not imply GC by itself, only if host refs are GCed pointers!
* Reference types are *opaque*, i.e., their value is abstract and they cannot be stored into linear memory. Tables are used as the equivalent.
## Language Extensions
Typing extensions:
* Introduce `funcref` and `externref` as a new class of *reference types*.
- `reftype ::= funcref | externref`
* Value types (of locals, globals, function parameters and results) can now be either numeric types or reference types.
- `numtype ::= i32 | i64 | f32 | f64`
- `valtype ::= <numtype> | <reftype>`
- locals with reference type are initialised with `null`
* Element types (of tables) are equated with reference types.
- `elemtype ::= <reftype>`
New/extended instructions:
* The `select` instruction now optionally takes a value type immediate. Only annotated `select` can be used with reference types.
- `select : [t t i32] -> [t]`
- iff `t` is a `numtype`
- `select t : [t t i32] -> [t]`
* The new instruction `ref.null` evaluates to the null reference constant.
- `ref.null rt : [] -> [rtref]`
- iff `rt = func` or `rt = extern`
- allowed in constant expressions
* The new instruction `ref.is_null` checks for null.
- `ref.is_null : [rtref] -> [i32]`
* The new instruction `ref.func` creates a reference to a given function.
- `ref.func $x : [] -> [funcref]`
- iff `$x : func $t`
- allowed in constant expressions
- Note: the result type of this instruction may be refined by future proposals (e.g., to `[(ref $t)]`)
* The new instructions `table.get` and `table.set` access tables.
- `table.get $x : [i32] -> [t]`
- iff `$x : table t`
- `table.set $x : [i32 t] -> []`
- iff `$x : table t`
* The new instructions `table.size`and `table.grow` manipulate the size of a table.
- `table.size $x : [] -> [i32]`
- iff `$x : table t`
- `table.grow $x : [t i32] -> [i32]`
- iff `$x : table t`
- the first operand of `table.grow` is an initialisation value (for compatibility with future extensions to the type system, such as non-nullable references)
* The new instruction `table.fill` fills a range in a table with a value.
- `table.fill $x : [i32 t i32] -> []`
- iff `$x : table t`
- the first operand is the start index of the range, the third operand its length (analoguous to `memory.fill`)
- traps when range+length > size of the table, but only after filling range up to size (analoguous to `memory.fill`)
* The `table.init` instruction takes an additional table index as immediate.
- `table.init $x $y : [i32 i32 i32] -> []`
- iff `$x : table t`
- and `$y : elem t'`
- and `t' <: t`
* The `table.copy` instruction takes two additional table indices as immediate.
- `table.copy $x $y : [i32 i32 i32] -> []`
- iff `$x : table t`
- and `$y : table t'`
- and `t' <: t`
* The `call_indirect` instruction takes a table index as immediate.
- `call_indirect $x (type $t) : [t1* i32] -> [t2*]`
- iff `$t = [t1*] -> [t2*]`
- and `$x : table t'`
- and `t' <: funcref`
* In all instructions, table indices can be omitted and default to 0.
Note:
- In the binary format, space for the additional table indices is already reserved.
- For backwards compatibility, all table indices may be omitted in the text format, in which case they default to 0 (for `table.copy`, both indices must be either present or absent).
Table extensions:
* A module may define, import, and export multiple tables.
- As usual, the imports come first in the index space.
- This is already representable in the binary format.
* Element segments take a table index as immediate that identifies the table they apply to.
- In the binary format, space for the index is already reserved.
- For backwards compatibility, the index may be omitted in the text format, in which case it defaults to 0.
JS API extensions:
* Any JS value can be passed as `externref` to a Wasm function, stored in a global, or in a table.
* Any Wasm exported function object or `null` can be passed as `funcref` to a Wasm function, stored in a global, or in a table.
* The `WebAssembly.Table#grow` method takes an additional initialisation argument.
- optional for backwards compatibility, defaults to default value of respective type
## Possible Future Extensions
### Subtyping
Motivation:
* Enable various extensions (see below).
Additions:
* Introduce a simple subtype relation between reference types.
- reflexive transitive closure of the following rules
- `t <: anyref` for all reftypes `t`
### Equality on references
Motivation:
* Allow references to be compared by identity.
* However, not all reference types should be comparable, since that may make implementation details observable in a non-deterministic fashion (consider e.g. host JavaScript strings).
Additions:
* Add `eqref` as the type of comparable references
- `reftype ::= ... | eqref`
* It is a subtype of `anyref`
- `eqref < anyref`
* Add `ref.eq` instruction.
- `ref.eq : [eqref eqref] -> [i32]`
API changes:
* Any JS object (non-primitive value) or symbol or `null` can be passed as `eqref` to a Wasm function, stored in a global, or in a table.
Questions:
* Interaction with type imports/exports: do they need to distinguish equality types from non-equality now?
* Similarly, the JS API for `WebAssembly.Type` below would need to enable the distinction.
### Typed function references
See the [typed function references proposal](https://github.com/WebAssembly/function-references/blob/master/proposals/function-references/Overview.md)
Motivation:
* Allow function pointers to be expressed directly without going through table and dynamic type check.
* Enable functions to be passed to other modules easily.
Additions:
* Add `(ref $t)` as a reference type
- `reftype ::= ... | ref <typeidx>`
* Refine `(ref.func $f)` instruction
- `ref.func $f : [] -> (ref $t)` iff `$f : $t`
* Add `(call_ref)` instruction
- `call_ref : [ts1 (ref $t)] -> [ts2]` iff `$t = [ts1] -> [ts2]`
* Introduce subtyping `ref <functype> < funcref`
* Subtying between concrete and universal reference types
- `ref $t < anyref`
- `ref <functype> < funcref`
- Note: reference types are not necessarily subtypes of `eqref`, including functions
* Typed function references cannot be null!
### Type Import/Export
Motivation:
* Allow the host (or Wasm modules) to distinguish different reference types.
Additions:
* Add `(type)` external type, enables types to be imported and exported
- `externtype ::= ... | type`
- `(ref $t)` can now denote an abstract type or a function reference
- imported types have index starting from 0.
- reserve byte in binary format to allow refinements later
* Add abstract type definitions in type section
- `deftype ::= <functype> | new`
- creates unique abstract type
* Add `WebAssembly.Type` class to JS API
- constructor `new WebAssembly.Type(name)` creates unique abstract type
* Subtyping `ref <abstype>` < `anyref`
Questions:
* Do we need to impose constraints on the order of imports, to stratify section dependencies? Should type import and export be separate sections instead?
* Do we need a nullable `(optref $t)` type to allow use with locals etc.? Could a `(nullable T)` type constructor work instead?
- Unclear how `nullable` constructor would integrate exactly. Would it only allow (non-nullable) reference types as argument? Does this require a kind system? Should `anyref` be different from `(nullable anyref)`, or the latter disallowed? What about `funcref`?
- Semantically, thinking of `(nullable T)` as `T | nullref` could answer these questions, but we cannot support arbitrary unions in Wasm.
* Should we add `(new)` definitional type to enable Wasm modules to define new types, too?
* Do `new` definition types and the `WebAssembly.Type` constructor need to take a "comparable" flag controlling whether references to a type can be compared?
* Should JS API allow specifying subtyping between new types?
### Down Casts
Motivation:
* Allow to implement generics by using `anyref` as a top type.
Addition:
* Add a `cast` instruction that checks whether its operand can be cast to a lower type and converts its type accordingly if so; otherwise, goes to an else branch.
- `cast <resulttype> <reftype1> <reftype2> <instr1>* else <instr2>* end: [<reftypet1>] -> <resulttype>` iff `<reftype2> < <reftype1>` and `<instr1>* : [<reftype2>] -> <resulttype>` and `<instr2>* : [<reftype1>] -> <resulttype>`
- could later be generalised to non-reference types?
Note:
* Can decompose `call_indirect` (assuming multi-value proposal):
- `(call_indirect $x (type $t))` reduces to `(table.get $x) (cast $t anyref (ref $t) (then (call_ref (ref $t))) (else (unreachable)))`
### GC Types
See [GC proposal](https://github.com/WebAssembly/gc/blob/master/proposals/gc/Overview.md).
### Further possible generalisations
* Introduce reference types pointing to tables, memories, or globals.
- `deftype ::= ... | global <globaltype> | table <tabletype> | memory <memtype>`
- `ref.global $g : [] -> (ref $t)` iff `$g : $t`
- `ref.table $x : [] -> (ref $t)` iff `$x : $t`
- `ref.mem $m : [] -> (ref $t)` iff `$m : $t`
- yields first-class tables, memories, globals
- would requires duplicating all respective instructions
* Allow all value types as element types.
- `deftype := ... | globaltype | tabletype | memtype`
- would unify element types with value types
| {
"pile_set_name": "Github"
} |
CHECK: BINGO
Done1000000: Done 1000000 runs in
RUN: LLVMFuzzer-SimpleTest 2>&1 | FileCheck %s
# only_ascii mode. Will perform some minimal self-validation.
RUN: LLVMFuzzer-SimpleTest -only_ascii=1 2>&1
RUN: LLVMFuzzer-SimpleCmpTest -max_total_time=1 -use_cmp=0 2>&1 | FileCheck %s --check-prefix=MaxTotalTime
MaxTotalTime: Done {{.*}} runs in {{.}} second(s)
RUN: not LLVMFuzzer-NullDerefTest 2>&1 | FileCheck %s --check-prefix=NullDerefTest
RUN: not LLVMFuzzer-NullDerefTest -close_fd_mask=3 2>&1 | FileCheck %s --check-prefix=NullDerefTest
NullDerefTest: ERROR: AddressSanitizer: SEGV on unknown address
NullDerefTest: Test unit written to ./crash-
RUN: not LLVMFuzzer-NullDerefTest -artifact_prefix=ZZZ 2>&1 | FileCheck %s --check-prefix=NullDerefTestPrefix
NullDerefTestPrefix: Test unit written to ZZZcrash-
RUN: not LLVMFuzzer-NullDerefTest -artifact_prefix=ZZZ -exact_artifact_path=FOOBAR 2>&1 | FileCheck %s --check-prefix=NullDerefTestExactPath
NullDerefTestExactPath: Test unit written to FOOBAR
RUN: not LLVMFuzzer-NullDerefOnEmptyTest -print_final_stats=1 2>&1 | FileCheck %s --check-prefix=NULL_DEREF_ON_EMPTY
NULL_DEREF_ON_EMPTY: stat::number_of_executed_units:
#not LLVMFuzzer-FullCoverageSetTest -timeout=15 -seed=1 -mutate_depth=2 -use_full_coverage_set=1 2>&1 | FileCheck %s
RUN: not LLVMFuzzer-CounterTest -max_len=6 -seed=1 -timeout=15 2>&1 | FileCheck %s --check-prefix=COUNTERS
COUNTERS: INITED {{.*}} {{bits:|ft:}}
COUNTERS: NEW {{.*}} {{bits:|ft:}} {{[1-9]*}}
COUNTERS: NEW {{.*}} {{bits:|ft:}} {{[1-9]*}}
COUNTERS: BINGO
# Don't run UninstrumentedTest for now since we build libFuzzer itself with asan.
DISABLED: not LLVMFuzzer-UninstrumentedTest-Uninstrumented 2>&1 | FileCheck %s --check-prefix=UNINSTRUMENTED
UNINSTRUMENTED: ERROR: __sanitizer_set_death_callback is not defined. Exiting.
RUN: not LLVMFuzzer-UninstrumentedTest-NoCoverage 2>&1 | FileCheck %s --check-prefix=NO_COVERAGE
NO_COVERAGE: ERROR: no interesting inputs were found. Is the code instrumented for coverage? Exiting
RUN: not LLVMFuzzer-BufferOverflowOnInput 2>&1 | FileCheck %s --check-prefix=OOB
OOB: AddressSanitizer: heap-buffer-overflow
OOB: is located 0 bytes to the right of 3-byte region
RUN: not LLVMFuzzer-InitializeTest -use_value_profile=1 2>&1 | FileCheck %s
RUN: not LLVMFuzzer-DSOTest 2>&1 | FileCheck %s --check-prefix=DSO
DSO: INFO: Loaded 3 modules
DSO: BINGO
RUN: LLVMFuzzer-SimpleTest -exit_on_src_pos=SimpleTest.cpp:17 2>&1 | FileCheck %s --check-prefix=EXIT_ON_SRC_POS
RUN: LLVMFuzzer-ShrinkControlFlowTest -exit_on_src_pos=ShrinkControlFlowTest.cpp:23 2>&1 | FileCheck %s --check-prefix=EXIT_ON_SRC_POS
EXIT_ON_SRC_POS: INFO: found line matching '{{.*}}', exiting.
RUN: ASAN_OPTIONS=strict_string_checks=1 not LLVMFuzzer-StrncmpOOBTest -seed=1 -runs=1000000 2>&1 | FileCheck %s --check-prefix=STRNCMP
STRNCMP: AddressSanitizer: heap-buffer-overflow
STRNCMP-NOT: __sanitizer_weak_hook_strncmp
STRNCMP: in LLVMFuzzerTestOneInput
| {
"pile_set_name": "Github"
} |
/**
* Use the sieve of eratosthenes to find all the prime numbers up to a certain limit.
*
* <p>Time Complexity: O(nloglogn)
*
* @author William Fiset, [email protected]
*/
package com.williamfiset.algorithms.math;
public class SieveOfEratosthenes {
// Gets all primes up to, but NOT including limit (returned as a list of primes)
public static int[] sieve(int limit) {
if (limit <= 2) return new int[0];
// Find an upper bound on the number of prime numbers up to our limit.
// https://en.wikipedia.org/wiki/Prime-counting_function#Inequalities
final int numPrimes = (int) (1.25506 * limit / Math.log((double) limit));
int[] primes = new int[numPrimes];
int index = 0;
boolean[] isComposite = new boolean[limit];
final int sqrtLimit = (int) Math.sqrt(limit);
for (int i = 2; i <= sqrtLimit; i++) {
if (!isComposite[i]) {
primes[index++] = i;
for (int j = i * i; j < limit; j += i) isComposite[j] = true;
}
}
for (int i = sqrtLimit + 1; i < limit; i++) if (!isComposite[i]) primes[index++] = i;
return java.util.Arrays.copyOf(primes, index);
}
public static void main(String[] args) {
// Generate all the primes up to 29 not inclusive
int[] primes = sieve(29);
// Prints [2, 3, 5, 7, 11, 13, 17, 19, 23]
System.out.println(java.util.Arrays.toString(primes));
}
}
| {
"pile_set_name": "Github"
} |
if (process.env.npm_package_name === 'pseudomap' &&
process.env.npm_lifecycle_script === 'test')
process.env.TEST_PSEUDOMAP = 'true'
if (typeof Map === 'function' && !process.env.TEST_PSEUDOMAP) {
module.exports = Map
} else {
module.exports = require('./pseudomap')
}
| {
"pile_set_name": "Github"
} |
angular
.module('walletDirectives')
.directive('downloadButton', downloadButton);
function downloadButton ($window, $timeout) {
const directive = {
restrict: 'E',
replace: true,
scope: {
filename: '@',
content: '='
},
template: '<a href="{{dataRef}}" download="{{filename}}" rel="noopener noreferrer">{{::"DOWNLOAD"|translate}}</a>',
link: link
};
return directive;
function link (scope, attr, elem) {
const BYTE_ORDER_MARKER_UTF8 = '\uFEFF';
scope.createDataUri = (data) => (
`data:text/plain;charset=utf-8,${encodeURIComponent(data)}`
);
scope.$watch('content', (content) => {
scope.dataRef = scope.createDataUri(BYTE_ORDER_MARKER_UTF8 + content);
});
scope.$on('download', (event) => {
if (!scope.dataRef) return;
$timeout(() => elem.$$element[0].click());
});
}
}
| {
"pile_set_name": "Github"
} |
<?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_COMPONENT . '/models/category.php';
/**
* HTML Contact View class for the Contact component
*
* @since 1.5
*/
class ContactViewContact extends JViewLegacy
{
/**
* The item model state
*
* @var \Joomla\Registry\Registry
* @since 1.6
*/
protected $state;
/**
* The form object for the contact item
*
* @var JForm
* @since 1.6
*/
protected $form;
/**
* The item object details
*
* @var JObject
* @since 1.6
*/
protected $item;
/**
* The page to return to on sumission
*
* @var string
* @since 1.6
* @deprecated 4.0 Variable not used
*/
protected $return_page;
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise a Error object.
*/
public function display($tpl = null)
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$state = $this->get('State');
$item = $this->get('Item');
$this->form = $this->get('Form');
// Get the parameters
$params = JComponentHelper::getParams('com_contact');
if ($item)
{
// If we found an item, merge the item parameters
$params->merge($item->params);
// Get Category Model data
$categoryModel = JModelLegacy::getInstance('Category', 'ContactModel', array('ignore_request' => true));
$categoryModel->setState('category.id', $item->catid);
$categoryModel->setState('list.ordering', 'a.name');
$categoryModel->setState('list.direction', 'asc');
$categoryModel->setState('filter.published', 1);
$contacts = $categoryModel->getItems();
}
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
// Check if access is not public
$groups = $user->getAuthorisedViewLevels();
$return = '';
if ((!in_array($item->access, $groups)) || (!in_array($item->category_access, $groups)))
{
JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
$options['category_id'] = $item->catid;
$options['order by'] = 'a.default_con DESC, a.ordering ASC';
// Handle email cloaking
if ($item->email_to && $params->get('show_email'))
{
$item->email_to = JHtml::_('email.cloak', $item->email_to);
}
if ($params->get('show_street_address') || $params->get('show_suburb') || $params->get('show_state')
|| $params->get('show_postcode') || $params->get('show_country'))
{
if (!empty ($item->address) || !empty ($item->suburb) || !empty ($item->state) || !empty ($item->country) || !empty ($item->postcode))
{
$params->set('address_check', 1);
}
}
else
{
$params->set('address_check', 0);
}
// Manage the display mode for contact detail groups
switch ($params->get('contact_icons'))
{
case 1 :
// Text
$params->set('marker_address', JText::_('COM_CONTACT_ADDRESS') . ": ");
$params->set('marker_email', JText::_('JGLOBAL_EMAIL') . ": ");
$params->set('marker_telephone', JText::_('COM_CONTACT_TELEPHONE') . ": ");
$params->set('marker_fax', JText::_('COM_CONTACT_FAX') . ": ");
$params->set('marker_mobile', JText::_('COM_CONTACT_MOBILE') . ": ");
$params->set('marker_misc', JText::_('COM_CONTACT_OTHER_INFORMATION') . ": ");
$params->set('marker_class', 'jicons-text');
break;
case 2 :
// None
$params->set('marker_address', '');
$params->set('marker_email', '');
$params->set('marker_telephone', '');
$params->set('marker_mobile', '');
$params->set('marker_fax', '');
$params->set('marker_misc', '');
$params->set('marker_class', 'jicons-none');
break;
default :
if ($params->get('icon_address'))
{
$image1 = JHtml::_('image', $params->get('icon_address', 'con_address.png'), JText::_('COM_CONTACT_ADDRESS') . ": ", null, false);
}
else
{
$image1 = JHtml::_('image', 'contacts/' . $params->get('icon_address', 'con_address.png'), JText::_('COM_CONTACT_ADDRESS') . ": ", null, true);
}
if ($params->get('icon_email'))
{
$image2 = JHtml::_('image', $params->get('icon_email', 'emailButton.png'), JText::_('JGLOBAL_EMAIL') . ": ", null, false);
}
else
{
$image2 = JHtml::_('image', 'contacts/' . $params->get('icon_email', 'emailButton.png'), JText::_('JGLOBAL_EMAIL') . ": ", null, true);
}
if ($params->get('icon_telephone'))
{
$image3 = JHtml::_('image', $params->get('icon_telephone', 'con_tel.png'), JText::_('COM_CONTACT_TELEPHONE') . ": ", null, false);
}
else
{
$image3 = JHtml::_('image', 'contacts/' . $params->get('icon_telephone', 'con_tel.png'), JText::_('COM_CONTACT_TELEPHONE') . ": ", null, true);
}
if ($params->get('icon_fax'))
{
$image4 = JHtml::_('image', $params->get('icon_fax', 'con_fax.png'), JText::_('COM_CONTACT_FAX') . ": ", null, false);
}
else
{
$image4 = JHtml::_('image', 'contacts/' . $params->get('icon_fax', 'con_fax.png'), JText::_('COM_CONTACT_FAX') . ": ", null, true);
}
if ($params->get('icon_misc'))
{
$image5 = JHtml::_('image', $params->get('icon_misc', 'con_info.png'), JText::_('COM_CONTACT_OTHER_INFORMATION') . ": ", null, false);
}
else
{
$image5 = JHtml::_(
'image',
'contacts/' . $params->get('icon_misc', 'con_info.png'),
JText::_('COM_CONTACT_OTHER_INFORMATION') . ": ", null, true
);
}
if ($params->get('icon_mobile'))
{
$image6 = JHtml::_('image', $params->get('icon_mobile', 'con_mobile.png'), JText::_('COM_CONTACT_MOBILE') . ": ", null, false);
}
else
{
$image6 = JHtml::_('image', 'contacts/' . $params->get('icon_mobile', 'con_mobile.png'), JText::_('COM_CONTACT_MOBILE') . ": ", null, true);
}
$params->set('marker_address', $image1);
$params->set('marker_email', $image2);
$params->set('marker_telephone', $image3);
$params->set('marker_fax', $image4);
$params->set('marker_misc', $image5);
$params->set('marker_mobile', $image6);
$params->set('marker_class', 'jicons-icons');
break;
}
// Add links to contacts
if ($params->get('show_contact_list') && count($contacts) > 1)
{
foreach ($contacts as &$contact)
{
$contact->link = JRoute::_(ContactHelperRoute::getContactRoute($contact->slug, $contact->catid));
}
$item->link = JRoute::_(ContactHelperRoute::getContactRoute($item->slug, $item->catid));
}
// Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$this->contact = &$item;
$this->params = &$params;
$this->return = &$return;
$this->state = &$state;
$this->item = &$item;
$this->user = &$user;
$this->contacts = &$contacts;
$item->tags = new JHelperTags;
$item->tags->getItemTags('com_contact.contact', $this->item->id);
// Override the layout only if this is not the active menu item
// If it is the active menu item, then the view and item id will match
$active = $app->getMenu()->getActive();
if ((!$active) || ((strpos($active->link, 'view=contact') === false) || (strpos($active->link, '&id=' . (string) $this->item->id) === false)))
{
if ($layout = $params->get('contact_layout'))
{
$this->setLayout($layout);
}
}
elseif (isset($active->query['layout']))
{
// We need to set the layout in case this is an alternative menu item (with an alternative layout)
$this->setLayout($active->query['layout']);
}
$model = $this->getModel();
$model->hit();
$this->_prepareDocument();
return parent::display($tpl);
}
/**
* Prepares the document
*
* @return void
*/
protected function _prepareDocument()
{
$app = JFactory::getApplication();
$menus = $app->getMenu();
$pathway = $app->getPathway();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if ($menu)
{
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
}
else
{
$this->params->def('page_heading', JText::_('COM_CONTACT_DEFAULT_PAGE_TITLE'));
}
$title = $this->params->get('page_title', '');
$id = (int) @$menu->query['id'];
// If the menu item does not concern this contact
if ($menu && ($menu->query['option'] != 'com_contact' || $menu->query['view'] != 'contact' || $id != $this->item->id))
{
// If this is not a single contact menu item, set the page title to the contact title
if ($this->item->name)
{
$title = $this->item->name;
}
$path = array(array('title' => $this->contact->name, 'link' => ''));
$category = JCategories::getInstance('Contact')->get($this->contact->catid);
while ($category && ($menu->query['option'] != 'com_contact' || $menu->query['view'] == 'contact' || $id != $category->id) && $category->id > 1)
{
$path[] = array('title' => $category->title, 'link' => ContactHelperRoute::getCategoryRoute($this->contact->catid));
$category = $category->getParent();
}
$path = array_reverse($path);
foreach ($path as $item)
{
$pathway->addItem($item['title'], $item['link']);
}
}
if (empty($title))
{
$title = $app->get('sitename');
}
elseif ($app->get('sitename_pagetitles', 0) == 1)
{
$title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title);
}
elseif ($app->get('sitename_pagetitles', 0) == 2)
{
$title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename'));
}
if (empty($title))
{
$title = $this->item->name;
}
$this->document->setTitle($title);
if ($this->item->metadesc)
{
$this->document->setDescription($this->item->metadesc);
}
elseif ($this->params->get('menu-meta_description'))
{
$this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->item->metakey)
{
$this->document->setMetadata('keywords', $this->item->metakey);
}
elseif ($this->params->get('menu-meta_keywords'))
{
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots'))
{
$this->document->setMetadata('robots', $this->params->get('robots'));
}
$mdata = $this->item->metadata->toArray();
foreach ($mdata as $k => $v)
{
if ($v)
{
$this->document->setMetadata($k, $v);
}
}
}
}
| {
"pile_set_name": "Github"
} |
// validator: no-self-include
/*
vc_crt_fix_ulink.cpp
Workaround for Visual C++ CRT incompatibility with old Windows versions (ulink version)
*/
/*
Copyright © 2010 Far Group
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "disable_warnings_in_std_begin.hpp"
#include <windows.h>
#include "disable_warnings_in_std_end.hpp"
#include <delayimp.h>
//----------------------------------------------------------------------------
static LPVOID WINAPI no_recode_pointer(LPVOID p)
{
return p;
}
//----------------------------------------------------------------------------
static void WINAPI sim_InitializeSListHead(PSLIST_HEADER ListHead)
{
((LPDWORD)ListHead)[1] = ((LPDWORD)ListHead)[0] = 0;
}
//----------------------------------------------------------------------------
static BOOL WINAPI sim_GetModuleHandleExW(DWORD flg, LPCWSTR name, HMODULE* pm)
{
// GET_MODULE_HANDLE_EX_FLAG_PIN not implemented (and unneeded)
HMODULE hm;
wchar_t buf[MAX_PATH];
*pm = NULL; // prepare to any return's
if(flg & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS) {
MEMORY_BASIC_INFORMATION mbi;
if(!VirtualQuery(name, &mbi, sizeof(mbi))) return FALSE;
hm = (HMODULE)mbi.AllocationBase;
if(flg & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT) goto done;
if(!GetModuleFileNameW(hm, buf, ARRAYSIZE(buf))) return FALSE;
name = buf;
} else if(flg & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT) {
hm = GetModuleHandleW(name);
goto done;
}
hm = LoadLibraryW(name);
done:
return (*pm = hm) != NULL;
}
//----------------------------------------------------------------------------
static FARPROC WINAPI delayFailureHook(/*dliNotification*/unsigned dliNotify,
PDelayLoadInfo pdli)
{
if( dliNotify == /*dliFailGetProcAddress*/dliFailGetProc
&& pdli && pdli->cb == sizeof(*pdli)
&& pdli->hmodCur == GetModuleHandleA("kernel32")
&& pdli->dlp.fImportByName && pdli->dlp.szProcName)
{
#if _MSC_FULL_VER >= 191326128 // VS2017.6
#pragma warning(disable: 4191) // unsafe conversion from...to
#endif
if( !lstrcmpA(pdli->dlp.szProcName, "EncodePointer")
|| !lstrcmpA(pdli->dlp.szProcName, "DecodePointer"))
{
return (FARPROC)no_recode_pointer;
}
if(!lstrcmpA(pdli->dlp.szProcName, "InitializeSListHead"))
return (FARPROC)sim_InitializeSListHead;
if(!lstrcmpA(pdli->dlp.szProcName, "GetModuleHandleExW"))
return (FARPROC)sim_GetModuleHandleExW;
}
return nullptr;
}
//----------------------------------------------------------------------------
#if _MSC_FULL_VER >= 190024215 // VS2015sp3
const
#endif
PfnDliHook __pfnDliFailureHook2 = (PfnDliHook)delayFailureHook;
//----------------------------------------------------------------------------
// TODO: Add GetModuleHandleExW
| {
"pile_set_name": "Github"
} |
{
"DESCRIPTION": "Shows information about the server!",
"USAGE": "{{prefix}}serverinfo [ID/Name]",
"EXAMPLES": "{{prefix}}serverinfo Atlanta\n{{prefix}}serverinfo",
"AFK_CHANNEL": "AFK channel",
"NO_AFK_CHANNEL": "No AFK channel",
"MEMBERS": "{{count}} members",
"BOTS": "{{count}} bots",
"BOOSTS": "Boosts count",
"TEXT_CHANNELS": "{{count}} text",
"VOICE_CHANNELS": "{{count}} voice",
"CAT_CHANNELS": "{{count}} categories"
} | {
"pile_set_name": "Github"
} |
# This file should be placed in the root directory of your project.
# Then modify the CMakeLists.txt file in the root directory of your
# project to incorporate the testing dashboard.
#
# # The following are required to submit to the CDash dashboard:
# ENABLE_TESTING()
# INCLUDE(CTest)
set(CTEST_PROJECT_NAME "Bareos")
set(CTEST_NIGHTLY_START_TIME "23:00:00 CET")
set(CTEST_DROP_METHOD "https")
set(CTEST_DROP_SITE "cdash.bareos.org")
set(CTEST_DROP_LOCATION "/submit.php?project=Bareos")
set(CTEST_DROP_SITE_CDASH TRUE)
| {
"pile_set_name": "Github"
} |
Scenario(887):
description: "Route table: support whitespace in URL path"
interactions:
- description: test
request:
get: "gh 887"
response:
text: 887
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>echonest.remix.support.midi.constants</title>
<link rel="stylesheet" href="epydoc.css" type="text/css" />
<script type="text/javascript" src="epydoc.js"></script>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
><a class="navbar" target="_top" href="https://github.com/echonest/remix/">Project Homepage</a></th>
</tr></table></th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<span class="breadcrumbs">
Package echonest ::
<a href="echonest.remix-module.html">Package remix</a> ::
<a href="echonest.remix.support-module.html">Package support</a> ::
<a href="echonest.remix.support.midi-module.html">Package midi</a> ::
Module constants
</span>
</td>
<td>
<table cellpadding="0" cellspacing="0">
<!-- hide/show private -->
<tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
onclick="toggle_private();">hide private</a>]</span></td></tr>
<tr><td align="right"><span class="options"
>[<a href="frames.html" target="_top">frames</a
>] | <a href="echonest.remix.support.midi.constants-module.html"
target="_top">no frames</a>]</span></td></tr>
</table>
</td>
</tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module constants</h1><p class="nomargin-top"><span class="codelink"><a href="echonest.remix.support.midi.constants-pysrc.html">source code</a></span></p>
<!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td colspan="2" class="table-header">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td align="left"><span class="table-header">Functions</span></td>
<td align="right" valign="top"
><span class="options">[<a href="#section-Functions"
class="privatelink" onclick="toggle_private();"
>hide private</a>]</span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a name="is_status"></a><span class="summary-sig-name">is_status</span>(<span class="summary-sig-arg">byte</span>)</span></td>
<td align="right" valign="top">
<span class="codelink"><a href="echonest.remix.support.midi.constants-pysrc.html#is_status">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td colspan="2" class="table-header">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td align="left"><span class="table-header">Variables</span></td>
<td align="right" valign="top"
><span class="options">[<a href="#section-Variables"
class="privatelink" onclick="toggle_private();"
>hide private</a>]</span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="NOTE_OFF"></a><span class="summary-name">NOTE_OFF</span> = <code title="128">128</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="NOTE_ON"></a><span class="summary-name">NOTE_ON</span> = <code title="144">144</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="AFTERTOUCH"></a><span class="summary-name">AFTERTOUCH</span> = <code title="160">160</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="CONTINUOUS_CONTROLLER"></a><span class="summary-name">CONTINUOUS_CONTROLLER</span> = <code title="176">176</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="PATCH_CHANGE"></a><span class="summary-name">PATCH_CHANGE</span> = <code title="192">192</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="CHANNEL_PRESSURE"></a><span class="summary-name">CHANNEL_PRESSURE</span> = <code title="208">208</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="PITCH_BEND"></a><span class="summary-name">PITCH_BEND</span> = <code title="224">224</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="GEN_PURPOSE_CONTROLLER_1"></a><span class="summary-name">GEN_PURPOSE_CONTROLLER_1</span> = <code title="16">16</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="GEN_PURPOSE_CONTROLLER_2"></a><span class="summary-name">GEN_PURPOSE_CONTROLLER_2</span> = <code title="17">17</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="GEN_PURPOSE_CONTROLLER_3"></a><span class="summary-name">GEN_PURPOSE_CONTROLLER_3</span> = <code title="18">18</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="GEN_PURPOSE_CONTROLLER_4"></a><span class="summary-name">GEN_PURPOSE_CONTROLLER_4</span> = <code title="19">19</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="BANK_SELECT"></a><span class="summary-name">BANK_SELECT</span> = <code title="32">32</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="MODULATION_WHEEL"></a><span class="summary-name">MODULATION_WHEEL</span> = <code title="33">33</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="BREATH_CONTROLLER"></a><span class="summary-name">BREATH_CONTROLLER</span> = <code title="34">34</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="FOOT_CONTROLLER"></a><span class="summary-name">FOOT_CONTROLLER</span> = <code title="36">36</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="PORTAMENTO_TIME"></a><span class="summary-name">PORTAMENTO_TIME</span> = <code title="37">37</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="DATA_ENTRY"></a><span class="summary-name">DATA_ENTRY</span> = <code title="38">38</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="CHANNEL_VOLUME"></a><span class="summary-name">CHANNEL_VOLUME</span> = <code title="39">39</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="BALANCE"></a><span class="summary-name">BALANCE</span> = <code title="40">40</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="PAN"></a><span class="summary-name">PAN</span> = <code title="42">42</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="EXPRESSION_CONTROLLER"></a><span class="summary-name">EXPRESSION_CONTROLLER</span> = <code title="43">43</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="EFFECT_CONTROL_1"></a><span class="summary-name">EFFECT_CONTROL_1</span> = <code title="44">44</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="EFFECT_CONTROL_2"></a><span class="summary-name">EFFECT_CONTROL_2</span> = <code title="45">45</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="GENERAL_PURPOSE_CONTROLLER_1"></a><span class="summary-name">GENERAL_PURPOSE_CONTROLLER_1</span> = <code title="48">48</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="GENERAL_PURPOSE_CONTROLLER_2"></a><span class="summary-name">GENERAL_PURPOSE_CONTROLLER_2</span> = <code title="49">49</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="GENERAL_PURPOSE_CONTROLLER_3"></a><span class="summary-name">GENERAL_PURPOSE_CONTROLLER_3</span> = <code title="50">50</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="GENERAL_PURPOSE_CONTROLLER_4"></a><span class="summary-name">GENERAL_PURPOSE_CONTROLLER_4</span> = <code title="51">51</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SUSTAIN_ONOFF"></a><span class="summary-name">SUSTAIN_ONOFF</span> = <code title="64">64</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="PORTAMENTO_ONOFF"></a><span class="summary-name">PORTAMENTO_ONOFF</span> = <code title="65">65</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SOSTENUTO_ONOFF"></a><span class="summary-name">SOSTENUTO_ONOFF</span> = <code title="66">66</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SOFT_PEDAL_ONOFF"></a><span class="summary-name">SOFT_PEDAL_ONOFF</span> = <code title="67">67</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="LEGATO_ONOFF"></a><span class="summary-name">LEGATO_ONOFF</span> = <code title="68">68</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="HOLD_2_ONOFF"></a><span class="summary-name">HOLD_2_ONOFF</span> = <code title="69">69</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SOUND_CONTROLLER_1"></a><span class="summary-name">SOUND_CONTROLLER_1</span> = <code title="70">70</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SOUND_CONTROLLER_2"></a><span class="summary-name">SOUND_CONTROLLER_2</span> = <code title="71">71</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SOUND_CONTROLLER_3"></a><span class="summary-name">SOUND_CONTROLLER_3</span> = <code title="72">72</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SOUND_CONTROLLER_4"></a><span class="summary-name">SOUND_CONTROLLER_4</span> = <code title="73">73</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SOUND_CONTROLLER_5"></a><span class="summary-name">SOUND_CONTROLLER_5</span> = <code title="74">74</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SOUND_CONTROLLER_7"></a><span class="summary-name">SOUND_CONTROLLER_7</span> = <code title="76">76</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SOUND_CONTROLLER_8"></a><span class="summary-name">SOUND_CONTROLLER_8</span> = <code title="77">77</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SOUND_CONTROLLER_9"></a><span class="summary-name">SOUND_CONTROLLER_9</span> = <code title="78">78</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SOUND_CONTROLLER_10"></a><span class="summary-name">SOUND_CONTROLLER_10</span> = <code title="79">79</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="GENERAL_PURPOSE_CONTROLLER_5"></a><span class="summary-name">GENERAL_PURPOSE_CONTROLLER_5</span> = <code title="80">80</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="GENERAL_PURPOSE_CONTROLLER_6"></a><span class="summary-name">GENERAL_PURPOSE_CONTROLLER_6</span> = <code title="81">81</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="GENERAL_PURPOSE_CONTROLLER_7"></a><span class="summary-name">GENERAL_PURPOSE_CONTROLLER_7</span> = <code title="82">82</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="GENERAL_PURPOSE_CONTROLLER_8"></a><span class="summary-name">GENERAL_PURPOSE_CONTROLLER_8</span> = <code title="83">83</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="PORTAMENTO_CONTROL"></a><span class="summary-name">PORTAMENTO_CONTROL</span> = <code title="84">84</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="EFFECTS_1"></a><span class="summary-name">EFFECTS_1</span> = <code title="91">91</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="EFFECTS_2"></a><span class="summary-name">EFFECTS_2</span> = <code title="92">92</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="EFFECTS_3"></a><span class="summary-name">EFFECTS_3</span> = <code title="93">93</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="EFFECTS_4"></a><span class="summary-name">EFFECTS_4</span> = <code title="94">94</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="EFFECTS_5"></a><span class="summary-name">EFFECTS_5</span> = <code title="95">95</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="DATA_INCREMENT"></a><span class="summary-name">DATA_INCREMENT</span> = <code title="96">96</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="DATA_DECREMENT"></a><span class="summary-name">DATA_DECREMENT</span> = <code title="97">97</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="NON_REGISTERED_PARAMETER_NUMBER"></a><span class="summary-name">NON_REGISTERED_PARAMETER_NUMBER</span> = <code title="99">99</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="REGISTERED_PARAMETER_NUMBER"></a><span class="summary-name">REGISTERED_PARAMETER_NUMBER</span> = <code title="101">101</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="ALL_SOUND_OFF"></a><span class="summary-name">ALL_SOUND_OFF</span> = <code title="120">120</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="RESET_ALL_CONTROLLERS"></a><span class="summary-name">RESET_ALL_CONTROLLERS</span> = <code title="121">121</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="LOCAL_CONTROL_ONOFF"></a><span class="summary-name">LOCAL_CONTROL_ONOFF</span> = <code title="122">122</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="ALL_NOTES_OFF"></a><span class="summary-name">ALL_NOTES_OFF</span> = <code title="123">123</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="OMNI_MODE_OFF"></a><span class="summary-name">OMNI_MODE_OFF</span> = <code title="124">124</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="OMNI_MODE_ON"></a><span class="summary-name">OMNI_MODE_ON</span> = <code title="125">125</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="MONO_MODE_ON"></a><span class="summary-name">MONO_MODE_ON</span> = <code title="126">126</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="POLY_MODE_ON"></a><span class="summary-name">POLY_MODE_ON</span> = <code title="127">127</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SYSTEM_EXCLUSIVE"></a><span class="summary-name">SYSTEM_EXCLUSIVE</span> = <code title="240">240</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="MTC"></a><span class="summary-name">MTC</span> = <code title="241">241</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SONG_POSITION_POINTER"></a><span class="summary-name">SONG_POSITION_POINTER</span> = <code title="242">242</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SONG_SELECT"></a><span class="summary-name">SONG_SELECT</span> = <code title="243">243</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="TUNING_REQUEST"></a><span class="summary-name">TUNING_REQUEST</span> = <code title="246">246</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="END_OFF_EXCLUSIVE"></a><span class="summary-name">END_OFF_EXCLUSIVE</span> = <code title="247">247</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SEQUENCE_NUMBER"></a><span class="summary-name">SEQUENCE_NUMBER</span> = <code title="0">0</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="TEXT"></a><span class="summary-name">TEXT</span> = <code title="1">1</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="COPYRIGHT"></a><span class="summary-name">COPYRIGHT</span> = <code title="2">2</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SEQUENCE_NAME"></a><span class="summary-name">SEQUENCE_NAME</span> = <code title="3">3</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="INSTRUMENT_NAME"></a><span class="summary-name">INSTRUMENT_NAME</span> = <code title="4">4</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="LYRIC"></a><span class="summary-name">LYRIC</span> = <code title="5">5</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="MARKER"></a><span class="summary-name">MARKER</span> = <code title="6">6</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="CUEPOINT"></a><span class="summary-name">CUEPOINT</span> = <code title="7">7</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="PROGRAM_NAME"></a><span class="summary-name">PROGRAM_NAME</span> = <code title="8">8</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="DEVICE_NAME"></a><span class="summary-name">DEVICE_NAME</span> = <code title="9">9</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="MIDI_CH_PREFIX"></a><span class="summary-name">MIDI_CH_PREFIX</span> = <code title="32">32</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="MIDI_PORT"></a><span class="summary-name">MIDI_PORT</span> = <code title="33">33</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="END_OF_TRACK"></a><span class="summary-name">END_OF_TRACK</span> = <code title="47">47</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="TEMPO"></a><span class="summary-name">TEMPO</span> = <code title="81">81</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SMTP_OFFSET"></a><span class="summary-name">SMTP_OFFSET</span> = <code title="84">84</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="TIME_SIGNATURE"></a><span class="summary-name">TIME_SIGNATURE</span> = <code title="88">88</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="KEY_SIGNATURE"></a><span class="summary-name">KEY_SIGNATURE</span> = <code title="89">89</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SPECIFIC"></a><span class="summary-name">SPECIFIC</span> = <code title="127">127</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="FILE_HEADER"></a><span class="summary-name">FILE_HEADER</span> = <code title="'MThd'"><code class="variable-quote">'</code><code class="variable-string">MThd</code><code class="variable-quote">'</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="TRACK_HEADER"></a><span class="summary-name">TRACK_HEADER</span> = <code title="'MTrk'"><code class="variable-quote">'</code><code class="variable-string">MTrk</code><code class="variable-quote">'</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="TIMING_CLOCK"></a><span class="summary-name">TIMING_CLOCK</span> = <code title="248">248</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SONG_START"></a><span class="summary-name">SONG_START</span> = <code title="250">250</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SONG_CONTINUE"></a><span class="summary-name">SONG_CONTINUE</span> = <code title="251">251</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SONG_STOP"></a><span class="summary-name">SONG_STOP</span> = <code title="252">252</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="ACTIVE_SENSING"></a><span class="summary-name">ACTIVE_SENSING</span> = <code title="254">254</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="SYSTEM_RESET"></a><span class="summary-name">SYSTEM_RESET</span> = <code title="255">255</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="META_EVENT"></a><span class="summary-name">META_EVENT</span> = <code title="255">255</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="__package__"></a><span class="summary-name">__package__</span> = <code title="None">None</code><br />
hash(x)
</td>
</tr>
</table>
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
><a class="navbar" target="_top" href="https://github.com/echonest/remix/">Project Homepage</a></th>
</tr></table></th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Wed Dec 12 11:24:19 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
>http://epydoc.sourceforge.net</a>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
// Private objects are initially displayed (because if
// javascript is turned off then we want them to be
// visible); but by default, we want to hide them. So hide
// them unless we have a cookie that says to show them.
checkCookie();
// -->
</script>
</body>
</html>
| {
"pile_set_name": "Github"
} |
// ******************************************************************
// *
// * This file is part of the Cxbx project.
// *
// * Cxbx and Cxbe are free software; you can redistribute them
// * and/or modify them 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 recieved a copy of the GNU General Public License
// * along with this program; see the file COPYING.
// * If not, write to the Free Software Foundation, Inc.,
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
// *
// * (c) 2002-2003 Aaron Robinson <[email protected]>
// *
// * All rights reserved
// *
// ******************************************************************
#include "Cxbx.h"
#include "EmuShared.h"
#include "CxbxDebugger.h"
// Note this implementation uses SEH. See the reference docs for RaiseException:
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680552(v=vs.85).aspx
namespace CxbxDebugger
{
namespace Internal
{
// Note: Keep the top 3-bits empty as they are used internally
enum ReportType : DWORD
{
// Debugger report codes:
HLECACHE_FILE = 0x00deed00,
KERNEL_PATCH = 0x00deed01,
FILE_OPENED = 0x00deed02,
FILE_READ = 0x00deed03,
FILE_CLOSED = 0x00deed04,
DEBUGGER_INIT = 0x00deed05,
FILE_WRITE = 0x00deed06,
// Debugger query codes:
OVERRIDE_EXCEPTION = 0x00ceed01,
};
bool IsAttached()
{
bool IsDebugging;
g_EmuShared->GetDebuggingFlag(&IsDebugging);
return IsDebugging && IsDebuggerPresent() == TRUE;
}
class ReportHelper
{
ReportType ExceptionCode;
ULONG_PTR ExceptionInfo[EXCEPTION_MAXIMUM_PARAMETERS];
DWORD ExceptionInfoCount;
ReportHelper() = delete;
ReportHelper(const ReportHelper&) = delete;
enum StringType : DWORD
{
STRING_CHAR,
STRING_WCHAR,
};
public:
ReportHelper(ReportType Code)
: ExceptionCode(Code)
, ExceptionInfoCount(0)
{ }
void Send()
{
if (ExceptionInfoCount > 0)
{
RaiseException(ExceptionCode, 0, ExceptionInfoCount, (ULONG_PTR*)ExceptionInfo);
}
else
{
RaiseException(ExceptionCode, 0, 0, nullptr);
}
}
template<typename T>
void Add(T Param)
{
if (ExceptionInfoCount + 1 < EXCEPTION_MAXIMUM_PARAMETERS)
{
ExceptionInfo[ExceptionInfoCount] = (ULONG_PTR)Param;
++ExceptionInfoCount;
}
}
void AddString(const char* szString)
{
Add(STRING_CHAR);
Add(std::strlen(szString));
Add(szString);
}
void AddWString(const wchar_t* wszString)
{
Add(STRING_WCHAR);
Add(std::wcslen(wszString));
Add(wszString);
}
};
}
bool IsDebuggerException(DWORD ExceptionCode)
{
switch (ExceptionCode)
{
case Internal::HLECACHE_FILE:
case Internal::KERNEL_PATCH:
case Internal::FILE_OPENED:
case Internal::FILE_READ:
case Internal::FILE_CLOSED:
case Internal::DEBUGGER_INIT:
return true;
case Internal::OVERRIDE_EXCEPTION:
return false;
}
return false;
}
bool CanReport()
{
return Internal::IsAttached();
}
void ReportDebuggerInit(const char* XbeTitle)
{
Internal::ReportHelper Report(Internal::DEBUGGER_INIT);
Report.Add(0); // unused
Report.AddString(XbeTitle);
Report.Send();
}
void ReportHLECacheFile(const char* Filename)
{
Internal::ReportHelper Report(Internal::HLECACHE_FILE);
Report.AddString(Filename);
Report.Send();
}
void ReportKernelPatch(const char* ImportName, DWORD Address)
{
Internal::ReportHelper Report(Internal::KERNEL_PATCH);
Report.AddString(ImportName);
Report.Add(Address);
Report.Send();
}
void ReportFileOpened(HANDLE hFile, const wchar_t* Filename, bool Success)
{
Internal::ReportHelper Report(Internal::FILE_OPENED);
Report.Add(hFile);
Report.AddWString(Filename);
Report.Add(Success);
Report.Send();
}
void ReportFileRead(HANDLE hFile, unsigned int Size, uint64_t Offset)
{
Internal::ReportHelper Report(Internal::FILE_READ);
Report.Add(hFile);
Report.Add(Size);
Report.Add(static_cast<unsigned int>(Offset));
Report.Send();
}
void ReportFileWrite(HANDLE hFile, unsigned int Size, uint64_t Offset)
{
Internal::ReportHelper Report(Internal::FILE_WRITE);
Report.Add(hFile);
Report.Add(Size);
Report.Add(static_cast<unsigned int>(Offset));
Report.Send();
}
void ReportFileClosed(HANDLE hFile)
{
Internal::ReportHelper Report(Internal::FILE_CLOSED);
Report.Add(hFile);
Report.Send();
}
void ReportAndHandleException(PEXCEPTION_RECORD Exception, bool& Handled)
{
Internal::ReportHelper Report(Internal::OVERRIDE_EXCEPTION);
Report.Add(&Handled);
Report.Add(Exception->ExceptionAddress);
Report.Add(Exception->ExceptionCode);
Report.Add(Exception->NumberParameters);
Report.Add(&Exception->ExceptionInformation[0]);
Report.Send();
}
}
| {
"pile_set_name": "Github"
} |
# Building `sys/unix`
The sys/unix package provides access to the raw system call interface of the
underlying operating system. See: https://godoc.org/golang.org/x/sys/unix
Porting Go to a new architecture/OS combination or adding syscalls, types, or
constants to an existing architecture/OS pair requires some manual effort;
however, there are tools that automate much of the process.
## Build Systems
There are currently two ways we generate the necessary files. We are currently
migrating the build system to use containers so the builds are reproducible.
This is being done on an OS-by-OS basis. Please update this documentation as
components of the build system change.
### Old Build System (currently for `GOOS != "linux"`)
The old build system generates the Go files based on the C header files
present on your system. This means that files
for a given GOOS/GOARCH pair must be generated on a system with that OS and
architecture. This also means that the generated code can differ from system
to system, based on differences in the header files.
To avoid this, if you are using the old build system, only generate the Go
files on an installation with unmodified header files. It is also important to
keep track of which version of the OS the files were generated from (ex.
Darwin 14 vs Darwin 15). This makes it easier to track the progress of changes
and have each OS upgrade correspond to a single change.
To build the files for your current OS and architecture, make sure GOOS and
GOARCH are set correctly and run `mkall.sh`. This will generate the files for
your specific system. Running `mkall.sh -n` shows the commands that will be run.
Requirements: bash, go
### New Build System (currently for `GOOS == "linux"`)
The new build system uses a Docker container to generate the go files directly
from source checkouts of the kernel and various system libraries. This means
that on any platform that supports Docker, all the files using the new build
system can be generated at once, and generated files will not change based on
what the person running the scripts has installed on their computer.
The OS specific files for the new build system are located in the `${GOOS}`
directory, and the build is coordinated by the `${GOOS}/mkall.go` program. When
the kernel or system library updates, modify the Dockerfile at
`${GOOS}/Dockerfile` to checkout the new release of the source.
To build all the files under the new build system, you must be on an amd64/Linux
system and have your GOOS and GOARCH set accordingly. Running `mkall.sh` will
then generate all of the files for all of the GOOS/GOARCH pairs in the new build
system. Running `mkall.sh -n` shows the commands that will be run.
Requirements: bash, go, docker
## Component files
This section describes the various files used in the code generation process.
It also contains instructions on how to modify these files to add a new
architecture/OS or to add additional syscalls, types, or constants. Note that
if you are using the new build system, the scripts/programs cannot be called normally.
They must be called from within the docker container.
### asm files
The hand-written assembly file at `asm_${GOOS}_${GOARCH}.s` implements system
call dispatch. There are three entry points:
```
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
```
The first and second are the standard ones; they differ only in how many
arguments can be passed to the kernel. The third is for low-level use by the
ForkExec wrapper. Unlike the first two, it does not call into the scheduler to
let it know that a system call is running.
When porting Go to an new architecture/OS, this file must be implemented for
each GOOS/GOARCH pair.
### mksysnum
Mksysnum is a Go program located at `${GOOS}/mksysnum.go` (or `mksysnum_${GOOS}.go`
for the old system). This program takes in a list of header files containing the
syscall number declarations and parses them to produce the corresponding list of
Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated
constants.
Adding new syscall numbers is mostly done by running the build on a sufficiently
new installation of the target OS (or updating the source checkouts for the
new build system). However, depending on the OS, you make need to update the
parsing in mksysnum.
### mksyscall.go
The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are
hand-written Go files which implement system calls (for unix, the specific OS,
or the specific OS/Architecture pair respectively) that need special handling
and list `//sys` comments giving prototypes for ones that can be generated.
The mksyscall.go program takes the `//sys` and `//sysnb` comments and converts
them into syscalls. This requires the name of the prototype in the comment to
match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function
prototype can be exported (capitalized) or not.
Adding a new syscall often just requires adding a new `//sys` function prototype
with the desired arguments and a capitalized name so it is exported. However, if
you want the interface to the syscall to be different, often one will make an
unexported `//sys` prototype, an then write a custom wrapper in
`syscall_${GOOS}.go`.
### types files
For each OS, there is a hand-written Go file at `${GOOS}/types.go` (or
`types_${GOOS}.go` on the old system). This file includes standard C headers and
creates Go type aliases to the corresponding C types. The file is then fed
through godef to get the Go compatible definitions. Finally, the generated code
is fed though mkpost.go to format the code correctly and remove any hidden or
private identifiers. This cleaned-up code is written to
`ztypes_${GOOS}_${GOARCH}.go`.
The hardest part about preparing this file is figuring out which headers to
include and which symbols need to be `#define`d to get the actual data
structures that pass through to the kernel system calls. Some C libraries
preset alternate versions for binary compatibility and translate them on the
way in and out of system calls, but there is almost always a `#define` that can
get the real ones.
See `types_darwin.go` and `linux/types.go` for examples.
To add a new type, add in the necessary include statement at the top of the
file (if it is not already there) and add in a type alias line. Note that if
your type is significantly different on different architectures, you may need
some `#if/#elif` macros in your include statements.
### mkerrors.sh
This script is used to generate the system's various constants. This doesn't
just include the error numbers and error strings, but also the signal numbers
an a wide variety of miscellaneous constants. The constants come from the list
of include files in the `includes_${uname}` variable. A regex then picks out
the desired `#define` statements, and generates the corresponding Go constants.
The error numbers and strings are generated from `#include <errno.h>`, and the
signal numbers and strings are generated from `#include <signal.h>`. All of
these constants are written to `zerrors_${GOOS}_${GOARCH}.go` via a C program,
`_errors.c`, which prints out all the constants.
To add a constant, add the header that includes it to the appropriate variable.
Then, edit the regex (if necessary) to match the desired constant. Avoid making
the regex too broad to avoid matching unintended constants.
## Generated files
### `zerror_${GOOS}_${GOARCH}.go`
A file containing all of the system's generated error numbers, error strings,
signal numbers, and constants. Generated by `mkerrors.sh` (see above).
### `zsyscall_${GOOS}_${GOARCH}.go`
A file containing all the generated syscalls for a specific GOOS and GOARCH.
Generated by `mksyscall.go` (see above).
### `zsysnum_${GOOS}_${GOARCH}.go`
A list of numeric constants for all the syscall number of the specific GOOS
and GOARCH. Generated by mksysnum (see above).
### `ztypes_${GOOS}_${GOARCH}.go`
A file containing Go types for passing into (or returning from) syscalls.
Generated by godefs and the types file (see above).
| {
"pile_set_name": "Github"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.